vskill 0.5.140 → 0.5.142
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/eval/activation-tester.d.ts +5 -0
- package/dist/eval/activation-tester.js +25 -5
- package/dist/eval/activation-tester.js.map +1 -1
- package/dist/eval/test-case-parser.d.ts +8 -0
- package/dist/eval/test-case-parser.js +74 -0
- package/dist/eval/test-case-parser.js.map +1 -0
- package/dist/eval-server/api-routes.d.ts +35 -0
- package/dist/eval-server/api-routes.js +170 -6
- package/dist/eval-server/api-routes.js.map +1 -1
- package/dist/eval-server/skill-create-routes.d.ts +20 -0
- package/dist/eval-server/skill-create-routes.js +50 -2
- package/dist/eval-server/skill-create-routes.js.map +1 -1
- package/dist/eval-server/skill-dir-registry.d.ts +2 -14
- package/dist/eval-server/skill-dir-registry.js +18 -0
- package/dist/eval-server/skill-dir-registry.js.map +1 -1
- package/dist/eval-ui/assets/{CommandPalette-DeEo1aM2.js → CommandPalette-D42KauW9.js} +1 -1
- package/dist/eval-ui/assets/{CreateSkillPage-BGi_wZ1y.js → CreateSkillPage-BWoyQQ0n.js} +1 -1
- package/dist/eval-ui/assets/{FindSkillsPalette-BbJJSef2.js → FindSkillsPalette-BtyebylE.js} +2 -2
- package/dist/eval-ui/assets/{SearchPaletteCore-BK0cFJb6.js → SearchPaletteCore-9ObzwMtM.js} +1 -1
- package/dist/eval-ui/assets/{SkillDetailPanel-DxidXsNP.js → SkillDetailPanel-8XS9hdR_.js} +1 -1
- package/dist/eval-ui/assets/{UpdateDropdown-CcaDVKoz.js → UpdateDropdown-D0dHy9y-.js} +1 -1
- package/dist/eval-ui/assets/{index-ByzTygib.css → index-CycZyHaL.css} +1 -1
- package/dist/eval-ui/assets/index-DUUmBJUa.js +120 -0
- package/dist/eval-ui/index.html +2 -2
- package/dist/first-run-onboarding.d.ts +10 -0
- package/dist/first-run-onboarding.js +50 -3
- package/dist/first-run-onboarding.js.map +1 -1
- package/package.json +3 -2
- package/dist/eval-ui/assets/index-C12VKBb6.js +0 -110
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-D0dHy9y-.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-D42KauW9.js","assets/FindSkillsPalette-BtyebylE.js","assets/SkillDetailPanel-8XS9hdR_.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-BWoyQQ0n.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 Ev(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var xd={exports:{}},zs={};/**
|
|
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 L0(){if(Bx)return zs;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 zs.Fragment=a,zs.jsx=s,zs.jsxs=s,zs}var Ix;function z0(){return Ix||(Ix=1,xd.exports=L0()),xd.exports}var r=z0(),gd={exports:{}},Ue={};/**
|
|
11
|
+
* @license React
|
|
12
|
+
* react.production.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/var $x;function D0(){if($x)return Ue;$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"),v=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function S(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,E={};function T(z,W,re){this.props=z,this.context=W,this.refs=E,this.updater=re||k}T.prototype.isReactComponent={},T.prototype.setState=function(z,W){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,W,"setState")},T.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function N(){}N.prototype=T.prototype;function L(z,W,re){this.props=z,this.context=W,this.refs=E,this.updater=re||k}var _=L.prototype=new N;_.constructor=L,w(_,T.prototype),_.isPureReactComponent=!0;var D=Array.isArray;function V(){}var C={H:null,A:null,T:null,S:null},B=Object.prototype.hasOwnProperty;function M(z,W,re){var Y=re.ref;return{$$typeof:t,type:z,key:W,ref:Y!==void 0?Y:null,props:re}}function $(z,W){return M(z.type,W,z.props)}function U(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function q(z){var W={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(re){return W[re]})}var X=/\/+/g;function ee(z,W){return typeof z=="object"&&z!==null&&z.key!=null?q(""+z.key):W.toString(36)}function H(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(V,V):(z.status="pending",z.then(function(W){z.status==="pending"&&(z.status="fulfilled",z.value=W)},function(W){z.status==="pending"&&(z.status="rejected",z.reason=W)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function A(z,W,re,Y,ce){var se=typeof z;(se==="undefined"||se==="boolean")&&(z=null);var be=!1;if(z===null)be=!0;else switch(se){case"bigint":case"string":case"number":be=!0;break;case"object":switch(z.$$typeof){case t:case a:be=!0;break;case v:return be=z._init,A(be(z._payload),W,re,Y,ce)}}if(be)return ce=ce(z),be=Y===""?"."+ee(z,0):Y,D(ce)?(re="",be!=null&&(re=be.replace(X,"$&/")+"/"),A(ce,W,re,"",function(Re){return Re})):ce!=null&&(U(ce)&&(ce=$(ce,re+(ce.key==null||z&&z.key===ce.key?"":(""+ce.key).replace(X,"$&/")+"/")+be)),W.push(ce)),1;be=0;var ie=Y===""?".":Y+":";if(D(z))for(var ye=0;ye<z.length;ye++)Y=z[ye],se=ie+ee(Y,ye),be+=A(Y,W,re,se,ce);else if(ye=S(z),typeof ye=="function")for(z=ye.call(z),ye=0;!(Y=z.next()).done;)Y=Y.value,se=ie+ee(Y,ye++),be+=A(Y,W,re,se,ce);else if(se==="object"){if(typeof z.then=="function")return A(H(z),W,re,Y,ce);throw W=String(z),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return be}function I(z,W,re){if(z==null)return z;var Y=[],ce=0;return A(z,Y,"","",function(se){return W.call(re,se,ce++)}),Y}function G(z){if(z._status===-1){var W=z._result;W=W(),W.then(function(re){(z._status===0||z._status===-1)&&(z._status=1,z._result=re)},function(re){(z._status===0||z._status===-1)&&(z._status=2,z._result=re)}),z._status===-1&&(z._status=0,z._result=W)}if(z._status===1)return z._result.default;throw z._result}var O=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},ne={map:I,forEach:function(z,W,re){I(z,function(){W.apply(this,arguments)},re)},count:function(z){var W=0;return I(z,function(){W++}),W},toArray:function(z){return I(z,function(W){return W})||[]},only:function(z){if(!U(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return Ue.Activity=y,Ue.Children=ne,Ue.Component=T,Ue.Fragment=s,Ue.Profiler=c,Ue.PureComponent=L,Ue.StrictMode=i,Ue.Suspense=x,Ue.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,Ue.__COMPILER_RUNTIME={__proto__:null,c:function(z){return C.H.useMemoCache(z)}},Ue.cache=function(z){return function(){return z.apply(null,arguments)}},Ue.cacheSignal=function(){return null},Ue.cloneElement=function(z,W,re){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var Y=w({},z.props),ce=z.key;if(W!=null)for(se in W.key!==void 0&&(ce=""+W.key),W)!B.call(W,se)||se==="key"||se==="__self"||se==="__source"||se==="ref"&&W.ref===void 0||(Y[se]=W[se]);var se=arguments.length-2;if(se===1)Y.children=re;else if(1<se){for(var be=Array(se),ie=0;ie<se;ie++)be[ie]=arguments[ie+2];Y.children=be}return M(z.type,ce,Y)},Ue.createContext=function(z){return z={$$typeof:d,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:u,_context:z},z},Ue.createElement=function(z,W,re){var Y,ce={},se=null;if(W!=null)for(Y in W.key!==void 0&&(se=""+W.key),W)B.call(W,Y)&&Y!=="key"&&Y!=="__self"&&Y!=="__source"&&(ce[Y]=W[Y]);var be=arguments.length-2;if(be===1)ce.children=re;else if(1<be){for(var ie=Array(be),ye=0;ye<be;ye++)ie[ye]=arguments[ye+2];ce.children=ie}if(z&&z.defaultProps)for(Y in be=z.defaultProps,be)ce[Y]===void 0&&(ce[Y]=be[Y]);return M(z,se,ce)},Ue.createRef=function(){return{current:null}},Ue.forwardRef=function(z){return{$$typeof:h,render:z}},Ue.isValidElement=U,Ue.lazy=function(z){return{$$typeof:v,_payload:{_status:-1,_result:z},_init:G}},Ue.memo=function(z,W){return{$$typeof:m,type:z,compare:W===void 0?null:W}},Ue.startTransition=function(z){var W=C.T,re={};C.T=re;try{var Y=z(),ce=C.S;ce!==null&&ce(re,Y),typeof Y=="object"&&Y!==null&&typeof Y.then=="function"&&Y.then(V,O)}catch(se){O(se)}finally{W!==null&&re.types!==null&&(W.types=re.types),C.T=W}},Ue.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},Ue.use=function(z){return C.H.use(z)},Ue.useActionState=function(z,W,re){return C.H.useActionState(z,W,re)},Ue.useCallback=function(z,W){return C.H.useCallback(z,W)},Ue.useContext=function(z){return C.H.useContext(z)},Ue.useDebugValue=function(){},Ue.useDeferredValue=function(z,W){return C.H.useDeferredValue(z,W)},Ue.useEffect=function(z,W){return C.H.useEffect(z,W)},Ue.useEffectEvent=function(z){return C.H.useEffectEvent(z)},Ue.useId=function(){return C.H.useId()},Ue.useImperativeHandle=function(z,W,re){return C.H.useImperativeHandle(z,W,re)},Ue.useInsertionEffect=function(z,W){return C.H.useInsertionEffect(z,W)},Ue.useLayoutEffect=function(z,W){return C.H.useLayoutEffect(z,W)},Ue.useMemo=function(z,W){return C.H.useMemo(z,W)},Ue.useOptimistic=function(z,W){return C.H.useOptimistic(z,W)},Ue.useReducer=function(z,W,re){return C.H.useReducer(z,W,re)},Ue.useRef=function(z){return C.H.useRef(z)},Ue.useState=function(z){return C.H.useState(z)},Ue.useSyncExternalStore=function(z,W,re){return C.H.useSyncExternalStore(z,W,re)},Ue.useTransition=function(){return C.H.useTransition()},Ue.version="19.2.4",Ue}var Ux;function wf(){return Ux||(Ux=1,gd.exports=D0()),gd.exports}var p=wf();const Ne=Ev(p);var vd={exports:{}},Ds={},yd={exports:{}},bd={};/**
|
|
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(A,I){var G=A.length;A.push(I);e:for(;0<G;){var O=G-1>>>1,ne=A[O];if(0<c(ne,I))A[O]=I,A[G]=ne,G=O;else break e}}function s(A){return A.length===0?null:A[0]}function i(A){if(A.length===0)return null;var I=A[0],G=A.pop();if(G!==I){A[0]=G;e:for(var O=0,ne=A.length,z=ne>>>1;O<z;){var W=2*(O+1)-1,re=A[W],Y=W+1,ce=A[Y];if(0>c(re,G))Y<ne&&0>c(ce,re)?(A[O]=ce,A[Y]=G,O=Y):(A[O]=re,A[W]=G,O=W);else if(Y<ne&&0>c(ce,G))A[O]=ce,A[Y]=G,O=Y;else break e}}return I}function c(A,I){var G=A.sortIndex-I.sortIndex;return G!==0?G:A.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=[],v=1,y=null,b=3,S=!1,k=!1,w=!1,E=!1,T=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function _(A){for(var I=s(m);I!==null;){if(I.callback===null)i(m);else if(I.startTime<=A)i(m),I.sortIndex=I.expirationTime,a(x,I);else break;I=s(m)}}function D(A){if(w=!1,_(A),!k)if(s(x)!==null)k=!0,V||(V=!0,q());else{var I=s(m);I!==null&&H(D,I.startTime-A)}}var V=!1,C=-1,B=5,M=-1;function $(){return E?!0:!(t.unstable_now()-M<B)}function U(){if(E=!1,V){var A=t.unstable_now();M=A;var I=!0;try{e:{k=!1,w&&(w=!1,N(C),C=-1),S=!0;var G=b;try{t:{for(_(A),y=s(x);y!==null&&!(y.expirationTime>A&&$());){var O=y.callback;if(typeof O=="function"){y.callback=null,b=y.priorityLevel;var ne=O(y.expirationTime<=A);if(A=t.unstable_now(),typeof ne=="function"){y.callback=ne,_(A),I=!0;break t}y===s(x)&&i(x),_(A)}else i(x);y=s(x)}if(y!==null)I=!0;else{var z=s(m);z!==null&&H(D,z.startTime-A),I=!1}}break e}finally{y=null,b=G,S=!1}I=void 0}}finally{I?q():V=!1}}}var q;if(typeof L=="function")q=function(){L(U)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,ee=X.port2;X.port1.onmessage=U,q=function(){ee.postMessage(null)}}else q=function(){T(U,0)};function H(A,I){C=T(function(){A(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(A){A.callback=null},t.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<A?Math.floor(1e3/A):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(A){switch(b){case 1:case 2:case 3:var I=3;break;default:I=b}var G=b;b=I;try{return A()}finally{b=G}},t.unstable_requestPaint=function(){E=!0},t.unstable_runWithPriority=function(A,I){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var G=b;b=A;try{return I()}finally{b=G}},t.unstable_scheduleCallback=function(A,I,G){var O=t.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?O+G:O):G=O,A){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=G+ne,A={id:v++,callback:I,priorityLevel:A,startTime:G,expirationTime:ne,sortIndex:-1},G>O?(A.sortIndex=G,a(m,A),s(x)===null&&A===s(m)&&(w?(N(C),C=-1):w=!0,H(D,G-O))):(A.sortIndex=ne,a(x,A),k||S||(k=!0,V||(V=!0,q()))),A},t.unstable_shouldYield=$,t.unstable_wrapCallback=function(A){var I=b;return function(){var G=b;b=I;try{return A.apply(this,arguments)}finally{b=G}}}})(bd)),bd}var Px;function O0(){return Px||(Px=1,yd.exports=_0()),yd.exports}var jd={exports:{}},ln={};/**
|
|
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 B0(){if(Vx)return ln;Vx=1;var t=wf();function a(x){var m="https://react.dev/errors/"+x;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)m+="&args[]="+encodeURIComponent(arguments[v])}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,v){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:y==null?null:""+y,children:x,containerInfo:m,implementation:v}}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 ln.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,ln.createPortal=function(x,m){var v=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,v)},ln.flushSync=function(x){var m=d.T,v=i.p;try{if(d.T=null,i.p=2,x)return x()}finally{d.T=m,i.p=v,i.d.f()}},ln.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))},ln.prefetchDNS=function(x){typeof x=="string"&&i.d.D(x)},ln.preinit=function(x,m){if(typeof x=="string"&&m&&typeof m.as=="string"){var v=m.as,y=h(v,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;v==="style"?i.d.S(x,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:y,integrity:b,fetchPriority:S}):v==="script"&&i.d.X(x,{crossOrigin:y,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},ln.preinitModule=function(x,m){if(typeof x=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var v=h(m.as,m.crossOrigin);i.d.M(x,{crossOrigin:v,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)},ln.preload=function(x,m){if(typeof x=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var v=m.as,y=h(v,m.crossOrigin);i.d.L(x,v,{crossOrigin:y,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})}},ln.preloadModule=function(x,m){if(typeof x=="string")if(m){var v=h(m.as,m.crossOrigin);i.d.m(x,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:v,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else i.d.m(x)},ln.requestFormReset=function(x){i.d.r(x)},ln.unstable_batchedUpdates=function(x,m){return x(m)},ln.useFormState=function(x,m,v){return d.H.useFormState(x,m,v)},ln.useFormStatus=function(){return d.H.useHostTransitionStatus()},ln.version="19.2.4",ln}var Fx;function Nv(){if(Fx)return jd.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(),jd.exports=B0(),jd.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 I0(){if(Gx)return Ds;Gx=1;var t=O0(),a=wf(),s=Nv();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,R=f.child;R;){if(R===l){j=!0,l=f,o=g;break}if(R===o){j=!0,o=f,l=g;break}R=R.sibling}if(!j){for(R=g.child;R;){if(R===l){j=!0,l=g,o=f;break}if(R===o){j=!0,o=g,l=f;break}R=R.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 v(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=v(e),n!==null)return n;e=e.sibling}return null}var y=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),L=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function q(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 ee(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 w:return"Fragment";case T:return"Profiler";case E:return"StrictMode";case D:return"Suspense";case V:return"SuspenseList";case M:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case L:return e.displayName||"Context";case N: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 C:return n=e.displayName||null,n!==null?n:ee(e.type)||"Memo";case B:n=e._payload,e=e._init;try{return ee(e(n))}catch{}}return null}var H=Array.isArray,A=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,G={pending:!1,data:null,method:null,action:null},O=[],ne=-1;function z(e){return{current:e}}function W(e){0>ne||(e.current=O[ne],O[ne]=null,ne--)}function re(e,n){ne++,O[ne]=e.current,e.current=n}var Y=z(null),ce=z(null),se=z(null),be=z(null);function ie(e,n){switch(re(se,n),re(ce,e),re(Y,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(Y),re(Y,e)}function ye(){W(Y),W(ce),W(se)}function Re(e){e.memoizedState!==null&&re(be,e);var n=Y.current,l=ix(n,e.type);n!==l&&(re(ce,e),re(Y,l))}function Ae(e){ce.current===e&&(W(Y),W(ce)),be.current===e&&(W(be),Rs._currentValue=G)}var le,he;function pe(e){if(le===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);le=n&&n[1]||"",he=-1<l.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+le+e+he}var xe=!1;function je(e,n){if(!e||xe)return"";xe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(ae){var J=ae}Reflect.construct(e,[],fe)}else{try{fe.call()}catch(ae){J=ae}e.call(fe.prototype)}}else{try{throw Error()}catch(ae){J=ae}(fe=e())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(ae){if(ae&&J&&typeof ae.stack=="string")return[ae.stack,J.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],R=g[1];if(j&&R){var P=j.split(`
|
|
45
|
+
`),Z=R.split(`
|
|
46
|
+
`);for(f=o=0;o<P.length&&!P[o].includes("DetermineComponentFrameRoot");)o++;for(;f<Z.length&&!Z[f].includes("DetermineComponentFrameRoot");)f++;if(o===P.length||f===Z.length)for(o=P.length-1,f=Z.length-1;1<=o&&0<=f&&P[o]!==Z[f];)f--;for(;1<=o&&0<=f;o--,f--)if(P[o]!==Z[f]){if(o!==1||f!==1)do if(o--,f--,0>f||P[o]!==Z[f]){var oe=`
|
|
47
|
+
`+P[o].replace(" at new "," at ");return e.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",e.displayName)),oe}while(1<=o&&0<=f);break}}}finally{xe=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?pe(l):""}function Be(e,n){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe("Lazy");case 13:return e.child!==n&&n!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return je(e.type,!1);case 11:return je(e.type.render,!1);case 1:return je(e.type,!0);case 31:return pe("Activity");default:return""}}function Ie(e){try{var n="",l=null;do n+=Be(e,l),l=e,e=e.return;while(e);return n}catch(o){return`
|
|
48
|
+
Error generating stack: `+o.message+`
|
|
49
|
+
`+o.stack}}var Nt=Object.prototype.hasOwnProperty,Vt=t.unstable_scheduleCallback,ut=t.unstable_cancelCallback,Et=t.unstable_shouldYield,Ft=t.unstable_requestPaint,qe=t.unstable_now,dt=t.unstable_getCurrentPriorityLevel,Jt=t.unstable_ImmediatePriority,Kt=t.unstable_UserBlockingPriority,cn=t.unstable_NormalPriority,ge=t.unstable_LowPriority,tt=t.unstable_IdlePriority,ft=t.log,Lt=t.unstable_setDisableYieldValue,Tt=null,Ze=null;function xn(e){if(typeof ft=="function"&&Lt(e),Ze&&typeof Ze.setStrictMode=="function")try{Ze.setStrictMode(Tt,e)}catch{}}var Ot=Math.clz32?Math.clz32:Qn,un=Math.log,dn=Math.LN2;function Qn(e){return e>>>=0,e===0?32:31-(un(e)/dn|0)|0}var gn=256,Zn=262144,On=4194304;function vt(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 De(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 R=o&134217727;return R!==0?(o=R&~g,o!==0?f=vt(o):(j&=R,j!==0?f=vt(j):l||(l=R&~e,l!==0&&(f=vt(l))))):(R=o&~g,R!==0?f=vt(R):j!==0?f=vt(j):l||(l=o&~e,l!==0&&(f=vt(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 We(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function ue(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 we(){var e=On;return On<<=1,(On&62914560)===0&&(On=4194304),e}function Le(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function Bt(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Pl(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 R=e.entanglements,P=e.expirationTimes,Z=e.hiddenUpdates;for(l=j&~l;0<l;){var oe=31-Ot(l),fe=1<<oe;R[oe]=0,P[oe]=-1;var J=Z[oe];if(J!==null)for(Z[oe]=null,oe=0;oe<J.length;oe++){var ae=J[oe];ae!==null&&(ae.lane&=-536870913)}l&=~fe}o!==0&&ii(e,o,0),g!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=g&~(j&~n))}function ii(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var o=31-Ot(n);e.entangledLanes|=n,e.entanglements[o]=e.entanglements[o]|1073741824|l&261930}function Ga(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var o=31-Ot(l),f=1<<o;f&n|e[o]&n&&(e[o]|=n),l&=~f}}function sr(e,n){var l=n&-n;return l=(l&42)!==0?1:Or(l),(l&(e.suspendedLanes|n))!==0?0:l}function Or(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 Br(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Vl(){var e=I.p;return e!==0?e:(e=window.event,e===void 0?32:Ax(e.type))}function ga(e,n){var l=I.p;try{return I.p=e,n()}finally{I.p=l}}var nt=Math.random().toString(36).slice(2),Rt="__reactFiber$"+nt,zt="__reactProps$"+nt,Ir="__reactContainer$"+nt,en="__reactEvents$"+nt,qf="__reactListeners$"+nt,$r="__reactHandles$"+nt,oi="__reactResources$"+nt,Fl="__reactMarker$"+nt;function oc(e){delete e[Rt],delete e[zt],delete e[en],delete e[qf],delete e[$r]}function Wa(e){var n=e[Rt];if(n)return n;for(var l=e.parentNode;l;){if(n=l[Ir]||l[Rt]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=mx(e);e!==null;){if(l=e[Rt])return l;e=mx(e)}return n}e=l,l=e.parentNode}return null}function qa(e){if(e=e[Rt]||e[Ir]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Gl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(i(33))}function Ya(e){var n=e[oi];return n||(n=e[oi]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Xt(e){e[Fl]=!0}var Yf=new Set,Kf={};function va(e,n){Ka(e,n),Ka(e+"Capture",n)}function Ka(e,n){for(Kf[e]=n,e=0;e<n.length;e++)Yf.add(n[e])}var kb=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 wb(e){return Nt.call(Qf,e)?!0:Nt.call(Xf,e)?!1:kb.test(e)?Qf[e]=!0:(Xf[e]=!0,!1)}function ci(e,n,l){if(wb(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 ui(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 hr(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 Bn(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 Cb(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 cc(e){if(!e._valueTracker){var n=Zf(e)?"checked":"value";e._valueTracker=Cb(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 di(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 Eb=/[\n"\\]/g;function In(e){return e.replace(Eb,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function uc(e,n,l,o,f,g,j,R){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),n!=null?j==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Bn(n)):e.value!==""+Bn(n)&&(e.value=""+Bn(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?dc(e,j,Bn(n)):l!=null?dc(e,j,Bn(l)):o!=null&&e.removeAttribute("value"),f==null&&g!=null&&(e.defaultChecked=!!g),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Bn(R):e.removeAttribute("name")}function ep(e,n,l,o,f,g,j,R){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)){cc(e);return}l=l!=null?""+Bn(l):"",n=n!=null?""+Bn(n):l,R||n===e.value||(e.value=n),e.defaultValue=n}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=R?e.checked:!!o,e.defaultChecked=!!o,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),cc(e)}function dc(e,n,l){n==="number"&&di(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Xa(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=""+Bn(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=""+Bn(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Bn(l):""}function np(e,n,l,o){if(n==null){if(o!=null){if(l!=null)throw Error(i(92));if(H(o)){if(1<o.length)throw Error(i(93));o=o[0]}l=o}l==null&&(l=""),n=l}l=Bn(n),e.defaultValue=l,o=e.textContent,o===l&&o!==""&&o!==null&&(e.value=o),cc(e)}function Qa(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var Nb=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function 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||Nb.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 fc(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 Tb=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"]]),Rb=/^[\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 fi(e){return Rb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function xr(){}var pc=null;function mc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Za=null,Ja=null;function lp(e){var n=qa(e);if(n&&(e=n.stateNode)){var l=e[zt]||null;e:switch(e=n.stateNode,n.type){case"input":if(uc(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="'+In(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var o=l[n];if(o!==e&&o.form===e.form){var f=o[zt]||null;if(!f)throw Error(i(90));uc(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&&Xa(e,!!l.multiple,n,!1)}}}var hc=!1;function sp(e,n,l){if(hc)return e(n,l);hc=!0;try{var o=e(n);return o}finally{if(hc=!1,(Za!==null||Ja!==null)&&(Ji(),Za&&(n=Za,e=Ja,Ja=Za=null,lp(n),e)))for(n=0;n<e.length;n++)lp(e[n])}}function Wl(e,n){var l=e.stateNode;if(l===null)return null;var o=l[zt]||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 gr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xc=!1;if(gr)try{var ql={};Object.defineProperty(ql,"passive",{get:function(){xc=!0}}),window.addEventListener("test",ql,ql),window.removeEventListener("test",ql,ql)}catch{xc=!1}var Ur=null,gc=null,pi=null;function ip(){if(pi)return pi;var e,n=gc,l=n.length,o,f="value"in Ur?Ur.value:Ur.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 pi=f.slice(e,1<o?1-o:void 0)}function mi(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 hi(){return!0}function op(){return!1}function vn(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 R in e)e.hasOwnProperty(R)&&(l=e[R],this[R]=l?l(g):g[R]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?hi:op,this.isPropagationStopped=op,this}return y(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=hi)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=hi)},persist:function(){},isPersistent:hi}),n}var ya={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xi=vn(ya),Yl=y({},ya,{view:0,detail:0}),Ab=vn(Yl),vc,yc,Kl,gi=y({},Yl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jc,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!==Kl&&(Kl&&e.type==="mousemove"?(vc=e.screenX-Kl.screenX,yc=e.screenY-Kl.screenY):yc=vc=0,Kl=e),vc)},movementY:function(e){return"movementY"in e?e.movementY:yc}}),cp=vn(gi),Mb=y({},gi,{dataTransfer:0}),Lb=vn(Mb),zb=y({},Yl,{relatedTarget:0}),bc=vn(zb),Db=y({},ya,{animationName:0,elapsedTime:0,pseudoElement:0}),_b=vn(Db),Ob=y({},ya,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Bb=vn(Ob),Ib=y({},ya,{data:0}),up=vn(Ib),$b={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ub={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"},Hb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Pb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Hb[e])?!!n[e]:!1}function jc(){return Pb}var Vb=y({},Yl,{key:function(e){if(e.key){var n=$b[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=mi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Ub[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jc,charCode:function(e){return e.type==="keypress"?mi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?mi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Fb=vn(Vb),Gb=y({},gi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),dp=vn(Gb),Wb=y({},Yl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jc}),qb=vn(Wb),Yb=y({},ya,{propertyName:0,elapsedTime:0,pseudoElement:0}),Kb=vn(Yb),Xb=y({},gi,{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}),Qb=vn(Xb),Zb=y({},ya,{newState:0,oldState:0}),Jb=vn(Zb),e1=[9,13,27,32],Sc=gr&&"CompositionEvent"in window,Xl=null;gr&&"documentMode"in document&&(Xl=document.documentMode);var t1=gr&&"TextEvent"in window&&!Xl,fp=gr&&(!Sc||Xl&&8<Xl&&11>=Xl),pp=" ",mp=!1;function hp(e,n){switch(e){case"keyup":return e1.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 el=!1;function n1(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 r1(e,n){if(el)return e==="compositionend"||!Sc&&hp(e,n)?(e=ip(),pi=gc=Ur=null,el=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return fp&&n.locale!=="ko"?null:n.data;default:return null}}var a1={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"?!!a1[e.type]:n==="textarea"}function vp(e,n,l,o){Za?Ja?Ja.push(o):Ja=[o]:Za=o,n=so(n,"onChange"),0<n.length&&(l=new xi("onChange","change",null,l,o),e.push({event:l,listeners:n}))}var Ql=null,Zl=null;function l1(e){ex(e,0)}function vi(e){var n=Gl(e);if(Jf(n))return e}function yp(e,n){if(e==="change")return n}var bp=!1;if(gr){var kc;if(gr){var wc="oninput"in document;if(!wc){var jp=document.createElement("div");jp.setAttribute("oninput","return;"),wc=typeof jp.oninput=="function"}kc=wc}else kc=!1;bp=kc&&(!document.documentMode||9<document.documentMode)}function Sp(){Ql&&(Ql.detachEvent("onpropertychange",kp),Zl=Ql=null)}function kp(e){if(e.propertyName==="value"&&vi(Zl)){var n=[];vp(n,Zl,e,mc(e)),sp(l1,n)}}function s1(e,n,l){e==="focusin"?(Sp(),Ql=n,Zl=l,Ql.attachEvent("onpropertychange",kp)):e==="focusout"&&Sp()}function i1(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return vi(Zl)}function o1(e,n){if(e==="click")return vi(n)}function c1(e,n){if(e==="input"||e==="change")return vi(n)}function u1(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var wn=typeof Object.is=="function"?Object.is:u1;function Jl(e,n){if(wn(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(!Nt.call(n,f)||!wn(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=di(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=di(e.document)}return n}function Cc(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 d1=gr&&"documentMode"in document&&11>=document.documentMode,tl=null,Ec=null,es=null,Nc=!1;function Tp(e,n,l){var o=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Nc||tl==null||tl!==di(o)||(o=tl,"selectionStart"in o&&Cc(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}),es&&Jl(es,o)||(es=o,o=so(Ec,"onSelect"),0<o.length&&(n=new xi("onSelect","select",null,n,l),e.push({event:n,listeners:o}),n.target=tl)))}function ba(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var nl={animationend:ba("Animation","AnimationEnd"),animationiteration:ba("Animation","AnimationIteration"),animationstart:ba("Animation","AnimationStart"),transitionrun:ba("Transition","TransitionRun"),transitionstart:ba("Transition","TransitionStart"),transitioncancel:ba("Transition","TransitionCancel"),transitionend:ba("Transition","TransitionEnd")},Tc={},Rp={};gr&&(Rp=document.createElement("div").style,"AnimationEvent"in window||(delete nl.animationend.animation,delete nl.animationiteration.animation,delete nl.animationstart.animation),"TransitionEvent"in window||delete nl.transitionend.transition);function ja(e){if(Tc[e])return Tc[e];if(!nl[e])return e;var n=nl[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in Rp)return Tc[e]=n[l];return e}var Ap=ja("animationend"),Mp=ja("animationiteration"),Lp=ja("animationstart"),f1=ja("transitionrun"),p1=ja("transitionstart"),m1=ja("transitioncancel"),zp=ja("transitionend"),Dp=new Map,Rc="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(" ");Rc.push("scrollEnd");function Jn(e,n){Dp.set(e,n),va(n,[e])}var yi=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)},$n=[],rl=0,Ac=0;function bi(){for(var e=rl,n=Ac=rl=0;n<e;){var l=$n[n];$n[n++]=null;var o=$n[n];$n[n++]=null;var f=$n[n];$n[n++]=null;var g=$n[n];if($n[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 ji(e,n,l,o){$n[rl++]=e,$n[rl++]=n,$n[rl++]=l,$n[rl++]=o,Ac|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Mc(e,n,l,o){return ji(e,n,l,o),Si(e)}function Sa(e,n){return ji(e,null,null,n),Si(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-Ot(l),e=g.hiddenUpdates,o=e[f],o===null?e[f]=[n]:o.push(n),n.lane=l|536870912),g):null}function Si(e){if(50<Ss)throw Ss=0,Uu=null,Error(i(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var al={};function h1(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 Cn(e,n,l,o){return new h1(e,n,l,o)}function Lc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function vr(e,n){var l=e.alternate;return l===null?(l=Cn(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 ki(e,n,l,o,f,g){var j=0;if(o=e,typeof e=="function")Lc(e)&&(j=1);else if(typeof e=="string")j=b0(e,l,Y.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case M:return e=Cn(31,l,n,f),e.elementType=M,e.lanes=g,e;case w:return ka(l.children,f,g,n);case E:j=8,f|=24;break;case T:return e=Cn(12,l,n,f|2),e.elementType=T,e.lanes=g,e;case D:return e=Cn(13,l,n,f),e.elementType=D,e.lanes=g,e;case V:return e=Cn(19,l,n,f),e.elementType=V,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case L:j=10;break e;case N:j=9;break e;case _:j=11;break e;case C:j=14;break e;case B:j=16,o=null;break e}j=29,l=Error(i(130,e===null?"null":typeof e,"")),o=null}return n=Cn(j,l,n,f),n.elementType=e,n.type=o,n.lanes=g,n}function ka(e,n,l,o){return e=Cn(7,e,o,n),e.lanes=l,e}function zc(e,n,l){return e=Cn(6,e,null,n),e.lanes=l,e}function Bp(e){var n=Cn(18,null,null,0);return n.stateNode=e,n}function Dc(e,n,l){return n=Cn(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 Un(e,n){if(typeof e=="object"&&e!==null){var l=Ip.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Ie(n)},Ip.set(e,n),n)}return{value:e,source:n,stack:Ie(n)}}var ll=[],sl=0,wi=null,ts=0,Hn=[],Pn=0,Hr=null,ir=1,or="";function yr(e,n){ll[sl++]=ts,ll[sl++]=wi,wi=e,ts=n}function $p(e,n,l){Hn[Pn++]=ir,Hn[Pn++]=or,Hn[Pn++]=Hr,Hr=e;var o=ir;e=or;var f=32-Ot(o)-1;o&=~(1<<f),l+=1;var g=32-Ot(n)+f;if(30<g){var j=f-f%5;g=(o&(1<<j)-1).toString(32),o>>=j,f-=j,ir=1<<32-Ot(n)+f|l<<f|o,or=g+e}else ir=1<<g|l<<f|o,or=e}function _c(e){e.return!==null&&(yr(e,1),$p(e,1,0))}function Oc(e){for(;e===wi;)wi=ll[--sl],ll[sl]=null,ts=ll[--sl],ll[sl]=null;for(;e===Hr;)Hr=Hn[--Pn],Hn[Pn]=null,or=Hn[--Pn],Hn[Pn]=null,ir=Hn[--Pn],Hn[Pn]=null}function Up(e,n){Hn[Pn++]=ir,Hn[Pn++]=or,Hn[Pn++]=Hr,ir=n.id,or=n.overflow,Hr=e}var tn=null,yt=null,Je=!1,Pr=null,Vn=!1,Bc=Error(i(519));function Vr(e){var n=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ns(Un(n,e)),Bc}function Hp(e){var n=e.stateNode,l=e.type,o=e.memoizedProps;switch(n[Rt]=e,n[zt]=o,l){case"dialog":Ke("cancel",n),Ke("close",n);break;case"iframe":case"object":case"embed":Ke("load",n);break;case"video":case"audio":for(l=0;l<ws.length;l++)Ke(ws[l],n);break;case"source":Ke("error",n);break;case"img":case"image":case"link":Ke("error",n),Ke("load",n);break;case"details":Ke("toggle",n);break;case"input":Ke("invalid",n),ep(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":Ke("invalid",n);break;case"textarea":Ke("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&&(Ke("beforetoggle",n),Ke("toggle",n)),o.onScroll!=null&&Ke("scroll",n),o.onScrollEnd!=null&&Ke("scrollend",n),o.onClick!=null&&(n.onclick=xr),n=!0):n=!1,n||Vr(e,!0)}function Pp(e){for(tn=e.return;tn;)switch(tn.tag){case 5:case 31:case 13:Vn=!1;return;case 27:case 3:Vn=!0;return;default:tn=tn.return}}function il(e){if(e!==tn)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")||td(e.type,e.memoizedProps)),l=!l),l&&yt&&Vr(e),Pp(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));yt=px(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));yt=px(e)}else n===27?(n=yt,ra(e.type)?(e=sd,sd=null,yt=e):yt=n):yt=tn?Gn(e.stateNode.nextSibling):null;return!0}function wa(){yt=tn=null,Je=!1}function Ic(){var e=Pr;return e!==null&&(Sn===null?Sn=e:Sn.push.apply(Sn,e),Pr=null),e}function ns(e){Pr===null?Pr=[e]:Pr.push(e)}var $c=z(null),Ca=null,br=null;function Fr(e,n,l){re($c,n._currentValue),n._currentValue=l}function jr(e){e._currentValue=$c.current,W($c)}function Uc(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 Hc(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 R=g;g=f;for(var P=0;P<n.length;P++)if(R.context===n[P]){g.lanes|=l,R=g.alternate,R!==null&&(R.lanes|=l),Uc(g.return,l,e),o||(j=null);break e}g=R.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),Uc(j,l,e),j=null}else j=f.child;if(j!==null)j.return=f;else for(j=f;j!==null;){if(j===e){j=null;break}if(f=j.sibling,f!==null){f.return=j.return,j=f;break}j=j.return}f=j}}function ol(e,n,l,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 R=f.type;wn(f.pendingProps.value,j.value)||(e!==null?e.push(R):e=[R])}}else if(f===be.current){if(j=f.alternate,j===null)throw Error(i(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Rs):e=[Rs])}f=f.return}e!==null&&Hc(n,e,l,o),n.flags|=262144}function Ci(e){for(e=e.firstContext;e!==null;){if(!wn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ea(e){Ca=e,br=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function nn(e){return Vp(Ca,e)}function Ei(e,n){return Ca===null&&Ea(e),Vp(e,n)}function Vp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},br===null){if(e===null)throw Error(i(308));br=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else br=br.next=n;return l}var x1=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()})}},g1=t.unstable_scheduleCallback,v1=t.unstable_NormalPriority,It={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Pc(){return{controller:new x1,data:new Map,refCount:0}}function rs(e){e.refCount--,e.refCount===0&&g1(v1,function(){e.controller.abort()})}var as=null,Vc=0,cl=0,ul=null;function y1(e,n){if(as===null){var l=as=[];Vc=0,cl=Wu(),ul={status:"pending",value:void 0,then:function(o){l.push(o)}}}return Vc++,n.then(Fp,Fp),n}function Fp(){if(--Vc===0&&as!==null){ul!==null&&(ul.status="fulfilled");var e=as;as=null,cl=0,ul=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function b1(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=A.S;A.S=function(e,n){Th=qe(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&y1(e,n),Gp!==null&&Gp(e,n)};var Na=z(null);function Fc(){var e=Na.current;return e!==null?e:gt.pooledCache}function Ni(e,n){n===null?re(Na,Na.current):re(Na,n.pool)}function Wp(){var e=Fc();return e===null?null:{parent:It._currentValue,pool:e}}var dl=Error(i(460)),Gc=Error(i(474)),Ti=Error(i(542)),Ri={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(xr,xr),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(xr,xr);else{if(e=gt,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 Ra=n,dl}}function Ta(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Ra=l,dl):l}}var Ra=null;function Kp(){if(Ra===null)throw Error(i(459));var e=Ra;return Ra=null,e}function Xp(e){if(e===dl||e===Ti)throw Error(i(483))}var fl=null,ls=0;function Ai(e){var n=ls;return ls+=1,fl===null&&(fl=[]),Yp(fl,e,n)}function ss(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Mi(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,F){if(e){var Q=K.deletions;Q===null?(K.deletions=[F],K.flags|=16):Q.push(F)}}function l(K,F){if(!e)return null;for(;F!==null;)n(K,F),F=F.sibling;return null}function o(K){for(var F=new Map;K!==null;)K.key!==null?F.set(K.key,K):F.set(K.index,K),K=K.sibling;return F}function f(K,F){return K=vr(K,F),K.index=0,K.sibling=null,K}function g(K,F,Q){return K.index=Q,e?(Q=K.alternate,Q!==null?(Q=Q.index,Q<F?(K.flags|=67108866,F):Q):(K.flags|=67108866,F)):(K.flags|=1048576,F)}function j(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function R(K,F,Q,de){return F===null||F.tag!==6?(F=zc(Q,K.mode,de),F.return=K,F):(F=f(F,Q),F.return=K,F)}function P(K,F,Q,de){var Me=Q.type;return Me===w?oe(K,F,Q.props.children,de,Q.key):F!==null&&(F.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===B&&Ta(Me)===F.type)?(F=f(F,Q.props),ss(F,Q),F.return=K,F):(F=ki(Q.type,Q.key,Q.props,null,K.mode,de),ss(F,Q),F.return=K,F)}function Z(K,F,Q,de){return F===null||F.tag!==4||F.stateNode.containerInfo!==Q.containerInfo||F.stateNode.implementation!==Q.implementation?(F=Dc(Q,K.mode,de),F.return=K,F):(F=f(F,Q.children||[]),F.return=K,F)}function oe(K,F,Q,de,Me){return F===null||F.tag!==7?(F=ka(Q,K.mode,de,Me),F.return=K,F):(F=f(F,Q),F.return=K,F)}function fe(K,F,Q){if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return F=zc(""+F,K.mode,Q),F.return=K,F;if(typeof F=="object"&&F!==null){switch(F.$$typeof){case S:return Q=ki(F.type,F.key,F.props,null,K.mode,Q),ss(Q,F),Q.return=K,Q;case k:return F=Dc(F,K.mode,Q),F.return=K,F;case B:return F=Ta(F),fe(K,F,Q)}if(H(F)||q(F))return F=ka(F,K.mode,Q,null),F.return=K,F;if(typeof F.then=="function")return fe(K,Ai(F),Q);if(F.$$typeof===L)return fe(K,Ei(K,F),Q);Mi(K,F)}return null}function J(K,F,Q,de){var Me=F!==null?F.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Me!==null?null:R(K,F,""+Q,de);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return Q.key===Me?P(K,F,Q,de):null;case k:return Q.key===Me?Z(K,F,Q,de):null;case B:return Q=Ta(Q),J(K,F,Q,de)}if(H(Q)||q(Q))return Me!==null?null:oe(K,F,Q,de,null);if(typeof Q.then=="function")return J(K,F,Ai(Q),de);if(Q.$$typeof===L)return J(K,F,Ei(K,Q),de);Mi(K,Q)}return null}function ae(K,F,Q,de,Me){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return K=K.get(Q)||null,R(F,K,""+de,Me);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case S:return K=K.get(de.key===null?Q:de.key)||null,P(F,K,de,Me);case k:return K=K.get(de.key===null?Q:de.key)||null,Z(F,K,de,Me);case B:return de=Ta(de),ae(K,F,Q,de,Me)}if(H(de)||q(de))return K=K.get(Q)||null,oe(F,K,de,Me,null);if(typeof de.then=="function")return ae(K,F,Q,Ai(de),Me);if(de.$$typeof===L)return ae(K,F,Q,Ei(F,de),Me);Mi(F,de)}return null}function Ce(K,F,Q,de){for(var Me=null,rt=null,Ee=F,Ve=F=0,Qe=null;Ee!==null&&Ve<Q.length;Ve++){Ee.index>Ve?(Qe=Ee,Ee=null):Qe=Ee.sibling;var at=J(K,Ee,Q[Ve],de);if(at===null){Ee===null&&(Ee=Qe);break}e&&Ee&&at.alternate===null&&n(K,Ee),F=g(at,F,Ve),rt===null?Me=at:rt.sibling=at,rt=at,Ee=Qe}if(Ve===Q.length)return l(K,Ee),Je&&yr(K,Ve),Me;if(Ee===null){for(;Ve<Q.length;Ve++)Ee=fe(K,Q[Ve],de),Ee!==null&&(F=g(Ee,F,Ve),rt===null?Me=Ee:rt.sibling=Ee,rt=Ee);return Je&&yr(K,Ve),Me}for(Ee=o(Ee);Ve<Q.length;Ve++)Qe=ae(Ee,K,Ve,Q[Ve],de),Qe!==null&&(e&&Qe.alternate!==null&&Ee.delete(Qe.key===null?Ve:Qe.key),F=g(Qe,F,Ve),rt===null?Me=Qe:rt.sibling=Qe,rt=Qe);return e&&Ee.forEach(function(oa){return n(K,oa)}),Je&&yr(K,Ve),Me}function ze(K,F,Q,de){if(Q==null)throw Error(i(151));for(var Me=null,rt=null,Ee=F,Ve=F=0,Qe=null,at=Q.next();Ee!==null&&!at.done;Ve++,at=Q.next()){Ee.index>Ve?(Qe=Ee,Ee=null):Qe=Ee.sibling;var oa=J(K,Ee,at.value,de);if(oa===null){Ee===null&&(Ee=Qe);break}e&&Ee&&oa.alternate===null&&n(K,Ee),F=g(oa,F,Ve),rt===null?Me=oa:rt.sibling=oa,rt=oa,Ee=Qe}if(at.done)return l(K,Ee),Je&&yr(K,Ve),Me;if(Ee===null){for(;!at.done;Ve++,at=Q.next())at=fe(K,at.value,de),at!==null&&(F=g(at,F,Ve),rt===null?Me=at:rt.sibling=at,rt=at);return Je&&yr(K,Ve),Me}for(Ee=o(Ee);!at.done;Ve++,at=Q.next())at=ae(Ee,K,Ve,at.value,de),at!==null&&(e&&at.alternate!==null&&Ee.delete(at.key===null?Ve:at.key),F=g(at,F,Ve),rt===null?Me=at:rt.sibling=at,rt=at);return e&&Ee.forEach(function(M0){return n(K,M0)}),Je&&yr(K,Ve),Me}function ht(K,F,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===w&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:e:{for(var Me=Q.key;F!==null;){if(F.key===Me){if(Me=Q.type,Me===w){if(F.tag===7){l(K,F.sibling),de=f(F,Q.props.children),de.return=K,K=de;break e}}else if(F.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===B&&Ta(Me)===F.type){l(K,F.sibling),de=f(F,Q.props),ss(de,Q),de.return=K,K=de;break e}l(K,F);break}else n(K,F);F=F.sibling}Q.type===w?(de=ka(Q.props.children,K.mode,de,Q.key),de.return=K,K=de):(de=ki(Q.type,Q.key,Q.props,null,K.mode,de),ss(de,Q),de.return=K,K=de)}return j(K);case k:e:{for(Me=Q.key;F!==null;){if(F.key===Me)if(F.tag===4&&F.stateNode.containerInfo===Q.containerInfo&&F.stateNode.implementation===Q.implementation){l(K,F.sibling),de=f(F,Q.children||[]),de.return=K,K=de;break e}else{l(K,F);break}else n(K,F);F=F.sibling}de=Dc(Q,K.mode,de),de.return=K,K=de}return j(K);case B:return Q=Ta(Q),ht(K,F,Q,de)}if(H(Q))return Ce(K,F,Q,de);if(q(Q)){if(Me=q(Q),typeof Me!="function")throw Error(i(150));return Q=Me.call(Q),ze(K,F,Q,de)}if(typeof Q.then=="function")return ht(K,F,Ai(Q),de);if(Q.$$typeof===L)return ht(K,F,Ei(K,Q),de);Mi(K,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,F!==null&&F.tag===6?(l(K,F.sibling),de=f(F,Q),de.return=K,K=de):(l(K,F),de=zc(Q,K.mode,de),de.return=K,K=de),j(K)):l(K,F)}return function(K,F,Q,de){try{ls=0;var Me=ht(K,F,Q,de);return fl=null,Me}catch(Ee){if(Ee===dl||Ee===Ti)throw Ee;var rt=Cn(29,Ee,null,K.mode);return rt.lanes=de,rt.return=K,rt}finally{}}}var Aa=Qp(!0),Zp=Qp(!1),Gr=!1;function Wc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qc(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 Wr(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=Si(e),_p(e,null,l),n}return ji(e,o,n,l),Si(e)}function is(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,Ga(e,l)}}function Yc(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 Kc=!1;function os(){if(Kc){var e=ul;if(e!==null)throw e}}function cs(e,n,l,o){Kc=!1;var f=e.updateQueue;Gr=!1;var g=f.firstBaseUpdate,j=f.lastBaseUpdate,R=f.shared.pending;if(R!==null){f.shared.pending=null;var P=R,Z=P.next;P.next=null,j===null?g=Z:j.next=Z,j=P;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,R=oe.lastBaseUpdate,R!==j&&(R===null?oe.firstBaseUpdate=Z:R.next=Z,oe.lastBaseUpdate=P))}if(g!==null){var fe=f.baseState;j=0,oe=Z=P=null,R=g;do{var J=R.lane&-536870913,ae=J!==R.lane;if(ae?(Xe&J)===J:(o&J)===J){J!==0&&J===cl&&(Kc=!0),oe!==null&&(oe=oe.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var Ce=e,ze=R;J=n;var ht=l;switch(ze.tag){case 1:if(Ce=ze.payload,typeof Ce=="function"){fe=Ce.call(ht,fe,J);break e}fe=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=ze.payload,J=typeof Ce=="function"?Ce.call(ht,fe,J):Ce,J==null)break e;fe=y({},fe,J);break e;case 2:Gr=!0}}J=R.callback,J!==null&&(e.flags|=64,ae&&(e.flags|=8192),ae=f.callbacks,ae===null?f.callbacks=[J]:ae.push(J))}else ae={lane:J,tag:R.tag,payload:R.payload,callback:R.callback,next:null},oe===null?(Z=oe=ae,P=fe):oe=oe.next=ae,j|=J;if(R=R.next,R===null){if(R=f.shared.pending,R===null)break;ae=R,R=ae.next,ae.next=null,f.lastBaseUpdate=ae,f.shared.pending=null}}while(!0);oe===null&&(P=fe),f.baseState=P,f.firstBaseUpdate=Z,f.lastBaseUpdate=oe,g===null&&(f.shared.lanes=0),Zr|=j,e.lanes=j,e.memoizedState=fe}}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 pl=z(null),Li=z(0);function tm(e,n){e=Ar,re(Li,e),re(pl,n),Ar=e|n.baseLanes}function Xc(){re(Li,Ar),re(pl,pl.current)}function Qc(){Ar=Li.current,W(pl),W(Li)}var En=z(null),Fn=null;function Yr(e){var n=e.alternate;re(Dt,Dt.current&1),re(En,e),Fn===null&&(n===null||pl.current!==null||n.memoizedState!==null)&&(Fn=e)}function Zc(e){re(Dt,Dt.current),re(En,e),Fn===null&&(Fn=e)}function nm(e){e.tag===22?(re(Dt,Dt.current),re(En,e),Fn===null&&(Fn=e)):Kr()}function Kr(){re(Dt,Dt.current),re(En,En.current)}function Nn(e){W(En),Fn===e&&(Fn=null),W(Dt)}var Dt=z(0);function zi(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||ad(l)||ld(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 Sr=0,Pe=null,pt=null,$t=null,Di=!1,ml=!1,Ma=!1,_i=0,us=0,hl=null,j1=0;function At(){throw Error(i(321))}function Jc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!wn(e[l],n[l]))return!1;return!0}function eu(e,n,l,o,f,g){return Sr=g,Pe=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,A.H=e===null||e.memoizedState===null?$m:hu,Ma=!1,g=l(o,f),Ma=!1,ml&&(g=am(n,l,o,f)),rm(e),g}function rm(e){A.H=ps;var n=pt!==null&&pt.next!==null;if(Sr=0,$t=pt=Pe=null,Di=!1,us=0,hl=null,n)throw Error(i(300));e===null||Ut||(e=e.dependencies,e!==null&&Ci(e)&&(Ut=!0))}function am(e,n,l,o){Pe=e;var f=0;do{if(ml&&(hl=null),us=0,ml=!1,25<=f)throw Error(i(301));if(f+=1,$t=pt=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}A.H=Um,g=n(l,o)}while(ml);return g}function S1(){var e=A.H,n=e.useState()[0];return n=typeof n.then=="function"?ds(n):n,e=e.useState()[0],(pt!==null?pt.memoizedState:null)!==e&&(Pe.flags|=1024),n}function tu(){var e=_i!==0;return _i=0,e}function nu(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function ru(e){if(Di){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Di=!1}Sr=0,$t=pt=Pe=null,ml=!1,us=_i=0,hl=null}function fn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $t===null?Pe.memoizedState=$t=e:$t=$t.next=e,$t}function _t(){if(pt===null){var e=Pe.alternate;e=e!==null?e.memoizedState:null}else e=pt.next;var n=$t===null?Pe.memoizedState:$t.next;if(n!==null)$t=n,pt=e;else{if(e===null)throw Pe.alternate===null?Error(i(467)):Error(i(310));pt=e,e={memoizedState:pt.memoizedState,baseState:pt.baseState,baseQueue:pt.baseQueue,queue:pt.queue,next:null},$t===null?Pe.memoizedState=$t=e:$t=$t.next=e}return $t}function Oi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ds(e){var n=us;return us+=1,hl===null&&(hl=[]),e=Yp(hl,e,n),n=Pe,($t===null?n.memoizedState:$t.next)===null&&(n=n.alternate,A.H=n===null||n.memoizedState===null?$m:hu),e}function Bi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ds(e);if(e.$$typeof===L)return nn(e)}throw Error(i(438,String(e)))}function au(e){var n=null,l=Pe.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var o=Pe.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=Oi(),Pe.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]=$;return n.index++,l}function kr(e,n){return typeof n=="function"?n(e):n}function Ii(e){var n=_t();return lu(n,pt,e)}function lu(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 R=j=null,P=null,Z=n,oe=!1;do{var fe=Z.lane&-536870913;if(fe!==Z.lane?(Xe&fe)===fe:(Sr&fe)===fe){var J=Z.revertLane;if(J===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),fe===cl&&(oe=!0);else if((Sr&J)===J){Z=Z.next,J===cl&&(oe=!0);continue}else fe={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=fe,j=g):P=P.next=fe,Pe.lanes|=J,Zr|=J;fe=Z.action,Ma&&l(g,fe),g=Z.hasEagerState?Z.eagerState:l(g,fe)}else J={lane:fe,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=J,j=g):P=P.next=J,Pe.lanes|=fe,Zr|=fe;Z=Z.next}while(Z!==null&&Z!==n);if(P===null?j=g:P.next=R,!wn(g,e.memoizedState)&&(Ut=!0,oe&&(l=ul,l!==null)))throw l;e.memoizedState=g,e.baseState=j,e.baseQueue=P,o.lastRenderedState=g}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function su(e){var n=_t(),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);wn(g,n.memoizedState)||(Ut=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),l.lastRenderedState=g}return[g,o]}function lm(e,n,l){var o=Pe,f=_t(),g=Je;if(g){if(l===void 0)throw Error(i(407));l=l()}else l=n();var j=!wn((pt||f).memoizedState,l);if(j&&(f.memoizedState=l,Ut=!0),f=f.queue,cu(om.bind(null,o,f,e),[e]),f.getSnapshot!==n||j||$t!==null&&$t.memoizedState.tag&1){if(o.flags|=2048,xl(9,{destroy:void 0},im.bind(null,o,f,l,n),null),gt===null)throw Error(i(349));g||(Sr&127)!==0||sm(o,n,l)}return l}function sm(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Pe.updateQueue,n===null?(n=Oi(),Pe.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!wn(e,l)}catch{return!0}}function um(e){var n=Sa(e,2);n!==null&&kn(n,e,2)}function iu(e){var n=fn();if(typeof e=="function"){var l=e;if(e=l(),Ma){xn(!0);try{l()}finally{xn(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:kr,lastRenderedState:e},n}function dm(e,n,l,o){return e.baseState=l,lu(e,pt,typeof o=="function"?o:kr)}function k1(e,n,l,o,f){if(Hi(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)}};A.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=A.T,j={};A.T=j;try{var R=l(f,o),P=A.S;P!==null&&P(j,R),pm(e,n,R)}catch(Z){ou(e,n,Z)}finally{g!==null&&j.types!==null&&(g.types=j.types),A.T=g}}else try{g=l(f,o),pm(e,n,g)}catch(Z){ou(e,n,Z)}}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 ou(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 ou(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=gt.formState;if(l!==null){e:{var o=Pe;if(Je){if(yt){t:{for(var f=yt,g=Vn;f.nodeType!==8;){if(!g){f=null;break t}if(f=Gn(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){yt=Gn(f.nextSibling),o=f.data==="F!";break e}}Vr(o)}o=!1}o&&(n=l[0])}}return l=fn(),l.memoizedState=l.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:xm,lastRenderedState:n},l.queue=o,l=Om.bind(null,Pe,o),o.dispatch=l,o=iu(!1),g=mu.bind(null,Pe,!1,o.queue),o=fn(),f={state:n,dispatch:null,action:e,pending:null},o.queue=f,l=k1.bind(null,Pe,f,g,l),f.dispatch=l,o.memoizedState=e,[n,l,!1]}function vm(e){var n=_t();return ym(n,pt,e)}function ym(e,n,l){if(n=lu(e,n,xm)[0],e=Ii(kr)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=ds(n)}catch(j){throw j===dl?Ti:j}else o=n;n=_t();var f=n.queue,g=f.dispatch;return l!==n.memoizedState&&(Pe.flags|=2048,xl(9,{destroy:void 0},w1.bind(null,f,l),null)),[o,g,e]}function w1(e,n){e.action=n}function bm(e){var n=_t(),l=pt;if(l!==null)return ym(n,l,e);_t(),n=n.memoizedState,l=_t();var o=l.queue.dispatch;return l.memoizedState=e,[n,o,!1]}function xl(e,n,l,o){return e={tag:e,create:l,deps:o,inst:n,next:null},n=Pe.updateQueue,n===null&&(n=Oi(),Pe.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 _t().memoizedState}function $i(e,n,l,o){var f=fn();Pe.flags|=e,f.memoizedState=xl(1|n,{destroy:void 0},l,o===void 0?null:o)}function Ui(e,n,l,o){var f=_t();o=o===void 0?null:o;var g=f.memoizedState.inst;pt!==null&&o!==null&&Jc(o,pt.memoizedState.deps)?f.memoizedState=xl(n,g,l,o):(Pe.flags|=e,f.memoizedState=xl(1|n,g,l,o))}function Sm(e,n){$i(8390656,8,e,n)}function cu(e,n){Ui(2048,8,e,n)}function C1(e){Pe.flags|=4;var n=Pe.updateQueue;if(n===null)n=Oi(),Pe.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function km(e){var n=_t().memoizedState;return C1({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 Ui(4,2,e,n)}function Cm(e,n){return Ui(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,Ui(4,4,Em.bind(null,n,e),l)}function uu(){}function Tm(e,n){var l=_t();n=n===void 0?null:n;var o=l.memoizedState;return n!==null&&Jc(n,o[1])?o[0]:(l.memoizedState=[e,n],e)}function Rm(e,n){var l=_t();n=n===void 0?null:n;var o=l.memoizedState;if(n!==null&&Jc(n,o[1]))return o[0];if(o=e(),Ma){xn(!0);try{e()}finally{xn(!1)}}return l.memoizedState=[o,n],o}function du(e,n,l){return l===void 0||(Sr&1073741824)!==0&&(Xe&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=Ah(),Pe.lanes|=e,Zr|=e,l)}function Am(e,n,l,o){return wn(l,n)?l:pl.current!==null?(e=du(e,l,o),wn(e,n)||(Ut=!0),e):(Sr&42)===0||(Sr&1073741824)!==0&&(Xe&261930)===0?(Ut=!0,e.memoizedState=l):(e=Ah(),Pe.lanes|=e,Zr|=e,n)}function Mm(e,n,l,o,f){var g=I.p;I.p=g!==0&&8>g?g:8;var j=A.T,R={};A.T=R,mu(e,!1,n,l);try{var P=f(),Z=A.S;if(Z!==null&&Z(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var oe=b1(P,o);fs(e,n,oe,An(e))}else fs(e,n,o,An(e))}catch(fe){fs(e,n,{then:function(){},status:"rejected",reason:fe},An())}finally{I.p=g,j!==null&&R.types!==null&&(j.types=R.types),A.T=j}}function E1(){}function fu(e,n,l,o){if(e.tag!==5)throw Error(i(476));var f=Lm(e).queue;Mm(e,f,n,G,l===null?E1:function(){return zm(e),l(o)})}function Lm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:kr,lastRenderedState:G},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:kr,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),fs(e,n.next.queue,{},An())}function pu(){return nn(Rs)}function Dm(){return _t().memoizedState}function _m(){return _t().memoizedState}function N1(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=An();e=Wr(l);var o=qr(n,e,l);o!==null&&(kn(o,n,l),is(o,n,l)),n={cache:Pc()},e.payload=n;return}n=n.return}}function T1(e,n,l){var o=An();l={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Hi(e)?Bm(n,l):(l=Mc(e,n,l,o),l!==null&&(kn(l,e,o),Im(l,n,o)))}function Om(e,n,l){var o=An();fs(e,n,l,o)}function fs(e,n,l,o){var f={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Hi(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,R=g(j,l);if(f.hasEagerState=!0,f.eagerState=R,wn(R,j))return ji(e,n,f,0),gt===null&&bi(),!1}catch{}finally{}if(l=Mc(e,n,f,o),l!==null)return kn(l,e,o),Im(l,n,o),!0}return!1}function mu(e,n,l,o){if(o={lane:2,revertLane:Wu(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Hi(e)){if(n)throw Error(i(479))}else n=Mc(e,l,o,2),n!==null&&kn(n,e,2)}function Hi(e){var n=e.alternate;return e===Pe||n!==null&&n===Pe}function Bm(e,n){ml=Di=!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,Ga(e,l)}}var ps={readContext:nn,use:Bi,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};ps.useEffectEvent=At;var $m={readContext:nn,use:Bi,useCallback:function(e,n){return fn().memoizedState=[e,n===void 0?null:n],e},useContext:nn,useEffect:Sm,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,$i(4194308,4,Em.bind(null,n,e),l)},useLayoutEffect:function(e,n){return $i(4194308,4,e,n)},useInsertionEffect:function(e,n){$i(4,2,e,n)},useMemo:function(e,n){var l=fn();n=n===void 0?null:n;var o=e();if(Ma){xn(!0);try{e()}finally{xn(!1)}}return l.memoizedState=[o,n],o},useReducer:function(e,n,l){var o=fn();if(l!==void 0){var f=l(n);if(Ma){xn(!0);try{l(n)}finally{xn(!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=T1.bind(null,Pe,e),[o.memoizedState,e]},useRef:function(e){var n=fn();return e={current:e},n.memoizedState=e},useState:function(e){e=iu(e);var n=e.queue,l=Om.bind(null,Pe,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:uu,useDeferredValue:function(e,n){var l=fn();return du(l,e,n)},useTransition:function(){var e=iu(!1);return e=Mm.bind(null,Pe,e.queue,!0,!1),fn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var o=Pe,f=fn();if(Je){if(l===void 0)throw Error(i(407));l=l()}else{if(l=n(),gt===null)throw Error(i(349));(Xe&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,xl(9,{destroy:void 0},im.bind(null,o,g,l,n),null),l},useId:function(){var e=fn(),n=gt.identifierPrefix;if(Je){var l=or,o=ir;l=(o&~(1<<32-Ot(o)-1)).toString(32)+l,n="_"+n+"R_"+l,l=_i++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=j1++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:pu,useFormState:gm,useActionState:gm,useOptimistic:function(e){var n=fn();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=mu.bind(null,Pe,!0,l),l.dispatch=n,[e,n]},useMemoCache:au,useCacheRefresh:function(){return fn().memoizedState=N1.bind(null,Pe)},useEffectEvent:function(e){var n=fn(),l={impl:e};return n.memoizedState=l,function(){if((st&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},hu={readContext:nn,use:Bi,useCallback:Tm,useContext:nn,useEffect:cu,useImperativeHandle:Nm,useInsertionEffect:wm,useLayoutEffect:Cm,useMemo:Rm,useReducer:Ii,useRef:jm,useState:function(){return Ii(kr)},useDebugValue:uu,useDeferredValue:function(e,n){var l=_t();return Am(l,pt.memoizedState,e,n)},useTransition:function(){var e=Ii(kr)[0],n=_t().memoizedState;return[typeof e=="boolean"?e:ds(e),n]},useSyncExternalStore:lm,useId:Dm,useHostTransitionStatus:pu,useFormState:vm,useActionState:vm,useOptimistic:function(e,n){var l=_t();return dm(l,pt,e,n)},useMemoCache:au,useCacheRefresh:_m};hu.useEffectEvent=km;var Um={readContext:nn,use:Bi,useCallback:Tm,useContext:nn,useEffect:cu,useImperativeHandle:Nm,useInsertionEffect:wm,useLayoutEffect:Cm,useMemo:Rm,useReducer:su,useRef:jm,useState:function(){return su(kr)},useDebugValue:uu,useDeferredValue:function(e,n){var l=_t();return pt===null?du(l,e,n):Am(l,pt.memoizedState,e,n)},useTransition:function(){var e=su(kr)[0],n=_t().memoizedState;return[typeof e=="boolean"?e:ds(e),n]},useSyncExternalStore:lm,useId:Dm,useHostTransitionStatus:pu,useFormState:bm,useActionState:bm,useOptimistic:function(e,n){var l=_t();return pt!==null?dm(l,pt,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:au,useCacheRefresh:_m};Um.useEffectEvent=km;function xu(e,n,l,o){n=e.memoizedState,l=l(o,n),l=l==null?n:y({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var gu={enqueueSetState:function(e,n,l){e=e._reactInternals;var o=An(),f=Wr(o);f.payload=n,l!=null&&(f.callback=l),n=qr(e,f,o),n!==null&&(kn(n,e,o),is(n,e,o))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var o=An(),f=Wr(o);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=qr(e,f,o),n!==null&&(kn(n,e,o),is(n,e,o))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=An(),o=Wr(l);o.tag=2,n!=null&&(o.callback=n),n=qr(e,o,l),n!==null&&(kn(n,e,l),is(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?!Jl(l,o)||!Jl(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&&gu.enqueueReplaceState(n,n.state,null)}function La(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=y({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function Vm(e){yi(e)}function Fm(e){console.error(e)}function Gm(e){yi(e)}function Pi(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 vu(e,n,l){return l=Wr(l),l.tag=3,l.payload={element:null},l.callback=function(){Pi(e,n)},l}function qm(e){return e=Wr(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"&&(Jr===null?Jr=new Set([this]):Jr.add(this));var R=o.stack;this.componentDidCatch(o.value,{componentStack:R!==null?R:""})})}function R1(e,n,l,o,f){if(l.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=l.alternate,n!==null&&ol(n,l,f,!0),l=En.current,l!==null){switch(l.tag){case 31:case 13:return Fn===null?eo():l.alternate===null&&Mt===0&&(Mt=3),l.flags&=-257,l.flags|=65536,l.lanes=f,o===Ri?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([o]):n.add(o),Vu(e,o,f)),!1;case 22:return l.flags|=65536,o===Ri?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)),Vu(e,o,f)),!1}throw Error(i(435,l.tag))}return Vu(e,o,f),eo(),!1}if(Je)return n=En.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,o!==Bc&&(e=Error(i(422),{cause:o}),ns(Un(e,l)))):(o!==Bc&&(n=Error(i(423),{cause:o}),ns(Un(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=Un(o,l),f=vu(e.stateNode,o,f),Yc(e,f),Mt!==4&&(Mt=2)),!1;var g=Error(i(520),{cause:o});if(g=Un(g,l),js===null?js=[g]:js.push(g),Mt!==4&&(Mt=2),n===null)return!0;o=Un(o,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=vu(l.stateNode,o,e),Yc(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"&&(Jr===null||!Jr.has(g))))return l.flags|=65536,f&=-f,l.lanes|=f,f=qm(f),Ym(f,e,l,o),Yc(l,f),!1}l=l.return}while(l!==null);return!1}var yu=Error(i(461)),Ut=!1;function rn(e,n,l,o){n.child=e===null?Zp(n,null,l,o):Aa(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 R in o)R!=="ref"&&(j[R]=o[R])}else j=o;return Ea(n),o=eu(e,n,l,j,g,f),R=tu(),e!==null&&!Ut?(nu(e,n,f),wr(e,n,f)):(Je&&R&&_c(n),n.flags|=1,rn(e,n,o,f),n.child)}function Xm(e,n,l,o,f){if(e===null){var g=l.type;return typeof g=="function"&&!Lc(g)&&g.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=g,Qm(e,n,g,o,f)):(e=ki(l.type,null,o,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Nu(e,f)){var j=g.memoizedProps;if(l=l.compare,l=l!==null?l:Jl,l(j,o)&&e.ref===n.ref)return wr(e,n,f)}return n.flags|=1,e=vr(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(Jl(g,o)&&e.ref===n.ref)if(Ut=!1,n.pendingProps=o=g,Nu(e,f))(e.flags&131072)!==0&&(Ut=!0);else return n.lanes=e.lanes,wr(e,n,f)}return bu(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&&Ni(n,g!==null?g.cachePool:null),g!==null?tm(n,g):Xc(),nm(n);else return o=n.lanes=536870912,Jm(e,n,g!==null?g.baseLanes|l:l,l,o)}else g!==null?(Ni(n,g.cachePool),tm(n,g),Kr(),n.memoizedState=null):(e!==null&&Ni(n,null),Xc(),Kr());return rn(e,n,f,l),n.child}function ms(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=Fc();return g=g===null?null:{parent:It._currentValue,pool:g},n.memoizedState={baseLanes:l,cachePool:g},e!==null&&Ni(n,null),Xc(),nm(n),e!==null&&ol(e,n,o,!0),n.childLanes=f,null}function Vi(e,n){return n=Gi({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 Aa(n,e.child,null,l),e=Vi(n,n.pendingProps),e.flags|=2,Nn(n),n.memoizedState=null,e}function A1(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=Vi(n,o),n.lanes=536870912,ms(null,e);if(Zc(n),(e=yt)?(e=fx(e,Vn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Hr!==null?{id:ir,overflow:or}:null,retryLane:536870912,hydrationErrors:null},l=Bp(e),l.return=n,n.child=l,tn=n,yt=null)):e=null,e===null)throw Vr(n);return n.lanes=536870912,null}return Vi(n,o)}var g=e.memoizedState;if(g!==null){var j=g.dehydrated;if(Zc(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(Ut||ol(e,n,l,!1),f=(l&e.childLanes)!==0,Ut||f){if(o=gt,o!==null&&(j=sr(o,l),j!==0&&j!==g.retryLane))throw g.retryLane=j,Sa(e,j),kn(o,e,j),yu;eo(),n=eh(e,n,l)}else e=g.treeContext,yt=Gn(j.nextSibling),tn=n,Je=!0,Pr=null,Vn=!1,e!==null&&Up(n,e),n=Vi(n,o),n.flags|=4096;return n}return e=vr(e.child,{mode:o.mode,children:o.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Fi(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 bu(e,n,l,o,f){return Ea(n),l=eu(e,n,l,o,void 0,f),o=tu(),e!==null&&!Ut?(nu(e,n,f),wr(e,n,f)):(Je&&o&&_c(n),n.flags|=1,rn(e,n,l,f),n.child)}function th(e,n,l,o,f,g){return Ea(n),n.updateQueue=null,l=am(n,o,l,f),rm(e),o=tu(),e!==null&&!Ut?(nu(e,n,g),wr(e,n,g)):(Je&&o&&_c(n),n.flags|=1,rn(e,n,l,g),n.child)}function nh(e,n,l,o,f){if(Ea(n),n.stateNode===null){var g=al,j=l.contextType;typeof j=="object"&&j!==null&&(g=nn(j)),g=new l(o,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=gu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=o,g.state=n.memoizedState,g.refs={},Wc(n),j=l.contextType,g.context=typeof j=="object"&&j!==null?nn(j):al,g.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(xu(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&&gu.enqueueReplaceState(g,g.state,null),cs(n,o,g,f),os(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(e===null){g=n.stateNode;var R=n.memoizedProps,P=La(l,R);g.props=P;var Z=g.context,oe=l.contextType;j=al,typeof oe=="object"&&oe!==null&&(j=nn(oe));var fe=l.getDerivedStateFromProps;oe=typeof fe=="function"||typeof g.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,oe||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(R||Z!==j)&&Pm(n,g,o,j),Gr=!1;var J=n.memoizedState;g.state=J,cs(n,o,g,f),os(),Z=n.memoizedState,R||J!==Z||Gr?(typeof fe=="function"&&(xu(n,l,fe,o),Z=n.memoizedState),(P=Gr||Hm(n,l,P,o,J,Z,j))?(oe||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=Z),g.props=o,g.state=Z,g.context=j,o=P):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{g=n.stateNode,qc(e,n),j=n.memoizedProps,oe=La(l,j),g.props=oe,fe=n.pendingProps,J=g.context,Z=l.contextType,P=al,typeof Z=="object"&&Z!==null&&(P=nn(Z)),R=l.getDerivedStateFromProps,(Z=typeof R=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(j!==fe||J!==P)&&Pm(n,g,o,P),Gr=!1,J=n.memoizedState,g.state=J,cs(n,o,g,f),os();var ae=n.memoizedState;j!==fe||J!==ae||Gr||e!==null&&e.dependencies!==null&&Ci(e.dependencies)?(typeof R=="function"&&(xu(n,l,R,o),ae=n.memoizedState),(oe=Gr||Hm(n,l,oe,o,J,ae,P)||e!==null&&e.dependencies!==null&&Ci(e.dependencies))?(Z||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(o,ae,P),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(o,ae,P)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=ae),g.props=o,g.state=ae,g.context=P,o=oe):(typeof g.componentDidUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&J===e.memoizedState||(n.flags|=1024),o=!1)}return g=o,Fi(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=Aa(n,e.child,null,f),n.child=Aa(n,null,l,f)):rn(e,n,l,f),n.memoizedState=g.state,e=n.child):e=wr(e,n,f),e}function rh(e,n,l,o){return wa(),n.flags|=256,rn(e,n,l,o),n.child}var ju={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Su(e){return{baseLanes:e,cachePool:Wp()}}function ku(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=Rn),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:(Dt.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Je){if(f?Yr(n):Kr(),(e=yt)?(e=fx(e,Vn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Hr!==null?{id:ir,overflow:or}:null,retryLane:536870912,hydrationErrors:null},l=Bp(e),l.return=n,n.child=l,tn=n,yt=null)):e=null,e===null)throw Vr(n);return ld(e)?n.lanes=32:n.lanes=536870912,null}var R=o.children;return o=o.fallback,f?(Kr(),f=n.mode,R=Gi({mode:"hidden",children:R},f),o=ka(o,f,l,null),R.return=n,o.return=n,R.sibling=o,n.child=R,o=n.child,o.memoizedState=Su(l),o.childLanes=ku(e,j,l),n.memoizedState=ju,ms(null,o)):(Yr(n),wu(n,R))}var P=e.memoizedState;if(P!==null&&(R=P.dehydrated,R!==null)){if(g)n.flags&256?(Yr(n),n.flags&=-257,n=Cu(e,n,l)):n.memoizedState!==null?(Kr(),n.child=e.child,n.flags|=128,n=null):(Kr(),R=o.fallback,f=n.mode,o=Gi({mode:"visible",children:o.children},f),R=ka(R,f,l,null),R.flags|=2,o.return=n,R.return=n,o.sibling=R,n.child=o,Aa(n,e.child,null,l),o=n.child,o.memoizedState=Su(l),o.childLanes=ku(e,j,l),n.memoizedState=ju,n=ms(null,o));else if(Yr(n),ld(R)){if(j=R.nextSibling&&R.nextSibling.dataset,j)var Z=j.dgst;j=Z,o=Error(i(419)),o.stack="",o.digest=j,ns({value:o,source:null,stack:null}),n=Cu(e,n,l)}else if(Ut||ol(e,n,l,!1),j=(l&e.childLanes)!==0,Ut||j){if(j=gt,j!==null&&(o=sr(j,l),o!==0&&o!==P.retryLane))throw P.retryLane=o,Sa(e,o),kn(j,e,o),yu;ad(R)||eo(),n=Cu(e,n,l)}else ad(R)?(n.flags|=192,n.child=e.child,n=null):(e=P.treeContext,yt=Gn(R.nextSibling),tn=n,Je=!0,Pr=null,Vn=!1,e!==null&&Up(n,e),n=wu(n,o.children),n.flags|=4096);return n}return f?(Kr(),R=o.fallback,f=n.mode,P=e.child,Z=P.sibling,o=vr(P,{mode:"hidden",children:o.children}),o.subtreeFlags=P.subtreeFlags&65011712,Z!==null?R=vr(Z,R):(R=ka(R,f,l,null),R.flags|=2),R.return=n,o.return=n,o.sibling=R,n.child=o,ms(null,o),o=n.child,R=e.child.memoizedState,R===null?R=Su(l):(f=R.cachePool,f!==null?(P=It._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=Wp(),R={baseLanes:R.baseLanes|l,cachePool:f}),o.memoizedState=R,o.childLanes=ku(e,j,l),n.memoizedState=ju,ms(e.child,o)):(Yr(n),l=e.child,e=l.sibling,l=vr(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 wu(e,n){return n=Gi({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Gi(e,n){return e=Cn(22,e,null,n),e.lanes=0,e}function Cu(e,n,l){return Aa(n,e.child,null,l),e=wu(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),Uc(e.return,n,l)}function Eu(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=Dt.current,R=(j&2)!==0;if(R?(j=j&1|2,n.flags|=128):j&=1,re(Dt,j),rn(e,n,o,l),o=Je?ts:0,!R&&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&&zi(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),Eu(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&&zi(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}Eu(n,!0,l,null,g,o);break;case"together":Eu(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function wr(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),Zr|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(ol(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(i(153));if(n.child!==null){for(e=n.child,l=vr(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=vr(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function Nu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&Ci(e)))}function M1(e,n,l){switch(n.tag){case 3:ie(n,n.stateNode.containerInfo),Fr(n,It,e.memoizedState.cache),wa();break;case 27:case 5:Re(n);break;case 4:ie(n,n.stateNode.containerInfo);break;case 10:Fr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Zc(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(Yr(n),n.flags|=128,null):(l&n.child.childLanes)!==0?ah(e,n,l):(Yr(n),e=wr(e,n,l),e!==null?e.sibling:null);Yr(n);break;case 19:var f=(e.flags&128)!==0;if(o=(l&n.childLanes)!==0,o||(ol(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),re(Dt,Dt.current),o)break;return null;case 22:return n.lanes=0,Zm(e,n,l,n.pendingProps);case 24:Fr(n,It,e.memoizedState.cache)}return wr(e,n,l)}function ih(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Ut=!0;else{if(!Nu(e,l)&&(n.flags&128)===0)return Ut=!1,M1(e,n,l);Ut=(e.flags&131072)!==0}else Ut=!1,Je&&(n.flags&1048576)!==0&&$p(n,ts,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(e=Ta(n.elementType),n.type=e,typeof e=="function")Lc(e)?(o=La(e,o),n.tag=1,n=nh(null,n,e,o,l)):(n.tag=0,n=bu(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===C){n.tag=14,n=Xm(null,n,e,o,l);break e}}throw n=ee(e)||e,Error(i(306,n,""))}}return n;case 0:return bu(e,n,n.type,n.pendingProps,l);case 1:return o=n.type,f=La(o,n.pendingProps),nh(e,n,o,f,l);case 3:e:{if(ie(n,n.stateNode.containerInfo),e===null)throw Error(i(387));o=n.pendingProps;var g=n.memoizedState;f=g.element,qc(e,n),cs(n,o,null,l);var j=n.memoizedState;if(o=j.cache,Fr(n,It,o),o!==g.cache&&Hc(n,[It],l,!0),os(),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=Un(Error(i(424)),n),ns(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(yt=Gn(e.firstChild),tn=n,Je=!0,Pr=null,Vn=!0,l=Zp(n,null,o,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(wa(),o===f){n=wr(e,n,l);break e}rn(e,n,o,l)}n=n.child}return n;case 26:return Fi(e,n),e===null?(l=vx(n.type,null,n.pendingProps,null))?n.memoizedState=l:Je||(l=n.type,e=n.pendingProps,o=io(se.current).createElement(l),o[Rt]=n,o[zt]=e,an(o,l,e),Xt(o),n.stateNode=o):n.memoizedState=vx(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Re(n),e===null&&Je&&(o=n.stateNode=hx(n.type,n.pendingProps,se.current),tn=n,Vn=!0,f=yt,ra(n.type)?(sd=f,yt=Gn(o.firstChild)):yt=f),rn(e,n,n.pendingProps.children,l),Fi(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Je&&((f=o=yt)&&(o=i0(o,n.type,n.pendingProps,Vn),o!==null?(n.stateNode=o,tn=n,yt=Gn(o.firstChild),Vn=!1,f=!0):f=!1),f||Vr(n)),Re(n),f=n.type,g=n.pendingProps,j=e!==null?e.memoizedProps:null,o=g.children,td(f,g)?o=null:j!==null&&td(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=eu(e,n,S1,null,null,l),Rs._currentValue=f),Fi(e,n),rn(e,n,o,l),n.child;case 6:return e===null&&Je&&((e=l=yt)&&(l=o0(l,n.pendingProps,Vn),l!==null?(n.stateNode=l,tn=n,yt=null,e=!0):e=!1),e||Vr(n)),null;case 13:return ah(e,n,l);case 4:return ie(n,n.stateNode.containerInfo),o=n.pendingProps,e===null?n.child=Aa(n,null,o,l):rn(e,n,o,l),n.child;case 11:return Km(e,n,n.type,n.pendingProps,l);case 7:return rn(e,n,n.pendingProps,l),n.child;case 8:return rn(e,n,n.pendingProps.children,l),n.child;case 12:return rn(e,n,n.pendingProps.children,l),n.child;case 10:return o=n.pendingProps,Fr(n,n.type,o.value),rn(e,n,o.children,l),n.child;case 9:return f=n.type._context,o=n.pendingProps.children,Ea(n),f=nn(f),o=o(f),n.flags|=1,rn(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 A1(e,n,l);case 22:return Zm(e,n,l,n.pendingProps);case 24:return Ea(n),o=nn(It),e===null?(f=Fc(),f===null&&(f=gt,g=Pc(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=l),f=g),n.memoizedState={parent:o,cache:f},Wc(n),Fr(n,It,f)):((e.lanes&l)!==0&&(qc(e,n),cs(n,null,null,l),os()),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),Fr(n,It,o)):(o=g.cache,Fr(n,It,o),o!==f.cache&&Hc(n,[It],l,!0))),rn(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(i(156,n.tag))}function Cr(e){e.flags|=4}function Tu(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 Ra=Ri,Gc}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 Ra=Ri,Gc}function Wi(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?we():536870912,e.lanes|=n,bl|=n)}function hs(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 bt(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 L1(e,n,l){var o=n.pendingProps;switch(Oc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bt(n),null;case 1:return bt(n),null;case 3:return l=n.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),jr(It),ye(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(il(n)?Cr(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Ic())),bt(n),null;case 26:var f=n.type,g=n.memoizedState;return e===null?(Cr(n),g!==null?(bt(n),oh(n,g)):(bt(n),Tu(n,f,null,o,l))):g?g!==e.memoizedState?(Cr(n),bt(n),oh(n,g)):(bt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==o&&Cr(n),bt(n),Tu(n,f,e,o,l)),null;case 27:if(Ae(n),l=se.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&Cr(n);else{if(!o){if(n.stateNode===null)throw Error(i(166));return bt(n),null}e=Y.current,il(n)?Hp(n):(e=hx(f,o,l),n.stateNode=e,Cr(n))}return bt(n),null;case 5:if(Ae(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&Cr(n);else{if(!o){if(n.stateNode===null)throw Error(i(166));return bt(n),null}if(g=Y.current,il(n))Hp(n);else{var j=io(se.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[Rt]=n,g[zt]=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(an(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&&Cr(n)}}return bt(n),Tu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==o&&Cr(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(i(166));if(e=se.current,il(n)){if(e=n.stateNode,l=n.memoizedProps,o=null,f=tn,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[Rt]=n,e=!!(e.nodeValue===l||o!==null&&o.suppressHydrationWarning===!0||ax(e.nodeValue,l)),e||Vr(n,!0)}else e=io(e).createTextNode(o),e[Rt]=n,n.stateNode=e}return bt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(o=il(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[Rt]=n}else wa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),e=!1}else l=Ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Nn(n),n):(Nn(n),null);if((n.flags&128)!==0)throw Error(i(558))}return bt(n),null;case 13:if(o=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=il(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[Rt]=n}else wa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),f=!1}else f=Ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Nn(n),n):(Nn(n),null)}return Nn(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),Wi(n,n.updateQueue),bt(n),null);case 4:return ye(),e===null&&Xu(n.stateNode.containerInfo),bt(n),null;case 10:return jr(n.type),bt(n),null;case 19:if(W(Dt),o=n.memoizedState,o===null)return bt(n),null;if(f=(n.flags&128)!==0,g=o.rendering,g===null)if(f)hs(o,!1);else{if(Mt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=zi(e),g!==null){for(n.flags|=128,hs(o,!1),e=g.updateQueue,n.updateQueue=e,Wi(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Op(l,e),l=l.sibling;return re(Dt,Dt.current&1|2),Je&&yr(n,o.treeForkCount),n.child}e=e.sibling}o.tail!==null&&qe()>Qi&&(n.flags|=128,f=!0,hs(o,!1),n.lanes=4194304)}else{if(!f)if(e=zi(g),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,Wi(n,e),hs(o,!0),o.tail===null&&o.tailMode==="hidden"&&!g.alternate&&!Je)return bt(n),null}else 2*qe()-o.renderingStartTime>Qi&&l!==536870912&&(n.flags|=128,f=!0,hs(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=qe(),e.sibling=null,l=Dt.current,re(Dt,f?l&1|2:l&1),Je&&yr(n,o.treeForkCount),e):(bt(n),null);case 22:case 23:return Nn(n),Qc(),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&&(bt(n),n.subtreeFlags&6&&(n.flags|=8192)):bt(n),l=n.updateQueue,l!==null&&Wi(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(Na),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),jr(It),bt(n),null;case 25:return null;case 30:return null}throw Error(i(156,n.tag))}function z1(e,n){switch(Oc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return jr(It),ye(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Ae(n),null;case 31:if(n.memoizedState!==null){if(Nn(n),n.alternate===null)throw Error(i(340));wa()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Nn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(i(340));wa()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return W(Dt),null;case 4:return ye(),null;case 10:return jr(n.type),null;case 22:case 23:return Nn(n),Qc(),e!==null&&W(Na),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return jr(It),null;case 25:return null;default:return null}}function ch(e,n){switch(Oc(n),n.tag){case 3:jr(It),ye();break;case 26:case 27:case 5:Ae(n);break;case 4:ye();break;case 31:n.memoizedState!==null&&Nn(n);break;case 13:Nn(n);break;case 19:W(Dt);break;case 10:jr(n.type);break;case 22:case 23:Nn(n),Qc(),e!==null&&W(Na);break;case 24:jr(It)}}function xs(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(R){ct(n,n.return,R)}}function Xr(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,R=j.destroy;if(R!==void 0){j.destroy=void 0,f=n;var P=l,Z=R;try{Z()}catch(oe){ct(f,P,oe)}}}o=o.next}while(o!==g)}}catch(oe){ct(n,n.return,oe)}}function uh(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{em(n,l)}catch(o){ct(e,e.return,o)}}}function dh(e,n,l){l.props=La(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(o){ct(e,n,o)}}function gs(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){ct(e,n,f)}}function cr(e,n){var l=e.ref,o=e.refCleanup;if(l!==null)if(typeof o=="function")try{o()}catch(f){ct(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){ct(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){ct(e,e.return,f)}}function Ru(e,n,l){try{var o=e.stateNode;t0(o,e.type,l,n),o[zt]=n}catch(f){ct(e,e.return,f)}}function ph(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ra(e.type)||e.tag===4}function Au(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&&ra(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 Mu(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=xr));else if(o!==4&&(o===27&&ra(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(Mu(e,n,l),e=e.sibling;e!==null;)Mu(e,n,l),e=e.sibling}function qi(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&&ra(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(qi(e,n,l),e=e.sibling;e!==null;)qi(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]);an(n,o,l),n[Rt]=e,n[zt]=l}catch(g){ct(e,e.return,g)}}var Er=!1,Ht=!1,Lu=!1,hh=typeof WeakSet=="function"?WeakSet:Set,Qt=null;function D1(e,n){if(e=e.containerInfo,Ju=ho,e=Np(e),Cc(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,R=-1,P=-1,Z=0,oe=0,fe=e,J=null;t:for(;;){for(var ae;fe!==l||f!==0&&fe.nodeType!==3||(R=j+f),fe!==g||o!==0&&fe.nodeType!==3||(P=j+o),fe.nodeType===3&&(j+=fe.nodeValue.length),(ae=fe.firstChild)!==null;)J=fe,fe=ae;for(;;){if(fe===e)break t;if(J===l&&++Z===f&&(R=j),J===g&&++oe===o&&(P=j),(ae=fe.nextSibling)!==null)break;fe=J,J=fe.parentNode}fe=ae}l=R===-1||P===-1?null:{start:R,end:P}}else l=null}l=l||{start:0,end:0}}else l=null;for(ed={focusedElem:e,selectionRange:l},ho=!1,Qt=n;Qt!==null;)if(n=Qt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Qt=e;else for(;Qt!==null;){switch(n=Qt,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=La(l.type,f);e=o.getSnapshotBeforeUpdate(Ce,g),o.__reactInternalSnapshotBeforeUpdate=e}catch(ze){ct(l,l.return,ze)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)rd(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":rd(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,Qt=e;break}Qt=n.return}}function xh(e,n,l){var o=l.flags;switch(l.tag){case 0:case 11:case 15:Tr(e,l),o&4&&xs(5,l);break;case 1:if(Tr(e,l),o&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){ct(l,l.return,j)}else{var f=La(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){ct(l,l.return,j)}}o&64&&uh(l),o&512&&gs(l,l.return);break;case 3:if(Tr(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){ct(l,l.return,j)}}break;case 27:n===null&&o&4&&mh(l);case 26:case 5:Tr(e,l),n===null&&o&4&&fh(l),o&512&&gs(l,l.return);break;case 12:Tr(e,l);break;case 31:Tr(e,l),o&4&&yh(e,l);break;case 13:Tr(e,l),o&4&&bh(e,l),o&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=V1.bind(null,l),c0(e,l))));break;case 22:if(o=l.memoizedState!==null||Er,!o){n=n!==null&&n.memoizedState!==null||Ht,f=Er;var g=Ht;Er=o,(Ht=n)&&!g?Rr(e,l,(l.subtreeFlags&8772)!==0):Tr(e,l),Er=f,Ht=g}break;case 30:break;default:Tr(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&&oc(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var kt=null,yn=!1;function Nr(e,n,l){for(l=l.child;l!==null;)vh(e,n,l),l=l.sibling}function vh(e,n,l){if(Ze&&typeof Ze.onCommitFiberUnmount=="function")try{Ze.onCommitFiberUnmount(Tt,l)}catch{}switch(l.tag){case 26:Ht||cr(l,n),Nr(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Ht||cr(l,n);var o=kt,f=yn;ra(l.type)&&(kt=l.stateNode,yn=!1),Nr(e,n,l),Es(l.stateNode),kt=o,yn=f;break;case 5:Ht||cr(l,n);case 6:if(o=kt,f=yn,kt=null,Nr(e,n,l),kt=o,yn=f,kt!==null)if(yn)try{(kt.nodeType===9?kt.body:kt.nodeName==="HTML"?kt.ownerDocument.body:kt).removeChild(l.stateNode)}catch(g){ct(l,n,g)}else try{kt.removeChild(l.stateNode)}catch(g){ct(l,n,g)}break;case 18:kt!==null&&(yn?(e=kt,ux(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),Tl(e)):ux(kt,l.stateNode));break;case 4:o=kt,f=yn,kt=l.stateNode.containerInfo,yn=!0,Nr(e,n,l),kt=o,yn=f;break;case 0:case 11:case 14:case 15:Xr(2,l,n),Ht||Xr(4,l,n),Nr(e,n,l);break;case 1:Ht||(cr(l,n),o=l.stateNode,typeof o.componentWillUnmount=="function"&&dh(l,n,o)),Nr(e,n,l);break;case 21:Nr(e,n,l);break;case 22:Ht=(o=Ht)||l.memoizedState!==null,Nr(e,n,l),Ht=o;break;default:Nr(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{Tl(e)}catch(l){ct(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{Tl(e)}catch(l){ct(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 Yi(e,n){var l=_1(e);n.forEach(function(o){if(!l.has(o)){l.add(o);var f=F1.bind(null,e,o);o.then(f,f)}})}function bn(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,R=j;e:for(;R!==null;){switch(R.tag){case 27:if(ra(R.type)){kt=R.stateNode,yn=!1;break e}break;case 5:kt=R.stateNode,yn=!1;break e;case 3:case 4:kt=R.stateNode.containerInfo,yn=!0;break e}R=R.return}if(kt===null)throw Error(i(160));vh(g,j,f),kt=null,yn=!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 er=null;function jh(e,n){var l=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:bn(n,e),jn(e),o&4&&(Xr(3,e,e.return),xs(3,e),Xr(5,e,e.return));break;case 1:bn(n,e),jn(e),o&512&&(Ht||l===null||cr(l,l.return)),o&64&&Er&&(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=er;if(bn(n,e),jn(e),o&512&&(Ht||l===null||cr(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[Fl]||g[Rt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(o),f.head.insertBefore(g,f.querySelector("head > title"))),an(g,o,l),g[Rt]=e,Xt(g),o=g;break e;case"link":var j=jx("link","href",f).get(o+(l.href||""));if(j){for(var R=0;R<j.length;R++)if(g=j[R],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(R,1);break t}}g=f.createElement(o),an(g,o,l),f.head.appendChild(g);break;case"meta":if(j=jx("meta","content",f).get(o+(l.content||""))){for(R=0;R<j.length;R++)if(g=j[R],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(R,1);break t}}g=f.createElement(o),an(g,o,l),f.head.appendChild(g);break;default:throw Error(i(468,o))}g[Rt]=e,Xt(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&&Ru(e,e.memoizedProps,l.memoizedProps)}break;case 27:bn(n,e),jn(e),o&512&&(Ht||l===null||cr(l,l.return)),l!==null&&o&4&&Ru(e,e.memoizedProps,l.memoizedProps);break;case 5:if(bn(n,e),jn(e),o&512&&(Ht||l===null||cr(l,l.return)),e.flags&32){f=e.stateNode;try{Qa(f,"")}catch(Ce){ct(e,e.return,Ce)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,Ru(e,f,l!==null?l.memoizedProps:f)),o&1024&&(Lu=!0);break;case 6:if(bn(n,e),jn(e),o&4){if(e.stateNode===null)throw Error(i(162));o=e.memoizedProps,l=e.stateNode;try{l.nodeValue=o}catch(Ce){ct(e,e.return,Ce)}}break;case 3:if(uo=null,f=er,er=oo(n.containerInfo),bn(n,e),er=f,jn(e),o&4&&l!==null&&l.memoizedState.isDehydrated)try{Tl(n.containerInfo)}catch(Ce){ct(e,e.return,Ce)}Lu&&(Lu=!1,Sh(e));break;case 4:o=er,er=oo(e.stateNode.containerInfo),bn(n,e),jn(e),er=o;break;case 12:bn(n,e),jn(e);break;case 31:bn(n,e),jn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Yi(e,o)));break;case 13:bn(n,e),jn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Xi=qe()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Yi(e,o)));break;case 22:f=e.memoizedState!==null;var P=l!==null&&l.memoizedState!==null,Z=Er,oe=Ht;if(Er=Z||f,Ht=oe||P,bn(n,e),Ht=oe,Er=Z,jn(e),o&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||P||Er||Ht||za(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){P=l=n;try{if(g=P.stateNode,f)j=g.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{R=P.stateNode;var fe=P.memoizedProps.style,J=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;R.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(Ce){ct(P,P.return,Ce)}}}else if(n.tag===6){if(l===null){P=n;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(Ce){ct(P,P.return,Ce)}}}else if(n.tag===18){if(l===null){P=n;try{var ae=P.stateNode;f?dx(ae,!0):dx(P.stateNode,!1)}catch(Ce){ct(P,P.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,Yi(e,l))));break;case 19:bn(n,e),jn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Yi(e,o)));break;case 30:break;case 21:break;default:bn(n,e),jn(e)}}function jn(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=Au(e);qi(e,g,f);break;case 5:var j=l.stateNode;l.flags&32&&(Qa(j,""),l.flags&=-33);var R=Au(e);qi(e,R,j);break;case 3:case 4:var P=l.stateNode.containerInfo,Z=Au(e);Mu(e,Z,P);break;default:throw Error(i(161))}}catch(oe){ct(e,e.return,oe)}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 Tr(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)xh(e,n.alternate,n),n=n.sibling}function za(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Xr(4,n,n.return),za(n);break;case 1:cr(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&dh(n,n.return,l),za(n);break;case 27:Es(n.stateNode);case 26:case 5:cr(n,n.return),za(n);break;case 22:n.memoizedState===null&&za(n);break;case 30:za(n);break;default:za(n)}e=e.sibling}}function Rr(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:Rr(f,g,l),xs(4,g);break;case 1:if(Rr(f,g,l),o=g,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(Z){ct(o,o.return,Z)}if(o=g,f=o.updateQueue,f!==null){var R=o.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)Jp(P[f],R)}catch(Z){ct(o,o.return,Z)}}l&&j&64&&uh(g),gs(g,g.return);break;case 27:mh(g);case 26:case 5:Rr(f,g,l),l&&o===null&&j&4&&fh(g),gs(g,g.return);break;case 12:Rr(f,g,l);break;case 31:Rr(f,g,l),l&&j&4&&yh(f,g);break;case 13:Rr(f,g,l),l&&j&4&&bh(f,g);break;case 22:g.memoizedState===null&&Rr(f,g,l),gs(g,g.return);break;case 30:break;default:Rr(f,g,l)}n=n.sibling}}function zu(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&&rs(l))}function Du(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&rs(e))}function tr(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:tr(e,n,l,o),f&2048&&xs(9,n);break;case 1:tr(e,n,l,o);break;case 3:tr(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&&rs(e)));break;case 12:if(f&2048){tr(e,n,l,o),e=n.stateNode;try{var g=n.memoizedProps,j=g.id,R=g.onPostCommit;typeof R=="function"&&R(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){ct(n,n.return,P)}}else tr(e,n,l,o);break;case 31:tr(e,n,l,o);break;case 13:tr(e,n,l,o);break;case 23:break;case 22:g=n.stateNode,j=n.alternate,n.memoizedState!==null?g._visibility&2?tr(e,n,l,o):vs(e,n):g._visibility&2?tr(e,n,l,o):(g._visibility|=2,gl(e,n,l,o,(n.subtreeFlags&10256)!==0||!1)),f&2048&&zu(j,n);break;case 24:tr(e,n,l,o),f&2048&&Du(n.alternate,n);break;default:tr(e,n,l,o)}}function gl(e,n,l,o,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,j=n,R=l,P=o,Z=j.flags;switch(j.tag){case 0:case 11:case 15:gl(g,j,R,P,f),xs(8,j);break;case 23:break;case 22:var oe=j.stateNode;j.memoizedState!==null?oe._visibility&2?gl(g,j,R,P,f):vs(g,j):(oe._visibility|=2,gl(g,j,R,P,f)),f&&Z&2048&&zu(j.alternate,j);break;case 24:gl(g,j,R,P,f),f&&Z&2048&&Du(j.alternate,j);break;default:gl(g,j,R,P,f)}n=n.sibling}}function vs(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:vs(l,o),f&2048&&zu(o.alternate,o);break;case 24:vs(l,o),f&2048&&Du(o.alternate,o);break;default:vs(l,o)}n=n.sibling}}var ys=8192;function vl(e,n,l){if(e.subtreeFlags&ys)for(e=e.child;e!==null;)wh(e,n,l),e=e.sibling}function wh(e,n,l){switch(e.tag){case 26:vl(e,n,l),e.flags&ys&&e.memoizedState!==null&&j0(l,er,e.memoizedState,e.memoizedProps);break;case 5:vl(e,n,l);break;case 3:case 4:var o=er;er=oo(e.stateNode.containerInfo),vl(e,n,l),er=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=ys,ys=16777216,vl(e,n,l),ys=o):vl(e,n,l));break;default:vl(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 bs(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];Qt=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:bs(e),e.flags&2048&&Xr(9,e,e.return);break;case 3:bs(e);break;case 12:bs(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Ki(e)):bs(e);break;default:bs(e)}}function Ki(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];Qt=o,Nh(o,e)}Ch(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Xr(8,n,n.return),Ki(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Ki(n));break;default:Ki(n)}e=e.sibling}}function Nh(e,n){for(;Qt!==null;){var l=Qt;switch(l.tag){case 0:case 11:case 15:Xr(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:rs(l.memoizedState.cache)}if(o=l.child,o!==null)o.return=l,Qt=o;else e:for(l=e;Qt!==null;){o=Qt;var f=o.sibling,g=o.return;if(gh(o),o===l){Qt=null;break e}if(f!==null){f.return=g,Qt=f;break e}Qt=g}}}var O1={getCacheForType:function(e){var n=nn(It),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return nn(It).controller.signal}},B1=typeof WeakMap=="function"?WeakMap:Map,st=0,gt=null,Ye=null,Xe=0,ot=0,Tn=null,Qr=!1,yl=!1,_u=!1,Ar=0,Mt=0,Zr=0,Da=0,Ou=0,Rn=0,bl=0,js=null,Sn=null,Bu=!1,Xi=0,Th=0,Qi=1/0,Zi=null,Jr=null,Gt=0,ea=null,jl=null,Mr=0,Iu=0,$u=null,Rh=null,Ss=0,Uu=null;function An(){return(st&2)!==0&&Xe!==0?Xe&-Xe:A.T!==null?Wu():Vl()}function Ah(){if(Rn===0)if((Xe&536870912)===0||Je){var e=Zn;Zn<<=1,(Zn&3932160)===0&&(Zn=262144),Rn=e}else Rn=536870912;return e=En.current,e!==null&&(e.flags|=32),Rn}function kn(e,n,l){(e===gt&&(ot===2||ot===9)||e.cancelPendingCommit!==null)&&(Sl(e,0),ta(e,Xe,Rn,!1)),Bt(e,l),((st&2)===0||e!==gt)&&(e===gt&&((st&2)===0&&(Da|=l),Mt===4&&ta(e,Xe,Rn,!1)),ur(e))}function Mh(e,n,l){if((st&6)!==0)throw Error(i(327));var o=!l&&(n&127)===0&&(n&e.expiredLanes)===0||We(e,n),f=o?U1(e,n):Pu(e,n,!0),g=o;do{if(f===0){yl&&!o&&ta(e,n,0,!1);break}else{if(l=e.current.alternate,g&&!I1(l)){f=Pu(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 R=e;f=js;var P=R.current.memoizedState.isDehydrated;if(P&&(Sl(R,j).flags|=256),j=Pu(R,j,!1),j!==2){if(_u&&!P){R.errorRecoveryDisabledLanes|=g,Da|=g,f=4;break e}g=Sn,Sn=f,g!==null&&(Sn===null?Sn=g:Sn.push.apply(Sn,g))}f=j}if(g=!1,f!==2)continue}}if(f===1){Sl(e,0),ta(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:ta(o,n,Rn,!Qr);break e;case 2:Sn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((n&62914560)===n&&(f=Xi+300-qe(),10<f)){if(ta(o,n,Rn,!Qr),De(o,0,!0)!==0)break e;Mr=n,o.timeoutHandle=ox(Lh.bind(null,o,l,Sn,Zi,Bu,n,Rn,Da,bl,Qr,g,"Throttled",-0,0),f);break e}Lh(o,l,Sn,Zi,Bu,n,Rn,Da,bl,Qr,g,null,-0,0)}}break}while(!0);ur(e)}function Lh(e,n,l,o,f,g,j,R,P,Z,oe,fe,J,ae){if(e.timeoutHandle=-1,fe=n.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:xr},wh(n,g,fe);var Ce=(g&62914560)===g?Xi-qe():(g&4194048)===g?Th-qe():0;if(Ce=S0(fe,Ce),Ce!==null){Mr=g,e.cancelPendingCommit=Ce(Uh.bind(null,e,n,g,l,o,f,j,R,P,oe,fe,null,J,ae)),ta(e,g,j,!Z);return}}Uh(e,n,g,l,o,f,j,R,P)}function I1(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(!wn(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 ta(e,n,l,o){n&=~Ou,n&=~Da,e.suspendedLanes|=n,e.pingedLanes&=~n,o&&(e.warmLanes|=n),o=e.expirationTimes;for(var f=n;0<f;){var g=31-Ot(f),j=1<<g;o[g]=-1,f&=~j}l!==0&&ii(e,l,n)}function Ji(){return(st&6)===0?(ks(0),!1):!0}function Hu(){if(Ye!==null){if(ot===0)var e=Ye.return;else e=Ye,br=Ca=null,ru(e),fl=null,ls=0,e=Ye;for(;e!==null;)ch(e.alternate,e),e=e.return;Ye=null}}function Sl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,a0(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Mr=0,Hu(),gt=e,Ye=l=vr(e.current,null),Xe=n,ot=0,Tn=null,Qr=!1,yl=We(e,n),_u=!1,bl=Rn=Ou=Da=Zr=Mt=0,Sn=js=null,Bu=!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-Ot(o),g=1<<f;n|=e[f],o&=~g}return Ar=n,bi(),l}function zh(e,n){Pe=null,A.H=ps,n===dl||n===Ti?(n=Kp(),ot=3):n===Gc?(n=Kp(),ot=4):ot=n===yu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Tn=n,Ye===null&&(Mt=1,Pi(e,Un(n,e.current)))}function Dh(){var e=En.current;return e===null?!0:(Xe&4194048)===Xe?Fn===null:(Xe&62914560)===Xe||(Xe&536870912)!==0?e===Fn:!1}function _h(){var e=A.H;return A.H=ps,e===null?ps:e}function Oh(){var e=A.A;return A.A=O1,e}function eo(){Mt=4,Qr||(Xe&4194048)!==Xe&&En.current!==null||(yl=!0),(Zr&134217727)===0&&(Da&134217727)===0||gt===null||ta(gt,Xe,Rn,!1)}function Pu(e,n,l){var o=st;st|=2;var f=_h(),g=Oh();(gt!==e||Xe!==n)&&(Zi=null,Sl(e,n)),n=!1;var j=Mt;e:do try{if(ot!==0&&Ye!==null){var R=Ye,P=Tn;switch(ot){case 8:Hu(),j=6;break e;case 3:case 2:case 9:case 6:En.current===null&&(n=!0);var Z=ot;if(ot=0,Tn=null,kl(e,R,P,Z),l&&yl){j=0;break e}break;default:Z=ot,ot=0,Tn=null,kl(e,R,P,Z)}}$1(),j=Mt;break}catch(oe){zh(e,oe)}while(!0);return n&&e.shellSuspendCounter++,br=Ca=null,st=o,A.H=f,A.A=g,Ye===null&&(gt=null,Xe=0,bi()),j}function $1(){for(;Ye!==null;)Bh(Ye)}function U1(e,n){var l=st;st|=2;var o=_h(),f=Oh();gt!==e||Xe!==n?(Zi=null,Qi=qe()+500,Sl(e,n)):yl=We(e,n);e:do try{if(ot!==0&&Ye!==null){n=Ye;var g=Tn;t:switch(ot){case 1:ot=0,Tn=null,kl(e,n,g,1);break;case 2:case 9:if(qp(g)){ot=0,Tn=null,Ih(n);break}n=function(){ot!==2&&ot!==9||gt!==e||(ot=7),ur(e)},g.then(n,n);break e;case 3:ot=7;break e;case 4:ot=5;break e;case 7:qp(g)?(ot=0,Tn=null,Ih(n)):(ot=0,Tn=null,kl(e,n,g,7));break;case 5:var j=null;switch(Ye.tag){case 26:j=Ye.memoizedState;case 5:case 27:var R=Ye;if(j?kx(j):R.stateNode.complete){ot=0,Tn=null;var P=R.sibling;if(P!==null)Ye=P;else{var Z=R.return;Z!==null?(Ye=Z,to(Z)):Ye=null}break t}}ot=0,Tn=null,kl(e,n,g,5);break;case 6:ot=0,Tn=null,kl(e,n,g,6);break;case 8:Hu(),Mt=6;break e;default:throw Error(i(462))}}H1();break}catch(oe){zh(e,oe)}while(!0);return br=Ca=null,A.H=o,A.A=f,st=l,Ye!==null?0:(gt=null,Xe=0,bi(),Mt)}function H1(){for(;Ye!==null&&!Et();)Bh(Ye)}function Bh(e){var n=ih(e.alternate,e,Ar);e.memoizedProps=e.pendingProps,n===null?to(e):Ye=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,Xe);break;case 11:n=th(l,n,n.pendingProps,n.type.render,n.ref,Xe);break;case 5:ru(n);default:ch(l,n),n=Ye=Op(n,Ar),n=ih(l,n,Ar)}e.memoizedProps=e.pendingProps,n===null?to(e):Ye=n}function kl(e,n,l,o){br=Ca=null,ru(n),fl=null,ls=0;var f=n.return;try{if(R1(e,f,n,l,Xe)){Mt=1,Pi(e,Un(l,e.current)),Ye=null;return}}catch(g){if(f!==null)throw Ye=f,g;Mt=1,Pi(e,Un(l,e.current)),Ye=null;return}n.flags&32768?(Je||o===1?e=!0:yl||(Xe&536870912)!==0?e=!1:(Qr=e=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),$h(n,e)):to(n)}function to(e){var n=e;do{if((n.flags&32768)!==0){$h(n,Qr);return}e=n.return;var l=L1(n.alternate,n,Ar);if(l!==null){Ye=l;return}if(n=n.sibling,n!==null){Ye=n;return}Ye=n=e}while(n!==null);Mt===0&&(Mt=5)}function $h(e,n){do{var l=z1(e.alternate,e);if(l!==null){l.flags&=32767,Ye=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){Ye=e;return}Ye=e=l}while(e!==null);Mt=6,Ye=null}function Uh(e,n,l,o,f,g,j,R,P){e.cancelPendingCommit=null;do no();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|=Ac,Pl(e,l,g,j,R,P),e===gt&&(Ye=gt=null,Xe=0),jl=n,ea=e,Mr=l,Iu=g,$u=f,Rh=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,G1(cn,function(){return Gh(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=A.T,A.T=null,f=I.p,I.p=2,j=st,st|=4;try{D1(e,n,l)}finally{st=j,I.p=f,A.T=o}}Gt=1,Hh(),Ph(),Vh()}}function Hh(){if(Gt===1){Gt=0;var e=ea,n=jl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=A.T,A.T=null;var o=I.p;I.p=2;var f=st;st|=4;try{jh(n,e);var g=ed,j=Np(e.containerInfo),R=g.focusedElem,P=g.selectionRange;if(j!==R&&R&&R.ownerDocument&&Ep(R.ownerDocument.documentElement,R)){if(P!==null&&Cc(R)){var Z=P.start,oe=P.end;if(oe===void 0&&(oe=Z),"selectionStart"in R)R.selectionStart=Z,R.selectionEnd=Math.min(oe,R.value.length);else{var fe=R.ownerDocument||document,J=fe&&fe.defaultView||window;if(J.getSelection){var ae=J.getSelection(),Ce=R.textContent.length,ze=Math.min(P.start,Ce),ht=P.end===void 0?ze:Math.min(P.end,Ce);!ae.extend&&ze>ht&&(j=ht,ht=ze,ze=j);var K=Cp(R,ze),F=Cp(R,ht);if(K&&F&&(ae.rangeCount!==1||ae.anchorNode!==K.node||ae.anchorOffset!==K.offset||ae.focusNode!==F.node||ae.focusOffset!==F.offset)){var Q=fe.createRange();Q.setStart(K.node,K.offset),ae.removeAllRanges(),ze>ht?(ae.addRange(Q),ae.extend(F.node,F.offset)):(Q.setEnd(F.node,F.offset),ae.addRange(Q))}}}}for(fe=[],ae=R;ae=ae.parentNode;)ae.nodeType===1&&fe.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<fe.length;R++){var de=fe[R];de.element.scrollLeft=de.left,de.element.scrollTop=de.top}}ho=!!Ju,ed=Ju=null}finally{st=f,I.p=o,A.T=l}}e.current=n,Gt=2}}function Ph(){if(Gt===2){Gt=0;var e=ea,n=jl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=A.T,A.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,A.T=l}}Gt=3}}function Vh(){if(Gt===4||Gt===3){Gt=0,Ft();var e=ea,n=jl,l=Mr,o=Rh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Gt=5:(Gt=0,jl=ea=null,Fh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Jr=null),Br(l),n=n.stateNode,Ze&&typeof Ze.onCommitFiberRoot=="function")try{Ze.onCommitFiberRoot(Tt,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=A.T,f=I.p,I.p=2,A.T=null;try{for(var g=e.onRecoverableError,j=0;j<o.length;j++){var R=o[j];g(R.value,{componentStack:R.stack})}}finally{A.T=n,I.p=f}}(Mr&3)!==0&&no(),ur(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===Uu?Ss++:(Ss=0,Uu=e):Ss=0,ks(0)}}function Fh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,rs(n)))}function no(){return Hh(),Ph(),Vh(),Gh()}function Gh(){if(Gt!==5)return!1;var e=ea,n=Iu;Iu=0;var l=Br(Mr),o=A.T,f=I.p;try{I.p=32>l?32:l,A.T=null,l=$u,$u=null;var g=ea,j=Mr;if(Gt=0,jl=ea=null,Mr=0,(st&6)!==0)throw Error(i(331));var R=st;if(st|=4,Eh(g.current),kh(g,g.current,j,l),st=R,ks(0,!1),Ze&&typeof Ze.onPostCommitFiberRoot=="function")try{Ze.onPostCommitFiberRoot(Tt,g)}catch{}return!0}finally{I.p=f,A.T=o,Fh(e,n)}}function Wh(e,n,l){n=Un(l,n),n=vu(e.stateNode,n,2),e=qr(e,n,2),e!==null&&(Bt(e,2),ur(e))}function ct(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"&&(Jr===null||!Jr.has(o))){e=Un(l,e),l=qm(2),o=qr(n,l,2),o!==null&&(Ym(l,o,n,e),Bt(o,2),ur(o));break}}n=n.return}}function Vu(e,n,l){var o=e.pingCache;if(o===null){o=e.pingCache=new B1;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)||(_u=!0,f.add(l),e=P1.bind(null,e,n,l),n.then(e,e))}function P1(e,n,l){var o=e.pingCache;o!==null&&o.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,gt===e&&(Xe&l)===l&&(Mt===4||Mt===3&&(Xe&62914560)===Xe&&300>qe()-Xi?(st&2)===0&&Sl(e,0):Ou|=l,bl===Xe&&(bl=0)),ur(e)}function qh(e,n){n===0&&(n=we()),e=Sa(e,n),e!==null&&(Bt(e,n),ur(e))}function V1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),qh(e,l)}function F1(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 G1(e,n){return Vt(e,n)}var ro=null,wl=null,Fu=!1,ao=!1,Gu=!1,na=0;function ur(e){e!==wl&&e.next===null&&(wl===null?ro=wl=e:wl=wl.next=e),ao=!0,Fu||(Fu=!0,q1())}function ks(e,n){if(!Gu&&ao){Gu=!0;do for(var l=!1,o=ro;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var g=0;else{var j=o.suspendedLanes,R=o.pingedLanes;g=(1<<31-Ot(42|e)+1)-1,g&=f&~(j&~R),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,Qh(o,g))}else g=Xe,g=De(o,o===gt?g:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(g&3)===0||We(o,g)||(l=!0,Qh(o,g));o=o.next}while(l);Gu=!1}}function W1(){Yh()}function Yh(){ao=Fu=!1;var e=0;na!==0&&r0()&&(e=na);for(var n=qe(),l=null,o=ro;o!==null;){var f=o.next,g=Kh(o,n);g===0?(o.next=null,l===null?ro=f:l.next=f,f===null&&(wl=l)):(l=o,(e!==0||(g&3)!==0)&&(ao=!0)),o=f}Gt!==0&&Gt!==5||ks(e),na!==0&&(na=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-Ot(g),R=1<<j,P=f[j];P===-1?((R&l)===0||(R&o)!==0)&&(f[j]=ue(R,n)):P<=n&&(e.expiredLanes|=R),g&=~R}if(n=gt,l=Xe,l=De(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,l===0||e===n&&(ot===2||ot===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&ut(o),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||We(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(o!==null&&ut(o),Br(l)){case 2:case 8:l=Kt;break;case 32:l=cn;break;case 268435456:l=tt;break;default:l=cn}return o=Xh.bind(null,e),l=Vt(l,o),e.callbackPriority=n,e.callbackNode=l,n}return o!==null&&o!==null&&ut(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(no()&&e.callbackNode!==l)return null;var o=Xe;return o=De(e,e===gt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Mh(e,o,n),Kh(e,qe()),e.callbackNode!=null&&e.callbackNode===l?Xh.bind(null,e):null)}function Qh(e,n){if(no())return null;Mh(e,n,!0)}function q1(){l0(function(){(st&6)!==0?Vt(Jt,W1):Yh()})}function Wu(){if(na===0){var e=cl;e===0&&(e=gn,gn<<=1,(gn&261888)===0&&(gn=256)),na=e}return na}function Zh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:fi(""+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 Y1(e,n,l,o,f){if(n==="submit"&&l&&l.stateNode===f){var g=Zh((f[zt]||null).action),j=o.submitter;j&&(n=(n=j[zt]||null)?Zh(n.formAction):j.getAttribute("formAction"),n!==null&&(g=n,j=null));var R=new xi("action","action",null,o,f);e.push({event:R,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(na!==0){var P=j?Jh(f,j):new FormData(f);fu(l,{pending:!0,data:P,method:f.method,action:g},null,P)}}else typeof g=="function"&&(R.preventDefault(),P=j?Jh(f,j):new FormData(f),fu(l,{pending:!0,data:P,method:f.method,action:g},g,P))},currentTarget:f}]})}}for(var qu=0;qu<Rc.length;qu++){var Yu=Rc[qu],K1=Yu.toLowerCase(),X1=Yu[0].toUpperCase()+Yu.slice(1);Jn(K1,"on"+X1)}Jn(Ap,"onAnimationEnd"),Jn(Mp,"onAnimationIteration"),Jn(Lp,"onAnimationStart"),Jn("dblclick","onDoubleClick"),Jn("focusin","onFocus"),Jn("focusout","onBlur"),Jn(f1,"onTransitionRun"),Jn(p1,"onTransitionStart"),Jn(m1,"onTransitionCancel"),Jn(zp,"onTransitionEnd"),Ka("onMouseEnter",["mouseout","mouseover"]),Ka("onMouseLeave",["mouseout","mouseover"]),Ka("onPointerEnter",["pointerout","pointerover"]),Ka("onPointerLeave",["pointerout","pointerover"]),va("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),va("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),va("onBeforeInput",["compositionend","keypress","textInput","paste"]),va("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),va("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),va("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ws="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(" "),Q1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ws));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 R=o[j],P=R.instance,Z=R.currentTarget;if(R=R.listener,P!==g&&f.isPropagationStopped())break e;g=R,f.currentTarget=Z;try{g(f)}catch(oe){yi(oe)}f.currentTarget=null,g=P}else for(j=0;j<o.length;j++){if(R=o[j],P=R.instance,Z=R.currentTarget,R=R.listener,P!==g&&f.isPropagationStopped())break e;g=R,f.currentTarget=Z;try{g(f)}catch(oe){yi(oe)}f.currentTarget=null,g=P}}}}function Ke(e,n){var l=n[en];l===void 0&&(l=n[en]=new Set);var o=e+"__bubble";l.has(o)||(tx(n,e,2,!1),l.add(o))}function Ku(e,n,l){var o=0;n&&(o|=4),tx(l,e,o,n)}var lo="_reactListening"+Math.random().toString(36).slice(2);function Xu(e){if(!e[lo]){e[lo]=!0,Yf.forEach(function(l){l!=="selectionchange"&&(Q1.has(l)||Ku(l,!1,e),Ku(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[lo]||(n[lo]=!0,Ku("selectionchange",!1,n))}}function tx(e,n,l,o){switch(Ax(n)){case 2:var f=C0;break;case 8:f=E0;break;default:f=dd}l=f.bind(null,n,l,e),f=void 0,!xc||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 Qu(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 R=o.stateNode.containerInfo;if(R===f)break;if(j===4)for(j=o.return;j!==null;){var P=j.tag;if((P===3||P===4)&&j.stateNode.containerInfo===f)return;j=j.return}for(;R!==null;){if(j=Wa(R),j===null)return;if(P=j.tag,P===5||P===6||P===26||P===27){o=g=j;continue e}R=R.parentNode}}o=o.return}sp(function(){var Z=g,oe=mc(l),fe=[];e:{var J=Dp.get(e);if(J!==void 0){var ae=xi,Ce=e;switch(e){case"keypress":if(mi(l)===0)break e;case"keydown":case"keyup":ae=Fb;break;case"focusin":Ce="focus",ae=bc;break;case"focusout":Ce="blur",ae=bc;break;case"beforeblur":case"afterblur":ae=bc;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":ae=cp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=Lb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=qb;break;case Ap:case Mp:case Lp:ae=_b;break;case zp:ae=Kb;break;case"scroll":case"scrollend":ae=Ab;break;case"wheel":ae=Qb;break;case"copy":case"cut":case"paste":ae=Bb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=dp;break;case"toggle":case"beforetoggle":ae=Jb}var ze=(n&4)!==0,ht=!ze&&(e==="scroll"||e==="scrollend"),K=ze?J!==null?J+"Capture":null:J;ze=[];for(var F=Z,Q;F!==null;){var de=F;if(Q=de.stateNode,de=de.tag,de!==5&&de!==26&&de!==27||Q===null||K===null||(de=Wl(F,K),de!=null&&ze.push(Cs(F,de,Q))),ht)break;F=F.return}0<ze.length&&(J=new ae(J,Ce,null,l,oe),fe.push({event:J,listeners:ze}))}}if((n&7)===0){e:{if(J=e==="mouseover"||e==="pointerover",ae=e==="mouseout"||e==="pointerout",J&&l!==pc&&(Ce=l.relatedTarget||l.fromElement)&&(Wa(Ce)||Ce[Ir]))break e;if((ae||J)&&(J=oe.window===oe?oe:(J=oe.ownerDocument)?J.defaultView||J.parentWindow:window,ae?(Ce=l.relatedTarget||l.toElement,ae=Z,Ce=Ce?Wa(Ce):null,Ce!==null&&(ht=u(Ce),ze=Ce.tag,Ce!==ht||ze!==5&&ze!==27&&ze!==6)&&(Ce=null)):(ae=null,Ce=Z),ae!==Ce)){if(ze=cp,de="onMouseLeave",K="onMouseEnter",F="mouse",(e==="pointerout"||e==="pointerover")&&(ze=dp,de="onPointerLeave",K="onPointerEnter",F="pointer"),ht=ae==null?J:Gl(ae),Q=Ce==null?J:Gl(Ce),J=new ze(de,F+"leave",ae,l,oe),J.target=ht,J.relatedTarget=Q,de=null,Wa(oe)===Z&&(ze=new ze(K,F+"enter",Ce,l,oe),ze.target=Q,ze.relatedTarget=ht,de=ze),ht=de,ae&&Ce)t:{for(ze=Z1,K=ae,F=Ce,Q=0,de=K;de;de=ze(de))Q++;de=0;for(var Me=F;Me;Me=ze(Me))de++;for(;0<Q-de;)K=ze(K),Q--;for(;0<de-Q;)F=ze(F),de--;for(;Q--;){if(K===F||F!==null&&K===F.alternate){ze=K;break t}K=ze(K),F=ze(F)}ze=null}else ze=null;ae!==null&&nx(fe,J,ae,ze,!1),Ce!==null&&ht!==null&&nx(fe,ht,Ce,ze,!0)}}e:{if(J=Z?Gl(Z):window,ae=J.nodeName&&J.nodeName.toLowerCase(),ae==="select"||ae==="input"&&J.type==="file")var rt=yp;else if(gp(J))if(bp)rt=c1;else{rt=i1;var Ee=s1}else ae=J.nodeName,!ae||ae.toLowerCase()!=="input"||J.type!=="checkbox"&&J.type!=="radio"?Z&&fc(Z.elementType)&&(rt=yp):rt=o1;if(rt&&(rt=rt(e,Z))){vp(fe,rt,l,oe);break e}Ee&&Ee(e,J,Z),e==="focusout"&&Z&&J.type==="number"&&Z.memoizedProps.value!=null&&dc(J,"number",J.value)}switch(Ee=Z?Gl(Z):window,e){case"focusin":(gp(Ee)||Ee.contentEditable==="true")&&(tl=Ee,Ec=Z,es=null);break;case"focusout":es=Ec=tl=null;break;case"mousedown":Nc=!0;break;case"contextmenu":case"mouseup":case"dragend":Nc=!1,Tp(fe,l,oe);break;case"selectionchange":if(d1)break;case"keydown":case"keyup":Tp(fe,l,oe)}var Ve;if(Sc)e:{switch(e){case"compositionstart":var Qe="onCompositionStart";break e;case"compositionend":Qe="onCompositionEnd";break e;case"compositionupdate":Qe="onCompositionUpdate";break e}Qe=void 0}else el?hp(e,l)&&(Qe="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Qe="onCompositionStart");Qe&&(fp&&l.locale!=="ko"&&(el||Qe!=="onCompositionStart"?Qe==="onCompositionEnd"&&el&&(Ve=ip()):(Ur=oe,gc="value"in Ur?Ur.value:Ur.textContent,el=!0)),Ee=so(Z,Qe),0<Ee.length&&(Qe=new up(Qe,e,null,l,oe),fe.push({event:Qe,listeners:Ee}),Ve?Qe.data=Ve:(Ve=xp(l),Ve!==null&&(Qe.data=Ve)))),(Ve=t1?n1(e,l):r1(e,l))&&(Qe=so(Z,"onBeforeInput"),0<Qe.length&&(Ee=new up("onBeforeInput","beforeinput",null,l,oe),fe.push({event:Ee,listeners:Qe}),Ee.data=Ve)),Y1(fe,e,Z,l,oe)}ex(fe,n)})}function Cs(e,n,l){return{instance:e,listener:n,currentTarget:l}}function so(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=Wl(e,l),f!=null&&o.unshift(Cs(e,f,g)),f=Wl(e,n),f!=null&&o.push(Cs(e,f,g))),e.tag===3)return o;e=e.return}return[]}function Z1(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 R=l,P=R.alternate,Z=R.stateNode;if(R=R.tag,P!==null&&P===o)break;R!==5&&R!==26&&R!==27||Z===null||(P=Z,f?(Z=Wl(l,g),Z!=null&&j.unshift(Cs(l,Z,P))):f||(Z=Wl(l,g),Z!=null&&j.push(Cs(l,Z,P)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var J1=/\r\n?/g,e0=/\u0000|\uFFFD/g;function rx(e){return(typeof e=="string"?e:""+e).replace(J1,`
|
|
50
|
+
`).replace(e0,"")}function ax(e,n){return n=rx(n),rx(e)===n}function mt(e,n,l,o,f,g){switch(l){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||Qa(e,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&Qa(e,""+o);break;case"className":ui(e,"class",o);break;case"tabIndex":ui(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":ui(e,l,o);break;case"style":ap(e,o,g);break;case"data":if(n!=="object"){ui(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=fi(""+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"&&mt(e,n,"name",f.name,f,null),mt(e,n,"formEncType",f.formEncType,f,null),mt(e,n,"formMethod",f.formMethod,f,null),mt(e,n,"formTarget",f.formTarget,f,null)):(mt(e,n,"encType",f.encType,f,null),mt(e,n,"method",f.method,f,null),mt(e,n,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=fi(""+o),e.setAttribute(l,o);break;case"onClick":o!=null&&(e.onclick=xr);break;case"onScroll":o!=null&&Ke("scroll",e);break;case"onScrollEnd":o!=null&&Ke("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=fi(""+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":Ke("beforetoggle",e),Ke("toggle",e),ci(e,"popover",o);break;case"xlinkActuate":hr(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":hr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":hr(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":hr(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":hr(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":hr(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":hr(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":hr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":hr(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":ci(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=Tb.get(l)||l,ci(e,l,o))}}function Zu(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"?Qa(e,o):(typeof o=="number"||typeof o=="bigint")&&Qa(e,""+o);break;case"onScroll":o!=null&&Ke("scroll",e);break;case"onScrollEnd":o!=null&&Ke("scrollend",e);break;case"onClick":o!=null&&(e.onclick=xr);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[zt]||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,""):ci(e,l,o)}}}function an(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ke("error",e),Ke("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:mt(e,n,g,j,l,null)}}f&&mt(e,n,"srcSet",l.srcSet,l,null),o&&mt(e,n,"src",l.src,l,null);return;case"input":Ke("invalid",e);var R=g=j=f=null,P=null,Z=null;for(o in l)if(l.hasOwnProperty(o)){var oe=l[o];if(oe!=null)switch(o){case"name":f=oe;break;case"type":j=oe;break;case"checked":P=oe;break;case"defaultChecked":Z=oe;break;case"value":g=oe;break;case"defaultValue":R=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(i(137,n));break;default:mt(e,n,o,oe,l,null)}}ep(e,g,R,P,Z,j,f,!1);return;case"select":Ke("invalid",e),o=j=g=null;for(f in l)if(l.hasOwnProperty(f)&&(R=l[f],R!=null))switch(f){case"value":g=R;break;case"defaultValue":j=R;break;case"multiple":o=R;default:mt(e,n,f,R,l,null)}n=g,l=j,e.multiple=!!o,n!=null?Xa(e,!!o,n,!1):l!=null&&Xa(e,!!o,l,!0);return;case"textarea":Ke("invalid",e),g=f=o=null;for(j in l)if(l.hasOwnProperty(j)&&(R=l[j],R!=null))switch(j){case"value":o=R;break;case"defaultValue":f=R;break;case"children":g=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(i(91));break;default:mt(e,n,j,R,l,null)}np(e,o,f,g);return;case"option":for(P in l)if(l.hasOwnProperty(P)&&(o=l[P],o!=null))switch(P){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:mt(e,n,P,o,l,null)}return;case"dialog":Ke("beforetoggle",e),Ke("toggle",e),Ke("cancel",e),Ke("close",e);break;case"iframe":case"object":Ke("load",e);break;case"video":case"audio":for(o=0;o<ws.length;o++)Ke(ws[o],e);break;case"image":Ke("error",e),Ke("load",e);break;case"details":Ke("toggle",e);break;case"embed":case"source":case"link":Ke("error",e),Ke("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in l)if(l.hasOwnProperty(Z)&&(o=l[Z],o!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,n));default:mt(e,n,Z,o,l,null)}return;default:if(fc(n)){for(oe in l)l.hasOwnProperty(oe)&&(o=l[oe],o!==void 0&&Zu(e,n,oe,o,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(o=l[R],o!=null&&mt(e,n,R,o,l,null))}function t0(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,R=null,P=null,Z=null,oe=null;for(ae in l){var fe=l[ae];if(l.hasOwnProperty(ae)&&fe!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":P=fe;default:o.hasOwnProperty(ae)||mt(e,n,ae,null,o,fe)}}for(var J in o){var ae=o[J];if(fe=l[J],o.hasOwnProperty(J)&&(ae!=null||fe!=null))switch(J){case"type":g=ae;break;case"name":f=ae;break;case"checked":Z=ae;break;case"defaultChecked":oe=ae;break;case"value":j=ae;break;case"defaultValue":R=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(i(137,n));break;default:ae!==fe&&mt(e,n,J,ae,o,fe)}}uc(e,j,R,P,Z,oe,g,f);return;case"select":ae=j=R=J=null;for(g in l)if(P=l[g],l.hasOwnProperty(g)&&P!=null)switch(g){case"value":break;case"multiple":ae=P;default:o.hasOwnProperty(g)||mt(e,n,g,null,o,P)}for(f in o)if(g=o[f],P=l[f],o.hasOwnProperty(f)&&(g!=null||P!=null))switch(f){case"value":J=g;break;case"defaultValue":R=g;break;case"multiple":j=g;default:g!==P&&mt(e,n,f,g,o,P)}n=R,l=j,o=ae,J!=null?Xa(e,!!l,J,!1):!!o!=!!l&&(n!=null?Xa(e,!!l,n,!0):Xa(e,!!l,l?[]:"",!1));return;case"textarea":ae=J=null;for(R in l)if(f=l[R],l.hasOwnProperty(R)&&f!=null&&!o.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:mt(e,n,R,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":J=f;break;case"defaultValue":ae=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==g&&mt(e,n,j,f,o,g)}tp(e,J,ae);return;case"option":for(var Ce in l)if(J=l[Ce],l.hasOwnProperty(Ce)&&J!=null&&!o.hasOwnProperty(Ce))switch(Ce){case"selected":e.selected=!1;break;default:mt(e,n,Ce,null,o,J)}for(P in o)if(J=o[P],ae=l[P],o.hasOwnProperty(P)&&J!==ae&&(J!=null||ae!=null))switch(P){case"selected":e.selected=J&&typeof J!="function"&&typeof J!="symbol";break;default:mt(e,n,P,J,o,ae)}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)J=l[ze],l.hasOwnProperty(ze)&&J!=null&&!o.hasOwnProperty(ze)&&mt(e,n,ze,null,o,J);for(Z in o)if(J=o[Z],ae=l[Z],o.hasOwnProperty(Z)&&J!==ae&&(J!=null||ae!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(i(137,n));break;default:mt(e,n,Z,J,o,ae)}return;default:if(fc(n)){for(var ht in l)J=l[ht],l.hasOwnProperty(ht)&&J!==void 0&&!o.hasOwnProperty(ht)&&Zu(e,n,ht,void 0,o,J);for(oe in o)J=o[oe],ae=l[oe],!o.hasOwnProperty(oe)||J===ae||J===void 0&&ae===void 0||Zu(e,n,oe,J,o,ae);return}}for(var K in l)J=l[K],l.hasOwnProperty(K)&&J!=null&&!o.hasOwnProperty(K)&&mt(e,n,K,null,o,J);for(fe in o)J=o[fe],ae=l[fe],!o.hasOwnProperty(fe)||J===ae||J==null&&ae==null||mt(e,n,fe,J,o,ae)}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 n0(){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,R=f.duration;if(g&&R&&lx(j)){for(j=0,R=f.responseEnd,o+=1;o<l.length;o++){var P=l[o],Z=P.startTime;if(Z>R)break;var oe=P.transferSize,fe=P.initiatorType;oe&&lx(fe)&&(P=P.responseEnd,j+=oe*(P<R?1:(R-Z)/(P-Z)))}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 Ju=null,ed=null;function io(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 td(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 nd=null;function r0(){var e=window.event;return e&&e.type==="popstate"?e===nd?!1:(nd=e,!0):(nd=null,!1)}var ox=typeof setTimeout=="function"?setTimeout:void 0,a0=typeof clearTimeout=="function"?clearTimeout:void 0,cx=typeof Promise=="function"?Promise:void 0,l0=typeof queueMicrotask=="function"?queueMicrotask:typeof cx<"u"?function(e){return cx.resolve(null).then(e).catch(s0)}:ox;function s0(e){setTimeout(function(){throw e})}function ra(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),Tl(n);return}o--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")o++;else if(l==="html")Es(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,Es(l);for(var g=l.firstChild;g;){var j=g.nextSibling,R=g.nodeName;g[Fl]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=j}}else l==="body"&&Es(e.ownerDocument.body);l=f}while(l);Tl(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 rd(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":rd(l),oc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function i0(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[Fl])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=Gn(e.nextSibling),e===null)break}return null}function o0(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Gn(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=Gn(e.nextSibling),e===null))return null;return e}function ad(e){return e.data==="$?"||e.data==="$~"}function ld(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function c0(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 Gn(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 sd=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 Gn(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=io(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 Es(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);oc(e)}var Wn=new Map,xx=new Set;function oo(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Lr=I.d;I.d={f:u0,r:d0,D:f0,C:p0,L:m0,m:h0,X:g0,S:x0,M:v0};function u0(){var e=Lr.f(),n=Ji();return e||n}function d0(e){var n=qa(e);n!==null&&n.tag===5&&n.type==="form"?zm(n):Lr.r(e)}var Cl=typeof document>"u"?null:document;function gx(e,n,l){var o=Cl;if(o&&typeof n=="string"&&n){var f=In(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"),an(n,"link",e),Xt(n),o.head.appendChild(n)))}}function f0(e){Lr.D(e),gx("dns-prefetch",e,null)}function p0(e,n){Lr.C(e,n),gx("preconnect",e,n)}function m0(e,n,l){Lr.L(e,n,l);var o=Cl;if(o&&e&&n){var f='link[rel="preload"][as="'+In(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+In(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+In(l.imageSizes)+'"]')):f+='[href="'+In(e)+'"]';var g=f;switch(n){case"style":g=El(e);break;case"script":g=Nl(e)}Wn.has(g)||(e=y({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),Wn.set(g,e),o.querySelector(f)!==null||n==="style"&&o.querySelector(Ns(g))||n==="script"&&o.querySelector(Ts(g))||(n=o.createElement("link"),an(n,"link",e),Xt(n),o.head.appendChild(n)))}}function h0(e,n){Lr.m(e,n);var l=Cl;if(l&&e){var o=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+In(o)+'"][href="'+In(e)+'"]',g=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Nl(e)}if(!Wn.has(g)&&(e=y({rel:"modulepreload",href:e},n),Wn.set(g,e),l.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Ts(g)))return}o=l.createElement("link"),an(o,"link",e),Xt(o),l.head.appendChild(o)}}}function x0(e,n,l){Lr.S(e,n,l);var o=Cl;if(o&&e){var f=Ya(o).hoistableStyles,g=El(e);n=n||"default";var j=f.get(g);if(!j){var R={loading:0,preload:null};if(j=o.querySelector(Ns(g)))R.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":n},l),(l=Wn.get(g))&&id(e,l);var P=j=o.createElement("link");Xt(P),an(P,"link",e),P._p=new Promise(function(Z,oe){P.onload=Z,P.onerror=oe}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,co(j,n,o)}j={type:"stylesheet",instance:j,count:1,state:R},f.set(g,j)}}}function g0(e,n){Lr.X(e,n);var l=Cl;if(l&&e){var o=Ya(l).hoistableScripts,f=Nl(e),g=o.get(f);g||(g=l.querySelector(Ts(f)),g||(e=y({src:e,async:!0},n),(n=Wn.get(f))&&od(e,n),g=l.createElement("script"),Xt(g),an(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(f,g))}}function v0(e,n){Lr.M(e,n);var l=Cl;if(l&&e){var o=Ya(l).hoistableScripts,f=Nl(e),g=o.get(f);g||(g=l.querySelector(Ts(f)),g||(e=y({src:e,async:!0,type:"module"},n),(n=Wn.get(f))&&od(e,n),g=l.createElement("script"),Xt(g),an(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=se.current)?oo(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=El(l.href),l=Ya(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=El(l.href);var g=Ya(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(Ns(e)))&&!g._p&&(j.instance=g,j.state.loading=5),Wn.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},Wn.set(e,l),g||y0(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=Nl(l),l=Ya(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 El(e){return'href="'+In(e)+'"'}function Ns(e){return'link[rel="stylesheet"]['+e+"]"}function yx(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function y0(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}),an(n,"link",l),Xt(n),e.head.appendChild(n))}function Nl(e){return'[src="'+In(e)+'"]'}function Ts(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~="'+In(l.href)+'"]');if(o)return n.instance=o,Xt(o),o;var f=y({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Xt(o),an(o,"style",f),co(o,l.precedence,e),n.instance=o;case"stylesheet":f=El(l.href);var g=e.querySelector(Ns(f));if(g)return n.state.loading|=4,n.instance=g,Xt(g),g;o=yx(l),(f=Wn.get(f))&&id(o,f),g=(e.ownerDocument||e).createElement("link"),Xt(g);var j=g;return j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),an(g,"link",o),n.state.loading|=4,co(g,l.precedence,e),n.instance=g;case"script":return g=Nl(l.src),(f=e.querySelector(Ts(g)))?(n.instance=f,Xt(f),f):(o=l,(f=Wn.get(g))&&(o=y({},l),od(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),Xt(f),an(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,co(o,l.precedence,e));return n.instance}function co(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 R=o[j];if(R.dataset.precedence===n)g=R;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 id(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function od(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var uo=null;function jx(e,n,l){if(uo===null){var o=new Map,f=uo=new Map;f.set(l,o)}else f=uo,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[Fl]||g[Rt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var j=g.getAttribute(n)||"";j=e+j;var R=o.get(j);R?R.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 b0(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 j0(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=El(o.href),g=n.querySelector(Ns(f));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=fo.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=g,Xt(g);return}g=n.ownerDocument||n,o=yx(o),(f=Wn.get(f))&&id(o,f),g=g.createElement("link"),Xt(g);var j=g;j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),an(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=fo.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var cd=0;function S0(e,n){return e.stylesheets&&e.count===0&&mo(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var o=setTimeout(function(){if(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&cd===0&&(cd=62500*n0());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>cd?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function fo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)mo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var po=null;function mo(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,po=new Map,n.forEach(k0,e),po=null,fo.call(e))}function k0(e,n){if(!(n.state.loading&4)){var l=po.get(e);if(l)var o=l.get(null);else{l=new Map,po.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=fo.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 Rs={$$typeof:L,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function w0(e,n,l,o,f,g,j,R,P){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Le(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Le(0),this.hiddenUpdates=Le(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function wx(e,n,l,o,f,g,j,R,P,Z,oe,fe){return e=new w0(e,n,l,j,P,Z,oe,fe,R),n=1,g===!0&&(n|=24),g=Cn(3,null,null,n),e.current=g,g.stateNode=e,n=Pc(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:o,isDehydrated:l,cache:n},Wc(g),e}function Cx(e){return e?(e=al,e):al}function Ex(e,n,l,o,f,g){f=Cx(f),o.context===null?o.context=f:o.pendingContext=f,o=Wr(n),o.payload={element:l},g=g===void 0?null:g,g!==null&&(o.callback=g),l=qr(e,o,n),l!==null&&(kn(l,e,n),is(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 ud(e,n){Nx(e,n),(e=e.alternate)&&Nx(e,n)}function Tx(e){if(e.tag===13||e.tag===31){var n=Sa(e,67108864);n!==null&&kn(n,e,67108864),ud(e,67108864)}}function Rx(e){if(e.tag===13||e.tag===31){var n=An();n=Or(n);var l=Sa(e,n);l!==null&&kn(l,e,n),ud(e,n)}}var ho=!0;function C0(e,n,l,o){var f=A.T;A.T=null;var g=I.p;try{I.p=2,dd(e,n,l,o)}finally{I.p=g,A.T=f}}function E0(e,n,l,o){var f=A.T;A.T=null;var g=I.p;try{I.p=8,dd(e,n,l,o)}finally{I.p=g,A.T=f}}function dd(e,n,l,o){if(ho){var f=fd(o);if(f===null)Qu(e,n,o,xo,l),Mx(e,o);else if(T0(f,e,n,l,o))o.stopPropagation();else if(Mx(e,o),n&4&&-1<N0.indexOf(e)){for(;f!==null;){var g=qa(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var j=vt(g.pendingLanes);if(j!==0){var R=g;for(R.pendingLanes|=2,R.entangledLanes|=2;j;){var P=1<<31-Ot(j);R.entanglements[1]|=P,j&=~P}ur(g),(st&6)===0&&(Qi=qe()+500,ks(0))}}break;case 31:case 13:R=Sa(g,2),R!==null&&kn(R,g,2),Ji(),ud(g,2)}if(g=fd(o),g===null&&Qu(e,n,o,xo,l),g===f)break;f=g}f!==null&&o.stopPropagation()}else Qu(e,n,o,null,l)}}function fd(e){return e=mc(e),pd(e)}var xo=null;function pd(e){if(xo=null,e=Wa(e),e!==null){var n=u(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=d(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return xo=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(dt()){case Jt:return 2;case Kt:return 8;case cn:case ge:return 32;case tt:return 268435456;default:return 32}default:return 32}}var md=!1,aa=null,la=null,sa=null,As=new Map,Ms=new Map,ia=[],N0="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Mx(e,n){switch(e){case"focusin":case"focusout":aa=null;break;case"dragenter":case"dragleave":la=null;break;case"mouseover":case"mouseout":sa=null;break;case"pointerover":case"pointerout":As.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ms.delete(n.pointerId)}}function Ls(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=qa(n),n!==null&&Tx(n)),e):(e.eventSystemFlags|=o,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function T0(e,n,l,o,f){switch(n){case"focusin":return aa=Ls(aa,e,n,l,o,f),!0;case"dragenter":return la=Ls(la,e,n,l,o,f),!0;case"mouseover":return sa=Ls(sa,e,n,l,o,f),!0;case"pointerover":var g=f.pointerId;return As.set(g,Ls(As.get(g)||null,e,n,l,o,f)),!0;case"gotpointercapture":return g=f.pointerId,Ms.set(g,Ls(Ms.get(g)||null,e,n,l,o,f)),!0}return!1}function Lx(e){var n=Wa(e.target);if(n!==null){var l=u(n);if(l!==null){if(n=l.tag,n===13){if(n=d(l),n!==null){e.blockedOn=n,ga(e.priority,function(){Rx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,ga(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 go(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=fd(e.nativeEvent);if(l===null){l=e.nativeEvent;var o=new l.constructor(l.type,l);pc=o,l.target.dispatchEvent(o),pc=null}else return n=qa(l),n!==null&&Tx(n),e.blockedOn=l,!1;n.shift()}return!0}function zx(e,n,l){go(e)&&l.delete(n)}function R0(){md=!1,aa!==null&&go(aa)&&(aa=null),la!==null&&go(la)&&(la=null),sa!==null&&go(sa)&&(sa=null),As.forEach(zx),Ms.forEach(zx)}function vo(e,n){e.blockedOn===n&&(e.blockedOn=null,md||(md=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,R0)))}var yo=null;function Dx(e){yo!==e&&(yo=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){yo===e&&(yo=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(pd(o||l)===null)continue;break}var g=qa(l);g!==null&&(e.splice(n,3),n-=3,fu(g,{pending:!0,data:f,method:l.method,action:o},o,f))}}))}function Tl(e){function n(P){return vo(P,e)}aa!==null&&vo(aa,e),la!==null&&vo(la,e),sa!==null&&vo(sa,e),As.forEach(n),Ms.forEach(n);for(var l=0;l<ia.length;l++){var o=ia[l];o.blockedOn===e&&(o.blockedOn=null)}for(;0<ia.length&&(l=ia[0],l.blockedOn===null);)Lx(l),l.blockedOn===null&&ia.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[zt]||null;if(typeof g=="function")j||Dx(l);else if(j){var R=null;if(g&&g.hasAttribute("formAction")){if(f=g,j=g[zt]||null)R=j.formAction;else if(pd(f)!==null)continue}else R=j.action;typeof R=="function"?l[o+1]=R:(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 hd(e){this._internalRoot=e}bo.prototype.render=hd.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(i(409));var l=n.current,o=An();Ex(l,o,e,n,null,null)},bo.prototype.unmount=hd.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),Ji(),n[Ir]=null}};function bo(e){this._internalRoot=e}bo.prototype.unstable_scheduleHydration=function(e){if(e){var n=Vl();e={blockedOn:null,target:e,priority:n};for(var l=0;l<ia.length&&n!==0&&n<ia[l].priority;l++);ia.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?v(e):null,e=e===null?null:e.stateNode,e};var A0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jo.isDisabled&&jo.supportsFiber)try{Tt=jo.inject(A0),Ze=jo}catch{}}return Ds.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[Ir]=n.current,Xu(e),new hd(n)},Ds.hydrateRoot=function(e,n,l){if(!c(e))throw Error(i(299));var o=!1,f="",g=Vm,j=Fm,R=Gm,P=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&&(R=l.onRecoverableError),l.formState!==void 0&&(P=l.formState)),n=wx(e,1,!0,n,l??null,o,f,P,g,j,R,_x),n.context=Cx(null),l=n.current,o=An(),o=Or(o),f=Wr(o),f.callback=null,qr(l,f,o),l=o,n.current.lanes=l,Bt(n,l),ur(n),e[Ir]=n.current,Xu(e),new bo(n)},Ds.version="19.2.4",Ds}var Wx;function $0(){if(Wx)return vd.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(),vd.exports=I0(),vd.exports}var U0=$0();/**
|
|
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 H0(t={}){function a(c,u){let{pathname:d="/",search:h="",hash:x=""}=Bl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),nf("",{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:Ws(u))}function i(c,u){rr(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return V0(a,s,i,t)}function Yt(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function rr(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function P0(){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 nf(t,a,s=null,i,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?Bl(a):a,state:s,key:a&&a.key||i||P0(),unstable_mask:c}}function Ws({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 Bl(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 V0(t,a,s,i={}){let{window:c=document.defaultView,v5Compat:u=!1}=i,d=c.history,h="POP",x=null,m=v();m==null&&(m=0,d.replaceState({...d.state,idx:m},""));function v(){return(d.state||{idx:null}).idx}function y(){h="POP";let E=v(),T=E==null?null:E-m;m=E,x&&x({action:h,location:w.location,delta:T})}function b(E,T){h="PUSH";let N=Yx(E)?E:nf(w.location,E,T);s&&s(N,E),m=v()+1;let L=Kx(N,m),_=w.createHref(N.unstable_mask||N);try{d.pushState(L,"",_)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(_)}u&&x&&x({action:h,location:w.location,delta:1})}function S(E,T){h="REPLACE";let N=Yx(E)?E:nf(w.location,E,T);s&&s(N,E),m=v();let L=Kx(N,m),_=w.createHref(N.unstable_mask||N);d.replaceState(L,"",_),u&&x&&x({action:h,location:w.location,delta:0})}function k(E){return F0(E)}let w={get action(){return h},get location(){return t(c,d)},listen(E){if(x)throw new Error("A history only accepts one active listener");return c.addEventListener(qx,y),x=E,()=>{c.removeEventListener(qx,y),x=null}},createHref(E){return a(c,E)},createURL:k,encodeLocation(E){let T=k(E);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:b,replace:S,go(E){return d.go(E)}};return w}function F0(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:Ws(t);return i=i.replace(/ $/,"%20"),!a&&i.startsWith("//")&&(i=s+i),new URL(i,s)}function Tv(t,a,s="/"){return G0(t,a,s,!1)}function G0(t,a,s,i){let c=typeof a=="string"?Bl(a):a,u=Dr(c.pathname||"/",s);if(u==null)return null;let d=Rv(t);W0(d);let h=null;for(let x=0;h==null&&x<d.length;++x){let m=rj(u);h=tj(d[x],m,i)}return h}function Rv(t,a=[],s=[],i="",c=!1){let u=(d,h,x=c,m)=>{let v={relativePath:m===void 0?d.path||"":m,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(i)&&x)return;Yt(v.relativePath.startsWith(i),`Absolute route path "${v.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(i.length)}let y=pr([i,v.relativePath]),b=s.concat(v);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 "${y}".`),Rv(d.children,a,b,y,x)),!(d.path==null&&!d.index)&&a.push({path:y,score:J0(y,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 Av(d.path))u(d,h,!0,m)}),a}function Av(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=Av(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 W0(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:ej(a.routesMeta.map(i=>i.childrenIndex),s.routesMeta.map(i=>i.childrenIndex)))}var q0=/^:[\w-]+$/,Y0=3,K0=2,X0=1,Q0=10,Z0=-2,Xx=t=>t==="*";function J0(t,a){let s=t.split("/"),i=s.length;return s.some(Xx)&&(i+=Z0),a&&(i+=K0),s.filter(c=>!Xx(c)).reduce((c,u)=>c+(q0.test(u)?Y0:u===""?X0:Q0),i)}function ej(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 tj(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,v=u==="/"?a:a.slice(u.length)||"/",y=Po({path:x.relativePath,caseSensitive:x.caseSensitive,end:m},v),b=x.route;if(!y&&m&&s&&!i[i.length-1].route.index&&(y=Po({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},v)),!y)return null;Object.assign(c,y.params),d.push({params:c,pathname:pr([u,y.pathname]),pathnameBase:ij(pr([u,y.pathnameBase])),route:b}),y.pathnameBase!=="/"&&(u=pr([u,y.pathnameBase]))}return d}function Po(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,i]=nj(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:v,isOptional:y},b)=>{if(v==="*"){let k=h[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[b];return y&&!S?m[v]=void 0:m[v]=(S||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:d,pattern:t}}function nj(t,a=!1,s=!0){rr(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,v)=>{if(i.push({paramName:h,isOptional:x!=null}),x){let y=v.charAt(m+d.length);return y&&y!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 rj(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return rr(!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 Dr(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 aj=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function lj(t,a="/"){let{pathname:s,search:i="",hash:c=""}=typeof t=="string"?Bl(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:oj(i),hash:cj(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 Sd(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 sj(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function Mv(t){let a=sj(t);return a.map((s,i)=>i===a.length-1?s.pathname:s.pathnameBase)}function Cf(t,a,s,i=!1){let c;typeof t=="string"?c=Bl(t):(c={...t},Yt(!c.pathname||!c.pathname.includes("?"),Sd("?","pathname","search",c)),Yt(!c.pathname||!c.pathname.includes("#"),Sd("#","pathname","hash",c)),Yt(!c.search||!c.search.includes("#"),Sd("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let y=a.length-1;if(!i&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),y-=1;c.pathname=b.join("/")}h=y>=0?a[y]:"/"}let x=lj(c,h),m=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&s.endsWith("/");return!x.pathname.endsWith("/")&&(m||v)&&(x.pathname+="/"),x}var pr=t=>t.join("/").replace(/\/\/+/g,"/"),ij=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),oj=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,cj=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,uj=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 dj(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function fj(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Lv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zv(t,a){let s=t;if(typeof s!="string"||!aj.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let i=s,c=!1;if(Lv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Dr(d.pathname,a);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{rr(!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 Dv=["POST","PUT","PATCH","DELETE"];new Set(Dv);var pj=["GET",...Dv];new Set(pj);var Il=p.createContext(null);Il.displayName="DataRouter";var Ko=p.createContext(null);Ko.displayName="DataRouterState";var mj=p.createContext(!1),_v=p.createContext({isTransitioning:!1});_v.displayName="ViewTransition";var hj=p.createContext(new Map);hj.displayName="Fetchers";var xj=p.createContext(null);xj.displayName="Await";var Xn=p.createContext(null);Xn.displayName="Navigation";var Xo=p.createContext(null);Xo.displayName="Location";var _r=p.createContext({outlet:null,matches:[],isDataRoute:!1});_r.displayName="Route";var Ef=p.createContext(null);Ef.displayName="RouteError";var Ov="REACT_ROUTER_ERROR",gj="REDIRECT",vj="ROUTE_ERROR_RESPONSE";function yj(t){if(t.startsWith(`${Ov}:${gj}:{`))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 bj(t){if(t.startsWith(`${Ov}:${vj}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new uj(a.status,a.statusText,a.data)}catch{}}function jj(t,{relative:a}={}){Yt(ei(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:i}=p.useContext(Xn),{hash:c,pathname:u,search:d}=ti(t,{relative:a}),h=u;return s!=="/"&&(h=u==="/"?s:pr([s,u])),i.createHref({pathname:h,search:d,hash:c})}function ei(){return p.useContext(Xo)!=null}function pa(){return Yt(ei(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(Xo).location}var Bv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Iv(t){p.useContext(Xn).static||p.useLayoutEffect(t)}function Sj(){let{isDataRoute:t}=p.useContext(_r);return t?_j():kj()}function kj(){Yt(ei(),"useNavigate() may be used only in the context of a <Router> component.");let t=p.useContext(Il),{basename:a,navigator:s}=p.useContext(Xn),{matches:i}=p.useContext(_r),{pathname:c}=pa(),u=JSON.stringify(Mv(i)),d=p.useRef(!1);return Iv(()=>{d.current=!0}),p.useCallback((x,m={})=>{if(rr(d.current,Bv),!d.current)return;if(typeof x=="number"){s.go(x);return}let v=Cf(x,JSON.parse(u),c,m.relative==="path");t==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:pr([a,v.pathname])),(m.replace?s.replace:s.push)(v,m.state,m)},[a,s,u,c,t])}p.createContext(null);function ti(t,{relative:a}={}){let{matches:s}=p.useContext(_r),{pathname:i}=pa(),c=JSON.stringify(Mv(s));return p.useMemo(()=>Cf(t,JSON.parse(c),i,a==="path"),[t,c,i,a])}function wj(t,a,s){Yt(ei(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=p.useContext(Xn),{matches:c}=p.useContext(_r),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",x=u?u.pathnameBase:"/",m=u&&u.route;{let E=m&&m.path||"";Uv(h,!m||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${E}">) 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="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let v=pa(),y;y=v;let b=y.pathname||"/",S=b;if(x!=="/"){let E=x.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(E.length).join("/")}let k=Tv(t,{pathname:S});return rr(m||k!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),rr(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.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.`),Rj(k&&k.map(E=>Object.assign({},E,{params:Object.assign({},d,E.params),pathname:pr([x,i.encodeLocation?i.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?x:pr([x,i.encodeLocation?i.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),c,s)}function Cj(){let t=Dj(),a=dj(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 Ej=p.createElement(Cj,null),$v=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=bj(t.digest);s&&(t=s)}let a=t!==void 0?p.createElement(_r.Provider,{value:this.props.routeContext},p.createElement(Ef.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?p.createElement(Nj,{error:t},a):a}};$v.contextType=mj;var kd=new WeakMap;function Nj({children:t,error:a}){let{basename:s}=p.useContext(Xn);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let i=yj(a.digest);if(i){let c=kd.get(a);if(c)throw c;let u=zv(i.location,s);if(Lv&&!kd.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 kd.set(a,d),d}return p.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function Tj({routeContext:t,match:a,children:s}){let i=p.useContext(Il);return i&&i.static&&i.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=a.route.id),p.createElement(_r.Provider,{value:t},s)}function Rj(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 v=c.findIndex(y=>y.route.id&&(u==null?void 0:u[y.route.id])!==void 0);Yt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let d=!1,h=-1;if(s&&i){d=i.renderFallback;for(let v=0;v<c.length;v++){let y=c[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(h=v),y.route.id){let{loaderData:b,errors:S}=i,k=y.route.loader&&!b.hasOwnProperty(y.route.id)&&(!S||S[y.route.id]===void 0);if(y.route.lazy||k){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?(v,y)=>{var b,S;x(v,{location:i.location,params:((S=(b=i.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:fj(i.matches),errorInfo:y})}:void 0;return c.reduceRight((v,y,b)=>{let S,k=!1,w=null,E=null;i&&(S=u&&y.route.id?u[y.route.id]:void 0,w=y.route.errorElement||Ej,d&&(h<0&&b===0?(Uv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,E=null):h===b&&(k=!0,E=y.route.hydrateFallbackElement||null)));let T=a.concat(c.slice(0,b+1)),N=()=>{let L;return S?L=w:k?L=E:y.route.Component?L=p.createElement(y.route.Component,null):y.route.element?L=y.route.element:L=v,p.createElement(Tj,{match:y,routeContext:{outlet:v,matches:T,isDataRoute:i!=null},children:L})};return i&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?p.createElement($v,{location:i.location,revalidation:i.revalidation,component:w,error:S,children:N(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:m}):N()},null)}function Nf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Aj(t){let a=p.useContext(Il);return Yt(a,Nf(t)),a}function Mj(t){let a=p.useContext(Ko);return Yt(a,Nf(t)),a}function Lj(t){let a=p.useContext(_r);return Yt(a,Nf(t)),a}function Tf(t){let a=Lj(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 zj(){return Tf("useRouteId")}function Dj(){var i;let t=p.useContext(Ef),a=Mj("useRouteError"),s=Tf("useRouteError");return t!==void 0?t:(i=a.errors)==null?void 0:i[s]}function _j(){let{router:t}=Aj("useNavigate"),a=Tf("useNavigate"),s=p.useRef(!1);return Iv(()=>{s.current=!0}),p.useCallback(async(c,u={})=>{rr(s.current,Bv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var Zx={};function Uv(t,a,s){!a&&!Zx[t]&&(Zx[t]=!0,rr(!1,s))}p.memo(Oj);function Oj({routes:t,future:a,state:s,isStatic:i,onError:c}){return wj(t,void 0,{state:s,isStatic:i,onError:c})}function Bj({basename:t="/",children:a=null,location:s,navigationType:i="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Yt(!ei(),"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=Bl(s));let{pathname:m="/",search:v="",hash:y="",state:b=null,key:S="default",unstable_mask:k}=s,w=p.useMemo(()=>{let E=Dr(m,h);return E==null?null:{location:{pathname:E,search:v,hash:y,state:b,key:S,unstable_mask:k},navigationType:i}},[h,m,v,y,b,S,i,k]);return rr(w!=null,`<Router basename="${h}"> is not able to match the URL "${m}${v}${y}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:p.createElement(Xn.Provider,{value:x},p.createElement(Xo.Provider,{children:a,value:w}))}var Oo="get",Bo="application/x-www-form-urlencoded";function Qo(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Ij(t){return Qo(t)&&t.tagName.toLowerCase()==="button"}function $j(t){return Qo(t)&&t.tagName.toLowerCase()==="form"}function Uj(t){return Qo(t)&&t.tagName.toLowerCase()==="input"}function Hj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Pj(t,a){return t.button===0&&(!a||a==="_self")&&!Hj(t)}var So=null;function Vj(){if(So===null)try{new FormData(document.createElement("form"),0),So=!1}catch{So=!0}return So}var Fj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function wd(t){return t!=null&&!Fj.has(t)?(rr(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Bo}"`),null):t}function Gj(t,a){let s,i,c,u,d;if($j(t)){let h=t.getAttribute("action");i=h?Dr(h,a):null,s=t.getAttribute("method")||Oo,c=wd(t.getAttribute("enctype"))||Bo,u=new FormData(t)}else if(Ij(t)||Uj(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?Dr(x,a):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||Oo,c=wd(t.getAttribute("formenctype"))||wd(h.getAttribute("enctype"))||Bo,u=new FormData(h,t),!Vj()){let{name:m,type:v,value:y}=t;if(v==="image"){let b=m?`${m}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else m&&u.append(m,y)}}else{if(Qo(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Oo,i=null,c=Bo,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 Rf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Wj(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&&Dr(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 Yj(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 Kj(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 Jj(i.flat(1).filter(Yj).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 v;return s[m].pathname!==x.pathname||((v=s[m].route.path)==null?void 0:v.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 y;let v=i.routes[x.route.id];if(!v||!v.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:((y=s[0])==null?void 0:y.params)||{},nextUrl:new URL(t,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function Xj(t,a,{includeHydrateFallback:s}={}){return Qj(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 Qj(t){return[...new Set(t)]}function Zj(t){let a={},s=Object.keys(t).sort();for(let i of s)a[i]=t[i];return a}function Jj(t,a){let s=new Set;return new Set(a),t.reduce((i,c)=>{let u=JSON.stringify(Zj(c));return s.has(u)||(s.add(u),i.push({key:u,link:c})),i},[])}function Hv(){let t=p.useContext(Il);return Rf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function eS(){let t=p.useContext(Ko);return Rf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Af=p.createContext(void 0);Af.displayName="FrameworkContext";function Pv(){let t=p.useContext(Af);return Rf(t,"You must render this element inside a <HydratedRouter> element"),t}function tS(t,a){let s=p.useContext(Af),[i,c]=p.useState(!1),[u,d]=p.useState(!1),{onFocus:h,onBlur:x,onMouseEnter:m,onMouseLeave:v,onTouchStart:y}=a,b=p.useRef(null);p.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let w=T=>{T.forEach(N=>{d(N.isIntersecting)})},E=new IntersectionObserver(w,{threshold:.5});return b.current&&E.observe(b.current),()=>{E.disconnect()}}},[t]),p.useEffect(()=>{if(i){let w=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(w)}}},[i]);let S=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:_s(h,S),onBlur:_s(x,k),onMouseEnter:_s(m,S),onMouseLeave:_s(v,k),onTouchStart:_s(y,S)}]:[!1,b,{}]}function _s(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function nS({page:t,...a}){let{router:s}=Hv(),i=p.useMemo(()=>Tv(s.routes,t,s.basename),[s.routes,t,s.basename]);return i?p.createElement(aS,{page:t,matches:i,...a}):null}function rS(t){let{manifest:a,routeModules:s}=Pv(),[i,c]=p.useState([]);return p.useEffect(()=>{let u=!1;return Kj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),i}function aS({page:t,matches:a,...s}){let i=pa(),{future:c,manifest:u,routeModules:d}=Pv(),{basename:h}=Hv(),{loaderData:x,matches:m}=eS(),v=p.useMemo(()=>Jx(t,a,m,u,i,"data"),[t,a,m,u,i]),y=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 w=new Set,E=!1;if(a.forEach(N=>{var _;let L=u.routes[N.route.id];!L||!L.hasLoader||(!v.some(D=>D.route.id===N.route.id)&&N.route.id in x&&((_=d[N.route.id])!=null&&_.shouldRevalidate)||L.hasClientLoader?E=!0:w.add(N.route.id))}),w.size===0)return[];let T=Wj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return E&&w.size>0&&T.searchParams.set("_routes",a.filter(N=>w.has(N.route.id)).map(N=>N.route.id).join(",")),[T.pathname+T.search]},[h,c.unstable_trailingSlashAwareDataRequests,x,i,u,v,a,t,d]),S=p.useMemo(()=>Xj(y,u),[y,u]),k=rS(y);return p.createElement(p.Fragment,null,b.map(w=>p.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...s})),S.map(w=>p.createElement("link",{key:w,rel:"modulepreload",href:w,...s})),k.map(({key:w,link:E})=>p.createElement("link",{key:w,nonce:s.nonce,...E,crossOrigin:E.crossOrigin??s.crossOrigin})))}function lS(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var sS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{sS&&(window.__reactRouterVersion="7.13.1")}catch{}function iS({basename:t,children:a,unstable_useTransitions:s,window:i}){let c=p.useRef();c.current==null&&(c.current=H0({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(Bj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Vv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fv=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:v,preventScrollReset:y,viewTransition:b,unstable_defaultShouldRevalidate:S,...k},w){let{basename:E,navigator:T,unstable_useTransitions:N}=p.useContext(Xn),L=typeof v=="string"&&Vv.test(v),_=zv(v,E);v=_.to;let D=jj(v,{relative:c}),V=pa(),C=null;if(h){let H=Cf(h,[],V.unstable_mask?V.unstable_mask.pathname:"/",!0);E!=="/"&&(H.pathname=H.pathname==="/"?E:pr([E,H.pathname])),C=T.createHref(H)}let[B,M,$]=tS(i,k),U=dS(v,{replace:d,unstable_mask:h,state:x,target:m,preventScrollReset:y,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:N});function q(H){a&&a(H),H.defaultPrevented||U(H)}let X=!(_.isExternal||u),ee=p.createElement("a",{...k,...$,href:(X?C:void 0)||_.absoluteURL||D,onClick:X?q:a,ref:lS(w,M),target:m,"data-discover":!L&&s==="render"?"true":void 0});return B&&!L?p.createElement(p.Fragment,null,ee,p.createElement(nS,{page:D})):ee});Fv.displayName="Link";var oS=p.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:i="",end:c=!1,style:u,to:d,viewTransition:h,children:x,...m},v){let y=ti(d,{relative:m.relative}),b=pa(),S=p.useContext(Ko),{navigator:k,basename:w}=p.useContext(Xn),E=S!=null&&xS(y)&&h===!0,T=k.encodeLocation?k.encodeLocation(y).pathname:y.pathname,N=b.pathname,L=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(N=N.toLowerCase(),L=L?L.toLowerCase():null,T=T.toLowerCase()),L&&w&&(L=Dr(L,w)||L);const _=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let D=N===T||!c&&N.startsWith(T)&&N.charAt(_)==="/",V=L!=null&&(L===T||!c&&L.startsWith(T)&&L.charAt(T.length)==="/"),C={isActive:D,isPending:V,isTransitioning:E},B=D?a:void 0,M;typeof i=="function"?M=i(C):M=[i,D?"active":null,V?"pending":null,E?"transitioning":null].filter(Boolean).join(" ");let $=typeof u=="function"?u(C):u;return p.createElement(Fv,{...m,"aria-current":B,className:M,ref:v,style:$,to:d,viewTransition:h},typeof x=="function"?x(C):x)});oS.displayName="NavLink";var cS=p.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:i,replace:c,state:u,method:d=Oo,action:h,onSubmit:x,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b,...S},k)=>{let{unstable_useTransitions:w}=p.useContext(Xn),E=mS(),T=hS(h,{relative:m}),N=d.toLowerCase()==="get"?"get":"post",L=typeof h=="string"&&Vv.test(h),_=D=>{if(x&&x(D),D.defaultPrevented)return;D.preventDefault();let V=D.nativeEvent.submitter,C=(V==null?void 0:V.getAttribute("formmethod"))||d,B=()=>E(V||D.currentTarget,{fetcherKey:a,method:C,navigate:s,replace:c,state:u,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b});w&&s!==!1?p.startTransition(()=>B()):B()};return p.createElement("form",{ref:k,method:N,action:T,onSubmit:i?x:_,...S,"data-discover":!L&&t==="render"?"true":void 0})});cS.displayName="Form";function uS(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Gv(t){let a=p.useContext(Il);return Yt(a,uS(t)),a}function dS(t,{target:a,replace:s,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:x,unstable_useTransitions:m}={}){let v=Sj(),y=pa(),b=ti(t,{relative:d});return p.useCallback(S=>{if(Pj(S,a)){S.preventDefault();let k=s!==void 0?s:Ws(y)===Ws(b),w=()=>v(t,{replace:k,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:x});m?p.startTransition(()=>w()):w()}},[y,v,b,s,i,c,a,t,u,d,h,x,m])}var fS=0,pS=()=>`__${String(++fS)}__`;function mS(){let{router:t}=Gv("useSubmit"),{basename:a}=p.useContext(Xn),s=zj(),i=t.fetch,c=t.navigate;return p.useCallback(async(u,d={})=>{let{action:h,method:x,encType:m,formData:v,body:y}=Gj(u,a);if(d.navigate===!1){let b=d.fetcherKey||pS();await i(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,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:v,body:y,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 hS(t,{relative:a}={}){let{basename:s}=p.useContext(Xn),i=p.useContext(_r);Yt(i,"useFormAction must be used inside a RouteContext");let[c]=i.matches.slice(-1),u={...ti(t||".",{relative:a})},d=pa();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),x=h.getAll("index");if(x.some(v=>v==="")){h.delete("index"),x.filter(y=>y).forEach(y=>h.append("index",y));let v=h.toString();u.search=v?`?${v}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:pr([s,u.pathname])),Ws(u)}function xS(t,{relative:a}={}){let s=p.useContext(_v);Yt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Gv("useViewTransitionState"),c=ti(t,{relative:a});if(!s.isTransitioning)return!1;let u=Dr(s.currentLocation.pathname,i)||s.currentLocation.pathname,d=Dr(s.nextLocation.pathname,i)||s.nextLocation.pathname;return Po(c.pathname,d)!=null||Po(c.pathname,u)!=null}var Zo=Nv();const gS=Ev(Zo),vS="modulepreload",yS=function(t){return"/"+t},eg={},Ha=function(a,s,i){let c=Promise.resolve();if(s&&s.length>0){let d=function(m){return Promise.all(m.map(v=>Promise.resolve(v).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};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=yS(m),m in eg)return;eg[m]=!0;const v=m.endsWith(".css"),y=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${y}`))return;const b=document.createElement("link");if(b.rel=v?"stylesheet":vS,v||(b.as="script"),b.crossOrigin="",b.href=m,x&&b.setAttribute("nonce",x),document.head.appendChild(b),v)return new Promise((S,k)=>{b.addEventListener("load",S),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return c.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return a().catch(u)})},bS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Cd(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!bS.test(a)||a==="0.0.0"?null:a}function Wv(t){const a=Cd(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=Cd(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const i=Cd(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"},rf=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function jS(t){if(typeof t=="string"){if(rf.has(t))return t;if(Object.prototype.hasOwnProperty.call(tg,t))return tg[t]}return"authoring-project"}function SS(t){return t.startsWith("available-")?"available":"authoring"}function kS(t){const a=t.indexOf("-");return t.slice(a+1)}const qn="";class Ml extends Error{constructor(a,s,i){super(a),this.name="ApiError",this.status=s,this.details=i}}async function $e(t,a){const s=await fetch(`${qn}${t}`,a);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText})),c=i&&typeof i=="object"?i:void 0;throw new Ml((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 Zt(t){return typeof t=="string"&&t.length>0?t:null}function wS(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function Ed(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 CS(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"&&rf.has(a.scopeV2)?a.scopeV2:jS(a.scope),d=SS(u),h=kS(u),x=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let m;a.shadowedBy===null?m=null:typeof a.shadowedBy=="string"&&rf.has(a.shadowedBy)?m=a.shadowedBy:m=void 0;const v={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:Zt(a.symlinkTarget),installMethod:c,sourcePath:Zt(a.sourcePath),scopeV2:u,group:d,source:h,pluginName:Zt(a.pluginName),pluginNamespace:Zt(a.pluginNamespace),pluginMarketplace:Zt(a.pluginMarketplace),pluginManifestPath:Zt(a.pluginManifestPath),pluginVersion:Zt(a.pluginVersion),precedenceRank:x,shadowedBy:m,description:Zt(a.description),version:Zt(a.version),category:Zt(a.category),author:Zt(a.author),license:Zt(a.license),homepage:Zt(a.homepage),repoUrl:Zt(a.repoUrl),skillPath:Zt(a.skillPath),tags:Ed(a.tags),deps:Ed(a.deps),mcpDeps:Ed(a.mcpDeps),entryPoint:Zt(a.entryPoint),lastModified:Zt(a.lastModified),sizeBytes:wS(a.sizeBytes),sourceAgent:Zt(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"?v.provenance={promotedFrom:b.promotedFrom,sourcePath:b.sourcePath,promotedAt:b.promotedAt,sourceSkillVersion:typeof b.sourceSkillVersion=="string"?b.sourceSkillVersion:void 0}:v.provenance=null}else a.provenance===null&&(v.provenance=null);typeof a.updateAvailable=="boolean"&&(v.updateAvailable=a.updateAvailable),typeof a.currentVersion=="string"&&(v.currentVersion=a.currentVersion),typeof a.latestVersion=="string"&&(v.latestVersion=a.latestVersion),typeof a.pinnedVersion=="string"&&(v.pinnedVersion=a.pinnedVersion);const y=Wv({frontmatterVersion:v.version??null,registryCurrentVersion:v.currentVersion??null,pluginVersion:v.pluginVersion??null});return v.resolvedVersion=y.version,v.versionSource=y.versionSource,v}const Se={getConfig(){return $e("/api/config")},setConfig(t,a){return $e("/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 $e(`/api/skills${s?"?"+s:""}`);return Array.isArray(i)?i.map(CS):[]},getAgents(){return $e("/api/agents")},getSkillDetail(t,a){return $e(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await $e(`/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 $e(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return $e(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return $e(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return $e(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${qn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText}));throw new Ml(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 $e(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return $e(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,i){return $e(`/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 $e(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return $e(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return $e(`/api/skills/${t}/${a}`,{method:"DELETE"})},improveSkill(t,a,s){return $e(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return $e(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return $e(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return $e(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return $e(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return $e("/api/project-layout")},getProjectGitHubStatus(){return $e("/api/project/github-status")},createSkill(t){return $e("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return $e("/api/studio/detect-engines")},saveDraft(t){return $e("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return $e("/api/skill-creator-status")},generateSkill(t){return $e("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return $e(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return $e(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,i){return $e(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:i})})},getLeaderboard(t,a){return $e(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return $e(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const i=`${qn}/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 $e(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,i){return $e(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:i})})},getParams(t,a){return $e(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const i=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return $e(`/api/credentials/${t}/${a}/params?${i}`)},searchModels(){return $e("/api/openrouter/models")},async getSkillVersions(t,a){const s=await $e(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return $e(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,i){return $e(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${i}`)},startBatchUpdate(t){const a=`${qn}/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=`${qn}/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 v=s;i=v.signal,c=v.agentId}const u=c?`?agent=${encodeURIComponent(c)}`:"",d=`${qn}/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 v=h.body.getReader(),y=new TextDecoder;let b=!1,S="";for(;!b;){const w=await v.read();if(b=w.done,w.value){const E=y.decode(w.value,{stream:!b});S+=E,m.length<200&&(m+=E)}}const k=S.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(k)try{x=JSON.parse(k[1]).version}catch{}m=m.slice(0,200)}else{const v=await h.text();m=v.slice(0,200);const y=v.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(y)try{x=JSON.parse(y[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(`${qn}/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(`${qn}/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(`${qn}/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(`${qn}/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 Nd(`/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 Nd(`/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 Nd(`/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 $e(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return $e(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${qn}/api/studio/ops/stream`)},gitRemote(){return $e("/api/git/remote")},gitDiff(){return $e("/api/git/diff",{method:"POST"})},gitStatus(){return $e("/api/git/status")},gitCommitMessage(t){return $e("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})},gitPublish(t){return $e("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})}};async function Nd(t,a,s){const i=await fetch(`${qn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!i.ok||!i.body){let v=`HTTP ${i.status}`,y;try{const S=await i.json();S.error&&(v=S.error),typeof S.code=="string"&&(y=S.code)}catch{}const b=new Ml(v,i.status);throw y&&(b.code=y),b}const c=i.body.getReader(),u=new TextDecoder;let d="",h="",x=null,m=null;for(;;){const{done:v,value:y}=await c.read();if(v)break;d+=u.decode(y,{stream:!0});const b=d.split(`
|
|
62
|
+
`);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const w={type:h,...k};a==null||a(w),w.type==="done"&&(x=w),w.type==="error"&&(m=w)}h=""}}if(m){const v=new Ml(m.message,500);throw v.code=m.code,v}if(!x)throw new Ml("Transfer stream ended without 'done' event",500);return x}function ES(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,v]=c.map(Number);return u!==x?u>x:d!==m?d>m:h>=v}function NS(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&&!ES(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=Wv({frontmatterVersion:h.version??null,registryCurrentVersion:h.currentVersion??null,pluginVersion:h.pluginVersion??null});return h.resolvedVersion=x.version,h.versionSource=x.versionSource,h})}const Io=new Map,Ba=new Map,Us=new Map;function Ln(t){Io.delete(t),Ba.delete(t);const a=Us.get(t);if(a)for(const s of a)s()}function $l(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),v=p.useRef(!0),y=p.useRef(t);y.current=t;const b=()=>{h(void 0),Ln(t),m(w=>w+1)};p.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),p.useEffect(()=>{if(!c)return;const w=()=>{v.current&&m(E=>E+1)};return Us.has(t)||Us.set(t,new Set),Us.get(t).add(w),()=>{var E;(E=Us.get(t))==null||E.delete(w)}},[t,c]),p.useEffect(()=>{if(!c)return;const w=Io.get(t);if(!(!w||Date.now()-w.fetchedAt>i))return;if(Ba.has(t)){const L=Ba.get(t),_=()=>{v.current&&y.current===t&&u(D=>D+1)};L.subscribers.push(_);return}const T={promise:Promise.resolve(),subscribers:[]},N=a().then(L=>{Io.set(t,{data:L,fetchedAt:Date.now()}),Ba.delete(t),v.current&&y.current===t&&(h(void 0),u(_=>_+1));for(const _ of T.subscribers)_()},L=>{Ba.delete(t);const _=L instanceof Error?L:new Error(String(L));v.current&&y.current===t&&(h(_),u(D=>D+1));for(const D of T.subscribers)D()});T.promise=N,Ba.set(t,T)},[t,a,i,c,x]);const S=Io.get(t),k=c&&!S&&!d&&Ba.has(t);return{data:S==null?void 0:S.data,loading:k,error:d,revalidate:b}}function TS(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 RS=500,af="vskill.updates.seenLastId";function AS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(af)}catch{return null}}function Td(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(af):window.localStorage.setItem(af,t)}catch{}}function MS(){let t=new Map;const a=new Set,s=new Set,i=[];let c=AS();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>RS){const x=i.shift();x&&s.delete(x)}c=h,Td(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,Td(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,Td(null),u()}}}const _a=MS(),LS=3e5,zS=500,DS=15e3,_S=6e4,OS=6e4,BS="/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 IS(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 $S(t){const a=(t==null?void 0:t.intervalMs)??LS,s=(t==null?void 0:t.debounceMs)??zS,i=(t==null?void 0:t.timeoutMs)??DS,c=(t==null?void 0:t.staleAfterMs)??_S,u=(t==null?void 0:t.disconnectFallbackMs)??OS,d=(t==null?void 0:t.streamUrlBase)??BS,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 z=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return z.length===0?"":[...z].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[m,v]=p.useState([]),[y,b]=p.useState(()=>new Map),[S,k]=p.useState(0),[w,E]=p.useState(!1),[T,N]=p.useState(null),[L,_]=p.useState(null),D=p.useRef(null),V=p.useRef(null),C=p.useRef(null),B=p.useRef(null),M=p.useRef(!0),[$,U]=p.useState(()=>h?"connecting":"fallback"),q=p.useRef($);q.current=$;const X=p.useSyncExternalStore(z=>_a.subscribe(z),()=>_a.getSnapshot(),()=>_a.getSnapshot()),ee=X.size,H=p.useCallback(async()=>{E(!0);const z=new AbortController,W=setTimeout(()=>z.abort(),i);try{const re=await Promise.race([Se.getSkillUpdates(),new Promise((Y,ce)=>{z.signal.addEventListener("abort",()=>{ce(new Error("TIMEOUT"))})})]);if(re==="TIMEOUT")throw new Error("TIMEOUT");if(!M.current)return;v(re),b(rg(re)),k(ag(re)),V.current=Date.now(),N(V.current),_(null)}catch(re){if(!M.current)return;_(re instanceof Error?re:new Error(String(re)))}finally{clearTimeout(W),M.current&&E(!1)}},[i]),A=p.useCallback(()=>{if(D.current)return D.current;const z=H().finally(()=>{D.current=null});return D.current=z,z},[H]),I=p.useCallback(()=>{C.current==null&&(C.current=setInterval(()=>{A()},a))},[a,A]),G=p.useCallback(()=>{C.current!=null&&(clearInterval(C.current),C.current=null)},[]);p.useEffect(()=>{M.current=!0,(V.current==null||Date.now()-V.current>c)&&A(),(typeof document>"u"||document.visibilityState!=="hidden")&&I();const re=()=>{if(B.current&&(clearTimeout(B.current),B.current=null),document.visibilityState==="hidden"){G();return}B.current=setTimeout(()=>{B.current=null,(V.current==null||Date.now()-V.current>c)&&A(),I()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",re),()=>{M.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",re),B.current&&clearTimeout(B.current),G()}},[]);const O=p.useCallback(async z=>{if(z.length!==0)try{const W=await Se.checkSkillUpdates(z);if(!M.current||W.length===0)return;const re=Date.now(),Y=W.filter(se=>se.skillId&&se.eventId&&se.version).map(se=>({skillId:se.skillId,version:se.version,eventId:se.eventId,publishedAt:se.publishedAt,diffSummary:se.diffSummary,receivedAt:re}));Y.length>0&&_a.mergeBulk(Y);const ce=W.filter(se=>typeof se.trackedForUpdates=="boolean"||typeof se.updateAvailable=="boolean").map(se=>({name:se.name??se.skillId,installed:se.installed??"",latest:se.latest??null,updateAvailable:se.updateAvailable??!1,trackedForUpdates:typeof se.trackedForUpdates=="boolean"?se.trackedForUpdates:void 0}));ce.length>0&&v(se=>{const be=new Map;for(const Re of se)be.set(Re.name.split("/").pop()||Re.name,Re);let ie=0;for(const Re of ce){const Ae=Re.name.split("/").pop()||Re.name,le=be.get(Ae);if(le){const he={...le};le.trackedForUpdates===void 0&&Re.trackedForUpdates!==void 0&&(he.trackedForUpdates=Re.trackedForUpdates),be.set(Ae,he)}else be.set(Ae,{name:Re.name,installed:Re.installed??"",latest:Re.latest??null,updateAvailable:Re.updateAvailable??!1,trackedForUpdates:Re.trackedForUpdates}),ie+=1}if(ie===0&&be.size===se.length)return se;const ye=[...be.values()];return b(rg(ye)),k(ag(ye)),ye})}catch{}},[]);p.useEffect(()=>{const z=h||x;if(!z){U("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){U("fallback");return}U("connecting");const W=z.split(","),re=`${d}?skills=${encodeURIComponent(z)}`;let Y=null,ce=null,se=null;const be=()=>{ce==null&&(ce=setTimeout(()=>{ce=null,M.current&&q.current!=="connected"&&U("fallback")},u))},ie=()=>{ce!=null&&(clearTimeout(ce),ce=null)};be();const ye=1e3,Re=()=>{M.current&&se==null&&(se=setTimeout(()=>{if(se=null,!!M.current&&!(Y&&Y.readyState!==EventSource.CLOSED)){if(Y)try{Y.close()}catch{}he()}},ye))},Ae=pe=>{if(!M.current)return;let xe;try{xe=JSON.parse(pe.data)}catch{return}if(!IS(xe)||_a.ingest(xe)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Ie=`${xe.skillId} updated to ${xe.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Ie,severity:"info",skillId:xe.skillId,version:xe.version,eventId:xe.eventId}}))}},le=()=>{M.current&&(_a.clearSeen(),O(W))},he=()=>{M.current&&(Y=new EventSource(re),Y.onopen=()=>{M.current&&(ie(),U("connected"))},Y.onerror=()=>{M.current&&(be(),Y&&Y.readyState===EventSource.CLOSED&&Re())},Y.onmessage=Ae,Y.addEventListener("gone",le))};return he(),()=>{if(ie(),se!=null&&(clearTimeout(se),se=null),Y){try{Y.removeEventListener("gone",le)}catch{}try{Y.close()}catch{}}}},[h,x,d,u,O]),p.useEffect(()=>{if(!x)return;const z=x.split(",");O(z)},[x,O]);const ne=p.useCallback(z=>{_a.dismiss(z)},[]);return{updates:m,updatesMap:y,updateCount:S,isRefreshing:w,lastFetchAt:T,error:L,refresh:A,updatesById:X,pushUpdateCount:ee,status:$,dismiss:ne}}function US(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 HS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function PS(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 qv=p.createContext(null),Yv=qv;function lr(){const t=p.useContext(Yv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function VS({children:t}){const[a,s]=p.useReducer(PS,HS),i=TS("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=p.useState(()=>{try{const O=window.localStorage.getItem("vskill.studio.prefs");if(!O)return null;const ne=JSON.parse(O);return typeof ne.activeAgent=="string"?ne.activeAgent:null}catch{return null}}),[d,h]=p.useState(c!==null);p.useEffect(()=>{function O(ne){if(!(ne instanceof CustomEvent))return;const z=ne.detail;z!=null&&z.agentId&&(u(z.agentId),h(!0))}return window.addEventListener("studio:agent-changed",O),()=>window.removeEventListener("studio:agent-changed",O)},[]),p.useEffect(()=>{if(d)return;let O=!1;return Se.getAgents().then(ne=>{if(O)return;const z=(ne==null?void 0:ne.suggested)??"claude-code";u(W=>W??z),h(!0)}).catch(()=>{O||(u(ne=>ne??"claude-code"),h(!0))}),()=>{O=!0}},[d]);const x=p.useCallback(()=>{if(!d||!c)return Promise.resolve();s({type:"SET_SKILLS_LOADING",loading:!0});const O={agent:c};return Se.getSkills(O).then(ne=>{s({type:"SET_SKILLS",skills:ne});const W=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(W){const[,re,Y]=W,ce=ne.find(se=>se.plugin===re&&se.skill===Y);ce&&s({type:"SELECT_SKILL",skill:{plugin:re,skill:Y,origin:ce.origin}})}}).catch(ne=>s({type:"SET_SKILLS_ERROR",error:ne.message}))},[c,d]);p.useEffect(()=>{x()},[x]);const m=p.useCallback(O=>{s({type:"SELECT_SKILL",skill:O}),window.location.hash=`/skills/${O.plugin}/${O.skill}`},[]),v=p.useRef(a.skills);p.useEffect(()=>{v.current=a.skills},[a.skills]);const y=p.useCallback((O,ne)=>{const z=v.current,W=O?z.find(ce=>ce.plugin===O&&ce.skill===ne):z.find(ce=>ce.skill===ne&&ce.source!=="plugin");if(!O&&!W){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${ne}" not yet in state — skipping reveal`);return}const re=(W==null?void 0:W.plugin)??O,Y=(W==null?void 0:W.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:re,skill:ne,origin:Y}}),window.location.hash=`/skills/${re}/${ne}`},[]),b=p.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=p.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=p.useCallback(O=>{s({type:"SET_MODE",mode:O})},[]),w=p.useCallback(O=>{s({type:"SET_SEARCH",query:O})},[]),E=p.useCallback(O=>{s({type:"SET_MOBILE_VIEW",view:O})},[]),T=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),N=p.useRef(new Map),L=p.useRef(""),_=p.useRef(!1),[D,V]=p.useState(""),C=p.useMemo(()=>a.skills.map(O=>`${O.plugin}/${O.skill}`),[a.skills]),B=p.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),M=$S({skillIds:B,trackingSkillIds:C}),$=p.useRef("");p.useEffect(()=>{const O=a.skills.filter(Y=>Y.origin==="installed");if(O.length===0){V(""),$.current="";return}const ne=new Map;for(const Y of M.updates)ne.set(Y.name.split("/").pop()||Y.name,Y);const z=O.map(Y=>{const ce=ne.get(Y.skill),se=Y.currentVersion??(ce==null?void 0:ce.installed)??Y.version??Y.pluginVersion??"1.0.0";return{plugin:Y.plugin,skill:Y.skill,name:(ce==null?void 0:ce.name)??Y.skill,currentVersion:se}}),W=z.map(Y=>`${Y.plugin}/${Y.skill}@${Y.currentVersion}#${Y.name}`).sort().join("|");if(W===$.current)return;$.current=W;let re=!1;return Se.resolveInstalledSkillIds(z).then(Y=>{if(re)return;const be=[...US(Y).flatMap(ie=>[ie.uuid,ie.slug].filter(Boolean))].sort().join(",");be!==L.current&&(L.current=be,N.current=new Map(Y.map(ie=>[`${ie.plugin}/${ie.skill}`,{uuid:ie.uuid,slug:ie.slug}])),V(be))}).catch(Y=>{if(re||($.current=""),!_.current){_.current=!0;const ce=Y instanceof Error?Y.message:String(Y);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",ce)}}),()=>{re=!0}},[a.skills,M.updates]);const U=p.useMemo(()=>{const O=a.skills.map(ne=>{if(!ne.updateAvailable&&ne.latestVersion===void 0&&ne.trackedForUpdates===void 0)return ne;const z={...ne};return delete z.updateAvailable,delete z.currentVersion,delete z.latestVersion,delete z.trackedForUpdates,z});return NS(O,M.updates)},[a.skills,M.updates]),q=p.useMemo(()=>{const O={source:0,installed:0};for(const ne of U)ne.updateAvailable&&(O[ne.origin]+=1);return O},[U]),X=p.useMemo(()=>({...a,skills:U}),[a,U]),ee=M.updateCount,H=M.refresh,A=M.isRefreshing,I=p.useCallback((O,ne)=>{H(),x(),Ln(`versions/${O}/${ne}`),M.dismiss(`${O}/${ne}`)},[H,x,M]),G=p.useMemo(()=>({state:X,selectSkill:m,clearSelection:S,setMode:k,setSearch:w,setMobileView:E,refreshSkills:x,updateCount:ee,dismissUpdateNotification:T,updates:M.updates,outdatedByOrigin:q,isRefreshingUpdates:A,refreshUpdates:H,revealSkill:y,clearReveal:b,updatesById:M.updatesById,pushUpdateCount:M.pushUpdateCount,updateStreamStatus:M.status,dismissPushUpdate:M.dismiss,activeAgent:c,onSkillUpdated:I}),[X,m,S,k,w,E,x,ee,T,M.updates,q,A,H,y,b,M.updatesById,M.pushUpdateCount,M.status,M.dismiss,c,I]);return r.jsx(Yv.Provider,{value:G,children:t})}const FS={config:null,loading:!0};function GS(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 Kv=p.createContext(null);function Pa(){const t=p.useContext(Kv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function WS({children:t}){const[a,s]=p.useReducer(GS,FS),i=p.useCallback(()=>{Se.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{i()},[i]);const c=p.useCallback(async(d,h)=>{const x=await Se.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(Kv.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)"},v={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:v,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"],YS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},KS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},XS={"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"},QS={"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 ZS(t,a){var h,x;const s=YS[t.id]??null,i=KS[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:QS[t.id]??"per-token",...m.pricing?{pricing:m.pricing}:{},...m.resolvedId?{resolvedId:m.resolvedId}:{}}));return{id:t.id,displayName:JS(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:XS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function JS(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 e2(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 t2(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),v=p.useRef(0),y=p.useRef(t==null?void 0:t.onStaleCatalog),b=p.useRef(t==null?void 0:t.onSetActiveError);p.useEffect(()=>{y.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 N=await fetch("/api/config");if(!N.ok)throw new Error(`/api/config returned ${N.status}`);const L=await N.json(),_=e2((L.providers||[]).map(D=>ZS(D,L.detection)));s({agents:_,activeAgent:L.provider??null,activeModel:L.model??null}),c("ready"),d(null)}catch(N){c("error"),d(N.message)}},[]);p.useEffect(()=>{S()},[S]);const k=p.useCallback(async()=>{var L;const N=Date.now();if(!(N-v.current<5*6e4))try{const _=await fetch("/api/openrouter/models");if(!_.ok){_.status!==400&&x(`OpenRouter catalog fetch failed (${_.status})`);return}const D=await _.json();v.current=N,x(null),s(B=>{if(!B)return B;const M=B.agents.map($=>{if($.id!=="openrouter")return $;const U=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...$,models:U,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...B,agents:M}});const V=D.ageSec??0;(D.stale===!0||V>600)&&((L=y.current)==null||L.call(y,"openrouter",V*1e3))}catch(_){x(`OpenRouter catalog unreachable: ${_.message}`)}},[]),w=p.useCallback(N=>{m.current=N,N==="openrouter"&&k()},[k]),E=p.useCallback(()=>{v.current=0,S()},[S]),T=p.useCallback(async(N,L)=>{var V,C;let _;try{_=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:N,model:L})})}catch(B){(V=b.current)==null||V.call(b,`Network error while setting ${N}: ${B.message}`);return}if(_.ok){s(B=>B&&{...B,activeAgent:N,activeModel:L});return}let D=`Failed to set ${N} (${_.status})`;try{const B=await _.json();B&&typeof B.error=="string"&&(D=B.error)}catch{}(C=b.current)==null||C.call(b,D)},[]);return{status:i,catalog:a,error:u,openRouterError:h,focusAgent:w,refresh:E,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:T}}function Rd({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 lf({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 n2={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}`},r2={appTitle:"Skill Studio",commandPaletteButtonLabel:"Open command palette",commandPaletteHint:"⌘K",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},a2={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"},l2={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"},s2={inputPlaceholder:"Type a command or search",emptyResults:"No matches. Try a different query.",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",actionSelectSkill:"Select skill",actionRunBenchmark:"Run benchmark",actionSwitchTheme:"Switch theme",actionNewSkill:"New skill",closeLabel:"Close palette"},i2={title:"Keyboard shortcuts",closeLabel:"Close shortcuts",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",search:"Focus search",moveDown:"Move selection down",moveUp:"Move selection up",openSelected:"Open selected skill",openPalette:"Open command palette",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},o2={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."},c2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},u2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},d2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},f2={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},p2={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)."}},m2={subscriptionBilling:"· subscription",free:"· free"},h2={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`},x2={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.`},g2={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}`},v2={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.`},y2={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"},b2={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."},j2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},S2={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"}},te={sidebar:n2,shell:r2,detail:a2,actions:l2,palette:s2,shortcuts:i2,toasts:o2,connection:c2,forms:u2,errors:d2,picker:f2,providers:p2,models:m2,settings:h2,statusBar:x2,scopePicker:g2,scopeSection:v2,claudeCodeLabel:y2,setupDrawer:b2,setupProviders:S2,scopeLabels:j2},k2=new Set(["claude-cli","claude-code"]);function sg(t){return k2.has(t)}const ig=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function w2({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}=te,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),v={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&&(v.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:v,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:te.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:te.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(lf,{unlocked:!0,size:10}):r.jsx(lf,{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:te.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(Rd,{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(Rd,{variant:"cli-install",label:x[t.id].label,installUrl:x[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(Rd,{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 C2(t,a,s,i){const d=t>=80,h=p.useRef(null),[x,m]=p.useState(0),v=p.useCallback(S=>{m(S.currentTarget.scrollTop)},[]),{visibleStart:y,visibleEnd:b}=p.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(x/a)-4),k=Math.ceil(s/a)+8,w=Math.min(t,S+k);return{visibleStart:S,visibleEnd:w}},[d,x,a,s,t,4]);return{visibleStart:y,visibleEnd:b,totalHeight:t*a,offsetTop:y*a,virtualised:d,containerProps:{onScroll:v,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Xv=44,E2=352,N2=60,cg=480;function T2(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 ${te.models.subscriptionBilling}`:te.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 R2(t,a){if(!a)return t;const s=a.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function A2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>x(u),N2);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:te.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:te.providers.openrouter.addKeyCta})]});const v=p.useMemo(()=>R2(t.models,h),[t.models,h]),y=C2(v.length,Xv,E2);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:te.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":te.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"}})}),v.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:te.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:te.picker.clearSearch})]}):v.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:te.picker.noModelsYet}):r.jsx("div",{...y.containerProps,children:r.jsx("div",{style:{height:y.virtualised?y.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:y.virtualised?`translateY(${y.offsetTop}px)`:void 0},children:v.slice(y.visibleStart,y.visibleEnd).map((b,S)=>{const k=y.visibleStart+S;return r.jsx(L2,{model:b,isActive:b.id===a,isFocused:s===k,onSelect:()=>i(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function M2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function L2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=T2(t),d=M2(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:Xv,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 z2(){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 v=await m.json();a({...ug,...v}),u(null)}catch(m){u(m.message),a(ug)}finally{i(!1)}},[]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async(m,v)=>{const y=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:m,key:v})});if(!y.ok){const S=await y.json().catch(()=>({error:y.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${y.status}`)}const b=await y.json();return await d(),b},[d]),x=p.useCallback(async m=>{const v=await fetch(`/api/settings/keys/${m}`,{method:"DELETE"});if(!v.ok)throw new Error(`DELETE /api/settings/keys/${m} returned ${v.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:x,refresh:d}}function D2({onMigrated:t,fetchImpl:a}){const[s,i]=p.useState({kind:"loading"}),c=a??globalThis.fetch,u=p.useCallback(async()=>{var m;try{const v=await c("/api/settings/migration-status");if(!v.ok){i({kind:"hidden"});return}const y=await v.json();y.pending&&(((m=y.darwinKeys)==null?void 0:m.length)??0)>0?i({kind:"visible",darwinKeys:y.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 v=await m.json().catch(()=>({migrated:[]}));t==null||t(v.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:Ad,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:{...Ad,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:{...Ad,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Ad={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},_2=[{id:"anthropic",name:te.providers.anthropic.name,keyIssuanceUrl:te.providers.anthropic.keyIssuanceUrl,prefix:te.providers.anthropic.keyPrefix,placeholder:`Paste ${te.providers.anthropic.name} key`},{id:"openai",name:te.providers.openai.name,keyIssuanceUrl:te.providers.openai.keyIssuanceUrl,prefix:te.providers.openai.keyPrefix,placeholder:te.providers.openai.pastePlaceholder},{id:"openrouter",name:te.providers.openrouter.name,keyIssuanceUrl:te.providers.openrouter.keyIssuanceUrl,prefix:te.providers.openrouter.keyPrefix,placeholder:`Paste ${te.providers.openrouter.name} key`}];function O2(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 Qv({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:h}=z2(),x=p.useRef(null),m=p.useRef(null),[v,y]=p.useState(null);p.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const w=await k.json();S||y(w.path??null)}catch{S||y(null)}})(),()=>{S=!0}},[t]),p.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var T;const w=s?`input[data-provider="${s}"]`:"input[data-provider]",E=(T=x.current)==null?void 0:T.querySelector(w);E==null||E.focus()},0);return()=>{var w;clearTimeout(k),(w=S==null?void 0:S.focus)==null||w.call(S)}},[t,s]),p.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),a();return}if(k.key==="Tab"&&x.current){const w=x.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(w.length===0)return;const E=w[0],T=w[w.length-1];k.shiftKey&&document.activeElement===E?(k.preventDefault(),T.focus()):!k.shiftKey&&document.activeElement===T&&(k.preventDefault(),E.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=p.useCallback(async()=>{var S,k;if(v)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,v)),i==null||i(te.settings.pathCopied)}catch{}},[i,v]);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:te.settings.title}),r.jsx(D2,{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:te.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:te.settings.sectionApiKeys}),_2.map(S=>r.jsx(B2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const w=await u(S.id,k);return i==null||i(te.settings.keySaved(S.name)),w},onRemove:async()=>{await d(S.id),i==null||i(te.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:v?te.settings.storagePath(v):te.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!v,"data-testid":"settings-copy-path",style:{...Ia,opacity:v?1:.5,cursor:v?"pointer":"not-allowed"},children:te.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 B2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:x}){const[m,v]=p.useState(""),[y,b]=p.useState(!1),[S,k]=p.useState(!1),[w,E]=p.useState(!1),[T,N]=p.useState(null),L=m.trim(),_=L.length===0,D=L.length>0&&!L.startsWith(i),V=p.useCallback(async()=>{if(_)return;k(!0);const M=L;v("");try{const $=await d(M);$.warning?N($.warning):N(null)}finally{k(!1)}},[_,d,L]),C=p.useCallback(async()=>{var M;try{if(!((M=navigator.clipboard)!=null&&M.readText))return;const $=await navigator.clipboard.readText();v($)}catch{}},[]),B=p.useCallback(async()=>{E(!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:y?"text":"password",value:m,onChange:M=>{v(M.target.value),N(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(!y),style:Ia,children:y?te.settings.hide:te.settings.show}),r.jsx("button",{type:"button",onClick:C,style:Ia,children:te.settings.paste})]}),D&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:dg,children:te.settings.prefixWarn(a)}),T&&r.jsx("div",{role:"status",style:dg,children:T}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:V,disabled:_||S,"data-testid":`save-${t}`,style:{...Ia,background:_?"var(--surface-2)":"var(--accent, var(--color-accent))",color:_?"var(--text-muted)":"white",cursor:_?"not-allowed":"pointer"},children:te.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:w?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:te.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:B,"data-testid":`remove-confirm-${t}`,style:{...Ia,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>E(!1),style:Ia,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>E(!0),"data-testid":`remove-${t}`,style:{...Ia,color:"var(--text-muted)"},children:te.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?te.settings.keyStoredAt(O2(u.updatedAt)):te.settings.noKey})]})]})}const Ia={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 I2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function $2({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=t2({onStaleCatalog:($,U)=>{const q=Math.round(U/6e4);t==null||t(`Using cached ${$} catalog (${q} min old)`)},onSetActiveError:$=>t==null?void 0:t($)}),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,v]=p.useState(),[y,b]=p.useState(null),[S,k]=p.useState("agents"),[w,E]=p.useState(0),T=p.useRef(null);p.useRef(null),p.useEffect(()=>{var $;s&&!y&&b(s.activeAgent??(($=s.agents[0])==null?void 0:$.id)??null)},[s,y]);const N=(s==null?void 0:s.agents)??[],L=p.useMemo(()=>N.find($=>$.id===y)??N[0],[N,y]);p.useEffect(()=>{E(0)},[y]);const _=p.useCallback(()=>{var $;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??(($=N[0])==null?void 0:$.id)??null),E(0)},[s,N]),D=p.useCallback(()=>{var $;d(!1),($=T.current)==null||$.focus()},[]);p.useEffect(()=>{const $=U=>{var X;if(!(U.metaKey||U.ctrlKey)||U.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(U.preventDefault(),d(ee=>!ee))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]),p.useEffect(()=>{if(!u)return;const $=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),U(1);return}if(q.key==="ArrowUp"){q.preventDefault(),U(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),E(X=>{const ee=((L==null?void 0:L.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,ee)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&L)k("models"),E(0);else if(S==="models"&&L){const X=Math.max(0,Math.min(L.models.length-1,w)),ee=L.models[X];ee&&(c(L.id,ee.id),D())}return}};function U(q){if(S==="agents"){const X=N.findIndex(H=>H.id===y),ee=N[Math.max(0,Math.min(N.length-1,X+q))];ee&&(b(ee.id),i(ee.id));return}if(S==="models"&&L){const X=L.models.length;if(X===0)return;E(ee=>{const H=ee+q;return Math.max(0,Math.min(X-1,H))})}}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[u,S,N,y,L,w,D,i,c]);const V=p.useCallback($=>{v($==="anthropic"||$==="openrouter"?$:void 0),x(!0),d(!1)},[]),C=N.find($=>$.id===(s==null?void 0:s.activeAgent)),B=C==null?void 0:C.models.find($=>$.id===(s==null?void 0:s.activeModel)),M=p.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const $=(C==null?void 0:C.displayName)??"Agent",U=(B==null?void 0:B.displayName)??s.activeModel??"Model";return`${$} · ${U}`},[a,s,C,B]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:T,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():_(),"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:C!=null&&C.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:M})]}),u&&typeof document<"u"&&Zo.createPortal(r.jsxs(U2,{reducedMotion:I2(),onClickOutside:D,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(w2,{agents:N,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:y,onFocus:$=>{b($),i($)},onSelect:$=>{b($),i($),k("models")},onOpenSettings:V}),L&&r.jsx(A2,{agent:L,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?w:-1,onSelect:$=>{c(L.id,$),D()},onOpenSettings:V})]}),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:()=>V(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:te.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:te.picker.footerHint})]})]}),document.body),r.jsx(Qv,{open:h,onClose:()=>x(!1),initialProvider:m,onToast:t})]})}function U2({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 H2({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 P2({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 V2({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(P2,{toast:c,onDismiss:a})},c.id))})]})}const Zv=p.createContext(null);function Jo(){const t=p.useContext(Zv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function F2({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),v=p.useCallback(E=>{const T=m.current.get(E);T&&(clearTimeout(T),m.current.delete(E)),c(N=>N.filter(L=>L.id!==E))},[]),y=p.useCallback((E,T)=>{if(T<=0)return;const N=setTimeout(()=>{v(E)},T);m.current.set(E,N)},[v]),b=p.useCallback(E=>{const T=E.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,N={id:T,message:E.message,severity:E.severity??"info",durationMs:E.durationMs??s,action:E.action};return c(L=>[...L,N]),N.severity==="error"?x(N.message):d(N.message),y(T,N.durationMs),T},[s,y]),S=p.useCallback(()=>{for(const E of m.current.values())clearTimeout(E);m.current.clear(),c([])},[]);p.useEffect(()=>{function E(T){T.key==="Escape"&&c(N=>{if(N.length===0)return N;const L=N.slice(0,a),_=L[L.length-1],D=m.current.get(_.id);return D&&(clearTimeout(D),m.current.delete(_.id)),N.filter(V=>V.id!==_.id)})}return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[a]),p.useEffect(()=>()=>{for(const E of m.current.values())clearTimeout(E);m.current.clear()},[]);const k=i.slice(0,a),w=p.useMemo(()=>({toast:b,dismiss:v,clear:S}),[b,v,S]);return r.jsxs(Zv.Provider,{value:w,children:[t,r.jsx(V2,{toasts:k,onDismiss:v,liveMessage:u,liveAssertiveMessage:h})]})}const G2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",W2=p.lazy(()=>Ha(()=>import("./UpdateDropdown-D0dHy9y-.js"),__vite__mapDeps([0,1])));function q2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:h,activeAgent:x}=lr(),{toast:m}=Jo(),v=p.useMemo(()=>{if(!h||h.size===0)return;const N=new Map;for(const[L,_]of h)_.diffSummary&&N.set(L,_.diffSummary);return N.size>0?N:void 0},[h]),[y,b]=p.useState(!1),S=p.useRef(null),k=p.useCallback(()=>b(!1),[]),w=t>0?"var(--text-primary)":"var(--text-secondary)",E=t>9?"9+":String(t),T=t===0?"No updates available":`${t} updates available, open summary`;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:S,type:"button","data-testid":"update-bell","aria-label":T,"aria-haspopup":"dialog","aria-expanded":y,onClick:()=>b(N=>!N),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:w,cursor:"pointer"},children:[r.jsx("img",{src:G2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:E})]}),y&&r.jsx(p.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(W2,{updates:a,isRefreshing:s,diffSummariesById:v,onRefresh:()=>i(),onSelectSkill:N=>{const L=N.localSkill??N.name.split("/").pop()??"",_=N.localPlugin??"";if(u)u(_,L);else{const V=N.name.split("/"),C=V.length>=2?V[V.length-2]:V[0];c({plugin:C,skill:L,origin:"installed"})}if(!(d??[]).some(V=>V.skill===L&&(_===""||V.plugin===_))){const V=N.installLocations??[];if(V.length>0){const C=x?V.filter(M=>M.agent===x):[],B=x?V.filter(M=>M.agent!==x):V;if(C.length>0&&B.length>0){const M=B.length>=2?`Also installed under ${B.length} other locations.`:`Also installed under ${B[0].agentLabel}.`;m({severity:"info",message:M})}else{const M=V[0].agentLabel;m({severity:"info",message:`Skill installed under ${M} — switch to ${M} to view details.`})}}}k()},onViewAll:()=>{window.location.hash="#/updates",k()},onClose:k,anchorRef:S})})]})}function mg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function Y2({projectName:t,selected:a,onOpenPalette:s,onHome:i,projectPickerSlot:c,onRequestCreateSkill:u,findSkillsSlot:d}){const h=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(H2,{onHome:i}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&h&&r.jsxs(r.Fragment,{children:[r.jsx(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:h}),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:[d,u&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx($2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(q2,{})}),r.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:r.jsx("span",{children:"⌘K"})})]})]})}function 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 ec="vskill-theme";function Jv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function K2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function X2(t){try{const a=t.getItem(ec);return Jv(a)}catch{return"auto"}}function Q2(t,a){try{t.setItem(ec,a)}catch{}}function Z2(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function J2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const ey=p.createContext(null);function ek({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?X2(c):"auto"),[m,v]=p.useState(()=>J2(u)),y=p.useMemo(()=>K2(h,m),[h,m]);p.useEffect(()=>{d&&Z2(d,h,y)},[d,h,y]),p.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),w=T=>v(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",w),()=>k.removeEventListener("change",w);const E=k;return E.addListener(w),()=>E.removeListener(w)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const k=w=>{w.key===ec&&x(Jv(w.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),p.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const w=N=>{N?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};w(k.matches);const E=N=>w(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const T=k;return T.addListener(E),()=>T.removeListener(E)},[u,d]);const b=p.useCallback(k=>{x(k),c&&Q2(c,k)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:y,setTheme:b}),[h,y,b]);return r.jsx(ey.Provider,{value:S,children:i})}function ty(){const t=p.useContext(ey);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 tk(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 nk(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 rk({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=tk(t),c=nk(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":te.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:te.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?te.statusBar.unlocked(t.label):t.kind==="cli-install"?te.statusBar.lockedCli(t.label):te.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(lf,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function ak(){try{return typeof localStorage>"u"?null:localStorage.getItem(ec)}catch{return null}}function lk({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:x,setTheme:m}=ty(),y=ak()==="auto",b=sk(h,x,y),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(ik,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(yg,{}),r.jsx(rk,{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(ok,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function sk(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function ik({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 ok({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 sf=new Set;function ny(){for(const t of sf)t()}const ck=5,uk=1e3,dk=6e4;function fk(){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),v=p.useRef(0),[y,b]=p.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},k=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),w=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;k();const T=new AbortController;h.current=T;try{const N=await fetch("/api/plugins",{signal:T.signal});if(!m.current)return;const L=await N.json();if(!m.current)return;d.current=0,a(L.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{m.current&&b(_=>_+1)},dk)}catch(N){if(!m.current||N instanceof DOMException&&N.name==="AbortError")return;if(d.current+=1,u(!1),d.current>ck){i(!0);return}const L=uk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{m.current&&b(_=>_+1)},L)}},[k]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),k()}),[k]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),w())},[y,w]),p.useEffect(()=>{const T=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,i(!1),b(N=>N+1))};return document.addEventListener("visibilitychange",T),()=>{document.removeEventListener("visibilitychange",T)}},[k]);const E=p.useCallback(()=>{d.current=0,i(!1),S(),v.current+=1,b(T=>T+1)},[]);return p.useEffect(()=>(sf.add(E),()=>{sf.delete(E)}),[E]),{plugins:t,paused:s,loading:c,retry:E}}const tc=0,ma=1,Ul=2,ry=4;function bg(t){return()=>t}function pk(t){t()}function ay(t,a){return s=>t(a(s))}function jg(t,a){return()=>t(a)}function mk(t,a){return s=>t(a,s)}function Mf(t){return t!==void 0}function hk(...t){return()=>{t.map(pk)}}function Hl(){}function nc(t,a){return a(t),t}function xk(t,a){return a(t)}function St(...t){return t}function it(t,a){return t(ma,a)}function Fe(t,a){t(tc,a)}function Lf(t){t(Ul)}function Ct(t){return t(ry)}function Te(t,a){return it(t,mk(a,tc))}function nr(t,a){const s=t(ma,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 ly(t,a){return t===a}function jt(t=ly){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function Oe(t){return a=>s=>{t(s)&&a(s)}}function ke(t){return a=>ay(a,t)}function dr(t){return a=>()=>{a(t)}}function me(t,...a){const s=gk(...a);return((i,c)=>{switch(i){case Ul:Lf(t);return;case ma:return it(t,s(c))}})}function fr(t,a){return s=>i=>{s(a=t(a,i))}}function Ua(t){return a=>s=>{t>0?t--:a(s)}}function zr(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function Ge(...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;it(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 gk(...t){return a=>t.reduceRight(xk,a)}function vk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ma:return u?s===u?void 0:(i(),s=u,a=it(t,u),a):(i(),Hl);case Ul:i(),s=null;return}}}function ve(t){let a=t;const s=et();return((i,c)=>{switch(i){case tc:a=c;break;case ma:{c(a);break}case ry:return a}return s(i,c)})}function on(t,a){return nc(ve(a),s=>Te(t,s))}function et(){const t=[];return((a,s)=>{switch(a){case tc:t.slice().forEach(i=>{i(s)});return;case Ul:t.splice(0,t.length);return;case ma:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function zn(t){return nc(et(),a=>Te(t,a))}function lt(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:yk(),singleton:s}}const yk=()=>Symbol();function bk(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 Pt(...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;it(u,x=>{s[d]=x,i|=h,i===c&&Fe(a,s)})}),function(u,d){switch(u){case Ul:{Lf(a);return}case ma:return i===c&&d(s),it(a,d)}}}function _e(t,a=ly){return me(t,jt(a))}function of(...t){return function(a,s){switch(a){case Ul:return;case ma:return hk(...t.map(i=>it(i,s)))}}}const qt={DEBUG:0,INFO:1,WARN:2,ERROR:3},jk={[qt.DEBUG]:"debug",[qt.ERROR]:"error",[qt.INFO]:"log",[qt.WARN]:"warn"},Sk=()=>typeof globalThis>"u"?window:globalThis,ha=lt(()=>{const t=ve(qt.ERROR);return{log:ve((a,s,i=qt.INFO)=>{const c=Sk().VIRTUOSO_LOG_LEVEL??Ct(t);i>=c&&console[jk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Va(t,a,s){return zf(t,a,s).callbackRef}function zf(t,a,s){const i=Ne.useRef(null);let c=d=>{};const u=Ne.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 kk(t,a,s,i,c,u,d,h,x){const m=Ne.useCallback(v=>{const y=wk(v.children,a,h?"offsetWidth":"offsetHeight",c);let b=v.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const w=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,E=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,T=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;i({scrollHeight:E,scrollTop:Math.max(w,0),viewportHeight:T}),u==null||u(h?kg("column-gap",getComputedStyle(v).columnGap,c):kg("row-gap",getComputedStyle(v).rowGap,c)),y!==null&&t(y)},[t,a,c,u,d,i,h]);return zf(m,s,x)}function wk(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),v=a(h,s);if(v===0&&i("Zero-sized element, this should not happen",{child:h},qt.ERROR),v===m)continue;const y=u[u.length-1];u.length===0||y.size!==v||y.endIndex!==x-1?u.push({endIndex:x,size:v,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 sy(t,a,s){const i=Ne.useRef(null),c=Ne.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const m=x.getBoundingClientRect(),v=m.width;let y,b;if(a){const S=a.getBoundingClientRect(),k=m.top-S.top;b=S.height-Math.max(0,k),y=k+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),y=m.top+S.scrollY}i.current={listHeight:m.height,offsetTop:y,visibleHeight:b,visibleWidth:v},t(i.current)},[t,a]),{callbackRef:u,ref:d}=zf(c,!0,s),h=Ne.useCallback(()=>{c(d.current)},[c,d]);return Ne.useEffect(()=>{var m;if(a){a.addEventListener("scroll",h);const v=new ResizeObserver(()=>{requestAnimationFrame(h)});return v.observe(a),()=>{a.removeEventListener("scroll",h),v.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 hn=lt(()=>{const t=et(),a=et(),s=ve(0),i=et(),c=ve(0),u=et(),d=et(),h=ve(0),x=ve(0),m=ve(0),v=ve(0),y=et(),b=et(),S=ve(!1),k=ve(!1),w=ve(!1);return Te(me(t,ke(({scrollTop:E})=>E)),a),Te(me(t,ke(({scrollHeight:E})=>E)),d),Te(a,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:x,footerHeight:v,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:y,scrollTop:a,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),qs={lvl:0};function iy(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 xt(t){return t===qs}function Ys(t,a){if(!xt(t))return a===t.k?t.v:a<t.k?Ys(t.l,a):Ys(t.r,a)}function ar(t,a,s="k"){if(xt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=ar(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return ar(t.l,a,s)}function Mn(t,a,s){return xt(t)?uy(a,s,1):a===t.k?Wt(t,{k:a,v:s}):a<t.k?wg(Wt(t,{l:Mn(t.l,a,s)})):wg(Wt(t,{r:Mn(t.r,a,s)}))}function Ll(){return qs}function zl(t,a,s){if(xt(t))return[];const i=ar(t,a)[0];return Ck(uf(t,i,s))}function cf(t,a){if(xt(t))return qs;const{k:s,l:i,r:c}=t;if(a===s){if(xt(i))return c;if(xt(c))return i;const[u,d]=cy(i);return $o(Wt(t,{k:u,l:oy(i),v:d}))}return a<s?$o(Wt(t,{l:cf(i,a)})):$o(Wt(t,{r:cf(c,a)}))}function $a(t){return xt(t)?[]:[...$a(t.l),{k:t.k,v:t.v},...$a(t.r)]}function uf(t,a,s){if(xt(t))return[];const{k:i,l:c,r:u,v:d}=t;let h=[];return i>a&&(h=h.concat(uf(c,a,s))),i>=a&&i<=s&&h.push({k:i,v:d}),i<=s&&(h=h.concat(uf(u,a,s))),h}function $o(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(Md(a))return dy(Wt(t,{lvl:s-1}));if(!xt(a)&&!xt(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(Md(t))return df(Wt(t,{lvl:s-1}));if(!xt(i)&&!xt(i.l)){const c=i.l,u=Md(c)?i.lvl-1:i.lvl;return Wt(c,{l:Wt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:df(Wt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Wt(t,a){return uy(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 oy(t){return xt(t.r)?t.l:$o(Wt(t,{r:oy(t.r)}))}function Md(t){return xt(t)||t.lvl>t.r.lvl}function cy(t){return xt(t.r)?[t.k,t.v]:cy(t.r)}function uy(t,a,s,i=qs,c=qs){return{k:t,l:i,lvl:s,r:c,v:a}}function wg(t){return df(dy(t))}function dy(t){const{l:a}=t;return!xt(a)&&a.lvl===t.lvl?Wt(a,{r:Wt(t,{l:a.r})}):t}function df(t){const{lvl:a,r:s}=t;return!xt(s)&&!xt(s.r)&&s.lvl===a&&s.r.lvl===a?Wt(s,{l:Wt(t,{r:s.l}),lvl:a+1}):t}function Ck(t){return iy(t,({k:a,v:s})=>({index:a,value:s}))}function fy(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Ks(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Df=lt(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function py(t,a,s){return t[Vo(t,a,s)]}function Vo(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 Ek(t,a,s,i){const c=Vo(t,a,i),u=Vo(t,s,i,c);return t.slice(c,u+1)}function fa(t,a){return Math.round(t.getBoundingClientRect()[a])}function rc(t){return!xt(t.groupOffsetTree)}function _f({index:t},a){return a===t?0:a<t?-1:1}function Nk(){return{groupIndices:[],groupOffsetTree:Ll(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ll()}}function Tk(t,a){let s=xt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),xt(t)){t=Mn(t,0,u);continue}const h=zl(t,d-1,c+1);if(h.some(_k(i)))continue;let x=!1,m=!1;for(const{end:v,start:y,value:b}of h)x?(c>=y||u===b)&&(t=cf(t,y)):(m=b!==u,x=!0),v>c&&c>=y&&b!==u&&(t=Mn(t,c+1,b));m&&(t=Mn(t,d,u))}return[t,s]}function Rk(t){return typeof t.groupIndex<"u"}function Ak({offset:t},a){return a===t?0:a<t?-1:1}function Xs(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=py(a,t,_f),d=t-i,h=u*d+(d-1)*s+c;return h>0?h+s:h}function my(t,a){if(!rc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function hy(t,a,s){if(Rk(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=my(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function Mk(t,a,s,i=0){return i>0&&(a=Math.max(a,py(t,i,_f).offset)),iy(Ek(t,a,s,Ak),Dk)}function Lk(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&&xt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((k,w)=>Mn(Mn(k,w,b),w+1,S),d)}else[d,h]=Tk(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:m,lastSize:v,offsetTree:y}=ff(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>Mn(b,S,Xs(S,y,c)),Ll()),lastIndex:x,lastOffset:m,lastSize:v,offsetTree:y,sizeTree:d}}function zk(t){return $a(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 ff(t,a,s,i){let c=t,u=0,d=0,h=0,x=0;if(a!==0){x=Vo(c,a-1,_f),h=c[x].offset;const m=ar(s,a-1);u=m[0],d=m[1],c.length&&c[x].size===ar(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:m,value:v}of zl(s,a,1/0)){const y=m-u,b=y*d+h+y*i;c.push({index:m,offset:b,size:v}),u=m,h=b,d=v}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function Dk(t){return{index:t.index,value:t}}function _k(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 Ok={offsetHeight:"height",offsetWidth:"width"},mr=lt(([{log:t},{recalcInProgress:a}])=>{const s=et(),i=et(),c=on(i,0),u=et(),d=et(),h=ve(0),x=ve([]),m=ve(void 0),v=ve(void 0),y=ve(void 0),b=ve(void 0),S=ve((C,B)=>fa(C,Ok[B])),k=ve(void 0),w=ve(0),E=Nk(),T=on(me(s,Ge(x,t,w),fr(Lk,E),jt()),E),N=on(me(x,jt(),fr((C,B)=>({current:B,prev:C.current}),{current:[],prev:[]}),ke(({prev:C})=>C)),[]);Te(me(x,Oe(C=>C.length>0),Ge(T,w),ke(([C,B,M])=>{const $=C.reduce((U,q,X)=>Mn(U,q,Xs(q,B.offsetTree,M)||X),Ll());return{...B,groupIndices:C,groupOffsetTree:$}})),T),Te(me(i,Ge(T),Oe(([C,{lastIndex:B}])=>C<B),ke(([C,{lastIndex:B,lastSize:M}])=>[{endIndex:B,size:M,startIndex:C}])),s),Te(m,v);const L=on(me(m,ke(C=>C===void 0)),!0);Te(me(v,Oe(C=>C!==void 0&&xt(Ct(T).sizeTree)),ke(C=>{const B=Ct(y),M=Ct(x).length>0;return B!==void 0&&B!==0?M?[{endIndex:0,size:B,startIndex:0},{endIndex:1,size:C,startIndex:1}]:[]:[{endIndex:0,size:C,startIndex:0}]})),s),Te(me(b,Oe(C=>C!==void 0&&C.length>0&&xt(Ct(T).sizeTree)),ke(C=>{const B=[];let M=C[0],$=0;for(let U=1;U<C.length;U++){const q=C[U];q!==M&&(B.push({endIndex:U-1,size:M,startIndex:$}),M=q,$=U)}return B.push({endIndex:C.length-1,size:M,startIndex:$}),B})),s),Te(me(x,Ge(y,v),Oe(([,C,B])=>C!==void 0&&B!==void 0),ke(([C,B,M])=>{const $=[];for(let U=0;U<C.length;U++){const q=C[U],X=C[U+1];$.push({startIndex:q,endIndex:q,size:B}),X!==void 0&&$.push({startIndex:q+1,endIndex:X-1,size:M})}return $})),s);const _=zn(me(s,Ge(T),fr(({sizes:C},[B,M])=>({changed:M!==C,sizes:M}),{changed:!1,sizes:E}),ke(C=>C.changed)));it(me(h,fr((C,B)=>({diff:C.prev-B,prev:B}),{diff:0,prev:0}),ke(C=>C.diff)),C=>{const{groupIndices:B}=Ct(T);if(C>0)Fe(a,!0),Fe(u,C+Cg(C,B));else if(C<0){const M=Ct(N);M.length>0&&(C-=Cg(-C,M)),Fe(d,C)}}),it(me(h,Ge(t)),([C,B])=>{C<0&&B("`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 D=zn(u);Te(me(u,Ge(T),ke(([C,B])=>{const M=B.groupIndices.length>0,$=[],U=B.lastSize;if(M){const q=Ys(B.sizeTree,0);let X=0,ee=0;for(;X<C;){const A=B.groupIndices[ee],I=B.groupIndices.length===ee+1?1/0:B.groupIndices[ee+1]-A-1;$.push({endIndex:A,size:q,startIndex:A}),$.push({endIndex:A+1+I-1,size:U,startIndex:A+1}),ee++,X+=I+1}const H=$a(B.sizeTree);return X!==C&&H.shift(),H.reduce((A,{k:I,v:G})=>{let O=A.ranges;return A.prevSize!==0&&(O=[...A.ranges,{endIndex:I+C-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:I+C,prevSize:G,ranges:O}},{prevIndex:C,prevSize:0,ranges:$}).ranges}return $a(B.sizeTree).reduce((q,{k:X,v:ee})=>({prevIndex:X+C,prevSize:ee,ranges:[...q.ranges,{endIndex:X+C-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:U,ranges:[]}).ranges})),s);const V=zn(me(d,Ge(T,w),ke(([C,{offsetTree:B},M])=>{const $=-C;return Xs($,B,M)})));return Te(me(d,Ge(T,w),ke(([C,B,M])=>{if(B.groupIndices.length>0){if(xt(B.sizeTree))return B;let U=Ll();const q=Ct(N);let X=0,ee=0,H=0;for(;X<-C;){H=q[ee];const A=q[ee+1]-H-1;ee++,X+=A+1}if(U=$a(B.sizeTree).reduce((A,{k:I,v:G})=>Mn(A,Math.max(0,I+C),G),U),X!==-C){const A=Ys(B.sizeTree,H);U=Mn(U,0,A);const I=ar(B.sizeTree,-C+1)[1];U=Mn(U,1,I)}return{...B,sizeTree:U,...ff(B.offsetTree,0,U,M)}}const $=$a(B.sizeTree).reduce((U,{k:q,v:X})=>Mn(U,Math.max(0,q+C),X),Ll());return{...B,sizeTree:$,...ff(B.offsetTree,0,$,M)}})),T),{beforeUnshiftWith:D,data:k,defaultItemSize:v,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:y,gap:w,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:_,shiftWith:d,shiftWithOffset:V,sizeRanges:s,sizes:T,statefulTotalCount:c,totalCount:i,trackItemSizes:L,unshiftWith:u}},St(ha,Df),{singleton:!0});function Bk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const xy=lt(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=et(),d=et(),h=zn(me(u,ke(Bk)));return Te(me(h,ke(x=>x.totalCount)),s),Te(me(h,ke(x=>x.groupIndices)),t),Te(me(Pt(c,a,i),Oe(([x,m])=>rc(m)),ke(([x,m,v])=>ar(m.groupOffsetTree,Math.max(x-v,0),"v")[0]),jt(),ke(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},St(mr,hn)),xa=lt(([{log:t}])=>{const a=ve(!1),s=zn(me(a,Oe(i=>i),jt()));return it(a,i=>{i&&Ct(t)("props updated",{},qt.DEBUG)}),{didMount:s,propsReady:a}},St(ha),{singleton:!0}),Ik=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function gy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!Ik)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ni=lt(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:x,scrollTo:m,smoothScrollTargetReached:v,viewportHeight:y},{log:b}])=>{const S=et(),k=et(),w=ve(0);let E=null,T=null,N=null;function L(){E!==null&&(E(),E=null),N!==null&&(N(),N=null),T&&(clearTimeout(T),T=null),Fe(x,!1)}return Te(me(S,Ge(s,y,i,w,h,d,b),Ge(t,u,c),ke(([[_,D,V,C,B,M,$,U],q,X,ee])=>{const H=gy(_),{align:A,behavior:I,offset:G}=H,O=C-1,ne=hy(H,D,O);let z=Xs(ne,D.offsetTree,q)+M;A==="end"?(z+=X+ar(D.sizeTree,ne)[1]-V+ee,ne===O&&(z+=$)):A==="center"?z+=(X+ar(D.sizeTree,ne)[1]-V+ee)/2:z-=B,G!==void 0&&G!==0&&(z+=G);const W=re=>{L(),re?(U("retrying to scroll to",{location:_},qt.DEBUG),Fe(S,_)):(Fe(k,!0),U("list did not change, scroll successful",{},qt.DEBUG))};if(L(),I==="smooth"){let re=!1;N=it(a,Y=>{re=re||Y}),E=nr(v,()=>{W(re)})}else E=nr(me(a,$k(150)),W);return T=setTimeout(()=>{L()},1200),Fe(x,!0),U("scrolling from index to",{behavior:I,index:ne,top:z},qt.DEBUG),{behavior:I,top:z}})),m),{scrollTargetReached:k,scrollToIndex:S,topListHeight:w}},St(mr,hn,ha),{singleton:!0});function $k(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Of(t,a){t===0?a():requestAnimationFrame(()=>{Of(t-1,a)})}function Bf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const ri=lt(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ve(!0),x=ve(0),m=ve(!0);return Te(me(d,Ge(x),Oe(([v,y])=>y!==0),dr(!1)),h),Te(me(d,Ge(x),Oe(([v,y])=>y!==0),dr(!1)),m),it(me(Pt(a,d),Ge(h,s,t,m),Oe(([[,v],y,{sizeTree:b},S,k])=>v&&(!xt(b)||Mf(S))&&!y&&!k),Ge(x)),([,v])=>{nr(c,()=>{Fe(m,!0)}),Of(4,()=>{nr(i,()=>{Fe(h,!0)}),Fe(u,v)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:x,scrolledToInitialItem:h}},St(mr,hn,ni,xa),{singleton:!0});function vy(t,a){return Math.abs(t-a)<1.01}const Qs="up",Vs="down",Uk="none",Hk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Pk=0,ai=lt(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ve(!1),h=ve(!0),x=et(),m=et(),v=ve(4),y=ve(Pk),b=on(me(of(me(_e(c),Ua(1),dr(!0)),me(_e(c),Ua(1),dr(!1),Sg(100))),jt()),!1),S=on(me(of(me(s,dr(!0)),me(s,dr(!1),Sg(200))),jt()),!1);Te(me(Pt(_e(c),_e(y)),ke(([N,L])=>N<=L),jt()),h),Te(me(h,zr(50)),m);const k=zn(me(Pt(i,_e(u),_e(a),_e(t),_e(v)),fr((N,[{scrollHeight:L,scrollTop:_},D,V,C,B])=>{const M=_+D-L>-B,$={scrollHeight:L,scrollTop:_,viewportHeight:D};if(M){let q,X;return _>N.state.scrollTop?(q="SCROLLED_DOWN",X=N.state.scrollTop-_):(q="SIZE_DECREASED",X=N.state.scrollTop-_||N.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:$}}let U;return $.scrollHeight>N.state.scrollHeight?U="SIZE_INCREASED":D<N.state.viewportHeight?U="VIEWPORT_HEIGHT_DECREASING":_<N.state.scrollTop?U="SCROLLING_UPWARDS":U="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:U,state:$}},Hk),jt((N,L)=>N!==void 0&&N.atBottom===L.atBottom))),w=on(me(i,fr((N,{scrollHeight:L,scrollTop:_,viewportHeight:D})=>{if(!vy(N.scrollHeight,L)){const V=L-(_+D)<1;return N.scrollTop!==_&&V?{changed:!0,jump:N.scrollTop-_,scrollHeight:L,scrollTop:_}:{changed:!0,jump:0,scrollHeight:L,scrollTop:_}}return{changed:!1,jump:0,scrollHeight:L,scrollTop:_}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Oe(N=>N.changed),ke(N=>N.jump)),0);Te(me(k,ke(N=>N.atBottom)),d),Te(me(d,zr(50)),x);const E=ve(Vs);Te(me(i,ke(({scrollTop:N})=>N),jt(),fr((N,L)=>Ct(S)?{direction:N.direction,prevScrollTop:L}:{direction:L<N.prevScrollTop?Qs:Vs,prevScrollTop:L},{direction:Vs,prevScrollTop:0}),ke(N=>N.direction)),E),Te(me(i,zr(50),dr(Uk)),E);const T=ve(0);return Te(me(b,Oe(N=>!N),dr(0)),T),Te(me(c,zr(100),Ge(b),Oe(([N,L])=>L),fr(([N,L],[_])=>[L,_],[0,0]),ke(([N,L])=>L-N)),T),{atBottomState:k,atBottomStateChange:x,atBottomThreshold:v,atTopStateChange:m,atTopThreshold:y,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:w,scrollDirection:E,scrollVelocity:T}},St(hn)),Zs="top",Js="bottom",Eg="none";function Ng(t,a,s){return typeof t=="number"?s===Qs&&a===Zs||s===Vs&&a===Js?t:0:s===Qs?a===Zs?t.main:t.reverse:a===Js?t.main:t.reverse}function Tg(t,a){return typeof t=="number"?t:t[a]??0}const If=lt(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=et(),d=ve(0),h=ve(0),x=ve(0),m=on(me(Pt(_e(i),_e(c),_e(s),_e(u,Ks),_e(x),_e(d),_e(a),_e(t),_e(h)),ke(([v,y,b,[S,k],w,E,T,N,L])=>{const _=v-N,D=E+T,V=Math.max(b-_,0);let C=Eg;const B=Tg(L,Zs),M=Tg(L,Js);return S-=N,S+=b+T,k+=b+T,k-=N,S>v+D-B&&(C=Qs),k<v-V+y+M&&(C=Vs),C!==Eg?[Math.max(_-b-Ng(w,Zs,C)-B,0),_-V-T+y+Ng(w,Js,C)+M]:null}),Oe(v=>v!==null),jt(Ks)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:x,topListHeight:d,visibleRange:m}},St(hn),{singleton:!0});function Vk(t,a,s){if(rc(a)){const i=my(t,a);return[{index:ar(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 Ld={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Uo(t,a,s,i,c,u){const{lastIndex:d,lastOffset:h,lastSize:x}=c;let m=0,v=0;if(t.length>0){m=t[0].offset;const w=t[t.length-1];v=w.offset+w.size}const y=s-d,b=h+y*x+(y-1)*i,S=m,k=b-v;return{bottom:v,firstItemIndex:u,items:Rg(t,c,u),offsetBottom:k,offsetTop:m,top:S,topItems:Rg(a,c,u),topListHeight:a.reduce((w,E)=>E.size+w,0),totalCount:s}}function yy(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const v of s.groupIndices){if(v-d>=t)break;d++}const h=t+d,x=Bf(a,h),m=Array.from({length:h}).map((v,y)=>({data:u[y+x],index:y+x,offset:0,size:0}));return Uo(m,[],h,c,s,i)}function Rg(t,a,s){if(t.length===0)return[];if(!rc(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=zl(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 v;m.index===h.start?v={index:x,type:"group"}:v={groupIndex:x,index:m.index-(x+1)+s},u.push({...v,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 Fa=lt(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:x},{initialTopMostItemIndex:m,scrolledToInitialItem:v},{topListHeight:y},b,{didMount:S},{recalcInProgress:k}])=>{const w=ve([]),E=ve(0),T=et(),N=ve(0);Te(u.topItemsIndexes,w);const L=on(me(Pt(S,k,_e(x,Ks),_e(c),_e(i),_e(m),v,_e(w),_e(a),_e(s),_e(N),t),Oe(([C,B,,M,,,,,,,,$])=>{const U=$!==void 0&&$.length!==M;return C&&!B&&!U}),ke(([,,[C,B],M,$,U,q,X,ee,H,A,I])=>{var ye,Re;const G=$,{offsetTree:O,sizeTree:ne}=G,z=Ct(E);if(M===0)return{...Ld,totalCount:M};if(C===0&&B===0)return z===0?{...Ld,totalCount:M}:yy(z,U,$,ee,H,I||[]);if(xt(ne))return z>0?null:Uo(Vk(Bf(U,M),G,I),[],M,H,G,ee);const W=[];if(X.length>0){const Ae=X[0],le=X[X.length-1];let he=0;for(const pe of zl(ne,Ae,le)){const xe=pe.value,je=Math.max(pe.start,Ae),Be=Math.min(pe.end,le);for(let Ie=je;Ie<=Be;Ie++)W.push({data:I==null?void 0:I[Ie],index:Ie,offset:he,size:xe}),he+=xe}}if(!q)return Uo([],W,M,H,G,ee);const re=X.length>0?X[X.length-1]+1:0,Y=Mk(O,C,B,re);if(Y.length===0)return null;const ce=M-1,se=nc([],Ae=>{for(const le of Y){const he=le.value;let pe=he.offset,xe=le.start;const je=he.size;if(he.offset<C){xe+=Math.floor((C-he.offset+H)/(je+H));const Ie=xe-le.start;pe+=Ie*je+Ie*H}xe<re&&(pe+=(re-xe)*je,xe=re);const Be=Math.min(le.end,ce);for(let Ie=xe;Ie<=Be&&!(pe>=B);Ie++)Ae.push({data:I==null?void 0:I[Ie],index:Ie,offset:pe,size:je}),pe+=je+H}}),be=Ag(A,Zs),ie=Ag(A,Js);if(se.length>0&&(be>0||ie>0)){const Ae=se[0],le=se[se.length-1];if(be>0&&Ae.index>re){const he=Math.min(be,Ae.index-re),pe=[];let xe=Ae.offset;for(let je=Ae.index-1;je>=Ae.index-he;je--){const Be=((ye=zl(ne,je,je)[0])==null?void 0:ye.value)??Ae.size;xe-=Be+H,pe.unshift({data:I==null?void 0:I[je],index:je,offset:xe,size:Be})}se.unshift(...pe)}if(ie>0&&le.index<ce){const he=Math.min(ie,ce-le.index);let pe=le.offset+le.size+H;for(let xe=le.index+1;xe<=le.index+he;xe++){const je=((Re=zl(ne,xe,xe)[0])==null?void 0:Re.value)??le.size;se.push({data:I==null?void 0:I[xe],index:xe,offset:pe,size:je}),pe+=je+H}}}return Uo(se,W,M,H,G,ee)}),Oe(C=>C!==null),jt()),Ld);Te(me(t,Oe(Mf),ke(C=>C==null?void 0:C.length)),c),Te(me(L,ke(C=>C.topListHeight)),y),Te(y,h),Te(me(L,ke(C=>[C.top,C.bottom])),d),Te(me(L,ke(C=>C.items)),T);const _=zn(me(L,Oe(({items:C})=>C.length>0),Ge(c,t),Oe(([{items:C},B])=>C[C.length-1].originalIndex===B-1),ke(([,C,B])=>[C-1,B]),jt(Ks),ke(([C])=>C))),D=zn(me(L,zr(200),Oe(({items:C,topItems:B})=>C.length>0&&C[0].originalIndex===B.length),ke(({items:C})=>C[0].index),jt())),V=zn(me(L,Oe(({items:C})=>C.length>0),ke(({items:C})=>{let B=0,M=C.length-1;for(;C[B].type==="group"&&B<M;)B++;for(;C[M].type==="group"&&M>B;)M--;return{endIndex:C[M].index,startIndex:C[B].index}}),jt(fy)));return{endReached:_,initialItemCount:E,itemsRendered:T,listState:L,minOverscanItemCount:N,rangeChanged:V,startReached:D,topItemsIndexes:w,...b}},St(mr,xy,If,ri,ni,ai,xa,Df),{singleton:!0}),by=lt(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=et(),d=on(me(Pt(s,t,i,a,c),ke(([h,x,m,v,y])=>h+x+m+v+y.offsetBottom+y.bottom)),0);return Te(_e(d),u),{totalListHeight:d,totalListHeightChanged:u}},St(hn,Fa),{singleton:!0}),Fk=lt(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ve(!1),i=on(me(Pt(s,t,a),Oe(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),zr(0),jt()),0);return{alignToBottom:s,paddingTopAddition:i}},St(hn,by),{singleton:!0}),jy=lt(()=>({context:ve(null)})),Gk=({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,Sy=lt(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:x},{scrollToIndex:m}])=>{const v=et();return Te(me(v,Ge(a,x,s,u,c,i,h),Ge(t),ke(([[y,b,S,k,w,E,T,N],L])=>{const{calculateViewLocation:_=Gk,done:D,...V}=y,C=hy(y,b,k-1),B=Xs(C,b.offsetTree,L)+w+E,M=B+ar(b.sizeTree,C)[1],$=N+E,U=N+S-T,q=_({itemBottom:M,itemTop:B,locationParams:V,viewportBottom:U,viewportTop:$});return q!==null?D&&nr(me(d,Oe(X=>!X),Ua(Ct(d)?1:2)),D):D==null||D(),q}),Oe(y=>y!==null)),m),{scrollIntoView:v}},St(mr,hn,ni,Fa,ha),{singleton:!0});function Mg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const Wk=(t,a)=>typeof t=="function"?Mg(t(a)):a&&Mg(t),qk=lt(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:x,propsReady:m},{log:v},{scrollingInProgress:y},{context:b},{scrollIntoView:S}])=>{const k=ve(!1),w=et();let E=null;function T(D){Fe(d,{align:"end",behavior:D,index:"LAST"})}it(me(Pt(me(_e(a),Ua(1)),x),Ge(_e(k),u,h,y),ke(([[D,V],C,B,M,$])=>{let U=V&&M,q="auto";return U&&(q=Wk(C,B||$),U=U&&q!==!1),{followOutputBehavior:q,shouldFollow:U,totalCount:D}}),Oe(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:V})=>{E!==null&&(E(),E=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(v)("following output to ",{totalCount:V},qt.DEBUG),T(D)}):E=nr(t,()=>{Ct(v)("following output to ",{totalCount:V},qt.DEBUG),T(D),E=null})});function N(D){const V=nr(c,C=>{D&&!C.atBottom&&C.notAtBottomBecause==="SIZE_INCREASED"&&E===null&&(Ct(v)("scrolling to bottom due to increased size",{},qt.DEBUG),T("auto"))});setTimeout(V,100)}it(me(Pt(_e(k),a,m),Oe(([D,,V])=>D!==!1&&V),fr(({value:D},[,V])=>({refreshed:D===V,value:V}),{refreshed:!1,value:0}),Oe(({refreshed:D})=>D),Ge(k,a)),([,D])=>{Ct(h)&&N(D!==!1)}),it(w,()=>{N(Ct(k)!==!1)}),it(Pt(_e(k),c),([D,V])=>{D!==!1&&!V.atBottom&&V.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&T("auto")});const L=ve(null),_=et();return Te(of(me(_e(i),ke(D=>(D==null?void 0:D.length)??0)),me(_e(a))),_),it(me(Pt(me(_,Ua(1)),x),Ge(_e(L),h,y,b),ke(([[D,V],C,B,M,$])=>V&&B&&(C==null?void 0:C({context:$,totalCount:D,scrollingInProgress:M}))),Oe(D=>!!D),zr(0)),D=>{E!==null&&(E(),E=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(v)("scrolling into view",{}),Fe(S,D)}):E=nr(t,()=>{Ct(v)("scrolling into view",{}),Fe(S,D),E=null})}),{autoscrollToBottom:w,followOutput:k,scrollIntoViewOnChange:L}},St(mr,ai,ni,ri,xa,ha,hn,jy,Sy)),Yk=lt(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Te(me(h,Ge(u),Oe(([,x])=>x!==0),Ge(c,i,a,s,t),ke(([[,x],m,v,y,b,S=[]])=>yy(x,m,v,y,b,S))),d),{}),St(mr,ri,Fa,xa),{singleton:!0}),Kk=lt(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ve(0);return it(me(t,Ge(i),Oe(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{nr(me(s,Ua(1),Oe(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(a,c)})})}),{initialScrollTop:i}},St(xa,hn,Fa),{singleton:!0}),ky=lt(([{scrollVelocity:t}])=>{const a=ve(!1),s=et(),i=ve(!1);return Te(me(t,Ge(i,a,s),Oe(([c,u])=>u!==!1&&u!==void 0),ke(([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}),jt()),a),it(me(Pt(a,t,s),Ge(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}},St(ai),{singleton:!0}),$f=lt(([{scrollContainerState:t,scrollTo:a}])=>{const s=et(),i=et(),c=et(),u=ve(!1),d=ve(void 0);return Te(me(Pt(s,i),ke(([{scrollTop:h,viewportHeight:x},{offsetTop:m,listHeight:v}])=>({scrollHeight:v,scrollTop:Math.max(0,h-m),viewportHeight:x}))),t),Te(me(a,Ge(i),ke(([h,{offsetTop:x}])=>({...h,top:h.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},St(hn)),Xk=lt(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:x}])=>{const m=et(),v=ve(void 0),y=ve(null),b=ve(null);return Te(h,y),Te(x,b),it(me(m,Ge(a,i,d,y,b,s)),([S,k,w,E,T,N,L])=>{const _=zk(k.sizeTree);E&&T!==null&&N!==null&&(w=T.scrollTop-N.offsetTop),w-=L,S({ranges:_,scrollTop:w})}),Te(me(v,Oe(Mf),ke(Qk)),c),Te(me(u,Ge(v),Oe(([,S])=>S!==void 0),jt(),ke(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:v}},St(mr,hn,ri,xa,$f));function Qk(t){return{align:"start",index:0,offset:t.scrollTop}}const Zk=lt(([{topItemsIndexes:t}])=>{const a=ve(0);return Te(me(a,Oe(s=>s>=0),ke(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},St(Fa));function wy(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const Jk=wy(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ew=lt(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:x},{beforeUnshiftWith:m,gap:v,shiftWithOffset:y,sizes:b},{log:S},{recalcInProgress:k}])=>{const w=zn(me(x,Ge(d),fr(([,T,N,L],[{bottom:_,items:D,offsetBottom:V,totalCount:C},B])=>{const M=_+V;let $=0;return N===C&&T.length>0&&D.length>0&&(D[0].originalIndex===0&&T[0].originalIndex===0||($=M-L,$!==0&&($+=B))),[$,D,C,M]},[0,[],0,0]),Oe(([T])=>T!==0),Ge(i,h,s,c,S,k),Oe(([,T,N,L,,,_])=>!_&&!L&&T!==0&&N===Qs),ke(([[T],,,,,N])=>(N("Upward scrolling compensation",{amount:T},qt.DEBUG),T))));function E(T){T>0?(Fe(a,{behavior:"auto",top:-T}),Fe(t,0)):(Fe(t,0),Fe(a,{behavior:"auto",top:-T}))}return it(me(w,Ge(t,u)),([T,N,L])=>{L&&Jk()?Fe(t,N-T):E(-T)}),it(me(Pt(on(u,!1),t,k),Oe(([T,N,L])=>!T&&!L&&N!==0),ke(([T,N])=>N),zr(1)),E),Te(me(y,ke(T=>({top:-T}))),a),it(me(m,Ge(b,v),ke(([T,{groupIndices:N,lastSize:L,sizeTree:_},D])=>{function V(U){return U*(L+D)}if(N.length===0)return V(T);let C=0;const B=Ys(_,0);let M=0,$=0;for(;M<T;){M++,C+=B;let U=N.length===$+1?1/0:N[$+1]-N[$]-1;M+U>T&&(C-=B,U=T-M+1),M+=U,C+=V(U),$++}return C})),T=>{Fe(t,T),requestAnimationFrame(()=>{Fe(a,{top:T}),requestAnimationFrame(()=>{Fe(t,0),Fe(k,!1)})})}),{deviation:t}},St(hn,ai,Fa,mr,ha,Df)),tw=lt(([t,a,s,i,c,u,d,h,x,m,v])=>({...t,...a,...s,...i,...c,...u,...d,...h,...x,...m,...v}),St(If,Yk,xa,ky,by,Kk,Fk,$f,Sy,ha,jy)),Cy=lt(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:x,sizeRanges:m,sizes:v,statefulTotalCount:y,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:w,scrolledToInitialItem:E},T,N,L,_,{scrollToIndex:D},V,{topItemCount:C},{groupCounts:B},M])=>{const{listState:$,minOverscanItemCount:U,topItemsIndexes:q,rangeChanged:X,...ee}=_;return Te(X,M.scrollSeekRangeChanged),Te(me(M.windowViewportRect,ke(H=>H.visibleHeight)),T.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:B,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:w,scrolledToInitialItem:E,sizeRanges:m,topItemCount:C,topItemsIndexes:q,totalCount:b,...L,groupIndices:d,itemSize:x,listState:$,minOverscanItemCount:U,scrollToIndex:D,statefulTotalCount:y,trackItemSizes:S,rangeChanged:X,...ee,...M,...T,sizes:v,...N}},St(mr,ri,hn,Xk,qk,Fa,ni,ew,Zk,xy,tw));function nw(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 ko=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Ey(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=Ne.createContext({});function x(E,T){E.propsReady!==void 0&&Fe(E.propsReady,!1);for(const N of i){const L=E[a.required[N]];Fe(L,T[N])}for(const N of c)if(N in T){const L=E[a.optional[N]];Fe(L,T[N])}E.propsReady!==void 0&&Fe(E.propsReady,!0)}function m(E){return u.reduce((T,N)=>(T[N]=L=>{const _=E[a.methods[N]];Fe(_,L)},T),{})}function v(E){return d.reduce((T,N)=>(T[N]=vk(E[a.events[N]]),T),{})}const y=Ne.forwardRef(function(E,T){const{children:N,...L}=E,[_]=Ne.useState(()=>nc(bk(t),C=>{x(C,L)})),[D]=Ne.useState(jg(v,_));ko(()=>{for(const C of d)C in L&&it(D[C],L[C]);return()=>{Object.values(D).map(Lf)}},[L,D,_]),ko(()=>{x(_,L)}),Ne.useImperativeHandle(T,bg(m(_)));const V=s;return r.jsx(h.Provider,{value:_,children:s!==void 0?r.jsx(V,{...nw([...i,...c,...d],L),children:N}):N})}),b=E=>{const T=Ne.useContext(h);return Ne.useCallback(N=>{Fe(T[E],N)},[T,E])},S=E=>{const T=Ne.useContext(h)[E],N=Ne.useCallback(L=>it(T,L),[T]);return Ne.useSyncExternalStore(N,()=>Ct(T),()=>Ct(T))},k=E=>{const T=Ne.useContext(h)[E],[N,L]=Ne.useState(jg(Ct,T));return ko(()=>it(T,_=>{_!==N&&L(bg(_))}),[T,N]),N},w=parseInt(Ne.version)>=18?S:k;return{Component:y,useEmitter:(E,T)=>{const N=Ne.useContext(h)[E];ko(()=>it(N,T),[T,N])},useEmitterValue:w,usePublisher:b}}const Ny=Ne.createContext(void 0),Ty=Ne.createContext(void 0),zd="-webkit-sticky",Lg="sticky",Uf=wy(()=>{if(typeof document>"u")return Lg;const t=document.createElement("div");return t.style.position=zd,t.style.position===zd?zd:Lg}),Ry=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Dd(t){return"self"in t}function rw(t){return"body"in t}function Ay(t,a,s,i=Hl,c,u){const d=Ne.useRef(null),h=Ne.useRef(null),x=Ne.useRef(null),m=Ne.useCallback(b=>{let S,k,w;const E=b.target;if(rw(E)||Dd(E)){const N=Dd(E)?E:E.defaultView;w=u===!0?N.scrollX:N.scrollY,S=u===!0?N.document.documentElement.scrollWidth:N.document.documentElement.scrollHeight,k=u===!0?N.innerWidth:N.innerHeight}else w=u===!0?E.scrollLeft:E.scrollTop,S=u===!0?E.scrollWidth:E.scrollHeight,k=u===!0?E.offsetWidth:E.offsetHeight;const T=()=>{t({scrollHeight:S,scrollTop:Math.max(w,0),viewportHeight:k})};b.suppressFlushSync===!0?T():gS.flushSync(T),h.current!==null&&(w===h.current||w<=0||w===S-k)&&(h.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Ne.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 v(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let w,E,T;Dd(S)?(E=Math.max(fa(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),w=u===!0?S.innerWidth:S.innerHeight,T=u===!0?window.scrollX:window.scrollY):(E=S[u===!0?"scrollWidth":"scrollHeight"],w=fa(S,u===!0?"width":"height"),T=S[u===!0?"scrollLeft":"scrollTop"]);const N=E-w;if(b.top=Math.ceil(Math.max(Math.min(N,b.top),0)),vy(w,E)||b.top===T){t({scrollHeight:E,scrollTop:T,viewportHeight:w}),k&&a(!0);return}k?(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 y(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:y,scrollerRef:d,scrollToCallback:v}}function Hf(t){return t}const aw=lt(()=>{const t=ve(h=>`Item ${h}`),a=ve(h=>`Group ${h}`),s=ve({}),i=ve(Hf),c=ve("div"),u=ve(Hl),d=(h,x=null)=>on(me(s,ke(m=>m[h]),jt()),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")}}),lw=lt(([t,a])=>({...t,...a}),St(Cy,aw)),sw=({height:t})=>r.jsx("div",{style:{height:t}}),iw={overflowAnchor:"none",position:Uf(),zIndex:1},My={overflowAnchor:"none"},ow={...My,display:"inline-block",height:"100%"},zg=Ne.memo(function({showTopList:t=!1}){const a=He("listState"),s=Yn("sizeRanges"),i=He("useWindowScroll"),c=He("customScrollParent"),u=Yn("windowScrollContainerState"),d=Yn("scrollContainerState"),h=c||i?u:d,x=He("itemContent"),m=He("context"),v=He("groupContent"),y=He("trackItemSizes"),b=He("itemSize"),S=He("log"),k=Yn("gap"),w=He("horizontalDirection"),{callbackRef:E}=kk(s,b,y,t?Hl:h,S,k,c,w,He("skipAnimationFrameInResizeObserver")),[T,N]=Ne.useState(0);Pf("deviation",ee=>{T!==ee&&N(ee)});const L=He("EmptyPlaceholder"),_=He("ScrollSeekPlaceholder")??sw,D=He("ListComponent"),V=He("ItemComponent"),C=He("GroupComponent"),B=He("computeItemKey"),M=He("isSeeking"),$=He("groupIndices").length>0,U=He("alignToBottom"),q=He("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:T!==0?T:U?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:T!==0?T:U?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&L!==null&&L!==void 0?r.jsx(L,{...sn(L,m)}):r.jsx(D,{...sn(D,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:E,style:X,children:(t?a.topItems:a.items).map(ee=>{const H=ee.originalIndex,A=B(H+a.firstItemIndex,ee.data,m);return M?p.createElement(_,{...sn(_,m),height:ee.size,index:ee.index,key:A,type:ee.type||"item",...ee.type==="group"?{}:{groupIndex:ee.groupIndex}}):ee.type==="group"?p.createElement(C,{...sn(C,m),"data-index":H,"data-item-index":ee.index,"data-known-size":ee.size,key:A,style:iw},v(ee.index,m)):p.createElement(V,{...sn(V,m),...fw(V,ee.data),"data-index":H,"data-item-group-index":ee.groupIndex,"data-item-index":ee.index,"data-known-size":ee.size,key:A,style:w?ow:My},$?x(ee.index,ee.groupIndex,ee.data,m):x(ee.index,ee.data,m))})})}),cw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},uw={outline:"none",overflowX:"auto",position:"relative"},ac=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),dw={position:Uf(),top:0,width:"100%",zIndex:1};function sn(t,a){if(typeof t!="string")return{context:a}}function fw(t,a){return{item:typeof t=="string"?void 0:a}}const pw=Ne.memo(function(){const t=He("HeaderComponent"),a=Yn("headerHeight"),s=He("HeaderFooterTag"),i=Va(Ne.useMemo(()=>u=>{a(fa(u,"height"))},[a]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...sn(t,c)})}):null}),mw=Ne.memo(function(){const t=He("FooterComponent"),a=Yn("footerHeight"),s=He("HeaderFooterTag"),i=Va(Ne.useMemo(()=>u=>{a(fa(u,"height"))},[a]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...sn(t,c)})}):null});function Ly({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:i,style:c,context:u,...d}){const h=s("scrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),v=a("scrollerRef"),y=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=Ay(h,m,x,v,void 0,y);return t("scrollTo",k),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...y?uw:cw,...c},tabIndex:0,...d,...sn(x,u),children:i})})}function zy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:i,style:c,context:u,...d}){const h=s("windowScrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),v=a("totalListHeight"),y=a("deviation"),b=a("customScrollParent"),S=Ne.useRef(null),k=a("scrollerRef"),{scrollByCallback:w,scrollerRef:E,scrollToCallback:T}=Ay(h,m,x,k,b);return Ry(()=>{var N;return E.current=b||((N=S.current)==null?void 0:N.ownerDocument.defaultView),()=>{E.current=null}},[E,b]),t("windowScrollTo",T),t("scrollBy",w),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...v!==0?{height:v+y}:void 0},...d,...sn(x,u),children:i})})}const hw=({children:t})=>{const a=Ne.useContext(Ny),s=Yn("viewportHeight"),i=Yn("fixedItemHeight"),c=He("alignToBottom"),u=He("horizontalDirection"),d=Ne.useMemo(()=>ay(s,x=>fa(x,u?"width":"height")),[s,u]),h=Va(d,!0,He("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:ac(c),children:t})},xw=({children:t})=>{const a=Ne.useContext(Ny),s=Yn("windowViewportRect"),i=Yn("fixedItemHeight"),c=He("customScrollParent"),u=sy(s,c,He("skipAnimationFrameInResizeObserver")),d=He("alignToBottom");return Ne.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:ac(d),children:t})},gw=({children:t})=>{const a=He("TopItemListComponent")??"div",s=He("headerHeight"),i={...dw,marginTop:`${s}px`},c=He("context");return r.jsx(a,{style:i,...sn(a,c),children:t})},vw=Ne.memo(function(t){const a=He("useWindowScroll"),s=He("topItemsIndexes").length>0,i=He("customScrollParent"),c=He("context");return r.jsxs(i||a?jw:bw,{...t,context:c,children:[s&&r.jsx(gw,{children:r.jsx(zg,{showTopList:!0})}),r.jsxs(i||a?xw:hw,{children:[r.jsx(pw,{}),r.jsx(zg,{}),r.jsx(mw,{})]})]})}),{Component:yw,useEmitter:Pf,useEmitterValue:He,usePublisher:Yn}=Ey(lw,{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"}},vw),bw=Ly({useEmitter:Pf,useEmitterValue:He,usePublisher:Yn}),jw=zy({useEmitter:Pf,useEmitterValue:He,usePublisher:Yn}),Sw=yw,kw=lt(()=>{const t=ve(m=>r.jsxs("td",{children:["Item $",m]})),a=ve(null),s=ve(m=>r.jsxs("td",{colSpan:1e3,children:["Group ",m]})),i=ve(null),c=ve(null),u=ve({}),d=ve(Hf),h=ve(Hl),x=(m,v=null)=>on(me(u,ke(y=>y[m]),jt()),v);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")}});St(Cy,kw);Uf();const Dg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},ww={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_g,floor:Fo,max:Fs,min:_d,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 Cw(t){return{...ww,items:t}}function wo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Ew(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Nw=lt(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:x,scrollTop:m,smoothScrollTargetReached:v,viewportHeight:y},b,S,{didMount:k,propsReady:w},{customScrollParent:E,useWindowScroll:T,windowScrollContainerState:N,windowScrollTo:L,windowViewportRect:_},D])=>{const V=ve(0),C=ve(0),B=ve(Dg),M=ve({height:0,width:0}),$=ve({height:0,width:0}),U=et(),q=et(),X=ve(0),ee=ve(null),H=ve({column:0,row:0}),A=et(),I=et(),G=ve(!1),O=ve(0),ne=ve(!0),z=ve(!1),W=ve(!1);it(me(k,Ge(O),Oe(([ie,ye])=>ye!==0)),()=>{Fe(ne,!1)}),it(me(Pt(k,ne,$,M,O,z),Oe(([ie,ye,Re,Ae,,le])=>ie&&!ye&&Re.height!==0&&Ae.height!==0&&!le)),([,,,,ie])=>{Fe(z,!0),Of(1,()=>{Fe(U,ie)}),nr(me(m),()=>{Fe(a,[0,0]),Fe(ne,!0)})}),Te(me(I,Oe(ie=>ie!=null&&ie.scrollTop>0),dr(0)),C),it(me(k,Ge(I),Oe(([,ie])=>ie!=null)),([,ie])=>{ie&&(Fe(M,ie.viewport),Fe($,ie.item),Fe(H,ie.gap),ie.scrollTop>0&&(Fe(G,!0),nr(me(m,Ua(1)),ye=>{Fe(G,!1)}),Fe(x,{top:ie.scrollTop})))}),Te(me(M,ke(({height:ie})=>ie)),y),Te(me(Pt(_e(M,wo),_e($,wo),_e(H,(ie,ye)=>ie!==void 0&&ie.column===ye.column&&ie.row===ye.row),_e(m)),ke(([ie,ye,Re,Ae])=>({gap:Re,item:ye,scrollTop:Ae,viewport:ie}))),A),Te(me(Pt(_e(V),i,_e(H,Ew),_e($,wo),_e(M,wo),_e(ee),_e(C),_e(G),_e(ne),_e(O)),Oe(([,,,,,,,ie])=>!ie),ke(([ie,[ye,Re],Ae,le,he,pe,xe,,je,Be])=>{const{column:Ie,row:Nt}=Ae,{height:Vt,width:ut}=le,{width:Et}=he;if(xe===0&&(ie===0||Et===0))return Dg;if(ut===0){const ft=Bf(Be,ie),Lt=ft+Math.max(xe-1,0);return Cw(Bg(ft,Lt,pe))}const Ft=Dy(Et,ut,Ie);let qe,dt;je?ye===0&&Re===0&&xe>0?(qe=0,dt=xe-1):(qe=Ft*Fo((ye+Nt)/(Vt+Nt)),dt=Ft*_g((Re+Nt)/(Vt+Nt))-1,dt=_d(ie-1,Fs(dt,Ft-1)),qe=_d(dt,Fs(0,qe))):(qe=0,dt=-1);const Jt=Bg(qe,dt,pe),{bottom:Kt,top:cn}=Ig(he,Ae,le,Jt),ge=_g(ie/Ft),tt=ge*Vt+(ge-1)*Nt-Kt;return{bottom:Kt,itemHeight:Vt,items:Jt,itemWidth:ut,offsetBottom:tt,offsetTop:cn,top:cn}})),B),Te(me(ee,Oe(ie=>ie!==null),ke(ie=>ie.length)),V),Te(me(Pt(M,$,B,H),Oe(([ie,ye,{items:Re}])=>Re.length>0&&ye.height!==0&&ie.height!==0),ke(([ie,ye,{items:Re},Ae])=>{const{bottom:le,top:he}=Ig(ie,Ae,ye,Re);return[he,le]}),jt(Ks)),a);const re=ve(!1);Te(me(m,Ge(re),ke(([ie,ye])=>ye||ie!==0)),re);const Y=zn(me(Pt(B,V),Oe(([{items:ie}])=>ie.length>0),Ge(re),Oe(([[ie,ye],Re])=>{const Ae=ie.items[ie.items.length-1].index===ye-1;return(Re||ie.bottom>0&&ie.itemHeight>0&&ie.offsetBottom===0&&ie.items.length===ye)&&Ae}),ke(([[,ie]])=>ie-1),jt())),ce=zn(me(_e(B),Oe(({items:ie})=>ie.length>0&&ie[0].index===0),dr(0),jt())),se=zn(me(_e(B),Ge(G),Oe(([{items:ie},ye])=>ie.length>0&&!ye),ke(([{items:ie}])=>({endIndex:ie[ie.length-1].index,startIndex:ie[0].index})),jt(fy),zr(0)));Te(se,S.scrollSeekRangeChanged),Te(me(U,Ge(M,$,V,H),ke(([ie,ye,Re,Ae,le])=>{const he=gy(ie),{align:pe,behavior:xe,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=Ae-1),Be=Fs(0,Be,_d(Ae-1,Be));let Ie=pf(ye,le,Re,Be);return pe==="end"?Ie=Og(Ie-ye.height+Re.height):pe==="center"&&(Ie=Og(Ie-ye.height/2+Re.height/2)),je!==void 0&&je!==0&&(Ie+=je),{behavior:xe,top:Ie}})),x);const be=on(me(B,ke(ie=>ie.offsetBottom+ie.bottom)),0);return Te(me(_,ke(ie=>({height:ie.visibleHeight,width:ie.visibleWidth}))),M),{customScrollParent:E,data:ee,deviation:X,footerHeight:c,gap:H,headerHeight:u,increaseViewportBy:t,initialItemCount:C,itemDimensions:$,overscan:s,restoreStateFrom:I,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:x,scrollToIndex:U,scrollTop:m,smoothScrollTargetReached:v,totalCount:V,useWindowScroll:T,viewportDimensions:M,windowScrollContainerState:N,windowScrollTo:L,windowViewportRect:_,...S,gridState:B,horizontalDirection:W,initialTopMostItemIndex:O,totalListHeight:be,...b,endReached:Y,propsReady:w,rangeChanged:se,startReached:ce,stateChanged:A,stateRestoreInProgress:G,...D}},St(If,hn,ai,ky,xa,$f,ha));function Dy(t,a,s){return Fs(1,Fo((t+s)/(Fo(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=pf(t,a,s,i[0].index);return{bottom:pf(t,a,s,i[i.length-1].index)+c,top:u}}function pf(t,a,s,i){const c=Dy(t.width,s.width,a.column),u=Fo(i/c),d=u*s.height+Fs(0,u-1)*a.row;return d>0?d+a.row:d}const Tw=lt(()=>{const t=ve(y=>`Item ${y}`),a=ve({}),s=ve(null),i=ve("virtuoso-grid-item"),c=ve("virtuoso-grid-list"),u=ve(Hf),d=ve("div"),h=ve(Hl),x=(y,b=null)=>on(me(a,ke(S=>S[y]),jt()),b),m=ve(!1),v=ve(!1);return Te(_e(v),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:v,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),Rw=lt(([t,a])=>({...t,...a}),St(Nw,Tw)),Aw=Ne.memo(function(){const t=wt("gridState"),a=wt("listClassName"),s=wt("itemClassName"),i=wt("itemContent"),c=wt("computeItemKey"),u=wt("isSeeking"),d=Kn("scrollHeight"),h=wt("ItemComponent"),x=wt("ListComponent"),m=wt("ScrollSeekPlaceholder"),v=wt("context"),y=Kn("itemDimensions"),b=Kn("gap"),S=wt("log"),k=wt("stateRestoreInProgress"),w=Kn("reportReadyState"),E=Va(Ne.useMemo(()=>T=>{const N=T.parentElement.parentElement.scrollHeight;d(N);const L=T.firstChild;if(L!==null){const{height:_,width:D}=L.getBoundingClientRect();y({height:_,width:D})}b({column:$g("column-gap",getComputedStyle(T).columnGap,S),row:$g("row-gap",getComputedStyle(T).rowGap,S)})},[d,y,b,S]),!0,!1);return Ry(()=>{t.itemHeight>0&&t.itemWidth>0&&w(!0)},[t]),k?null:r.jsx(x,{className:a,ref:E,...sn(x,v),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(T=>{const N=c(T.index,T.data,v);return u?r.jsx(m,{...sn(m,v),height:t.itemHeight,index:T.index,width:t.itemWidth},N):p.createElement(h,{...sn(h,v),className:s,"data-index":T.index,key:N},i(T.index,T.data,v))})})}),Mw=Ne.memo(function(){const t=wt("HeaderComponent"),a=Kn("headerHeight"),s=wt("headerFooterTag"),i=Va(Ne.useMemo(()=>u=>{a(fa(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...sn(t,c)})}):null}),Lw=Ne.memo(function(){const t=wt("FooterComponent"),a=Kn("footerHeight"),s=wt("headerFooterTag"),i=Va(Ne.useMemo(()=>u=>{a(fa(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...sn(t,c)})}):null}),zw=({children:t})=>{const a=Ne.useContext(Ty),s=Kn("itemDimensions"),i=Kn("viewportDimensions"),c=Va(Ne.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Ne.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:ac(!1),children:t})},Dw=({children:t})=>{const a=Ne.useContext(Ty),s=Kn("windowViewportRect"),i=Kn("itemDimensions"),c=wt("customScrollParent"),u=sy(s,c,!1);return Ne.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:ac(!1),children:t})},_w=Ne.memo(function({...t}){const a=wt("useWindowScroll"),s=wt("customScrollParent"),i=s||a?Bw:Ow,c=s||a?Dw:zw,u=wt("context");return r.jsx(i,{...t,...sn(i,u),children:r.jsxs(c,{children:[r.jsx(Mw,{}),r.jsx(Aw,{}),r.jsx(Lw,{})]})})}),{useEmitter:_y,useEmitterValue:wt,usePublisher:Kn}=Ey(Rw,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},_w),Ow=Ly({useEmitter:_y,useEmitterValue:wt,usePublisher:Kn}),Bw=zy({useEmitter:_y,useEmitterValue:wt,usePublisher:Kn});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 Iw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Oy={source:"Own",installed:"Installed"};function $w(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 Uw(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=Iw[t],[d,h]=p.useState(()=>$w(u)),x=p.useCallback(()=>{h(b=>{const S=!b;return Uw(u,S),S})},[u]),m=Oy[t],v=`sidebar-section-${t}-header`,y=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:v,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":y,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(Pw,{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(Hw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:y,role:"group","aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Hw({origin:t,updateCount:a}){const[s,i]=p.useState(!1),c=Oy[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 Pw({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 Vf(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 Vw({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 v=m.target;if(!v)return;const y=v.tagName;y==="INPUT"||y==="TEXTAREA"||v.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 Fw({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 Gw({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 Ww({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(qv)}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 qw(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 li(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,v=i==="sm"?1:2,y=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=qw(c,h,u),k=t.title??S,w={display:"inline-flex",alignItems:"center",padding:`${v}px ${y}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:m,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(w.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":h,"data-version-source":c,title:k,style:w,children:x})}function Yw({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(li,{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(Fw,{target:t.symlinkTarget??null}),r.jsx(Gw,{skill:t}),r.jsx(Ww,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Go=p.memo(Yw);function Kw({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(Go,{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 Xw(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(()=>Xw(i,s)),v=d?!1:x,y=p.useCallback(()=>{m(k=>{const w=!k;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(w))}catch{}return w})},[i]),b=v?"▸":"▾";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:y,"aria-expanded":!v,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})]}),!v&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>r.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}function mf({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),v=p.useRef(null);if(p.useEffect(()=>{if(t)return v.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=m.current)==null||k.focus()}),()=>{var k,w;(w=(k=v.current)==null?void 0:k.focus)==null||w.call(k),v.current=null}},[t]),p.useEffect(()=>{if(!t)return;function k(w){if(w.key==="Escape"){w.preventDefault(),h();return}if(w.key==="Tab"&&x.current){const E=x.current.querySelectorAll("button:not([disabled])");if(E.length===0)return;const T=E[0],N=E[E.length-1];w.shiftKey&&document.activeElement===T?(w.preventDefault(),N.focus()):!w.shiftKey&&document.activeElement===N&&(w.preventDefault(),T.focus())}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[t,h]),!t)return null;const y="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:k=>{k.target===k.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":y,"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:y,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 Qw(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Od(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Zw({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=p.useState(!1),[u,d]=p.useState(null),[h,x]=p.useState(null),[m,v]=p.useState(!1),y=p.useRef(null);p.useEffect(()=>{if(!i)return;function k(w){y.current&&!y.current.contains(w.target)&&c(!1)}return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[i]);async function b(k){d(k),x(null);try{const w=await fetch(`/api/plugins/${encodeURIComponent(t)}/${k}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),E=await w.json().catch(()=>({}));if(!w.ok||!E.ok){const T=E.error??`${k} failed (${w.status})`;x(T),k==="uninstall"&&Od(`Failed to uninstall ${t}: ${T}`,"error");return}if(k==="uninstall"){const T=E.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Od(T,"success")}Ln("skills"),ny(),s==null||s(),c(!1)}catch(w){const E=w instanceof Error?w.message:String(w);x(E),k==="uninstall"&&Od(`Failed to uninstall ${t}: ${E}`,"error")}finally{d(null)}}function S(){v(!0)}return r.jsxs("div",{ref:y,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:k=>{k.stopPropagation(),c(w=>!w)},"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:k=>{k.currentTarget.style.color="var(--text-primary)",k.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:k=>{k.currentTarget.style.color="var(--text-tertiary)",k.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(Bd,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Bd,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Bd,{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(mf,{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:()=>{v(!1),c(!1)},onConfirm:()=>{v(!1),b("uninstall")}})]})}function Bd({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",v={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"},y=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:y}),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(Jw,{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:v,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:v,children:b})}function Jw({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 eC(){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 tC(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 nC(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 rC(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 hf(t,a={}){const{enabled:s=!0,target:i}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(tC),p.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function h(x){const m=x,v=nC(m.target);for(const y of c.current){if(!rC(m,y))continue;const b=y.meta||y.ctrl||y.alt;if(!(v&&!y.allowInInputs&&!b)){y.handler(m);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,i])}function By(){const{data:t,loading:a,error:s,revalidate:i}=$l("project-github-status",()=>Se.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function aC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function lC({projectRoot:t}){const{status:a,loading:s}=By();if(s||!a||a.status==="github"||aC(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 sC=200;function iC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function oC(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=>Vf(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 cC(t,a){const s=[],i=[],c=[];for(const d of t){const h=iC(d);h==="global"?c.push(d):h==="installed"?i.push(d):s.push(d)}function u(d){var v;const h=d.filter(y=>Vf(y,a)),x={};for(const y of h)(x[v=y.plugin]||(x[v]=[])).push(y);const m=Object.entries(x).sort((y,b)=>y[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(i),global:u(c)}}function uC(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(v=>Vf(v,a)),h={};for(const v of d)(h[m=v.plugin]||(h[m]=[])).push(v);const x=Object.entries(h).sort((v,y)=>v[0].localeCompare(y[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function dC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:x,outdatedByScope:m,topSlot:v,revealSkillId:y,onRevealComplete:b,dirtySkillIds:S}){const k=!!x||t.some(Y=>Y.scope!==void 0&&Y.scope!==null),w=x??"claude-cli",[E,T]=p.useState(""),N=p.useDeferredValue(E),L=p.useMemo(()=>cC(t,N),[t,N]),_=p.useMemo(()=>oC(t,N),[t,N]),D=w==="claude-code",{plugins:V}=fk(),C=D?{plugins:V??[]}:void 0,B=p.useMemo(()=>{const Y=new Map;for(const ce of(C==null?void 0:C.plugins)??[]){const se=Y.get(ce.name);Y.set(ce.name,!!se||!!ce.enabled)}return Y},[C==null?void 0:C.plugins]),[M,$]=p.useState(()=>xf(`vskill-sidebar-${w}-group-available-collapsed`)),[U,q]=p.useState(()=>xf(`vskill-sidebar-${w}-group-authoring-collapsed`)),X=p.useCallback(Y=>{$(Y);try{window.localStorage.setItem(`vskill-sidebar-${w}-group-available-collapsed`,String(Y))}catch{}},[w]),ee=p.useCallback(Y=>{q(Y);try{window.localStorage.setItem(`vskill-sidebar-${w}-group-authoring-collapsed`,String(Y))}catch{}},[w]),{own:H,installed:A}=p.useMemo(()=>uC(t,N),[t,N]),G=L.own.filtered+L.installed.filtered+L.global.filtered>=sC,O=p.useMemo(()=>{const Y=ce=>{const se=[];for(const[,be]of ce){const ie=[...be].sort((ye,Re)=>ye.skill.localeCompare(Re.skill));se.push(...ie)}return se};return k?[...Y(L.own.byPlugin),...Y(L.installed.byPlugin),...Y(L.global.byPlugin)]:[...Y(H.byPlugin),...Y(A.byPlugin)]},[k,L.own.byPlugin,L.installed.byPlugin,L.global.byPlugin,H.byPlugin,A.byPlugin]),ne=p.useMemo(()=>a?O.findIndex(Y=>Y.plugin===a.plugin&&Y.skill===a.skill):-1,[O,a]),z=p.useCallback(Y=>{if(O.length===0)return;const ce=ne<0?Y>0?0:O.length-1:Math.min(Math.max(ne+Y,0),O.length-1);s(O[ce])},[O,ne,s]),W=p.useMemo(()=>{if(!y)return null;const[Y,ce]=y.split("/");if(!Y||!ce)return null;const se=t.find(ye=>ye.plugin===Y&&ye.skill===ce);if(!se)return{plugin:Y,skill:ce,bucket:null,pluginName:null};const be=se.source==="plugin"?"plugin":"project",ie=be==="plugin"?se.pluginName??Y:null;return{plugin:Y,skill:ce,bucket:be,pluginName:ie}},[y,t]),re=p.useRef(null);return p.useEffect(()=>{if(!y){re.current=null;return}if(re.current===y)return;const Y=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(y):y.replace(/["\\]/g,"\\$&"),ce=document.querySelector(`[data-skill-id="${Y}"]`);ce&&(re.current=y,ce.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[y,b,t]),hf([{key:"j",handler:()=>z(1)},{key:"k",handler:()=>z(-1)},{key:"Enter",handler:()=>{ne>=0&&s(O[ne])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[v,r.jsx(Vw,{value:E,onChange:T}),i&&r.jsx(xC,{}),!i&&c&&r.jsx(gC,{error:c,onRetry:u}),!i&&!c&&k&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Pg,{name:te.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:M,onToggle:X,count:_.availableProject.total+_.availablePersonal.total+_.availablePlugin.total}),!M&&r.jsxs(r.Fragment,{children:[r.jsx(Os,{label:te.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${w}-available-project-collapsed`,count:_.availableProject.total,filteredCount:E?_.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),headerRightSlot:D?r.jsx(lC,{projectRoot:w}):null,children:_.availableProject.filtered===0?r.jsx(Fg,{queryActive:!!E,agentId:w}):r.jsx(Bs,{items:_.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),r.jsx(Os,{label:te.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${w}-available-personal-collapsed`,count:_.availablePersonal.total,filteredCount:E?_.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:_.availablePersonal.filtered===0?r.jsx(pC,{queryActive:!!E,agentId:w}):r.jsx(Bs,{items:_.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),D&&r.jsxs(Os,{label:te.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${w}-available-plugin-collapsed`,count:_.availablePlugin.total,filteredCount:E?_.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("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):_.availablePlugin.byPlugin.map(([Y,ce])=>r.jsx(Hg,{pluginName:Y,skills:ce,persistKey:`vskill-plugin-available-${Y}-collapsed`,headerActionSlot:D?r.jsx(Zw,{pluginName:Y,enabled:B.get(Y)??!0}):void 0,renderSkill:se=>r.jsx(Go,{skill:se,isSelected:(a==null?void 0:a.plugin)===se.plugin&&(a==null?void 0:a.skill)===se.skill,onSelect:()=>s(se),onContextMenu:d,dirty:S==null?void 0:S.has(`${se.plugin}/${se.skill}`)})},`available-${Y}`))]})]}),r.jsx(hC,{}),r.jsx(Pg,{name:te.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:W?!1:U,onToggle:ee,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(Os,{label:te.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${w}-authoring-project-collapsed`,count:_.authoringProject.total,filteredCount:E?_.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:!!E}):r.jsx(Bs,{items:_.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),D&&r.jsx(Os,{label:te.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${w}-authoring-plugin-collapsed`,count:_.authoringPlugin.total,filteredCount:E?_.authoringPlugin.filtered:null,forceOpen:(W==null?void 0:W.bucket)==="plugin",children:_.authoringPlugin.filtered===0?r.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",r.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):_.authoringPlugin.byPlugin.map(([Y,ce])=>r.jsx(Hg,{pluginName:Y,skills:ce,persistKey:`vskill-plugin-authoring-${Y}-collapsed`,forceOpen:(W==null?void 0:W.bucket)==="plugin"&&W.pluginName===Y,renderSkill:se=>r.jsx(Go,{skill:se,isSelected:(a==null?void 0:a.plugin)===se.plugin&&(a==null?void 0:a.skill)===se.skill,onSelect:()=>s(se),onContextMenu:d,dirty:S==null?void 0:S.has(`${se.plugin}/${se.skill}`)})},`authoring-${Y}`))})]})]}),!i&&!c&&!k&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ug,{origin:"source",count:H.total,filteredCount:E?H.filtered:null,updateCount:h==null?void 0:h.source,children:H.filtered===0?r.jsx(Vg,{queryActive:!!E}):r.jsx(Bs,{items:H.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),r.jsx(mC,{}),r.jsx(Ug,{origin:"installed",count:A.total,filteredCount:E?A.filtered:null,updateCount:h==null?void 0:h.installed,children:A.filtered===0?r.jsx(Fg,{queryActive:!!E}):r.jsx(Bs,{items:A.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})})]})]})}function xf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Os({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:h}){const[x,m]=p.useState(()=>xf(a)),v=d?!1:x,y=p.useCallback(()=>{m(S=>{const k=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(k))}catch{}return k})},[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:y,"aria-expanded":!v,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:v?"▸":"▾"}),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]}),!v&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function fC(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 Bs({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=fC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Sw,{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,v=!!a&&a.plugin===m.plugin&&a.skill===m.skill;return r.jsx(Go,{skill:m,isSelected:v,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(Kw,{plugin:d,skills:h,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Vg({queryActive:t}){return t?r.jsx(_l,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(_l,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Ff,{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(_l,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(_l,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Ff,{children:"vskill install <skill>"})," to add one."]})})}function pC({queryActive:t,agentId:a}){return t?r.jsx(_l,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(_l,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Ff,{children:"vskill install --global <skill>"})," to add one."]})})}function _l({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 Ff({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 mC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function hC(){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 xC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(eC,{},t))})}function gC({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:vC(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 vC(t){const a=t.split(`
|
|
66
|
+
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const Iy=240,$y=480,Uy="vskill-sidebar-width",Gs=320;function Gf(t){return Number.isFinite(t)?Math.round(Math.max(Iy,Math.min($y,t))):Gs}function yC(){try{const t=localStorage.getItem(Uy);if(!t)return Gs;const a=Number(t);return Number.isFinite(a)?Gf(a):Gs}catch{return Gs}}function bC(t){try{localStorage.setItem(Uy,String(Gf(t)))}catch{}}function jC({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,bC(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":Iy,"aria-valuemax":$y,"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 SC=/^[ MADRCU?!]{1,2} +/;function kC(t){return t.replace(SC,"")}function wC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function CC(t,a,s){const i=new Set;if(a.length===0||t.length===0)return i;const c=a.map(u=>kC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const h=wC(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 v of c)if(v===h||v.startsWith(m)){i.add(x);break}}return i}const EC=5e3;function NC(t,a,s=EC){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 v=await Se.gitStatus();d||c(v.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?CC(u.current,i,a):new Set}function TC({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 Hy(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 Py(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 Id(){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(y,b)=>{a([]),i(!0),u(!1),h(null);const S=new AbortController;x.current=S;try{const k=Py(b),w=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!w.ok||!w.body){let _=`HTTP ${w.status}`,D;try{D=await w.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(_=D.error)}catch{}throw Hy(w.status,D),new Error(_)}const E=w.body.getReader(),T=new TextDecoder;let N="",L="";for(;;){const{done:_,value:D}=await E.read();if(_)break;N+=T.decode(D,{stream:!0});const V=N.split(`
|
|
67
|
+
`);N=V.pop()||"";for(const C of V)if(C.startsWith("event: "))L=C.slice(7).trim();else if(C.startsWith("data: ")){try{const B=JSON.parse(C.slice(6)),M={event:L,data:B};L==="done"?(u(!0),a($=>[...$,M])):a($=>[...$,M])}catch{}L=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{i(!1),x.current=null}},[]),v=p.useCallback(()=>{var y;(y=x.current)==null||y.abort()},[]);return{events:t,running:s,done:c,error:d,start:m,stop:v}}function RC(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,v,y)=>{var S;(S=c.current.get(m))==null||S.abort();const b=new AbortController;c.current.set(m,b),i(k=>{const w=new Set(k);return w.add(m),w});try{const k=Py(y),w=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!w.ok||!w.body){let _=`HTTP ${w.status}`,D;try{D=await w.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(_=D.error)}catch{}throw Hy(w.status,D),new Error(_)}const E=w.body.getReader(),T=new TextDecoder;let N="",L="";for(;;){const{done:_,value:D}=await E.read();if(_)break;N+=T.decode(D,{stream:!0});const V=N.split(`
|
|
68
|
+
`);N=V.pop()||"";for(const C of V)if(C.startsWith("event: "))L=C.slice(7).trim();else if(C.startsWith("data: ")){try{const B=JSON.parse(C.slice(6)),M={event:L,data:B};a.current.onEvent(m,M)}catch{}L=""}}a.current.onDone(m)}catch(k){k.name!=="AbortError"&&a.current.onError(m,k.message)}finally{i(k=>{const w=new Set(k);return w.delete(m),w}),c.current.delete(m)}},[]),d=p.useCallback(m=>{var v;(v=c.current.get(m))==null||v.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 AC={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function MC(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"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function LC(t){if(t==="unit"||t==="integration")return t}function zC(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 Vy=p.createContext(null);function _n(){const t=p.useContext(Vy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function DC({plugin:t,skill:a,origin:s,children:i}){const c=s==="installed",[u,d]=p.useReducer(MC,{...AC,plugin:t,skill:a}),h=p.useRef(new Set),x=p.useRef(new Set),m=p.useRef(new Map),v=p.useCallback((le,he)=>{let pe=m.current.get(le);pe||(pe={assertions:[]},m.current.set(le,pe)),zC(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:le,result:{...pe,assertions:[...pe.assertions]}})},[]),y=p.useCallback(le=>{if(x.current.has(le))return;x.current.add(le);const he=m.current.get(le)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:le,result:{...he,assertions:[...he.assertions]}}),h.current.has(le)&&(h.current.delete(le),h.current.size===0&&Se.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=p.useCallback((le,he)=>{x.current.has(le)||(x.current.add(le),d({type:"CASE_RUN_ERROR",caseId:le,error:he}),h.current.has(le)&&(h.current.delete(le),h.current.size===0&&Se.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:k,stopAll:w}=RC({onEvent:v,onDone:y,onError:b});p.useEffect(()=>()=>{w()},[w]);const E=p.useCallback(async()=>{try{const le=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!le.ok){if(le.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await le.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,a]);p.useEffect(()=>{let le=!1;async function he(){try{const[pe,xe,je]=await Promise.allSettled([Se.getSkillDetail(t,a),Se.getEvals(t,a),Se.getLatestBenchmark(t,a)]);if(le)return;let Be=null,Ie=null;if(xe.status==="fulfilled")Be=xe.value;else{const Nt=xe.reason;Ie=(Nt==null?void 0:Nt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Ie,benchmark:je.status==="fulfilled"?je.value:null})}catch(pe){le||d({type:"SET_ERROR",error:pe.message})}}return he(),E(),()=>{le=!0}},[t,a,E]);const T=p.useCallback(async()=>{if(!c)try{await Se.applyImprovement(t,a,u.skillContent),d({type:"CONTENT_SAVED"})}catch(le){d({type:"SET_ERROR",error:le.message})}},[c,t,a,u.skillContent]),N=p.useCallback(async le=>{if(!c)try{const he=await Se.saveEvals(t,a,le);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,a]),L=p.useCallback((le,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(le);if((pe==null?void 0:pe.status)!=="running")if(m.current.delete(le),x.current.delete(le),d({type:"CASE_RUN_START",caseId:le,mode:he}),he==="comparison"){const xe=`/api/skills/${t}/${a}/compare`;S(le,xe,{eval_ids:[le]})}else{const xe=`/api/skills/${t}/${a}/benchmark/case/${le}`;S(le,xe,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),_=p.useCallback((le="benchmark")=>{var xe;if(c)return;const he=((xe=u.evals)==null?void 0:xe.evals)??[];if(he.length===0)return;const pe=he.map(je=>je.id);for(const je of pe)m.current.delete(je),x.current.delete(je);d({type:"BULK_RUN_START",caseIds:pe,mode:le}),h.current=new Set(pe);for(const je of pe)if(le==="comparison")S(je,`/api/skills/${t}/${a}/compare`,{eval_ids:[je]});else{const Be=`/api/skills/${t}/${a}/benchmark/case/${je}`;S(je,Be,le==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),D=p.useCallback(le=>{k(le),d({type:"CASE_RUN_CANCEL",caseId:le}),h.current.delete(le),x.current.add(le)},[k]),V=p.useCallback(()=>{w(),d({type:"CANCEL_ALL"}),h.current.clear()},[w]),C=p.useCallback(async(le,he)=>{d({type:"OPEN_IMPROVE",evalId:le})},[]),B=p.useCallback(async(le,he)=>{try{await Se.applyImprovement(t,a,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),L(le,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,a,L]),M=Id(),$=p.useRef(null),U=p.useRef(0);p.useEffect(()=>{const le=M.events;for(let he=U.current;he<le.length;he++){const pe=le[he],xe=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const je=xe.improved,Be=xe.reasoning,Ie=xe.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Be,evalChanges:Ie})}if(pe.event==="error"){const je=xe;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}U.current=le.length},[M.events]),p.useEffect(()=>{M.error&&d({type:"AI_EDIT_ERROR",message:M.error})},[M.error]),p.useEffect(()=>()=>{M.stop()},[M.stop]);const q=p.useCallback(async(le,he,pe)=>{c||(U.current=0,d({type:"AI_EDIT_LOADING"}),$.current=M.stop,M.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:le,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:he,model:pe}))},[c,t,a,u.skillContent,u.evals,M]),X=p.useCallback(()=>{M.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[M]),ee=p.useCallback(async()=>{const le=u.aiEditResult;if(le!=null&&le.improved)try{if(await Se.applyImprovement(t,a,le.improved),d({type:"SET_CONTENT",content:le.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Ha(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),xe=u.evals??{skill_name:a,evals:[]},je=pe(xe,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Se.saveEvals(t,a,je);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:je}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:he.message})}},[t,a,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),H=p.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),A=p.useCallback(le=>{d({type:"TOGGLE_EVAL_CHANGE",index:le})},[]),I=p.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),G=p.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),O=p.useCallback(async()=>{const le=u.aiEditEvalsRetry;if(le)try{const he=await Se.saveEvals(t,a,le);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,a,u.aiEditEvalsRetry]),ne=p.useCallback(async()=>{try{const le=await Se.getSkillDetail(t,a);d({type:"SET_CONTENT",content:le.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:z}=Pa(),W=Id(),re=p.useRef(0);p.useEffect(()=>{const le=W.events;for(let he=re.current;he<le.length;he++){const pe=le[he],xe=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const je=xe;Se.saveEvals(t,a,je).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}pe.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:xe})}re.current=le.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 Y=p.useCallback(async le=>{if(c)return;re.current=0,d({type:"GENERATE_EVALS_START"});const he={};z!=null&&z.provider&&(he.provider=z.provider),z!=null&&z.model&&(he.model=z.model);const pe=LC(le==null?void 0:le.testType);pe&&(he.testType=pe),W.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,a,W,z]),ce=Id(),se=p.useRef(0);p.useEffect(()=>()=>{ce.stop()},[ce.stop]),p.useEffect(()=>{const le=ce.events;for(let he=se.current;he<le.length;he++){const pe=le[he];if(pe.event==="classifying"){const xe=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:xe.index,total:xe.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){be.current&&(clearTimeout(be.current),be.current=null);const xe=pe.data;if(xe.error)d({type:"ACTIVATION_ERROR",error:xe.error});else{d({type:"ACTIVATION_DONE",summary:xe});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(z==null?void 0:z.model)||"unknown",provider:(z==null?void 0:z.provider)||"unknown",promptCount:xe.total,summary:{precision:xe.precision,recall:xe.recall,reliability:xe.reliability,tp:xe.tp,tn:xe.tn,fp:xe.fp,fn:xe.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...u.activationHistory??[]]})}}}se.current=le.length},[ce.events,z,u.activationHistory]),p.useEffect(()=>{ce.error&&(be.current&&(clearTimeout(be.current),be.current=null),d({type:"ACTIVATION_ERROR",error:ce.error}))},[ce.error]);const be=p.useRef(null),ie=p.useCallback(()=>{be.current&&(clearTimeout(be.current),be.current=null),ce.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[ce]),ye=p.useCallback(le=>{const pe=le.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"});se.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:le});const xe={prompts:pe};z!=null&&z.provider&&(xe.provider=z.provider),z!=null&&z.model&&(xe.model=z.model),ce.start(`/api/skills/${t}/${a}/activation-test`,xe),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>{ce.stop(),d({type:"ACTIVATION_TIMEOUT"}),be.current=null},12e4)},[t,a,ce,z]),Re=p.useCallback(async(le=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const he={count:le};z!=null&&z.provider&&(he.provider=z.provider),z!=null&&z.model&&(he.model=z.model);const pe=await fetch(`/api/skills/${t}/${a}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!pe.ok){let ut=`HTTP ${pe.status}`;try{const Et=await pe.json();Et.error&&(ut=Et.error)}catch{}throw new Error(ut)}const xe=pe.body.getReader(),je=new TextDecoder;let Be="",Ie="",Nt=[];for(;;){const{done:ut,value:Et}=await xe.read();if(ut)break;Be+=je.decode(Et,{stream:!0});const Ft=Be.split(`
|
|
70
|
+
`);Be=Ft.pop()||"";for(const qe of Ft)if(qe.startsWith("event: "))Ie=qe.slice(7).trim();else if(qe.startsWith("data: ")){try{const dt=JSON.parse(qe.slice(6));if(Ie==="done"){if(dt.error)throw new Error(dt.error);Nt=dt.prompts||[]}if(Ie==="error")throw new Error(dt.message||dt.description||"Generation failed")}catch(dt){if(!(dt instanceof SyntaxError))throw dt}Ie=""}}const Vt=Nt.map(ut=>`${ut.expected==="should_activate"?"+":"!"}${ut.prompt}`).join(`
|
|
71
|
+
`);d({type:"SET_ACTIVATION_PROMPTS",prompts:Vt}),d({type:"GENERATE_PROMPTS_DONE"})}catch(he){d({type:"GENERATE_PROMPTS_ERROR",error:he.message})}},[t,a,z]),Ae=p.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:T,saveEvals:N,runCase:L,runAll:_,cancelCase:D,cancelAll:V,improveForCase:C,applyImproveAndRerun:B,refreshSkillContent:ne,generateEvals:Y,runActivationTest:ye,cancelActivation:ie,generateActivationPrompts:Re,fetchActivationHistory:E,submitAiEdit:q,cancelAiEdit:X,applyAiEdit:ee,discardAiEdit:H,toggleEvalChange:A,selectAllEvalChanges:I,deselectAllEvalChanges:G,retryEvalsSave:O}),[u,c,T,N,L,_,D,V,C,B,ne,Y,ye,ie,Re,E,q,X,ee,H,A,I,G,O]);return r.jsx(Vy.Provider,{value:Ae,children:i})}function _C(t){if(!t)return[];const a=t.split(`
|
|
72
|
+
`),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),[v,y]=p.useState("unified"),b=p.useRef(null),S=p.useRef(null),k=p.useMemo(()=>_C(t),[t]),w=p.useMemo(()=>{const D=k.filter(C=>C.type==="add").length,V=k.filter(C=>C.type==="remove").length;return{added:D,removed:V}},[k]),E=p.useMemo(()=>{let D=0,V=0;return k.filter(C=>C.type!=="header").map(C=>C.type==="remove"?(D++,{...C,origNum:D,newNum:null}):C.type==="add"?(V++,{...C,origNum:null,newNum:V}):(D++,V++,{...C,origNum:D,newNum:V}))},[k]),T=p.useMemo(()=>{const D=[],V=[];for(const C of E)if(C.type==="remove")D.push(C);else if(C.type==="add")V.push(C);else{for(;D.length<V.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;V.length<D.length;)V.push({type:"context",content:"",origNum:null,newNum:null});D.push(C),V.push(C)}for(;D.length<V.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;V.length<D.length;)V.push({type:"context",content:"",origNum:null,newNum:null});return{left:D,right:V}},[E]),N=p.useCallback(D=>{const V=D==="left"?b.current:S.current,C=D==="left"?S.current:b.current;V&&C&&(C.scrollTop=V.scrollTop)},[]);if(!t||k.length===0)return r.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&r.jsx("button",{onClick:h,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const L=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:["+",w.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",w.removed]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>y(v==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:v==="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&&(v==="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:E.map((D,V)=>r.jsxs("tr",{style:{background:D.type==="add"?"rgba(34,197,94,0.08)":D.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:D.type==="remove"?"rgba(239,68,68,0.5)":"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==="add"?"rgba(34,197,94,0.5)":"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==="add"?"var(--green)":D.type==="remove"?"var(--red)":"transparent",borderRight:D.type==="add"?"2px solid var(--green)":D.type==="remove"?"2px solid var(--red)":"2px solid transparent"},children:D.type==="add"?"+":D.type==="remove"?"-":" "}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="add"?"var(--green)":D.type==="remove"?"var(--red)":"var(--text-secondary)"},children:D.content||""})]},V))})})}):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:()=>N("left"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:T.left.map((D,V)=>r.jsxs("tr",{style:{background:D.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:D.origNum??""}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="remove"?"var(--red)":"var(--text-secondary)"},children:D.content||""})]},V))})})}),r.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>N("right"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:T.right.map((D,V)=>r.jsxs("tr",{style:{background:D.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:D.newNum??""}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:D.type==="add"?"var(--green)":"var(--text-secondary)"},children:D.content||""})]},V))})})})]}))]});return d==="modal"?r.jsx("div",{className:L,children:r.jsx("div",{style:{width:"80%",maxWidth:900},children:_})}):_}const $d="https://verified-skill.com/submit",OC=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function BC(t){if(!t)return $d;const a=t.trim();return!a||!OC.test(a)?$d:`${$d}?repo=${encodeURIComponent(a)}`}const IC={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 $C({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 UC({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)"}},HC={VERIFIED:"Security-Scanned",CERTIFIED:"Trusted Publisher",TAINTED:"Tainted"};function Fy(t){return HC[t]??t}function PC({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 VC({tier:t,size:a}){return t==="TAINTED"?r.jsx(PC,{size:a}):t==="CERTIFIED"?r.jsx(UC,{size:a}):r.jsx($C,{size:a})}function FR({tier:t,size:a="md",isTainted:s}){const i=IC[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(VC,{tier:c,size:i.icon}),Fy(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 FC(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function GC(){const{state:t}=_n(),{plugin:a,skill:s}=t,i=lr(),{onSkillUpdated:c,updateCount:u}=i,d=p.useMemo(()=>i.state.skills.find(A=>A.plugin===a&&A.skill===s)??null,[i.state.skills,a,s]),h=`versions/${a}/${s}`,x=p.useCallback(()=>Se.getSkillVersions(a,s),[a,s]),{data:m,loading:v}=$l(h,x),[y,b]=p.useState(null),[S,k]=p.useState(null),[w,E]=p.useState(null),[T,N]=p.useState(!1),[L,_]=p.useState("idle"),[D,V]=p.useState(null),C=p.useRef(null),B=p.useRef(null),M=p.useMemo(()=>(m==null?void 0:m.find(A=>A.isInstalled))??null,[m]),$=p.useMemo(()=>(m==null?void 0:m[0])??null,[m]),U=M&&$&&M.version!==$.version,q=p.useCallback(A=>{y?!S&&A!==y?k(A):(b(A),k(null),E(null)):(b(A),E(null))},[y,S]),X=p.useCallback(async(A,I)=>{N(!0);try{const G=await Se.getVersionDiff(a,s,A,I);E(G)}catch{E(null)}finally{N(!1)}},[a,s]);p.useEffect(()=>{if(y&&S){const A=m||[],I=A.findIndex(z=>z.version===y),G=A.findIndex(z=>z.version===S),[O,ne]=I>G?[y,S]:[S,y];X(O,ne)}},[y,S,m,X]);const ee=p.useCallback(()=>{!M||!$||(b(M.version),k($.version))},[M,$]),H=p.useCallback(async()=>{_("updating"),V(null);const A=new AbortController;C.current=A;try{const I=await Se.postSkillUpdate(a,s,A.signal);if(I.ok)_("done"),c(a,s);else{const G=`Update failed (HTTP ${I.status}): ${I.body||"no response body"}`;_("error"),V(G)}}catch(I){if(I instanceof DOMException&&I.name==="AbortError")return;const G=I instanceof Error?I.message:"Network error";_("error"),V(G)}finally{C.current===A&&(C.current=null)}},[a,s,c]);if(p.useEffect(()=>()=>{var A;(A=C.current)==null||A.abort(),C.current=null},[]),v)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=BC((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:ee,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),U&&L!=="done"&&(L==="error"?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:D||"Update failed"}),r.jsx("button",{onClick:H,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):r.jsx("button",{onClick:H,disabled:L!=="idle",className:"btn btn-primary text-[11px]",children:L==="idle"?`Update to ${$==null?void 0:$.version}`:L==="updating"?"Starting update...":L==="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,")"]})]})]}),y&&!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 ",y]}),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(A=>{const I=Wg[A.certTier]||Wg.COMMUNITY,G=A.version===y||A.version===S,O=A.isInstalled;return r.jsxs("button",{onClick:()=>q(A.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:G?"var(--accent-muted)":"transparent",border:G?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:ne=>{G||(ne.currentTarget.style.background="var(--surface-1)")},onMouseLeave:ne=>{G||(ne.currentTarget.style.background="transparent")},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:O?10:8,height:O?10:8,background:O?"var(--accent)":"var(--surface-3)",border:O?"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:A.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:Fy(A.certTier)}),O&&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(A.createdAt).toLocaleDateString()})]}),A.diffSummary&&r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:FC(A.diffSummary,80)})]},A.version)})}),r.jsx("div",{ref:B,style:{height:1}})]}),T&&r.jsx("div",{className:"mt-4",children:r.jsx("div",{className:"skeleton h-48 rounded-xl"})}),w&&!T&&r.jsx("div",{className:"mt-4",children:r.jsx(Wf,{contentDiff:w.contentDiff,fromLabel:w.from,toLabel:w.to,diffSummary:w.diffSummary,renderContext:"inline",onRetry:()=>y&&S&&X(w.from,w.to)})})]})}function WC(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(`
|
|
73
|
+
`);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 k=c[d];if((typeof k!="object"||Array.isArray(k))&&(k={},c[d]=k),!S)k[b]=[];else{const w=S.match(/^\[(.+)\]$/);w?k[b]=w[1].split(",").map(E=>E.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[b]=S.replace(/^["']|["']$/g,"")}continue}const v=x.match(/^\s+-\s+(.+)$/);if(v&&d){h=!1;const b=c[d];Array.isArray(b)?b.push(v[1].trim().replace(/^["']|["']$/g,"")):c[d]=[v[1].trim().replace(/^["']|["']$/g,"")];continue}const y=x.match(/^([\w-]+):\s*(.*)$/);if(y){d=y[1];const b=y[2].trim();if(h=!1,!b){c[d]={},h=!0;continue}const S=b.match(/^\[(.+)\]$/);if(S){c[d]=S[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:i}}function lc(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=qC(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 qC(t){const a=t.split(`
|
|
74
|
+
`),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 v of m)x+=`<td ${h}>${v}</td>`;x+="</tr>"}x+="</tbody></table>",s.push(x)}else s.push(a[i]),i++;return s.join(`
|
|
75
|
+
`)}function qg(t){return t.split("|").map(a=>a.trim()).filter(a=>a.length>0)}function sc(t,a){const s=t.split(`
|
|
76
|
+
`),i=a.split(`
|
|
77
|
+
`);if(s.length>1e3||i.length>1e3)return[...s.map(v=>({type:"unchanged",content:v}))];const c=s.length,u=i.length,d=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let v=1;v<=c;v++)for(let y=1;y<=u;y++)s[v-1]===i[y-1]?d[v][y]=d[v-1][y-1]+1:d[v][y]=Math.max(d[v-1][y],d[v][y-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 YC(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 si({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:[YC(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 ic({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 KC({plugin:t,skill:a,skillContent:s,onApplied:i}){const[c,u]=p.useState("closed"),{config:d}=Pa(),[h,x]=p.useState("claude-cli"),[m,v]=p.useState("opus"),[y,b]=p.useState([]),[S,k]=p.useState(""),[w,E]=p.useState(""),[T,N]=p.useState(null),[L,_]=p.useState(null),[D,V]=p.useState([]),[C,B]=p.useState(!1),M=p.useRef(null);p.useEffect(()=>{if(!d)return;d.providers.find(I=>I.id==="claude-cli"&&I.available)&&(x("claude-cli"),v("opus"))},[d]),p.useEffect(()=>()=>{var A;(A=M.current)==null||A.abort()},[]);function $(){return d==null?void 0:d.providers.find(A=>A.id===h&&A.available)}const U=p.useCallback(()=>{var A;(A=M.current)==null||A.abort(),u("open")},[]);async function q(){u("loading"),N(null),_(null),V([]);const A=new AbortController;M.current=A;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:A.signal});if(!I.ok||!I.body){let W=`HTTP ${I.status}`;try{const re=await I.json();re.error&&(W=re.error)}catch{}throw new Error(W)}const G=I.body.getReader(),O=new TextDecoder;let ne="",z="";for(;;){const{done:W,value:re}=await G.read();if(W)break;ne+=O.decode(re,{stream:!0});const Y=ne.split(`
|
|
78
|
+
`);ne=Y.pop()||"";for(const ce of Y)if(ce.startsWith("event: "))z=ce.slice(7).trim();else if(ce.startsWith("data: ")){try{const se=JSON.parse(ce.slice(6));z==="progress"?V(be=>[...be,{phase:se.phase,message:se.message,timestamp:Date.now()}]):z==="done"||z==="complete"?(k(se.improved),E(se.reasoning||""),b(sc(se.original||s,se.improved)),u("diff_shown")):z==="error"&&(N(se.message||se.description||"Unknown error"),se.category&&_(se),u("open"))}catch{}z=""}}}catch(I){I.name!=="AbortError"&&(N(I.message),u("open"))}finally{M.current=null}}async function X(){B(!0);try{await Se.applyImprovement(t,a,S),i(S),u("closed")}catch(A){N(A.message)}finally{B(!1)}}function ee(){u("closed"),b([]),k(""),E(""),N(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 H=$();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:ee,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:A=>{A.currentTarget.style.background="var(--surface-3)"},onMouseLeave:A=>{A.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:A=>{x(A.target.value);const I=d==null?void 0:d.providers.find(G=>G.id===A.target.value);I!=null&&I.models[0]&&v(I.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(A=>A.available).map(A=>r.jsx("option",{value:A.id,children:A.label},A.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:A=>v(A.target.value),disabled:c==="loading",children:H==null?void 0:H.models.map(A=>r.jsx("option",{value:A.id,children:A.label},A.id))})]}),c==="loading"?r.jsx("button",{onClick:U,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):r.jsx("button",{onClick:q,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&D.length>0&&r.jsx("div",{className:"mt-3",children:r.jsx(si,{entries:D,isRunning:!0})})]}),T&&r.jsx("div",{className:"mb-4",children:L?r.jsx(ic,{error:L,onRetry:q,onDismiss:()=>{N(null),_(null)}}):r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:T})}),c==="diff_shown"&&r.jsxs(r.Fragment,{children:[w&&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: "}),w]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:y.map((A,I)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:A.type==="added"?"rgba(34,197,94,0.1)":A.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:A.type==="added"?"var(--green)":A.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:A.type==="added"?"3px solid var(--green)":A.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:A.type==="added"?"+":A.type==="removed"?"-":" "}),A.content]},I))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:X,disabled:C,className:"btn btn-primary",children:C?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:ee,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"}},XC={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function QC({change:t,index:a,selected:s,onToggle:i,originalEval:c}){var y;const[u,d]=p.useState(!1),h=Kg[t.action]??Kg.add,x=XC[t.action]??"var(--border-subtle)",m=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((y=t.eval)==null?void 0:y.name)??"Unnamed",v=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:v,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(ZC,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&r.jsx(JC,{original:c,proposed:t.eval}),t.action==="remove"&&c&&r.jsx(eE,{evalCase:c})]})]})}function ZC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[r.jsx(gf,{label:"Prompt",value:t.prompt}),r.jsx(gf,{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 JC({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:["- ",vf(m.old,120)]}),r.jsxs("div",{style:{color:"var(--green)"},children:["+ ",vf(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 eE({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[r.jsx(gf,{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 gf({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:vf(a,300)})]})}function vf(t,a){return t.length>a?t.slice(0,a)+"...":t}const Xg={remove:0,modify:1,add:2};function tE({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(QC,{change:x,index:m,selected:a.get(m)??!1,onToggle:i,originalEval:x.evalId!=null?s.find(v=>v.id===x.evalId):void 0},m))})]})}function nE(){var A;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:i,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:x,retryEvalsSave:m}=_n(),{aiEditLoading:v,aiEditResult:y,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:k,aiEditEvalChanges:w,aiEditEvalSelections:E,aiEditEvalsRetry:T}=t,[N,L]=p.useState(""),{config:_}=Pa(),[D,V]=p.useState("claude-cli"),[C,B]=p.useState("opus"),M=p.useRef(null);p.useEffect(()=>{var I;(I=M.current)==null||I.focus()},[]),p.useEffect(()=>{if(!_)return;_.providers.find(G=>G.id==="claude-cli"&&G.available)&&(V("claude-cli"),B("opus"))},[_]);const $=_==null?void 0:_.providers.find(I=>I.id===D&&I.available),U=p.useCallback(()=>{const I=N.trim();!I||v||s(I,D,C)},[N,v,s,D,C]),q=p.useCallback(I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),U()),I.key==="Escape"&&(I.preventDefault(),v?u():c())},[U,v,u,c]),X=p.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),ee=y?sc(t.skillContent,y.improved):[],H=((A=t.evals)==null?void 0:A.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:[!y&&r.jsxs(r.Fragment,{children:[r.jsx("textarea",{ref:M,value:N,onChange:I=>L(I.target.value),onKeyDown:q,placeholder:"e.g., Add an error handling section...",disabled:v,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:D,onChange:I=>{V(I.target.value);const G=_==null?void 0:_.providers.find(O=>O.id===I.target.value);G!=null&&G.models[0]&&B(G.models[0].id)},disabled:v,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:C,onChange:I=>B(I.target.value),disabled:v,style:{width:"100%"},children:$==null?void 0:$.models.map(I=>r.jsx("option",{value:I.id,children:I.label},I.id))})]}),r.jsx("div",{className:"flex-1"}),v?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:!N.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),v&&k.length>0&&r.jsx("div",{className:"mt-2.5",children:r.jsx(si,{entries:k,isRunning:!0})})]}),b&&r.jsx("div",{className:"mt-3",children:S?r.jsx(ic,{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})}),y&&r.jsxs("div",{className:"animate-fade-in",children:[y.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: "}),y.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:ee.map((I,G)=>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]},G))}),r.jsx(tE,{changes:w,selections:E,currentEvals:H,onToggle:d,onSelectAll:h,onDeselectAll:x}),T&&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 rE(t,a){const[s,i]=p.useState([]),[c,u]=p.useState("SKILL.md"),[d,h]=p.useState(null),[x,m]=p.useState(!1),[v,y]=p.useState(null),[b,S]=p.useState(null),k=p.useCallback(async()=>{try{const T=await Se.getSkillFiles(t,a);i(T.files),S(null)}catch(T){i([]),S(T.message??"Unable to load skill files")}},[t,a]);p.useEffect(()=>{u("SKILL.md"),h(null),y(null),S(null),k()},[t,a,k]);const w=p.useCallback(async T=>{if(u(T),T==="SKILL.md"){h(null),y(null);return}m(!0),y(null);try{const N=await Se.getSkillFile(t,a,T);h(N)}catch(N){y(`Unable to open file: ${N.message}`),h(null)}finally{m(!1)}},[t,a]),E=p.useCallback(()=>{k()},[k]);return{files:s,activeFile:c,secondaryContent:d,loading:x,error:v,loadError:b,selectFile:w,refresh:E,isSkillMd:c==="SKILL.md"}}function aE(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function lE(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 Gy({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 Wy(){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 sE(){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 iE(){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 qy({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(Gy,{expanded:c}),r.jsx(Wy,{}),r.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>r.jsx(qy,{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(sE,{}),r.jsx("span",{style:{flex:1},children:t.name}),r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:aE(t.size)})]})}function oE({files:t,activeFile:a,onSelect:s,onRefresh:i,loadError:c}){const[u,d]=p.useState(!1),h=p.useMemo(()=>lE(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(Gy,{expanded:u}),r.jsx(Wy,{}),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(iE,{})})]}),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(qy,{node:x,depth:0,activeFile:a,onSelect:s},x.path))})]})}function Co(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function cE(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function uE(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=cE(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:lc(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 dE({file:t,loading:a,error:s,viewMode:i,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[x,m]=p.useState(i),[v,y]=p.useState(!1),[b,S]=p.useState(""),[k,w]=p.useState(!1),[E,T]=p.useState(null),N=i!==x?i:x;p.useEffect(()=>{h==null||h(v)},[v,h]);const L=p.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),y(!0))},[t]),_=p.useCallback(()=>{y(!1)},[]),D=p.useCallback(async()=>{if(!(!c||!u||!t)){w(!0);try{await Se.saveSkillFile(c,u,t.path,b),T("Saved"),y(!1),d==null||d(),setTimeout(()=>T(null),2e3)}catch(B){T(`Save failed: ${B.message}`),setTimeout(()=>T(null),3e3)}finally{w(!1)}}},[c,u,t,b,d]);if(p.useEffect(()=>{if(!v)return;const B=M=>{(M.ctrlKey||M.metaKey)&&M.key==="s"&&(M.preventDefault(),D())};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[v,D]),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 (",Co(t.size),") — cannot be displayed"]});const V=t.content??"",C=uE(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 ",Co(512*1024)," — ",Co(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:[(C==="md"||C==="json")&&["raw","split","preview"].map(B=>r.jsx("button",{onClick:()=>m(B),style:{padding:"2px 8px",fontSize:11,background:N===B?"var(--accent-muted)":"none",color:N===B?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:B},B)),r.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[Co(t.size),c&&u&&!t.binary&&!v&&r.jsx("button",{onClick:L,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),v&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:D,disabled:k,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),r.jsx("button",{onClick:_,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),E&&r.jsx("div",{style:{padding:"4px 12px",background:E.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:E.startsWith("Save failed")?"var(--red)":"var(--green)"},children:E}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:v?r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[r.jsx("textarea",{value:b,onChange:B=>S(B.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:D,disabled:k,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),r.jsx("button",{onClick:_,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):N==="split"&&C!=="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:V})}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:C==="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(V)}}):r.jsx(Zg,{content:V,fileType:C})})]}):N==="preview"&&C!=="other"?C==="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(V)}}):r.jsx(Zg,{content:V,fileType:C}):r.jsx(Qg,{content:V})})]})}const fE=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/,pE=/^https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/;function mE(t){const a=t.trim();if(!a)throw new Error("normalizeRemoteUrl: empty input");let s=a.match(fE);if(s)return`https://github.com/${s[1]}/${s[2]}`;if(s=a.match(pE),s)return`https://github.com/${s[1]}/${s[2]}`;throw new Error(`normalizeRemoteUrl: unrecognized remote URL: ${t}`)}function Yy(t){const a=mE(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 hE({remoteUrl:t,fileCount:a,provider:s,model:i,onClose:c,defaultMode:u="manual"}){const[d,h]=p.useState(u),[x,m]=p.useState(""),[v,y]=p.useState(!1),[b,S]=p.useState(!1),[k,w]=p.useState(null),[E,T]=p.useState(null),N=p.useCallback(async()=>{y(!0),w(null);try{const $=await Se.gitCommitMessage({provider:s,model:i});m($.message)}catch($){const U=$ instanceof Error?$.message:String($);w(U)}finally{y(!1)}},[s,i]);p.useEffect(()=>{u==="ai"&&!x&&N()},[]);const L=p.useCallback(()=>{h("ai"),T(null),x.trim()||N()},[x,N]),_=p.useCallback(()=>{h("manual"),w(null)},[]),D=p.useCallback(async()=>{const $=x.trim();if(!(!$||b)){S(!0),T(null);try{const U=await Se.gitPublish({commitMessage:$}),q=U.remoteUrl??t,X=Yy(q);window.open(X,"_blank","noopener,noreferrer");const ee=(U.commitSha??"").slice(0,7),H=U.branch??"";ev(`Opening verified-skill.com — ${ee} on ${H}`,"info"),c()}catch(U){const q=U instanceof Error?U.message:String(U),X=q.length>200?q.slice(0,200)+"…":q;T(X),ev(`Publish failed: ${X}`,"error")}finally{S(!1)}}},[x,b,t,c]),V=x.trim().length>0&&!b&&!v,C={fontSize:10,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)",marginBottom:6,display:"block"},B={flex:1,height:30,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:11,fontFamily:"var(--font-mono, monospace)",background:"transparent",color:"var(--text-secondary)",border:"none",cursor:"pointer",transition:"background 120ms ease, color 120ms ease"},M={...B,background:"var(--bg-subtle)",color:"var(--text-primary)",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:"var(--bg-elevated, #1a1a1a)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:24,boxShadow:"0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04)",color:"var(--text-primary)",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:14,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)",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:"var(--text-tertiary)",fontSize:18,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:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",marginBottom:18},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--color-accent)",fontFamily:"monospace"},children:"▮"}),r.jsxs("span",{children:[a," file",a===1?"":"s"," changed"]})]}),r.jsx("div",{style:{height:1,background:"var(--border-subtle)",margin:"0 -24px 18px"}}),r.jsx("span",{style:C,children:"Mode"}),r.jsxs("div",{role:"tablist","aria-label":"Commit message mode","data-testid":"publish-mode-toggle",style:{display:"flex",border:"1px solid var(--border-subtle)",borderRadius:4,overflow:"hidden",marginBottom:16},children:[r.jsx("button",{type:"button",role:"tab","aria-selected":d==="manual","data-testid":"publish-mode-manual",onClick:_,disabled:b,style:d==="manual"?M:B,children:"Write yourself"}),r.jsx("div",{style:{width:1,background:"var(--border-subtle)"}}),r.jsx("button",{type:"button",role:"tab","aria-selected":d==="ai","data-testid":"publish-mode-ai",onClick:L,disabled:b,style:d==="ai"?M:B,children:v&&d==="ai"?"Generating…":"Generate with AI"})]}),r.jsx("label",{htmlFor:"commit-message",style:C,children:"Commit message"}),r.jsx("textarea",{id:"commit-message",value:x,onChange:$=>m($.target.value),rows:5,disabled:v||b,placeholder:v?"Generating with AI…":d==="ai"?"Click Generate to draft a message":"Type your commit message…",style:{width:"100%",background:"var(--bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"10px 12px",fontFamily:"var(--font-mono, monospace)",fontSize:12,lineHeight:1.6,color:"var(--text-primary)",resize:"vertical",outline:"none"}}),k&&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."})," ",k," ",r.jsx("button",{type:"button",onClick:N,disabled:v,style:{background:"none",border:"none",color:"var(--color-accent)",cursor:v?"not-allowed":"pointer",fontFamily:"inherit",fontSize:"inherit",textDecoration:"underline",padding:0},children:"Retry"})]}),E&&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."})," ",E]}),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:N,disabled:v||b,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:v?"Generating…":"Regenerate"})}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("button",{type:"button","aria-label":"Cancel",onClick:c,disabled:b,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:"Cancel"}),r.jsx("button",{type:"button","aria-label":"Commit & Push",onClick:D,disabled:!V,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?"Publishing…":"Commit & Push"})]})]})]})}),r.jsx("style",{children:`
|
|
79
|
+
@keyframes publishDrawerBackdropIn { from { opacity: 0 } to { opacity: 1 } }
|
|
80
|
+
@keyframes publishDrawerIn {
|
|
81
|
+
from { opacity: 0; transform: translateY(4px) }
|
|
82
|
+
to { opacity: 1; transform: translateY(0) }
|
|
83
|
+
}
|
|
84
|
+
@media (prefers-reduced-motion: reduce) {
|
|
85
|
+
[role="dialog"][aria-label="Publish"],
|
|
86
|
+
[role="dialog"][aria-label="Publish"] + * { animation: none !important }
|
|
87
|
+
}
|
|
88
|
+
`})]})}function tv(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Ky({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 y=!1,b=0;try{const N=await Se.gitDiff();y=!!N.hasChanges,b=N.fileCount??0}catch{}if(y){x(b),d(!0);return}const S=await Se.gitPublish(),k=S.remoteUrl??t,w=Yy(k);window.open(w,"_blank","noopener,noreferrer");const E=(S.commitSha??"").slice(0,7),T=S.branch??"";tv(`Opening verified-skill.com — ${E} on ${T}`,"info")}catch(y){const b=y instanceof Error?y.message:String(y),S=b.length>200?b.slice(0,200)+"…":b;tv(`Publish failed: ${S}`,"error")}finally{c(!1)}}},[i,u,t]),v=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(hE,{remoteUrl:t,fileCount:h,provider:a,model:s,onClose:v})]})}const xE={hasRemote:!1,remoteUrl:null,branch:null,loading:!0,error:null};function gE(){const[t,a]=p.useState(xE);return p.useEffect(()=>{let s=!1;return Se.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 vE=/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function yf(t){if(typeof t!="string")return null;const a=t.trim().match(vE);return a?{major:Number(a[1]),minor:Number(a[2]),patch:Number(a[3])}:null}function Eo(t,a){const s=yf(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 yE(t,a){const s=yf(a);if(!s)return{valid:!1,reason:`Invalid semver: ${JSON.stringify(a)}`};if(t==null)return{valid:!0};const i=yf(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 Xy=/^---\n([\s\S]*?)\n---(?:\n|$)/,bf=/^version:\s*["']?([^"'\n]+?)["']?\s*$/m;function No(t){const a=t.match(Xy);if(!a)return null;const s=a[1].match(bf);return s&&s[1].trim()||null}function bE(t,a){const s=`version: "${a}"`,i=t.match(Xy);if(!i)return`---
|
|
89
|
+
${s}
|
|
90
|
+
---
|
|
91
|
+
${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;bf.test(c)?x=c.replace(bf,s):x=`${s}
|
|
92
|
+
${c}`;const m=i[0].endsWith(`---
|
|
93
|
+
`)?`---
|
|
94
|
+
`:"---";return`${h}---
|
|
95
|
+
${x}
|
|
96
|
+
${m}${d}`}function Ud(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function jE({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 SE({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 kE({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 wE({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 Hd({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 CE(){const{state:t,dispatch:a,saveContent:s,isReadOnly:i}=_n(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:x,aiEditOpen:m}=t,[v,y]=p.useState("split"),[b,S]=p.useState(!1),k=p.useRef(null),[w,E]=p.useState(!1),[T,N]=p.useState(""),[L,_]=p.useState(!1),[D,V]=p.useState(null),[C,B]=p.useState([]),[M,$]=p.useState([]),[U,q]=p.useState(null),X=p.useRef(null),{config:ee}=Pa(),H=gE(),{files:A,activeFile:I,secondaryContent:G,loading:O,error:ne,loadError:z,selectFile:W,refresh:re,isSkillMd:Y}=rE(c??"",u??""),[ce,se]=p.useState(!1),be=p.useCallback(ge=>{ce&&!window.confirm("You have unsaved changes. Discard?")||W(ge)},[ce,W]);p.useEffect(()=>()=>{var ge;(ge=X.current)==null||ge.abort()},[]);const{metadata:ie,body:ye}=WC(d),Re=ie["allowed-tools"],Ae=Array.isArray(Re)?Re:typeof Re=="string"?[Re]:[],le=ie.name,he=ie.description,pe=ie.metadata,xe=typeof pe=="object"&&!Array.isArray(pe)?pe:null,je=ie.version||(xe==null?void 0:xe.version),Be=ie.tags||(xe==null?void 0:xe.tags),Ie=Array.isArray(Be)?Be:typeof Be=="string"?Be.split(",").map(ge=>ge.trim()).filter(Boolean):[],Nt=new Set(["name","description","metadata","allowed-tools","version","tags"]),Vt=Object.entries(ie).filter(([ge])=>!Nt.has(ge)),ut=p.useCallback(async()=>{const ge=No(t.savedContent),tt=No(d);if(tt!==null){const ft=yE(ge,tt);if(!ft.valid){Ud(`Save blocked: ${ft.reason??"invalid version transition"}`,"error");return}}S(!0),await s(),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]),Et=p.useCallback(ge=>{const tt=No(d)??"1.0.0";let ft;try{ft=Eo(tt,ge)}catch(Tt){const Ze=Tt instanceof Error?Tt.message:String(Tt);Ud(`Bump failed: ${Ze}`,"error");return}const Lt=bE(d,ft);a({type:"SET_CONTENT",content:Lt}),Ud(`Bumped to v${ft} (${ge}). Click Save to commit.`,"info")},[d,a]),Ft=p.useCallback(ge=>{(ge.ctrlKey||ge.metaKey)&&ge.key==="s"&&(ge.preventDefault(),ge.stopPropagation(),h&&ut()),(ge.ctrlKey||ge.metaKey)&&ge.key==="k"&&(ge.preventDefault(),ge.stopPropagation(),a({type:m?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,ut,m,a]),qe=p.useCallback(async()=>{var tt,ft;if(!T.trim())return;(tt=X.current)==null||tt.abort();const ge=new AbortController;X.current=ge,_(!0),q(null),$([]),V(null),B([]);try{const Lt=(ee==null?void 0:ee.provider)||"claude-cli",Tt=(ee==null?void 0:ee.model)||"sonnet",Ze=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:T,provider:Lt,model:Tt}),signal:ge.signal});if(!Ze.ok||!Ze.body){let Qn=`HTTP ${Ze.status}`;try{const gn=await Ze.json();gn.error&&(Qn=gn.error)}catch{}throw new Error(Qn)}const xn=Ze.body.getReader(),Ot=new TextDecoder;let un="",dn="";for(;;){const{done:Qn,value:gn}=await xn.read();if(Qn)break;un+=Ot.decode(gn,{stream:!0});const Zn=un.split(`
|
|
97
|
+
`);un=Zn.pop()||"";for(const On of Zn)if(On.startsWith("event: "))dn=On.slice(7).trim();else if(On.startsWith("data: ")){try{const vt=JSON.parse(On.slice(6));if(dn==="progress")$(De=>[...De,{phase:vt.phase,message:vt.message,timestamp:Date.now()}]);else if(dn==="done"||dn==="complete"){const De=["---"];vt.name&&De.push(`name: ${vt.name}`),vt.description&&De.push(`description: "${vt.description.replace(/"/g,'\\"')}"`),vt.model&&De.push(`model: ${vt.model}`),(ft=vt.allowedTools)!=null&&ft.trim()&&De.push(`allowed-tools: ${vt.allowedTools.trim()}`),De.push("---","",vt.body||"");const We=De.join(`
|
|
98
|
+
`);V(We),B(sc(d,We)),_(!1)}else dn==="error"&&(q(vt.message||vt.description||"Generation failed"),_(!1))}catch{}dn=""}}}catch(Lt){Lt.name!=="AbortError"&&q(Lt.message)}finally{_(!1),X.current=null}},[T,ee,d]),dt=p.useCallback(()=>{D&&a({type:"SET_CONTENT",content:D}),E(!1),V(null),B([]),N(""),$([])},[D,a]),Jt=p.useCallback(()=>{E(!1),V(null),B([]),N(""),$([]),q(null)},[]),Kt=p.useCallback(()=>{var ge;w?((ge=X.current)==null||ge.abort(),Jt()):(m&&a({type:"CLOSE_AI_EDIT"}),E(!0))},[w,m,a,Jt]),cn=[{mode:"raw",icon:r.jsx(jE,{}),label:"Editor"},{mode:"split",icon:r.jsx(SE,{}),label:"Split"},{mode:"preview",icon:r.jsx(kE,{}),label:"Preview"}];return r.jsxs("div",{className:"flex flex-col h-full",onKeyDown:Ft,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:cn.map(({mode:ge,icon:tt,label:ft})=>r.jsxs("button",{onClick:()=>y(ge),title:ft,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:v===ge?"var(--surface-4)":"transparent",color:v===ge?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:v===ge?600:400,border:"none",cursor:"pointer"},children:[tt,r.jsx("span",{style:{letterSpacing:"0.01em"},children:ft})]},ge))}),Y?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"}):(w&&Jt(),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(wE,{size:13}),r.jsx("span",{children:"AI Edit"})]}),r.jsxs("button",{onClick:Kt,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:w?600:400,border:"none",cursor:"pointer",color:w?"var(--purple)":"var(--text-tertiary)",background:w?"var(--purple-muted)":"transparent"},children:[r.jsx(Hd,{size:13}),r.jsx("span",{children:"Regenerate"})]}),r.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),!i&&(()=>{const ge=No(d)??"1.0.0";let tt=ge,ft=ge,Lt=ge;try{tt=Eo(ge,"patch"),ft=Eo(ge,"minor"),Lt=Eo(ge,"major")}catch{}const Tt={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:()=>Et("patch"),title:`Bump patch: ${ge} → ${tt}`,"aria-label":"Bump patch version",className:"btn btn-ghost text-[11px]",style:Tt,children:"+patch"}),r.jsx("button",{type:"button",onClick:()=>Et("minor"),title:`Bump minor: ${ge} → ${ft}`,"aria-label":"Bump minor version",className:"btn btn-ghost text-[11px]",style:Tt,children:"+minor"}),r.jsx("button",{type:"button",onClick:()=>Et("major"),title:`Bump major: ${ge} → ${Lt}`,"aria-label":"Bump major version",className:"btn btn-ghost text-[11px]",style:Tt,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:ut,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"}),H.hasRemote&&H.remoteUrl&&r.jsx(Ky,{remoteUrl:H.remoteUrl,provider:ee==null?void 0:ee.provider,model:ee==null?void 0:ee.model})]}):null]}),c&&u&&r.jsx(oE,{files:A,activeFile:I,onSelect:be,onRefresh:re,loadError:z}),!Y&&r.jsx(dE,{file:G,loading:O,error:ne,viewMode:v,plugin:c??void 0,skill:u??void 0,onSaved:()=>{W(I),re()},onDirtyChange:se}),Y&&r.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:v==="raw"||v==="preview"?"1fr":"1fr 1fr"},children:[v!=="preview"&&r.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:v==="split"?"1px solid var(--border-subtle)":"none"},children:r.jsx("textarea",{ref:k,value:d,onChange:ge=>{i||a({type:"SET_CONTENT",content:ge.target.value})},onKeyDown:Ft,spellCheck:!1,readOnly:i,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}})}),v!=="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||je||he)&&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}),je&&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",je]})]}),he&&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:he})]}),Ie.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:Ie.map(ge=>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:ge},ge))}),Ae.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"}),Ae.map(ge=>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:ge},ge))]})}),Vt.length>0&&r.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:Vt.map(([ge,tt],ft)=>{const Lt=Array.isArray(tt)?tt.join(", "):typeof tt=="object"?Object.entries(tt).map(([Tt,Ze])=>`${Tt}: ${Array.isArray(Ze)?Ze.join(", "):Ze}`).join(" | "):tt;return r.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:ft>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:ge}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Lt})]},ge)})}),(le||he||Ie.length>0||Ae.length>0||Vt.length>0)&&ye&&r.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ye&&r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:lc(ye)}})]})})]}),Y&&m&&r.jsx(nE,{}),Y&&w&&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:[!D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Hd,{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:T,onChange:ge=>N(ge.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:L,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:L?.5:1},onKeyDown:ge=>{ge.key==="Enter"&&(ge.ctrlKey||ge.metaKey)&&T.trim()&&!L&&(ge.preventDefault(),qe())}})}),r.jsxs("div",{className:"flex items-center gap-2",children:[L?r.jsx("button",{onClick:()=>{var ge;(ge=X.current)==null||ge.abort(),_(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):r.jsx("button",{onClick:qe,disabled:!T.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),r.jsx("button",{onClick:Jt,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),L&&M.length>0&&r.jsx("div",{className:"mt-2",children:r.jsx(si,{entries:M,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:qe,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Hd,{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:C.map((ge,tt)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:ge.type==="added"?"var(--green-muted)":ge.type==="removed"?"var(--red-muted)":"transparent",color:ge.type==="added"?"var(--green)":ge.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:ge.type==="added"?"3px solid var(--green)":ge.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:ge.type==="added"?"+":ge.type==="removed"?"-":" "}),ge.content]},tt))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:dt,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:Jt,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Y&&x!==null&&c&&u&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(KC,{plugin:c,skill:u,skillContent:d,onApplied:ge=>{a({type:"SET_CONTENT",content:ge}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})})]})}function Rl(t){return t.testType==="integration"?"integration":"unit"}function Ol(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function Qy(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 Zy(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const EE=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 Jy({entries:t}){const a=t.filter(y=>EE.has(y.type)).slice().reverse(),s=a.map((y,b,S)=>({rate:y.pass_rate,idx:b,total:S.length})).filter((y,b)=>{const S=a[b].type;return S==="benchmark"||S==="comparison"}),i=a.flatMap((y,b)=>y.type==="baseline"?[{rate:y.pass_rate,idx:b,total:a.length}]:y.type==="comparison"&&y.baselinePassRate!=null?[{rate:y.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],v=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"}),v&&r.jsx("circle",{cx:parseFloat(v.split(",")[0]),cy:parseFloat(v.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 eb(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(v=>v.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(y=>y.criterion).join(", ")}.`:"",v=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return v.length===0&&v.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${i.toFixed(2)}): evaluation did not meet expectations.${m}`,recommendations:v}}if(t==="INEFFECTIVE"){if(i<.2){const v=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.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:v}}const m=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.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(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`),...u.map(v=>`Improve "${v.criterion}" (score: ${v.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(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.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 tb={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function NE(t){return Object.hasOwn(tb,t)}function TE(t){return NE(t)?tb[t]:t}function RE(){const{state:t}=_n(),{plugin:a,skill:s}=t,[i,c]=p.useState([]),[u,d]=p.useState([]),[h,x]=p.useState(!0),[m,v]=p.useState(null),[y,b]=p.useState(new Set),[S,k]=p.useState({}),[w,E]=p.useState(null),[T,N]=p.useState(""),[L,_]=p.useState(!1),[D,V]=p.useState(""),[C,B]=p.useState(""),M=p.useCallback(async()=>{x(!0),v(null);try{const[H,A]=await Promise.all([Se.getCredentials(a,s),Se.getParams(a,s)]);c(H.credentials),d(A.params)}catch(H){v(H instanceof Error?H.message:"Failed to load parameters"),c([]),d([])}finally{x(!1)}},[a,s]);p.useEffect(()=>{M()},[M]);const $=p.useCallback(async(H,A)=>{_(!0),v(null);try{await Se.setCredential(a,s,H,A),E(null),N(""),await M()}catch(I){v(I instanceof Error?I.message:`Failed to save ${H}`)}finally{_(!1)}},[a,s,M]),U=p.useCallback(async()=>{const H=D.trim().toUpperCase(),A=C.trim();if(!(!H||!A)){_(!0),v(null);try{await Se.setCredential(a,s,H,A),V(""),B(""),await M()}catch(I){v(I instanceof Error?I.message:`Failed to add ${H}`)}finally{_(!1)}}},[a,s,D,C,M]),q=p.useCallback(async H=>{if(y.has(H)){b(A=>{const I=new Set(A);return I.delete(H),I}),k(A=>{const I={...A};return delete I[H],I});return}try{const I=(await Se.getParamsRevealed(a,s,H)).params.find(G=>G.name===H);I!=null&&I.value&&(k(G=>({...G,[H]:I.value})),b(G=>new Set(G).add(H)))}catch{}},[a,s,y]),X=new Set(i.map(H=>H.name)),ee=[...i.map(H=>{const A=u.find(I=>I.name===H.name);return{name:H.name,status:H.status,maskedValue:(A==null?void 0:A.maskedValue)??""}}),...u.filter(H=>!X.has(H.name)).map(H=>({name:H.name,status:H.status,maskedValue:H.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&&ee.length===0&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&ee.length===0&&!m&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),ee.map(H=>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:H.name}),r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:H.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:H.status==="ready"?"var(--green)":"var(--red)"},children:H.status}),(H.maskedValue||H.status==="ready")&&r.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[y.has(H.name)?S[H.name]??H.maskedValue:H.maskedValue||"***",r.jsx("button",{onClick:()=>q(H.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${y.has(H.name)?"Hide":"Reveal"} value for ${H.name}`,children:y.has(H.name)?"hide":"show"})]}),w===H.name?r.jsxs("div",{className:"flex gap-1",children:[r.jsx("input",{value:T,onChange:A=>N(A.target.value),onKeyDown:A=>{A.key==="Enter"&&T.trim()&&$(H.name,T)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${H.name}`,autoFocus:!0}),r.jsx("button",{onClick:()=>$(H.name,T),disabled:L||!T.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),r.jsx("button",{onClick:()=>{E(null),N("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):r.jsx("button",{onClick:()=>{E(H.name),N("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},H.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:D,onChange:H=>V(H.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),r.jsx("input",{value:C,onChange:H=>B(H.target.value),onKeyDown:H=>{H.key==="Enter"&&D.trim()&&C.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:L||!D.trim()||!C.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:L?"not-allowed":"pointer"},children:"Add"})]})]})]})}const Is="This is an installed copy (read-only). Open the source skill to edit.";function AE(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),Se.getCaseHistory(t,a,s).then(v=>c(v)).catch(()=>c([])).finally(()=>d(!1)))},[t,a,s]);const x=p.useCallback(()=>{d(!0),h.current="",Se.getCaseHistory(t,a,s).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1))},[t,a,s]);return{entries:i,loading:u,refetch:x}}function ME(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(v=>v.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(v=>v.id===t),m=h.assertions.find(v=>v.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(v=>v.id===t);m!=null&&m.pass&&(i.regression=!0)}return i}function LE(){var G;const{state:t,dispatch:a,saveEvals:s,runCase:i,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:x}=_n(),{evals:m,evalsError:v,selectedCaseId:y,inlineResults:b,caseRunStates:S,generateEvalsLoading:k,generateEvalsProgress:w,generateEvalsError:E}=t,T=p.useMemo(()=>{for(const O of S.values())if(O.status==="running"||O.status==="queued")return!0;return!1},[S]),[N,L]=p.useState(!1),[_,D]=p.useState("all"),V={skill_name:t.skill,evals:[]},C=m??V,B=C.evals,M=p.useMemo(()=>_==="all"?B:B.filter(O=>Rl(O)===_),[_,B]),$=M.find(O=>O.id===y)??null;p.useEffect(()=>{y!==null&&!M.find(O=>O.id===y)&&a({type:"SELECT_CASE",caseId:M.length>0?M[0].id:null})},[M,y,a]);const[U,q]=p.useState([]),X=p.useMemo(()=>B.some(O=>Rl(O)==="integration"),[B]);p.useEffect(()=>{X&&Se.getCredentials(t.plugin,t.skill).then(O=>q(O.credentials)).catch(()=>q([]))},[t.plugin,t.skill,X]);const ee=p.useMemo(()=>new Set(U.filter(O=>O.status==="missing").map(O=>O.name)),[U]),[H,A]=p.useState(!1),I=p.useCallback(O=>{A(!1),h(O?{testType:O}:void 0)},[h]);return!m||B.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:v?"var(--red-muted)":"var(--accent-muted)"},children:v?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:v?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:v}),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:()=>L(!0),disabled:x,title:x?Is: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:k||x,title:x?Is:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:k?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),r.jsx("button",{onClick:()=>A(!H),disabled:k||x,title:x?Is: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"})})})]}),H&&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:O=>{O.currentTarget.style.background="var(--surface-2)"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),k&&w.length>0&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(si,{entries:w,isRunning:!0})}),E&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ic,{error:E,onRetry:()=>I()})}),N&&r.jsx(rv,{evals:C,onSave:O=>{s(O),L(!1)},onCancel:()=>L(!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 (",M.length,")"]}),r.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:T?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:M.length===0||x,title:x?Is: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:M.length===0||x,title:x?Is: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(O=>r.jsx("button",{onClick:()=>D(O),style:{padding:"2px 8px",fontSize:10,fontWeight:_===O?600:400,background:_===O?"var(--accent-muted)":"transparent",color:_===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:O==="all"?`All (${B.length})`:O==="unit"?`Unit (${B.filter(ne=>Rl(ne)==="unit").length})`:`Integration (${B.filter(ne=>Rl(ne)==="integration").length})`},O))}),r.jsxs("div",{className:"py-1",children:[M.length===0&&B.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"]}),M.map(O=>{var re;const ne=b.get(O.id),z=y===O.id,W=Rl(O);return r.jsxs("button",{onClick:()=>a({type:"SELECT_CASE",caseId:O.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:z?"var(--accent-muted)":"transparent",borderLeft:z?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:Y=>{z||(Y.currentTarget.style.background="var(--surface-2)")},onMouseLeave:Y=>{z||(Y.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:z?"var(--text-primary)":"var(--text-secondary)"},children:["#",O.id," ",O.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"&&((re=O.requiredCredentials)==null?void 0:re.some(Y=>ee.has(Y)))&&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(nb,{result:ne})]}),r.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[O.assertions.length," assertion",O.assertions.length!==1?"s":"",(ne==null?void 0:ne.passRate)!=null&&r.jsx(_E,{passRate:ne.passRate})]})]},O.id)})]}),r.jsx("div",{className:"px-3 py-2",children:!x&&r.jsx("button",{onClick:()=>L(!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:O=>{O.currentTarget.style.borderColor="var(--accent)",O.currentTarget.style.color="var(--accent)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--border-default)",O.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(RE,{})})]}),r.jsx("div",{className:"overflow-auto",children:$?r.jsx(zE,{evalCase:$,result:b.get($.id),evals:m,caseStatus:((G=S.get($.id))==null?void 0:G.status)??"idle",onSaveEvals:s,onRun:O=>i(O,"benchmark"),onCompare:O=>i(O,"comparison"),onCancel:O=>u(O),onImprove:O=>a({type:"OPEN_IMPROVE",evalId:O})}):r.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),N&&r.jsx(rv,{evals:C,onSave:O=>{s(O),L(!1)},onCancel:()=>L(!1)})]})}function zE({evalCase:t,result:a,evals:s,caseStatus:i,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:x}){const{state:m,isReadOnly:v}=_n(),{plugin:y,skill:b}=m,{entries:S,loading:k}=AE(y,b,t.id),[w,E]=p.useState(!1),[T,N]=p.useState(t.prompt),[L,_]=p.useState(!1),[D,V]=p.useState(t.expected_output);p.useState(()=>{N(t.prompt),V(t.expected_output)});const C=p.useCallback(O=>{c({...s,evals:s.evals.map(ne=>ne.id===O.id?O:ne)})},[s,c]),B=p.useCallback(()=>{C({...t,prompt:T}),E(!1)},[t,T,C]),M=p.useCallback(()=>{C({...t,expected_output:D}),_(!1)},[t,D,C]),$=p.useCallback(()=>{C({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,C]),U=p.useCallback((O,ne)=>{C({...t,assertions:t.assertions.map(z=>z.id===O?{...z,text:ne}:z)})},[t,C]),q=p.useCallback(O=>{C({...t,assertions:t.assertions.filter(ne=>ne.id!==O)})},[t,C]),X=p.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(O=>O.id!==t.id)})},[s,t.id,c]),ee=a&&a.assertions.length>0&&a.assertions.every(O=>O.pass),H=a&&a.assertions.some(O=>!O.pass),A=Rl(t),I=t.requiredCredentials??[],G=A==="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]}),v?r.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:A==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:A==="unit"?"var(--accent)":"var(--orange)"},children:A==="unit"?"Unit":"Integration"}):r.jsx("button",{onClick:()=>{if((A==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:ne,requirements:z,cleanup:W,...re}=t;C({...re,testType:"unit"})}else C({...t,testType:"integration"})},title:`Click to switch to ${A==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:A==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:A==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:A==="unit"?"Unit":"Integration"}),r.jsx(nb,{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:v,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),r.jsx("button",{onClick:()=>d(t.id),disabled:v,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),H&&!v&&i!=="running"&&i!=="queued"&&r.jsx("button",{onClick:()=>x(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!v&&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"})]})})]})]}),v&&A==="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"})]}),ee&&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"})]}),G&&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(O=>r.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:O},O))})]}),!v&&A==="integration"&&r.jsx(IE,{evalCase:t,onUpdate:C}),r.jsx(To,{title:"Prompt",children:w?r.jsxs("div",{children:[r.jsx("textarea",{value:T,onChange:O=>N(O.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:B,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{N(t.prompt),E(!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:v?"default":"pointer"},onClick:()=>{v||E(!0)},onMouseEnter:O=>{v||(O.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||r.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:v?"No prompt":"Click to edit prompt..."})})}),r.jsx(To,{title:"Expected Output",children:L?r.jsxs("div",{children:[r.jsx("textarea",{value:D,onChange:O=>V(O.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:M,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{V(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:v?"default":"pointer"},onClick:()=>{v||_(!0)},onMouseEnter:O=>{v||(O.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||r.jsx("span",{style:{fontStyle:"italic"},children:v?"No expected output":"Click to edit expected output..."})})}),r.jsx(To,{title:`Assertions (${t.assertions.length})`,action:v?void 0:r.jsx("button",{onClick:$,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(O=>{const ne=a==null?void 0:a.assertions.find(W=>W.assertion_id===O.id),z=ME(O.id,ne,S);return r.jsx(DE,{assertion:O,result:ne,badges:z,isReadOnly:v,onUpdate:W=>U(O.id,W),onDelete:()=>q(O.id)},O.id)})})}),(a==null?void 0:a.output)&&r.jsx(OE,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const O=eb("INEFFECTIVE",a.passRate);return O.recommendations&&O.recommendations.length>0?r.jsx(To,{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:O.recommendations.map((ne,z)=>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:"•"}),ne]},z))})]})}):null})(),r.jsx(BE,{evalId:t.id,sharedEntries:S,sharedLoading:k})]},t.id)}function DE({assertion:t,result:a,badges:s,isReadOnly:i,onUpdate:c,onDelete:u}){const[d,h]=p.useState(!1),[x,m]=p.useState(t.text),[v,y]=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:()=>y(!v),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:v?"Hide reasoning":"Show reasoning"}),v&&(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 To({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 nb({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=eb(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 _E({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 OE({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 Pd(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function Vd({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:Qy(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:Ol(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:Zy(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 BE({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:i,dispatch:c}=_n(),{plugin:u,skill:d}=i,[h,x]=p.useState(!0),m=a??null,v=s??!1,y=p.useCallback(()=>{x(w=>!w)},[]),b=m?m.slice(0,10):[],S=b.some(w=>{const E=Pd(w.type);return E==="left"||E==="full"}),k=b.some(w=>{const E=Pd(w.type);return E==="right"||E==="full"});return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:y,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:v?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(Jy,{entries:b})}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&r.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&r.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((w,E)=>{const T=Pd(w.type);return T==="full"?r.jsx("div",{style:{gridColumn:"1 / -1"},children:r.jsx(Vd,{entry:w})},E):T==="left"?r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"},children:r.jsx(Vd,{entry:w})}),r.jsx("div",{style:{gridColumn:"2"}})]},E):r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"}}),r.jsx("div",{style:{gridColumn:"2"},children:r.jsx(Vd,{entry:w})})]},E)})]}),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:w=>{w.currentTarget.style.textDecoration="underline"},onMouseLeave:w=>{w.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,v]=p.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[y,b]=p.useState("unit"),[S,k]=p.useState(""),[w,E]=p.useState([]),[T,N]=p.useState(""),[L,_]=p.useState(""),D=Math.max(0,...t.evals.map(M=>M.id))+1,V=M=>{b(M),M==="unit"&&(E([]),k(""),N(""),_(""))},C=()=>{const M=S.trim().toUpperCase();M&&!w.includes(M)&&E([...w,M]),k("")},B=()=>{if(!i.trim()||!u.trim())return;const M={id:D,name:i.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:m.filter($=>$.text.trim()),...y==="integration"?{testType:"integration",...w.length>0?{requiredCredentials:w}:{},...T||L?{requirements:{...T?{platform:T}:{},...L?{chromeProfile:L}:{}}}:{}}:{}};a({...t,evals:[...t.evals,M]})};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(M=>r.jsx("button",{onClick:()=>V(M),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:y===M?M==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:y===M?M==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:M},M))})]}),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:M=>c(M.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:M=>d(M.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:M=>x(M.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((M,$)=>r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:M.text,onChange:U=>v(m.map((q,X)=>X===$?{...q,text:U.target.value}:q)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),m.length>1&&r.jsx("button",{onClick:()=>v(m.filter((U,q)=>q!==$)),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"})]})})]},M.id)),r.jsx("button",{onClick:()=>v([...m,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),y==="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:w.map(M=>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:[M,r.jsx("button",{onClick:()=>E(w.filter($=>$!==M)),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"})]})})]},M))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:S,onChange:M=>k(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),C())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),r.jsx("button",{onClick:C,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:T,onChange:M=>N(M.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:L,onChange:M=>_(M.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:B,disabled:!i.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function IE({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(v=>v!==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 Dn(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 rb(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function $E(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function UE(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 HE(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 PE(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function VE(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 FE={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function GE(t,a){if(!t)return null;const s=FE[t];if(s==null||s===0)return null;const i=s*a*.5,c=s*a*2;return`${Dn(i)}–${Dn(c)}`}function WE(){const{state:t,runCase:a,runAll:s,cancelCase:i,cancelAll:c,isReadOnly:u}=_n(),{evals:d,caseRunStates:h,bulkRunActive:x,latestBenchmark:m,inlineResults:v}=t,{config:y}=Pa(),b=(d==null?void 0:d.evals)??[],S=p.useMemo(()=>{for(const C of h.values())if(C.status==="running"||C.status==="queued")return!0;return!1},[h]),k=b.filter(C=>{const B=h.get(C.id);return B&&(B.status==="complete"||B.status==="error"||B.status==="cancelled")}).length,w=b.filter(C=>{const B=h.get(C.id);return B&&(B.status==="running"||B.status==="queued")}).length,E=p.useRef(null),[T,N]=p.useState(0);p.useEffect(()=>{if(S&&!E.current&&(E.current=Date.now()),!S){E.current=null,N(0);return}const C=setInterval(()=>{E.current&&N(Math.round((Date.now()-E.current)/1e3))},1e3);return()=>clearInterval(C)},[S]);const L=b.reduce((C,B)=>C+B.assertions.length,0),_=b.length+L,D=p.useMemo(()=>VE(b.length,L),[b.length,L]),V=p.useMemo(()=>GE((y==null?void 0:y.provider)??null,_),[y==null?void 0:y.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:[w," 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: ",D]}),V&&r.jsxs("span",{children:["Est. cost: ",V]}),!V&&(y==null?void 0:y.provider)&&(y.provider==="claude-cli"||y.provider==="codex-cli")&&r.jsx("span",{children:"Cost: Included"}),!V&&(y==null?void 0:y.provider)&&(y.provider==="ollama"||y.provider==="lm-studio"||y.provider==="gemini-cli")&&r.jsx("span",{children:"Cost: Free"})]})]}),S&&b.length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",k,"/",b.length," cases"]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(k/b.length*100),"%"]})]}),r.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${k/b.length*100}%`,background:"var(--accent)"}})}),r.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",T>=60?`${Math.floor(T/60)}m ${T%60}s`:`${T}s`]}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",D]})]})]}),r.jsx("div",{className:"space-y-3 stagger-children",children:b.map(C=>{const B=v.get(C.id),M=h.get(C.id),$=(M==null?void 0:M.status)??"idle",U=m==null?void 0:m.cases.find(q=>q.eval_id===C.id);return r.jsx(YE,{name:C.name,evalId:C.id,result:B,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:$,runMode:(M==null?void 0:M.mode)??null,comparisonDetail:U==null?void 0:U.comparisonDetail,isReadOnly:u,onRun:q=>a(q,"benchmark"),onBaseline:q=>a(q,"baseline"),onCompare:q=>a(q,"comparison"),onCancel:q=>i(q)},C.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:$E(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: ${rb(m.totalInputTokens,m.totalOutputTokens)}`,m.totalCost!=null&&` | Cost: ${Dn(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 C=UE(m.model,m.timestamp);return C?r.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:C}):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&&` | ${TE(m.verdict)}`]}),(()=>{const C=m.cases.reduce((M,$)=>M+$.assertions.length,0),B=HE(m.comparison.delta,C,m.cases.length);return r.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:B})})()]})]})]})}const qE={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 YE({name:t,evalId:a,result:s,caseCost:i,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:x,comparisonDetail:m,isReadOnly:v,onRun:y,onBaseline:b,onCompare:S,onCancel:k}){const[w,E]=p.useState(!1),T=h==="running"||h==="queued",N=h==="complete"||h==="error";return r.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:T?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:T?"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&&(T||N)&&(()=>{const L=qE[x];return L?r.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:L.bg,color:L.color,padding:"1px 6px"},children:L.label}):null})()]}),r.jsxs("div",{className:"flex items-center gap-2",children:[T?r.jsx("button",{onClick:()=>k(a),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>S(a),disabled:v,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),r.jsx("button",{onClick:()=>y(a),disabled:v,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),r.jsx("button",{onClick:()=>b(a),disabled:v,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:rb(u,d)}),i!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Dn(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(L=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{style:{color:L.pass?"var(--green)":"var(--red)"},children:L.pass?"PASS":"FAIL"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:L.text})]},L.assertion_id))}),s.output&&r.jsx("button",{onClick:()=>E(!w),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:w?"Hide output":"Show output"}),w&&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 L=av(m.skillContentScore,m.baselineContentScore),_=av(m.skillStructureScore,m.baselineStructureScore),D=PE(m.winner);return r.jsxs(r.Fragment,{children:[r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",L.skill,"% / Baseline ",L.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:D.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:D.text})]})})()})})}),s&&s.errorMessage&&r.jsx(KE,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const Fd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function KE({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?Fd[a.category]??Fd.unknown:Fd.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)"}},XE={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 QE(){const{state:t,dispatch:a,runActivationTest:s,cancelActivation:i,generateActivationPrompts:c}=_n(),{plugin:u,skill:d,activationPrompts:h,activationResults:x,activationSummary:m,activationRunning:v,activationError:y,activationStartedAt:b,activationClassifyingStatus:S,generatingPrompts:k,generatingPromptsError:w,activationHistory:E}=t,{state:T}=lr(),N=T.skills.find(O=>O.plugin===u&&O.skill===d),L=(N==null?void 0:N.resolvedVersion)??(N==null?void 0:N.version)??null,[_,D]=p.useState(h),[V,C]=p.useState(null),[B,M]=p.useState(!1);p.useEffect(()=>{h&&h!==_&&D(h)},[h]),p.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:_})},[_,a]),p.useEffect(()=>{fetch(`/api/skills/${u}/${d}/description`).then(O=>O.json()).then(O=>C(O.rawContent||O.description||null)).catch(()=>C(null))},[u,d]);function $(){s(_)}function U(){c(8)}const q=_.trim().split(`
|
|
99
|
+
`).filter(Boolean).length,X=O=>O.verdict==="scope_warning"||O.verdict==="drift_warning",ee=x.filter(O=>(O.classification==="TP"||O.classification==="TN")&&!X(O)),H=x.filter(O=>(O.classification==="FP"||O.classification==="FN")&&!X(O));x.filter(X);const A=(V==null?void 0:V.replace(/^---[\s\S]*?---\s*/,"").trim())??null,I=_.trim().length>0,G=A?lc(A):"";return r.jsxs("div",{className:"p-5 space-y-5",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),r.jsx("div",{className:"text-[12px] mt-0.5",style:{color:"var(--text-tertiary)"},children:"Test whether this skill's description activates for relevant prompts and stays silent for irrelevant ones."})]}),r.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[r.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),r.jsx("div",{className:"flex gap-1.5",children:r.jsx("button",{onClick:U,disabled:k||!A||v,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:k?"var(--surface-3)":"var(--surface-2)",color:A?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:A?1:.5,cursor:A?"pointer":"not-allowed"},title:A?void 0:"No skill description available",onMouseEnter:O=>{A&&!k&&(O.currentTarget.style.background="var(--surface-3)")},onMouseLeave:O=>{k||(O.currentTarget.style.background="var(--surface-2)")},children:k?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 3v3m6.36.64l-2.12 2.12M21 12h-3m-.64 6.36l-2.12-2.12M12 21v-3m-4.24.64l2.12-2.12M3 12h3m.64-6.36l2.12 2.12"})}),I?"Regenerate":"Generate"," Test Prompts"]})})})]}),!A&&!v&&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."}),w&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:w}),r.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:_,onChange:O=>D(O.target.value),placeholder:`How do I write a unit test?
|
|
100
|
+
What edge cases should I test?
|
|
101
|
+
+Deploy this to production
|
|
102
|
+
!What's the weather like today?
|
|
103
|
+
!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(Ro,{}),r.jsx("span",{children:"No prefix = auto-classify"}),r.jsx(Ro,{}),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(Ro,{}),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(Ro,{}),r.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[q," prompt",q!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:$,disabled:v||!_.trim(),className:"btn btn-primary",children:v?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"]})}),v&&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:[S||`${x.length} / ${q} prompts tested`,b&&r.jsx(tN,{startedAt:b})]})]})]})]}),r.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[r.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:A?r.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:G}}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),y&&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:y}),v&&x.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..."})]}),x.length>0&&r.jsxs("div",{className:"space-y-5",children:[H.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 (",H.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:H.map((O,ne)=>r.jsx(iv,{result:O},`incorrect-${ne}`))})]}),ee.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 (",ee.length,")"]})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:ee.map((O,ne)=>r.jsx(iv,{result:O},`correct-${ne}`))})]})]}),m&&r.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),m.autoClassifiedCount!=null&&m.autoClassifiedCount>0&&r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[m.autoClassifiedCount," of ",m.total," prompts auto-classified from skill name and tags"]}),r.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[r.jsx(Gd,{label:"Precision",value:m.precision,description:"Of all activations, how many were correct?",detail:`${m.tp} true / ${m.tp+m.fp} total activations`}),r.jsx(Gd,{label:"Recall",value:m.recall,description:"Of expected activations, how many fired?",detail:`${m.tp} activated / ${m.tp+m.fn} expected`}),r.jsx(Gd,{label:"Reliability",value:m.reliability,description:"Overall correct classification rate",detail:`${m.tp+m.tn} correct / ${m.total} total`})]}),r.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[r.jsx(Ao,{label:"True Positive",abbr:"TP",count:m.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),r.jsx(Ao,{label:"False Positive",abbr:"FP",count:m.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),r.jsx(Ao,{label:"False Negative",abbr:"FN",count:m.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),r.jsx(Ao,{label:"True Negative",abbr:"TN",count:m.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:(m.scopeWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[m.scopeWarnings??0," scope"]}),", ",r.jsxs("span",{style:{color:(m.driftWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[m.driftWarnings??0," drift"]})]})]})]}),r.jsx(ZE,{history:E,expanded:B,onToggle:()=>M(!B),skillVersion:L})]})}function ZE({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(JE,{run:c,skillVersion:i},c.id))})})]})}function JE({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:eN(t.timestamp)}),r.jsx(li,{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 eN(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 Ro(){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"?XE[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 Gd({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 Ao({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 tN({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 Wd={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},ov={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},jf=600,Sf=180,pn=40,qd=jf-pn*2,ca=Sf-pn*2,nN=[25,50,75,100];function cv(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function rN(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function aN({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,v)=>{const y=pn+v/(u-1)*qd,b=m.passRate*100,S=pn+ca-b/100*ca;return{x:y,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:Wd[m]??"var(--text-tertiary)"}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:ov[m]??m})]},m))}),r.jsxs("svg",{width:jf,height:Sf,viewBox:`0 0 ${jf} ${Sf}`,style:{display:"block",overflow:"visible"},children:[nN.map(m=>{const v=pn+ca-m/100*ca;return r.jsxs("g",{children:[r.jsx("line",{x1:pn,y1:v,x2:pn+qd,y2:v,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),r.jsxs("text",{x:pn-8,y:v+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[m,"%"]})]},m)}),r.jsx("line",{x1:pn,y1:pn+ca,x2:pn+qd,y2:pn+ca,stroke:"var(--border-subtle)",strokeWidth:1}),r.jsx("text",{x:pn-8,y:pn+ca+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,v)=>r.jsx("circle",{cx:m.x,cy:m.y,r:5,fill:Wd[m.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:y=>{y.currentTarget.setAttribute("r","7"),i({x:m.x,y:m.y,entry:m.entry})},onMouseLeave:y=>{y.currentTarget.setAttribute("r","5"),i(null)},onClick:()=>a==null?void 0:a(m.entry)},v)),lN(u).map(m=>r.jsx("text",{x:d[m].x,y:pn+ca+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:Wd[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:rN(s.entry.totalDurationMs)}),r.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function lN(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 Hs=new Map;let mn=null,Ho=null,Mo=1e3,Al=0;function ab(){if(mn)return;mn=new EventSource("/api/events");const t=a=>s=>{let i={};try{i=s.data?JSON.parse(s.data):{}}catch{}const c=Hs.get(a);if(c)for(const u of c)u(i)};mn.addEventListener("benchmark:complete",t("benchmark:complete")),mn.addEventListener("history:written",t("history:written")),mn.addEventListener("leaderboard:updated",t("leaderboard:updated")),mn.onerror=()=>{mn==null||mn.close(),mn=null,Al>0&&(Ho=setTimeout(()=>{Mo=Math.min(Mo*2,3e4),ab()},Mo))},mn.onopen=()=>{Mo=1e3}}function sN(){Ho!=null&&(clearTimeout(Ho),Ho=null),mn==null||mn.close(),mn=null}function iN(t,a){return Hs.has(t)||Hs.set(t,new Set),Hs.get(t).add(a),Al++,ab(),()=>{var s;(s=Hs.get(t))==null||s.delete(a),Al--,Al<=0&&(Al=0,queueMicrotask(()=>{Al<=0&&sN()}))}}function Wo(t,a){const s=p.useRef(a);s.current=a,p.useEffect(()=>iN(t,c=>s.current(c)),[t])}function qo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function oN(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function cN({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:qo(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:qo(t)}})})]})})}function uN({points:t}){if(t.length<2)return null;const a=200,s=48,i=4,c=t.length,u=t.map((x,m)=>{const v=i+m/(c-1)*(a-i*2),y=i+(s-i*2)-x.passRate*(s-i*2);return{x:v,y}}),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 dN({plugin:t,skill:a}){const s=`stats/${t}/${a}`,i=p.useCallback(()=>Se.getStats(t,a),[t,a]),{data:c,loading:u}=$l(s,i),d=p.useCallback(()=>Ln(s),[s]);if(Wo("benchmark:complete",d),Wo("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,v=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:qo(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:Dn(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:Dn(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(uN,{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(y=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:y.model}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:y.runs}),r.jsx("td",{style:{padding:"8px",textAlign:"center"},children:r.jsxs("span",{className:"font-semibold",style:{color:qo(y.avgPassRate)},children:[Math.round(y.avgPassRate*100),"%"]})}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:oN(y.avgDurationMs)}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:y.avgCost!=null?Dn(y.avgCost):"N/A"})]},y.model))})]})]}),v.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:v.map(y=>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:["#",y.evalId]}),r.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:y.evalName}),r.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[y.totalRuns," runs"]})]}),r.jsx(cN,{rate:y.passRate,label:y.text})]},`${y.evalId}:${y.id}`))})]})]})}function fN({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(()=>{Se.getEvals(t,a).then(i).catch(()=>i(null))},[t,a]);async function v(y){if(c===y){u(null);return}if(u(y),!d[y]){m(b=>({...b,[y]:!0}));try{const b=await Se.getCaseHistory(t,a,y);h(S=>({...S,[y]:b}))}catch{h(b=>({...b,[y]:[]}))}finally{m(b=>({...b,[y]:!1}))}}}return s?r.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(y=>{const b=d[y.id]||[],S=c===y.id,k=x[y.id],w=b.length>0?b[0].pass_rate:null;return r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>v(y.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:E=>{S||(E.currentTarget.style.background="var(--surface-2)")},onMouseLeave:E=>{S||(E.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:["#",y.id]}),r.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:y.name}),b.length>=2&&r.jsx(Jy,{entries:b}),w!=null&&r.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Ol(w)},children:[Math.round(w*100),"%"]}),b.length>0&&r.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),S&&r.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?r.jsxs("div",{className:"p-4 flex items-center gap-2",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?r.jsx("div",{className:"p-4",children:r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):r.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((E,T)=>r.jsxs("div",{className:"p-4",style:{background:T===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:Qy(E.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:E.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:E.type==="benchmark"?"rgba(99,131,255,0.15)":E.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:E.type==="benchmark"?"#6383ff":E.type==="comparison"?"var(--purple)":"#fb923c"},children:E.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ol(E.pass_rate)},children:[Math.round(E.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:[E.durationMs!=null&&r.jsx("span",{children:Zy(E.durationMs)}),E.tokens!=null&&r.jsxs("span",{children:[E.tokens>=1e3?`${(E.tokens/1e3).toFixed(1)}k`:E.tokens," tok"]})]}),r.jsx("div",{className:"space-y-1",children:E.assertions.map(N=>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:N.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:N.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:N.text}),N.reasoning&&r.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:N.reasoning})]})]},N.id))})]},T))})})]},y.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}=_n(),{plugin:s,skill:i}=t,{state:c}=lr(),u=c.skills.find(G=>G.plugin===s&&G.skill===i),d=(u==null?void 0:u.resolvedVersion)??(u==null?void 0:u.version)??null,[h,x]=p.useState("timeline"),[m,v]=p.useState(""),[y,b]=p.useState(""),[S,k]=p.useState(!1),[w,E]=p.useState([]),[T,N]=p.useState(null),[L,_]=p.useState(!1),[D,V]=p.useState(null),[C,B]=p.useState(!1),M=`history/${s}/${i}?model=${m}&type=${y}`,$=p.useCallback(()=>Se.getHistory(s,i,{model:m||void 0,type:y||void 0}),[s,i,m,y]),{data:U,loading:q}=$l(M,$),X=U??[];p.useEffect(()=>{!U||U.length<2||Se.compareRuns(s,i,U[0].timestamp,U[1].timestamp).then(G=>{const O=G.regressions.filter(ne=>ne.change==="regression");a({type:"SET_REGRESSIONS",regressions:O})}).catch(()=>{})},[U,s,i,a]);const ee=p.useCallback(()=>Ln(M),[M]);Wo("history:written",ee);const H=p.useCallback(async G=>{if(S){E(O=>O.includes(G)?O.filter(ne=>ne!==G):O.length>=2?[O[1],G]:[...O,G]);return}B(!0);try{const O=await Se.getHistoryEntry(s,i,G);V(O)}catch{}finally{B(!1)}},[s,i,S]),A=p.useCallback(async()=>{if(w.length===2){_(!0);try{const G=await Se.compareRuns(s,i,w[0],w[1]);N(G)}catch{}finally{_(!1)}}},[s,i,w]),I=[...new Set(X.map(G=>G.model))];return q?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"skeleton h-12 rounded-lg"}),r.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(G=>r.jsx("button",{onClick:()=>x(G),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===G?"var(--accent-muted)":"transparent",color:h===G?"var(--accent)":"var(--text-tertiary)"},children:G==="timeline"?"Timeline":G==="per-eval"?"Per Eval":"Statistics"},G))}),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(aN,{entries:X,onPointClick:G=>H(G.timestamp)})}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("select",{value:m,onChange:G=>v(G.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Models"}),I.map(G=>r.jsx("option",{value:G,children:G},G))]}),r.jsxs("select",{value:y,onChange:G=>b(G.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Types"}),r.jsx("option",{value:"benchmark",children:"Benchmark"}),r.jsx("option",{value:"comparison",children:"Comparison"}),r.jsx("option",{value:"baseline",children:"Baseline"}),r.jsx("option",{value:"model-compare",children:"Model Compare"}),r.jsx("option",{value:"improve",children:"AI Improve"}),r.jsx("option",{value:"instruct",children:"AI Edit"}),r.jsx("option",{value:"ai-generate",children:"AI Generate"}),r.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:()=>{k(!S),E([]),N(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&w.length===2&&r.jsx("button",{onClick:A,disabled:L,className:"btn btn-primary text-[12px]",children:L?"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(G=>{const O=w.includes(G.timestamp);return r.jsx("button",{onClick:()=>H(G.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:O?"var(--accent-muted)":"var(--surface-1)",border:O?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:ne=>{O||(ne.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:ne=>{O||(ne.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:O?"var(--accent)":"var(--border-default)",background:O?"var(--accent)":"transparent"},children:O&&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(G.timestamp).toLocaleString()}),r.jsx("span",{className:"pill text-[9px]",style:{background:G.type==="comparison"?"var(--purple-muted)":G.type==="baseline"?"var(--surface-3)":G.type==="model-compare"?"var(--accent-muted)":G.type==="improve"||G.type==="instruct"?"var(--purple-muted)":G.type==="ai-generate"?"var(--green-muted)":G.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:G.type==="comparison"?"var(--purple)":G.type==="baseline"?"var(--text-tertiary)":G.type==="model-compare"?"var(--accent)":G.type==="improve"||G.type==="instruct"?"var(--purple)":G.type==="ai-generate"?"var(--green)":G.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:G.type==="model-compare"?"model compare":G.type==="improve"?"ai improve":G.type==="instruct"?"ai edit":G.type==="ai-generate"?"ai generate":G.type==="eval-generate"?"eval generate":G.type})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(li,{version:d,size:"sm","data-testid":"history-row-version"}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:G.model}),G.totalCost!=null&&G.totalCost>0&&r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Dn(G.totalCost)}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:G.passRate>=.8?"var(--green)":G.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(G.passRate*100),"%"]})]})]})},G.timestamp)})}),T&&r.jsx(pN,{result:T}),D&&!S&&r.jsx(mN,{run:D,onClose:()=>V(null)})]}),h==="per-eval"&&r.jsx(fN,{plugin:s,skill:i}),h==="statistics"&&r.jsx(dN,{plugin:s,skill:i})]})}function pN({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: ",Dn(t.runA.totalCost??null)]}),r.jsxs("span",{children:["Run B cost: ",Dn(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: ",Dn(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 mN({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?r.jsx(hN,{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: ${Dn(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:Dn(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 hN({run:t,onClose:a}){var u;const s=p.useMemo(()=>t.improve?sc(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 lb({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),v=Math.max(...a)-x||1,y=a.map((k,w)=>{const E=c+w/(h-1)*u,T=c+d-(k-x)/v*d;return`${E.toFixed(1)},${T.toFixed(1)}`}),b=a[a.length-1],S=Ol(b);return r.jsxs("svg",{width:s,height:i,viewBox:`0 0 ${s} ${i}`,style:{display:"block"},children:[r.jsx("polyline",{points:y.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,w]=y[y.length-1].split(",");return r.jsx("circle",{cx:k,cy:w,r:2.5,fill:S})})()]})}function xN(){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 gN({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 vN({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 yN({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 bN({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 jN(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 sb=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function SN({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:sb(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(xN,{})]})}),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:Ol(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(lb,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function kN({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:sb(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:Ol(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(gN,{pct:s.amplificationPct}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(lb,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function dv(){const{state:t}=_n(),{plugin:a,skill:s}=t,[i,c]=p.useState("rankings"),u=`leaderboard/${a}/${s}`,d=p.useCallback(()=>Se.getLeaderboard(a,s),[a,s]),{data:h,loading:x,error:m}=$l(u,d),v=(h==null?void 0:h.entries)??[],y=(m==null?void 0:m.message)??null;p.useEffect(()=>{c("rankings")},[a,s]);const b=p.useCallback(()=>Ln(u),[u]);Wo("leaderboard:updated",b);const S=p.useMemo(()=>jN(v),[v]),k=S.some(T=>T.hasBaseline),w=v[0],E=w==null?void 0:w.judgeBiasWarning;return x?r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx("div",{className:"spinner spinner-lg"})}):y?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:y})]})}):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(bN,{active:i,onChange:c,hasBaseline:k})]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[v.length," sweep",v.length!==1?"s":""," · ",S.length," model",S.length!==1?"s":""]})]}),E&&r.jsx(yN,{warning:E}),i==="rankings"?r.jsx(SN,{entries:S}):r.jsx(kN,{entries:S}),i==="amplification"&&(w==null?void 0:w.skillQualityScore)!=null&&(w==null?void 0:w.skillQualityRating)&&r.jsx(vN,{score:w.skillQualityScore,rating:w.skillQualityRating})]})}function ib({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(()=>{Se.getDependencies(t,a).then(y=>{i(y.mcpDependencies),u(y.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,a]);async function v(y,b){try{await navigator.clipboard.writeText(b),m(y),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(y=>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:y.server}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:y.transport})]}),r.jsx("button",{onClick:()=>v(y.server,y.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:x===y.server?"var(--green)":"var(--accent)"},children:x===y.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:y.url}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.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))})]},y.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(y=>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:y.name}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:y.source==="frontmatter"?"frontmatter":"referenced"})]},y.name))})]})]})]})}function kf({plugin:t,skill:a}){const[s,i]=p.useState([]),[c,u]=p.useState(!0),[d,h]=p.useState(null),[x,m]=p.useState(""),[v,y]=p.useState(!1),[b,S]=p.useState(null),[k,w]=p.useState(""),[E,T]=p.useState(""),[N,L]=p.useState(!1),[_,D]=p.useState(new Set),V=p.useCallback(async()=>{u(!0);try{const[$,U]=await Promise.all([Se.getCredentials(t,a).catch(()=>({credentials:[]})),Se.getParams(t,a).catch(()=>({params:[]}))]),q=new Map(U.params.map(H=>[H.name,H])),X=new Set,ee=[];for(const H of $.credentials){X.add(H.name);const A=q.get(H.name);ee.push({name:H.name,status:H.status==="ready"||H.status==="resolved"?"ready":"missing",source:H.source,maskedValue:A==null?void 0:A.maskedValue})}for(const H of U.params)X.has(H.name)||ee.push({name:H.name,status:H.status,maskedValue:H.maskedValue});i(ee)}finally{u(!1)}},[t,a]);p.useEffect(()=>{V()},[V]);const C=p.useCallback(async $=>{if(_.has($)){D(U=>{const q=new Set(U);return q.delete($),q}),i(U=>U.map(q=>q.name===$?{...q,revealedValue:void 0}:q));return}try{const q=(await Se.getParamsRevealed(t,a,$)).params.find(X=>X.name===$);q&&(i(X=>X.map(ee=>ee.name===$?{...ee,revealedValue:q.value}:ee)),D(X=>new Set(X).add($)))}catch{}},[t,a,_]),B=async($,U)=>{if(!(!$.trim()||!U.trim())){y(!0),S(null);try{await Se.setCredential(t,a,$,U),h(null),m(""),D(new Set),V()}catch(q){S(q.message)}finally{y(!1)}}},M=async()=>{if(!(!k.trim()||!E.trim())){y(!0),S(null);try{await Se.setCredential(t,a,k.trim().toUpperCase(),E),w(""),T(""),L(!1),V()}catch($){S($.message)}finally{y(!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:()=>L(!N),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&&!N?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($=>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:$.name}),$.maskedValue&&r.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:_.has($.name)&&$.revealedValue!=null?$.revealedValue:$.maskedValue}),$.maskedValue&&r.jsx("button",{onClick:()=>C($.name),className:"btn btn-ghost px-1",title:_.has($.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:_.has($.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:$.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:$.status==="ready"?"var(--green)":"var(--orange)"},children:$.status==="ready"?"ready":"missing"}),$.source&&r.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:$.source}),d===$.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"&&B($.name,x)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),r.jsx("button",{onClick:()=>B($.name,x),disabled:v||!x.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:v?"...":"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($.name),m("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},$.name))}),N&&r.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:k,onChange:$=>w($.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),r.jsx("input",{value:E,onChange:$=>T($.target.value),onKeyDown:$=>{$.key==="Enter"&&M()},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:()=>{L(!1),w(""),T("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),r.jsx("button",{onClick:M,disabled:v||!k.trim()||!E.trim(),className:"btn btn-primary text-[10px]",children:v?"Saving...":"Save"})]})]})]})}function wN(){const{state:t}=_n(),{plugin:a,skill:s}=t,[i,c]=p.useState(null),[u,d]=p.useState(!0);return p.useEffect(()=>{Se.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(ib,{plugin:a,skill:s}),r.jsx(kf,{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(kf,{plugin:a,skill:s})]})}function CN(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 EN(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 Yo(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function NN(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 TN({onCreated:t,resolveAiConfigOverride:a,forceLayout:s}){const[i,c]=p.useState("ai"),[u,d]=p.useState(null),[h,x]=p.useState(!0),{config:m}=Pa(),[v,y]=p.useState(""),[b,S]=p.useState(s??3),[k,w]=p.useState(""),[E,T]=p.useState(""),[N,L]=p.useState(""),[_,D]=p.useState(""),[V,C]=p.useState(""),[B,M]=p.useState(""),[$,U]=p.useState("write"),[q,X]=p.useState([]),[ee,H]=p.useState(!1),[A,I]=p.useState(null),[G,O]=p.useState(null),[ne,z]=p.useState(null),[W,re]=p.useState("vskill"),[Y,ce]=p.useState("1.0.0"),[se,be]=p.useState(!0),ie=p.useCallback(async()=>{try{const De=await Se.detectEngines();z(De),re(We=>We!=="vskill"?We:De.vskillSkillBuilder?"vskill":De.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{z({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);p.useEffect(()=>{ie()},[ie]);const[ye,Re]=p.useState(""),[Ae,le]=p.useState(!1),[he,pe]=p.useState(!1),[xe,je]=p.useState(null),[Be,Ie]=p.useState(null),[Nt,Vt]=p.useState([]),ut=p.useRef(null),Et=p.useRef(null),Ft=p.useRef(null),qe=p.useRef(null),dt=p.useRef(null),[Jt,Kt]=p.useState(!1),[cn,ge]=p.useState(!1),tt=p.useRef(v),ft=p.useRef(k),Lt=p.useRef(E);p.useEffect(()=>{tt.current=v},[v]),p.useEffect(()=>{ft.current=k},[k]),p.useEffect(()=>{Lt.current=E},[E]),p.useEffect(()=>{Se.getProjectLayout().then(De=>{if(d(De),s)return;S(De.suggestedLayout);const We=De.detectedLayouts.find(ue=>ue.layout===De.suggestedLayout);We!=null&&We.existingPlugins.length&&w(We.existingPlugins[0])}).catch(()=>{}).finally(()=>x(!1))},[s]),p.useEffect(()=>{var De;i==="ai"&&((De=ut.current)==null||De.focus())},[i]),p.useEffect(()=>()=>{var De;(De=Et.current)==null||De.abort()},[]);const Tt=p.useMemo(()=>{var De;return u?((De=u.detectedLayouts.find(We=>We.layout===b))==null?void 0:De.existingPlugins)||[]:[]},[u,b]),Ze=k==="__new__"?E:k,xn=u?NN(u.root,b,Ze||"{plugin}",v||"{skill}"):"",Ot=p.useMemo(()=>u?u.detectedLayouts.filter(De=>De.layout!==4):[],[u]),un=p.useMemo(()=>{if(!u)return null;const De=u.detectedLayouts.find(we=>we.layout===2&&we.existingPlugins.length>0),We=u.detectedLayouts.find(we=>we.layout===1&&we.existingPlugins.length>0),ue=De||We;return ue?{layout:ue.layout,plugins:ue.existingPlugins}:null},[u]),dn=p.useCallback(()=>{if(a)return a();if(!m)return{provider:"claude-cli",model:"sonnet"};const De=m.provider||"claude-cli",We=m.model||"sonnet";return{provider:De,model:We}},[m,a]),Qn=p.useCallback(()=>{var De;(De=Et.current)==null||De.abort(),le(!1)},[]),gn=p.useCallback(()=>{je(null),Ie(null)},[]),Zn=p.useCallback(async()=>{var we,Le;if(je(null),Ie(null),Vt([]),Ft.current=null,qe.current=null,!ye.trim()){je("Describe what your skill should do");return}le(!0);const De=new AbortController;Et.current=De;const{provider:We,model:ue}=dn();try{const Bt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(CN({prompt:ye.trim(),provider:We,model:ue,targetAgents:q})),signal:De.signal});if(!Bt.ok||!Bt.body){let Or=`HTTP ${Bt.status}`;try{const Br=await Bt.json();Br.error&&(Or=Br.error)}catch{}throw new Error(Or)}const Pl=Bt.body.getReader(),ii=new TextDecoder;let Ga="",sr="";for(;;){const{done:Or,value:Br}=await Pl.read();if(Or)break;Ga+=ii.decode(Br,{stream:!0});const Vl=Ga.split(`
|
|
104
|
+
`);Ga=Vl.pop()||"";for(const ga of Vl)if(ga.startsWith("event: "))sr=ga.slice(7).trim();else if(ga.startsWith("data: ")){try{const nt=JSON.parse(ga.slice(6));if(sr==="progress")Vt(Rt=>[...Rt,{phase:nt.phase,message:nt.message,timestamp:Date.now()}]);else if(sr==="provenance")qe.current={resolvedModelId:typeof nt.resolvedModelId=="string"?nt.resolvedModelId:null,snapshotDate:typeof nt.snapshotDate=="string"?nt.snapshotDate:null};else if(sr==="done"||sr==="complete"){const Rt={prompt:ye.trim(),provider:dn().provider,model:dn().model,resolvedModelId:((we=qe.current)==null?void 0:we.resolvedModelId)??null,snapshotDate:((Le=qe.current)==null?void 0:Le.snapshotDate)??null,reasoning:nt.reasoning||""},zt=EN({userName:tt.current,userPlugin:ft.current,userNewPlugin:Lt.current,aiName:nt.name,aiSuggestedPlugin:nt.suggestedPlugin&&nt.suggestedPlugin.plugin?{plugin:nt.suggestedPlugin.plugin,layout:nt.suggestedPlugin.layout}:null,forceLayout:s});if(zt.applyName!==null&&y(zt.applyName),L(nt.description),D(nt.model||""),C(nt.allowedTools||""),M(nt.body),pe(!0),Ft.current=Rt,c("manual"),s===3)S(3),w(""),T("");else if(zt.applySuggestedPlugin&&zt.suggestedPluginValue){const en=zt.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap($r=>$r.existingPlugins))??[]).includes(en.plugin))if(w(en.plugin),en.layout&&(en.layout===1||en.layout===2))S(en.layout);else{const $r=u==null?void 0:u.detectedLayouts.find(oi=>oi.existingPlugins.includes(en.plugin));$r&&($r.layout===1||$r.layout===2)&&S($r.layout)}else w("__new__"),T(en.plugin)}else!zt.applySuggestedPlugin&&ft.current.trim().length===0&&Lt.current.trim().length===0&&b===3&&un&&ge(!0);const Ir={name:nt.name,plugin:Ze||"",layout:b,description:nt.description,model:nt.model||void 0,allowedTools:nt.allowedTools||void 0,body:nt.body,aiMeta:Rt};Se.saveDraft(Ir).then(en=>{Kt(!0),en!=null&&en.dir&&(dt.current=en.dir)}).catch(()=>{})}else sr==="error"&&(je(nt.message||nt.description||"Unknown error"),nt.category&&Ie(nt))}catch{}sr=""}}}catch(Bt){Bt.name!=="AbortError"&&je(Bt.message)}finally{le(!1),Et.current=null}},[ye,dn,b,un,Ze,u,q,s]),On=p.useCallback(async()=>{var De;if(I(null),O(null),!v.trim()){I("Skill name is required");return}if(!N.trim()){I("Description is required");return}if(b!==3&&!Ze.trim()){I("Plugin name is required");return}if(!se){I("Version is not valid semver");return}H(!0);try{const We=await Se.createSkill({name:Yo(v),plugin:Ze||"",layout:b,description:N,model:_||void 0,allowedTools:V||void 0,body:B,aiMeta:Ft.current||void 0,draftDir:dt.current||void 0,version:Y.trim()||void 0,engine:W});dt.current=null,t(We.plugin,We.skill)}catch(We){if(We instanceof Ml&&We.status===409&&((De=We.details)==null?void 0:De.code)==="skill-already-exists"){const ue=typeof We.details.plugin=="string"?We.details.plugin:"",we=typeof We.details.skill=="string"?We.details.skill:Yo(v);O("Skill already existed — opened it."),dt.current=null,t(ue,we)}else I(We.message)}finally{H(!1)}},[v,N,b,Ze,_,V,B,Y,se,W,t]),vt=p.useCallback(()=>{un&&(S(un.layout),w(un.plugins[0]),ge(!1))},[un]);return{mode:i,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:S,creatableLayouts:Ot,availablePlugins:Tt,pathPreview:xn,plugin:k,setPlugin:w,newPlugin:E,setNewPlugin:T,effectivePlugin:Ze,name:v,setName:y,description:N,setDescription:L,model:_,setModel:D,allowedTools:V,setAllowedTools:C,body:B,setBody:M,bodyViewMode:$,setBodyViewMode:U,aiPrompt:ye,setAiPrompt:Re,generating:Ae,aiGenerated:he,aiError:xe,aiClassifiedError:Be,aiProgress:Nt,promptRef:ut,handleGenerate:Zn,handleCancelGenerate:Qn,clearAiError:gn,targetAgents:q,setTargetAgents:X,draftSaved:Jt,showPluginRecommendation:cn,setShowPluginRecommendation:ge,pluginLayoutInfo:un,applyPluginRecommendation:vt,creating:ee,error:A,info:G,handleCreate:On,engineDetection:ne,refreshEngineDetection:ie,engine:W,setEngine:re,version:Y,setVersion:ce,versionValid:se,setVersionValid:be,standaloneLocked:s===3}}function ob(){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 RN(){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 cb({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(ob,{}):r.jsx(RN,{}),r.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(i=>r.jsx(cb,{node:i,depth:a+1},i.name))]})}function AN(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 MN({skillName:t,hasEvals:a,isDraft:s}){const i=AN(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(ob,{})}),"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(cb,{node:i})})]})}const ua={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Yd({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 LN({onCreated:t,onCancel:a}){const s=TN({onCreated:t});return r.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[r.jsxs("div",{className:"mb-5",children:[r.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),r.jsx("div",{className:"flex items-center justify-between mt-2",children:r.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Yd,{size:12}),"AI-Assisted"]})}),r.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),r.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[r.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsx(Yd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),r.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:i=>s.setAiPrompt(i.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
|
|
105
|
+
|
|
106
|
+
Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...ua,minHeight:"120px"},onKeyDown:i=>{i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.preventDefault(),s.handleGenerate())}}),r.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&r.jsx(si,{entries:s.aiProgress,isRunning:!0}),s.aiError&&r.jsx("div",{children:s.aiClassifiedError?r.jsx(ic,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):r.jsxs("div",{children:[r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.aiError}),r.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?r.jsx("button",{onClick:s.handleCancelGenerate,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:"var(--surface-3)",color:"var(--text-secondary)",border:"none",cursor:"pointer"},children:"Cancel Generation"}):r.jsxs("button",{onClick:s.handleGenerate,disabled:!s.aiPrompt.trim(),className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:s.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:s.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:s.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[r.jsx(Yd,{size:14}),"Generate"]}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",r.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),r.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(i=>r.jsx("button",{onClick:()=>{s.setSelectedLayout(i.layout),s.setPlugin(i.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===i.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===i.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===i.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:i.label},i.layout))})]}),s.selectedLayout!==3&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),r.jsxs("select",{value:s.plugin,onChange:i=>{s.setPlugin(i.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ua,children:[s.availablePlugins.map(i=>r.jsx("option",{value:i,children:i},i)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&r.jsx("input",{type:"text",value:s.newPlugin,onChange:i=>s.setNewPlugin(Yo(i.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:ua})]}),r.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&r.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),r.jsxs("span",{children:["Plugins detected (",r.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),r.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("input",{type:"text",value:s.name,onChange:i=>s.setName(Yo(i.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ua})]}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("textarea",{value:s.description,onChange:i=>s.setDescription(i.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...ua,minHeight:"72px"}})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsxs("select",{value:s.model,onChange:i=>s.setModel(i.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ua,children:[r.jsx("option",{value:"",children:"Any"}),r.jsx("option",{value:"opus",children:"Opus"}),r.jsx("option",{value:"sonnet",children:"Sonnet"}),r.jsx("option",{value:"haiku",children:"Haiku"})]})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),r.jsx("input",{type:"text",value:s.allowedTools,onChange:i=>s.setAllowedTools(i.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ua})]})]})]}),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(i=>r.jsxs("button",{onClick:()=>s.setBodyViewMode(i),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===i?"var(--surface-4)":"transparent",color:s.bodyViewMode===i?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===i?600:400,border:"none",cursor:"pointer"},children:[i==="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:i==="write"?"Write":"Preview"})]},i))})]}),s.bodyViewMode==="write"?r.jsx("textarea",{value:s.body,onChange:i=>s.setBody(i.target.value),placeholder:`# /my-skill
|
|
107
|
+
|
|
108
|
+
You are an expert at...
|
|
109
|
+
`,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...ua,minHeight:"150px"}}):s.body.trim()?r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:lc(s.body)}}):r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),r.jsx(MN,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function 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 Ps({variant:t,message:a,onRetry:s}){const{setMode:i,setSearch:c}=lr(),[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 zN(t,a){const[s,i]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>i?"minor":"patch"}const DN={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 ub(){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),[v,y]=p.useState(new Set),[b,S]=p.useState(new Map),[k,w]=p.useState(null),[E,T]=p.useState(null),[N,L]=p.useState(!1),_=p.useCallback(async()=>{i(!0);try{const U=await Se.getSkillUpdates();a(U.filter(q=>q.updateAvailable))}catch{a([])}finally{i(!1)}},[]);p.useEffect(()=>{_()},[_]);const D=p.useMemo(()=>t.filter(U=>!U.pinned),[t]),V=p.useCallback(U=>{u(q=>{const X=new Set(q);return X.has(U)?X.delete(U):X.add(U),X})},[]),C=p.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map(U=>U.name)))},[c,D]),B=p.useCallback(()=>{const U=[...c];if(!U.length)return;m(!0),h(new Map(U.map(X=>[X,{skill:X,status:"pending"}])));const q=Se.startBatchUpdate(U);q.addEventListener("progress",X=>{try{const ee=JSON.parse(X.data);h(H=>new Map(H).set(ee.skill,ee))}catch{}}),q.addEventListener("done",X=>{q.close(),m(!1);try{const ee=JSON.parse(X.data);w(`Updated ${ee.updated??0} skills, ${ee.failed??0} failed`),setTimeout(()=>w(null),5e3)}catch{}_()}),q.addEventListener("error",()=>{q.close(),m(!1),w("Batch update failed"),setTimeout(()=>w(null),5e3)})},[c,_]),M=p.useCallback(async U=>{const q=U.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],ee=q[q.length-1];y(H=>new Set(H).add(U.name)),S(H=>{const A=new Map(H);return A.delete(U.name),A});try{const H=await Se.postSkillUpdate(X,ee);if(H.ok)_();else{const A=`Update failed (HTTP ${H.status}): ${H.body}`;S(I=>new Map(I).set(U.name,A)),w(`Couldn't update ${ee} — HTTP ${H.status}`),setTimeout(()=>w(null),5e3)}}catch(H){const A=H instanceof Error?H.message:"Network error";S(I=>new Map(I).set(U.name,A)),w(`Couldn't update ${ee} — ${A}`),setTimeout(()=>w(null),5e3)}finally{y(H=>{const A=new Set(H);return A.delete(U.name),A})}},[_]),$=p.useCallback(async U=>{if(!U.latest)return;const q=U.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],ee=q[q.length-1];L(!0);try{const H=await Se.getVersionDiff(X,ee,U.installed,U.latest);T({skill:U,diff:H})}catch{T(null)}finally{L(!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:[k&&r.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:k}),r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.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:B,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:C,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===D.length&&D.length>0?"var(--accent)":"var(--border-default)",background:c.size===D.length&&D.length>0?"var(--accent)":"transparent"},children:c.size===D.length&&D.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 q=U.name.split("/").pop()||U.name,X=U.latest?zN(U.installed,U.latest):"patch",ee=DN[X],H=!!U.pinned,A=v.has(U.name),I=d.get(U.name),G=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:H?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!H&&V(U.name),disabled:H,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:H?"not-allowed":"pointer"},children:r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:G?"var(--accent)":"var(--border-default)",background:G?"var(--accent)":"transparent",opacity:H?.4:1},children:G&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:q}),H&&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:ee.bg,color:ee.text},children:X})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[U.installed," → ",U.latest||"?",H&&` (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:()=>$(U),className:"btn btn-ghost text-[11px]",disabled:N,children:"View Changes"}),r.jsx("button",{onClick:()=>M(U),disabled:H||A||x,title:H?"Pinned — unpin from CLI to update":"",className:`btn ${H?"btn-ghost":"btn-primary"} text-[11px]`,children:A?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)})}),E&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>T(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:()=>T(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(Wf,{contentDiff:E.diff.contentDiff,fromLabel:E.diff.from,toLabel:E.diff.to,diffSummary:E.diff.diffSummary,renderContext:"inline"})]})})]})}const _N=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:ub},Symbol.toStringTag,{value:"Module"}));function ON(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function BN(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function IN(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 db(t){const{author:a,repoUrl:s}=t,i=IN(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 $N(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function UN(t,a){const s=$N(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 fb(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 y;const v=i??s??"";if(v)try{await((y=navigator.clipboard)==null?void 0:y.writeText(v)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[i,s]);if(d){const v=UN(a,s);return r.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:v,target:"_blank",rel:"noopener noreferrer",title:v,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 pb(t){return t.skill?PN({skill:t.skill}):FN({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function HN(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 PN({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(te.toasts.pathCopied,"info")}catch{mv(te.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.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(li,{version:t.resolvedVersion??t.version??null,source:t.versionSource,pluginName:t.pluginName??null})})]}),r.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(db,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(fb,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(VN,{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:HN(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 VN({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 FN({state:t,isReadOnly:a,onDelete:s}){const{plugin:i,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:x,regressions:m,iterationCount:v}=t,y=Array.from(x.values()).some(T=>T.status==="running"||T.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((T,N)=>T+N.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,w=ON(b),E=BN(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(GN,{}),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"}),y&&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:y,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:y?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:y?.4:1,borderRadius:4},onMouseEnter:T=>{y||(T.currentTarget.style.color="var(--red)")},onMouseLeave:T=>{T.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(WN,{})}),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":""]}),v>0&&r.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",v]}),r.jsx("span",{className:"pill",style:{background:E,color:w},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function GN(){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 WN(){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 da(t){const{title:a,label:s,value:i,subtitle:c,description:u,linkLabel:d,children:h,onClick:x}=t,m=a??s??"",v=typeof x=="function",y=b=>{v&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x==null||x())};return r.jsxs("div",{className:v?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:v?"button":void 0,tabIndex:v?0:void 0,onClick:v?()=>x==null?void 0:x():void 0,onKeyDown:v?y: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:v?"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 qN="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 YN(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:qN}),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:Kd,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Kd,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Kd,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Kd={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function KN(t){return`gh repo create ${t.trim()||"<repo-name>"} --public --source=. --remote=origin --push`}const XN="Add a GitHub remote: `gh repo create --public --source=.` (replace existing origin if needed).";function QN({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 ZN(t={}){const{status:a,loading:s}=By();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(Ky,{remoteUrl:a.githubOrigin??"",provider:t.provider,model:t.model})})]});const i=a.status==="no-git"?KN(t.projectBasename??""):XN;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(QN,{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 JN({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(ib,{plugin:t,skill:a})]}),r.jsxs("section",{"data-testid":"overview-rightrail-credentials",children:[r.jsx(xv,{children:"Credentials"}),r.jsx(kf,{plugin:t,skill:a})]})]})}function eT(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 $s(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 tT(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function nT(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 rT(t){var y,b;const{skill:a,onNavigate:s,activationsCount:i=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(aT(a.homepage)?a.homepage??null:null),x=((y=a.mcpDeps)==null?void 0:y.length)??0,m=((b=a.deps)==null?void 0:b.length)??0,v=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(li,{version:a.resolvedVersion??a.version??null,source:a.versionSource,pluginName:a.pluginName??null}),nT(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(db,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(fb,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",$s(a.lastModified)]}):null]})]}),r.jsx(ZN,{}),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(da,{title:"Benchmark",value:tT(a),subtitle:a.lastBenchmark?$s(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(YN,{onNavigate:s})})}),r.jsx(da,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(da,{title:"Activations",value:i,subtitle:c?`Last: ${$s(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(da,{title:"Last run",value:$s(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(da,{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(da,{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(da,{title:"Size",value:eT(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(da,{title:"Last modified",value:$s(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:[v,r.jsx(JN,{plugin:a.plugin,skill:a.skill})]})}function aT(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function lT({skill:t}){const{onSkillUpdated:a}=lr(),{toast:s}=Jo(),[i,c]=p.useState("idle"),[u,d]=p.useState(null),[h,x]=p.useState(!1),[m,v]=p.useState(null),[y,b]=p.useState(!1),S=p.useRef(null),k=p.useCallback(async()=>{if(!t||i==="updating")return;const N=new AbortController;S.current=N,c("updating"),d(null);try{const L=await Se.postSkillUpdate(t.plugin,t.skill,N.signal);if(L.ok)c("done"),a(t.plugin,t.skill),s({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const _=`Update failed (HTTP ${L.status}): ${L.body}`;c("idle"),d(_),s({message:`Couldn't update ${t.skill} — HTTP ${L.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{k()}}})}}catch(L){if(L instanceof DOMException&&L.name==="AbortError")return;const _=L instanceof Error?L.message:"Network error";c("idle"),d(_),s({message:`Couldn't update ${t.skill} — ${_}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{k()}}})}finally{S.current===N&&(S.current=null)}},[t,i,a,s]);if(p.useEffect(()=>{if(!h||m!=null||!t||!t.latestVersion)return;let N=!1;return b(!0),Se.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(L=>{N||v(L)}).catch(()=>{N||v(null)}).finally(()=>{N||b(!1)}),()=>{N=!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 N;(N=S.current)==null||N.abort()},[]),!t||t.updateAvailable!==!0)return null;const w=t.latestVersion,E=i==="updating"?"Updating…":w?`Update to ${w}`:"Update",T=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:()=>{k()},disabled:T,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:T?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:E}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>x(N=>!N),disabled:T||!w,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&&w&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[y&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!y&&m&&r.jsx(Wf,{contentDiff:m.contentDiff,fromLabel:m.from,toLabel:m.to,diffSummary:m.diffSummary??void 0,renderContext:"inline"}),!y&&!m&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const sT=3e4;function iT({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:i=!1}){const c=lr(),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[,m]=p.useState(0),v=p.useRef(null),y=p.useRef(null),b=`${t}/${a}`,S=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const w=setInterval(()=>m(E=>(E+1)%1e6),250);return()=>clearInterval(w)},[u]),p.useEffect(()=>{if(!u||!S)return;const w=y.current??0;S.receivedAt<w||(v.current&&(clearTimeout(v.current),v.current=null),d(!1),x(!1),y.current=null)},[u,S]),p.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]),s===!1||i)return null;const k=async()=>{if(!u){x(!1),d(!0),y.current=Date.now(),v.current=setTimeout(()=>{d(!1),x(!0),v.current=null,y.current=null},sT);try{await Se.rescanSkill(t,a)}catch{v.current&&(clearTimeout(v.current),v.current=null),d(!1),y.current=null}}};return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx("button",{type:"button","data-testid":"check-now-button",onClick:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&r.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}function oT({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 cT=[{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"}],uT=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"];function dT(t){return typeof t=="string"&&uT.includes(t)}function mb(t){return cT.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":dT(a)?a:"overview"}const fT=new Set(["history","leaderboard","deps"]);function hb(t,a){return!a||new Set(mb(!0).map(i=>i.id)).has(t)||fT.has(t)?t:"overview"}const Dl={run:[{id:"run",label:"Run"},{id:"history",label:"History"},{id:"models",label:"Models"}],activation:[{id:"run",label:"Run"},{id:"history",label:"History"}]};function pT(t){const a=Dl[t];return a&&a.length>0?a[0].id:""}function mT(t,a){const s=Dl[t];if(!s)return"";const c=new URLSearchParams(a).get("sub");return c&&s.some(u=>u.id===c)?c:s[0].id}function Xd(){const{state:t,setMobileView:a}=lr();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 hT(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return xT(t);const{state:a,selectSkill:s,setMode:i,refreshSkills:c}=lr(),[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(Xd,{}),r.jsx(ub,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Xd,{}),r.jsx(LN,{onCreated:async(m,v)=>{i("browse"),await c(),s({plugin:m,skill:v,origin:"source"})},onCancel:()=>i("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(Ps,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(Ps,{variant:"no-skills"}):!a.skillsLoading&&a.skills.length>0&&!a.skills.some(m=>m.scopeV2==="available-project")?r.jsx(Ps,{variant:"no-project-skills"}):r.jsx(Ps,{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(Xd,{}),r.jsx(gT,{skillInfo:x,allSkills:a.skills,onSelectSkill:m=>s(m)})]})}function xT(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return yT();if(t.loadError)return bT(a,t.loadError);const i=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return xb(a,s,t.onDetailTabChange,i)}function gT({skillInfo:t,allSkills:a,onSelectSkill:s}){const[i,c]=p.useState(gv()),[u,d]=p.useState(()=>mT(gv(),typeof window<"u"?window.location.search:""));p.useEffect(()=>{if(!t||!(t.origin==="installed"))return;const m=hb(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(pT(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=Dl[i];m&&u&&u!==m[0].id?x.set("sub",u):x.delete("sub");const v=x.toString(),y=`${window.location.pathname}${v?"?"+v:""}${window.location.hash}`;window.history.replaceState(null,"",y)},[i,u]);const h=p.useMemo(()=>t?xb(t,i,c,u,d,{}):r.jsx(Ps,{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 vT(t,a,s){const i=mb(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 yT(){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 bT(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[pb({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 jT({active:t,sub:a}){return t==="editor"?r.jsx(CE,{}):t==="tests"?r.jsx(LE,{}):t==="run"?a==="history"?r.jsx(uv,{}):a==="models"?r.jsx(dv,{}):r.jsx(WE,{}):t==="activation"?r.jsx(QE,{}):t==="history"?r.jsx(uv,{}):t==="leaderboard"?r.jsx(dv,{}):t==="deps"?r.jsx(wN,{}):t==="versions"?r.jsx(GC,{}):null}function ST({active:t}){const{state:a,dispatch:s}=_n();return p.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function xb(t,a,s,i="",c,u){var y;const d=t.origin==="installed",h=hb(a,d),x=b=>{s==null||s(b)},m=r.jsx(rT,{skill:t,onNavigate:x,repoUrl:t.homepage??null}),v=u!=null?r.jsxs(DC,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(ST,{active:h}),r.jsx(jT,{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:pb({skill:t})}),r.jsx(lT,{skill:t}),t.origin==="installed"&&r.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{children:"This is an installed copy of the skill. Editing, generating tests, and running evals are disabled. Open the source skill to make changes."})]}),t.origin==="installed"&&t.scopeV2!=="available-plugin"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(iT,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),vT(h,s,d),Dl[h]&&r.jsx(oT,{parentTabId:h,tabs:Dl[h],active:i||(((y=Dl[h][0])==null?void 0:y.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:v})]})}function kT(){const{updateCount:t,state:a,dismissUpdateNotification:s}=lr(),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 wT=[{name:te.shortcuts.groupNavigation,items:[{keys:"/",label:te.shortcuts.search},{keys:"j",label:te.shortcuts.moveDown},{keys:"k",label:te.shortcuts.moveUp},{keys:"Enter",label:te.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:te.shortcuts.groupActions,items:[{keys:"⌘K",label:te.shortcuts.openPalette},{keys:"?",label:te.shortcuts.openShortcuts},{keys:"⌘B",label:te.shortcuts.toggleSidebar},{keys:"E",label:te.actions.edit}]},{name:te.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:te.shortcuts.toggleTheme}]}];function CT({open:t,onClose:a,groups:s=wT,title:i=te.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 ET(t){const a=te.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 NT({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??ET(t.skill):[],[t.skill,i]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const y=8,b=220,S=44+x.length*28;let k=t.x,w=t.y;return k+b+y>window.innerWidth&&(k=Math.max(y,t.x-b)),w+S+y>window.innerHeight&&(w=Math.max(y,t.y-S)),{left:k,top:w}},[t.x,t.y,x.length]);p.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var y;(y=c.current)==null||y.focus()}),()=>{var y,b;(b=(y=u.current)==null?void 0:y.focus)==null||b.call(y),u.current=null}},[t.open]);const v=p.useCallback(()=>{if(!t.skill)return;const y=x[d];!y||y.disabled||(s(y.action,t.skill),a())},[x,d,t.skill,s,a]);return p.useEffect(()=>{if(!t.open)return;function y(S){if(S.key==="Escape"){S.preventDefault(),a();return}if(S.key==="ArrowDown"){S.preventDefault(),h(k=>Math.min(k+1,Math.max(x.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(k=>Math.max(k-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),v();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||a())}return window.addEventListener("keydown",y,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",y,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,a,x.length,v]),!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((y,b)=>r.jsx("div",{role:"menuitem","aria-disabled":y.disabled||void 0,title:y.title||void 0,"data-action":y.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{y.disabled||(s(y.action,t.skill),a())},style:{padding:"5px 10px",borderRadius:4,cursor:y.disabled?"default":"pointer",opacity:y.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:y.label},y.action))})}const vv=t=>`${t.plugin}/${t.skill}`;function TT(t){const a=t==null?void 0:t.delayMs,s=t==null?void 0:t.onCommit,i=t==null?void 0:t.onFailure,c=p.useRef(s),u=p.useRef(i);c.current=s,u.current=i;const d=p.useRef(new Map),[,h]=p.useState(0),x=p.useCallback(()=>h(k=>k+1),[]),m=p.useCallback(async k=>{var w,E;try{await Se.deleteSkill(k.skill.plugin,k.skill.skill),(w=c.current)==null||w.call(c,k.skill)}catch(T){(E=u.current)==null||E.call(u,k.skill,T)}finally{d.current.delete(vv(k.skill)),x()}},[x]),v=p.useCallback(k=>{const w=vv(k),E=d.current.get(w);E!=null&&E.timeoutId&&clearTimeout(E.timeoutId);const T={skill:k,timeoutId:null};T.timeoutId=setTimeout(()=>{T.timeoutId=null,m(T)},a),d.current.set(w,T),x()},[a,m,x]),y=p.useCallback(k=>{const w=d.current.get(k);w&&(w.timeoutId&&clearTimeout(w.timeoutId),d.current.delete(k),x())},[x]),b=p.useCallback(async()=>{const k=Array.from(d.current.values());for(const w of k)w.timeoutId&&(clearTimeout(w.timeoutId),w.timeoutId=null);await Promise.all(k.map(w=>m(w)))},[m]),S=p.useCallback(k=>d.current.has(k),[]);return p.useEffect(()=>{const k=()=>{b()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[b]),p.useEffect(()=>{const k=d.current;return()=>{for(const w of k.values())w.timeoutId&&clearTimeout(w.timeoutId);k.clear()}},[]),{enqueueDelete:v,cancelDelete:y,flushPending:b,isPending:S}}const RT={"anthropic-api":{name:te.setupProviders.anthropic.name,description:te.setupProviders.anthropic.description,envVars:te.setupProviders.anthropic.envVars,keyUrl:te.setupProviders.anthropic.keyUrl,learnMoreUrl:te.setupProviders.anthropic.learnMoreUrl},openai:{name:te.setupProviders.openai.name,description:te.setupProviders.openai.description,envVars:te.setupProviders.openai.envVars,keyUrl:te.setupProviders.openai.keyUrl,learnMoreUrl:te.setupProviders.openai.learnMoreUrl},openrouter:{name:te.setupProviders.openrouter.name,description:te.setupProviders.openrouter.description,envVars:te.setupProviders.openrouter.envVars,keyUrl:te.setupProviders.openrouter.keyUrl,learnMoreUrl:te.setupProviders.openrouter.learnMoreUrl},gemini:{name:te.setupProviders.gemini.name,description:te.setupProviders.gemini.description,envVars:te.setupProviders.gemini.envVars,keyUrl:te.setupProviders.gemini.keyUrl,learnMoreUrl:te.setupProviders.gemini.learnMoreUrl},ollama:{name:te.setupProviders.ollama.name,description:te.setupProviders.ollama.description,envVars:te.setupProviders.ollama.envVars,install:[te.setupProviders.ollama.installCmd],start:[te.setupProviders.ollama.startCmd],pullExample:te.setupProviders.ollama.pullExample,learnMoreUrl:te.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:te.setupProviders.lmStudio.name,description:te.setupProviders.lmStudio.description,envVars:te.setupProviders.lmStudio.envVars,install:[te.setupProviders.lmStudio.installCmd],start:[te.setupProviders.lmStudio.startCmd],pullExample:te.setupProviders.lmStudio.pullExample,learnMoreUrl:te.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:te.setupProviders.claudeCode.name,description:te.setupProviders.claudeCode.description,envVars:[],notes:[te.setupProviders.claudeCode.loginHint,te.claudeCodeLabel.compactLabel],learnMoreUrl:te.setupProviders.claudeCode.learnMoreUrl}};function AT(t){return t?RT[t]??null:null}function MT({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=AT(a),u=(c==null?void 0:c.name)??te.setupDrawer.fallbackTitle;return Zo.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":te.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(LT,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(zT,{content:c}):r.jsx(DT,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
|
|
110
|
+
from { transform: translateX(100%); }
|
|
111
|
+
to { transform: translateX(0); }
|
|
112
|
+
}
|
|
113
|
+
@keyframes vskillDrawerBackdropIn {
|
|
114
|
+
from { opacity: 0; }
|
|
115
|
+
to { opacity: 1; }
|
|
116
|
+
}`})]})]}),document.body)}function LT({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:te.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":te.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function zT({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:te.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(_T,{name:i})},i))})]}),t.keyUrl&&r.jsx(OT,{href:t.keyUrl,label:te.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:te.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(Qd,{code:i},`install-${c}`)),(s=t.start)==null?void 0:s.map((i,c)=>r.jsx(Qd,{code:i},`start-${c}`)),t.pullExample&&r.jsx(Qd,{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:[te.setupDrawer.learnMore," →"]})})]})}function DT(){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:te.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:te.setupDrawer.fallbackBody})]})}function _T({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:te.setupDrawer.copy})]})}function Qd({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 OT({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 BT(){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 IT(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 $T({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:i,onSwitch:c,onOpenSetup:u,onClose:d}){const h=p.useRef(null);p.useEffect(()=>{const v=y=>{y.key==="Escape"&&(y.preventDefault(),d())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[d]),p.useEffect(()=>{const v=b=>{h.current&&!h.current.contains(b.target)&&d()},y=setTimeout(()=>{document.addEventListener("mousedown",v)},0);return()=>{clearTimeout(y),document.removeEventListener("mousedown",v)}},[d]);const x=p.useMemo(()=>IT(t),[t]),m=t.find(v=>v.id===s)??t.find(v=>v.id===a)??t[0];return typeof document>"u"?null:Zo.createPortal(r.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":te.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(yv,{}),x.detected.map(v=>v.kind==="aggregate"?r.jsx(HT,{row:v,onFocus:()=>{var y;return i(((y=v.consumers[0])==null?void 0:y.id)??a??"")}},v.key):r.jsx(UT,{agent:v.agent,focused:v.agent.id===s,active:v.agent.id===a,onClick:()=>i(v.agent.id)},v.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:te.scopePicker.notDetectedSubheading}),x.notDetected.map(v=>r.jsx(PT,{agent:v.agent},v.key))]})]}),r.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:m?r.jsx(VT,{agent:m,activeAgentId:a,onSwitch:()=>c(m.id)}):r.jsx(yv,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
|
|
117
|
+
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
118
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
119
|
+
}`})]}),document.body)}function UT({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 HT({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 PT({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 VT({agent:t,activeAgentId:a,onSwitch:s}){const i=t.id===a,c=t.isRemoteOnly===!0,u=i||c,d=i?"Active":c?"Remote-only":te.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":GT(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Lo,{label:te.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Lo,{label:te.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Lo,{label:te.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),r.jsx(Lo,{label:te.scopePicker.statsLastSync,value:t.lastSync?FT(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 Lo({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 yv(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function FT(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 GT(t){switch(t){case"ok":return te.scopePicker.statsHealthOk;case"stale":return te.scopePicker.statsHealthStale;case"missing":return te.scopePicker.statsHealthMissing}}function WT(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 qT({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]),v=p.useMemo(()=>m?m.health==="ok"?"var(--color-ok, #22c55e)":m.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[m]),y=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:v,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($T,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{i(S),y()},onClose:y})]})}const gb="vskill-ccode-banner-dismissed",YT=new Set(["claude-cli","claude-code"]);function KT(){try{return sessionStorage.getItem(gb)==="true"}catch{return!1}}function XT(){try{sessionStorage.setItem(gb,"true")}catch{}}function QT({activeAgentId:t}){const[a,s]=p.useState(()=>KT()),i=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{XT(),s(!0)},[]);return!t||!YT.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:[te.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:te.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 ZT(){const[t,a]=p.useState(null),[s,i]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const h=await Se.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 zo="workspace",JT=["skills","agents"];async function eR(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function tR(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 nR(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 rR(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 Zd(){for(const t of JT)Ln(t)}function aR(){const{data:t,loading:a,error:s,revalidate:i}=$l(zo,eR),c=t,u=c==null?void 0:c.projects.find(m=>m.id===c.activeProjectId),d=p.useCallback(async m=>{await tR(m),Ln(zo),Zd()},[]),h=p.useCallback(async m=>{await nR(m),Ln(zo),Zd()},[]),x=p.useCallback(async m=>{await rR(m),Ln(zo),Zd()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:x,revalidate:i}}function lR({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,v]=p.useState(""),[y,b]=p.useState(null),[S,k]=p.useState(null),[w,E]=p.useState(null),[T,N]=p.useState(!1),L=p.useRef(null),_=(t==null?void 0:t.projects)??[],D=_.find(M=>M.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function M($){L.current&&!L.current.contains($.target)&&(d(!1),x(!1),b(null))}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[u]);async function V(){b(null);const M=m.trim();if(!M){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!M.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(M)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:M}),v(""),x(!1)}catch($){const U=$ instanceof Error?$.message:String($);/does not exist/i.test(U)?b(`Path not found on disk: ${M}`):/Duplicate/i.test(U)?b("That project is already registered."):b(U)}}async function C(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const M=await window.showDirectoryPicker();v(M.name),x(!0)}catch{}else x(!0)}function B(M){if(M.length<=50)return M;const $=M.split("/");return $.length<=4?M:`${$.slice(0,3).join("/")}/…/${$.slice(-2).join("/")}`}return r.jsxs("div",{ref:L,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(M=>!M),"aria-expanded":u,"aria-haspopup":"menu",title:(D==null?void 0:D.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:(D==null?void 0:D.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D?D.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(M=>{const $=c?c(M.path):!1,U=M.id===(t==null?void 0:t.activeProjectId),q=S===M.id;return r.jsxs("li",{role:"menuitem","data-stale":$?"true":"false",onMouseEnter:()=>k(M.id),onMouseLeave:()=>k(X=>X===M.id?null:X),onClick:()=>{if(!$){if(U){d(!1);return}E(M)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:$?"not-allowed":"pointer",background:q&&!$?"var(--surface-2, rgba(0,0,0,0.04))":U?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:$?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:M.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:M.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:M.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B(M.path)}),$&&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 ${M.name}`,onClick:X=>{X.stopPropagation(),i(M.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},M.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 C(),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:M=>{M.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:M=>{M.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:M=>v(M.target.value),onKeyDown:M=>{M.key==="Enter"&&V(),M.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),v("")},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 V(),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"})]}),y&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:y})]})]})]}),w&&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:()=>E(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:M=>M.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 ",w.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 "${w.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 "${w.path}" && npx vskill@latest studio`),N(!0),setTimeout(()=>N(!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:T?"Copied!":"Copy command"}),r.jsx("button",{type:"button",onClick:()=>E(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 sR(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 iR({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=p.useState(""),[d,h]=p.useState(0),x=p.useMemo(()=>sR(a,c),[a,c]);p.useEffect(()=>{t||(u(""),h(0))},[t]),p.useEffect(()=>{d>=x.length&&h(0)},[x.length,d]);const m=v=>{if(v.key==="Escape"){v.preventDefault(),i();return}if(v.key==="ArrowDown"){v.preventDefault(),h(y=>Math.min(y+1,Math.max(x.length-1,0)));return}if(v.key==="ArrowUp"){v.preventDefault(),h(y=>Math.max(y-1,0));return}if(v.key==="Enter"){v.preventDefault();const y=x[d];y&&(s(y.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:v=>u(v.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((v,y)=>r.jsxs("li",{role:"option","aria-selected":y===d,"data-highlighted":y===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",y===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(y),onClick:()=>{s(v.id),i()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:v.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:v.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:v.path})]})]},v.id))]})]})]}):null}const bv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function oR({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,h]=p.useState("destination"),[x,m]=p.useState(s),[v,y]=p.useState(""),[b,S]=p.useState(""),[k,w]=p.useState(""),[E,T]=p.useState([]),[N,L]=p.useState(!1),[_,D]=p.useState(null);if(p.useEffect(()=>{t&&(h("destination"),m(s),y(""),S(""),w(""),D(null))},[t,s]),p.useEffect(()=>{if(!t)return;let H=!0;return fetch("/api/authoring/plugins").then(A=>A.json()).then(A=>{H&&T(A.plugins??[])}).catch(()=>{}),()=>{H=!1}},[t]),p.useEffect(()=>{if(!t)return;function H(A){A.key==="Escape"&&(A.preventDefault(),a())}return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[t,a]),!t)return null;const V=E.length>0,C=i&&V,B=i,M=bv.test(v),$=x==="existing-plugin"?b.length>0:bv.test(b),U=!N&&M&&(x==="standalone"||$),q=cR(c,x,b,v);async function X(){D(null),L(!0);try{const I=new URLSearchParams;I.set("mode",x),I.set("skillName",v),b&&I.set("pluginName",b);const G=await fetch(`/api/authoring/skill-exists?${I.toString()}`),O=await G.json();if(!G.ok){D(O.error??`Check failed: ${G.status}`);return}if(O.exists){D(`Skill '${v}' already exists${O.path?` at ${O.path}`:""}`);return}}catch(I){D(I instanceof Error?I.message:String(I));return}finally{L(!1)}const H=new URLSearchParams;H.set("mode",x),H.set("skillName",v),k.trim()&&H.set("description",k.trim()),b&&H.set("pluginName",b);const A=`#/create?${H.toString()}`;typeof window<"u"&&(window.location.hash=A),a()}async function ee(){D(null),L(!0);try{const H=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,skillName:v,description:k.trim()||void 0,pluginName:x==="standalone"?void 0:b})}),A=await H.json();if(!H.ok||!A.ok){D(A.error??`Create failed: ${H.status}`);return}Ln("skills"),u==null||u({mode:x,skillName:v,pluginName:A.pluginName??null,skillMdPath:A.skillMdPath}),a()}catch(H){D(H instanceof Error?H.message:String(H))}finally{L(!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(Jd,{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(Jd,{title:"Add to existing plugin",subtitle:C?`${E.length} plugin source${E.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:!C,selected:x==="existing-plugin",onClick:()=>C&&m("existing-plugin")}),r.jsx(Jd,{title:"New plugin",subtitle:B?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!B,selected:x==="new-plugin",onClick:()=>B&&m("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[x==="new-plugin"&&r.jsx(Do,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:H=>S(H.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:_o(!b||$)})}),x==="existing-plugin"&&r.jsx(Do,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:H=>S(H.target.value),style:{..._o(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),E.map(H=>r.jsx("option",{value:H.name,children:H.name},H.path))]})}),r.jsx(Do,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:v,onChange:H=>y(H.target.value.trim()),placeholder:"my-new-skill",autoFocus:x!=="new-plugin",style:_o(!v||M)})}),r.jsx(Do,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:k,onChange:H=>w(H.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{..._o(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map((H,A)=>r.jsx("div",{children:H},A))]}),_&&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:ef,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:jv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:ef,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!U,style:{...ef,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 ee(),disabled:!U,style:{...jv,opacity:U?1:.5,cursor:U?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:N?"Creating…":"Create empty scaffold"})]})]})]})]})}function Jd({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 Do({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 _o(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 jv={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"},ef={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 cR(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 vb(t){return t.trim().toLowerCase()}function uR(t,a){const s=vb(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function dR(t,a){const s=vb(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function fR({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=p.useState(null),[h,x]=p.useState([]),[m,v]=p.useState(null),[y,b]=p.useState(null),[S,k]=p.useState(!1),[w,E]=p.useState(null),[T,N]=p.useState(""),[L,_]=p.useState("");p.useEffect(()=>{m?N(""):_("")},[m]);const D=p.useMemo(()=>uR(h,T),[h,T]),V=p.useMemo(()=>dR((y==null?void 0:y.plugins)??[],L),[y,L]);return p.useEffect(()=>{t&&(k(!0),E(null),fetch("/api/plugins/marketplaces").then(C=>C.json()).then(C=>{if(C.error)throw new Error(C.error);x(C.marketplaces??[])}).catch(C=>E(C instanceof Error?C.message:String(C))).finally(()=>k(!1)))},[t]),p.useEffect(()=>{if(!m){b(null);return}k(!0),E(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(m)}`).then(C=>C.json()).then(C=>{if(C.error)throw new Error(C.error);b(C)}).catch(C=>E(C instanceof Error?C.message:String(C))).finally(()=>k(!1))},[m]),p.useEffect(()=>{if(!t)return;function C(B){B.key==="Escape"&&a()}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[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:()=>v(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?(y==null?void 0:y.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…"}),w&&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:w}),!m&&!S&&h.length===0&&!w&&r.jsx(pR,{}),!m&&h.length>0&&r.jsx(Sv,{value:T,onChange:N,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!m&&h.length>0&&D.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",T,"”."]}),!m&&D.map(C=>r.jsxs("button",{type:"button",onClick:()=>v(C.name),style:hR,onMouseEnter:B=>{B.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:C.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.source})]},C.name)),m&&y&&r.jsxs(r.Fragment,{children:[y.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:y.description}),y.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),y.plugins.length>0&&r.jsx(Sv,{value:L,onChange:_,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),y.plugins.length>0&&V.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",L,"”."]}),V.map(C=>{const B=c.has(C.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:[C.name,C.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:C.version}),C.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:C.category})]}),C.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:C.description})]}),B&&i?r.jsx("button",{type:"button",disabled:u===C.name,onClick:async()=>{d(C.name);try{await i(C.name)}finally{d(null)}},"aria-label":`Uninstall ${C.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===C.name?"wait":"pointer",opacity:u===C.name?.6:1,fontFamily:"inherit"},children:u===C.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:B,onClick:()=>s(C.name,m),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:B?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:B?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:B?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:B?"default":"pointer",fontFamily:"inherit",boxShadow:B?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:B?"Installed":"Install"})]})},C.name)})]})]}),!m&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(mR,{onAdded:()=>{Ln("marketplaces"),fetch("/api/plugins/marketplaces").then(C=>C.json()).then(C=>x(C.marketplaces??[]))}})})]})]}):null}function Sv({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 pR(){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 mR({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})}),v=await m.json().catch(()=>({}));if(!m.ok||!v.ok){d(v.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 hR={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},tf=12;function xR({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 y=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:y.signal});if(!k.ok||!k.body){u("failed"),a({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const w=k.body.getReader(),E=new TextDecoder;let T="";for(;;){const{value:N,done:L}=await w.read();if(L)break;T+=E.decode(N,{stream:!0});const _=T.split(/\n\n/);T=_.pop()??"";for(const D of _){const V=D.match(/^data:\s*(.*)$/m);if(V)try{const C=JSON.parse(V[1]);C.type==="stdout"&&C.line?(b=[...b,C.line].slice(-tf),i(b)):C.type==="stderr"&&C.line?(b=[...b,`⚠ ${C.line}`].slice(-tf),i(b)):C.type==="done"?(S=C.ok?"ok":"failed",u(S),ny(),Ln("skills"),a({ok:C.ok??!1,code:C.code??null,lines:b})):C.type==="error"&&C.error&&(b=[...b,`✘ ${C.error}`].slice(-tf),i(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>y.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"?"✘":"…",v=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(y=>!y),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(gR,{}):m}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[v,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
|
|
120
|
+
`)})]})}function gR(){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 vR=3e3,yR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function kv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function bR(){const{toast:t}=Jo(),a=p.useRef(new Map),s=p.useCallback(i=>{if(!kv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<vR)return;a.current.set(i.provider,c);const d=yR[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||!kv(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 yb="vskill.studio.prefs";function bb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function jb(){const t=bb();if(!t)return{};try{const a=t.getItem(yb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function jR(t,a){const s=bb();if(s)try{const c={...jb(),[t]:a};s.setItem(yb,JSON.stringify(c))}catch{}}function SR(t,a){const i=jb()[t];return i===void 0?a:i}const wv={open:!1,x:0,y:0,skill:null};function kR(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function Oa(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function wR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function CR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{Oa(te.toasts.permissionDenied,"error");return}Oa(te.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Oa(te.actions.editPlaceholder,"info");return;case"run-benchmark":Oa(te.toasts.benchmarkQueued,"info");return;case"duplicate":Oa(te.toasts.skillDuplicated,"info");return;case"update":Oa(te.toasts.skillUpdated,"info");return;case"uninstall":Oa(te.actions.editPlaceholder,"info");return;case"delete":wR(a);return;default:return}}function ER(t){return t.startsWith("#/create")}function NR(t){return t.startsWith("#/updates")}function Sb(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 TR(){return Sb(ER)}function RR(){return Sb(NR)}function AR(){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+Shift+K"}function MR(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function LR(){const[t,a]=p.useState("⌘⇧K");p.useEffect(()=>{a(AR())},[]);const s=MR();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 zR=p.lazy(()=>Ha(()=>import("./CommandPalette-D42KauW9.js"),__vite__mapDeps([2,1]))),DR=p.lazy(()=>Ha(()=>import("./FindSkillsPalette-BtyebylE.js"),__vite__mapDeps([3,1])).then(t=>({default:t.FindSkillsPalette}))),_R=p.lazy(()=>Ha(()=>import("./SkillDetailPanel-8XS9hdR_.js"),__vite__mapDeps([4,5,1])).then(t=>({default:t.SkillDetailPanel}))),OR=p.lazy(()=>Ha(()=>import("./CreateSkillPage-BWoyQQ0n.js"),__vite__mapDeps([6,1])).then(t=>({default:t.CreateSkillPage}))),BR=p.lazy(()=>Ha(()=>Promise.resolve().then(()=>_N),void 0).then(t=>({default:t.UpdatesPanel})));function IR(){return r.jsx(WS,{children:r.jsx(VS,{children:r.jsxs(F2,{children:[r.jsx($R,{}),r.jsx(kT,{})]})})})}function $R(){var De,We;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=lr(),{config:h}=Pa(),{mode:x,resolvedTheme:m,setTheme:v}=ty(),{toast:y}=Jo(),[b,S]=p.useState(()=>yC()),[k]=p.useState(!0),[w,E]=p.useState(!1),[T,N]=p.useState(!1),[L,_]=p.useState(!1),[D,V]=p.useState("overview"),[C,B]=p.useState(wv),M=p.useCallback((ue,we)=>{B(kR(ue,we))},[]),$=ZT(),[U,q]=p.useState(()=>SR("activeAgent",null)),X=p.useCallback(ue=>{q(ue),jR("activeAgent",ue),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ue}}))},[]);p.useEffect(()=>{var ue;!U&&((ue=$.response)!=null&&ue.suggested)&&X($.response.suggested)},[U,(De=$.response)==null?void 0:De.suggested,X]);const ee=p.useMemo(()=>$.response?WT($.response):[],[$.response]),{workspace:H,switchProject:A,addProject:I,removeProject:G,activeProject:O}=aR(),[ne,z]=p.useState(!1),[W,re]=p.useState(!1),[Y,ce]=p.useState("standalone"),se=p.useCallback((ue="standalone")=>{ce(ue),re(!0)},[]);p.useEffect(()=>{function ue(we){if(!(we instanceof CustomEvent))return;const Le=we.detail;se((Le==null?void 0:Le.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ue),()=>window.removeEventListener("studio:request-create-skill",ue)},[se]);const[be,ie]=p.useState(!1),[ye,Re]=p.useState(null),[Ae,le]=p.useState(null);p.useEffect(()=>{function ue(){ie(!0)}return window.addEventListener("studio:open-marketplace",ue),()=>window.removeEventListener("studio:open-marketplace",ue)},[]);const he=p.useMemo(()=>{const ue=new Set;for(const we of t.skills)we.source==="plugin"&&we.pluginName&&ue.add(we.pluginName);return ue},[t.skills]);hf([{key:"p",meta:!0,handler:ue=>{var Le;const we=typeof document<"u"?document.activeElement:null;we&&we.tagName==="INPUT"||((Le=ue==null?void 0:ue.preventDefault)==null||Le.call(ue),z(Bt=>!Bt))}}],{enabled:!0});const pe=BT(),xe=pe.open;p.useEffect(()=>{function ue(we){if(!(we instanceof CustomEvent))return;const Le=we.detail;Le!=null&&Le.provider&&xe(Le.provider)}return window.addEventListener("studio:open-setup-drawer",ue),()=>window.removeEventListener("studio:open-setup-drawer",ue)},[xe]);const je=p.useCallback(()=>{B(wv)},[]);p.useEffect(()=>{function ue(we){if(!(we instanceof CustomEvent))return;const Le=we.detail;Le!=null&&Le.message&&y({message:Le.message,severity:Le.severity??"info"})}return window.addEventListener("studio:toast",ue),()=>window.removeEventListener("studio:toast",ue)},[y]),bR();const[Be,Ie]=p.useState(!1),[Nt,Vt]=p.useState(void 0);p.useEffect(()=>{function ue(we){if(!(we instanceof CustomEvent))return;const Le=we.detail;Vt(Le==null?void 0:Le.provider),Ie(!0)}return window.addEventListener("studio:open-settings",ue),()=>window.removeEventListener("studio:open-settings",ue)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]),p.useEffect(()=>{function ue(){i()}return window.addEventListener("studio:content-saved",ue),()=>window.removeEventListener("studio:content-saved",ue)},[i]);const[ut,Et]=p.useState(null),[Ft,qe]=p.useState(()=>new Set),dt=p.useRef(!1),Jt=p.useMemo(()=>Qw(),[]),Kt=p.useCallback(ue=>`${ue.plugin}/${ue.skill}`,[]),cn=p.useCallback(ue=>{qe(we=>{const Le=new Set(we);return Le.add(Kt(ue)),Le})},[Kt]),ge=p.useCallback(ue=>{qe(we=>{const Le=new Set(we);return Le.delete(Kt(ue)),Le})},[Kt]),tt=TT({delayMs:1e4,onCommit:ue=>{i(),ge(ue)},onFailure:(ue,we)=>{ge(ue),y({message:`Couldn't delete ${ue.skill}: ${we.message}`,severity:"error",durationMs:0,action:{label:te.actions.retry,onInvoke:()=>{cn(ue),tt.enqueueDelete(ue)}}})}});p.useEffect(()=>{function ue(we){if(!(we instanceof CustomEvent))return;const Le=we.detail;Le!=null&&Le.skill&&Et(Le.skill)}return window.addEventListener("studio:request-delete",ue),()=>window.removeEventListener("studio:request-delete",ue)},[]);const ft=p.useCallback(()=>{const ue=ut;if(Et(null),!ue)return;const we={plugin:ue.plugin,skill:ue.skill};cn(we),tt.enqueueDelete(we);const Le=dt.current?"":`Sent to your ${Jt}. Open Trash to restore. `;dt.current=!0,y({message:`${Le}Deleted ${ue.skill}`,severity:"info",durationMs:1e4,action:{label:te.actions.undo,onInvoke:()=>{tt.cancelDelete(Kt(we)),ge(we)}}})},[ut,cn,ge,tt,y,Jt,Kt]),Lt=p.useCallback(()=>{Et(null)},[]),Tt=p.useMemo(()=>t.skills.filter(ue=>!Ft.has(Kt(ue))),[t.skills,Ft,Kt]),Ze=NC(Tt,(O==null?void 0:O.path)??null),xn=p.useMemo(()=>t.selectedSkill?t.skills.find(ue=>ue.plugin===t.selectedSkill.plugin&&ue.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Ot=p.useCallback(ue=>{a({plugin:ue.plugin,skill:ue.skill,origin:ue.origin})},[a]),un=p.useMemo(()=>{if(!t.selectedSkill)return"";const ue=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ue})`},[t.selectedSkill]),dn=p.useMemo(()=>[{id:"switch-theme",label:te.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>v(x==="light"?"dark":x==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>_(ue=>!ue)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>N(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>i()}],[x,v,i]),[Qn,gn]=p.useState(null);hf([{key:"cmd+k",handler:()=>E(ue=>!ue)},{key:"ctrl+k",handler:()=>E(ue=>!ue)},{key:"cmd+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>N(ue=>!ue)},{key:"cmd+shift+d",handler:()=>v(m==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>v(m==="light"?"dark":"light")},{key:"cmd+b",handler:()=>_(ue=>!ue)},{key:"ctrl+b",handler:()=>_(ue=>!ue)},{key:"e",handler:()=>y({message:te.actions.editPlaceholder,severity:"info"})}]);const Zn=TR(),vt=RR()?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(BR,{})}):Zn?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(OR,{})}):r.jsx(hT,{selectedSkillInfo:xn,activeDetailTab:D,onDetailTabChange:V,allSkills:t.skills,onSelectSkill:Ot});return r.jsxs(r.Fragment,{children:[r.jsx(qS,{sidebarWidth:b,sidebarHidden:L||t.isMobile&&t.mobileView==="detail",banner:r.jsx(TC,{connected:k}),liveMessage:un,topRail:r.jsx(Y2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>E(!0),onHome:s,onRequestCreateSkill:()=>se("standalone"),projectPickerSlot:H&&H.projects.length>0?r.jsx(lR,{workspace:H,onSwitch:A,onAdd:I,onRemove:G}):void 0,findSkillsSlot:r.jsx(LR,{})}),sidebar:r.jsx(dC,{skills:Tt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Ot,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:M,outdatedByOrigin:c,activeAgentId:U,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:Ze,topSlot:$.status==="ready"&&ee.length>0?r.jsxs(r.Fragment,{children:[r.jsx(qT,{agents:ee,activeAgentId:U,onActiveAgentChange:X,onOpenSetup:ue=>pe.open(ue)}),r.jsx(QT,{activeAgentId:U})]}):null}),resizeHandle:r.jsx(jC,{initialWidth:b??Gs,onChange:S}),main:vt,statusBar:r.jsx(lk,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(We=h==null?void 0:h.providers)==null?void 0:We.map(ue=>{const we=ue.id;return{id:we,label:ue.label,available:ue.available,kind:we==="ollama"||we==="lm-studio"?"start-service":we==="anthropic"||we==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(CT,{open:T,onClose:()=>N(!1)}),r.jsx(MT,{open:pe.isOpen,providerKey:pe.providerKey,onClose:pe.close}),r.jsx(NT,{state:C,onClose:je,onAction:(ue,we)=>CR(ue,we)}),w&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(zR,{open:w,onClose:()=>E(!1),commands:dn})}),r.jsx(p.Suspense,{fallback:null,children:r.jsx(DR,{onSelect:ue=>{const we=ue.name.split("/");we.length===3&&gn({owner:we[0],repo:we[1],slug:we[2],displayName:ue.displayName??ue.name})}})}),Qn&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(_R,{selectedSkill:Qn,onClose:()=>gn(null)})}),r.jsx(iR,{open:ne,projects:(H==null?void 0:H.projects)??[],onSwitch:ue=>{A(ue)},onClose:()=>z(!1)}),r.jsx(oR,{open:W,onClose:()=>re(!1),initialMode:Y,isClaudeCode:U==="claude-code",projectRoot:(O==null?void 0:O.path)??(h==null?void 0:h.projectName)??"",onCreated:ue=>{i(),setTimeout(()=>{u(ue.pluginName??"",ue.skillName)},500)}}),r.jsx(fR,{open:be,onClose:()=>ie(!1),installedNames:he,onInstall:(ue,we)=>{Re({plugin:ue,marketplace:we,ref:`${ue}@${we}`}),ie(!1)},onUninstall:async ue=>{if(await new Promise(Le=>{le({plugin:ue,resolve:Le})}))try{const Le=await fetch(`/api/plugins/${encodeURIComponent(ue)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Bt=await Le.json().catch(()=>({}));if(!Le.ok||!Bt.ok){y({message:Bt.error??`Uninstall failed (${Le.status})`,severity:"error"});return}const Pl=Bt.fallback==="orphan-cache-removed"?`Removed orphaned ${ue}.`:`Uninstalled ${ue}.`;y({message:Pl,severity:"success"}),i()}catch(Le){y({message:Le instanceof Error?Le.message:String(Le),severity:"error"})}}}),r.jsx(Qv,{open:Be,onClose:()=>Ie(!1),initialProvider:Nt,onToast:ue=>y({message:ue,severity:"info"})}),r.jsx(xR,{job:ye,onDone:ue=>{ue.ok&&(i(),setTimeout(()=>Re(null),3e3))}}),r.jsx(mf,{open:ut!==null,title:ut?`Delete "${ut.skill}"?`:"",body:`It will be sent to your ${Jt}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:ft,onCancel:Lt}),r.jsx(mf,{open:Ae!==null,title:Ae?`Uninstall ${Ae.plugin}?`:"",body:Ae?`This removes the ${Ae.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ae==null||Ae.resolve(!0),le(null)},onCancel:()=>{Ae==null||Ae.resolve(!1),le(null)}})]})}const Cv="vskill.migrations.scope-rename.v1",UR={own:"authoring-project",installed:"available-project",global:"available-personal"},HR=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function PR(t){if(t.getItem(Cv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(HR);if(!c)continue;const[,u,d]=c,h=UR[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(Cv,"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{PR(window.localStorage)}catch{}U0.createRoot(document.getElementById("root")).render(r.jsx(p.StrictMode,{children:r.jsx(iS,{children:r.jsx(ek,{children:r.jsx(IR,{})})})}));export{ic as E,Fv as L,si as P,Ne as R,MN as S,FR as T,Ha as _,Pa as a,jb as b,TN as c,lc as d,Jo as e,lr as f,SR as g,Se as h,Fy as i,r as j,p as r,te as s,Yo as t,Sj as u,jR as w};
|