vskill 0.5.124 → 0.5.126

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-Dw9BDVCE.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-DVR-q8QQ.js","assets/CreateSkillPage-CZUWGR8T.js"])))=>i.map(i=>d[i]);
2
- /* empty css */(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function sv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var cd={exports:{}},Ts={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-BsAm4uMW.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-CBrGufxz.js","assets/FindSkillsPalette-D99SoJx3.js","assets/SkillDetailPanel-DzmlOsAc.js","assets/skill-url-lxDpBkBU.js","assets/CreateSkillPage-DXrpM1On.js"])))=>i.map(i=>d[i]);
2
+ /* empty css */(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function sv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var cd={exports:{}},As={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
5
5
  *
@@ -7,7 +7,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var Ex;function l0(){if(Ex)return Ts;Ex=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function s(o,c,u){var d=null;if(u!==void 0&&(d=""+u),c.key!==void 0&&(d=""+c.key),"key"in c){u={};for(var h in c)h!=="key"&&(u[h]=c[h])}else u=c;return c=u.ref,{$$typeof:t,type:o,key:d,ref:c!==void 0?c:null,props:u}}return Ts.Fragment=a,Ts.jsx=s,Ts.jsxs=s,Ts}var Nx;function s0(){return Nx||(Nx=1,cd.exports=l0()),cd.exports}var r=s0(),ud={exports:{}},Ie={};/**
10
+ */var Ex;function l0(){if(Ex)return As;Ex=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function s(o,c,u){var d=null;if(u!==void 0&&(d=""+u),c.key!==void 0&&(d=""+c.key),"key"in c){u={};for(var h in c)h!=="key"&&(u[h]=c[h])}else u=c;return c=u.ref,{$$typeof:t,type:o,key:d,ref:c!==void 0?c:null,props:u}}return As.Fragment=a,As.jsx=s,As.jsxs=s,As}var Nx;function s0(){return Nx||(Nx=1,cd.exports=l0()),cd.exports}var r=s0(),ud={exports:{}},Ue={};/**
11
11
  * @license React
12
12
  * react.production.js
13
13
  *
@@ -15,7 +15,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Tx;function i0(){if(Tx)return Ie;Tx=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,C={};function N(M,Y,G){this.props=M,this.context=Y,this.refs=C,this.updater=G||k}N.prototype.isReactComponent={},N.prototype.setState=function(M,Y){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,Y,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function T(){}T.prototype=N.prototype;function A(M,Y,G){this.props=M,this.context=Y,this.refs=C,this.updater=G||k}var B=A.prototype=new T;B.constructor=A,E(B,N.prototype),B.isPureReactComponent=!0;var D=Array.isArray;function F(){}var w={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function z(M,Y,G){var te=G.ref;return{$$typeof:t,type:M,key:Y,ref:te!==void 0?te:null,props:G}}function U(M,Y){return z(M.type,Y,M.props)}function H(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function q(M){var Y={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(G){return Y[G]})}var X=/\/+/g;function J(M,Y){return typeof M=="object"&&M!==null&&M.key!=null?q(""+M.key):Y.toString(36)}function $(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(F,F):(M.status="pending",M.then(function(Y){M.status==="pending"&&(M.status="fulfilled",M.value=Y)},function(Y){M.status==="pending"&&(M.status="rejected",M.reason=Y)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,Y,G,te,fe){var ie=typeof M;(ie==="undefined"||ie==="boolean")&&(M=null);var ye=!1;if(M===null)ye=!0;else switch(ie){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(M.$$typeof){case t:case a:ye=!0;break;case y:return ye=M._init,L(ye(M._payload),Y,G,te,fe)}}if(ye)return fe=fe(M),ye=te===""?"."+J(M,0):te,D(fe)?(G="",ye!=null&&(G=ye.replace(X,"$&/")+"/"),L(fe,Y,G,"",function(Ae){return Ae})):fe!=null&&(H(fe)&&(fe=U(fe,G+(fe.key==null||M&&M.key===fe.key?"":(""+fe.key).replace(X,"$&/")+"/")+ye)),Y.push(fe)),1;ye=0;var de=te===""?".":te+":";if(D(M))for(var Se=0;Se<M.length;Se++)te=M[Se],ie=de+J(te,Se),ye+=L(te,Y,G,ie,fe);else if(Se=S(M),typeof Se=="function")for(M=Se.call(M),Se=0;!(te=M.next()).done;)te=te.value,ie=de+J(te,Se++),ye+=L(te,Y,G,ie,fe);else if(ie==="object"){if(typeof M.then=="function")return L($(M),Y,G,te,fe);throw Y=String(M),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ye}function _(M,Y,G){if(M==null)return M;var te=[],fe=0;return L(M,te,"","",function(ie){return Y.call(G,ie,fe++)}),te}function I(M){if(M._status===-1){var Y=M._result;Y=Y(),Y.then(function(G){(M._status===0||M._status===-1)&&(M._status=1,M._result=G)},function(G){(M._status===0||M._status===-1)&&(M._status=2,M._result=G)}),M._status===-1&&(M._status=0,M._result=Y)}if(M._status===1)return M._result.default;throw M._result}var V=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},se={map:_,forEach:function(M,Y,G){_(M,function(){Y.apply(this,arguments)},G)},count:function(M){var Y=0;return _(M,function(){Y++}),Y},toArray:function(M){return _(M,function(Y){return Y})||[]},only:function(M){if(!H(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ie.Activity=v,Ie.Children=se,Ie.Component=N,Ie.Fragment=s,Ie.Profiler=c,Ie.PureComponent=A,Ie.StrictMode=o,Ie.Suspense=g,Ie.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,Ie.__COMPILER_RUNTIME={__proto__:null,c:function(M){return w.H.useMemoCache(M)}},Ie.cache=function(M){return function(){return M.apply(null,arguments)}},Ie.cacheSignal=function(){return null},Ie.cloneElement=function(M,Y,G){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var te=E({},M.props),fe=M.key;if(Y!=null)for(ie in Y.key!==void 0&&(fe=""+Y.key),Y)!O.call(Y,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&Y.ref===void 0||(te[ie]=Y[ie]);var ie=arguments.length-2;if(ie===1)te.children=G;else if(1<ie){for(var ye=Array(ie),de=0;de<ie;de++)ye[de]=arguments[de+2];te.children=ye}return z(M.type,fe,te)},Ie.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:u,_context:M},M},Ie.createElement=function(M,Y,G){var te,fe={},ie=null;if(Y!=null)for(te in Y.key!==void 0&&(ie=""+Y.key),Y)O.call(Y,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(fe[te]=Y[te]);var ye=arguments.length-2;if(ye===1)fe.children=G;else if(1<ye){for(var de=Array(ye),Se=0;Se<ye;Se++)de[Se]=arguments[Se+2];fe.children=de}if(M&&M.defaultProps)for(te in ye=M.defaultProps,ye)fe[te]===void 0&&(fe[te]=ye[te]);return z(M,ie,fe)},Ie.createRef=function(){return{current:null}},Ie.forwardRef=function(M){return{$$typeof:h,render:M}},Ie.isValidElement=H,Ie.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:I}},Ie.memo=function(M,Y){return{$$typeof:p,type:M,compare:Y===void 0?null:Y}},Ie.startTransition=function(M){var Y=w.T,G={};w.T=G;try{var te=M(),fe=w.S;fe!==null&&fe(G,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(F,V)}catch(ie){V(ie)}finally{Y!==null&&G.types!==null&&(Y.types=G.types),w.T=Y}},Ie.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},Ie.use=function(M){return w.H.use(M)},Ie.useActionState=function(M,Y,G){return w.H.useActionState(M,Y,G)},Ie.useCallback=function(M,Y){return w.H.useCallback(M,Y)},Ie.useContext=function(M){return w.H.useContext(M)},Ie.useDebugValue=function(){},Ie.useDeferredValue=function(M,Y){return w.H.useDeferredValue(M,Y)},Ie.useEffect=function(M,Y){return w.H.useEffect(M,Y)},Ie.useEffectEvent=function(M){return w.H.useEffectEvent(M)},Ie.useId=function(){return w.H.useId()},Ie.useImperativeHandle=function(M,Y,G){return w.H.useImperativeHandle(M,Y,G)},Ie.useInsertionEffect=function(M,Y){return w.H.useInsertionEffect(M,Y)},Ie.useLayoutEffect=function(M,Y){return w.H.useLayoutEffect(M,Y)},Ie.useMemo=function(M,Y){return w.H.useMemo(M,Y)},Ie.useOptimistic=function(M,Y){return w.H.useOptimistic(M,Y)},Ie.useReducer=function(M,Y,G){return w.H.useReducer(M,Y,G)},Ie.useRef=function(M){return w.H.useRef(M)},Ie.useState=function(M){return w.H.useState(M)},Ie.useSyncExternalStore=function(M,Y,G){return w.H.useSyncExternalStore(M,Y,G)},Ie.useTransition=function(){return w.H.useTransition()},Ie.version="19.2.4",Ie}var Rx;function ff(){return Rx||(Rx=1,ud.exports=i0()),ud.exports}var m=ff();const Te=sv(m);var dd={exports:{}},Rs={},fd={exports:{}},pd={};/**
18
+ */var Tx;function i0(){if(Tx)return Ue;Tx=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,C={};function N(M,Y,G){this.props=M,this.context=Y,this.refs=C,this.updater=G||k}N.prototype.isReactComponent={},N.prototype.setState=function(M,Y){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,Y,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function T(){}T.prototype=N.prototype;function A(M,Y,G){this.props=M,this.context=Y,this.refs=C,this.updater=G||k}var B=A.prototype=new T;B.constructor=A,E(B,N.prototype),B.isPureReactComponent=!0;var D=Array.isArray;function F(){}var w={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function z(M,Y,G){var te=G.ref;return{$$typeof:t,type:M,key:Y,ref:te!==void 0?te:null,props:G}}function U(M,Y){return z(M.type,Y,M.props)}function H(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function q(M){var Y={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(G){return Y[G]})}var X=/\/+/g;function J(M,Y){return typeof M=="object"&&M!==null&&M.key!=null?q(""+M.key):Y.toString(36)}function $(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(F,F):(M.status="pending",M.then(function(Y){M.status==="pending"&&(M.status="fulfilled",M.value=Y)},function(Y){M.status==="pending"&&(M.status="rejected",M.reason=Y)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,Y,G,te,fe){var oe=typeof M;(oe==="undefined"||oe==="boolean")&&(M=null);var ve=!1;if(M===null)ve=!0;else switch(oe){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(M.$$typeof){case t:case a:ve=!0;break;case y:return ve=M._init,L(ve(M._payload),Y,G,te,fe)}}if(ve)return fe=fe(M),ve=te===""?"."+J(M,0):te,D(fe)?(G="",ve!=null&&(G=ve.replace(X,"$&/")+"/"),L(fe,Y,G,"",function(Re){return Re})):fe!=null&&(H(fe)&&(fe=U(fe,G+(fe.key==null||M&&M.key===fe.key?"":(""+fe.key).replace(X,"$&/")+"/")+ve)),Y.push(fe)),1;ve=0;var de=te===""?".":te+":";if(D(M))for(var je=0;je<M.length;je++)te=M[je],oe=de+J(te,je),ve+=L(te,Y,G,oe,fe);else if(je=S(M),typeof je=="function")for(M=je.call(M),je=0;!(te=M.next()).done;)te=te.value,oe=de+J(te,je++),ve+=L(te,Y,G,oe,fe);else if(oe==="object"){if(typeof M.then=="function")return L($(M),Y,G,te,fe);throw Y=String(M),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ve}function _(M,Y,G){if(M==null)return M;var te=[],fe=0;return L(M,te,"","",function(oe){return Y.call(G,oe,fe++)}),te}function I(M){if(M._status===-1){var Y=M._result;Y=Y(),Y.then(function(G){(M._status===0||M._status===-1)&&(M._status=1,M._result=G)},function(G){(M._status===0||M._status===-1)&&(M._status=2,M._result=G)}),M._status===-1&&(M._status=0,M._result=Y)}if(M._status===1)return M._result.default;throw M._result}var V=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ie={map:_,forEach:function(M,Y,G){_(M,function(){Y.apply(this,arguments)},G)},count:function(M){var Y=0;return _(M,function(){Y++}),Y},toArray:function(M){return _(M,function(Y){return Y})||[]},only:function(M){if(!H(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ue.Activity=v,Ue.Children=ie,Ue.Component=N,Ue.Fragment=s,Ue.Profiler=c,Ue.PureComponent=A,Ue.StrictMode=o,Ue.Suspense=g,Ue.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,Ue.__COMPILER_RUNTIME={__proto__:null,c:function(M){return w.H.useMemoCache(M)}},Ue.cache=function(M){return function(){return M.apply(null,arguments)}},Ue.cacheSignal=function(){return null},Ue.cloneElement=function(M,Y,G){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var te=E({},M.props),fe=M.key;if(Y!=null)for(oe in Y.key!==void 0&&(fe=""+Y.key),Y)!O.call(Y,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&Y.ref===void 0||(te[oe]=Y[oe]);var oe=arguments.length-2;if(oe===1)te.children=G;else if(1<oe){for(var ve=Array(oe),de=0;de<oe;de++)ve[de]=arguments[de+2];te.children=ve}return z(M.type,fe,te)},Ue.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:u,_context:M},M},Ue.createElement=function(M,Y,G){var te,fe={},oe=null;if(Y!=null)for(te in Y.key!==void 0&&(oe=""+Y.key),Y)O.call(Y,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(fe[te]=Y[te]);var ve=arguments.length-2;if(ve===1)fe.children=G;else if(1<ve){for(var de=Array(ve),je=0;je<ve;je++)de[je]=arguments[je+2];fe.children=de}if(M&&M.defaultProps)for(te in ve=M.defaultProps,ve)fe[te]===void 0&&(fe[te]=ve[te]);return z(M,oe,fe)},Ue.createRef=function(){return{current:null}},Ue.forwardRef=function(M){return{$$typeof:h,render:M}},Ue.isValidElement=H,Ue.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:I}},Ue.memo=function(M,Y){return{$$typeof:m,type:M,compare:Y===void 0?null:Y}},Ue.startTransition=function(M){var Y=w.T,G={};w.T=G;try{var te=M(),fe=w.S;fe!==null&&fe(G,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(F,V)}catch(oe){V(oe)}finally{Y!==null&&G.types!==null&&(Y.types=G.types),w.T=Y}},Ue.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},Ue.use=function(M){return w.H.use(M)},Ue.useActionState=function(M,Y,G){return w.H.useActionState(M,Y,G)},Ue.useCallback=function(M,Y){return w.H.useCallback(M,Y)},Ue.useContext=function(M){return w.H.useContext(M)},Ue.useDebugValue=function(){},Ue.useDeferredValue=function(M,Y){return w.H.useDeferredValue(M,Y)},Ue.useEffect=function(M,Y){return w.H.useEffect(M,Y)},Ue.useEffectEvent=function(M){return w.H.useEffectEvent(M)},Ue.useId=function(){return w.H.useId()},Ue.useImperativeHandle=function(M,Y,G){return w.H.useImperativeHandle(M,Y,G)},Ue.useInsertionEffect=function(M,Y){return w.H.useInsertionEffect(M,Y)},Ue.useLayoutEffect=function(M,Y){return w.H.useLayoutEffect(M,Y)},Ue.useMemo=function(M,Y){return w.H.useMemo(M,Y)},Ue.useOptimistic=function(M,Y){return w.H.useOptimistic(M,Y)},Ue.useReducer=function(M,Y,G){return w.H.useReducer(M,Y,G)},Ue.useRef=function(M){return w.H.useRef(M)},Ue.useState=function(M){return w.H.useState(M)},Ue.useSyncExternalStore=function(M,Y,G){return w.H.useSyncExternalStore(M,Y,G)},Ue.useTransition=function(){return w.H.useTransition()},Ue.version="19.2.4",Ue}var Rx;function ff(){return Rx||(Rx=1,ud.exports=i0()),ud.exports}var p=ff();const Ne=sv(p);var dd={exports:{}},Ms={},fd={exports:{}},pd={};/**
19
19
  * @license React
20
20
  * scheduler.production.js
21
21
  *
@@ -23,7 +23,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
23
23
  *
24
24
  * This source code is licensed under the MIT license found in the
25
25
  * LICENSE file in the root directory of this source tree.
26
- */var Ax;function o0(){return Ax||(Ax=1,(function(t){function a(L,_){var I=L.length;L.push(_);e:for(;0<I;){var V=I-1>>>1,se=L[V];if(0<c(se,_))L[V]=_,L[I]=se,I=V;else break e}}function s(L){return L.length===0?null:L[0]}function o(L){if(L.length===0)return null;var _=L[0],I=L.pop();if(I!==_){L[0]=I;e:for(var V=0,se=L.length,M=se>>>1;V<M;){var Y=2*(V+1)-1,G=L[Y],te=Y+1,fe=L[te];if(0>c(G,I))te<se&&0>c(fe,G)?(L[V]=fe,L[te]=I,V=te):(L[V]=G,L[Y]=I,V=Y);else if(te<se&&0>c(fe,I))L[V]=fe,L[te]=I,V=te;else break e}}return _}function c(L,_){var I=L.sortIndex-_.sortIndex;return I!==0?I:L.id-_.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var g=[],p=[],y=1,v=null,b=3,S=!1,k=!1,E=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function B(L){for(var _=s(p);_!==null;){if(_.callback===null)o(p);else if(_.startTime<=L)o(p),_.sortIndex=_.expirationTime,a(g,_);else break;_=s(p)}}function D(L){if(E=!1,B(L),!k)if(s(g)!==null)k=!0,F||(F=!0,q());else{var _=s(p);_!==null&&$(D,_.startTime-L)}}var F=!1,w=-1,O=5,z=-1;function U(){return C?!0:!(t.unstable_now()-z<O)}function H(){if(C=!1,F){var L=t.unstable_now();z=L;var _=!0;try{e:{k=!1,E&&(E=!1,T(w),w=-1),S=!0;var I=b;try{t:{for(B(L),v=s(g);v!==null&&!(v.expirationTime>L&&U());){var V=v.callback;if(typeof V=="function"){v.callback=null,b=v.priorityLevel;var se=V(v.expirationTime<=L);if(L=t.unstable_now(),typeof se=="function"){v.callback=se,B(L),_=!0;break t}v===s(g)&&o(g),B(L)}else o(g);v=s(g)}if(v!==null)_=!0;else{var M=s(p);M!==null&&$(D,M.startTime-L),_=!1}}break e}finally{v=null,b=I,S=!1}_=void 0}}finally{_?q():F=!1}}}var q;if(typeof A=="function")q=function(){A(H)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,J=X.port2;X.port1.onmessage=H,q=function(){J.postMessage(null)}}else q=function(){N(H,0)};function $(L,_){w=N(function(){L(t.unstable_now())},_)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<L?Math.floor(1e3/L):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(L){switch(b){case 1:case 2:case 3:var _=3;break;default:_=b}var I=b;b=_;try{return L()}finally{b=I}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(L,_){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var I=b;b=L;try{return _()}finally{b=I}},t.unstable_scheduleCallback=function(L,_,I){var V=t.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?V+I:V):I=V,L){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=I+se,L={id:y++,callback:_,priorityLevel:L,startTime:I,expirationTime:se,sortIndex:-1},I>V?(L.sortIndex=I,a(p,L),s(g)===null&&L===s(p)&&(E?(T(w),w=-1):E=!0,$(D,I-V))):(L.sortIndex=se,a(g,L),k||S||(k=!0,F||(F=!0,q()))),L},t.unstable_shouldYield=U,t.unstable_wrapCallback=function(L){var _=b;return function(){var I=b;b=_;try{return L.apply(this,arguments)}finally{b=I}}}})(pd)),pd}var Mx;function c0(){return Mx||(Mx=1,fd.exports=o0()),fd.exports}var md={exports:{}},en={};/**
26
+ */var Ax;function o0(){return Ax||(Ax=1,(function(t){function a(L,_){var I=L.length;L.push(_);e:for(;0<I;){var V=I-1>>>1,ie=L[V];if(0<c(ie,_))L[V]=_,L[I]=ie,I=V;else break e}}function s(L){return L.length===0?null:L[0]}function o(L){if(L.length===0)return null;var _=L[0],I=L.pop();if(I!==_){L[0]=I;e:for(var V=0,ie=L.length,M=ie>>>1;V<M;){var Y=2*(V+1)-1,G=L[Y],te=Y+1,fe=L[te];if(0>c(G,I))te<ie&&0>c(fe,G)?(L[V]=fe,L[te]=I,V=te):(L[V]=G,L[Y]=I,V=Y);else if(te<ie&&0>c(fe,I))L[V]=fe,L[te]=I,V=te;else break e}}return _}function c(L,_){var I=L.sortIndex-_.sortIndex;return I!==0?I:L.id-_.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var g=[],m=[],y=1,v=null,b=3,S=!1,k=!1,E=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function B(L){for(var _=s(m);_!==null;){if(_.callback===null)o(m);else if(_.startTime<=L)o(m),_.sortIndex=_.expirationTime,a(g,_);else break;_=s(m)}}function D(L){if(E=!1,B(L),!k)if(s(g)!==null)k=!0,F||(F=!0,q());else{var _=s(m);_!==null&&$(D,_.startTime-L)}}var F=!1,w=-1,O=5,z=-1;function U(){return C?!0:!(t.unstable_now()-z<O)}function H(){if(C=!1,F){var L=t.unstable_now();z=L;var _=!0;try{e:{k=!1,E&&(E=!1,T(w),w=-1),S=!0;var I=b;try{t:{for(B(L),v=s(g);v!==null&&!(v.expirationTime>L&&U());){var V=v.callback;if(typeof V=="function"){v.callback=null,b=v.priorityLevel;var ie=V(v.expirationTime<=L);if(L=t.unstable_now(),typeof ie=="function"){v.callback=ie,B(L),_=!0;break t}v===s(g)&&o(g),B(L)}else o(g);v=s(g)}if(v!==null)_=!0;else{var M=s(m);M!==null&&$(D,M.startTime-L),_=!1}}break e}finally{v=null,b=I,S=!1}_=void 0}}finally{_?q():F=!1}}}var q;if(typeof A=="function")q=function(){A(H)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,J=X.port2;X.port1.onmessage=H,q=function(){J.postMessage(null)}}else q=function(){N(H,0)};function $(L,_){w=N(function(){L(t.unstable_now())},_)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<L?Math.floor(1e3/L):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(L){switch(b){case 1:case 2:case 3:var _=3;break;default:_=b}var I=b;b=_;try{return L()}finally{b=I}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(L,_){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var I=b;b=L;try{return _()}finally{b=I}},t.unstable_scheduleCallback=function(L,_,I){var V=t.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?V+I:V):I=V,L){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=I+ie,L={id:y++,callback:_,priorityLevel:L,startTime:I,expirationTime:ie,sortIndex:-1},I>V?(L.sortIndex=I,a(m,L),s(g)===null&&L===s(m)&&(E?(T(w),w=-1):E=!0,$(D,I-V))):(L.sortIndex=ie,a(g,L),k||S||(k=!0,F||(F=!0,q()))),L},t.unstable_shouldYield=U,t.unstable_wrapCallback=function(L){var _=b;return function(){var I=b;b=_;try{return L.apply(this,arguments)}finally{b=I}}}})(pd)),pd}var Mx;function c0(){return Mx||(Mx=1,fd.exports=o0()),fd.exports}var md={exports:{}},nn={};/**
27
27
  * @license React
28
28
  * react-dom.production.js
29
29
  *
@@ -31,7 +31,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
31
31
  *
32
32
  * This source code is licensed under the MIT license found in the
33
33
  * LICENSE file in the root directory of this source tree.
34
- */var Lx;function u0(){if(Lx)return en;Lx=1;var t=ff();function a(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var o={d:{f:s,r:function(){throw Error(a(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},c=Symbol.for("react.portal");function u(g,p,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:v==null?null:""+v,children:g,containerInfo:p,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return en.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,en.createPortal=function(g,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(a(299));return u(g,p,null,y)},en.flushSync=function(g){var p=d.T,y=o.p;try{if(d.T=null,o.p=2,g)return g()}finally{d.T=p,o.p=y,o.d.f()}},en.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,o.d.C(g,p))},en.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},en.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,v=h(y,p.crossOrigin),b=typeof p.integrity=="string"?p.integrity:void 0,S=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?o.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):y==="script"&&o.d.X(g,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},en.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=h(p.as,p.crossOrigin);o.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&o.d.M(g)},en.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,v=h(y,p.crossOrigin);o.d.L(g,y,{crossOrigin:v,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},en.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=h(p.as,p.crossOrigin);o.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else o.d.m(g)},en.requestFormReset=function(g){o.d.r(g)},en.unstable_batchedUpdates=function(g,p){return g(p)},en.useFormState=function(g,p,y){return d.H.useFormState(g,p,y)},en.useFormStatus=function(){return d.H.useHostTransitionStatus()},en.version="19.2.4",en}var zx;function iv(){if(zx)return md.exports;zx=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(),md.exports=u0(),md.exports}/**
34
+ */var Lx;function u0(){if(Lx)return nn;Lx=1;var t=ff();function a(g){var m="https://react.dev/errors/"+g;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var o={d:{f:s,r:function(){throw Error(a(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},c=Symbol.for("react.portal");function u(g,m,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:v==null?null:""+v,children:g,containerInfo:m,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,m){if(g==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return nn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,nn.createPortal=function(g,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(a(299));return u(g,m,null,y)},nn.flushSync=function(g){var m=d.T,y=o.p;try{if(d.T=null,o.p=2,g)return g()}finally{d.T=m,o.p=y,o.d.f()}},nn.preconnect=function(g,m){typeof g=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,o.d.C(g,m))},nn.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},nn.preinit=function(g,m){if(typeof g=="string"&&m&&typeof m.as=="string"){var y=m.as,v=h(y,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?o.d.S(g,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):y==="script"&&o.d.X(g,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},nn.preinitModule=function(g,m){if(typeof g=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=h(m.as,m.crossOrigin);o.d.M(g,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&o.d.M(g)},nn.preload=function(g,m){if(typeof g=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,v=h(y,m.crossOrigin);o.d.L(g,y,{crossOrigin:v,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},nn.preloadModule=function(g,m){if(typeof g=="string")if(m){var y=h(m.as,m.crossOrigin);o.d.m(g,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else o.d.m(g)},nn.requestFormReset=function(g){o.d.r(g)},nn.unstable_batchedUpdates=function(g,m){return g(m)},nn.useFormState=function(g,m,y){return d.H.useFormState(g,m,y)},nn.useFormStatus=function(){return d.H.useHostTransitionStatus()},nn.version="19.2.4",nn}var zx;function iv(){if(zx)return md.exports;zx=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(),md.exports=u0(),md.exports}/**
35
35
  * @license React
36
36
  * react-dom-client.production.js
37
37
  *
@@ -39,15 +39,15 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
39
39
  *
40
40
  * This source code is licensed under the MIT license found in the
41
41
  * LICENSE file in the root directory of this source tree.
42
- */var Dx;function d0(){if(Dx)return Rs;Dx=1;var t=c0(),a=ff(),s=iv();function o(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(o(188))}function p(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(o(188));return n!==e?null:e}for(var l=e,i=n;;){var f=l.return;if(f===null)break;var x=f.alternate;if(x===null){if(i=f.return,i!==null){l=i;continue}break}if(f.child===x.child){for(x=f.child;x;){if(x===l)return g(f),e;if(x===i)return g(f),n;x=x.sibling}throw Error(o(188))}if(l.return!==i.return)l=f,i=x;else{for(var j=!1,R=f.child;R;){if(R===l){j=!0,l=f,i=x;break}if(R===i){j=!0,i=f,l=x;break}R=R.sibling}if(!j){for(R=x.child;R;){if(R===l){j=!0,l=x,i=f;break}if(R===i){j=!0,i=x,l=f;break}R=R.sibling}if(!j)throw Error(o(189))}}if(l.alternate!==i)throw Error(o(190))}if(l.tag!==3)throw Error(o(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function q(e){return e===null||typeof e!="object"?null:(e=H&&e[H]||e["@@iterator"],typeof e=="function"?e:null)}var X=Symbol.for("react.client.reference");function J(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===X?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case N:return"Profiler";case C:return"StrictMode";case D:return"Suspense";case F:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case A:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case B:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case w:return n=e.displayName||null,n!==null?n:J(e.type)||"Memo";case O:n=e._payload,e=e._init;try{return J(e(n))}catch{}}return null}var $=Array.isArray,L=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},V=[],se=-1;function M(e){return{current:e}}function Y(e){0>se||(e.current=V[se],V[se]=null,se--)}function G(e,n){se++,V[se]=e.current,e.current=n}var te=M(null),fe=M(null),ie=M(null),ye=M(null);function de(e,n){switch(G(ie,n),G(fe,e),G(te,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Kh(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Kh(n),e=Xh(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Y(te),G(te,e)}function Se(){Y(te),Y(fe),Y(ie)}function Ae(e){e.memoizedState!==null&&G(ye,e);var n=te.current,l=Xh(n,e.type);n!==l&&(G(fe,e),G(te,l))}function _e(e){fe.current===e&&(Y(te),Y(fe)),ye.current===e&&(Y(ye),ws._currentValue=I)}var ae,he;function pe(e){if(ae===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);ae=n&&n[1]||"",he=-1<l.stack.indexOf(`
42
+ */var Dx;function d0(){if(Dx)return Ms;Dx=1;var t=c0(),a=ff(),s=iv();function o(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(o(188))}function m(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(o(188));return n!==e?null:e}for(var l=e,i=n;;){var f=l.return;if(f===null)break;var x=f.alternate;if(x===null){if(i=f.return,i!==null){l=i;continue}break}if(f.child===x.child){for(x=f.child;x;){if(x===l)return g(f),e;if(x===i)return g(f),n;x=x.sibling}throw Error(o(188))}if(l.return!==i.return)l=f,i=x;else{for(var j=!1,R=f.child;R;){if(R===l){j=!0,l=f,i=x;break}if(R===i){j=!0,i=f,l=x;break}R=R.sibling}if(!j){for(R=x.child;R;){if(R===l){j=!0,l=x,i=f;break}if(R===i){j=!0,i=x,l=f;break}R=R.sibling}if(!j)throw Error(o(189))}}if(l.alternate!==i)throw Error(o(190))}if(l.tag!==3)throw Error(o(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function q(e){return e===null||typeof e!="object"?null:(e=H&&e[H]||e["@@iterator"],typeof e=="function"?e:null)}var X=Symbol.for("react.client.reference");function J(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===X?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case N:return"Profiler";case C:return"StrictMode";case D:return"Suspense";case F:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case A:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case B:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case w:return n=e.displayName||null,n!==null?n:J(e.type)||"Memo";case O:n=e._payload,e=e._init;try{return J(e(n))}catch{}}return null}var $=Array.isArray,L=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},V=[],ie=-1;function M(e){return{current:e}}function Y(e){0>ie||(e.current=V[ie],V[ie]=null,ie--)}function G(e,n){ie++,V[ie]=e.current,e.current=n}var te=M(null),fe=M(null),oe=M(null),ve=M(null);function de(e,n){switch(G(oe,n),G(fe,e),G(te,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Kh(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Kh(n),e=Xh(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Y(te),G(te,e)}function je(){Y(te),Y(fe),Y(oe)}function Re(e){e.memoizedState!==null&&G(ve,e);var n=te.current,l=Xh(n,e.type);n!==l&&(G(fe,e),G(te,l))}function _e(e){fe.current===e&&(Y(te),Y(fe)),ve.current===e&&(Y(ve),Es._currentValue=I)}var ae,he;function pe(e){if(ae===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);ae=n&&n[1]||"",he=-1<l.stack.indexOf(`
43
43
  at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
44
- `+ae+e+he}var ge=!1;function je(e,n){if(!e||ge)return"";ge=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(re){var ee=re}Reflect.construct(e,[],ue)}else{try{ue.call()}catch(re){ee=re}e.call(ue.prototype)}}else{try{throw Error()}catch(re){ee=re}(ue=e())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(re){if(re&&ee&&typeof re.stack=="string")return[re.stack,ee.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=i.DetermineComponentFrameRoot(),j=x[0],R=x[1];if(j&&R){var P=j.split(`
44
+ `+ae+e+he}var xe=!1;function be(e,n){if(!e||xe)return"";xe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(re){var ee=re}Reflect.construct(e,[],ue)}else{try{ue.call()}catch(re){ee=re}e.call(ue.prototype)}}else{try{throw Error()}catch(re){ee=re}(ue=e())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(re){if(re&&ee&&typeof re.stack=="string")return[re.stack,ee.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=i.DetermineComponentFrameRoot(),j=x[0],R=x[1];if(j&&R){var P=j.split(`
45
45
  `),Z=R.split(`
46
- `);for(f=i=0;i<P.length&&!P[i].includes("DetermineComponentFrameRoot");)i++;for(;f<Z.length&&!Z[f].includes("DetermineComponentFrameRoot");)f++;if(i===P.length||f===Z.length)for(i=P.length-1,f=Z.length-1;1<=i&&0<=f&&P[i]!==Z[f];)f--;for(;1<=i&&0<=f;i--,f--)if(P[i]!==Z[f]){if(i!==1||f!==1)do if(i--,f--,0>f||P[i]!==Z[f]){var le=`
47
- `+P[i].replace(" at new "," at ");return e.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",e.displayName)),le}while(1<=i&&0<=f);break}}}finally{ge=!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 Oe(e){try{var n="",l=null;do n+=Be(e,l),l=e,e=e.return;while(e);return n}catch(i){return`
46
+ `);for(f=i=0;i<P.length&&!P[i].includes("DetermineComponentFrameRoot");)i++;for(;f<Z.length&&!Z[f].includes("DetermineComponentFrameRoot");)f++;if(i===P.length||f===Z.length)for(i=P.length-1,f=Z.length-1;1<=i&&0<=f&&P[i]!==Z[f];)f--;for(;1<=i&&0<=f;i--,f--)if(P[i]!==Z[f]){if(i!==1||f!==1)do if(i--,f--,0>f||P[i]!==Z[f]){var se=`
47
+ `+P[i].replace(" at new "," at ");return e.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",e.displayName)),se}while(1<=i&&0<=f);break}}}finally{xe=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?pe(l):""}function Be(e,n){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe("Lazy");case 13:return e.child!==n&&n!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return pe("Activity");default:return""}}function Oe(e){try{var n="",l=null;do n+=Be(e,l),l=e,e=e.return;while(e);return n}catch(i){return`
48
48
  Error generating stack: `+i.message+`
49
- `+i.stack}}var at=Object.prototype.hasOwnProperty,Nt=t.unstable_scheduleCallback,ht=t.unstable_cancelCallback,Dt=t.unstable_shouldYield,Tt=t.unstable_requestPaint,Qe=t.unstable_now,tt=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,pt=t.unstable_UserBlockingPriority,Ct=t.unstable_NormalPriority,Yt=t.unstable_LowPriority,un=t.unstable_IdlePriority,Gt=t.log,rn=t.unstable_setDisableYieldValue,Mn=null,Mt=null;function xt(e){if(typeof Gt=="function"&&rn(e),Mt&&typeof Mt.setStrictMode=="function")try{Mt.setStrictMode(Mn,e)}catch{}}var gt=Math.clz32?Math.clz32:Wn,dr=Math.log,zr=Math.LN2;function Wn(e){return e>>>=0,e===0?32:31-(dr(e)/zr|0)|0}var Et=256,oe=262144,xe=4194304;function Ee(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 dn(e,n,l){var i=e.pendingLanes;if(i===0)return 0;var f=0,x=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var R=i&134217727;return R!==0?(i=R&~x,i!==0?f=Ee(i):(j&=R,j!==0?f=Ee(j):l||(l=R&~e,l!==0&&(f=Ee(l))))):(R=i&~x,R!==0?f=Ee(R):j!==0?f=Ee(j):l||(l=i&~e,l!==0&&(f=Ee(l)))),f===0?0:n!==0&&n!==f&&(n&x)===0&&(x=f&-f,l=n&-n,x>=l||x===32&&(l&4194048)!==0)?n:f}function fn(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function ai(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function qn(){var e=xe;return xe<<=1,(xe&62914560)===0&&(xe=4194304),e}function Bl(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function fa(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Il(e,n,l,i,f,x){var j=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var R=e.entanglements,P=e.expirationTimes,Z=e.hiddenUpdates;for(l=j&~l;0<l;){var le=31-gt(l),ue=1<<le;R[le]=0,P[le]=-1;var ee=Z[le];if(ee!==null)for(Z[le]=null,le=0;le<ee.length;le++){var re=ee[le];re!==null&&(re.lane&=-536870913)}l&=~ue}i!==0&&tr(e,i,0),x!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=x&~(j&~n))}function tr(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var i=31-gt(n);e.entangledLanes|=n,e.entanglements[i]=e.entanglements[i]|1073741824|l&261930}function pa(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var i=31-gt(l),f=1<<i;f&n|e[i]&n&&(e[i]|=n),l&=~f}}function ma(e,n){var l=n&-n;return l=(l&42)!==0?1:Pa(l),(l&(e.suspendedLanes|n))!==0?0:l}function Pa(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Dr(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function it(){var e=_.p;return e!==0?e:(e=window.event,e===void 0?32:yx(e.type))}function ha(e,n){var l=_.p;try{return _.p=e,n()}finally{_.p=l}}var an=Math.random().toString(36).slice(2),Ht="__reactFiber$"+an,ot="__reactProps$"+an,xa="__reactContainer$"+an,nr="__reactEvents$"+an,ec="__reactListeners$"+an,Ky="__reactHandles$"+an,Of="__reactResources$"+an,Ul="__reactMarker$"+an;function tc(e){delete e[Ht],delete e[ot],delete e[nr],delete e[ec],delete e[Ky]}function Fa(e){var n=e[Ht];if(n)return n;for(var l=e.parentNode;l;){if(n=l[xa]||l[Ht]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=rx(e);e!==null;){if(l=e[Ht])return l;e=rx(e)}return n}e=l,l=e.parentNode}return null}function Ga(e){if(e=e[Ht]||e[xa]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Hl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(o(33))}function Wa(e){var n=e[Of];return n||(n=e[Of]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Wt(e){e[Ul]=!0}var Bf=new Set,If={};function ga(e,n){qa(e,n),qa(e+"Capture",n)}function qa(e,n){for(If[e]=n,e=0;e<n.length;e++)Bf.add(n[e])}var Xy=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]*$"),Uf={},Hf={};function Qy(e){return at.call(Hf,e)?!0:at.call(Uf,e)?!1:Xy.test(e)?Hf[e]=!0:(Uf[e]=!0,!1)}function li(e,n,l){if(Qy(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var i=n.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function si(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function fr(e,n,l,i){if(i===null)e.removeAttribute(l);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+i)}}function Ln(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function $f(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Zy(e,n,l){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,x=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(j){l=""+j,x.call(this,j)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(j){l=""+j},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function nc(e){if(!e._valueTracker){var n=$f(e)?"checked":"value";e._valueTracker=Zy(e,n,""+e[n])}}function Vf(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),i="";return e&&(i=$f(e)?e.checked?"true":"false":e.value),e=i,e!==l?(n.setValue(e),!0):!1}function ii(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Jy=/[\n"\\]/g;function zn(e){return e.replace(Jy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function rc(e,n,l,i,f,x,j,R){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),n!=null?j==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Ln(n)):e.value!==""+Ln(n)&&(e.value=""+Ln(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?ac(e,j,Ln(n)):l!=null?ac(e,j,Ln(l)):i!=null&&e.removeAttribute("value"),f==null&&x!=null&&(e.defaultChecked=!!x),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Ln(R):e.removeAttribute("name")}function Pf(e,n,l,i,f,x,j,R){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(e.type=x),n!=null||l!=null){if(!(x!=="submit"&&x!=="reset"||n!=null)){nc(e);return}l=l!=null?""+Ln(l):"",n=n!=null?""+Ln(n):l,R||n===e.value||(e.value=n),e.defaultValue=n}i=i??f,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=R?e.checked:!!i,e.defaultChecked=!!i,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),nc(e)}function ac(e,n,l){n==="number"&&ii(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Ya(e,n,l,i){if(e=e.options,n){n={};for(var f=0;f<l.length;f++)n["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=n.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&i&&(e[l].defaultSelected=!0)}else{for(l=""+Ln(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,i&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Ff(e,n,l){if(n!=null&&(n=""+Ln(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Ln(l):""}function Gf(e,n,l,i){if(n==null){if(i!=null){if(l!=null)throw Error(o(92));if($(i)){if(1<i.length)throw Error(o(93));i=i[0]}l=i}l==null&&(l=""),n=l}l=Ln(n),e.defaultValue=l,i=e.textContent,i===l&&i!==""&&i!==null&&(e.value=i),nc(e)}function Ka(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var eb=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 Wf(e,n,l){var i=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?i?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":i?e.setProperty(n,l):typeof l!="number"||l===0||eb.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function qf(e,n,l){if(n!=null&&typeof n!="object")throw Error(o(62));if(e=e.style,l!=null){for(var i in l)!l.hasOwnProperty(i)||n!=null&&n.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var f in n)i=n[f],n.hasOwnProperty(f)&&l[f]!==i&&Wf(e,f,i)}else for(var x in n)n.hasOwnProperty(x)&&Wf(e,x,n[x])}function lc(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"]]),nb=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function oi(e){return nb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function pr(){}var sc=null;function ic(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xa=null,Qa=null;function Yf(e){var n=Ga(e);if(n&&(e=n.stateNode)){var l=e[ot]||null;e:switch(e=n.stateNode,n.type){case"input":if(rc(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+zn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var i=l[n];if(i!==e&&i.form===e.form){var f=i[ot]||null;if(!f)throw Error(o(90));rc(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)i=l[n],i.form===e.form&&Vf(i)}break e;case"textarea":Ff(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Ya(e,!!l.multiple,n,!1)}}}var oc=!1;function Kf(e,n,l){if(oc)return e(n,l);oc=!0;try{var i=e(n);return i}finally{if(oc=!1,(Xa!==null||Qa!==null)&&(Ki(),Xa&&(n=Xa,e=Qa,Qa=Xa=null,Yf(n),e)))for(n=0;n<e.length;n++)Yf(e[n])}}function $l(e,n){var l=e.stateNode;if(l===null)return null;var i=l[ot]||null;if(i===null)return null;l=i[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(o(231,n,typeof l));return l}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cc=!1;if(mr)try{var Vl={};Object.defineProperty(Vl,"passive",{get:function(){cc=!0}}),window.addEventListener("test",Vl,Vl),window.removeEventListener("test",Vl,Vl)}catch{cc=!1}var _r=null,uc=null,ci=null;function Xf(){if(ci)return ci;var e,n=uc,l=n.length,i,f="value"in _r?_r.value:_r.textContent,x=f.length;for(e=0;e<l&&n[e]===f[e];e++);var j=l-e;for(i=1;i<=j&&n[l-i]===f[x-i];i++);return ci=f.slice(e,1<i?1-i:void 0)}function ui(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function di(){return!0}function Qf(){return!1}function pn(e){function n(l,i,f,x,j){this._reactName=l,this._targetInst=f,this.type=i,this.nativeEvent=x,this.target=j,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(l=e[R],this[R]=l?l(x):x[R]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?di:Qf,this.isPropagationStopped=Qf,this}return v(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=di)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=di)},persist:function(){},isPersistent:di}),n}var va={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fi=pn(va),Pl=v({},va,{view:0,detail:0}),rb=pn(Pl),dc,fc,Fl,pi=v({},Pl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mc,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!==Fl&&(Fl&&e.type==="mousemove"?(dc=e.screenX-Fl.screenX,fc=e.screenY-Fl.screenY):fc=dc=0,Fl=e),dc)},movementY:function(e){return"movementY"in e?e.movementY:fc}}),Zf=pn(pi),ab=v({},pi,{dataTransfer:0}),lb=pn(ab),sb=v({},Pl,{relatedTarget:0}),pc=pn(sb),ib=v({},va,{animationName:0,elapsedTime:0,pseudoElement:0}),ob=pn(ib),cb=v({},va,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ub=pn(cb),db=v({},va,{data:0}),Jf=pn(db),fb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pb={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"},mb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=mb[e])?!!n[e]:!1}function mc(){return hb}var xb=v({},Pl,{key:function(e){if(e.key){var n=fb[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?pb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mc,charCode:function(e){return e.type==="keypress"?ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),gb=pn(xb),vb=v({},pi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ep=pn(vb),yb=v({},Pl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mc}),bb=pn(yb),jb=v({},va,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sb=pn(jb),kb=v({},pi,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),wb=pn(kb),Cb=v({},va,{newState:0,oldState:0}),Eb=pn(Cb),Nb=[9,13,27,32],hc=mr&&"CompositionEvent"in window,Gl=null;mr&&"documentMode"in document&&(Gl=document.documentMode);var Tb=mr&&"TextEvent"in window&&!Gl,tp=mr&&(!hc||Gl&&8<Gl&&11>=Gl),np=" ",rp=!1;function ap(e,n){switch(e){case"keyup":return Nb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Za=!1;function Rb(e,n){switch(e){case"compositionend":return lp(n);case"keypress":return n.which!==32?null:(rp=!0,np);case"textInput":return e=n.data,e===np&&rp?null:e;default:return null}}function Ab(e,n){if(Za)return e==="compositionend"||!hc&&ap(e,n)?(e=Xf(),ci=uc=_r=null,Za=!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 tp&&n.locale!=="ko"?null:n.data;default:return null}}var Mb={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 sp(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Mb[e.type]:n==="textarea"}function ip(e,n,l,i){Xa?Qa?Qa.push(i):Qa=[i]:Xa=i,n=no(n,"onChange"),0<n.length&&(l=new fi("onChange","change",null,l,i),e.push({event:l,listeners:n}))}var Wl=null,ql=null;function Lb(e){Ph(e,0)}function mi(e){var n=Hl(e);if(Vf(n))return e}function op(e,n){if(e==="change")return n}var cp=!1;if(mr){var xc;if(mr){var gc="oninput"in document;if(!gc){var up=document.createElement("div");up.setAttribute("oninput","return;"),gc=typeof up.oninput=="function"}xc=gc}else xc=!1;cp=xc&&(!document.documentMode||9<document.documentMode)}function dp(){Wl&&(Wl.detachEvent("onpropertychange",fp),ql=Wl=null)}function fp(e){if(e.propertyName==="value"&&mi(ql)){var n=[];ip(n,ql,e,ic(e)),Kf(Lb,n)}}function zb(e,n,l){e==="focusin"?(dp(),Wl=n,ql=l,Wl.attachEvent("onpropertychange",fp)):e==="focusout"&&dp()}function Db(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return mi(ql)}function _b(e,n){if(e==="click")return mi(n)}function Ob(e,n){if(e==="input"||e==="change")return mi(n)}function Bb(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:Bb;function Yl(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),i=Object.keys(n);if(l.length!==i.length)return!1;for(i=0;i<l.length;i++){var f=l[i];if(!at.call(n,f)||!yn(e[f],n[f]))return!1}return!0}function pp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function mp(e,n){var l=pp(e);e=0;for(var i;l;){if(l.nodeType===3){if(i=e+l.textContent.length,e<=n&&i>=n)return{node:l,offset:n-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=pp(l)}}function hp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?hp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function xp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=ii(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=ii(e.document)}return n}function vc(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 Ib=mr&&"documentMode"in document&&11>=document.documentMode,Ja=null,yc=null,Kl=null,bc=!1;function gp(e,n,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;bc||Ja==null||Ja!==ii(i)||(i=Ja,"selectionStart"in i&&vc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Kl&&Yl(Kl,i)||(Kl=i,i=no(yc,"onSelect"),0<i.length&&(n=new fi("onSelect","select",null,n,l),e.push({event:n,listeners:i}),n.target=Ja)))}function ya(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var el={animationend:ya("Animation","AnimationEnd"),animationiteration:ya("Animation","AnimationIteration"),animationstart:ya("Animation","AnimationStart"),transitionrun:ya("Transition","TransitionRun"),transitionstart:ya("Transition","TransitionStart"),transitioncancel:ya("Transition","TransitionCancel"),transitionend:ya("Transition","TransitionEnd")},jc={},vp={};mr&&(vp=document.createElement("div").style,"AnimationEvent"in window||(delete el.animationend.animation,delete el.animationiteration.animation,delete el.animationstart.animation),"TransitionEvent"in window||delete el.transitionend.transition);function ba(e){if(jc[e])return jc[e];if(!el[e])return e;var n=el[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in vp)return jc[e]=n[l];return e}var yp=ba("animationend"),bp=ba("animationiteration"),jp=ba("animationstart"),Ub=ba("transitionrun"),Hb=ba("transitionstart"),$b=ba("transitioncancel"),Sp=ba("transitionend"),kp=new Map,Sc="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(" ");Sc.push("scrollEnd");function Yn(e,n){kp.set(e,n),ga(n,[e])}var hi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Dn=[],tl=0,kc=0;function xi(){for(var e=tl,n=kc=tl=0;n<e;){var l=Dn[n];Dn[n++]=null;var i=Dn[n];Dn[n++]=null;var f=Dn[n];Dn[n++]=null;var x=Dn[n];if(Dn[n++]=null,i!==null&&f!==null){var j=i.pending;j===null?f.next=f:(f.next=j.next,j.next=f),i.pending=f}x!==0&&wp(l,f,x)}}function gi(e,n,l,i){Dn[tl++]=e,Dn[tl++]=n,Dn[tl++]=l,Dn[tl++]=i,kc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function wc(e,n,l,i){return gi(e,n,l,i),vi(e)}function ja(e,n){return gi(e,null,null,n),vi(e)}function wp(e,n,l){e.lanes|=l;var i=e.alternate;i!==null&&(i.lanes|=l);for(var f=!1,x=e.return;x!==null;)x.childLanes|=l,i=x.alternate,i!==null&&(i.childLanes|=l),x.tag===22&&(e=x.stateNode,e===null||e._visibility&1||(f=!0)),e=x,x=x.return;return e.tag===3?(x=e.stateNode,f&&n!==null&&(f=31-gt(l),e=x.hiddenUpdates,i=e[f],i===null?e[f]=[n]:i.push(n),n.lane=l|536870912),x):null}function vi(e){if(50<gs)throw gs=0,zu=null,Error(o(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var nl={};function Vb(e,n,l,i){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bn(e,n,l,i){return new Vb(e,n,l,i)}function Cc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hr(e,n){var l=e.alternate;return l===null?(l=bn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function Cp(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function yi(e,n,l,i,f,x){var j=0;if(i=e,typeof e=="function")Cc(e)&&(j=1);else if(typeof e=="string")j=q1(e,l,te.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=bn(31,l,n,f),e.elementType=z,e.lanes=x,e;case E:return Sa(l.children,f,x,n);case C:j=8,f|=24;break;case N:return e=bn(12,l,n,f|2),e.elementType=N,e.lanes=x,e;case D:return e=bn(13,l,n,f),e.elementType=D,e.lanes=x,e;case F:return e=bn(19,l,n,f),e.elementType=F,e.lanes=x,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case A:j=10;break e;case T:j=9;break e;case B:j=11;break e;case w:j=14;break e;case O:j=16,i=null;break e}j=29,l=Error(o(130,e===null?"null":typeof e,"")),i=null}return n=bn(j,l,n,f),n.elementType=e,n.type=i,n.lanes=x,n}function Sa(e,n,l,i){return e=bn(7,e,i,n),e.lanes=l,e}function Ec(e,n,l){return e=bn(6,e,null,n),e.lanes=l,e}function Ep(e){var n=bn(18,null,null,0);return n.stateNode=e,n}function Nc(e,n,l){return n=bn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Np=new WeakMap;function _n(e,n){if(typeof e=="object"&&e!==null){var l=Np.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Oe(n)},Np.set(e,n),n)}return{value:e,source:n,stack:Oe(n)}}var rl=[],al=0,bi=null,Xl=0,On=[],Bn=0,Or=null,rr=1,ar="";function xr(e,n){rl[al++]=Xl,rl[al++]=bi,bi=e,Xl=n}function Tp(e,n,l){On[Bn++]=rr,On[Bn++]=ar,On[Bn++]=Or,Or=e;var i=rr;e=ar;var f=32-gt(i)-1;i&=~(1<<f),l+=1;var x=32-gt(n)+f;if(30<x){var j=f-f%5;x=(i&(1<<j)-1).toString(32),i>>=j,f-=j,rr=1<<32-gt(n)+f|l<<f|i,ar=x+e}else rr=1<<x|l<<f|i,ar=e}function Tc(e){e.return!==null&&(xr(e,1),Tp(e,1,0))}function Rc(e){for(;e===bi;)bi=rl[--al],rl[al]=null,Xl=rl[--al],rl[al]=null;for(;e===Or;)Or=On[--Bn],On[Bn]=null,ar=On[--Bn],On[Bn]=null,rr=On[--Bn],On[Bn]=null}function Rp(e,n){On[Bn++]=rr,On[Bn++]=ar,On[Bn++]=Or,rr=n.id,ar=n.overflow,Or=e}var Kt=null,vt=null,Ke=!1,Br=null,In=!1,Ac=Error(o(519));function Ir(e){var n=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ql(_n(n,e)),Ac}function Ap(e){var n=e.stateNode,l=e.type,i=e.memoizedProps;switch(n[Ht]=e,n[ot]=i,l){case"dialog":We("cancel",n),We("close",n);break;case"iframe":case"object":case"embed":We("load",n);break;case"video":case"audio":for(l=0;l<ys.length;l++)We(ys[l],n);break;case"source":We("error",n);break;case"img":case"image":case"link":We("error",n),We("load",n);break;case"details":We("toggle",n);break;case"input":We("invalid",n),Pf(n,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":We("invalid",n);break;case"textarea":We("invalid",n),Gf(n,i.value,i.defaultValue,i.children)}l=i.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||i.suppressHydrationWarning===!0||qh(n.textContent,l)?(i.popover!=null&&(We("beforetoggle",n),We("toggle",n)),i.onScroll!=null&&We("scroll",n),i.onScrollEnd!=null&&We("scrollend",n),i.onClick!=null&&(n.onclick=pr),n=!0):n=!1,n||Ir(e,!0)}function Mp(e){for(Kt=e.return;Kt;)switch(Kt.tag){case 5:case 31:case 13:In=!1;return;case 27:case 3:In=!0;return;default:Kt=Kt.return}}function ll(e){if(e!==Kt)return!1;if(!Ke)return Mp(e),Ke=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Yu(e.type,e.memoizedProps)),l=!l),l&&vt&&Ir(e),Mp(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=nx(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));vt=nx(e)}else n===27?(n=vt,Zr(e.type)?(e=Ju,Ju=null,vt=e):vt=n):vt=Kt?Hn(e.stateNode.nextSibling):null;return!0}function ka(){vt=Kt=null,Ke=!1}function Mc(){var e=Br;return e!==null&&(gn===null?gn=e:gn.push.apply(gn,e),Br=null),e}function Ql(e){Br===null?Br=[e]:Br.push(e)}var Lc=M(null),wa=null,gr=null;function Ur(e,n,l){G(Lc,n._currentValue),n._currentValue=l}function vr(e){e._currentValue=Lc.current,Y(Lc)}function zc(e,n,l){for(;e!==null;){var i=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,i!==null&&(i.childLanes|=n)):i!==null&&(i.childLanes&n)!==n&&(i.childLanes|=n),e===l)break;e=e.return}}function Dc(e,n,l,i){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var x=f.dependencies;if(x!==null){var j=f.child;x=x.firstContext;e:for(;x!==null;){var R=x;x=f;for(var P=0;P<n.length;P++)if(R.context===n[P]){x.lanes|=l,R=x.alternate,R!==null&&(R.lanes|=l),zc(x.return,l,e),i||(j=null);break e}x=R.next}}else if(f.tag===18){if(j=f.return,j===null)throw Error(o(341));j.lanes|=l,x=j.alternate,x!==null&&(x.lanes|=l),zc(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 sl(e,n,l,i){e=null;for(var f=n,x=!1;f!==null;){if(!x){if((f.flags&524288)!==0)x=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var j=f.alternate;if(j===null)throw Error(o(387));if(j=j.memoizedProps,j!==null){var R=f.type;yn(f.pendingProps.value,j.value)||(e!==null?e.push(R):e=[R])}}else if(f===ye.current){if(j=f.alternate,j===null)throw Error(o(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(ws):e=[ws])}f=f.return}e!==null&&Dc(n,e,l,i),n.flags|=262144}function ji(e){for(e=e.firstContext;e!==null;){if(!yn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ca(e){wa=e,gr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Xt(e){return Lp(wa,e)}function Si(e,n){return wa===null&&Ca(e),Lp(e,n)}function Lp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},gr===null){if(e===null)throw Error(o(308));gr=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else gr=gr.next=n;return l}var Pb=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,i){e.push(i)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},Fb=t.unstable_scheduleCallback,Gb=t.unstable_NormalPriority,_t={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _c(){return{controller:new Pb,data:new Map,refCount:0}}function Zl(e){e.refCount--,e.refCount===0&&Fb(Gb,function(){e.controller.abort()})}var Jl=null,Oc=0,il=0,ol=null;function Wb(e,n){if(Jl===null){var l=Jl=[];Oc=0,il=Uu(),ol={status:"pending",value:void 0,then:function(i){l.push(i)}}}return Oc++,n.then(zp,zp),n}function zp(){if(--Oc===0&&Jl!==null){ol!==null&&(ol.status="fulfilled");var e=Jl;Jl=null,il=0,ol=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function qb(e,n){var l=[],i={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){i.status="fulfilled",i.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(i.status="rejected",i.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),i}var Dp=L.S;L.S=function(e,n){gh=Qe(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Wb(e,n),Dp!==null&&Dp(e,n)};var Ea=M(null);function Bc(){var e=Ea.current;return e!==null?e:mt.pooledCache}function ki(e,n){n===null?G(Ea,Ea.current):G(Ea,n.pool)}function _p(){var e=Bc();return e===null?null:{parent:_t._currentValue,pool:e}}var cl=Error(o(460)),Ic=Error(o(474)),wi=Error(o(542)),Ci={then:function(){}};function Op(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Bp(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(pr,pr),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Up(e),e;default:if(typeof n.status=="string")n.then(pr,pr);else{if(e=mt,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=n,e.status="pending",e.then(function(i){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=i}},function(i){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=i}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Up(e),e}throw Ta=n,cl}}function Na(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Ta=l,cl):l}}var Ta=null;function Ip(){if(Ta===null)throw Error(o(459));var e=Ta;return Ta=null,e}function Up(e){if(e===cl||e===wi)throw Error(o(483))}var ul=null,es=0;function Ei(e){var n=es;return es+=1,ul===null&&(ul=[]),Bp(ul,e,n)}function ts(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ni(e,n){throw n.$$typeof===b?Error(o(525)):(e=Object.prototype.toString.call(n),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Hp(e){function n(K,W){if(e){var Q=K.deletions;Q===null?(K.deletions=[W],K.flags|=16):Q.push(W)}}function l(K,W){if(!e)return null;for(;W!==null;)n(K,W),W=W.sibling;return null}function i(K){for(var W=new Map;K!==null;)K.key!==null?W.set(K.key,K):W.set(K.index,K),K=K.sibling;return W}function f(K,W){return K=hr(K,W),K.index=0,K.sibling=null,K}function x(K,W,Q){return K.index=Q,e?(Q=K.alternate,Q!==null?(Q=Q.index,Q<W?(K.flags|=67108866,W):Q):(K.flags|=67108866,W)):(K.flags|=1048576,W)}function j(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function R(K,W,Q,ce){return W===null||W.tag!==6?(W=Ec(Q,K.mode,ce),W.return=K,W):(W=f(W,Q),W.return=K,W)}function P(K,W,Q,ce){var Me=Q.type;return Me===E?le(K,W,Q.props.children,ce,Q.key):W!==null&&(W.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&Na(Me)===W.type)?(W=f(W,Q.props),ts(W,Q),W.return=K,W):(W=yi(Q.type,Q.key,Q.props,null,K.mode,ce),ts(W,Q),W.return=K,W)}function Z(K,W,Q,ce){return W===null||W.tag!==4||W.stateNode.containerInfo!==Q.containerInfo||W.stateNode.implementation!==Q.implementation?(W=Nc(Q,K.mode,ce),W.return=K,W):(W=f(W,Q.children||[]),W.return=K,W)}function le(K,W,Q,ce,Me){return W===null||W.tag!==7?(W=Sa(Q,K.mode,ce,Me),W.return=K,W):(W=f(W,Q),W.return=K,W)}function ue(K,W,Q){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=Ec(""+W,K.mode,Q),W.return=K,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case S:return Q=yi(W.type,W.key,W.props,null,K.mode,Q),ts(Q,W),Q.return=K,Q;case k:return W=Nc(W,K.mode,Q),W.return=K,W;case O:return W=Na(W),ue(K,W,Q)}if($(W)||q(W))return W=Sa(W,K.mode,Q,null),W.return=K,W;if(typeof W.then=="function")return ue(K,Ei(W),Q);if(W.$$typeof===A)return ue(K,Si(K,W),Q);Ni(K,W)}return null}function ee(K,W,Q,ce){var Me=W!==null?W.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Me!==null?null:R(K,W,""+Q,ce);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return Q.key===Me?P(K,W,Q,ce):null;case k:return Q.key===Me?Z(K,W,Q,ce):null;case O:return Q=Na(Q),ee(K,W,Q,ce)}if($(Q)||q(Q))return Me!==null?null:le(K,W,Q,ce,null);if(typeof Q.then=="function")return ee(K,W,Ei(Q),ce);if(Q.$$typeof===A)return ee(K,W,Si(K,Q),ce);Ni(K,Q)}return null}function re(K,W,Q,ce,Me){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return K=K.get(Q)||null,R(W,K,""+ce,Me);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case S:return K=K.get(ce.key===null?Q:ce.key)||null,P(W,K,ce,Me);case k:return K=K.get(ce.key===null?Q:ce.key)||null,Z(W,K,ce,Me);case O:return ce=Na(ce),re(K,W,Q,ce,Me)}if($(ce)||q(ce))return K=K.get(Q)||null,le(W,K,ce,Me,null);if(typeof ce.then=="function")return re(K,W,Q,Ei(ce),Me);if(ce.$$typeof===A)return re(K,W,Q,Si(W,ce),Me);Ni(W,ce)}return null}function we(K,W,Q,ce){for(var Me=null,Ze=null,Ne=W,Ve=W=0,Ye=null;Ne!==null&&Ve<Q.length;Ve++){Ne.index>Ve?(Ye=Ne,Ne=null):Ye=Ne.sibling;var Je=ee(K,Ne,Q[Ve],ce);if(Je===null){Ne===null&&(Ne=Ye);break}e&&Ne&&Je.alternate===null&&n(K,Ne),W=x(Je,W,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je,Ne=Ye}if(Ve===Q.length)return l(K,Ne),Ke&&xr(K,Ve),Me;if(Ne===null){for(;Ve<Q.length;Ve++)Ne=ue(K,Q[Ve],ce),Ne!==null&&(W=x(Ne,W,Ve),Ze===null?Me=Ne:Ze.sibling=Ne,Ze=Ne);return Ke&&xr(K,Ve),Me}for(Ne=i(Ne);Ve<Q.length;Ve++)Ye=re(Ne,K,Ve,Q[Ve],ce),Ye!==null&&(e&&Ye.alternate!==null&&Ne.delete(Ye.key===null?Ve:Ye.key),W=x(Ye,W,Ve),Ze===null?Me=Ye:Ze.sibling=Ye,Ze=Ye);return e&&Ne.forEach(function(ra){return n(K,ra)}),Ke&&xr(K,Ve),Me}function Le(K,W,Q,ce){if(Q==null)throw Error(o(151));for(var Me=null,Ze=null,Ne=W,Ve=W=0,Ye=null,Je=Q.next();Ne!==null&&!Je.done;Ve++,Je=Q.next()){Ne.index>Ve?(Ye=Ne,Ne=null):Ye=Ne.sibling;var ra=ee(K,Ne,Je.value,ce);if(ra===null){Ne===null&&(Ne=Ye);break}e&&Ne&&ra.alternate===null&&n(K,Ne),W=x(ra,W,Ve),Ze===null?Me=ra:Ze.sibling=ra,Ze=ra,Ne=Ye}if(Je.done)return l(K,Ne),Ke&&xr(K,Ve),Me;if(Ne===null){for(;!Je.done;Ve++,Je=Q.next())Je=ue(K,Je.value,ce),Je!==null&&(W=x(Je,W,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je);return Ke&&xr(K,Ve),Me}for(Ne=i(Ne);!Je.done;Ve++,Je=Q.next())Je=re(Ne,K,Ve,Je.value,ce),Je!==null&&(e&&Je.alternate!==null&&Ne.delete(Je.key===null?Ve:Je.key),W=x(Je,W,Ve),Ze===null?Me=Je:Ze.sibling=Je,Ze=Je);return e&&Ne.forEach(function(a0){return n(K,a0)}),Ke&&xr(K,Ve),Me}function dt(K,W,Q,ce){if(typeof Q=="object"&&Q!==null&&Q.type===E&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:e:{for(var Me=Q.key;W!==null;){if(W.key===Me){if(Me=Q.type,Me===E){if(W.tag===7){l(K,W.sibling),ce=f(W,Q.props.children),ce.return=K,K=ce;break e}}else if(W.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&Na(Me)===W.type){l(K,W.sibling),ce=f(W,Q.props),ts(ce,Q),ce.return=K,K=ce;break e}l(K,W);break}else n(K,W);W=W.sibling}Q.type===E?(ce=Sa(Q.props.children,K.mode,ce,Q.key),ce.return=K,K=ce):(ce=yi(Q.type,Q.key,Q.props,null,K.mode,ce),ts(ce,Q),ce.return=K,K=ce)}return j(K);case k:e:{for(Me=Q.key;W!==null;){if(W.key===Me)if(W.tag===4&&W.stateNode.containerInfo===Q.containerInfo&&W.stateNode.implementation===Q.implementation){l(K,W.sibling),ce=f(W,Q.children||[]),ce.return=K,K=ce;break e}else{l(K,W);break}else n(K,W);W=W.sibling}ce=Nc(Q,K.mode,ce),ce.return=K,K=ce}return j(K);case O:return Q=Na(Q),dt(K,W,Q,ce)}if($(Q))return we(K,W,Q,ce);if(q(Q)){if(Me=q(Q),typeof Me!="function")throw Error(o(150));return Q=Me.call(Q),Le(K,W,Q,ce)}if(typeof Q.then=="function")return dt(K,W,Ei(Q),ce);if(Q.$$typeof===A)return dt(K,W,Si(K,Q),ce);Ni(K,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,W!==null&&W.tag===6?(l(K,W.sibling),ce=f(W,Q),ce.return=K,K=ce):(l(K,W),ce=Ec(Q,K.mode,ce),ce.return=K,K=ce),j(K)):l(K,W)}return function(K,W,Q,ce){try{es=0;var Me=dt(K,W,Q,ce);return ul=null,Me}catch(Ne){if(Ne===cl||Ne===wi)throw Ne;var Ze=bn(29,Ne,null,K.mode);return Ze.lanes=ce,Ze.return=K,Ze}finally{}}}var Ra=Hp(!0),$p=Hp(!1),Hr=!1;function Uc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hc(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function $r(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Vr(e,n,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(nt&2)!==0){var f=i.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),i.pending=n,n=vi(e),wp(e,null,l),n}return gi(e,i,n,l),vi(e)}function ns(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pa(e,l)}}function $c(e,n){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var f=null,x=null;if(l=l.firstBaseUpdate,l!==null){do{var j={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};x===null?f=x=j:x=x.next=j,l=l.next}while(l!==null);x===null?f=x=n:x=x.next=n}else f=x=n;l={baseState:i.baseState,firstBaseUpdate:f,lastBaseUpdate:x,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var Vc=!1;function rs(){if(Vc){var e=ol;if(e!==null)throw e}}function as(e,n,l,i){Vc=!1;var f=e.updateQueue;Hr=!1;var x=f.firstBaseUpdate,j=f.lastBaseUpdate,R=f.shared.pending;if(R!==null){f.shared.pending=null;var P=R,Z=P.next;P.next=null,j===null?x=Z:j.next=Z,j=P;var le=e.alternate;le!==null&&(le=le.updateQueue,R=le.lastBaseUpdate,R!==j&&(R===null?le.firstBaseUpdate=Z:R.next=Z,le.lastBaseUpdate=P))}if(x!==null){var ue=f.baseState;j=0,le=Z=P=null,R=x;do{var ee=R.lane&-536870913,re=ee!==R.lane;if(re?(qe&ee)===ee:(i&ee)===ee){ee!==0&&ee===il&&(Vc=!0),le!==null&&(le=le.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var we=e,Le=R;ee=n;var dt=l;switch(Le.tag){case 1:if(we=Le.payload,typeof we=="function"){ue=we.call(dt,ue,ee);break e}ue=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Le.payload,ee=typeof we=="function"?we.call(dt,ue,ee):we,ee==null)break e;ue=v({},ue,ee);break e;case 2:Hr=!0}}ee=R.callback,ee!==null&&(e.flags|=64,re&&(e.flags|=8192),re=f.callbacks,re===null?f.callbacks=[ee]:re.push(ee))}else re={lane:ee,tag:R.tag,payload:R.payload,callback:R.callback,next:null},le===null?(Z=le=re,P=ue):le=le.next=re,j|=ee;if(R=R.next,R===null){if(R=f.shared.pending,R===null)break;re=R,R=re.next,re.next=null,f.lastBaseUpdate=re,f.shared.pending=null}}while(!0);le===null&&(P=ue),f.baseState=P,f.firstBaseUpdate=Z,f.lastBaseUpdate=le,x===null&&(f.shared.lanes=0),qr|=j,e.lanes=j,e.memoizedState=ue}}function Vp(e,n){if(typeof e!="function")throw Error(o(191,e));e.call(n)}function Pp(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Vp(l[e],n)}var dl=M(null),Ti=M(0);function Fp(e,n){e=Nr,G(Ti,e),G(dl,n),Nr=e|n.baseLanes}function Pc(){G(Ti,Nr),G(dl,dl.current)}function Fc(){Nr=Ti.current,Y(dl),Y(Ti)}var jn=M(null),Un=null;function Pr(e){var n=e.alternate;G(Lt,Lt.current&1),G(jn,e),Un===null&&(n===null||dl.current!==null||n.memoizedState!==null)&&(Un=e)}function Gc(e){G(Lt,Lt.current),G(jn,e),Un===null&&(Un=e)}function Gp(e){e.tag===22?(G(Lt,Lt.current),G(jn,e),Un===null&&(Un=e)):Fr()}function Fr(){G(Lt,Lt.current),G(jn,jn.current)}function Sn(e){Y(jn),Un===e&&(Un=null),Y(Lt)}var Lt=M(0);function Ri(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Qu(l)||Zu(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var yr=0,He=null,ct=null,Ot=null,Ai=!1,fl=!1,Aa=!1,Mi=0,ls=0,pl=null,Yb=0;function Rt(){throw Error(o(321))}function Wc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!yn(e[l],n[l]))return!1;return!0}function qc(e,n,l,i,f,x){return yr=x,He=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,L.H=e===null||e.memoizedState===null?Tm:ou,Aa=!1,x=l(i,f),Aa=!1,fl&&(x=qp(n,l,i,f)),Wp(e),x}function Wp(e){L.H=os;var n=ct!==null&&ct.next!==null;if(yr=0,Ot=ct=He=null,Ai=!1,ls=0,pl=null,n)throw Error(o(300));e===null||Bt||(e=e.dependencies,e!==null&&ji(e)&&(Bt=!0))}function qp(e,n,l,i){He=e;var f=0;do{if(fl&&(pl=null),ls=0,fl=!1,25<=f)throw Error(o(301));if(f+=1,Ot=ct=null,e.updateQueue!=null){var x=e.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}L.H=Rm,x=n(l,i)}while(fl);return x}function Kb(){var e=L.H,n=e.useState()[0];return n=typeof n.then=="function"?ss(n):n,e=e.useState()[0],(ct!==null?ct.memoizedState:null)!==e&&(He.flags|=1024),n}function Yc(){var e=Mi!==0;return Mi=0,e}function Kc(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Xc(e){if(Ai){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Ai=!1}yr=0,Ot=ct=He=null,fl=!1,ls=Mi=0,pl=null}function ln(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?He.memoizedState=Ot=e:Ot=Ot.next=e,Ot}function zt(){if(ct===null){var e=He.alternate;e=e!==null?e.memoizedState:null}else e=ct.next;var n=Ot===null?He.memoizedState:Ot.next;if(n!==null)Ot=n,ct=e;else{if(e===null)throw He.alternate===null?Error(o(467)):Error(o(310));ct=e,e={memoizedState:ct.memoizedState,baseState:ct.baseState,baseQueue:ct.baseQueue,queue:ct.queue,next:null},Ot===null?He.memoizedState=Ot=e:Ot=Ot.next=e}return Ot}function Li(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ss(e){var n=ls;return ls+=1,pl===null&&(pl=[]),e=Bp(pl,e,n),n=He,(Ot===null?n.memoizedState:Ot.next)===null&&(n=n.alternate,L.H=n===null||n.memoizedState===null?Tm:ou),e}function zi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ss(e);if(e.$$typeof===A)return Xt(e)}throw Error(o(438,String(e)))}function Qc(e){var n=null,l=He.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var i=He.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(n={data:i.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=Li(),He.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),i=0;i<e;i++)l[i]=U;return n.index++,l}function br(e,n){return typeof n=="function"?n(e):n}function Di(e){var n=zt();return Zc(n,ct,e)}function Zc(e,n,l){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=l;var f=e.baseQueue,x=i.pending;if(x!==null){if(f!==null){var j=f.next;f.next=x.next,x.next=j}n.baseQueue=f=x,i.pending=null}if(x=e.baseState,f===null)e.memoizedState=x;else{n=f.next;var R=j=null,P=null,Z=n,le=!1;do{var ue=Z.lane&-536870913;if(ue!==Z.lane?(qe&ue)===ue:(yr&ue)===ue){var ee=Z.revertLane;if(ee===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),ue===il&&(le=!0);else if((yr&ee)===ee){Z=Z.next,ee===il&&(le=!0);continue}else ue={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ue,j=x):P=P.next=ue,He.lanes|=ee,qr|=ee;ue=Z.action,Aa&&l(x,ue),x=Z.hasEagerState?Z.eagerState:l(x,ue)}else ee={lane:ue,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ee,j=x):P=P.next=ee,He.lanes|=ue,qr|=ue;Z=Z.next}while(Z!==null&&Z!==n);if(P===null?j=x:P.next=R,!yn(x,e.memoizedState)&&(Bt=!0,le&&(l=ol,l!==null)))throw l;e.memoizedState=x,e.baseState=j,e.baseQueue=P,i.lastRenderedState=x}return f===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Jc(e){var n=zt(),l=n.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=e;var i=l.dispatch,f=l.pending,x=n.memoizedState;if(f!==null){l.pending=null;var j=f=f.next;do x=e(x,j.action),j=j.next;while(j!==f);yn(x,n.memoizedState)||(Bt=!0),n.memoizedState=x,n.baseQueue===null&&(n.baseState=x),l.lastRenderedState=x}return[x,i]}function Yp(e,n,l){var i=He,f=zt(),x=Ke;if(x){if(l===void 0)throw Error(o(407));l=l()}else l=n();var j=!yn((ct||f).memoizedState,l);if(j&&(f.memoizedState=l,Bt=!0),f=f.queue,nu(Qp.bind(null,i,f,e),[e]),f.getSnapshot!==n||j||Ot!==null&&Ot.memoizedState.tag&1){if(i.flags|=2048,ml(9,{destroy:void 0},Xp.bind(null,i,f,l,n),null),mt===null)throw Error(o(349));x||(yr&127)!==0||Kp(i,n,l)}return l}function Kp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=He.updateQueue,n===null?(n=Li(),He.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function Xp(e,n,l,i){n.value=l,n.getSnapshot=i,Zp(n)&&Jp(e)}function Qp(e,n,l){return l(function(){Zp(n)&&Jp(e)})}function Zp(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!yn(e,l)}catch{return!0}}function Jp(e){var n=ja(e,2);n!==null&&vn(n,e,2)}function eu(e){var n=ln();if(typeof e=="function"){var l=e;if(e=l(),Aa){xt(!0);try{l()}finally{xt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:e},n}function em(e,n,l,i){return e.baseState=l,Zc(e,ct,typeof i=="function"?i:br)}function Xb(e,n,l,i,f){if(Bi(e))throw Error(o(485));if(e=n.action,e!==null){var x={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){x.listeners.push(j)}};L.T!==null?l(!0):x.isTransition=!1,i(x),l=n.pending,l===null?(x.next=n.pending=x,tm(n,x)):(x.next=l.next,n.pending=l.next=x)}}function tm(e,n){var l=n.action,i=n.payload,f=e.state;if(n.isTransition){var x=L.T,j={};L.T=j;try{var R=l(f,i),P=L.S;P!==null&&P(j,R),nm(e,n,R)}catch(Z){tu(e,n,Z)}finally{x!==null&&j.types!==null&&(x.types=j.types),L.T=x}}else try{x=l(f,i),nm(e,n,x)}catch(Z){tu(e,n,Z)}}function nm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(i){rm(e,n,i)},function(i){return tu(e,n,i)}):rm(e,n,l)}function rm(e,n,l){n.status="fulfilled",n.value=l,am(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,tm(e,l)))}function tu(e,n,l){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do n.status="rejected",n.reason=l,am(n),n=n.next;while(n!==i)}e.action=null}function am(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function lm(e,n){return n}function sm(e,n){if(Ke){var l=mt.formState;if(l!==null){e:{var i=He;if(Ke){if(vt){t:{for(var f=vt,x=In;f.nodeType!==8;){if(!x){f=null;break t}if(f=Hn(f.nextSibling),f===null){f=null;break t}}x=f.data,f=x==="F!"||x==="F"?f:null}if(f){vt=Hn(f.nextSibling),i=f.data==="F!";break e}}Ir(i)}i=!1}i&&(n=l[0])}}return l=ln(),l.memoizedState=l.baseState=n,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:lm,lastRenderedState:n},l.queue=i,l=Cm.bind(null,He,i),i.dispatch=l,i=eu(!1),x=iu.bind(null,He,!1,i.queue),i=ln(),f={state:n,dispatch:null,action:e,pending:null},i.queue=f,l=Xb.bind(null,He,f,x,l),f.dispatch=l,i.memoizedState=e,[n,l,!1]}function im(e){var n=zt();return om(n,ct,e)}function om(e,n,l){if(n=Zc(e,n,lm)[0],e=Di(br)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var i=ss(n)}catch(j){throw j===cl?wi:j}else i=n;n=zt();var f=n.queue,x=f.dispatch;return l!==n.memoizedState&&(He.flags|=2048,ml(9,{destroy:void 0},Qb.bind(null,f,l),null)),[i,x,e]}function Qb(e,n){e.action=n}function cm(e){var n=zt(),l=ct;if(l!==null)return om(n,l,e);zt(),n=n.memoizedState,l=zt();var i=l.queue.dispatch;return l.memoizedState=e,[n,i,!1]}function ml(e,n,l,i){return e={tag:e,create:l,deps:i,inst:n,next:null},n=He.updateQueue,n===null&&(n=Li(),He.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(i=l.next,l.next=e,e.next=i,n.lastEffect=e),e}function um(){return zt().memoizedState}function _i(e,n,l,i){var f=ln();He.flags|=e,f.memoizedState=ml(1|n,{destroy:void 0},l,i===void 0?null:i)}function Oi(e,n,l,i){var f=zt();i=i===void 0?null:i;var x=f.memoizedState.inst;ct!==null&&i!==null&&Wc(i,ct.memoizedState.deps)?f.memoizedState=ml(n,x,l,i):(He.flags|=e,f.memoizedState=ml(1|n,x,l,i))}function dm(e,n){_i(8390656,8,e,n)}function nu(e,n){Oi(2048,8,e,n)}function Zb(e){He.flags|=4;var n=He.updateQueue;if(n===null)n=Li(),He.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function fm(e){var n=zt().memoizedState;return Zb({ref:n,nextImpl:e}),function(){if((nt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}function pm(e,n){return Oi(4,2,e,n)}function mm(e,n){return Oi(4,4,e,n)}function hm(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 xm(e,n,l){l=l!=null?l.concat([e]):null,Oi(4,4,hm.bind(null,n,e),l)}function ru(){}function gm(e,n){var l=zt();n=n===void 0?null:n;var i=l.memoizedState;return n!==null&&Wc(n,i[1])?i[0]:(l.memoizedState=[e,n],e)}function vm(e,n){var l=zt();n=n===void 0?null:n;var i=l.memoizedState;if(n!==null&&Wc(n,i[1]))return i[0];if(i=e(),Aa){xt(!0);try{e()}finally{xt(!1)}}return l.memoizedState=[i,n],i}function au(e,n,l){return l===void 0||(yr&1073741824)!==0&&(qe&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=yh(),He.lanes|=e,qr|=e,l)}function ym(e,n,l,i){return yn(l,n)?l:dl.current!==null?(e=au(e,l,i),yn(e,n)||(Bt=!0),e):(yr&42)===0||(yr&1073741824)!==0&&(qe&261930)===0?(Bt=!0,e.memoizedState=l):(e=yh(),He.lanes|=e,qr|=e,n)}function bm(e,n,l,i,f){var x=_.p;_.p=x!==0&&8>x?x:8;var j=L.T,R={};L.T=R,iu(e,!1,n,l);try{var P=f(),Z=L.S;if(Z!==null&&Z(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var le=qb(P,i);is(e,n,le,Cn(e))}else is(e,n,i,Cn(e))}catch(ue){is(e,n,{then:function(){},status:"rejected",reason:ue},Cn())}finally{_.p=x,j!==null&&R.types!==null&&(j.types=R.types),L.T=j}}function Jb(){}function lu(e,n,l,i){if(e.tag!==5)throw Error(o(476));var f=jm(e).queue;bm(e,f,n,I,l===null?Jb:function(){return Sm(e),l(i)})}function jm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:I},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Sm(e){var n=jm(e);n.next===null&&(n=e.alternate.memoizedState),is(e,n.next.queue,{},Cn())}function su(){return Xt(ws)}function km(){return zt().memoizedState}function wm(){return zt().memoizedState}function e1(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Cn();e=$r(l);var i=Vr(n,e,l);i!==null&&(vn(i,n,l),ns(i,n,l)),n={cache:_c()},e.payload=n;return}n=n.return}}function t1(e,n,l){var i=Cn();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Bi(e)?Em(n,l):(l=wc(e,n,l,i),l!==null&&(vn(l,e,i),Nm(l,n,i)))}function Cm(e,n,l){var i=Cn();is(e,n,l,i)}function is(e,n,l,i){var f={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Bi(e))Em(n,f);else{var x=e.alternate;if(e.lanes===0&&(x===null||x.lanes===0)&&(x=n.lastRenderedReducer,x!==null))try{var j=n.lastRenderedState,R=x(j,l);if(f.hasEagerState=!0,f.eagerState=R,yn(R,j))return gi(e,n,f,0),mt===null&&xi(),!1}catch{}finally{}if(l=wc(e,n,f,i),l!==null)return vn(l,e,i),Nm(l,n,i),!0}return!1}function iu(e,n,l,i){if(i={lane:2,revertLane:Uu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Bi(e)){if(n)throw Error(o(479))}else n=wc(e,l,i,2),n!==null&&vn(n,e,2)}function Bi(e){var n=e.alternate;return e===He||n!==null&&n===He}function Em(e,n){fl=Ai=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Nm(e,n,l){if((l&4194048)!==0){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pa(e,l)}}var os={readContext:Xt,use:zi,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useLayoutEffect:Rt,useInsertionEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useSyncExternalStore:Rt,useId:Rt,useHostTransitionStatus:Rt,useFormState:Rt,useActionState:Rt,useOptimistic:Rt,useMemoCache:Rt,useCacheRefresh:Rt};os.useEffectEvent=Rt;var Tm={readContext:Xt,use:zi,useCallback:function(e,n){return ln().memoizedState=[e,n===void 0?null:n],e},useContext:Xt,useEffect:dm,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,_i(4194308,4,hm.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=ln();n=n===void 0?null:n;var i=e();if(Aa){xt(!0);try{e()}finally{xt(!1)}}return l.memoizedState=[i,n],i},useReducer:function(e,n,l){var i=ln();if(l!==void 0){var f=l(n);if(Aa){xt(!0);try{l(n)}finally{xt(!1)}}}else f=n;return i.memoizedState=i.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},i.queue=e,e=e.dispatch=t1.bind(null,He,e),[i.memoizedState,e]},useRef:function(e){var n=ln();return e={current:e},n.memoizedState=e},useState:function(e){e=eu(e);var n=e.queue,l=Cm.bind(null,He,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:ru,useDeferredValue:function(e,n){var l=ln();return au(l,e,n)},useTransition:function(){var e=eu(!1);return e=bm.bind(null,He,e.queue,!0,!1),ln().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var i=He,f=ln();if(Ke){if(l===void 0)throw Error(o(407));l=l()}else{if(l=n(),mt===null)throw Error(o(349));(qe&127)!==0||Kp(i,n,l)}f.memoizedState=l;var x={value:l,getSnapshot:n};return f.queue=x,dm(Qp.bind(null,i,x,e),[e]),i.flags|=2048,ml(9,{destroy:void 0},Xp.bind(null,i,x,l,n),null),l},useId:function(){var e=ln(),n=mt.identifierPrefix;if(Ke){var l=ar,i=rr;l=(i&~(1<<32-gt(i)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Mi++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=Yb++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:su,useFormState:sm,useActionState:sm,useOptimistic:function(e){var n=ln();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=iu.bind(null,He,!0,l),l.dispatch=n,[e,n]},useMemoCache:Qc,useCacheRefresh:function(){return ln().memoizedState=e1.bind(null,He)},useEffectEvent:function(e){var n=ln(),l={impl:e};return n.memoizedState=l,function(){if((nt&2)!==0)throw Error(o(440));return l.impl.apply(void 0,arguments)}}},ou={readContext:Xt,use:zi,useCallback:gm,useContext:Xt,useEffect:nu,useImperativeHandle:xm,useInsertionEffect:pm,useLayoutEffect:mm,useMemo:vm,useReducer:Di,useRef:um,useState:function(){return Di(br)},useDebugValue:ru,useDeferredValue:function(e,n){var l=zt();return ym(l,ct.memoizedState,e,n)},useTransition:function(){var e=Di(br)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:ss(e),n]},useSyncExternalStore:Yp,useId:km,useHostTransitionStatus:su,useFormState:im,useActionState:im,useOptimistic:function(e,n){var l=zt();return em(l,ct,e,n)},useMemoCache:Qc,useCacheRefresh:wm};ou.useEffectEvent=fm;var Rm={readContext:Xt,use:zi,useCallback:gm,useContext:Xt,useEffect:nu,useImperativeHandle:xm,useInsertionEffect:pm,useLayoutEffect:mm,useMemo:vm,useReducer:Jc,useRef:um,useState:function(){return Jc(br)},useDebugValue:ru,useDeferredValue:function(e,n){var l=zt();return ct===null?au(l,e,n):ym(l,ct.memoizedState,e,n)},useTransition:function(){var e=Jc(br)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:ss(e),n]},useSyncExternalStore:Yp,useId:km,useHostTransitionStatus:su,useFormState:cm,useActionState:cm,useOptimistic:function(e,n){var l=zt();return ct!==null?em(l,ct,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Qc,useCacheRefresh:wm};Rm.useEffectEvent=fm;function cu(e,n,l,i){n=e.memoizedState,l=l(i,n),l=l==null?n:v({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var uu={enqueueSetState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$r(i);f.payload=n,l!=null&&(f.callback=l),n=Vr(e,f,i),n!==null&&(vn(n,e,i),ns(n,e,i))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$r(i);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Vr(e,f,i),n!==null&&(vn(n,e,i),ns(n,e,i))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Cn(),i=$r(l);i.tag=2,n!=null&&(i.callback=n),n=Vr(e,i,l),n!==null&&(vn(n,e,l),ns(n,e,l))}};function Am(e,n,l,i,f,x,j){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,x,j):n.prototype&&n.prototype.isPureReactComponent?!Yl(l,i)||!Yl(f,x):!0}function Mm(e,n,l,i){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,i),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,i),n.state!==e&&uu.enqueueReplaceState(n,n.state,null)}function Ma(e,n){var l=n;if("ref"in n){l={};for(var i in n)i!=="ref"&&(l[i]=n[i])}if(e=e.defaultProps){l===n&&(l=v({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function Lm(e){hi(e)}function zm(e){console.error(e)}function Dm(e){hi(e)}function Ii(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(i){setTimeout(function(){throw i})}}function _m(e,n,l){try{var i=e.onCaughtError;i(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function du(e,n,l){return l=$r(l),l.tag=3,l.payload={element:null},l.callback=function(){Ii(e,n)},l}function Om(e){return e=$r(e),e.tag=3,e}function Bm(e,n,l,i){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var x=i.value;e.payload=function(){return f(x)},e.callback=function(){_m(n,l,i)}}var j=l.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(e.callback=function(){_m(n,l,i),typeof f!="function"&&(Yr===null?Yr=new Set([this]):Yr.add(this));var R=i.stack;this.componentDidCatch(i.value,{componentStack:R!==null?R:""})})}function n1(e,n,l,i,f){if(l.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(n=l.alternate,n!==null&&sl(n,l,f,!0),l=jn.current,l!==null){switch(l.tag){case 31:case 13:return Un===null?Xi():l.alternate===null&&At===0&&(At=3),l.flags&=-257,l.flags|=65536,l.lanes=f,i===Ci?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([i]):n.add(i),Ou(e,i,f)),!1;case 22:return l.flags|=65536,i===Ci?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([i])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([i]):l.add(i)),Ou(e,i,f)),!1}throw Error(o(435,l.tag))}return Ou(e,i,f),Xi(),!1}if(Ke)return n=jn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,i!==Ac&&(e=Error(o(422),{cause:i}),Ql(_n(e,l)))):(i!==Ac&&(n=Error(o(423),{cause:i}),Ql(_n(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,i=_n(i,l),f=du(e.stateNode,i,f),$c(e,f),At!==4&&(At=2)),!1;var x=Error(o(520),{cause:i});if(x=_n(x,l),xs===null?xs=[x]:xs.push(x),At!==4&&(At=2),n===null)return!0;i=_n(i,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=du(l.stateNode,i,e),$c(l,e),!1;case 1:if(n=l.type,x=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Yr===null||!Yr.has(x))))return l.flags|=65536,f&=-f,l.lanes|=f,f=Om(f),Bm(f,e,l,i),$c(l,f),!1}l=l.return}while(l!==null);return!1}var fu=Error(o(461)),Bt=!1;function Qt(e,n,l,i){n.child=e===null?$p(n,null,l,i):Ra(n,e.child,l,i)}function Im(e,n,l,i,f){l=l.render;var x=n.ref;if("ref"in i){var j={};for(var R in i)R!=="ref"&&(j[R]=i[R])}else j=i;return Ca(n),i=qc(e,n,l,j,x,f),R=Yc(),e!==null&&!Bt?(Kc(e,n,f),jr(e,n,f)):(Ke&&R&&Tc(n),n.flags|=1,Qt(e,n,i,f),n.child)}function Um(e,n,l,i,f){if(e===null){var x=l.type;return typeof x=="function"&&!Cc(x)&&x.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=x,Hm(e,n,x,i,f)):(e=yi(l.type,null,i,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(x=e.child,!bu(e,f)){var j=x.memoizedProps;if(l=l.compare,l=l!==null?l:Yl,l(j,i)&&e.ref===n.ref)return jr(e,n,f)}return n.flags|=1,e=hr(x,i),e.ref=n.ref,e.return=n,n.child=e}function Hm(e,n,l,i,f){if(e!==null){var x=e.memoizedProps;if(Yl(x,i)&&e.ref===n.ref)if(Bt=!1,n.pendingProps=i=x,bu(e,f))(e.flags&131072)!==0&&(Bt=!0);else return n.lanes=e.lanes,jr(e,n,f)}return pu(e,n,l,i,f)}function $m(e,n,l,i){var f=i.children,x=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((n.flags&128)!==0){if(x=x!==null?x.baseLanes|l:l,e!==null){for(i=n.child=e.child,f=0;i!==null;)f=f|i.lanes|i.childLanes,i=i.sibling;i=f&~x}else i=0,n.child=null;return Vm(e,n,x,l,i)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&ki(n,x!==null?x.cachePool:null),x!==null?Fp(n,x):Pc(),Gp(n);else return i=n.lanes=536870912,Vm(e,n,x!==null?x.baseLanes|l:l,l,i)}else x!==null?(ki(n,x.cachePool),Fp(n,x),Fr(),n.memoizedState=null):(e!==null&&ki(n,null),Pc(),Fr());return Qt(e,n,f,l),n.child}function cs(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Vm(e,n,l,i,f){var x=Bc();return x=x===null?null:{parent:_t._currentValue,pool:x},n.memoizedState={baseLanes:l,cachePool:x},e!==null&&ki(n,null),Pc(),Gp(n),e!==null&&sl(e,n,i,!0),n.childLanes=f,null}function Ui(e,n){return n=$i({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Pm(e,n,l){return Ra(n,e.child,null,l),e=Ui(n,n.pendingProps),e.flags|=2,Sn(n),n.memoizedState=null,e}function r1(e,n,l){var i=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Ke){if(i.mode==="hidden")return e=Ui(n,i),n.lanes=536870912,cs(null,e);if(Gc(n),(e=vt)?(e=tx(e,In),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Or!==null?{id:rr,overflow:ar}:null,retryLane:536870912,hydrationErrors:null},l=Ep(e),l.return=n,n.child=l,Kt=n,vt=null)):e=null,e===null)throw Ir(n);return n.lanes=536870912,null}return Ui(n,i)}var x=e.memoizedState;if(x!==null){var j=x.dehydrated;if(Gc(n),f)if(n.flags&256)n.flags&=-257,n=Pm(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(o(558));else if(Bt||sl(e,n,l,!1),f=(l&e.childLanes)!==0,Bt||f){if(i=mt,i!==null&&(j=ma(i,l),j!==0&&j!==x.retryLane))throw x.retryLane=j,ja(e,j),vn(i,e,j),fu;Xi(),n=Pm(e,n,l)}else e=x.treeContext,vt=Hn(j.nextSibling),Kt=n,Ke=!0,Br=null,In=!1,e!==null&&Rp(n,e),n=Ui(n,i),n.flags|=4096;return n}return e=hr(e.child,{mode:i.mode,children:i.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Hi(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(o(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function pu(e,n,l,i,f){return Ca(n),l=qc(e,n,l,i,void 0,f),i=Yc(),e!==null&&!Bt?(Kc(e,n,f),jr(e,n,f)):(Ke&&i&&Tc(n),n.flags|=1,Qt(e,n,l,f),n.child)}function Fm(e,n,l,i,f,x){return Ca(n),n.updateQueue=null,l=qp(n,i,l,f),Wp(e),i=Yc(),e!==null&&!Bt?(Kc(e,n,x),jr(e,n,x)):(Ke&&i&&Tc(n),n.flags|=1,Qt(e,n,l,x),n.child)}function Gm(e,n,l,i,f){if(Ca(n),n.stateNode===null){var x=nl,j=l.contextType;typeof j=="object"&&j!==null&&(x=Xt(j)),x=new l(i,x),n.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=uu,n.stateNode=x,x._reactInternals=n,x=n.stateNode,x.props=i,x.state=n.memoizedState,x.refs={},Uc(n),j=l.contextType,x.context=typeof j=="object"&&j!==null?Xt(j):nl,x.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(cu(n,l,j,i),x.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(j=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),j!==x.state&&uu.enqueueReplaceState(x,x.state,null),as(n,i,x,f),rs(),x.state=n.memoizedState),typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!0}else if(e===null){x=n.stateNode;var R=n.memoizedProps,P=Ma(l,R);x.props=P;var Z=x.context,le=l.contextType;j=nl,typeof le=="object"&&le!==null&&(j=Xt(le));var ue=l.getDerivedStateFromProps;le=typeof ue=="function"||typeof x.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,le||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(R||Z!==j)&&Mm(n,x,i,j),Hr=!1;var ee=n.memoizedState;x.state=ee,as(n,i,x,f),rs(),Z=n.memoizedState,R||ee!==Z||Hr?(typeof ue=="function"&&(cu(n,l,ue,i),Z=n.memoizedState),(P=Hr||Am(n,l,P,i,ee,Z,j))?(le||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=i,n.memoizedState=Z),x.props=i,x.state=Z,x.context=j,i=P):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!1)}else{x=n.stateNode,Hc(e,n),j=n.memoizedProps,le=Ma(l,j),x.props=le,ue=n.pendingProps,ee=x.context,Z=l.contextType,P=nl,typeof Z=="object"&&Z!==null&&(P=Xt(Z)),R=l.getDerivedStateFromProps,(Z=typeof R=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(j!==ue||ee!==P)&&Mm(n,x,i,P),Hr=!1,ee=n.memoizedState,x.state=ee,as(n,i,x,f),rs();var re=n.memoizedState;j!==ue||ee!==re||Hr||e!==null&&e.dependencies!==null&&ji(e.dependencies)?(typeof R=="function"&&(cu(n,l,R,i),re=n.memoizedState),(le=Hr||Am(n,l,le,i,ee,re,P)||e!==null&&e.dependencies!==null&&ji(e.dependencies))?(Z||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(i,re,P),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(i,re,P)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),n.memoizedProps=i,n.memoizedState=re),x.props=i,x.state=re,x.context=P,i=le):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),i=!1)}return x=i,Hi(e,n),i=(n.flags&128)!==0,x||i?(x=n.stateNode,l=i&&typeof l.getDerivedStateFromError!="function"?null:x.render(),n.flags|=1,e!==null&&i?(n.child=Ra(n,e.child,null,f),n.child=Ra(n,null,l,f)):Qt(e,n,l,f),n.memoizedState=x.state,e=n.child):e=jr(e,n,f),e}function Wm(e,n,l,i){return ka(),n.flags|=256,Qt(e,n,l,i),n.child}var mu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function hu(e){return{baseLanes:e,cachePool:_p()}}function xu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=wn),e}function qm(e,n,l){var i=n.pendingProps,f=!1,x=(n.flags&128)!==0,j;if((j=x)||(j=e!==null&&e.memoizedState===null?!1:(Lt.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Ke){if(f?Pr(n):Fr(),(e=vt)?(e=tx(e,In),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Or!==null?{id:rr,overflow:ar}:null,retryLane:536870912,hydrationErrors:null},l=Ep(e),l.return=n,n.child=l,Kt=n,vt=null)):e=null,e===null)throw Ir(n);return Zu(e)?n.lanes=32:n.lanes=536870912,null}var R=i.children;return i=i.fallback,f?(Fr(),f=n.mode,R=$i({mode:"hidden",children:R},f),i=Sa(i,f,l,null),R.return=n,i.return=n,R.sibling=i,n.child=R,i=n.child,i.memoizedState=hu(l),i.childLanes=xu(e,j,l),n.memoizedState=mu,cs(null,i)):(Pr(n),gu(n,R))}var P=e.memoizedState;if(P!==null&&(R=P.dehydrated,R!==null)){if(x)n.flags&256?(Pr(n),n.flags&=-257,n=vu(e,n,l)):n.memoizedState!==null?(Fr(),n.child=e.child,n.flags|=128,n=null):(Fr(),R=i.fallback,f=n.mode,i=$i({mode:"visible",children:i.children},f),R=Sa(R,f,l,null),R.flags|=2,i.return=n,R.return=n,i.sibling=R,n.child=i,Ra(n,e.child,null,l),i=n.child,i.memoizedState=hu(l),i.childLanes=xu(e,j,l),n.memoizedState=mu,n=cs(null,i));else if(Pr(n),Zu(R)){if(j=R.nextSibling&&R.nextSibling.dataset,j)var Z=j.dgst;j=Z,i=Error(o(419)),i.stack="",i.digest=j,Ql({value:i,source:null,stack:null}),n=vu(e,n,l)}else if(Bt||sl(e,n,l,!1),j=(l&e.childLanes)!==0,Bt||j){if(j=mt,j!==null&&(i=ma(j,l),i!==0&&i!==P.retryLane))throw P.retryLane=i,ja(e,i),vn(j,e,i),fu;Qu(R)||Xi(),n=vu(e,n,l)}else Qu(R)?(n.flags|=192,n.child=e.child,n=null):(e=P.treeContext,vt=Hn(R.nextSibling),Kt=n,Ke=!0,Br=null,In=!1,e!==null&&Rp(n,e),n=gu(n,i.children),n.flags|=4096);return n}return f?(Fr(),R=i.fallback,f=n.mode,P=e.child,Z=P.sibling,i=hr(P,{mode:"hidden",children:i.children}),i.subtreeFlags=P.subtreeFlags&65011712,Z!==null?R=hr(Z,R):(R=Sa(R,f,l,null),R.flags|=2),R.return=n,i.return=n,i.sibling=R,n.child=i,cs(null,i),i=n.child,R=e.child.memoizedState,R===null?R=hu(l):(f=R.cachePool,f!==null?(P=_t._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=_p(),R={baseLanes:R.baseLanes|l,cachePool:f}),i.memoizedState=R,i.childLanes=xu(e,j,l),n.memoizedState=mu,cs(e.child,i)):(Pr(n),l=e.child,e=l.sibling,l=hr(l,{mode:"visible",children:i.children}),l.return=n,l.sibling=null,e!==null&&(j=n.deletions,j===null?(n.deletions=[e],n.flags|=16):j.push(e)),n.child=l,n.memoizedState=null,l)}function gu(e,n){return n=$i({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function $i(e,n){return e=bn(22,e,null,n),e.lanes=0,e}function vu(e,n,l){return Ra(n,e.child,null,l),e=gu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Ym(e,n,l){e.lanes|=n;var i=e.alternate;i!==null&&(i.lanes|=n),zc(e.return,n,l)}function yu(e,n,l,i,f,x){var j=e.memoizedState;j===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:i,tail:l,tailMode:f,treeForkCount:x}:(j.isBackwards=n,j.rendering=null,j.renderingStartTime=0,j.last=i,j.tail=l,j.tailMode=f,j.treeForkCount=x)}function Km(e,n,l){var i=n.pendingProps,f=i.revealOrder,x=i.tail;i=i.children;var j=Lt.current,R=(j&2)!==0;if(R?(j=j&1|2,n.flags|=128):j&=1,G(Lt,j),Qt(e,n,i,l),i=Ke?Xl:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ym(e,l,n);else if(e.tag===19)Ym(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=n.child,f=null;l!==null;)e=l.alternate,e!==null&&Ri(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),yu(n,!1,f,l,x,i);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Ri(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}yu(n,!0,l,null,x,i);break;case"together":yu(n,!1,null,null,void 0,i);break;default:n.memoizedState=null}return n.child}function jr(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),qr|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(sl(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,l=hr(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=hr(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function bu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&ji(e)))}function a1(e,n,l){switch(n.tag){case 3:de(n,n.stateNode.containerInfo),Ur(n,_t,e.memoizedState.cache),ka();break;case 27:case 5:Ae(n);break;case 4:de(n,n.stateNode.containerInfo);break;case 10:Ur(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Gc(n),null;break;case 13:var i=n.memoizedState;if(i!==null)return i.dehydrated!==null?(Pr(n),n.flags|=128,null):(l&n.child.childLanes)!==0?qm(e,n,l):(Pr(n),e=jr(e,n,l),e!==null?e.sibling:null);Pr(n);break;case 19:var f=(e.flags&128)!==0;if(i=(l&n.childLanes)!==0,i||(sl(e,n,l,!1),i=(l&n.childLanes)!==0),f){if(i)return Km(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),G(Lt,Lt.current),i)break;return null;case 22:return n.lanes=0,$m(e,n,l,n.pendingProps);case 24:Ur(n,_t,e.memoizedState.cache)}return jr(e,n,l)}function Xm(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Bt=!0;else{if(!bu(e,l)&&(n.flags&128)===0)return Bt=!1,a1(e,n,l);Bt=(e.flags&131072)!==0}else Bt=!1,Ke&&(n.flags&1048576)!==0&&Tp(n,Xl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var i=n.pendingProps;if(e=Na(n.elementType),n.type=e,typeof e=="function")Cc(e)?(i=Ma(e,i),n.tag=1,n=Gm(null,n,e,i,l)):(n.tag=0,n=pu(null,n,e,i,l));else{if(e!=null){var f=e.$$typeof;if(f===B){n.tag=11,n=Im(null,n,e,i,l);break e}else if(f===w){n.tag=14,n=Um(null,n,e,i,l);break e}}throw n=J(e)||e,Error(o(306,n,""))}}return n;case 0:return pu(e,n,n.type,n.pendingProps,l);case 1:return i=n.type,f=Ma(i,n.pendingProps),Gm(e,n,i,f,l);case 3:e:{if(de(n,n.stateNode.containerInfo),e===null)throw Error(o(387));i=n.pendingProps;var x=n.memoizedState;f=x.element,Hc(e,n),as(n,i,null,l);var j=n.memoizedState;if(i=j.cache,Ur(n,_t,i),i!==x.cache&&Dc(n,[_t],l,!0),rs(),i=j.element,x.isDehydrated)if(x={element:i,isDehydrated:!1,cache:j.cache},n.updateQueue.baseState=x,n.memoizedState=x,n.flags&256){n=Wm(e,n,i,l);break e}else if(i!==f){f=_n(Error(o(424)),n),Ql(f),n=Wm(e,n,i,l);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(vt=Hn(e.firstChild),Kt=n,Ke=!0,Br=null,In=!0,l=$p(n,null,i,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(ka(),i===f){n=jr(e,n,l);break e}Qt(e,n,i,l)}n=n.child}return n;case 26:return Hi(e,n),e===null?(l=ix(n.type,null,n.pendingProps,null))?n.memoizedState=l:Ke||(l=n.type,e=n.pendingProps,i=ro(ie.current).createElement(l),i[Ht]=n,i[ot]=e,Zt(i,l,e),Wt(i),n.stateNode=i):n.memoizedState=ix(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Ae(n),e===null&&Ke&&(i=n.stateNode=ax(n.type,n.pendingProps,ie.current),Kt=n,In=!0,f=vt,Zr(n.type)?(Ju=f,vt=Hn(i.firstChild)):vt=f),Qt(e,n,n.pendingProps.children,l),Hi(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Ke&&((f=i=vt)&&(i=D1(i,n.type,n.pendingProps,In),i!==null?(n.stateNode=i,Kt=n,vt=Hn(i.firstChild),In=!1,f=!0):f=!1),f||Ir(n)),Ae(n),f=n.type,x=n.pendingProps,j=e!==null?e.memoizedProps:null,i=x.children,Yu(f,x)?i=null:j!==null&&Yu(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=qc(e,n,Kb,null,null,l),ws._currentValue=f),Hi(e,n),Qt(e,n,i,l),n.child;case 6:return e===null&&Ke&&((e=l=vt)&&(l=_1(l,n.pendingProps,In),l!==null?(n.stateNode=l,Kt=n,vt=null,e=!0):e=!1),e||Ir(n)),null;case 13:return qm(e,n,l);case 4:return de(n,n.stateNode.containerInfo),i=n.pendingProps,e===null?n.child=Ra(n,null,i,l):Qt(e,n,i,l),n.child;case 11:return Im(e,n,n.type,n.pendingProps,l);case 7:return Qt(e,n,n.pendingProps,l),n.child;case 8:return Qt(e,n,n.pendingProps.children,l),n.child;case 12:return Qt(e,n,n.pendingProps.children,l),n.child;case 10:return i=n.pendingProps,Ur(n,n.type,i.value),Qt(e,n,i.children,l),n.child;case 9:return f=n.type._context,i=n.pendingProps.children,Ca(n),f=Xt(f),i=i(f),n.flags|=1,Qt(e,n,i,l),n.child;case 14:return Um(e,n,n.type,n.pendingProps,l);case 15:return Hm(e,n,n.type,n.pendingProps,l);case 19:return Km(e,n,l);case 31:return r1(e,n,l);case 22:return $m(e,n,l,n.pendingProps);case 24:return Ca(n),i=Xt(_t),e===null?(f=Bc(),f===null&&(f=mt,x=_c(),f.pooledCache=x,x.refCount++,x!==null&&(f.pooledCacheLanes|=l),f=x),n.memoizedState={parent:i,cache:f},Uc(n),Ur(n,_t,f)):((e.lanes&l)!==0&&(Hc(e,n),as(n,null,null,l),rs()),f=e.memoizedState,x=n.memoizedState,f.parent!==i?(f={parent:i,cache:i},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Ur(n,_t,i)):(i=x.cache,Ur(n,_t,i),i!==f.cache&&Dc(n,[_t],l,!0))),Qt(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(o(156,n.tag))}function Sr(e){e.flags|=4}function ju(e,n,l,i,f){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(kh())e.flags|=8192;else throw Ta=Ci,Ic}else e.flags&=-16777217}function Qm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!fx(n))if(kh())e.flags|=8192;else throw Ta=Ci,Ic}function Vi(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?qn():536870912,e.lanes|=n,vl|=n)}function us(e,n){if(!Ke)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var i=null;l!==null;)l.alternate!==null&&(i=l),l=l.sibling;i===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function yt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,i=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags&65011712,i|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags,i|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=i,e.childLanes=l,n}function l1(e,n,l){var i=n.pendingProps;switch(Rc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yt(n),null;case 1:return yt(n),null;case 3:return l=n.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),vr(_t),Se(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(ll(n)?Sr(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Mc())),yt(n),null;case 26:var f=n.type,x=n.memoizedState;return e===null?(Sr(n),x!==null?(yt(n),Qm(n,x)):(yt(n),ju(n,f,null,i,l))):x?x!==e.memoizedState?(Sr(n),yt(n),Qm(n,x)):(yt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==i&&Sr(n),yt(n),ju(n,f,e,i,l)),null;case 27:if(_e(n),l=ie.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return yt(n),null}e=te.current,ll(n)?Ap(n):(e=ax(f,i,l),n.stateNode=e,Sr(n))}return yt(n),null;case 5:if(_e(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return yt(n),null}if(x=te.current,ll(n))Ap(n);else{var j=ro(ie.current);switch(x){case 1:x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":x=j.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof i.is=="string"?j.createElement("select",{is:i.is}):j.createElement("select"),i.multiple?x.multiple=!0:i.size&&(x.size=i.size);break;default:x=typeof i.is=="string"?j.createElement(f,{is:i.is}):j.createElement(f)}}x[Ht]=n,x[ot]=i;e:for(j=n.child;j!==null;){if(j.tag===5||j.tag===6)x.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===n)break e;for(;j.sibling===null;){if(j.return===null||j.return===n)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}n.stateNode=x;e:switch(Zt(x,f,i),f){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Sr(n)}}return yt(n),ju(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(typeof i!="string"&&n.stateNode===null)throw Error(o(166));if(e=ie.current,ll(n)){if(e=n.stateNode,l=n.memoizedProps,i=null,f=Kt,f!==null)switch(f.tag){case 27:case 5:i=f.memoizedProps}e[Ht]=n,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||qh(e.nodeValue,l)),e||Ir(n,!0)}else e=ro(e).createTextNode(i),e[Ht]=n,n.stateNode=e}return yt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(i=ll(n),l!==null){if(e===null){if(!i)throw Error(o(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[Ht]=n}else ka(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),e=!1}else l=Mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Sn(n),n):(Sn(n),null);if((n.flags&128)!==0)throw Error(o(558))}return yt(n),null;case 13:if(i=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=ll(n),i!==null&&i.dehydrated!==null){if(e===null){if(!f)throw Error(o(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));f[Ht]=n}else ka(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),f=!1}else f=Mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Sn(n),n):(Sn(n),null)}return Sn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=n.child,f=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(f=i.alternate.memoizedState.cachePool.pool),x=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(x=i.memoizedState.cachePool.pool),x!==f&&(i.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),Vi(n,n.updateQueue),yt(n),null);case 4:return Se(),e===null&&Pu(n.stateNode.containerInfo),yt(n),null;case 10:return vr(n.type),yt(n),null;case 19:if(Y(Lt),i=n.memoizedState,i===null)return yt(n),null;if(f=(n.flags&128)!==0,x=i.rendering,x===null)if(f)us(i,!1);else{if(At!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=Ri(e),x!==null){for(n.flags|=128,us(i,!1),e=x.updateQueue,n.updateQueue=e,Vi(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Cp(l,e),l=l.sibling;return G(Lt,Lt.current&1|2),Ke&&xr(n,i.treeForkCount),n.child}e=e.sibling}i.tail!==null&&Qe()>qi&&(n.flags|=128,f=!0,us(i,!1),n.lanes=4194304)}else{if(!f)if(e=Ri(x),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,Vi(n,e),us(i,!0),i.tail===null&&i.tailMode==="hidden"&&!x.alternate&&!Ke)return yt(n),null}else 2*Qe()-i.renderingStartTime>qi&&l!==536870912&&(n.flags|=128,f=!0,us(i,!1),n.lanes=4194304);i.isBackwards?(x.sibling=n.child,n.child=x):(e=i.last,e!==null?e.sibling=x:n.child=x,i.last=x)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Qe(),e.sibling=null,l=Lt.current,G(Lt,f?l&1|2:l&1),Ke&&xr(n,i.treeForkCount),e):(yt(n),null);case 22:case 23:return Sn(n),Fc(),i=n.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(n.flags|=8192):i&&(n.flags|=8192),i?(l&536870912)!==0&&(n.flags&128)===0&&(yt(n),n.subtreeFlags&6&&(n.flags|=8192)):yt(n),l=n.updateQueue,l!==null&&Vi(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==l&&(n.flags|=2048),e!==null&&Y(Ea),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),vr(_t),yt(n),null;case 25:return null;case 30:return null}throw Error(o(156,n.tag))}function s1(e,n){switch(Rc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return vr(_t),Se(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return _e(n),null;case 31:if(n.memoizedState!==null){if(Sn(n),n.alternate===null)throw Error(o(340));ka()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Sn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ka()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Y(Lt),null;case 4:return Se(),null;case 10:return vr(n.type),null;case 22:case 23:return Sn(n),Fc(),e!==null&&Y(Ea),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return vr(_t),null;case 25:return null;default:return null}}function Zm(e,n){switch(Rc(n),n.tag){case 3:vr(_t),Se();break;case 26:case 27:case 5:_e(n);break;case 4:Se();break;case 31:n.memoizedState!==null&&Sn(n);break;case 13:Sn(n);break;case 19:Y(Lt);break;case 10:vr(n.type);break;case 22:case 23:Sn(n),Fc(),e!==null&&Y(Ea);break;case 24:vr(_t)}}function ds(e,n){try{var l=n.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var f=i.next;l=f;do{if((l.tag&e)===e){i=void 0;var x=l.create,j=l.inst;i=x(),j.destroy=i}l=l.next}while(l!==f)}}catch(R){st(n,n.return,R)}}function Gr(e,n,l){try{var i=n.updateQueue,f=i!==null?i.lastEffect:null;if(f!==null){var x=f.next;i=x;do{if((i.tag&e)===e){var j=i.inst,R=j.destroy;if(R!==void 0){j.destroy=void 0,f=n;var P=l,Z=R;try{Z()}catch(le){st(f,P,le)}}}i=i.next}while(i!==x)}}catch(le){st(n,n.return,le)}}function Jm(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Pp(n,l)}catch(i){st(e,e.return,i)}}}function eh(e,n,l){l.props=Ma(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){st(e,n,i)}}function fs(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(f){st(e,n,f)}}function lr(e,n){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(f){st(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){st(e,n,f)}else l.current=null}function th(e){var n=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(f){st(e,e.return,f)}}function Su(e,n,l){try{var i=e.stateNode;T1(i,e.type,l,n),i[ot]=n}catch(f){st(e,e.return,f)}}function nh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zr(e.type)||e.tag===4}function ku(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||nh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function wu(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=pr));else if(i!==4&&(i===27&&Zr(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(wu(e,n,l),e=e.sibling;e!==null;)wu(e,n,l),e=e.sibling}function Pi(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(i!==4&&(i===27&&Zr(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Pi(e,n,l),e=e.sibling;e!==null;)Pi(e,n,l),e=e.sibling}function rh(e){var n=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);Zt(n,i,l),n[Ht]=e,n[ot]=l}catch(x){st(e,e.return,x)}}var kr=!1,It=!1,Cu=!1,ah=typeof WeakSet=="function"?WeakSet:Set,qt=null;function i1(e,n){if(e=e.containerInfo,Wu=uo,e=xp(e),vc(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var f=i.anchorOffset,x=i.focusNode;i=i.focusOffset;try{l.nodeType,x.nodeType}catch{l=null;break e}var j=0,R=-1,P=-1,Z=0,le=0,ue=e,ee=null;t:for(;;){for(var re;ue!==l||f!==0&&ue.nodeType!==3||(R=j+f),ue!==x||i!==0&&ue.nodeType!==3||(P=j+i),ue.nodeType===3&&(j+=ue.nodeValue.length),(re=ue.firstChild)!==null;)ee=ue,ue=re;for(;;){if(ue===e)break t;if(ee===l&&++Z===f&&(R=j),ee===x&&++le===i&&(P=j),(re=ue.nextSibling)!==null)break;ue=ee,ee=ue.parentNode}ue=re}l=R===-1||P===-1?null:{start:R,end:P}}else l=null}l=l||{start:0,end:0}}else l=null;for(qu={focusedElem:e,selectionRange:l},uo=!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,x=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&x!==null){e=void 0,l=n,f=x.memoizedProps,x=x.memoizedState,i=l.stateNode;try{var we=Ma(l.type,f);e=i.getSnapshotBeforeUpdate(we,x),i.__reactInternalSnapshotBeforeUpdate=e}catch(Le){st(l,l.return,Le)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Xu(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Xu(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=n.sibling,e!==null){e.return=n.return,qt=e;break}qt=n.return}}function lh(e,n,l){var i=l.flags;switch(l.tag){case 0:case 11:case 15:Cr(e,l),i&4&&ds(5,l);break;case 1:if(Cr(e,l),i&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){st(l,l.return,j)}else{var f=Ma(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){st(l,l.return,j)}}i&64&&Jm(l),i&512&&fs(l,l.return);break;case 3:if(Cr(e,l),i&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Pp(e,n)}catch(j){st(l,l.return,j)}}break;case 27:n===null&&i&4&&rh(l);case 26:case 5:Cr(e,l),n===null&&i&4&&th(l),i&512&&fs(l,l.return);break;case 12:Cr(e,l);break;case 31:Cr(e,l),i&4&&oh(e,l);break;case 13:Cr(e,l),i&4&&ch(e,l),i&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=x1.bind(null,l),O1(e,l))));break;case 22:if(i=l.memoizedState!==null||kr,!i){n=n!==null&&n.memoizedState!==null||It,f=kr;var x=It;kr=i,(It=n)&&!x?Er(e,l,(l.subtreeFlags&8772)!==0):Cr(e,l),kr=f,It=x}break;case 30:break;default:Cr(e,l)}}function sh(e){var n=e.alternate;n!==null&&(e.alternate=null,sh(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&tc(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 St=null,mn=!1;function wr(e,n,l){for(l=l.child;l!==null;)ih(e,n,l),l=l.sibling}function ih(e,n,l){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Mn,l)}catch{}switch(l.tag){case 26:It||lr(l,n),wr(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:It||lr(l,n);var i=St,f=mn;Zr(l.type)&&(St=l.stateNode,mn=!1),wr(e,n,l),js(l.stateNode),St=i,mn=f;break;case 5:It||lr(l,n);case 6:if(i=St,f=mn,St=null,wr(e,n,l),St=i,mn=f,St!==null)if(mn)try{(St.nodeType===9?St.body:St.nodeName==="HTML"?St.ownerDocument.body:St).removeChild(l.stateNode)}catch(x){st(l,n,x)}else try{St.removeChild(l.stateNode)}catch(x){st(l,n,x)}break;case 18:St!==null&&(mn?(e=St,Jh(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),El(e)):Jh(St,l.stateNode));break;case 4:i=St,f=mn,St=l.stateNode.containerInfo,mn=!0,wr(e,n,l),St=i,mn=f;break;case 0:case 11:case 14:case 15:Gr(2,l,n),It||Gr(4,l,n),wr(e,n,l);break;case 1:It||(lr(l,n),i=l.stateNode,typeof i.componentWillUnmount=="function"&&eh(l,n,i)),wr(e,n,l);break;case 21:wr(e,n,l);break;case 22:It=(i=It)||l.memoizedState!==null,wr(e,n,l),It=i;break;default:wr(e,n,l)}}function oh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{El(e)}catch(l){st(n,n.return,l)}}}function ch(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{El(e)}catch(l){st(n,n.return,l)}}function o1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new ah),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new ah),n;default:throw Error(o(435,e.tag))}}function Fi(e,n){var l=o1(e);n.forEach(function(i){if(!l.has(i)){l.add(i);var f=g1.bind(null,e,i);i.then(f,f)}})}function hn(e,n){var l=n.deletions;if(l!==null)for(var i=0;i<l.length;i++){var f=l[i],x=e,j=n,R=j;e:for(;R!==null;){switch(R.tag){case 27:if(Zr(R.type)){St=R.stateNode,mn=!1;break e}break;case 5:St=R.stateNode,mn=!1;break e;case 3:case 4:St=R.stateNode.containerInfo,mn=!0;break e}R=R.return}if(St===null)throw Error(o(160));ih(x,j,f),St=null,mn=!1,x=f.alternate,x!==null&&(x.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)uh(n,e),n=n.sibling}var Kn=null;function uh(e,n){var l=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hn(n,e),xn(e),i&4&&(Gr(3,e,e.return),ds(3,e),Gr(5,e,e.return));break;case 1:hn(n,e),xn(e),i&512&&(It||l===null||lr(l,l.return)),i&64&&kr&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?i:l.concat(i))));break;case 26:var f=Kn;if(hn(n,e),xn(e),i&512&&(It||l===null||lr(l,l.return)),i&4){var x=l!==null?l.memoizedState:null;if(i=e.memoizedState,l===null)if(i===null)if(e.stateNode===null){e:{i=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(i){case"title":x=f.getElementsByTagName("title")[0],(!x||x[Ul]||x[Ht]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=f.createElement(i),f.head.insertBefore(x,f.querySelector("head > title"))),Zt(x,i,l),x[Ht]=e,Wt(x),i=x;break e;case"link":var j=ux("link","href",f).get(i+(l.href||""));if(j){for(var R=0;R<j.length;R++)if(x=j[R],x.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&x.getAttribute("rel")===(l.rel==null?null:l.rel)&&x.getAttribute("title")===(l.title==null?null:l.title)&&x.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){j.splice(R,1);break t}}x=f.createElement(i),Zt(x,i,l),f.head.appendChild(x);break;case"meta":if(j=ux("meta","content",f).get(i+(l.content||""))){for(R=0;R<j.length;R++)if(x=j[R],x.getAttribute("content")===(l.content==null?null:""+l.content)&&x.getAttribute("name")===(l.name==null?null:l.name)&&x.getAttribute("property")===(l.property==null?null:l.property)&&x.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&x.getAttribute("charset")===(l.charSet==null?null:l.charSet)){j.splice(R,1);break t}}x=f.createElement(i),Zt(x,i,l),f.head.appendChild(x);break;default:throw Error(o(468,i))}x[Ht]=e,Wt(x),i=x}e.stateNode=i}else dx(f,e.type,e.stateNode);else e.stateNode=cx(f,i,e.memoizedProps);else x!==i?(x===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):x.count--,i===null?dx(f,e.type,e.stateNode):cx(f,i,e.memoizedProps)):i===null&&e.stateNode!==null&&Su(e,e.memoizedProps,l.memoizedProps)}break;case 27:hn(n,e),xn(e),i&512&&(It||l===null||lr(l,l.return)),l!==null&&i&4&&Su(e,e.memoizedProps,l.memoizedProps);break;case 5:if(hn(n,e),xn(e),i&512&&(It||l===null||lr(l,l.return)),e.flags&32){f=e.stateNode;try{Ka(f,"")}catch(we){st(e,e.return,we)}}i&4&&e.stateNode!=null&&(f=e.memoizedProps,Su(e,f,l!==null?l.memoizedProps:f)),i&1024&&(Cu=!0);break;case 6:if(hn(n,e),xn(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,l=e.stateNode;try{l.nodeValue=i}catch(we){st(e,e.return,we)}}break;case 3:if(so=null,f=Kn,Kn=ao(n.containerInfo),hn(n,e),Kn=f,xn(e),i&4&&l!==null&&l.memoizedState.isDehydrated)try{El(n.containerInfo)}catch(we){st(e,e.return,we)}Cu&&(Cu=!1,dh(e));break;case 4:i=Kn,Kn=ao(e.stateNode.containerInfo),hn(n,e),xn(e),Kn=i;break;case 12:hn(n,e),xn(e);break;case 31:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 13:hn(n,e),xn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Wi=Qe()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 22:f=e.memoizedState!==null;var P=l!==null&&l.memoizedState!==null,Z=kr,le=It;if(kr=Z||f,It=le||P,hn(n,e),It=le,kr=Z,xn(e),i&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||P||kr||It||La(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){P=l=n;try{if(x=P.stateNode,f)j=x.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{R=P.stateNode;var ue=P.memoizedProps.style,ee=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;R.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(we){st(P,P.return,we)}}}else if(n.tag===6){if(l===null){P=n;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(we){st(P,P.return,we)}}}else if(n.tag===18){if(l===null){P=n;try{var re=P.stateNode;f?ex(re,!0):ex(P.stateNode,!1)}catch(we){st(P,P.return,we)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}i&4&&(i=e.updateQueue,i!==null&&(l=i.retryQueue,l!==null&&(i.retryQueue=null,Fi(e,l))));break;case 19:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 30:break;case 21:break;default:hn(n,e),xn(e)}}function xn(e){var n=e.flags;if(n&2){try{for(var l,i=e.return;i!==null;){if(nh(i)){l=i;break}i=i.return}if(l==null)throw Error(o(160));switch(l.tag){case 27:var f=l.stateNode,x=ku(e);Pi(e,x,f);break;case 5:var j=l.stateNode;l.flags&32&&(Ka(j,""),l.flags&=-33);var R=ku(e);Pi(e,R,j);break;case 3:case 4:var P=l.stateNode.containerInfo,Z=ku(e);wu(e,Z,P);break;default:throw Error(o(161))}}catch(le){st(e,e.return,le)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function dh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;dh(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Cr(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)lh(e,n.alternate,n),n=n.sibling}function La(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Gr(4,n,n.return),La(n);break;case 1:lr(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&eh(n,n.return,l),La(n);break;case 27:js(n.stateNode);case 26:case 5:lr(n,n.return),La(n);break;case 22:n.memoizedState===null&&La(n);break;case 30:La(n);break;default:La(n)}e=e.sibling}}function Er(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var i=n.alternate,f=e,x=n,j=x.flags;switch(x.tag){case 0:case 11:case 15:Er(f,x,l),ds(4,x);break;case 1:if(Er(f,x,l),i=x,f=i.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(Z){st(i,i.return,Z)}if(i=x,f=i.updateQueue,f!==null){var R=i.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)Vp(P[f],R)}catch(Z){st(i,i.return,Z)}}l&&j&64&&Jm(x),fs(x,x.return);break;case 27:rh(x);case 26:case 5:Er(f,x,l),l&&i===null&&j&4&&th(x),fs(x,x.return);break;case 12:Er(f,x,l);break;case 31:Er(f,x,l),l&&j&4&&oh(f,x);break;case 13:Er(f,x,l),l&&j&4&&ch(f,x);break;case 22:x.memoizedState===null&&Er(f,x,l),fs(x,x.return);break;case 30:break;default:Er(f,x,l)}n=n.sibling}}function Eu(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&&Zl(l))}function Nu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Zl(e))}function Xn(e,n,l,i){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)fh(e,n,l,i),n=n.sibling}function fh(e,n,l,i){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Xn(e,n,l,i),f&2048&&ds(9,n);break;case 1:Xn(e,n,l,i);break;case 3:Xn(e,n,l,i),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Zl(e)));break;case 12:if(f&2048){Xn(e,n,l,i),e=n.stateNode;try{var x=n.memoizedProps,j=x.id,R=x.onPostCommit;typeof R=="function"&&R(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){st(n,n.return,P)}}else Xn(e,n,l,i);break;case 31:Xn(e,n,l,i);break;case 13:Xn(e,n,l,i);break;case 23:break;case 22:x=n.stateNode,j=n.alternate,n.memoizedState!==null?x._visibility&2?Xn(e,n,l,i):ps(e,n):x._visibility&2?Xn(e,n,l,i):(x._visibility|=2,hl(e,n,l,i,(n.subtreeFlags&10256)!==0||!1)),f&2048&&Eu(j,n);break;case 24:Xn(e,n,l,i),f&2048&&Nu(n.alternate,n);break;default:Xn(e,n,l,i)}}function hl(e,n,l,i,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var x=e,j=n,R=l,P=i,Z=j.flags;switch(j.tag){case 0:case 11:case 15:hl(x,j,R,P,f),ds(8,j);break;case 23:break;case 22:var le=j.stateNode;j.memoizedState!==null?le._visibility&2?hl(x,j,R,P,f):ps(x,j):(le._visibility|=2,hl(x,j,R,P,f)),f&&Z&2048&&Eu(j.alternate,j);break;case 24:hl(x,j,R,P,f),f&&Z&2048&&Nu(j.alternate,j);break;default:hl(x,j,R,P,f)}n=n.sibling}}function ps(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,i=n,f=i.flags;switch(i.tag){case 22:ps(l,i),f&2048&&Eu(i.alternate,i);break;case 24:ps(l,i),f&2048&&Nu(i.alternate,i);break;default:ps(l,i)}n=n.sibling}}var ms=8192;function xl(e,n,l){if(e.subtreeFlags&ms)for(e=e.child;e!==null;)ph(e,n,l),e=e.sibling}function ph(e,n,l){switch(e.tag){case 26:xl(e,n,l),e.flags&ms&&e.memoizedState!==null&&Y1(l,Kn,e.memoizedState,e.memoizedProps);break;case 5:xl(e,n,l);break;case 3:case 4:var i=Kn;Kn=ao(e.stateNode.containerInfo),xl(e,n,l),Kn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=ms,ms=16777216,xl(e,n,l),ms=i):xl(e,n,l));break;default:xl(e,n,l)}}function mh(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 hs(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];qt=i,xh(i,e)}mh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)hh(e),e=e.sibling}function hh(e){switch(e.tag){case 0:case 11:case 15:hs(e),e.flags&2048&&Gr(9,e,e.return);break;case 3:hs(e);break;case 12:hs(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Gi(e)):hs(e);break;default:hs(e)}}function Gi(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];qt=i,xh(i,e)}mh(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Gr(8,n,n.return),Gi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Gi(n));break;default:Gi(n)}e=e.sibling}}function xh(e,n){for(;qt!==null;){var l=qt;switch(l.tag){case 0:case 11:case 15:Gr(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var i=l.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:Zl(l.memoizedState.cache)}if(i=l.child,i!==null)i.return=l,qt=i;else e:for(l=e;qt!==null;){i=qt;var f=i.sibling,x=i.return;if(sh(i),i===l){qt=null;break e}if(f!==null){f.return=x,qt=f;break e}qt=x}}}var c1={getCacheForType:function(e){var n=Xt(_t),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return Xt(_t).controller.signal}},u1=typeof WeakMap=="function"?WeakMap:Map,nt=0,mt=null,Ge=null,qe=0,lt=0,kn=null,Wr=!1,gl=!1,Tu=!1,Nr=0,At=0,qr=0,za=0,Ru=0,wn=0,vl=0,xs=null,gn=null,Au=!1,Wi=0,gh=0,qi=1/0,Yi=null,Yr=null,$t=0,Kr=null,yl=null,Tr=0,Mu=0,Lu=null,vh=null,gs=0,zu=null;function Cn(){return(nt&2)!==0&&qe!==0?qe&-qe:L.T!==null?Uu():it()}function yh(){if(wn===0)if((qe&536870912)===0||Ke){var e=oe;oe<<=1,(oe&3932160)===0&&(oe=262144),wn=e}else wn=536870912;return e=jn.current,e!==null&&(e.flags|=32),wn}function vn(e,n,l){(e===mt&&(lt===2||lt===9)||e.cancelPendingCommit!==null)&&(bl(e,0),Xr(e,qe,wn,!1)),fa(e,l),((nt&2)===0||e!==mt)&&(e===mt&&((nt&2)===0&&(za|=l),At===4&&Xr(e,qe,wn,!1)),sr(e))}function bh(e,n,l){if((nt&6)!==0)throw Error(o(327));var i=!l&&(n&127)===0&&(n&e.expiredLanes)===0||fn(e,n),f=i?p1(e,n):_u(e,n,!0),x=i;do{if(f===0){gl&&!i&&Xr(e,n,0,!1);break}else{if(l=e.current.alternate,x&&!d1(l)){f=_u(e,n,!1),x=!1;continue}if(f===2){if(x=n,e.errorRecoveryDisabledLanes&x)var j=0;else j=e.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){n=j;e:{var R=e;f=xs;var P=R.current.memoizedState.isDehydrated;if(P&&(bl(R,j).flags|=256),j=_u(R,j,!1),j!==2){if(Tu&&!P){R.errorRecoveryDisabledLanes|=x,za|=x,f=4;break e}x=gn,gn=f,x!==null&&(gn===null?gn=x:gn.push.apply(gn,x))}f=j}if(x=!1,f!==2)continue}}if(f===1){bl(e,0),Xr(e,n,0,!0);break}e:{switch(i=e,x=f,x){case 0:case 1:throw Error(o(345));case 4:if((n&4194048)!==n)break;case 6:Xr(i,n,wn,!Wr);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((n&62914560)===n&&(f=Wi+300-Qe(),10<f)){if(Xr(i,n,wn,!Wr),dn(i,0,!0)!==0)break e;Tr=n,i.timeoutHandle=Qh(jh.bind(null,i,l,gn,Yi,Au,n,wn,za,vl,Wr,x,"Throttled",-0,0),f);break e}jh(i,l,gn,Yi,Au,n,wn,za,vl,Wr,x,null,-0,0)}}break}while(!0);sr(e)}function jh(e,n,l,i,f,x,j,R,P,Z,le,ue,ee,re){if(e.timeoutHandle=-1,ue=n.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pr},ph(n,x,ue);var we=(x&62914560)===x?Wi-Qe():(x&4194048)===x?gh-Qe():0;if(we=K1(ue,we),we!==null){Tr=x,e.cancelPendingCommit=we(Rh.bind(null,e,n,x,l,i,f,j,R,P,le,ue,null,ee,re)),Xr(e,x,j,!Z);return}}Rh(e,n,x,l,i,f,j,R,P)}function d1(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var i=0;i<l.length;i++){var f=l[i],x=f.getSnapshot;f=f.value;try{if(!yn(x(),f))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Xr(e,n,l,i){n&=~Ru,n&=~za,e.suspendedLanes|=n,e.pingedLanes&=~n,i&&(e.warmLanes|=n),i=e.expirationTimes;for(var f=n;0<f;){var x=31-gt(f),j=1<<x;i[x]=-1,f&=~j}l!==0&&tr(e,l,n)}function Ki(){return(nt&6)===0?(vs(0),!1):!0}function Du(){if(Ge!==null){if(lt===0)var e=Ge.return;else e=Ge,gr=wa=null,Xc(e),ul=null,es=0,e=Ge;for(;e!==null;)Zm(e.alternate,e),e=e.return;Ge=null}}function bl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,M1(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Tr=0,Du(),mt=e,Ge=l=hr(e.current,null),qe=n,lt=0,kn=null,Wr=!1,gl=fn(e,n),Tu=!1,vl=wn=Ru=za=qr=At=0,gn=xs=null,Au=!1,(n&8)!==0&&(n|=n&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=n;0<i;){var f=31-gt(i),x=1<<f;n|=e[f],i&=~x}return Nr=n,xi(),l}function Sh(e,n){He=null,L.H=os,n===cl||n===wi?(n=Ip(),lt=3):n===Ic?(n=Ip(),lt=4):lt=n===fu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,Ge===null&&(At=1,Ii(e,_n(n,e.current)))}function kh(){var e=jn.current;return e===null?!0:(qe&4194048)===qe?Un===null:(qe&62914560)===qe||(qe&536870912)!==0?e===Un:!1}function wh(){var e=L.H;return L.H=os,e===null?os:e}function Ch(){var e=L.A;return L.A=c1,e}function Xi(){At=4,Wr||(qe&4194048)!==qe&&jn.current!==null||(gl=!0),(qr&134217727)===0&&(za&134217727)===0||mt===null||Xr(mt,qe,wn,!1)}function _u(e,n,l){var i=nt;nt|=2;var f=wh(),x=Ch();(mt!==e||qe!==n)&&(Yi=null,bl(e,n)),n=!1;var j=At;e:do try{if(lt!==0&&Ge!==null){var R=Ge,P=kn;switch(lt){case 8:Du(),j=6;break e;case 3:case 2:case 9:case 6:jn.current===null&&(n=!0);var Z=lt;if(lt=0,kn=null,jl(e,R,P,Z),l&&gl){j=0;break e}break;default:Z=lt,lt=0,kn=null,jl(e,R,P,Z)}}f1(),j=At;break}catch(le){Sh(e,le)}while(!0);return n&&e.shellSuspendCounter++,gr=wa=null,nt=i,L.H=f,L.A=x,Ge===null&&(mt=null,qe=0,xi()),j}function f1(){for(;Ge!==null;)Eh(Ge)}function p1(e,n){var l=nt;nt|=2;var i=wh(),f=Ch();mt!==e||qe!==n?(Yi=null,qi=Qe()+500,bl(e,n)):gl=fn(e,n);e:do try{if(lt!==0&&Ge!==null){n=Ge;var x=kn;t:switch(lt){case 1:lt=0,kn=null,jl(e,n,x,1);break;case 2:case 9:if(Op(x)){lt=0,kn=null,Nh(n);break}n=function(){lt!==2&&lt!==9||mt!==e||(lt=7),sr(e)},x.then(n,n);break e;case 3:lt=7;break e;case 4:lt=5;break e;case 7:Op(x)?(lt=0,kn=null,Nh(n)):(lt=0,kn=null,jl(e,n,x,7));break;case 5:var j=null;switch(Ge.tag){case 26:j=Ge.memoizedState;case 5:case 27:var R=Ge;if(j?fx(j):R.stateNode.complete){lt=0,kn=null;var P=R.sibling;if(P!==null)Ge=P;else{var Z=R.return;Z!==null?(Ge=Z,Qi(Z)):Ge=null}break t}}lt=0,kn=null,jl(e,n,x,5);break;case 6:lt=0,kn=null,jl(e,n,x,6);break;case 8:Du(),At=6;break e;default:throw Error(o(462))}}m1();break}catch(le){Sh(e,le)}while(!0);return gr=wa=null,L.H=i,L.A=f,nt=l,Ge!==null?0:(mt=null,qe=0,xi(),At)}function m1(){for(;Ge!==null&&!Dt();)Eh(Ge)}function Eh(e){var n=Xm(e.alternate,e,Nr);e.memoizedProps=e.pendingProps,n===null?Qi(e):Ge=n}function Nh(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=Fm(l,n,n.pendingProps,n.type,void 0,qe);break;case 11:n=Fm(l,n,n.pendingProps,n.type.render,n.ref,qe);break;case 5:Xc(n);default:Zm(l,n),n=Ge=Cp(n,Nr),n=Xm(l,n,Nr)}e.memoizedProps=e.pendingProps,n===null?Qi(e):Ge=n}function jl(e,n,l,i){gr=wa=null,Xc(n),ul=null,es=0;var f=n.return;try{if(n1(e,f,n,l,qe)){At=1,Ii(e,_n(l,e.current)),Ge=null;return}}catch(x){if(f!==null)throw Ge=f,x;At=1,Ii(e,_n(l,e.current)),Ge=null;return}n.flags&32768?(Ke||i===1?e=!0:gl||(qe&536870912)!==0?e=!1:(Wr=e=!0,(i===2||i===9||i===3||i===6)&&(i=jn.current,i!==null&&i.tag===13&&(i.flags|=16384))),Th(n,e)):Qi(n)}function Qi(e){var n=e;do{if((n.flags&32768)!==0){Th(n,Wr);return}e=n.return;var l=l1(n.alternate,n,Nr);if(l!==null){Ge=l;return}if(n=n.sibling,n!==null){Ge=n;return}Ge=n=e}while(n!==null);At===0&&(At=5)}function Th(e,n){do{var l=s1(e.alternate,e);if(l!==null){l.flags&=32767,Ge=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){Ge=e;return}Ge=e=l}while(e!==null);At=6,Ge=null}function Rh(e,n,l,i,f,x,j,R,P){e.cancelPendingCommit=null;do Zi();while($t!==0);if((nt&6)!==0)throw Error(o(327));if(n!==null){if(n===e.current)throw Error(o(177));if(x=n.lanes|n.childLanes,x|=kc,Il(e,l,x,j,R,P),e===mt&&(Ge=mt=null,qe=0),yl=n,Kr=e,Tr=l,Mu=x,Lu=f,vh=i,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,v1(Ct,function(){return Dh(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||i){i=L.T,L.T=null,f=_.p,_.p=2,j=nt,nt|=4;try{i1(e,n,l)}finally{nt=j,_.p=f,L.T=i}}$t=1,Ah(),Mh(),Lh()}}function Ah(){if($t===1){$t=0;var e=Kr,n=yl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=nt;nt|=4;try{uh(n,e);var x=qu,j=xp(e.containerInfo),R=x.focusedElem,P=x.selectionRange;if(j!==R&&R&&R.ownerDocument&&hp(R.ownerDocument.documentElement,R)){if(P!==null&&vc(R)){var Z=P.start,le=P.end;if(le===void 0&&(le=Z),"selectionStart"in R)R.selectionStart=Z,R.selectionEnd=Math.min(le,R.value.length);else{var ue=R.ownerDocument||document,ee=ue&&ue.defaultView||window;if(ee.getSelection){var re=ee.getSelection(),we=R.textContent.length,Le=Math.min(P.start,we),dt=P.end===void 0?Le:Math.min(P.end,we);!re.extend&&Le>dt&&(j=dt,dt=Le,Le=j);var K=mp(R,Le),W=mp(R,dt);if(K&&W&&(re.rangeCount!==1||re.anchorNode!==K.node||re.anchorOffset!==K.offset||re.focusNode!==W.node||re.focusOffset!==W.offset)){var Q=ue.createRange();Q.setStart(K.node,K.offset),re.removeAllRanges(),Le>dt?(re.addRange(Q),re.extend(W.node,W.offset)):(Q.setEnd(W.node,W.offset),re.addRange(Q))}}}}for(ue=[],re=R;re=re.parentNode;)re.nodeType===1&&ue.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<ue.length;R++){var ce=ue[R];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}uo=!!Wu,qu=Wu=null}finally{nt=f,_.p=i,L.T=l}}e.current=n,$t=2}}function Mh(){if($t===2){$t=0;var e=Kr,n=yl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=nt;nt|=4;try{lh(e,n.alternate,n)}finally{nt=f,_.p=i,L.T=l}}$t=3}}function Lh(){if($t===4||$t===3){$t=0,Tt();var e=Kr,n=yl,l=Tr,i=vh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?$t=5:($t=0,yl=Kr=null,zh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Yr=null),Dr(l),n=n.stateNode,Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(Mn,n,void 0,(n.current.flags&128)===128)}catch{}if(i!==null){n=L.T,f=_.p,_.p=2,L.T=null;try{for(var x=e.onRecoverableError,j=0;j<i.length;j++){var R=i[j];x(R.value,{componentStack:R.stack})}}finally{L.T=n,_.p=f}}(Tr&3)!==0&&Zi(),sr(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===zu?gs++:(gs=0,zu=e):gs=0,vs(0)}}function zh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Zl(n)))}function Zi(){return Ah(),Mh(),Lh(),Dh()}function Dh(){if($t!==5)return!1;var e=Kr,n=Mu;Mu=0;var l=Dr(Tr),i=L.T,f=_.p;try{_.p=32>l?32:l,L.T=null,l=Lu,Lu=null;var x=Kr,j=Tr;if($t=0,yl=Kr=null,Tr=0,(nt&6)!==0)throw Error(o(331));var R=nt;if(nt|=4,hh(x.current),fh(x,x.current,j,l),nt=R,vs(0,!1),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(Mn,x)}catch{}return!0}finally{_.p=f,L.T=i,zh(e,n)}}function _h(e,n,l){n=_n(l,n),n=du(e.stateNode,n,2),e=Vr(e,n,2),e!==null&&(fa(e,2),sr(e))}function st(e,n,l){if(e.tag===3)_h(e,e,l);else for(;n!==null;){if(n.tag===3){_h(n,e,l);break}else if(n.tag===1){var i=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Yr===null||!Yr.has(i))){e=_n(l,e),l=Om(2),i=Vr(n,l,2),i!==null&&(Bm(l,i,n,e),fa(i,2),sr(i));break}}n=n.return}}function Ou(e,n,l){var i=e.pingCache;if(i===null){i=e.pingCache=new u1;var f=new Set;i.set(n,f)}else f=i.get(n),f===void 0&&(f=new Set,i.set(n,f));f.has(l)||(Tu=!0,f.add(l),e=h1.bind(null,e,n,l),n.then(e,e))}function h1(e,n,l){var i=e.pingCache;i!==null&&i.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,mt===e&&(qe&l)===l&&(At===4||At===3&&(qe&62914560)===qe&&300>Qe()-Wi?(nt&2)===0&&bl(e,0):Ru|=l,vl===qe&&(vl=0)),sr(e)}function Oh(e,n){n===0&&(n=qn()),e=ja(e,n),e!==null&&(fa(e,n),sr(e))}function x1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Oh(e,l)}function g1(e,n){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(n),Oh(e,l)}function v1(e,n){return Nt(e,n)}var Ji=null,Sl=null,Bu=!1,eo=!1,Iu=!1,Qr=0;function sr(e){e!==Sl&&e.next===null&&(Sl===null?Ji=Sl=e:Sl=Sl.next=e),eo=!0,Bu||(Bu=!0,b1())}function vs(e,n){if(!Iu&&eo){Iu=!0;do for(var l=!1,i=Ji;i!==null;){if(e!==0){var f=i.pendingLanes;if(f===0)var x=0;else{var j=i.suspendedLanes,R=i.pingedLanes;x=(1<<31-gt(42|e)+1)-1,x&=f&~(j&~R),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(l=!0,Hh(i,x))}else x=qe,x=dn(i,i===mt?x:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(x&3)===0||fn(i,x)||(l=!0,Hh(i,x));i=i.next}while(l);Iu=!1}}function y1(){Bh()}function Bh(){eo=Bu=!1;var e=0;Qr!==0&&A1()&&(e=Qr);for(var n=Qe(),l=null,i=Ji;i!==null;){var f=i.next,x=Ih(i,n);x===0?(i.next=null,l===null?Ji=f:l.next=f,f===null&&(Sl=l)):(l=i,(e!==0||(x&3)!==0)&&(eo=!0)),i=f}$t!==0&&$t!==5||vs(e),Qr!==0&&(Qr=0)}function Ih(e,n){for(var l=e.suspendedLanes,i=e.pingedLanes,f=e.expirationTimes,x=e.pendingLanes&-62914561;0<x;){var j=31-gt(x),R=1<<j,P=f[j];P===-1?((R&l)===0||(R&i)!==0)&&(f[j]=ai(R,n)):P<=n&&(e.expiredLanes|=R),x&=~R}if(n=mt,l=qe,l=dn(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,l===0||e===n&&(lt===2||lt===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&ht(i),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||fn(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(i!==null&&ht(i),Dr(l)){case 2:case 8:l=pt;break;case 32:l=Ct;break;case 268435456:l=un;break;default:l=Ct}return i=Uh.bind(null,e),l=Nt(l,i),e.callbackPriority=n,e.callbackNode=l,n}return i!==null&&i!==null&&ht(i),e.callbackPriority=2,e.callbackNode=null,2}function Uh(e,n){if($t!==0&&$t!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Zi()&&e.callbackNode!==l)return null;var i=qe;return i=dn(e,e===mt?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(bh(e,i,n),Ih(e,Qe()),e.callbackNode!=null&&e.callbackNode===l?Uh.bind(null,e):null)}function Hh(e,n){if(Zi())return null;bh(e,n,!0)}function b1(){L1(function(){(nt&6)!==0?Nt(be,y1):Bh()})}function Uu(){if(Qr===0){var e=il;e===0&&(e=Et,Et<<=1,(Et&261888)===0&&(Et=256)),Qr=e}return Qr}function $h(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:oi(""+e)}function Vh(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 j1(e,n,l,i,f){if(n==="submit"&&l&&l.stateNode===f){var x=$h((f[ot]||null).action),j=i.submitter;j&&(n=(n=j[ot]||null)?$h(n.formAction):j.getAttribute("formAction"),n!==null&&(x=n,j=null));var R=new fi("action","action",null,i,f);e.push({event:R,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Qr!==0){var P=j?Vh(f,j):new FormData(f);lu(l,{pending:!0,data:P,method:f.method,action:x},null,P)}}else typeof x=="function"&&(R.preventDefault(),P=j?Vh(f,j):new FormData(f),lu(l,{pending:!0,data:P,method:f.method,action:x},x,P))},currentTarget:f}]})}}for(var Hu=0;Hu<Sc.length;Hu++){var $u=Sc[Hu],S1=$u.toLowerCase(),k1=$u[0].toUpperCase()+$u.slice(1);Yn(S1,"on"+k1)}Yn(yp,"onAnimationEnd"),Yn(bp,"onAnimationIteration"),Yn(jp,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(Ub,"onTransitionRun"),Yn(Hb,"onTransitionStart"),Yn($b,"onTransitionCancel"),Yn(Sp,"onTransitionEnd"),qa("onMouseEnter",["mouseout","mouseover"]),qa("onMouseLeave",["mouseout","mouseover"]),qa("onPointerEnter",["pointerout","pointerover"]),qa("onPointerLeave",["pointerout","pointerover"]),ga("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ga("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ga("onBeforeInput",["compositionend","keypress","textInput","paste"]),ga("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ys="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(" "),w1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ys));function Ph(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var i=e[l],f=i.event;i=i.listeners;e:{var x=void 0;if(n)for(var j=i.length-1;0<=j;j--){var R=i[j],P=R.instance,Z=R.currentTarget;if(R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(le){hi(le)}f.currentTarget=null,x=P}else for(j=0;j<i.length;j++){if(R=i[j],P=R.instance,Z=R.currentTarget,R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(le){hi(le)}f.currentTarget=null,x=P}}}}function We(e,n){var l=n[nr];l===void 0&&(l=n[nr]=new Set);var i=e+"__bubble";l.has(i)||(Fh(n,e,2,!1),l.add(i))}function Vu(e,n,l){var i=0;n&&(i|=4),Fh(l,e,i,n)}var to="_reactListening"+Math.random().toString(36).slice(2);function Pu(e){if(!e[to]){e[to]=!0,Bf.forEach(function(l){l!=="selectionchange"&&(w1.has(l)||Vu(l,!1,e),Vu(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[to]||(n[to]=!0,Vu("selectionchange",!1,n))}}function Fh(e,n,l,i){switch(yx(n)){case 2:var f=Z1;break;case 8:f=J1;break;default:f=ad}l=f.bind(null,n,l,e),f=void 0,!cc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),i?f!==void 0?e.addEventListener(n,l,{capture:!0,passive:f}):e.addEventListener(n,l,!0):f!==void 0?e.addEventListener(n,l,{passive:f}):e.addEventListener(n,l,!1)}function Fu(e,n,l,i,f){var x=i;if((n&1)===0&&(n&2)===0&&i!==null)e:for(;;){if(i===null)return;var j=i.tag;if(j===3||j===4){var R=i.stateNode.containerInfo;if(R===f)break;if(j===4)for(j=i.return;j!==null;){var P=j.tag;if((P===3||P===4)&&j.stateNode.containerInfo===f)return;j=j.return}for(;R!==null;){if(j=Fa(R),j===null)return;if(P=j.tag,P===5||P===6||P===26||P===27){i=x=j;continue e}R=R.parentNode}}i=i.return}Kf(function(){var Z=x,le=ic(l),ue=[];e:{var ee=kp.get(e);if(ee!==void 0){var re=fi,we=e;switch(e){case"keypress":if(ui(l)===0)break e;case"keydown":case"keyup":re=gb;break;case"focusin":we="focus",re=pc;break;case"focusout":we="blur",re=pc;break;case"beforeblur":case"afterblur":re=pc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=Zf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=lb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=bb;break;case yp:case bp:case jp:re=ob;break;case Sp:re=Sb;break;case"scroll":case"scrollend":re=rb;break;case"wheel":re=wb;break;case"copy":case"cut":case"paste":re=ub;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=ep;break;case"toggle":case"beforetoggle":re=Eb}var Le=(n&4)!==0,dt=!Le&&(e==="scroll"||e==="scrollend"),K=Le?ee!==null?ee+"Capture":null:ee;Le=[];for(var W=Z,Q;W!==null;){var ce=W;if(Q=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||Q===null||K===null||(ce=$l(W,K),ce!=null&&Le.push(bs(W,ce,Q))),dt)break;W=W.return}0<Le.length&&(ee=new re(ee,we,null,l,le),ue.push({event:ee,listeners:Le}))}}if((n&7)===0){e:{if(ee=e==="mouseover"||e==="pointerover",re=e==="mouseout"||e==="pointerout",ee&&l!==sc&&(we=l.relatedTarget||l.fromElement)&&(Fa(we)||we[xa]))break e;if((re||ee)&&(ee=le.window===le?le:(ee=le.ownerDocument)?ee.defaultView||ee.parentWindow:window,re?(we=l.relatedTarget||l.toElement,re=Z,we=we?Fa(we):null,we!==null&&(dt=u(we),Le=we.tag,we!==dt||Le!==5&&Le!==27&&Le!==6)&&(we=null)):(re=null,we=Z),re!==we)){if(Le=Zf,ce="onMouseLeave",K="onMouseEnter",W="mouse",(e==="pointerout"||e==="pointerover")&&(Le=ep,ce="onPointerLeave",K="onPointerEnter",W="pointer"),dt=re==null?ee:Hl(re),Q=we==null?ee:Hl(we),ee=new Le(ce,W+"leave",re,l,le),ee.target=dt,ee.relatedTarget=Q,ce=null,Fa(le)===Z&&(Le=new Le(K,W+"enter",we,l,le),Le.target=Q,Le.relatedTarget=dt,ce=Le),dt=ce,re&&we)t:{for(Le=C1,K=re,W=we,Q=0,ce=K;ce;ce=Le(ce))Q++;ce=0;for(var Me=W;Me;Me=Le(Me))ce++;for(;0<Q-ce;)K=Le(K),Q--;for(;0<ce-Q;)W=Le(W),ce--;for(;Q--;){if(K===W||W!==null&&K===W.alternate){Le=K;break t}K=Le(K),W=Le(W)}Le=null}else Le=null;re!==null&&Gh(ue,ee,re,Le,!1),we!==null&&dt!==null&&Gh(ue,dt,we,Le,!0)}}e:{if(ee=Z?Hl(Z):window,re=ee.nodeName&&ee.nodeName.toLowerCase(),re==="select"||re==="input"&&ee.type==="file")var Ze=op;else if(sp(ee))if(cp)Ze=Ob;else{Ze=Db;var Ne=zb}else re=ee.nodeName,!re||re.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?Z&&lc(Z.elementType)&&(Ze=op):Ze=_b;if(Ze&&(Ze=Ze(e,Z))){ip(ue,Ze,l,le);break e}Ne&&Ne(e,ee,Z),e==="focusout"&&Z&&ee.type==="number"&&Z.memoizedProps.value!=null&&ac(ee,"number",ee.value)}switch(Ne=Z?Hl(Z):window,e){case"focusin":(sp(Ne)||Ne.contentEditable==="true")&&(Ja=Ne,yc=Z,Kl=null);break;case"focusout":Kl=yc=Ja=null;break;case"mousedown":bc=!0;break;case"contextmenu":case"mouseup":case"dragend":bc=!1,gp(ue,l,le);break;case"selectionchange":if(Ib)break;case"keydown":case"keyup":gp(ue,l,le)}var Ve;if(hc)e:{switch(e){case"compositionstart":var Ye="onCompositionStart";break e;case"compositionend":Ye="onCompositionEnd";break e;case"compositionupdate":Ye="onCompositionUpdate";break e}Ye=void 0}else Za?ap(e,l)&&(Ye="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Ye="onCompositionStart");Ye&&(tp&&l.locale!=="ko"&&(Za||Ye!=="onCompositionStart"?Ye==="onCompositionEnd"&&Za&&(Ve=Xf()):(_r=le,uc="value"in _r?_r.value:_r.textContent,Za=!0)),Ne=no(Z,Ye),0<Ne.length&&(Ye=new Jf(Ye,e,null,l,le),ue.push({event:Ye,listeners:Ne}),Ve?Ye.data=Ve:(Ve=lp(l),Ve!==null&&(Ye.data=Ve)))),(Ve=Tb?Rb(e,l):Ab(e,l))&&(Ye=no(Z,"onBeforeInput"),0<Ye.length&&(Ne=new Jf("onBeforeInput","beforeinput",null,l,le),ue.push({event:Ne,listeners:Ye}),Ne.data=Ve)),j1(ue,e,Z,l,le)}Ph(ue,n)})}function bs(e,n,l){return{instance:e,listener:n,currentTarget:l}}function no(e,n){for(var l=n+"Capture",i=[];e!==null;){var f=e,x=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||x===null||(f=$l(e,l),f!=null&&i.unshift(bs(e,f,x)),f=$l(e,n),f!=null&&i.push(bs(e,f,x))),e.tag===3)return i;e=e.return}return[]}function C1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Gh(e,n,l,i,f){for(var x=n._reactName,j=[];l!==null&&l!==i;){var R=l,P=R.alternate,Z=R.stateNode;if(R=R.tag,P!==null&&P===i)break;R!==5&&R!==26&&R!==27||Z===null||(P=Z,f?(Z=$l(l,x),Z!=null&&j.unshift(bs(l,Z,P))):f||(Z=$l(l,x),Z!=null&&j.push(bs(l,Z,P)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var E1=/\r\n?/g,N1=/\u0000|\uFFFD/g;function Wh(e){return(typeof e=="string"?e:""+e).replace(E1,`
50
- `).replace(N1,"")}function qh(e,n){return n=Wh(n),Wh(e)===n}function ut(e,n,l,i,f,x){switch(l){case"children":typeof i=="string"?n==="body"||n==="textarea"&&i===""||Ka(e,i):(typeof i=="number"||typeof i=="bigint")&&n!=="body"&&Ka(e,""+i);break;case"className":si(e,"class",i);break;case"tabIndex":si(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":si(e,l,i);break;case"style":qf(e,i,x);break;case"data":if(n!=="object"){si(e,"data",i);break}case"src":case"href":if(i===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=oi(""+i),e.setAttribute(l,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof x=="function"&&(l==="formAction"?(n!=="input"&&ut(e,n,"name",f.name,f,null),ut(e,n,"formEncType",f.formEncType,f,null),ut(e,n,"formMethod",f.formMethod,f,null),ut(e,n,"formTarget",f.formTarget,f,null)):(ut(e,n,"encType",f.encType,f,null),ut(e,n,"method",f.method,f,null),ut(e,n,"target",f.target,f,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=oi(""+i),e.setAttribute(l,i);break;case"onClick":i!=null&&(e.onclick=pr);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}l=oi(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""+i):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":i===!0?e.setAttribute(l,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,i):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(l,i):e.removeAttribute(l);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(l):e.setAttribute(l,i);break;case"popover":We("beforetoggle",e),We("toggle",e),li(e,"popover",i);break;case"xlinkActuate":fr(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":fr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":fr(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":fr(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":fr(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":fr(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":fr(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":fr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":fr(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":li(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=tb.get(l)||l,li(e,l,i))}}function Gu(e,n,l,i,f,x){switch(l){case"style":qf(e,i,x);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"children":typeof i=="string"?Ka(e,i):(typeof i=="number"||typeof i=="bigint")&&Ka(e,""+i);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"onClick":i!=null&&(e.onclick=pr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!If.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),x=e[ot]||null,x=x!=null?x[l]:null,typeof x=="function"&&e.removeEventListener(n,x,f),typeof i=="function")){typeof x!="function"&&x!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,i,f);break e}l in e?e[l]=i:i===!0?e.setAttribute(l,""):li(e,l,i)}}}function Zt(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":We("error",e),We("load",e);var i=!1,f=!1,x;for(x in l)if(l.hasOwnProperty(x)){var j=l[x];if(j!=null)switch(x){case"src":i=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ut(e,n,x,j,l,null)}}f&&ut(e,n,"srcSet",l.srcSet,l,null),i&&ut(e,n,"src",l.src,l,null);return;case"input":We("invalid",e);var R=x=j=f=null,P=null,Z=null;for(i in l)if(l.hasOwnProperty(i)){var le=l[i];if(le!=null)switch(i){case"name":f=le;break;case"type":j=le;break;case"checked":P=le;break;case"defaultChecked":Z=le;break;case"value":x=le;break;case"defaultValue":R=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(o(137,n));break;default:ut(e,n,i,le,l,null)}}Pf(e,x,R,P,Z,j,f,!1);return;case"select":We("invalid",e),i=j=x=null;for(f in l)if(l.hasOwnProperty(f)&&(R=l[f],R!=null))switch(f){case"value":x=R;break;case"defaultValue":j=R;break;case"multiple":i=R;default:ut(e,n,f,R,l,null)}n=x,l=j,e.multiple=!!i,n!=null?Ya(e,!!i,n,!1):l!=null&&Ya(e,!!i,l,!0);return;case"textarea":We("invalid",e),x=f=i=null;for(j in l)if(l.hasOwnProperty(j)&&(R=l[j],R!=null))switch(j){case"value":i=R;break;case"defaultValue":f=R;break;case"children":x=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(o(91));break;default:ut(e,n,j,R,l,null)}Gf(e,i,f,x);return;case"option":for(P in l)if(l.hasOwnProperty(P)&&(i=l[P],i!=null))switch(P){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:ut(e,n,P,i,l,null)}return;case"dialog":We("beforetoggle",e),We("toggle",e),We("cancel",e),We("close",e);break;case"iframe":case"object":We("load",e);break;case"video":case"audio":for(i=0;i<ys.length;i++)We(ys[i],e);break;case"image":We("error",e),We("load",e);break;case"details":We("toggle",e);break;case"embed":case"source":case"link":We("error",e),We("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in l)if(l.hasOwnProperty(Z)&&(i=l[Z],i!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ut(e,n,Z,i,l,null)}return;default:if(lc(n)){for(le in l)l.hasOwnProperty(le)&&(i=l[le],i!==void 0&&Gu(e,n,le,i,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(i=l[R],i!=null&&ut(e,n,R,i,l,null))}function T1(e,n,l,i){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,x=null,j=null,R=null,P=null,Z=null,le=null;for(re in l){var ue=l[re];if(l.hasOwnProperty(re)&&ue!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":P=ue;default:i.hasOwnProperty(re)||ut(e,n,re,null,i,ue)}}for(var ee in i){var re=i[ee];if(ue=l[ee],i.hasOwnProperty(ee)&&(re!=null||ue!=null))switch(ee){case"type":x=re;break;case"name":f=re;break;case"checked":Z=re;break;case"defaultChecked":le=re;break;case"value":j=re;break;case"defaultValue":R=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(o(137,n));break;default:re!==ue&&ut(e,n,ee,re,i,ue)}}rc(e,j,R,P,Z,le,x,f);return;case"select":re=j=R=ee=null;for(x in l)if(P=l[x],l.hasOwnProperty(x)&&P!=null)switch(x){case"value":break;case"multiple":re=P;default:i.hasOwnProperty(x)||ut(e,n,x,null,i,P)}for(f in i)if(x=i[f],P=l[f],i.hasOwnProperty(f)&&(x!=null||P!=null))switch(f){case"value":ee=x;break;case"defaultValue":R=x;break;case"multiple":j=x;default:x!==P&&ut(e,n,f,x,i,P)}n=R,l=j,i=re,ee!=null?Ya(e,!!l,ee,!1):!!i!=!!l&&(n!=null?Ya(e,!!l,n,!0):Ya(e,!!l,l?[]:"",!1));return;case"textarea":re=ee=null;for(R in l)if(f=l[R],l.hasOwnProperty(R)&&f!=null&&!i.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:ut(e,n,R,null,i,f)}for(j in i)if(f=i[j],x=l[j],i.hasOwnProperty(j)&&(f!=null||x!=null))switch(j){case"value":ee=f;break;case"defaultValue":re=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(o(91));break;default:f!==x&&ut(e,n,j,f,i,x)}Ff(e,ee,re);return;case"option":for(var we in l)if(ee=l[we],l.hasOwnProperty(we)&&ee!=null&&!i.hasOwnProperty(we))switch(we){case"selected":e.selected=!1;break;default:ut(e,n,we,null,i,ee)}for(P in i)if(ee=i[P],re=l[P],i.hasOwnProperty(P)&&ee!==re&&(ee!=null||re!=null))switch(P){case"selected":e.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:ut(e,n,P,ee,i,re)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Le in l)ee=l[Le],l.hasOwnProperty(Le)&&ee!=null&&!i.hasOwnProperty(Le)&&ut(e,n,Le,null,i,ee);for(Z in i)if(ee=i[Z],re=l[Z],i.hasOwnProperty(Z)&&ee!==re&&(ee!=null||re!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(o(137,n));break;default:ut(e,n,Z,ee,i,re)}return;default:if(lc(n)){for(var dt in l)ee=l[dt],l.hasOwnProperty(dt)&&ee!==void 0&&!i.hasOwnProperty(dt)&&Gu(e,n,dt,void 0,i,ee);for(le in i)ee=i[le],re=l[le],!i.hasOwnProperty(le)||ee===re||ee===void 0&&re===void 0||Gu(e,n,le,ee,i,re);return}}for(var K in l)ee=l[K],l.hasOwnProperty(K)&&ee!=null&&!i.hasOwnProperty(K)&&ut(e,n,K,null,i,ee);for(ue in i)ee=i[ue],re=l[ue],!i.hasOwnProperty(ue)||ee===re||ee==null&&re==null||ut(e,n,ue,ee,i,re)}function Yh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function R1(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),i=0;i<l.length;i++){var f=l[i],x=f.transferSize,j=f.initiatorType,R=f.duration;if(x&&R&&Yh(j)){for(j=0,R=f.responseEnd,i+=1;i<l.length;i++){var P=l[i],Z=P.startTime;if(Z>R)break;var le=P.transferSize,ue=P.initiatorType;le&&Yh(ue)&&(P=P.responseEnd,j+=le*(P<R?1:(R-Z)/(P-Z)))}if(--i,n+=8*(x+j)/(f.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Wu=null,qu=null;function ro(e){return e.nodeType===9?e:e.ownerDocument}function Kh(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 Xh(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 Yu(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 Ku=null;function A1(){var e=window.event;return e&&e.type==="popstate"?e===Ku?!1:(Ku=e,!0):(Ku=null,!1)}var Qh=typeof setTimeout=="function"?setTimeout:void 0,M1=typeof clearTimeout=="function"?clearTimeout:void 0,Zh=typeof Promise=="function"?Promise:void 0,L1=typeof queueMicrotask=="function"?queueMicrotask:typeof Zh<"u"?function(e){return Zh.resolve(null).then(e).catch(z1)}:Qh;function z1(e){setTimeout(function(){throw e})}function Zr(e){return e==="head"}function Jh(e,n){var l=n,i=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(i===0){e.removeChild(f),El(n);return}i--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")i++;else if(l==="html")js(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,js(l);for(var x=l.firstChild;x;){var j=x.nextSibling,R=x.nodeName;x[Ul]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&x.rel.toLowerCase()==="stylesheet"||l.removeChild(x),x=j}}else l==="body"&&js(e.ownerDocument.body);l=f}while(l);El(n)}function ex(e,n){var l=e;e=0;do{var i=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),i&&i.nodeType===8)if(l=i.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=i}while(l)}function Xu(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":Xu(l),tc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function D1(e,n,l,i){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[Ul])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(x=e.getAttribute("rel"),x==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(x!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(x=e.getAttribute("src"),(x!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&x&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var x=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===x)return e}else return e;if(e=Hn(e.nextSibling),e===null)break}return null}function _1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Hn(e.nextSibling),e===null))return null;return e}function tx(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Hn(e.nextSibling),e===null))return null;return e}function Qu(e){return e.data==="$?"||e.data==="$~"}function Zu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function O1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var i=function(){n(),l.removeEventListener("DOMContentLoaded",i)};l.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function Hn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var Ju=null;function nx(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Hn(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function rx(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 ax(e,n,l){switch(n=ro(l),e){case"html":if(e=n.documentElement,!e)throw Error(o(452));return e;case"head":if(e=n.head,!e)throw Error(o(453));return e;case"body":if(e=n.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function js(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);tc(e)}var $n=new Map,lx=new Set;function ao(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Rr=_.d;_.d={f:B1,r:I1,D:U1,C:H1,L:$1,m:V1,X:F1,S:P1,M:G1};function B1(){var e=Rr.f(),n=Ki();return e||n}function I1(e){var n=Ga(e);n!==null&&n.tag===5&&n.type==="form"?Sm(n):Rr.r(e)}var kl=typeof document>"u"?null:document;function sx(e,n,l){var i=kl;if(i&&typeof n=="string"&&n){var f=zn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),lx.has(f)||(lx.add(f),e={rel:e,crossOrigin:l,href:n},i.querySelector(f)===null&&(n=i.createElement("link"),Zt(n,"link",e),Wt(n),i.head.appendChild(n)))}}function U1(e){Rr.D(e),sx("dns-prefetch",e,null)}function H1(e,n){Rr.C(e,n),sx("preconnect",e,n)}function $1(e,n,l){Rr.L(e,n,l);var i=kl;if(i&&e&&n){var f='link[rel="preload"][as="'+zn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+zn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+zn(l.imageSizes)+'"]')):f+='[href="'+zn(e)+'"]';var x=f;switch(n){case"style":x=wl(e);break;case"script":x=Cl(e)}$n.has(x)||(e=v({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),$n.set(x,e),i.querySelector(f)!==null||n==="style"&&i.querySelector(Ss(x))||n==="script"&&i.querySelector(ks(x))||(n=i.createElement("link"),Zt(n,"link",e),Wt(n),i.head.appendChild(n)))}}function V1(e,n){Rr.m(e,n);var l=kl;if(l&&e){var i=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+zn(i)+'"][href="'+zn(e)+'"]',x=f;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Cl(e)}if(!$n.has(x)&&(e=v({rel:"modulepreload",href:e},n),$n.set(x,e),l.querySelector(f)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ks(x)))return}i=l.createElement("link"),Zt(i,"link",e),Wt(i),l.head.appendChild(i)}}}function P1(e,n,l){Rr.S(e,n,l);var i=kl;if(i&&e){var f=Wa(i).hoistableStyles,x=wl(e);n=n||"default";var j=f.get(x);if(!j){var R={loading:0,preload:null};if(j=i.querySelector(Ss(x)))R.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":n},l),(l=$n.get(x))&&ed(e,l);var P=j=i.createElement("link");Wt(P),Zt(P,"link",e),P._p=new Promise(function(Z,le){P.onload=Z,P.onerror=le}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,lo(j,n,i)}j={type:"stylesheet",instance:j,count:1,state:R},f.set(x,j)}}}function F1(e,n){Rr.X(e,n);var l=kl;if(l&&e){var i=Wa(l).hoistableScripts,f=Cl(e),x=i.get(f);x||(x=l.querySelector(ks(f)),x||(e=v({src:e,async:!0},n),(n=$n.get(f))&&td(e,n),x=l.createElement("script"),Wt(x),Zt(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function G1(e,n){Rr.M(e,n);var l=kl;if(l&&e){var i=Wa(l).hoistableScripts,f=Cl(e),x=i.get(f);x||(x=l.querySelector(ks(f)),x||(e=v({src:e,async:!0,type:"module"},n),(n=$n.get(f))&&td(e,n),x=l.createElement("script"),Wt(x),Zt(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function ix(e,n,l,i){var f=(f=ie.current)?ao(f):null;if(!f)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=wl(l.href),l=Wa(f).hoistableStyles,i=l.get(n),i||(i={type:"style",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=wl(l.href);var x=Wa(f).hoistableStyles,j=x.get(e);if(j||(f=f.ownerDocument||f,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(e,j),(x=f.querySelector(Ss(e)))&&!x._p&&(j.instance=x,j.state.loading=5),$n.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},$n.set(e,l),x||W1(f,e,l,j.state))),n&&i===null)throw Error(o(528,""));return j}if(n&&i!==null)throw Error(o(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Cl(l),l=Wa(f).hoistableScripts,i=l.get(n),i||(i={type:"script",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function wl(e){return'href="'+zn(e)+'"'}function Ss(e){return'link[rel="stylesheet"]['+e+"]"}function ox(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function W1(e,n,l,i){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?i.loading=1:(n=e.createElement("link"),i.preload=n,n.addEventListener("load",function(){return i.loading|=1}),n.addEventListener("error",function(){return i.loading|=2}),Zt(n,"link",l),Wt(n),e.head.appendChild(n))}function Cl(e){return'[src="'+zn(e)+'"]'}function ks(e){return"script[async]"+e}function cx(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var i=e.querySelector('style[data-href~="'+zn(l.href)+'"]');if(i)return n.instance=i,Wt(i),i;var f=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Wt(i),Zt(i,"style",f),lo(i,l.precedence,e),n.instance=i;case"stylesheet":f=wl(l.href);var x=e.querySelector(Ss(f));if(x)return n.state.loading|=4,n.instance=x,Wt(x),x;i=ox(l),(f=$n.get(f))&&ed(i,f),x=(e.ownerDocument||e).createElement("link"),Wt(x);var j=x;return j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),Zt(x,"link",i),n.state.loading|=4,lo(x,l.precedence,e),n.instance=x;case"script":return x=Cl(l.src),(f=e.querySelector(ks(x)))?(n.instance=f,Wt(f),f):(i=l,(f=$n.get(x))&&(i=v({},l),td(i,f)),e=e.ownerDocument||e,f=e.createElement("script"),Wt(f),Zt(f,"link",i),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(o(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(i=n.instance,n.state.loading|=4,lo(i,l.precedence,e));return n.instance}function lo(e,n,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=i.length?i[i.length-1]:null,x=f,j=0;j<i.length;j++){var R=i[j];if(R.dataset.precedence===n)x=R;else if(x!==f)break}x?x.parentNode.insertBefore(e,x.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function ed(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function td(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var so=null;function ux(e,n,l){if(so===null){var i=new Map,f=so=new Map;f.set(l,i)}else f=so,i=f.get(l),i||(i=new Map,f.set(l,i));if(i.has(e))return i;for(i.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var x=l[f];if(!(x[Ul]||x[Ht]||e==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var j=x.getAttribute(n)||"";j=e+j;var R=i.get(j);R?R.push(x):i.set(j,[x])}}return i}function dx(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function q1(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 fx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Y1(e,n,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=wl(i.href),x=n.querySelector(Ss(f));if(x){n=x._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=io.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=x,Wt(x);return}x=n.ownerDocument||n,i=ox(i),(f=$n.get(f))&&ed(i,f),x=x.createElement("link"),Wt(x);var j=x;j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),Zt(x,"link",i),l.instance=x}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=io.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var nd=0;function K1(e,n){return e.stylesheets&&e.count===0&&co(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var i=setTimeout(function(){if(e.stylesheets&&co(e,e.stylesheets),e.unsuspend){var x=e.unsuspend;e.unsuspend=null,x()}},6e4+n);0<e.imgBytes&&nd===0&&(nd=62500*R1());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&co(e,e.stylesheets),e.unsuspend)){var x=e.unsuspend;e.unsuspend=null,x()}},(e.imgBytes>nd?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(f)}}:null}function io(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)co(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var oo=null;function co(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oo=new Map,n.forEach(X1,e),oo=null,io.call(e))}function X1(e,n){if(!(n.state.loading&4)){var l=oo.get(e);if(l)var i=l.get(null);else{l=new Map,oo.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<f.length;x++){var j=f[x];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(l.set(j.dataset.precedence,j),i=j)}i&&l.set(null,i)}f=n.instance,j=f.getAttribute("data-precedence"),x=l.get(j)||i,x===i&&l.set(null,f),l.set(j,f),this.count++,i=io.bind(this),f.addEventListener("load",i),f.addEventListener("error",i),x?x.parentNode.insertBefore(f,x.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var ws={$$typeof:A,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function Q1(e,n,l,i,f,x,j,R,P){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Bl(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bl(0),this.hiddenUpdates=Bl(null),this.identifierPrefix=i,this.onUncaughtError=f,this.onCaughtError=x,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function px(e,n,l,i,f,x,j,R,P,Z,le,ue){return e=new Q1(e,n,l,j,P,Z,le,ue,R),n=1,x===!0&&(n|=24),x=bn(3,null,null,n),e.current=x,x.stateNode=e,n=_c(),n.refCount++,e.pooledCache=n,n.refCount++,x.memoizedState={element:i,isDehydrated:l,cache:n},Uc(x),e}function mx(e){return e?(e=nl,e):nl}function hx(e,n,l,i,f,x){f=mx(f),i.context===null?i.context=f:i.pendingContext=f,i=$r(n),i.payload={element:l},x=x===void 0?null:x,x!==null&&(i.callback=x),l=Vr(e,i,n),l!==null&&(vn(l,e,n),ns(l,e,n))}function xx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function rd(e,n){xx(e,n),(e=e.alternate)&&xx(e,n)}function gx(e){if(e.tag===13||e.tag===31){var n=ja(e,67108864);n!==null&&vn(n,e,67108864),rd(e,67108864)}}function vx(e){if(e.tag===13||e.tag===31){var n=Cn();n=Pa(n);var l=ja(e,n);l!==null&&vn(l,e,n),rd(e,n)}}var uo=!0;function Z1(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=2,ad(e,n,l,i)}finally{_.p=x,L.T=f}}function J1(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=8,ad(e,n,l,i)}finally{_.p=x,L.T=f}}function ad(e,n,l,i){if(uo){var f=ld(i);if(f===null)Fu(e,n,i,fo,l),bx(e,i);else if(t0(f,e,n,l,i))i.stopPropagation();else if(bx(e,i),n&4&&-1<e0.indexOf(e)){for(;f!==null;){var x=Ga(f);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var j=Ee(x.pendingLanes);if(j!==0){var R=x;for(R.pendingLanes|=2,R.entangledLanes|=2;j;){var P=1<<31-gt(j);R.entanglements[1]|=P,j&=~P}sr(x),(nt&6)===0&&(qi=Qe()+500,vs(0))}}break;case 31:case 13:R=ja(x,2),R!==null&&vn(R,x,2),Ki(),rd(x,2)}if(x=ld(i),x===null&&Fu(e,n,i,fo,l),x===f)break;f=x}f!==null&&i.stopPropagation()}else Fu(e,n,i,null,l)}}function ld(e){return e=ic(e),sd(e)}var fo=null;function sd(e){if(fo=null,e=Fa(e),e!==null){var n=u(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=d(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return fo=e,null}function yx(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(tt()){case be:return 2;case pt:return 8;case Ct:case Yt:return 32;case un:return 268435456;default:return 32}default:return 32}}var id=!1,Jr=null,ea=null,ta=null,Cs=new Map,Es=new Map,na=[],e0="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 bx(e,n){switch(e){case"focusin":case"focusout":Jr=null;break;case"dragenter":case"dragleave":ea=null;break;case"mouseover":case"mouseout":ta=null;break;case"pointerover":case"pointerout":Cs.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Es.delete(n.pointerId)}}function Ns(e,n,l,i,f,x){return e===null||e.nativeEvent!==x?(e={blockedOn:n,domEventName:l,eventSystemFlags:i,nativeEvent:x,targetContainers:[f]},n!==null&&(n=Ga(n),n!==null&&gx(n)),e):(e.eventSystemFlags|=i,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function t0(e,n,l,i,f){switch(n){case"focusin":return Jr=Ns(Jr,e,n,l,i,f),!0;case"dragenter":return ea=Ns(ea,e,n,l,i,f),!0;case"mouseover":return ta=Ns(ta,e,n,l,i,f),!0;case"pointerover":var x=f.pointerId;return Cs.set(x,Ns(Cs.get(x)||null,e,n,l,i,f)),!0;case"gotpointercapture":return x=f.pointerId,Es.set(x,Ns(Es.get(x)||null,e,n,l,i,f)),!0}return!1}function jx(e){var n=Fa(e.target);if(n!==null){var l=u(n);if(l!==null){if(n=l.tag,n===13){if(n=d(l),n!==null){e.blockedOn=n,ha(e.priority,function(){vx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,ha(e.priority,function(){vx(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function po(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=ld(e.nativeEvent);if(l===null){l=e.nativeEvent;var i=new l.constructor(l.type,l);sc=i,l.target.dispatchEvent(i),sc=null}else return n=Ga(l),n!==null&&gx(n),e.blockedOn=l,!1;n.shift()}return!0}function Sx(e,n,l){po(e)&&l.delete(n)}function n0(){id=!1,Jr!==null&&po(Jr)&&(Jr=null),ea!==null&&po(ea)&&(ea=null),ta!==null&&po(ta)&&(ta=null),Cs.forEach(Sx),Es.forEach(Sx)}function mo(e,n){e.blockedOn===n&&(e.blockedOn=null,id||(id=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,n0)))}var ho=null;function kx(e){ho!==e&&(ho=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ho===e&&(ho=null);for(var n=0;n<e.length;n+=3){var l=e[n],i=e[n+1],f=e[n+2];if(typeof i!="function"){if(sd(i||l)===null)continue;break}var x=Ga(l);x!==null&&(e.splice(n,3),n-=3,lu(x,{pending:!0,data:f,method:l.method,action:i},i,f))}}))}function El(e){function n(P){return mo(P,e)}Jr!==null&&mo(Jr,e),ea!==null&&mo(ea,e),ta!==null&&mo(ta,e),Cs.forEach(n),Es.forEach(n);for(var l=0;l<na.length;l++){var i=na[l];i.blockedOn===e&&(i.blockedOn=null)}for(;0<na.length&&(l=na[0],l.blockedOn===null);)jx(l),l.blockedOn===null&&na.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(i=0;i<l.length;i+=3){var f=l[i],x=l[i+1],j=f[ot]||null;if(typeof x=="function")j||kx(l);else if(j){var R=null;if(x&&x.hasAttribute("formAction")){if(f=x,j=x[ot]||null)R=j.formAction;else if(sd(f)!==null)continue}else R=j.action;typeof R=="function"?l[i+1]=R:(l.splice(i,3),i-=3),kx(l)}}}function wx(){function e(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(j){return f=j})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),i||setTimeout(l,20)}function l(){if(!i&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function od(e){this._internalRoot=e}xo.prototype.render=od.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(o(409));var l=n.current,i=Cn();hx(l,i,e,n,null,null)},xo.prototype.unmount=od.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;hx(e.current,2,null,e,null,null),Ki(),n[xa]=null}};function xo(e){this._internalRoot=e}xo.prototype.unstable_scheduleHydration=function(e){if(e){var n=it();e={blockedOn:null,target:e,priority:n};for(var l=0;l<na.length&&n!==0&&n<na[l].priority;l++);na.splice(l,0,e),l===0&&jx(e)}};var Cx=a.version;if(Cx!=="19.2.4")throw Error(o(527,Cx,"19.2.4"));_.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=p(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var r0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var go=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!go.isDisabled&&go.supportsFiber)try{Mn=go.inject(r0),Mt=go}catch{}}return Rs.createRoot=function(e,n){if(!c(e))throw Error(o(299));var l=!1,i="",f=Lm,x=zm,j=Dm;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(x=n.onCaughtError),n.onRecoverableError!==void 0&&(j=n.onRecoverableError)),n=px(e,1,!1,null,null,l,i,null,f,x,j,wx),e[xa]=n.current,Pu(e),new od(n)},Rs.hydrateRoot=function(e,n,l){if(!c(e))throw Error(o(299));var i=!1,f="",x=Lm,j=zm,R=Dm,P=null;return l!=null&&(l.unstable_strictMode===!0&&(i=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(x=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError),l.formState!==void 0&&(P=l.formState)),n=px(e,1,!0,n,l??null,i,f,P,x,j,R,wx),n.context=mx(null),l=n.current,i=Cn(),i=Pa(i),f=$r(i),f.callback=null,Vr(l,f,i),l=i,n.current.lanes=l,fa(n,l),sr(n),e[xa]=n.current,Pu(e),new xo(n)},Rs.version="19.2.4",Rs}var _x;function f0(){if(_x)return dd.exports;_x=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(),dd.exports=d0(),dd.exports}var p0=f0();/**
49
+ `+i.stack}}var lt=Object.prototype.hasOwnProperty,Nt=t.unstable_scheduleCallback,xt=t.unstable_cancelCallback,_t=t.unstable_shouldYield,Tt=t.unstable_requestPaint,Ze=t.unstable_now,nt=t.unstable_getCurrentPriorityLevel,ye=t.unstable_ImmediatePriority,mt=t.unstable_UserBlockingPriority,Et=t.unstable_NormalPriority,Xt=t.unstable_LowPriority,fn=t.unstable_IdlePriority,Wt=t.log,ln=t.unstable_setDisableYieldValue,Mn=null,Lt=null;function vt(e){if(typeof Wt=="function"&&ln(e),Lt&&typeof Lt.setStrictMode=="function")try{Lt.setStrictMode(Mn,e)}catch{}}var gt=Math.clz32?Math.clz32:dr,Wn=Math.log,zr=Math.LN2;function dr(e){return e>>>=0,e===0?32:31-(Wn(e)/zr|0)|0}var Rt=256,qt=262144,Ie=4194304;function le(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Se(e,n,l){var i=e.pendingLanes;if(i===0)return 0;var f=0,x=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var R=i&134217727;return R!==0?(i=R&~x,i!==0?f=le(i):(j&=R,j!==0?f=le(j):l||(l=R&~e,l!==0&&(f=le(l))))):(R=i&~x,R!==0?f=le(R):j!==0?f=le(j):l||(l=i&~e,l!==0&&(f=le(l)))),f===0?0:n!==0&&n!==f&&(n&x)===0&&(x=f&-f,l=n&-n,x>=l||x===32&&(l&4194048)!==0)?n:f}function Me(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function Fa(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function qn(){var e=Ie;return Ie<<=1,(Ie&62914560)===0&&(Ie=4194304),e}function Ul(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function fa(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Hl(e,n,l,i,f,x){var j=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var R=e.entanglements,P=e.expirationTimes,Z=e.hiddenUpdates;for(l=j&~l;0<l;){var se=31-gt(l),ue=1<<se;R[se]=0,P[se]=-1;var ee=Z[se];if(ee!==null)for(Z[se]=null,se=0;se<ee.length;se++){var re=ee[se];re!==null&&(re.lane&=-536870913)}l&=~ue}i!==0&&tr(e,i,0),x!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=x&~(j&~n))}function tr(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var i=31-gt(n);e.entangledLanes|=n,e.entanglements[i]=e.entanglements[i]|1073741824|l&261930}function pa(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var i=31-gt(l),f=1<<i;f&n|e[i]&n&&(e[i]|=n),l&=~f}}function ma(e,n){var l=n&-n;return l=(l&42)!==0?1:Ga(l),(l&(e.suspendedLanes|n))!==0?0:l}function Ga(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Dr(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ot(){var e=_.p;return e!==0?e:(e=window.event,e===void 0?32:yx(e.type))}function ha(e,n){var l=_.p;try{return _.p=e,n()}finally{_.p=l}}var sn=Math.random().toString(36).slice(2),$t="__reactFiber$"+sn,ct="__reactProps$"+sn,xa="__reactContainer$"+sn,nr="__reactEvents$"+sn,ec="__reactListeners$"+sn,Ky="__reactHandles$"+sn,Of="__reactResources$"+sn,$l="__reactMarker$"+sn;function tc(e){delete e[$t],delete e[ct],delete e[nr],delete e[ec],delete e[Ky]}function Wa(e){var n=e[$t];if(n)return n;for(var l=e.parentNode;l;){if(n=l[xa]||l[$t]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=rx(e);e!==null;){if(l=e[$t])return l;e=rx(e)}return n}e=l,l=e.parentNode}return null}function qa(e){if(e=e[$t]||e[xa]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Vl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(o(33))}function Ya(e){var n=e[Of];return n||(n=e[Of]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Yt(e){e[$l]=!0}var Bf=new Set,If={};function ga(e,n){Ka(e,n),Ka(e+"Capture",n)}function Ka(e,n){for(If[e]=n,e=0;e<n.length;e++)Bf.add(n[e])}var Xy=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]*$"),Uf={},Hf={};function Qy(e){return lt.call(Hf,e)?!0:lt.call(Uf,e)?!1:Xy.test(e)?Hf[e]=!0:(Uf[e]=!0,!1)}function li(e,n,l){if(Qy(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var i=n.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function si(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function fr(e,n,l,i){if(i===null)e.removeAttribute(l);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+i)}}function Ln(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function $f(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Zy(e,n,l){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,x=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(j){l=""+j,x.call(this,j)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(j){l=""+j},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function nc(e){if(!e._valueTracker){var n=$f(e)?"checked":"value";e._valueTracker=Zy(e,n,""+e[n])}}function Vf(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),i="";return e&&(i=$f(e)?e.checked?"true":"false":e.value),e=i,e!==l?(n.setValue(e),!0):!1}function ii(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Jy=/[\n"\\]/g;function zn(e){return e.replace(Jy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function rc(e,n,l,i,f,x,j,R){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),n!=null?j==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Ln(n)):e.value!==""+Ln(n)&&(e.value=""+Ln(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?ac(e,j,Ln(n)):l!=null?ac(e,j,Ln(l)):i!=null&&e.removeAttribute("value"),f==null&&x!=null&&(e.defaultChecked=!!x),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Ln(R):e.removeAttribute("name")}function Pf(e,n,l,i,f,x,j,R){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(e.type=x),n!=null||l!=null){if(!(x!=="submit"&&x!=="reset"||n!=null)){nc(e);return}l=l!=null?""+Ln(l):"",n=n!=null?""+Ln(n):l,R||n===e.value||(e.value=n),e.defaultValue=n}i=i??f,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=R?e.checked:!!i,e.defaultChecked=!!i,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),nc(e)}function ac(e,n,l){n==="number"&&ii(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Xa(e,n,l,i){if(e=e.options,n){n={};for(var f=0;f<l.length;f++)n["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=n.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&i&&(e[l].defaultSelected=!0)}else{for(l=""+Ln(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,i&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Ff(e,n,l){if(n!=null&&(n=""+Ln(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Ln(l):""}function Gf(e,n,l,i){if(n==null){if(i!=null){if(l!=null)throw Error(o(92));if($(i)){if(1<i.length)throw Error(o(93));i=i[0]}l=i}l==null&&(l=""),n=l}l=Ln(n),e.defaultValue=l,i=e.textContent,i===l&&i!==""&&i!==null&&(e.value=i),nc(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 eb=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 Wf(e,n,l){var i=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?i?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":i?e.setProperty(n,l):typeof l!="number"||l===0||eb.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function qf(e,n,l){if(n!=null&&typeof n!="object")throw Error(o(62));if(e=e.style,l!=null){for(var i in l)!l.hasOwnProperty(i)||n!=null&&n.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var f in n)i=n[f],n.hasOwnProperty(f)&&l[f]!==i&&Wf(e,f,i)}else for(var x in n)n.hasOwnProperty(x)&&Wf(e,x,n[x])}function lc(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"]]),nb=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function oi(e){return nb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function pr(){}var sc=null;function ic(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 Yf(e){var n=qa(e);if(n&&(e=n.stateNode)){var l=e[ct]||null;e:switch(e=n.stateNode,n.type){case"input":if(rc(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+zn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var i=l[n];if(i!==e&&i.form===e.form){var f=i[ct]||null;if(!f)throw Error(o(90));rc(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)i=l[n],i.form===e.form&&Vf(i)}break e;case"textarea":Ff(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Xa(e,!!l.multiple,n,!1)}}}var oc=!1;function Kf(e,n,l){if(oc)return e(n,l);oc=!0;try{var i=e(n);return i}finally{if(oc=!1,(Za!==null||Ja!==null)&&(Ki(),Za&&(n=Za,e=Ja,Ja=Za=null,Yf(n),e)))for(n=0;n<e.length;n++)Yf(e[n])}}function Pl(e,n){var l=e.stateNode;if(l===null)return null;var i=l[ct]||null;if(i===null)return null;l=i[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(o(231,n,typeof l));return l}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cc=!1;if(mr)try{var Fl={};Object.defineProperty(Fl,"passive",{get:function(){cc=!0}}),window.addEventListener("test",Fl,Fl),window.removeEventListener("test",Fl,Fl)}catch{cc=!1}var _r=null,uc=null,ci=null;function Xf(){if(ci)return ci;var e,n=uc,l=n.length,i,f="value"in _r?_r.value:_r.textContent,x=f.length;for(e=0;e<l&&n[e]===f[e];e++);var j=l-e;for(i=1;i<=j&&n[l-i]===f[x-i];i++);return ci=f.slice(e,1<i?1-i:void 0)}function ui(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function di(){return!0}function Qf(){return!1}function pn(e){function n(l,i,f,x,j){this._reactName=l,this._targetInst=f,this.type=i,this.nativeEvent=x,this.target=j,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(l=e[R],this[R]=l?l(x):x[R]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?di:Qf,this.isPropagationStopped=Qf,this}return v(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=di)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=di)},persist:function(){},isPersistent:di}),n}var va={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fi=pn(va),Gl=v({},va,{view:0,detail:0}),rb=pn(Gl),dc,fc,Wl,pi=v({},Gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mc,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Wl&&(Wl&&e.type==="mousemove"?(dc=e.screenX-Wl.screenX,fc=e.screenY-Wl.screenY):fc=dc=0,Wl=e),dc)},movementY:function(e){return"movementY"in e?e.movementY:fc}}),Zf=pn(pi),ab=v({},pi,{dataTransfer:0}),lb=pn(ab),sb=v({},Gl,{relatedTarget:0}),pc=pn(sb),ib=v({},va,{animationName:0,elapsedTime:0,pseudoElement:0}),ob=pn(ib),cb=v({},va,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ub=pn(cb),db=v({},va,{data:0}),Jf=pn(db),fb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pb={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"},mb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=mb[e])?!!n[e]:!1}function mc(){return hb}var xb=v({},Gl,{key:function(e){if(e.key){var n=fb[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?pb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mc,charCode:function(e){return e.type==="keypress"?ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),gb=pn(xb),vb=v({},pi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ep=pn(vb),yb=v({},Gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mc}),bb=pn(yb),jb=v({},va,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sb=pn(jb),kb=v({},pi,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),wb=pn(kb),Cb=v({},va,{newState:0,oldState:0}),Eb=pn(Cb),Nb=[9,13,27,32],hc=mr&&"CompositionEvent"in window,ql=null;mr&&"documentMode"in document&&(ql=document.documentMode);var Tb=mr&&"TextEvent"in window&&!ql,tp=mr&&(!hc||ql&&8<ql&&11>=ql),np=" ",rp=!1;function ap(e,n){switch(e){case"keyup":return Nb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var el=!1;function Rb(e,n){switch(e){case"compositionend":return lp(n);case"keypress":return n.which!==32?null:(rp=!0,np);case"textInput":return e=n.data,e===np&&rp?null:e;default:return null}}function Ab(e,n){if(el)return e==="compositionend"||!hc&&ap(e,n)?(e=Xf(),ci=uc=_r=null,el=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return tp&&n.locale!=="ko"?null:n.data;default:return null}}var Mb={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 sp(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Mb[e.type]:n==="textarea"}function ip(e,n,l,i){Za?Ja?Ja.push(i):Ja=[i]:Za=i,n=no(n,"onChange"),0<n.length&&(l=new fi("onChange","change",null,l,i),e.push({event:l,listeners:n}))}var Yl=null,Kl=null;function Lb(e){Ph(e,0)}function mi(e){var n=Vl(e);if(Vf(n))return e}function op(e,n){if(e==="change")return n}var cp=!1;if(mr){var xc;if(mr){var gc="oninput"in document;if(!gc){var up=document.createElement("div");up.setAttribute("oninput","return;"),gc=typeof up.oninput=="function"}xc=gc}else xc=!1;cp=xc&&(!document.documentMode||9<document.documentMode)}function dp(){Yl&&(Yl.detachEvent("onpropertychange",fp),Kl=Yl=null)}function fp(e){if(e.propertyName==="value"&&mi(Kl)){var n=[];ip(n,Kl,e,ic(e)),Kf(Lb,n)}}function zb(e,n,l){e==="focusin"?(dp(),Yl=n,Kl=l,Yl.attachEvent("onpropertychange",fp)):e==="focusout"&&dp()}function Db(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return mi(Kl)}function _b(e,n){if(e==="click")return mi(n)}function Ob(e,n){if(e==="input"||e==="change")return mi(n)}function Bb(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:Bb;function Xl(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),i=Object.keys(n);if(l.length!==i.length)return!1;for(i=0;i<l.length;i++){var f=l[i];if(!lt.call(n,f)||!yn(e[f],n[f]))return!1}return!0}function pp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function mp(e,n){var l=pp(e);e=0;for(var i;l;){if(l.nodeType===3){if(i=e+l.textContent.length,e<=n&&i>=n)return{node:l,offset:n-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=pp(l)}}function hp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?hp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function xp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=ii(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=ii(e.document)}return n}function vc(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 Ib=mr&&"documentMode"in document&&11>=document.documentMode,tl=null,yc=null,Ql=null,bc=!1;function gp(e,n,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;bc||tl==null||tl!==ii(i)||(i=tl,"selectionStart"in i&&vc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Ql&&Xl(Ql,i)||(Ql=i,i=no(yc,"onSelect"),0<i.length&&(n=new fi("onSelect","select",null,n,l),e.push({event:n,listeners:i}),n.target=tl)))}function ya(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var nl={animationend:ya("Animation","AnimationEnd"),animationiteration:ya("Animation","AnimationIteration"),animationstart:ya("Animation","AnimationStart"),transitionrun:ya("Transition","TransitionRun"),transitionstart:ya("Transition","TransitionStart"),transitioncancel:ya("Transition","TransitionCancel"),transitionend:ya("Transition","TransitionEnd")},jc={},vp={};mr&&(vp=document.createElement("div").style,"AnimationEvent"in window||(delete nl.animationend.animation,delete nl.animationiteration.animation,delete nl.animationstart.animation),"TransitionEvent"in window||delete nl.transitionend.transition);function ba(e){if(jc[e])return jc[e];if(!nl[e])return e;var n=nl[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in vp)return jc[e]=n[l];return e}var yp=ba("animationend"),bp=ba("animationiteration"),jp=ba("animationstart"),Ub=ba("transitionrun"),Hb=ba("transitionstart"),$b=ba("transitioncancel"),Sp=ba("transitionend"),kp=new Map,Sc="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(" ");Sc.push("scrollEnd");function Yn(e,n){kp.set(e,n),ga(n,[e])}var hi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Dn=[],rl=0,kc=0;function xi(){for(var e=rl,n=kc=rl=0;n<e;){var l=Dn[n];Dn[n++]=null;var i=Dn[n];Dn[n++]=null;var f=Dn[n];Dn[n++]=null;var x=Dn[n];if(Dn[n++]=null,i!==null&&f!==null){var j=i.pending;j===null?f.next=f:(f.next=j.next,j.next=f),i.pending=f}x!==0&&wp(l,f,x)}}function gi(e,n,l,i){Dn[rl++]=e,Dn[rl++]=n,Dn[rl++]=l,Dn[rl++]=i,kc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function wc(e,n,l,i){return gi(e,n,l,i),vi(e)}function ja(e,n){return gi(e,null,null,n),vi(e)}function wp(e,n,l){e.lanes|=l;var i=e.alternate;i!==null&&(i.lanes|=l);for(var f=!1,x=e.return;x!==null;)x.childLanes|=l,i=x.alternate,i!==null&&(i.childLanes|=l),x.tag===22&&(e=x.stateNode,e===null||e._visibility&1||(f=!0)),e=x,x=x.return;return e.tag===3?(x=e.stateNode,f&&n!==null&&(f=31-gt(l),e=x.hiddenUpdates,i=e[f],i===null?e[f]=[n]:i.push(n),n.lane=l|536870912),x):null}function vi(e){if(50<ys)throw ys=0,zu=null,Error(o(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var al={};function Vb(e,n,l,i){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bn(e,n,l,i){return new Vb(e,n,l,i)}function Cc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hr(e,n){var l=e.alternate;return l===null?(l=bn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function Cp(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function yi(e,n,l,i,f,x){var j=0;if(i=e,typeof e=="function")Cc(e)&&(j=1);else if(typeof e=="string")j=q1(e,l,te.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case z:return e=bn(31,l,n,f),e.elementType=z,e.lanes=x,e;case E:return Sa(l.children,f,x,n);case C:j=8,f|=24;break;case N:return e=bn(12,l,n,f|2),e.elementType=N,e.lanes=x,e;case D:return e=bn(13,l,n,f),e.elementType=D,e.lanes=x,e;case F:return e=bn(19,l,n,f),e.elementType=F,e.lanes=x,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case A:j=10;break e;case T:j=9;break e;case B:j=11;break e;case w:j=14;break e;case O:j=16,i=null;break e}j=29,l=Error(o(130,e===null?"null":typeof e,"")),i=null}return n=bn(j,l,n,f),n.elementType=e,n.type=i,n.lanes=x,n}function Sa(e,n,l,i){return e=bn(7,e,i,n),e.lanes=l,e}function Ec(e,n,l){return e=bn(6,e,null,n),e.lanes=l,e}function Ep(e){var n=bn(18,null,null,0);return n.stateNode=e,n}function Nc(e,n,l){return n=bn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Np=new WeakMap;function _n(e,n){if(typeof e=="object"&&e!==null){var l=Np.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Oe(n)},Np.set(e,n),n)}return{value:e,source:n,stack:Oe(n)}}var ll=[],sl=0,bi=null,Zl=0,On=[],Bn=0,Or=null,rr=1,ar="";function xr(e,n){ll[sl++]=Zl,ll[sl++]=bi,bi=e,Zl=n}function Tp(e,n,l){On[Bn++]=rr,On[Bn++]=ar,On[Bn++]=Or,Or=e;var i=rr;e=ar;var f=32-gt(i)-1;i&=~(1<<f),l+=1;var x=32-gt(n)+f;if(30<x){var j=f-f%5;x=(i&(1<<j)-1).toString(32),i>>=j,f-=j,rr=1<<32-gt(n)+f|l<<f|i,ar=x+e}else rr=1<<x|l<<f|i,ar=e}function Tc(e){e.return!==null&&(xr(e,1),Tp(e,1,0))}function Rc(e){for(;e===bi;)bi=ll[--sl],ll[sl]=null,Zl=ll[--sl],ll[sl]=null;for(;e===Or;)Or=On[--Bn],On[Bn]=null,ar=On[--Bn],On[Bn]=null,rr=On[--Bn],On[Bn]=null}function Rp(e,n){On[Bn++]=rr,On[Bn++]=ar,On[Bn++]=Or,rr=n.id,ar=n.overflow,Or=e}var Qt=null,yt=null,Xe=!1,Br=null,In=!1,Ac=Error(o(519));function Ir(e){var n=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Jl(_n(n,e)),Ac}function Ap(e){var n=e.stateNode,l=e.type,i=e.memoizedProps;switch(n[$t]=e,n[ct]=i,l){case"dialog":qe("cancel",n),qe("close",n);break;case"iframe":case"object":case"embed":qe("load",n);break;case"video":case"audio":for(l=0;l<js.length;l++)qe(js[l],n);break;case"source":qe("error",n);break;case"img":case"image":case"link":qe("error",n),qe("load",n);break;case"details":qe("toggle",n);break;case"input":qe("invalid",n),Pf(n,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":qe("invalid",n);break;case"textarea":qe("invalid",n),Gf(n,i.value,i.defaultValue,i.children)}l=i.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||i.suppressHydrationWarning===!0||qh(n.textContent,l)?(i.popover!=null&&(qe("beforetoggle",n),qe("toggle",n)),i.onScroll!=null&&qe("scroll",n),i.onScrollEnd!=null&&qe("scrollend",n),i.onClick!=null&&(n.onclick=pr),n=!0):n=!1,n||Ir(e,!0)}function Mp(e){for(Qt=e.return;Qt;)switch(Qt.tag){case 5:case 31:case 13:In=!1;return;case 27:case 3:In=!0;return;default:Qt=Qt.return}}function il(e){if(e!==Qt)return!1;if(!Xe)return Mp(e),Xe=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Yu(e.type,e.memoizedProps)),l=!l),l&&yt&&Ir(e),Mp(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));yt=nx(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));yt=nx(e)}else n===27?(n=yt,Zr(e.type)?(e=Ju,Ju=null,yt=e):yt=n):yt=Qt?Hn(e.stateNode.nextSibling):null;return!0}function ka(){yt=Qt=null,Xe=!1}function Mc(){var e=Br;return e!==null&&(gn===null?gn=e:gn.push.apply(gn,e),Br=null),e}function Jl(e){Br===null?Br=[e]:Br.push(e)}var Lc=M(null),wa=null,gr=null;function Ur(e,n,l){G(Lc,n._currentValue),n._currentValue=l}function vr(e){e._currentValue=Lc.current,Y(Lc)}function zc(e,n,l){for(;e!==null;){var i=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,i!==null&&(i.childLanes|=n)):i!==null&&(i.childLanes&n)!==n&&(i.childLanes|=n),e===l)break;e=e.return}}function Dc(e,n,l,i){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var x=f.dependencies;if(x!==null){var j=f.child;x=x.firstContext;e:for(;x!==null;){var R=x;x=f;for(var P=0;P<n.length;P++)if(R.context===n[P]){x.lanes|=l,R=x.alternate,R!==null&&(R.lanes|=l),zc(x.return,l,e),i||(j=null);break e}x=R.next}}else if(f.tag===18){if(j=f.return,j===null)throw Error(o(341));j.lanes|=l,x=j.alternate,x!==null&&(x.lanes|=l),zc(j,l,e),j=null}else j=f.child;if(j!==null)j.return=f;else for(j=f;j!==null;){if(j===e){j=null;break}if(f=j.sibling,f!==null){f.return=j.return,j=f;break}j=j.return}f=j}}function ol(e,n,l,i){e=null;for(var f=n,x=!1;f!==null;){if(!x){if((f.flags&524288)!==0)x=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var j=f.alternate;if(j===null)throw Error(o(387));if(j=j.memoizedProps,j!==null){var R=f.type;yn(f.pendingProps.value,j.value)||(e!==null?e.push(R):e=[R])}}else if(f===ve.current){if(j=f.alternate,j===null)throw Error(o(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Es):e=[Es])}f=f.return}e!==null&&Dc(n,e,l,i),n.flags|=262144}function ji(e){for(e=e.firstContext;e!==null;){if(!yn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ca(e){wa=e,gr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Zt(e){return Lp(wa,e)}function Si(e,n){return wa===null&&Ca(e),Lp(e,n)}function Lp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},gr===null){if(e===null)throw Error(o(308));gr=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else gr=gr.next=n;return l}var Pb=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,i){e.push(i)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},Fb=t.unstable_scheduleCallback,Gb=t.unstable_NormalPriority,Ot={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _c(){return{controller:new Pb,data:new Map,refCount:0}}function es(e){e.refCount--,e.refCount===0&&Fb(Gb,function(){e.controller.abort()})}var ts=null,Oc=0,cl=0,ul=null;function Wb(e,n){if(ts===null){var l=ts=[];Oc=0,cl=Uu(),ul={status:"pending",value:void 0,then:function(i){l.push(i)}}}return Oc++,n.then(zp,zp),n}function zp(){if(--Oc===0&&ts!==null){ul!==null&&(ul.status="fulfilled");var e=ts;ts=null,cl=0,ul=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function qb(e,n){var l=[],i={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){i.status="fulfilled",i.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(i.status="rejected",i.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),i}var Dp=L.S;L.S=function(e,n){gh=Ze(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Wb(e,n),Dp!==null&&Dp(e,n)};var Ea=M(null);function Bc(){var e=Ea.current;return e!==null?e:ht.pooledCache}function ki(e,n){n===null?G(Ea,Ea.current):G(Ea,n.pool)}function _p(){var e=Bc();return e===null?null:{parent:Ot._currentValue,pool:e}}var dl=Error(o(460)),Ic=Error(o(474)),wi=Error(o(542)),Ci={then:function(){}};function Op(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Bp(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(pr,pr),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Up(e),e;default:if(typeof n.status=="string")n.then(pr,pr);else{if(e=ht,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=n,e.status="pending",e.then(function(i){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=i}},function(i){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=i}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Up(e),e}throw Ta=n,dl}}function Na(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Ta=l,dl):l}}var Ta=null;function Ip(){if(Ta===null)throw Error(o(459));var e=Ta;return Ta=null,e}function Up(e){if(e===dl||e===wi)throw Error(o(483))}var fl=null,ns=0;function Ei(e){var n=ns;return ns+=1,fl===null&&(fl=[]),Bp(fl,e,n)}function rs(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ni(e,n){throw n.$$typeof===b?Error(o(525)):(e=Object.prototype.toString.call(n),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Hp(e){function n(K,W){if(e){var Q=K.deletions;Q===null?(K.deletions=[W],K.flags|=16):Q.push(W)}}function l(K,W){if(!e)return null;for(;W!==null;)n(K,W),W=W.sibling;return null}function i(K){for(var W=new Map;K!==null;)K.key!==null?W.set(K.key,K):W.set(K.index,K),K=K.sibling;return W}function f(K,W){return K=hr(K,W),K.index=0,K.sibling=null,K}function x(K,W,Q){return K.index=Q,e?(Q=K.alternate,Q!==null?(Q=Q.index,Q<W?(K.flags|=67108866,W):Q):(K.flags|=67108866,W)):(K.flags|=1048576,W)}function j(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function R(K,W,Q,ce){return W===null||W.tag!==6?(W=Ec(Q,K.mode,ce),W.return=K,W):(W=f(W,Q),W.return=K,W)}function P(K,W,Q,ce){var Ae=Q.type;return Ae===E?se(K,W,Q.props.children,ce,Q.key):W!==null&&(W.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===O&&Na(Ae)===W.type)?(W=f(W,Q.props),rs(W,Q),W.return=K,W):(W=yi(Q.type,Q.key,Q.props,null,K.mode,ce),rs(W,Q),W.return=K,W)}function Z(K,W,Q,ce){return W===null||W.tag!==4||W.stateNode.containerInfo!==Q.containerInfo||W.stateNode.implementation!==Q.implementation?(W=Nc(Q,K.mode,ce),W.return=K,W):(W=f(W,Q.children||[]),W.return=K,W)}function se(K,W,Q,ce,Ae){return W===null||W.tag!==7?(W=Sa(Q,K.mode,ce,Ae),W.return=K,W):(W=f(W,Q),W.return=K,W)}function ue(K,W,Q){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=Ec(""+W,K.mode,Q),W.return=K,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case S:return Q=yi(W.type,W.key,W.props,null,K.mode,Q),rs(Q,W),Q.return=K,Q;case k:return W=Nc(W,K.mode,Q),W.return=K,W;case O:return W=Na(W),ue(K,W,Q)}if($(W)||q(W))return W=Sa(W,K.mode,Q,null),W.return=K,W;if(typeof W.then=="function")return ue(K,Ei(W),Q);if(W.$$typeof===A)return ue(K,Si(K,W),Q);Ni(K,W)}return null}function ee(K,W,Q,ce){var Ae=W!==null?W.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Ae!==null?null:R(K,W,""+Q,ce);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return Q.key===Ae?P(K,W,Q,ce):null;case k:return Q.key===Ae?Z(K,W,Q,ce):null;case O:return Q=Na(Q),ee(K,W,Q,ce)}if($(Q)||q(Q))return Ae!==null?null:se(K,W,Q,ce,null);if(typeof Q.then=="function")return ee(K,W,Ei(Q),ce);if(Q.$$typeof===A)return ee(K,W,Si(K,Q),ce);Ni(K,Q)}return null}function re(K,W,Q,ce,Ae){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return K=K.get(Q)||null,R(W,K,""+ce,Ae);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case S:return K=K.get(ce.key===null?Q:ce.key)||null,P(W,K,ce,Ae);case k:return K=K.get(ce.key===null?Q:ce.key)||null,Z(W,K,ce,Ae);case O:return ce=Na(ce),re(K,W,Q,ce,Ae)}if($(ce)||q(ce))return K=K.get(Q)||null,se(W,K,ce,Ae,null);if(typeof ce.then=="function")return re(K,W,Q,Ei(ce),Ae);if(ce.$$typeof===A)return re(K,W,Q,Si(W,ce),Ae);Ni(W,ce)}return null}function we(K,W,Q,ce){for(var Ae=null,Je=null,Ee=W,Pe=W=0,Ke=null;Ee!==null&&Pe<Q.length;Pe++){Ee.index>Pe?(Ke=Ee,Ee=null):Ke=Ee.sibling;var et=ee(K,Ee,Q[Pe],ce);if(et===null){Ee===null&&(Ee=Ke);break}e&&Ee&&et.alternate===null&&n(K,Ee),W=x(et,W,Pe),Je===null?Ae=et:Je.sibling=et,Je=et,Ee=Ke}if(Pe===Q.length)return l(K,Ee),Xe&&xr(K,Pe),Ae;if(Ee===null){for(;Pe<Q.length;Pe++)Ee=ue(K,Q[Pe],ce),Ee!==null&&(W=x(Ee,W,Pe),Je===null?Ae=Ee:Je.sibling=Ee,Je=Ee);return Xe&&xr(K,Pe),Ae}for(Ee=i(Ee);Pe<Q.length;Pe++)Ke=re(Ee,K,Pe,Q[Pe],ce),Ke!==null&&(e&&Ke.alternate!==null&&Ee.delete(Ke.key===null?Pe:Ke.key),W=x(Ke,W,Pe),Je===null?Ae=Ke:Je.sibling=Ke,Je=Ke);return e&&Ee.forEach(function(ra){return n(K,ra)}),Xe&&xr(K,Pe),Ae}function Le(K,W,Q,ce){if(Q==null)throw Error(o(151));for(var Ae=null,Je=null,Ee=W,Pe=W=0,Ke=null,et=Q.next();Ee!==null&&!et.done;Pe++,et=Q.next()){Ee.index>Pe?(Ke=Ee,Ee=null):Ke=Ee.sibling;var ra=ee(K,Ee,et.value,ce);if(ra===null){Ee===null&&(Ee=Ke);break}e&&Ee&&ra.alternate===null&&n(K,Ee),W=x(ra,W,Pe),Je===null?Ae=ra:Je.sibling=ra,Je=ra,Ee=Ke}if(et.done)return l(K,Ee),Xe&&xr(K,Pe),Ae;if(Ee===null){for(;!et.done;Pe++,et=Q.next())et=ue(K,et.value,ce),et!==null&&(W=x(et,W,Pe),Je===null?Ae=et:Je.sibling=et,Je=et);return Xe&&xr(K,Pe),Ae}for(Ee=i(Ee);!et.done;Pe++,et=Q.next())et=re(Ee,K,Pe,et.value,ce),et!==null&&(e&&et.alternate!==null&&Ee.delete(et.key===null?Pe:et.key),W=x(et,W,Pe),Je===null?Ae=et:Je.sibling=et,Je=et);return e&&Ee.forEach(function(a0){return n(K,a0)}),Xe&&xr(K,Pe),Ae}function ft(K,W,Q,ce){if(typeof Q=="object"&&Q!==null&&Q.type===E&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:e:{for(var Ae=Q.key;W!==null;){if(W.key===Ae){if(Ae=Q.type,Ae===E){if(W.tag===7){l(K,W.sibling),ce=f(W,Q.props.children),ce.return=K,K=ce;break e}}else if(W.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===O&&Na(Ae)===W.type){l(K,W.sibling),ce=f(W,Q.props),rs(ce,Q),ce.return=K,K=ce;break e}l(K,W);break}else n(K,W);W=W.sibling}Q.type===E?(ce=Sa(Q.props.children,K.mode,ce,Q.key),ce.return=K,K=ce):(ce=yi(Q.type,Q.key,Q.props,null,K.mode,ce),rs(ce,Q),ce.return=K,K=ce)}return j(K);case k:e:{for(Ae=Q.key;W!==null;){if(W.key===Ae)if(W.tag===4&&W.stateNode.containerInfo===Q.containerInfo&&W.stateNode.implementation===Q.implementation){l(K,W.sibling),ce=f(W,Q.children||[]),ce.return=K,K=ce;break e}else{l(K,W);break}else n(K,W);W=W.sibling}ce=Nc(Q,K.mode,ce),ce.return=K,K=ce}return j(K);case O:return Q=Na(Q),ft(K,W,Q,ce)}if($(Q))return we(K,W,Q,ce);if(q(Q)){if(Ae=q(Q),typeof Ae!="function")throw Error(o(150));return Q=Ae.call(Q),Le(K,W,Q,ce)}if(typeof Q.then=="function")return ft(K,W,Ei(Q),ce);if(Q.$$typeof===A)return ft(K,W,Si(K,Q),ce);Ni(K,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,W!==null&&W.tag===6?(l(K,W.sibling),ce=f(W,Q),ce.return=K,K=ce):(l(K,W),ce=Ec(Q,K.mode,ce),ce.return=K,K=ce),j(K)):l(K,W)}return function(K,W,Q,ce){try{ns=0;var Ae=ft(K,W,Q,ce);return fl=null,Ae}catch(Ee){if(Ee===dl||Ee===wi)throw Ee;var Je=bn(29,Ee,null,K.mode);return Je.lanes=ce,Je.return=K,Je}finally{}}}var Ra=Hp(!0),$p=Hp(!1),Hr=!1;function Uc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hc(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function $r(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Vr(e,n,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(rt&2)!==0){var f=i.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),i.pending=n,n=vi(e),wp(e,null,l),n}return gi(e,i,n,l),vi(e)}function as(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pa(e,l)}}function $c(e,n){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var f=null,x=null;if(l=l.firstBaseUpdate,l!==null){do{var j={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};x===null?f=x=j:x=x.next=j,l=l.next}while(l!==null);x===null?f=x=n:x=x.next=n}else f=x=n;l={baseState:i.baseState,firstBaseUpdate:f,lastBaseUpdate:x,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var Vc=!1;function ls(){if(Vc){var e=ul;if(e!==null)throw e}}function ss(e,n,l,i){Vc=!1;var f=e.updateQueue;Hr=!1;var x=f.firstBaseUpdate,j=f.lastBaseUpdate,R=f.shared.pending;if(R!==null){f.shared.pending=null;var P=R,Z=P.next;P.next=null,j===null?x=Z:j.next=Z,j=P;var se=e.alternate;se!==null&&(se=se.updateQueue,R=se.lastBaseUpdate,R!==j&&(R===null?se.firstBaseUpdate=Z:R.next=Z,se.lastBaseUpdate=P))}if(x!==null){var ue=f.baseState;j=0,se=Z=P=null,R=x;do{var ee=R.lane&-536870913,re=ee!==R.lane;if(re?(Ye&ee)===ee:(i&ee)===ee){ee!==0&&ee===cl&&(Vc=!0),se!==null&&(se=se.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var we=e,Le=R;ee=n;var ft=l;switch(Le.tag){case 1:if(we=Le.payload,typeof we=="function"){ue=we.call(ft,ue,ee);break e}ue=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Le.payload,ee=typeof we=="function"?we.call(ft,ue,ee):we,ee==null)break e;ue=v({},ue,ee);break e;case 2:Hr=!0}}ee=R.callback,ee!==null&&(e.flags|=64,re&&(e.flags|=8192),re=f.callbacks,re===null?f.callbacks=[ee]:re.push(ee))}else re={lane:ee,tag:R.tag,payload:R.payload,callback:R.callback,next:null},se===null?(Z=se=re,P=ue):se=se.next=re,j|=ee;if(R=R.next,R===null){if(R=f.shared.pending,R===null)break;re=R,R=re.next,re.next=null,f.lastBaseUpdate=re,f.shared.pending=null}}while(!0);se===null&&(P=ue),f.baseState=P,f.firstBaseUpdate=Z,f.lastBaseUpdate=se,x===null&&(f.shared.lanes=0),qr|=j,e.lanes=j,e.memoizedState=ue}}function Vp(e,n){if(typeof e!="function")throw Error(o(191,e));e.call(n)}function Pp(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Vp(l[e],n)}var pl=M(null),Ti=M(0);function Fp(e,n){e=Nr,G(Ti,e),G(pl,n),Nr=e|n.baseLanes}function Pc(){G(Ti,Nr),G(pl,pl.current)}function Fc(){Nr=Ti.current,Y(pl),Y(Ti)}var jn=M(null),Un=null;function Pr(e){var n=e.alternate;G(zt,zt.current&1),G(jn,e),Un===null&&(n===null||pl.current!==null||n.memoizedState!==null)&&(Un=e)}function Gc(e){G(zt,zt.current),G(jn,e),Un===null&&(Un=e)}function Gp(e){e.tag===22?(G(zt,zt.current),G(jn,e),Un===null&&(Un=e)):Fr()}function Fr(){G(zt,zt.current),G(jn,jn.current)}function Sn(e){Y(jn),Un===e&&(Un=null),Y(zt)}var zt=M(0);function Ri(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Qu(l)||Zu(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var yr=0,$e=null,ut=null,Bt=null,Ai=!1,ml=!1,Aa=!1,Mi=0,is=0,hl=null,Yb=0;function At(){throw Error(o(321))}function Wc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!yn(e[l],n[l]))return!1;return!0}function qc(e,n,l,i,f,x){return yr=x,$e=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,L.H=e===null||e.memoizedState===null?Tm:ou,Aa=!1,x=l(i,f),Aa=!1,ml&&(x=qp(n,l,i,f)),Wp(e),x}function Wp(e){L.H=us;var n=ut!==null&&ut.next!==null;if(yr=0,Bt=ut=$e=null,Ai=!1,is=0,hl=null,n)throw Error(o(300));e===null||It||(e=e.dependencies,e!==null&&ji(e)&&(It=!0))}function qp(e,n,l,i){$e=e;var f=0;do{if(ml&&(hl=null),is=0,ml=!1,25<=f)throw Error(o(301));if(f+=1,Bt=ut=null,e.updateQueue!=null){var x=e.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}L.H=Rm,x=n(l,i)}while(ml);return x}function Kb(){var e=L.H,n=e.useState()[0];return n=typeof n.then=="function"?os(n):n,e=e.useState()[0],(ut!==null?ut.memoizedState:null)!==e&&($e.flags|=1024),n}function Yc(){var e=Mi!==0;return Mi=0,e}function Kc(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Xc(e){if(Ai){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Ai=!1}yr=0,Bt=ut=$e=null,ml=!1,is=Mi=0,hl=null}function on(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bt===null?$e.memoizedState=Bt=e:Bt=Bt.next=e,Bt}function Dt(){if(ut===null){var e=$e.alternate;e=e!==null?e.memoizedState:null}else e=ut.next;var n=Bt===null?$e.memoizedState:Bt.next;if(n!==null)Bt=n,ut=e;else{if(e===null)throw $e.alternate===null?Error(o(467)):Error(o(310));ut=e,e={memoizedState:ut.memoizedState,baseState:ut.baseState,baseQueue:ut.baseQueue,queue:ut.queue,next:null},Bt===null?$e.memoizedState=Bt=e:Bt=Bt.next=e}return Bt}function Li(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function os(e){var n=is;return is+=1,hl===null&&(hl=[]),e=Bp(hl,e,n),n=$e,(Bt===null?n.memoizedState:Bt.next)===null&&(n=n.alternate,L.H=n===null||n.memoizedState===null?Tm:ou),e}function zi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return os(e);if(e.$$typeof===A)return Zt(e)}throw Error(o(438,String(e)))}function Qc(e){var n=null,l=$e.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var i=$e.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(n={data:i.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=Li(),$e.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),i=0;i<e;i++)l[i]=U;return n.index++,l}function br(e,n){return typeof n=="function"?n(e):n}function Di(e){var n=Dt();return Zc(n,ut,e)}function Zc(e,n,l){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=l;var f=e.baseQueue,x=i.pending;if(x!==null){if(f!==null){var j=f.next;f.next=x.next,x.next=j}n.baseQueue=f=x,i.pending=null}if(x=e.baseState,f===null)e.memoizedState=x;else{n=f.next;var R=j=null,P=null,Z=n,se=!1;do{var ue=Z.lane&-536870913;if(ue!==Z.lane?(Ye&ue)===ue:(yr&ue)===ue){var ee=Z.revertLane;if(ee===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),ue===cl&&(se=!0);else if((yr&ee)===ee){Z=Z.next,ee===cl&&(se=!0);continue}else ue={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ue,j=x):P=P.next=ue,$e.lanes|=ee,qr|=ee;ue=Z.action,Aa&&l(x,ue),x=Z.hasEagerState?Z.eagerState:l(x,ue)}else ee={lane:ue,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ee,j=x):P=P.next=ee,$e.lanes|=ue,qr|=ue;Z=Z.next}while(Z!==null&&Z!==n);if(P===null?j=x:P.next=R,!yn(x,e.memoizedState)&&(It=!0,se&&(l=ul,l!==null)))throw l;e.memoizedState=x,e.baseState=j,e.baseQueue=P,i.lastRenderedState=x}return f===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Jc(e){var n=Dt(),l=n.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=e;var i=l.dispatch,f=l.pending,x=n.memoizedState;if(f!==null){l.pending=null;var j=f=f.next;do x=e(x,j.action),j=j.next;while(j!==f);yn(x,n.memoizedState)||(It=!0),n.memoizedState=x,n.baseQueue===null&&(n.baseState=x),l.lastRenderedState=x}return[x,i]}function Yp(e,n,l){var i=$e,f=Dt(),x=Xe;if(x){if(l===void 0)throw Error(o(407));l=l()}else l=n();var j=!yn((ut||f).memoizedState,l);if(j&&(f.memoizedState=l,It=!0),f=f.queue,nu(Qp.bind(null,i,f,e),[e]),f.getSnapshot!==n||j||Bt!==null&&Bt.memoizedState.tag&1){if(i.flags|=2048,xl(9,{destroy:void 0},Xp.bind(null,i,f,l,n),null),ht===null)throw Error(o(349));x||(yr&127)!==0||Kp(i,n,l)}return l}function Kp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=$e.updateQueue,n===null?(n=Li(),$e.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function Xp(e,n,l,i){n.value=l,n.getSnapshot=i,Zp(n)&&Jp(e)}function Qp(e,n,l){return l(function(){Zp(n)&&Jp(e)})}function Zp(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!yn(e,l)}catch{return!0}}function Jp(e){var n=ja(e,2);n!==null&&vn(n,e,2)}function eu(e){var n=on();if(typeof e=="function"){var l=e;if(e=l(),Aa){vt(!0);try{l()}finally{vt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:e},n}function em(e,n,l,i){return e.baseState=l,Zc(e,ut,typeof i=="function"?i:br)}function Xb(e,n,l,i,f){if(Bi(e))throw Error(o(485));if(e=n.action,e!==null){var x={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){x.listeners.push(j)}};L.T!==null?l(!0):x.isTransition=!1,i(x),l=n.pending,l===null?(x.next=n.pending=x,tm(n,x)):(x.next=l.next,n.pending=l.next=x)}}function tm(e,n){var l=n.action,i=n.payload,f=e.state;if(n.isTransition){var x=L.T,j={};L.T=j;try{var R=l(f,i),P=L.S;P!==null&&P(j,R),nm(e,n,R)}catch(Z){tu(e,n,Z)}finally{x!==null&&j.types!==null&&(x.types=j.types),L.T=x}}else try{x=l(f,i),nm(e,n,x)}catch(Z){tu(e,n,Z)}}function nm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(i){rm(e,n,i)},function(i){return tu(e,n,i)}):rm(e,n,l)}function rm(e,n,l){n.status="fulfilled",n.value=l,am(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,tm(e,l)))}function tu(e,n,l){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do n.status="rejected",n.reason=l,am(n),n=n.next;while(n!==i)}e.action=null}function am(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function lm(e,n){return n}function sm(e,n){if(Xe){var l=ht.formState;if(l!==null){e:{var i=$e;if(Xe){if(yt){t:{for(var f=yt,x=In;f.nodeType!==8;){if(!x){f=null;break t}if(f=Hn(f.nextSibling),f===null){f=null;break t}}x=f.data,f=x==="F!"||x==="F"?f:null}if(f){yt=Hn(f.nextSibling),i=f.data==="F!";break e}}Ir(i)}i=!1}i&&(n=l[0])}}return l=on(),l.memoizedState=l.baseState=n,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:lm,lastRenderedState:n},l.queue=i,l=Cm.bind(null,$e,i),i.dispatch=l,i=eu(!1),x=iu.bind(null,$e,!1,i.queue),i=on(),f={state:n,dispatch:null,action:e,pending:null},i.queue=f,l=Xb.bind(null,$e,f,x,l),f.dispatch=l,i.memoizedState=e,[n,l,!1]}function im(e){var n=Dt();return om(n,ut,e)}function om(e,n,l){if(n=Zc(e,n,lm)[0],e=Di(br)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var i=os(n)}catch(j){throw j===dl?wi:j}else i=n;n=Dt();var f=n.queue,x=f.dispatch;return l!==n.memoizedState&&($e.flags|=2048,xl(9,{destroy:void 0},Qb.bind(null,f,l),null)),[i,x,e]}function Qb(e,n){e.action=n}function cm(e){var n=Dt(),l=ut;if(l!==null)return om(n,l,e);Dt(),n=n.memoizedState,l=Dt();var i=l.queue.dispatch;return l.memoizedState=e,[n,i,!1]}function xl(e,n,l,i){return e={tag:e,create:l,deps:i,inst:n,next:null},n=$e.updateQueue,n===null&&(n=Li(),$e.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(i=l.next,l.next=e,e.next=i,n.lastEffect=e),e}function um(){return Dt().memoizedState}function _i(e,n,l,i){var f=on();$e.flags|=e,f.memoizedState=xl(1|n,{destroy:void 0},l,i===void 0?null:i)}function Oi(e,n,l,i){var f=Dt();i=i===void 0?null:i;var x=f.memoizedState.inst;ut!==null&&i!==null&&Wc(i,ut.memoizedState.deps)?f.memoizedState=xl(n,x,l,i):($e.flags|=e,f.memoizedState=xl(1|n,x,l,i))}function dm(e,n){_i(8390656,8,e,n)}function nu(e,n){Oi(2048,8,e,n)}function Zb(e){$e.flags|=4;var n=$e.updateQueue;if(n===null)n=Li(),$e.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function fm(e){var n=Dt().memoizedState;return Zb({ref:n,nextImpl:e}),function(){if((rt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}function pm(e,n){return Oi(4,2,e,n)}function mm(e,n){return Oi(4,4,e,n)}function hm(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 xm(e,n,l){l=l!=null?l.concat([e]):null,Oi(4,4,hm.bind(null,n,e),l)}function ru(){}function gm(e,n){var l=Dt();n=n===void 0?null:n;var i=l.memoizedState;return n!==null&&Wc(n,i[1])?i[0]:(l.memoizedState=[e,n],e)}function vm(e,n){var l=Dt();n=n===void 0?null:n;var i=l.memoizedState;if(n!==null&&Wc(n,i[1]))return i[0];if(i=e(),Aa){vt(!0);try{e()}finally{vt(!1)}}return l.memoizedState=[i,n],i}function au(e,n,l){return l===void 0||(yr&1073741824)!==0&&(Ye&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=yh(),$e.lanes|=e,qr|=e,l)}function ym(e,n,l,i){return yn(l,n)?l:pl.current!==null?(e=au(e,l,i),yn(e,n)||(It=!0),e):(yr&42)===0||(yr&1073741824)!==0&&(Ye&261930)===0?(It=!0,e.memoizedState=l):(e=yh(),$e.lanes|=e,qr|=e,n)}function bm(e,n,l,i,f){var x=_.p;_.p=x!==0&&8>x?x:8;var j=L.T,R={};L.T=R,iu(e,!1,n,l);try{var P=f(),Z=L.S;if(Z!==null&&Z(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var se=qb(P,i);cs(e,n,se,Cn(e))}else cs(e,n,i,Cn(e))}catch(ue){cs(e,n,{then:function(){},status:"rejected",reason:ue},Cn())}finally{_.p=x,j!==null&&R.types!==null&&(j.types=R.types),L.T=j}}function Jb(){}function lu(e,n,l,i){if(e.tag!==5)throw Error(o(476));var f=jm(e).queue;bm(e,f,n,I,l===null?Jb:function(){return Sm(e),l(i)})}function jm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:I},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Sm(e){var n=jm(e);n.next===null&&(n=e.alternate.memoizedState),cs(e,n.next.queue,{},Cn())}function su(){return Zt(Es)}function km(){return Dt().memoizedState}function wm(){return Dt().memoizedState}function e1(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Cn();e=$r(l);var i=Vr(n,e,l);i!==null&&(vn(i,n,l),as(i,n,l)),n={cache:_c()},e.payload=n;return}n=n.return}}function t1(e,n,l){var i=Cn();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Bi(e)?Em(n,l):(l=wc(e,n,l,i),l!==null&&(vn(l,e,i),Nm(l,n,i)))}function Cm(e,n,l){var i=Cn();cs(e,n,l,i)}function cs(e,n,l,i){var f={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Bi(e))Em(n,f);else{var x=e.alternate;if(e.lanes===0&&(x===null||x.lanes===0)&&(x=n.lastRenderedReducer,x!==null))try{var j=n.lastRenderedState,R=x(j,l);if(f.hasEagerState=!0,f.eagerState=R,yn(R,j))return gi(e,n,f,0),ht===null&&xi(),!1}catch{}finally{}if(l=wc(e,n,f,i),l!==null)return vn(l,e,i),Nm(l,n,i),!0}return!1}function iu(e,n,l,i){if(i={lane:2,revertLane:Uu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Bi(e)){if(n)throw Error(o(479))}else n=wc(e,l,i,2),n!==null&&vn(n,e,2)}function Bi(e){var n=e.alternate;return e===$e||n!==null&&n===$e}function Em(e,n){ml=Ai=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Nm(e,n,l){if((l&4194048)!==0){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pa(e,l)}}var us={readContext:Zt,use:zi,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};us.useEffectEvent=At;var Tm={readContext:Zt,use:zi,useCallback:function(e,n){return on().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:dm,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,_i(4194308,4,hm.bind(null,n,e),l)},useLayoutEffect:function(e,n){return _i(4194308,4,e,n)},useInsertionEffect:function(e,n){_i(4,2,e,n)},useMemo:function(e,n){var l=on();n=n===void 0?null:n;var i=e();if(Aa){vt(!0);try{e()}finally{vt(!1)}}return l.memoizedState=[i,n],i},useReducer:function(e,n,l){var i=on();if(l!==void 0){var f=l(n);if(Aa){vt(!0);try{l(n)}finally{vt(!1)}}}else f=n;return i.memoizedState=i.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},i.queue=e,e=e.dispatch=t1.bind(null,$e,e),[i.memoizedState,e]},useRef:function(e){var n=on();return e={current:e},n.memoizedState=e},useState:function(e){e=eu(e);var n=e.queue,l=Cm.bind(null,$e,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:ru,useDeferredValue:function(e,n){var l=on();return au(l,e,n)},useTransition:function(){var e=eu(!1);return e=bm.bind(null,$e,e.queue,!0,!1),on().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var i=$e,f=on();if(Xe){if(l===void 0)throw Error(o(407));l=l()}else{if(l=n(),ht===null)throw Error(o(349));(Ye&127)!==0||Kp(i,n,l)}f.memoizedState=l;var x={value:l,getSnapshot:n};return f.queue=x,dm(Qp.bind(null,i,x,e),[e]),i.flags|=2048,xl(9,{destroy:void 0},Xp.bind(null,i,x,l,n),null),l},useId:function(){var e=on(),n=ht.identifierPrefix;if(Xe){var l=ar,i=rr;l=(i&~(1<<32-gt(i)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Mi++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=Yb++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:su,useFormState:sm,useActionState:sm,useOptimistic:function(e){var n=on();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=iu.bind(null,$e,!0,l),l.dispatch=n,[e,n]},useMemoCache:Qc,useCacheRefresh:function(){return on().memoizedState=e1.bind(null,$e)},useEffectEvent:function(e){var n=on(),l={impl:e};return n.memoizedState=l,function(){if((rt&2)!==0)throw Error(o(440));return l.impl.apply(void 0,arguments)}}},ou={readContext:Zt,use:zi,useCallback:gm,useContext:Zt,useEffect:nu,useImperativeHandle:xm,useInsertionEffect:pm,useLayoutEffect:mm,useMemo:vm,useReducer:Di,useRef:um,useState:function(){return Di(br)},useDebugValue:ru,useDeferredValue:function(e,n){var l=Dt();return ym(l,ut.memoizedState,e,n)},useTransition:function(){var e=Di(br)[0],n=Dt().memoizedState;return[typeof e=="boolean"?e:os(e),n]},useSyncExternalStore:Yp,useId:km,useHostTransitionStatus:su,useFormState:im,useActionState:im,useOptimistic:function(e,n){var l=Dt();return em(l,ut,e,n)},useMemoCache:Qc,useCacheRefresh:wm};ou.useEffectEvent=fm;var Rm={readContext:Zt,use:zi,useCallback:gm,useContext:Zt,useEffect:nu,useImperativeHandle:xm,useInsertionEffect:pm,useLayoutEffect:mm,useMemo:vm,useReducer:Jc,useRef:um,useState:function(){return Jc(br)},useDebugValue:ru,useDeferredValue:function(e,n){var l=Dt();return ut===null?au(l,e,n):ym(l,ut.memoizedState,e,n)},useTransition:function(){var e=Jc(br)[0],n=Dt().memoizedState;return[typeof e=="boolean"?e:os(e),n]},useSyncExternalStore:Yp,useId:km,useHostTransitionStatus:su,useFormState:cm,useActionState:cm,useOptimistic:function(e,n){var l=Dt();return ut!==null?em(l,ut,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Qc,useCacheRefresh:wm};Rm.useEffectEvent=fm;function cu(e,n,l,i){n=e.memoizedState,l=l(i,n),l=l==null?n:v({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var uu={enqueueSetState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$r(i);f.payload=n,l!=null&&(f.callback=l),n=Vr(e,f,i),n!==null&&(vn(n,e,i),as(n,e,i))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$r(i);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Vr(e,f,i),n!==null&&(vn(n,e,i),as(n,e,i))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Cn(),i=$r(l);i.tag=2,n!=null&&(i.callback=n),n=Vr(e,i,l),n!==null&&(vn(n,e,l),as(n,e,l))}};function Am(e,n,l,i,f,x,j){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,x,j):n.prototype&&n.prototype.isPureReactComponent?!Xl(l,i)||!Xl(f,x):!0}function Mm(e,n,l,i){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,i),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,i),n.state!==e&&uu.enqueueReplaceState(n,n.state,null)}function Ma(e,n){var l=n;if("ref"in n){l={};for(var i in n)i!=="ref"&&(l[i]=n[i])}if(e=e.defaultProps){l===n&&(l=v({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function Lm(e){hi(e)}function zm(e){console.error(e)}function Dm(e){hi(e)}function Ii(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(i){setTimeout(function(){throw i})}}function _m(e,n,l){try{var i=e.onCaughtError;i(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function du(e,n,l){return l=$r(l),l.tag=3,l.payload={element:null},l.callback=function(){Ii(e,n)},l}function Om(e){return e=$r(e),e.tag=3,e}function Bm(e,n,l,i){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var x=i.value;e.payload=function(){return f(x)},e.callback=function(){_m(n,l,i)}}var j=l.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(e.callback=function(){_m(n,l,i),typeof f!="function"&&(Yr===null?Yr=new Set([this]):Yr.add(this));var R=i.stack;this.componentDidCatch(i.value,{componentStack:R!==null?R:""})})}function n1(e,n,l,i,f){if(l.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(n=l.alternate,n!==null&&ol(n,l,f,!0),l=jn.current,l!==null){switch(l.tag){case 31:case 13:return Un===null?Xi():l.alternate===null&&Mt===0&&(Mt=3),l.flags&=-257,l.flags|=65536,l.lanes=f,i===Ci?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([i]):n.add(i),Ou(e,i,f)),!1;case 22:return l.flags|=65536,i===Ci?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([i])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([i]):l.add(i)),Ou(e,i,f)),!1}throw Error(o(435,l.tag))}return Ou(e,i,f),Xi(),!1}if(Xe)return n=jn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,i!==Ac&&(e=Error(o(422),{cause:i}),Jl(_n(e,l)))):(i!==Ac&&(n=Error(o(423),{cause:i}),Jl(_n(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,i=_n(i,l),f=du(e.stateNode,i,f),$c(e,f),Mt!==4&&(Mt=2)),!1;var x=Error(o(520),{cause:i});if(x=_n(x,l),vs===null?vs=[x]:vs.push(x),Mt!==4&&(Mt=2),n===null)return!0;i=_n(i,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=du(l.stateNode,i,e),$c(l,e),!1;case 1:if(n=l.type,x=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Yr===null||!Yr.has(x))))return l.flags|=65536,f&=-f,l.lanes|=f,f=Om(f),Bm(f,e,l,i),$c(l,f),!1}l=l.return}while(l!==null);return!1}var fu=Error(o(461)),It=!1;function Jt(e,n,l,i){n.child=e===null?$p(n,null,l,i):Ra(n,e.child,l,i)}function Im(e,n,l,i,f){l=l.render;var x=n.ref;if("ref"in i){var j={};for(var R in i)R!=="ref"&&(j[R]=i[R])}else j=i;return Ca(n),i=qc(e,n,l,j,x,f),R=Yc(),e!==null&&!It?(Kc(e,n,f),jr(e,n,f)):(Xe&&R&&Tc(n),n.flags|=1,Jt(e,n,i,f),n.child)}function Um(e,n,l,i,f){if(e===null){var x=l.type;return typeof x=="function"&&!Cc(x)&&x.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=x,Hm(e,n,x,i,f)):(e=yi(l.type,null,i,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(x=e.child,!bu(e,f)){var j=x.memoizedProps;if(l=l.compare,l=l!==null?l:Xl,l(j,i)&&e.ref===n.ref)return jr(e,n,f)}return n.flags|=1,e=hr(x,i),e.ref=n.ref,e.return=n,n.child=e}function Hm(e,n,l,i,f){if(e!==null){var x=e.memoizedProps;if(Xl(x,i)&&e.ref===n.ref)if(It=!1,n.pendingProps=i=x,bu(e,f))(e.flags&131072)!==0&&(It=!0);else return n.lanes=e.lanes,jr(e,n,f)}return pu(e,n,l,i,f)}function $m(e,n,l,i){var f=i.children,x=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((n.flags&128)!==0){if(x=x!==null?x.baseLanes|l:l,e!==null){for(i=n.child=e.child,f=0;i!==null;)f=f|i.lanes|i.childLanes,i=i.sibling;i=f&~x}else i=0,n.child=null;return Vm(e,n,x,l,i)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&ki(n,x!==null?x.cachePool:null),x!==null?Fp(n,x):Pc(),Gp(n);else return i=n.lanes=536870912,Vm(e,n,x!==null?x.baseLanes|l:l,l,i)}else x!==null?(ki(n,x.cachePool),Fp(n,x),Fr(),n.memoizedState=null):(e!==null&&ki(n,null),Pc(),Fr());return Jt(e,n,f,l),n.child}function ds(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Vm(e,n,l,i,f){var x=Bc();return x=x===null?null:{parent:Ot._currentValue,pool:x},n.memoizedState={baseLanes:l,cachePool:x},e!==null&&ki(n,null),Pc(),Gp(n),e!==null&&ol(e,n,i,!0),n.childLanes=f,null}function Ui(e,n){return n=$i({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Pm(e,n,l){return Ra(n,e.child,null,l),e=Ui(n,n.pendingProps),e.flags|=2,Sn(n),n.memoizedState=null,e}function r1(e,n,l){var i=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Xe){if(i.mode==="hidden")return e=Ui(n,i),n.lanes=536870912,ds(null,e);if(Gc(n),(e=yt)?(e=tx(e,In),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Or!==null?{id:rr,overflow:ar}:null,retryLane:536870912,hydrationErrors:null},l=Ep(e),l.return=n,n.child=l,Qt=n,yt=null)):e=null,e===null)throw Ir(n);return n.lanes=536870912,null}return Ui(n,i)}var x=e.memoizedState;if(x!==null){var j=x.dehydrated;if(Gc(n),f)if(n.flags&256)n.flags&=-257,n=Pm(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(o(558));else if(It||ol(e,n,l,!1),f=(l&e.childLanes)!==0,It||f){if(i=ht,i!==null&&(j=ma(i,l),j!==0&&j!==x.retryLane))throw x.retryLane=j,ja(e,j),vn(i,e,j),fu;Xi(),n=Pm(e,n,l)}else e=x.treeContext,yt=Hn(j.nextSibling),Qt=n,Xe=!0,Br=null,In=!1,e!==null&&Rp(n,e),n=Ui(n,i),n.flags|=4096;return n}return e=hr(e.child,{mode:i.mode,children:i.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Hi(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(o(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function pu(e,n,l,i,f){return Ca(n),l=qc(e,n,l,i,void 0,f),i=Yc(),e!==null&&!It?(Kc(e,n,f),jr(e,n,f)):(Xe&&i&&Tc(n),n.flags|=1,Jt(e,n,l,f),n.child)}function Fm(e,n,l,i,f,x){return Ca(n),n.updateQueue=null,l=qp(n,i,l,f),Wp(e),i=Yc(),e!==null&&!It?(Kc(e,n,x),jr(e,n,x)):(Xe&&i&&Tc(n),n.flags|=1,Jt(e,n,l,x),n.child)}function Gm(e,n,l,i,f){if(Ca(n),n.stateNode===null){var x=al,j=l.contextType;typeof j=="object"&&j!==null&&(x=Zt(j)),x=new l(i,x),n.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=uu,n.stateNode=x,x._reactInternals=n,x=n.stateNode,x.props=i,x.state=n.memoizedState,x.refs={},Uc(n),j=l.contextType,x.context=typeof j=="object"&&j!==null?Zt(j):al,x.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(cu(n,l,j,i),x.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(j=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),j!==x.state&&uu.enqueueReplaceState(x,x.state,null),ss(n,i,x,f),ls(),x.state=n.memoizedState),typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!0}else if(e===null){x=n.stateNode;var R=n.memoizedProps,P=Ma(l,R);x.props=P;var Z=x.context,se=l.contextType;j=al,typeof se=="object"&&se!==null&&(j=Zt(se));var ue=l.getDerivedStateFromProps;se=typeof ue=="function"||typeof x.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,se||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(R||Z!==j)&&Mm(n,x,i,j),Hr=!1;var ee=n.memoizedState;x.state=ee,ss(n,i,x,f),ls(),Z=n.memoizedState,R||ee!==Z||Hr?(typeof ue=="function"&&(cu(n,l,ue,i),Z=n.memoizedState),(P=Hr||Am(n,l,P,i,ee,Z,j))?(se||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=i,n.memoizedState=Z),x.props=i,x.state=Z,x.context=j,i=P):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!1)}else{x=n.stateNode,Hc(e,n),j=n.memoizedProps,se=Ma(l,j),x.props=se,ue=n.pendingProps,ee=x.context,Z=l.contextType,P=al,typeof Z=="object"&&Z!==null&&(P=Zt(Z)),R=l.getDerivedStateFromProps,(Z=typeof R=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(j!==ue||ee!==P)&&Mm(n,x,i,P),Hr=!1,ee=n.memoizedState,x.state=ee,ss(n,i,x,f),ls();var re=n.memoizedState;j!==ue||ee!==re||Hr||e!==null&&e.dependencies!==null&&ji(e.dependencies)?(typeof R=="function"&&(cu(n,l,R,i),re=n.memoizedState),(se=Hr||Am(n,l,se,i,ee,re,P)||e!==null&&e.dependencies!==null&&ji(e.dependencies))?(Z||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(i,re,P),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(i,re,P)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),n.memoizedProps=i,n.memoizedState=re),x.props=i,x.state=re,x.context=P,i=se):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),i=!1)}return x=i,Hi(e,n),i=(n.flags&128)!==0,x||i?(x=n.stateNode,l=i&&typeof l.getDerivedStateFromError!="function"?null:x.render(),n.flags|=1,e!==null&&i?(n.child=Ra(n,e.child,null,f),n.child=Ra(n,null,l,f)):Jt(e,n,l,f),n.memoizedState=x.state,e=n.child):e=jr(e,n,f),e}function Wm(e,n,l,i){return ka(),n.flags|=256,Jt(e,n,l,i),n.child}var mu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function hu(e){return{baseLanes:e,cachePool:_p()}}function xu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=wn),e}function qm(e,n,l){var i=n.pendingProps,f=!1,x=(n.flags&128)!==0,j;if((j=x)||(j=e!==null&&e.memoizedState===null?!1:(zt.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Xe){if(f?Pr(n):Fr(),(e=yt)?(e=tx(e,In),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Or!==null?{id:rr,overflow:ar}:null,retryLane:536870912,hydrationErrors:null},l=Ep(e),l.return=n,n.child=l,Qt=n,yt=null)):e=null,e===null)throw Ir(n);return Zu(e)?n.lanes=32:n.lanes=536870912,null}var R=i.children;return i=i.fallback,f?(Fr(),f=n.mode,R=$i({mode:"hidden",children:R},f),i=Sa(i,f,l,null),R.return=n,i.return=n,R.sibling=i,n.child=R,i=n.child,i.memoizedState=hu(l),i.childLanes=xu(e,j,l),n.memoizedState=mu,ds(null,i)):(Pr(n),gu(n,R))}var P=e.memoizedState;if(P!==null&&(R=P.dehydrated,R!==null)){if(x)n.flags&256?(Pr(n),n.flags&=-257,n=vu(e,n,l)):n.memoizedState!==null?(Fr(),n.child=e.child,n.flags|=128,n=null):(Fr(),R=i.fallback,f=n.mode,i=$i({mode:"visible",children:i.children},f),R=Sa(R,f,l,null),R.flags|=2,i.return=n,R.return=n,i.sibling=R,n.child=i,Ra(n,e.child,null,l),i=n.child,i.memoizedState=hu(l),i.childLanes=xu(e,j,l),n.memoizedState=mu,n=ds(null,i));else if(Pr(n),Zu(R)){if(j=R.nextSibling&&R.nextSibling.dataset,j)var Z=j.dgst;j=Z,i=Error(o(419)),i.stack="",i.digest=j,Jl({value:i,source:null,stack:null}),n=vu(e,n,l)}else if(It||ol(e,n,l,!1),j=(l&e.childLanes)!==0,It||j){if(j=ht,j!==null&&(i=ma(j,l),i!==0&&i!==P.retryLane))throw P.retryLane=i,ja(e,i),vn(j,e,i),fu;Qu(R)||Xi(),n=vu(e,n,l)}else Qu(R)?(n.flags|=192,n.child=e.child,n=null):(e=P.treeContext,yt=Hn(R.nextSibling),Qt=n,Xe=!0,Br=null,In=!1,e!==null&&Rp(n,e),n=gu(n,i.children),n.flags|=4096);return n}return f?(Fr(),R=i.fallback,f=n.mode,P=e.child,Z=P.sibling,i=hr(P,{mode:"hidden",children:i.children}),i.subtreeFlags=P.subtreeFlags&65011712,Z!==null?R=hr(Z,R):(R=Sa(R,f,l,null),R.flags|=2),R.return=n,i.return=n,i.sibling=R,n.child=i,ds(null,i),i=n.child,R=e.child.memoizedState,R===null?R=hu(l):(f=R.cachePool,f!==null?(P=Ot._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=_p(),R={baseLanes:R.baseLanes|l,cachePool:f}),i.memoizedState=R,i.childLanes=xu(e,j,l),n.memoizedState=mu,ds(e.child,i)):(Pr(n),l=e.child,e=l.sibling,l=hr(l,{mode:"visible",children:i.children}),l.return=n,l.sibling=null,e!==null&&(j=n.deletions,j===null?(n.deletions=[e],n.flags|=16):j.push(e)),n.child=l,n.memoizedState=null,l)}function gu(e,n){return n=$i({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function $i(e,n){return e=bn(22,e,null,n),e.lanes=0,e}function vu(e,n,l){return Ra(n,e.child,null,l),e=gu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Ym(e,n,l){e.lanes|=n;var i=e.alternate;i!==null&&(i.lanes|=n),zc(e.return,n,l)}function yu(e,n,l,i,f,x){var j=e.memoizedState;j===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:i,tail:l,tailMode:f,treeForkCount:x}:(j.isBackwards=n,j.rendering=null,j.renderingStartTime=0,j.last=i,j.tail=l,j.tailMode=f,j.treeForkCount=x)}function Km(e,n,l){var i=n.pendingProps,f=i.revealOrder,x=i.tail;i=i.children;var j=zt.current,R=(j&2)!==0;if(R?(j=j&1|2,n.flags|=128):j&=1,G(zt,j),Jt(e,n,i,l),i=Xe?Zl:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ym(e,l,n);else if(e.tag===19)Ym(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=n.child,f=null;l!==null;)e=l.alternate,e!==null&&Ri(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),yu(n,!1,f,l,x,i);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Ri(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}yu(n,!0,l,null,x,i);break;case"together":yu(n,!1,null,null,void 0,i);break;default:n.memoizedState=null}return n.child}function jr(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),qr|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(ol(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,l=hr(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=hr(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function bu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&ji(e)))}function a1(e,n,l){switch(n.tag){case 3:de(n,n.stateNode.containerInfo),Ur(n,Ot,e.memoizedState.cache),ka();break;case 27:case 5:Re(n);break;case 4:de(n,n.stateNode.containerInfo);break;case 10:Ur(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Gc(n),null;break;case 13:var i=n.memoizedState;if(i!==null)return i.dehydrated!==null?(Pr(n),n.flags|=128,null):(l&n.child.childLanes)!==0?qm(e,n,l):(Pr(n),e=jr(e,n,l),e!==null?e.sibling:null);Pr(n);break;case 19:var f=(e.flags&128)!==0;if(i=(l&n.childLanes)!==0,i||(ol(e,n,l,!1),i=(l&n.childLanes)!==0),f){if(i)return Km(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),G(zt,zt.current),i)break;return null;case 22:return n.lanes=0,$m(e,n,l,n.pendingProps);case 24:Ur(n,Ot,e.memoizedState.cache)}return jr(e,n,l)}function Xm(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)It=!0;else{if(!bu(e,l)&&(n.flags&128)===0)return It=!1,a1(e,n,l);It=(e.flags&131072)!==0}else It=!1,Xe&&(n.flags&1048576)!==0&&Tp(n,Zl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var i=n.pendingProps;if(e=Na(n.elementType),n.type=e,typeof e=="function")Cc(e)?(i=Ma(e,i),n.tag=1,n=Gm(null,n,e,i,l)):(n.tag=0,n=pu(null,n,e,i,l));else{if(e!=null){var f=e.$$typeof;if(f===B){n.tag=11,n=Im(null,n,e,i,l);break e}else if(f===w){n.tag=14,n=Um(null,n,e,i,l);break e}}throw n=J(e)||e,Error(o(306,n,""))}}return n;case 0:return pu(e,n,n.type,n.pendingProps,l);case 1:return i=n.type,f=Ma(i,n.pendingProps),Gm(e,n,i,f,l);case 3:e:{if(de(n,n.stateNode.containerInfo),e===null)throw Error(o(387));i=n.pendingProps;var x=n.memoizedState;f=x.element,Hc(e,n),ss(n,i,null,l);var j=n.memoizedState;if(i=j.cache,Ur(n,Ot,i),i!==x.cache&&Dc(n,[Ot],l,!0),ls(),i=j.element,x.isDehydrated)if(x={element:i,isDehydrated:!1,cache:j.cache},n.updateQueue.baseState=x,n.memoizedState=x,n.flags&256){n=Wm(e,n,i,l);break e}else if(i!==f){f=_n(Error(o(424)),n),Jl(f),n=Wm(e,n,i,l);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(yt=Hn(e.firstChild),Qt=n,Xe=!0,Br=null,In=!0,l=$p(n,null,i,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(ka(),i===f){n=jr(e,n,l);break e}Jt(e,n,i,l)}n=n.child}return n;case 26:return Hi(e,n),e===null?(l=ix(n.type,null,n.pendingProps,null))?n.memoizedState=l:Xe||(l=n.type,e=n.pendingProps,i=ro(oe.current).createElement(l),i[$t]=n,i[ct]=e,en(i,l,e),Yt(i),n.stateNode=i):n.memoizedState=ix(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Re(n),e===null&&Xe&&(i=n.stateNode=ax(n.type,n.pendingProps,oe.current),Qt=n,In=!0,f=yt,Zr(n.type)?(Ju=f,yt=Hn(i.firstChild)):yt=f),Jt(e,n,n.pendingProps.children,l),Hi(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Xe&&((f=i=yt)&&(i=D1(i,n.type,n.pendingProps,In),i!==null?(n.stateNode=i,Qt=n,yt=Hn(i.firstChild),In=!1,f=!0):f=!1),f||Ir(n)),Re(n),f=n.type,x=n.pendingProps,j=e!==null?e.memoizedProps:null,i=x.children,Yu(f,x)?i=null:j!==null&&Yu(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=qc(e,n,Kb,null,null,l),Es._currentValue=f),Hi(e,n),Jt(e,n,i,l),n.child;case 6:return e===null&&Xe&&((e=l=yt)&&(l=_1(l,n.pendingProps,In),l!==null?(n.stateNode=l,Qt=n,yt=null,e=!0):e=!1),e||Ir(n)),null;case 13:return qm(e,n,l);case 4:return de(n,n.stateNode.containerInfo),i=n.pendingProps,e===null?n.child=Ra(n,null,i,l):Jt(e,n,i,l),n.child;case 11:return Im(e,n,n.type,n.pendingProps,l);case 7:return Jt(e,n,n.pendingProps,l),n.child;case 8:return Jt(e,n,n.pendingProps.children,l),n.child;case 12:return Jt(e,n,n.pendingProps.children,l),n.child;case 10:return i=n.pendingProps,Ur(n,n.type,i.value),Jt(e,n,i.children,l),n.child;case 9:return f=n.type._context,i=n.pendingProps.children,Ca(n),f=Zt(f),i=i(f),n.flags|=1,Jt(e,n,i,l),n.child;case 14:return Um(e,n,n.type,n.pendingProps,l);case 15:return Hm(e,n,n.type,n.pendingProps,l);case 19:return Km(e,n,l);case 31:return r1(e,n,l);case 22:return $m(e,n,l,n.pendingProps);case 24:return Ca(n),i=Zt(Ot),e===null?(f=Bc(),f===null&&(f=ht,x=_c(),f.pooledCache=x,x.refCount++,x!==null&&(f.pooledCacheLanes|=l),f=x),n.memoizedState={parent:i,cache:f},Uc(n),Ur(n,Ot,f)):((e.lanes&l)!==0&&(Hc(e,n),ss(n,null,null,l),ls()),f=e.memoizedState,x=n.memoizedState,f.parent!==i?(f={parent:i,cache:i},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Ur(n,Ot,i)):(i=x.cache,Ur(n,Ot,i),i!==f.cache&&Dc(n,[Ot],l,!0))),Jt(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(o(156,n.tag))}function Sr(e){e.flags|=4}function ju(e,n,l,i,f){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(kh())e.flags|=8192;else throw Ta=Ci,Ic}else e.flags&=-16777217}function Qm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!fx(n))if(kh())e.flags|=8192;else throw Ta=Ci,Ic}function Vi(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?qn():536870912,e.lanes|=n,bl|=n)}function fs(e,n){if(!Xe)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var i=null;l!==null;)l.alternate!==null&&(i=l),l=l.sibling;i===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function bt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,i=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags&65011712,i|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags,i|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=i,e.childLanes=l,n}function l1(e,n,l){var i=n.pendingProps;switch(Rc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bt(n),null;case 1:return bt(n),null;case 3:return l=n.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),vr(Ot),je(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(il(n)?Sr(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Mc())),bt(n),null;case 26:var f=n.type,x=n.memoizedState;return e===null?(Sr(n),x!==null?(bt(n),Qm(n,x)):(bt(n),ju(n,f,null,i,l))):x?x!==e.memoizedState?(Sr(n),bt(n),Qm(n,x)):(bt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==i&&Sr(n),bt(n),ju(n,f,e,i,l)),null;case 27:if(_e(n),l=oe.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return bt(n),null}e=te.current,il(n)?Ap(n):(e=ax(f,i,l),n.stateNode=e,Sr(n))}return bt(n),null;case 5:if(_e(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return bt(n),null}if(x=te.current,il(n))Ap(n);else{var j=ro(oe.current);switch(x){case 1:x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":x=j.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof i.is=="string"?j.createElement("select",{is:i.is}):j.createElement("select"),i.multiple?x.multiple=!0:i.size&&(x.size=i.size);break;default:x=typeof i.is=="string"?j.createElement(f,{is:i.is}):j.createElement(f)}}x[$t]=n,x[ct]=i;e:for(j=n.child;j!==null;){if(j.tag===5||j.tag===6)x.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===n)break e;for(;j.sibling===null;){if(j.return===null||j.return===n)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}n.stateNode=x;e:switch(en(x,f,i),f){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Sr(n)}}return bt(n),ju(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(typeof i!="string"&&n.stateNode===null)throw Error(o(166));if(e=oe.current,il(n)){if(e=n.stateNode,l=n.memoizedProps,i=null,f=Qt,f!==null)switch(f.tag){case 27:case 5:i=f.memoizedProps}e[$t]=n,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||qh(e.nodeValue,l)),e||Ir(n,!0)}else e=ro(e).createTextNode(i),e[$t]=n,n.stateNode=e}return bt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(i=il(n),l!==null){if(e===null){if(!i)throw Error(o(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[$t]=n}else ka(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),e=!1}else l=Mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Sn(n),n):(Sn(n),null);if((n.flags&128)!==0)throw Error(o(558))}return bt(n),null;case 13:if(i=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=il(n),i!==null&&i.dehydrated!==null){if(e===null){if(!f)throw Error(o(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));f[$t]=n}else ka(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),f=!1}else f=Mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Sn(n),n):(Sn(n),null)}return Sn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=n.child,f=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(f=i.alternate.memoizedState.cachePool.pool),x=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(x=i.memoizedState.cachePool.pool),x!==f&&(i.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),Vi(n,n.updateQueue),bt(n),null);case 4:return je(),e===null&&Pu(n.stateNode.containerInfo),bt(n),null;case 10:return vr(n.type),bt(n),null;case 19:if(Y(zt),i=n.memoizedState,i===null)return bt(n),null;if(f=(n.flags&128)!==0,x=i.rendering,x===null)if(f)fs(i,!1);else{if(Mt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=Ri(e),x!==null){for(n.flags|=128,fs(i,!1),e=x.updateQueue,n.updateQueue=e,Vi(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Cp(l,e),l=l.sibling;return G(zt,zt.current&1|2),Xe&&xr(n,i.treeForkCount),n.child}e=e.sibling}i.tail!==null&&Ze()>qi&&(n.flags|=128,f=!0,fs(i,!1),n.lanes=4194304)}else{if(!f)if(e=Ri(x),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,Vi(n,e),fs(i,!0),i.tail===null&&i.tailMode==="hidden"&&!x.alternate&&!Xe)return bt(n),null}else 2*Ze()-i.renderingStartTime>qi&&l!==536870912&&(n.flags|=128,f=!0,fs(i,!1),n.lanes=4194304);i.isBackwards?(x.sibling=n.child,n.child=x):(e=i.last,e!==null?e.sibling=x:n.child=x,i.last=x)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Ze(),e.sibling=null,l=zt.current,G(zt,f?l&1|2:l&1),Xe&&xr(n,i.treeForkCount),e):(bt(n),null);case 22:case 23:return Sn(n),Fc(),i=n.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(n.flags|=8192):i&&(n.flags|=8192),i?(l&536870912)!==0&&(n.flags&128)===0&&(bt(n),n.subtreeFlags&6&&(n.flags|=8192)):bt(n),l=n.updateQueue,l!==null&&Vi(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==l&&(n.flags|=2048),e!==null&&Y(Ea),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),vr(Ot),bt(n),null;case 25:return null;case 30:return null}throw Error(o(156,n.tag))}function s1(e,n){switch(Rc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return vr(Ot),je(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return _e(n),null;case 31:if(n.memoizedState!==null){if(Sn(n),n.alternate===null)throw Error(o(340));ka()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Sn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ka()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Y(zt),null;case 4:return je(),null;case 10:return vr(n.type),null;case 22:case 23:return Sn(n),Fc(),e!==null&&Y(Ea),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return vr(Ot),null;case 25:return null;default:return null}}function Zm(e,n){switch(Rc(n),n.tag){case 3:vr(Ot),je();break;case 26:case 27:case 5:_e(n);break;case 4:je();break;case 31:n.memoizedState!==null&&Sn(n);break;case 13:Sn(n);break;case 19:Y(zt);break;case 10:vr(n.type);break;case 22:case 23:Sn(n),Fc(),e!==null&&Y(Ea);break;case 24:vr(Ot)}}function ps(e,n){try{var l=n.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var f=i.next;l=f;do{if((l.tag&e)===e){i=void 0;var x=l.create,j=l.inst;i=x(),j.destroy=i}l=l.next}while(l!==f)}}catch(R){it(n,n.return,R)}}function Gr(e,n,l){try{var i=n.updateQueue,f=i!==null?i.lastEffect:null;if(f!==null){var x=f.next;i=x;do{if((i.tag&e)===e){var j=i.inst,R=j.destroy;if(R!==void 0){j.destroy=void 0,f=n;var P=l,Z=R;try{Z()}catch(se){it(f,P,se)}}}i=i.next}while(i!==x)}}catch(se){it(n,n.return,se)}}function Jm(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Pp(n,l)}catch(i){it(e,e.return,i)}}}function eh(e,n,l){l.props=Ma(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){it(e,n,i)}}function ms(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(f){it(e,n,f)}}function lr(e,n){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(f){it(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){it(e,n,f)}else l.current=null}function th(e){var n=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(f){it(e,e.return,f)}}function Su(e,n,l){try{var i=e.stateNode;T1(i,e.type,l,n),i[ct]=n}catch(f){it(e,e.return,f)}}function nh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zr(e.type)||e.tag===4}function ku(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||nh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function wu(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=pr));else if(i!==4&&(i===27&&Zr(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(wu(e,n,l),e=e.sibling;e!==null;)wu(e,n,l),e=e.sibling}function Pi(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(i!==4&&(i===27&&Zr(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Pi(e,n,l),e=e.sibling;e!==null;)Pi(e,n,l),e=e.sibling}function rh(e){var n=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);en(n,i,l),n[$t]=e,n[ct]=l}catch(x){it(e,e.return,x)}}var kr=!1,Ut=!1,Cu=!1,ah=typeof WeakSet=="function"?WeakSet:Set,Kt=null;function i1(e,n){if(e=e.containerInfo,Wu=uo,e=xp(e),vc(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var f=i.anchorOffset,x=i.focusNode;i=i.focusOffset;try{l.nodeType,x.nodeType}catch{l=null;break e}var j=0,R=-1,P=-1,Z=0,se=0,ue=e,ee=null;t:for(;;){for(var re;ue!==l||f!==0&&ue.nodeType!==3||(R=j+f),ue!==x||i!==0&&ue.nodeType!==3||(P=j+i),ue.nodeType===3&&(j+=ue.nodeValue.length),(re=ue.firstChild)!==null;)ee=ue,ue=re;for(;;){if(ue===e)break t;if(ee===l&&++Z===f&&(R=j),ee===x&&++se===i&&(P=j),(re=ue.nextSibling)!==null)break;ue=ee,ee=ue.parentNode}ue=re}l=R===-1||P===-1?null:{start:R,end:P}}else l=null}l=l||{start:0,end:0}}else l=null;for(qu={focusedElem:e,selectionRange:l},uo=!1,Kt=n;Kt!==null;)if(n=Kt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Kt=e;else for(;Kt!==null;){switch(n=Kt,x=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&x!==null){e=void 0,l=n,f=x.memoizedProps,x=x.memoizedState,i=l.stateNode;try{var we=Ma(l.type,f);e=i.getSnapshotBeforeUpdate(we,x),i.__reactInternalSnapshotBeforeUpdate=e}catch(Le){it(l,l.return,Le)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Xu(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Xu(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=n.sibling,e!==null){e.return=n.return,Kt=e;break}Kt=n.return}}function lh(e,n,l){var i=l.flags;switch(l.tag){case 0:case 11:case 15:Cr(e,l),i&4&&ps(5,l);break;case 1:if(Cr(e,l),i&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){it(l,l.return,j)}else{var f=Ma(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){it(l,l.return,j)}}i&64&&Jm(l),i&512&&ms(l,l.return);break;case 3:if(Cr(e,l),i&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Pp(e,n)}catch(j){it(l,l.return,j)}}break;case 27:n===null&&i&4&&rh(l);case 26:case 5:Cr(e,l),n===null&&i&4&&th(l),i&512&&ms(l,l.return);break;case 12:Cr(e,l);break;case 31:Cr(e,l),i&4&&oh(e,l);break;case 13:Cr(e,l),i&4&&ch(e,l),i&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=x1.bind(null,l),O1(e,l))));break;case 22:if(i=l.memoizedState!==null||kr,!i){n=n!==null&&n.memoizedState!==null||Ut,f=kr;var x=Ut;kr=i,(Ut=n)&&!x?Er(e,l,(l.subtreeFlags&8772)!==0):Cr(e,l),kr=f,Ut=x}break;case 30:break;default:Cr(e,l)}}function sh(e){var n=e.alternate;n!==null&&(e.alternate=null,sh(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&tc(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var kt=null,mn=!1;function wr(e,n,l){for(l=l.child;l!==null;)ih(e,n,l),l=l.sibling}function ih(e,n,l){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(Mn,l)}catch{}switch(l.tag){case 26:Ut||lr(l,n),wr(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Ut||lr(l,n);var i=kt,f=mn;Zr(l.type)&&(kt=l.stateNode,mn=!1),wr(e,n,l),ks(l.stateNode),kt=i,mn=f;break;case 5:Ut||lr(l,n);case 6:if(i=kt,f=mn,kt=null,wr(e,n,l),kt=i,mn=f,kt!==null)if(mn)try{(kt.nodeType===9?kt.body:kt.nodeName==="HTML"?kt.ownerDocument.body:kt).removeChild(l.stateNode)}catch(x){it(l,n,x)}else try{kt.removeChild(l.stateNode)}catch(x){it(l,n,x)}break;case 18:kt!==null&&(mn?(e=kt,Jh(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),Tl(e)):Jh(kt,l.stateNode));break;case 4:i=kt,f=mn,kt=l.stateNode.containerInfo,mn=!0,wr(e,n,l),kt=i,mn=f;break;case 0:case 11:case 14:case 15:Gr(2,l,n),Ut||Gr(4,l,n),wr(e,n,l);break;case 1:Ut||(lr(l,n),i=l.stateNode,typeof i.componentWillUnmount=="function"&&eh(l,n,i)),wr(e,n,l);break;case 21:wr(e,n,l);break;case 22:Ut=(i=Ut)||l.memoizedState!==null,wr(e,n,l),Ut=i;break;default:wr(e,n,l)}}function oh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Tl(e)}catch(l){it(n,n.return,l)}}}function ch(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Tl(e)}catch(l){it(n,n.return,l)}}function o1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new ah),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new ah),n;default:throw Error(o(435,e.tag))}}function Fi(e,n){var l=o1(e);n.forEach(function(i){if(!l.has(i)){l.add(i);var f=g1.bind(null,e,i);i.then(f,f)}})}function hn(e,n){var l=n.deletions;if(l!==null)for(var i=0;i<l.length;i++){var f=l[i],x=e,j=n,R=j;e:for(;R!==null;){switch(R.tag){case 27:if(Zr(R.type)){kt=R.stateNode,mn=!1;break e}break;case 5:kt=R.stateNode,mn=!1;break e;case 3:case 4:kt=R.stateNode.containerInfo,mn=!0;break e}R=R.return}if(kt===null)throw Error(o(160));ih(x,j,f),kt=null,mn=!1,x=f.alternate,x!==null&&(x.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)uh(n,e),n=n.sibling}var Kn=null;function uh(e,n){var l=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hn(n,e),xn(e),i&4&&(Gr(3,e,e.return),ps(3,e),Gr(5,e,e.return));break;case 1:hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),i&64&&kr&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?i:l.concat(i))));break;case 26:var f=Kn;if(hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),i&4){var x=l!==null?l.memoizedState:null;if(i=e.memoizedState,l===null)if(i===null)if(e.stateNode===null){e:{i=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(i){case"title":x=f.getElementsByTagName("title")[0],(!x||x[$l]||x[$t]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=f.createElement(i),f.head.insertBefore(x,f.querySelector("head > title"))),en(x,i,l),x[$t]=e,Yt(x),i=x;break e;case"link":var j=ux("link","href",f).get(i+(l.href||""));if(j){for(var R=0;R<j.length;R++)if(x=j[R],x.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&x.getAttribute("rel")===(l.rel==null?null:l.rel)&&x.getAttribute("title")===(l.title==null?null:l.title)&&x.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){j.splice(R,1);break t}}x=f.createElement(i),en(x,i,l),f.head.appendChild(x);break;case"meta":if(j=ux("meta","content",f).get(i+(l.content||""))){for(R=0;R<j.length;R++)if(x=j[R],x.getAttribute("content")===(l.content==null?null:""+l.content)&&x.getAttribute("name")===(l.name==null?null:l.name)&&x.getAttribute("property")===(l.property==null?null:l.property)&&x.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&x.getAttribute("charset")===(l.charSet==null?null:l.charSet)){j.splice(R,1);break t}}x=f.createElement(i),en(x,i,l),f.head.appendChild(x);break;default:throw Error(o(468,i))}x[$t]=e,Yt(x),i=x}e.stateNode=i}else dx(f,e.type,e.stateNode);else e.stateNode=cx(f,i,e.memoizedProps);else x!==i?(x===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):x.count--,i===null?dx(f,e.type,e.stateNode):cx(f,i,e.memoizedProps)):i===null&&e.stateNode!==null&&Su(e,e.memoizedProps,l.memoizedProps)}break;case 27:hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),l!==null&&i&4&&Su(e,e.memoizedProps,l.memoizedProps);break;case 5:if(hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),e.flags&32){f=e.stateNode;try{Qa(f,"")}catch(we){it(e,e.return,we)}}i&4&&e.stateNode!=null&&(f=e.memoizedProps,Su(e,f,l!==null?l.memoizedProps:f)),i&1024&&(Cu=!0);break;case 6:if(hn(n,e),xn(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,l=e.stateNode;try{l.nodeValue=i}catch(we){it(e,e.return,we)}}break;case 3:if(so=null,f=Kn,Kn=ao(n.containerInfo),hn(n,e),Kn=f,xn(e),i&4&&l!==null&&l.memoizedState.isDehydrated)try{Tl(n.containerInfo)}catch(we){it(e,e.return,we)}Cu&&(Cu=!1,dh(e));break;case 4:i=Kn,Kn=ao(e.stateNode.containerInfo),hn(n,e),xn(e),Kn=i;break;case 12:hn(n,e),xn(e);break;case 31:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 13:hn(n,e),xn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Wi=Ze()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 22:f=e.memoizedState!==null;var P=l!==null&&l.memoizedState!==null,Z=kr,se=Ut;if(kr=Z||f,Ut=se||P,hn(n,e),Ut=se,kr=Z,xn(e),i&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||P||kr||Ut||La(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){P=l=n;try{if(x=P.stateNode,f)j=x.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{R=P.stateNode;var ue=P.memoizedProps.style,ee=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;R.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(we){it(P,P.return,we)}}}else if(n.tag===6){if(l===null){P=n;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(we){it(P,P.return,we)}}}else if(n.tag===18){if(l===null){P=n;try{var re=P.stateNode;f?ex(re,!0):ex(P.stateNode,!1)}catch(we){it(P,P.return,we)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}i&4&&(i=e.updateQueue,i!==null&&(l=i.retryQueue,l!==null&&(i.retryQueue=null,Fi(e,l))));break;case 19:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 30:break;case 21:break;default:hn(n,e),xn(e)}}function xn(e){var n=e.flags;if(n&2){try{for(var l,i=e.return;i!==null;){if(nh(i)){l=i;break}i=i.return}if(l==null)throw Error(o(160));switch(l.tag){case 27:var f=l.stateNode,x=ku(e);Pi(e,x,f);break;case 5:var j=l.stateNode;l.flags&32&&(Qa(j,""),l.flags&=-33);var R=ku(e);Pi(e,R,j);break;case 3:case 4:var P=l.stateNode.containerInfo,Z=ku(e);wu(e,Z,P);break;default:throw Error(o(161))}}catch(se){it(e,e.return,se)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function dh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;dh(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Cr(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)lh(e,n.alternate,n),n=n.sibling}function La(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Gr(4,n,n.return),La(n);break;case 1:lr(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&eh(n,n.return,l),La(n);break;case 27:ks(n.stateNode);case 26:case 5:lr(n,n.return),La(n);break;case 22:n.memoizedState===null&&La(n);break;case 30:La(n);break;default:La(n)}e=e.sibling}}function Er(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var i=n.alternate,f=e,x=n,j=x.flags;switch(x.tag){case 0:case 11:case 15:Er(f,x,l),ps(4,x);break;case 1:if(Er(f,x,l),i=x,f=i.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(Z){it(i,i.return,Z)}if(i=x,f=i.updateQueue,f!==null){var R=i.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)Vp(P[f],R)}catch(Z){it(i,i.return,Z)}}l&&j&64&&Jm(x),ms(x,x.return);break;case 27:rh(x);case 26:case 5:Er(f,x,l),l&&i===null&&j&4&&th(x),ms(x,x.return);break;case 12:Er(f,x,l);break;case 31:Er(f,x,l),l&&j&4&&oh(f,x);break;case 13:Er(f,x,l),l&&j&4&&ch(f,x);break;case 22:x.memoizedState===null&&Er(f,x,l),ms(x,x.return);break;case 30:break;default:Er(f,x,l)}n=n.sibling}}function Eu(e,n){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&es(l))}function Nu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&es(e))}function Xn(e,n,l,i){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)fh(e,n,l,i),n=n.sibling}function fh(e,n,l,i){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Xn(e,n,l,i),f&2048&&ps(9,n);break;case 1:Xn(e,n,l,i);break;case 3:Xn(e,n,l,i),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&es(e)));break;case 12:if(f&2048){Xn(e,n,l,i),e=n.stateNode;try{var x=n.memoizedProps,j=x.id,R=x.onPostCommit;typeof R=="function"&&R(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){it(n,n.return,P)}}else Xn(e,n,l,i);break;case 31:Xn(e,n,l,i);break;case 13:Xn(e,n,l,i);break;case 23:break;case 22:x=n.stateNode,j=n.alternate,n.memoizedState!==null?x._visibility&2?Xn(e,n,l,i):hs(e,n):x._visibility&2?Xn(e,n,l,i):(x._visibility|=2,gl(e,n,l,i,(n.subtreeFlags&10256)!==0||!1)),f&2048&&Eu(j,n);break;case 24:Xn(e,n,l,i),f&2048&&Nu(n.alternate,n);break;default:Xn(e,n,l,i)}}function gl(e,n,l,i,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var x=e,j=n,R=l,P=i,Z=j.flags;switch(j.tag){case 0:case 11:case 15:gl(x,j,R,P,f),ps(8,j);break;case 23:break;case 22:var se=j.stateNode;j.memoizedState!==null?se._visibility&2?gl(x,j,R,P,f):hs(x,j):(se._visibility|=2,gl(x,j,R,P,f)),f&&Z&2048&&Eu(j.alternate,j);break;case 24:gl(x,j,R,P,f),f&&Z&2048&&Nu(j.alternate,j);break;default:gl(x,j,R,P,f)}n=n.sibling}}function hs(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,i=n,f=i.flags;switch(i.tag){case 22:hs(l,i),f&2048&&Eu(i.alternate,i);break;case 24:hs(l,i),f&2048&&Nu(i.alternate,i);break;default:hs(l,i)}n=n.sibling}}var xs=8192;function vl(e,n,l){if(e.subtreeFlags&xs)for(e=e.child;e!==null;)ph(e,n,l),e=e.sibling}function ph(e,n,l){switch(e.tag){case 26:vl(e,n,l),e.flags&xs&&e.memoizedState!==null&&Y1(l,Kn,e.memoizedState,e.memoizedProps);break;case 5:vl(e,n,l);break;case 3:case 4:var i=Kn;Kn=ao(e.stateNode.containerInfo),vl(e,n,l),Kn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=xs,xs=16777216,vl(e,n,l),xs=i):vl(e,n,l));break;default:vl(e,n,l)}}function mh(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function gs(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];Kt=i,xh(i,e)}mh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)hh(e),e=e.sibling}function hh(e){switch(e.tag){case 0:case 11:case 15:gs(e),e.flags&2048&&Gr(9,e,e.return);break;case 3:gs(e);break;case 12:gs(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Gi(e)):gs(e);break;default:gs(e)}}function Gi(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];Kt=i,xh(i,e)}mh(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Gr(8,n,n.return),Gi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Gi(n));break;default:Gi(n)}e=e.sibling}}function xh(e,n){for(;Kt!==null;){var l=Kt;switch(l.tag){case 0:case 11:case 15:Gr(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var i=l.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:es(l.memoizedState.cache)}if(i=l.child,i!==null)i.return=l,Kt=i;else e:for(l=e;Kt!==null;){i=Kt;var f=i.sibling,x=i.return;if(sh(i),i===l){Kt=null;break e}if(f!==null){f.return=x,Kt=f;break e}Kt=x}}}var c1={getCacheForType:function(e){var n=Zt(Ot),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return Zt(Ot).controller.signal}},u1=typeof WeakMap=="function"?WeakMap:Map,rt=0,ht=null,We=null,Ye=0,st=0,kn=null,Wr=!1,yl=!1,Tu=!1,Nr=0,Mt=0,qr=0,za=0,Ru=0,wn=0,bl=0,vs=null,gn=null,Au=!1,Wi=0,gh=0,qi=1/0,Yi=null,Yr=null,Vt=0,Kr=null,jl=null,Tr=0,Mu=0,Lu=null,vh=null,ys=0,zu=null;function Cn(){return(rt&2)!==0&&Ye!==0?Ye&-Ye:L.T!==null?Uu():ot()}function yh(){if(wn===0)if((Ye&536870912)===0||Xe){var e=qt;qt<<=1,(qt&3932160)===0&&(qt=262144),wn=e}else wn=536870912;return e=jn.current,e!==null&&(e.flags|=32),wn}function vn(e,n,l){(e===ht&&(st===2||st===9)||e.cancelPendingCommit!==null)&&(Sl(e,0),Xr(e,Ye,wn,!1)),fa(e,l),((rt&2)===0||e!==ht)&&(e===ht&&((rt&2)===0&&(za|=l),Mt===4&&Xr(e,Ye,wn,!1)),sr(e))}function bh(e,n,l){if((rt&6)!==0)throw Error(o(327));var i=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Me(e,n),f=i?p1(e,n):_u(e,n,!0),x=i;do{if(f===0){yl&&!i&&Xr(e,n,0,!1);break}else{if(l=e.current.alternate,x&&!d1(l)){f=_u(e,n,!1),x=!1;continue}if(f===2){if(x=n,e.errorRecoveryDisabledLanes&x)var j=0;else j=e.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){n=j;e:{var R=e;f=vs;var P=R.current.memoizedState.isDehydrated;if(P&&(Sl(R,j).flags|=256),j=_u(R,j,!1),j!==2){if(Tu&&!P){R.errorRecoveryDisabledLanes|=x,za|=x,f=4;break e}x=gn,gn=f,x!==null&&(gn===null?gn=x:gn.push.apply(gn,x))}f=j}if(x=!1,f!==2)continue}}if(f===1){Sl(e,0),Xr(e,n,0,!0);break}e:{switch(i=e,x=f,x){case 0:case 1:throw Error(o(345));case 4:if((n&4194048)!==n)break;case 6:Xr(i,n,wn,!Wr);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((n&62914560)===n&&(f=Wi+300-Ze(),10<f)){if(Xr(i,n,wn,!Wr),Se(i,0,!0)!==0)break e;Tr=n,i.timeoutHandle=Qh(jh.bind(null,i,l,gn,Yi,Au,n,wn,za,bl,Wr,x,"Throttled",-0,0),f);break e}jh(i,l,gn,Yi,Au,n,wn,za,bl,Wr,x,null,-0,0)}}break}while(!0);sr(e)}function jh(e,n,l,i,f,x,j,R,P,Z,se,ue,ee,re){if(e.timeoutHandle=-1,ue=n.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pr},ph(n,x,ue);var we=(x&62914560)===x?Wi-Ze():(x&4194048)===x?gh-Ze():0;if(we=K1(ue,we),we!==null){Tr=x,e.cancelPendingCommit=we(Rh.bind(null,e,n,x,l,i,f,j,R,P,se,ue,null,ee,re)),Xr(e,x,j,!Z);return}}Rh(e,n,x,l,i,f,j,R,P)}function d1(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var i=0;i<l.length;i++){var f=l[i],x=f.getSnapshot;f=f.value;try{if(!yn(x(),f))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Xr(e,n,l,i){n&=~Ru,n&=~za,e.suspendedLanes|=n,e.pingedLanes&=~n,i&&(e.warmLanes|=n),i=e.expirationTimes;for(var f=n;0<f;){var x=31-gt(f),j=1<<x;i[x]=-1,f&=~j}l!==0&&tr(e,l,n)}function Ki(){return(rt&6)===0?(bs(0),!1):!0}function Du(){if(We!==null){if(st===0)var e=We.return;else e=We,gr=wa=null,Xc(e),fl=null,ns=0,e=We;for(;e!==null;)Zm(e.alternate,e),e=e.return;We=null}}function Sl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,M1(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Tr=0,Du(),ht=e,We=l=hr(e.current,null),Ye=n,st=0,kn=null,Wr=!1,yl=Me(e,n),Tu=!1,bl=wn=Ru=za=qr=Mt=0,gn=vs=null,Au=!1,(n&8)!==0&&(n|=n&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=n;0<i;){var f=31-gt(i),x=1<<f;n|=e[f],i&=~x}return Nr=n,xi(),l}function Sh(e,n){$e=null,L.H=us,n===dl||n===wi?(n=Ip(),st=3):n===Ic?(n=Ip(),st=4):st=n===fu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,We===null&&(Mt=1,Ii(e,_n(n,e.current)))}function kh(){var e=jn.current;return e===null?!0:(Ye&4194048)===Ye?Un===null:(Ye&62914560)===Ye||(Ye&536870912)!==0?e===Un:!1}function wh(){var e=L.H;return L.H=us,e===null?us:e}function Ch(){var e=L.A;return L.A=c1,e}function Xi(){Mt=4,Wr||(Ye&4194048)!==Ye&&jn.current!==null||(yl=!0),(qr&134217727)===0&&(za&134217727)===0||ht===null||Xr(ht,Ye,wn,!1)}function _u(e,n,l){var i=rt;rt|=2;var f=wh(),x=Ch();(ht!==e||Ye!==n)&&(Yi=null,Sl(e,n)),n=!1;var j=Mt;e:do try{if(st!==0&&We!==null){var R=We,P=kn;switch(st){case 8:Du(),j=6;break e;case 3:case 2:case 9:case 6:jn.current===null&&(n=!0);var Z=st;if(st=0,kn=null,kl(e,R,P,Z),l&&yl){j=0;break e}break;default:Z=st,st=0,kn=null,kl(e,R,P,Z)}}f1(),j=Mt;break}catch(se){Sh(e,se)}while(!0);return n&&e.shellSuspendCounter++,gr=wa=null,rt=i,L.H=f,L.A=x,We===null&&(ht=null,Ye=0,xi()),j}function f1(){for(;We!==null;)Eh(We)}function p1(e,n){var l=rt;rt|=2;var i=wh(),f=Ch();ht!==e||Ye!==n?(Yi=null,qi=Ze()+500,Sl(e,n)):yl=Me(e,n);e:do try{if(st!==0&&We!==null){n=We;var x=kn;t:switch(st){case 1:st=0,kn=null,kl(e,n,x,1);break;case 2:case 9:if(Op(x)){st=0,kn=null,Nh(n);break}n=function(){st!==2&&st!==9||ht!==e||(st=7),sr(e)},x.then(n,n);break e;case 3:st=7;break e;case 4:st=5;break e;case 7:Op(x)?(st=0,kn=null,Nh(n)):(st=0,kn=null,kl(e,n,x,7));break;case 5:var j=null;switch(We.tag){case 26:j=We.memoizedState;case 5:case 27:var R=We;if(j?fx(j):R.stateNode.complete){st=0,kn=null;var P=R.sibling;if(P!==null)We=P;else{var Z=R.return;Z!==null?(We=Z,Qi(Z)):We=null}break t}}st=0,kn=null,kl(e,n,x,5);break;case 6:st=0,kn=null,kl(e,n,x,6);break;case 8:Du(),Mt=6;break e;default:throw Error(o(462))}}m1();break}catch(se){Sh(e,se)}while(!0);return gr=wa=null,L.H=i,L.A=f,rt=l,We!==null?0:(ht=null,Ye=0,xi(),Mt)}function m1(){for(;We!==null&&!_t();)Eh(We)}function Eh(e){var n=Xm(e.alternate,e,Nr);e.memoizedProps=e.pendingProps,n===null?Qi(e):We=n}function Nh(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=Fm(l,n,n.pendingProps,n.type,void 0,Ye);break;case 11:n=Fm(l,n,n.pendingProps,n.type.render,n.ref,Ye);break;case 5:Xc(n);default:Zm(l,n),n=We=Cp(n,Nr),n=Xm(l,n,Nr)}e.memoizedProps=e.pendingProps,n===null?Qi(e):We=n}function kl(e,n,l,i){gr=wa=null,Xc(n),fl=null,ns=0;var f=n.return;try{if(n1(e,f,n,l,Ye)){Mt=1,Ii(e,_n(l,e.current)),We=null;return}}catch(x){if(f!==null)throw We=f,x;Mt=1,Ii(e,_n(l,e.current)),We=null;return}n.flags&32768?(Xe||i===1?e=!0:yl||(Ye&536870912)!==0?e=!1:(Wr=e=!0,(i===2||i===9||i===3||i===6)&&(i=jn.current,i!==null&&i.tag===13&&(i.flags|=16384))),Th(n,e)):Qi(n)}function Qi(e){var n=e;do{if((n.flags&32768)!==0){Th(n,Wr);return}e=n.return;var l=l1(n.alternate,n,Nr);if(l!==null){We=l;return}if(n=n.sibling,n!==null){We=n;return}We=n=e}while(n!==null);Mt===0&&(Mt=5)}function Th(e,n){do{var l=s1(e.alternate,e);if(l!==null){l.flags&=32767,We=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){We=e;return}We=e=l}while(e!==null);Mt=6,We=null}function Rh(e,n,l,i,f,x,j,R,P){e.cancelPendingCommit=null;do Zi();while(Vt!==0);if((rt&6)!==0)throw Error(o(327));if(n!==null){if(n===e.current)throw Error(o(177));if(x=n.lanes|n.childLanes,x|=kc,Hl(e,l,x,j,R,P),e===ht&&(We=ht=null,Ye=0),jl=n,Kr=e,Tr=l,Mu=x,Lu=f,vh=i,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,v1(Et,function(){return Dh(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||i){i=L.T,L.T=null,f=_.p,_.p=2,j=rt,rt|=4;try{i1(e,n,l)}finally{rt=j,_.p=f,L.T=i}}Vt=1,Ah(),Mh(),Lh()}}function Ah(){if(Vt===1){Vt=0;var e=Kr,n=jl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=rt;rt|=4;try{uh(n,e);var x=qu,j=xp(e.containerInfo),R=x.focusedElem,P=x.selectionRange;if(j!==R&&R&&R.ownerDocument&&hp(R.ownerDocument.documentElement,R)){if(P!==null&&vc(R)){var Z=P.start,se=P.end;if(se===void 0&&(se=Z),"selectionStart"in R)R.selectionStart=Z,R.selectionEnd=Math.min(se,R.value.length);else{var ue=R.ownerDocument||document,ee=ue&&ue.defaultView||window;if(ee.getSelection){var re=ee.getSelection(),we=R.textContent.length,Le=Math.min(P.start,we),ft=P.end===void 0?Le:Math.min(P.end,we);!re.extend&&Le>ft&&(j=ft,ft=Le,Le=j);var K=mp(R,Le),W=mp(R,ft);if(K&&W&&(re.rangeCount!==1||re.anchorNode!==K.node||re.anchorOffset!==K.offset||re.focusNode!==W.node||re.focusOffset!==W.offset)){var Q=ue.createRange();Q.setStart(K.node,K.offset),re.removeAllRanges(),Le>ft?(re.addRange(Q),re.extend(W.node,W.offset)):(Q.setEnd(W.node,W.offset),re.addRange(Q))}}}}for(ue=[],re=R;re=re.parentNode;)re.nodeType===1&&ue.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<ue.length;R++){var ce=ue[R];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}uo=!!Wu,qu=Wu=null}finally{rt=f,_.p=i,L.T=l}}e.current=n,Vt=2}}function Mh(){if(Vt===2){Vt=0;var e=Kr,n=jl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=rt;rt|=4;try{lh(e,n.alternate,n)}finally{rt=f,_.p=i,L.T=l}}Vt=3}}function Lh(){if(Vt===4||Vt===3){Vt=0,Tt();var e=Kr,n=jl,l=Tr,i=vh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Vt=5:(Vt=0,jl=Kr=null,zh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Yr=null),Dr(l),n=n.stateNode,Lt&&typeof Lt.onCommitFiberRoot=="function")try{Lt.onCommitFiberRoot(Mn,n,void 0,(n.current.flags&128)===128)}catch{}if(i!==null){n=L.T,f=_.p,_.p=2,L.T=null;try{for(var x=e.onRecoverableError,j=0;j<i.length;j++){var R=i[j];x(R.value,{componentStack:R.stack})}}finally{L.T=n,_.p=f}}(Tr&3)!==0&&Zi(),sr(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===zu?ys++:(ys=0,zu=e):ys=0,bs(0)}}function zh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,es(n)))}function Zi(){return Ah(),Mh(),Lh(),Dh()}function Dh(){if(Vt!==5)return!1;var e=Kr,n=Mu;Mu=0;var l=Dr(Tr),i=L.T,f=_.p;try{_.p=32>l?32:l,L.T=null,l=Lu,Lu=null;var x=Kr,j=Tr;if(Vt=0,jl=Kr=null,Tr=0,(rt&6)!==0)throw Error(o(331));var R=rt;if(rt|=4,hh(x.current),fh(x,x.current,j,l),rt=R,bs(0,!1),Lt&&typeof Lt.onPostCommitFiberRoot=="function")try{Lt.onPostCommitFiberRoot(Mn,x)}catch{}return!0}finally{_.p=f,L.T=i,zh(e,n)}}function _h(e,n,l){n=_n(l,n),n=du(e.stateNode,n,2),e=Vr(e,n,2),e!==null&&(fa(e,2),sr(e))}function it(e,n,l){if(e.tag===3)_h(e,e,l);else for(;n!==null;){if(n.tag===3){_h(n,e,l);break}else if(n.tag===1){var i=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Yr===null||!Yr.has(i))){e=_n(l,e),l=Om(2),i=Vr(n,l,2),i!==null&&(Bm(l,i,n,e),fa(i,2),sr(i));break}}n=n.return}}function Ou(e,n,l){var i=e.pingCache;if(i===null){i=e.pingCache=new u1;var f=new Set;i.set(n,f)}else f=i.get(n),f===void 0&&(f=new Set,i.set(n,f));f.has(l)||(Tu=!0,f.add(l),e=h1.bind(null,e,n,l),n.then(e,e))}function h1(e,n,l){var i=e.pingCache;i!==null&&i.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,ht===e&&(Ye&l)===l&&(Mt===4||Mt===3&&(Ye&62914560)===Ye&&300>Ze()-Wi?(rt&2)===0&&Sl(e,0):Ru|=l,bl===Ye&&(bl=0)),sr(e)}function Oh(e,n){n===0&&(n=qn()),e=ja(e,n),e!==null&&(fa(e,n),sr(e))}function x1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Oh(e,l)}function g1(e,n){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(n),Oh(e,l)}function v1(e,n){return Nt(e,n)}var Ji=null,wl=null,Bu=!1,eo=!1,Iu=!1,Qr=0;function sr(e){e!==wl&&e.next===null&&(wl===null?Ji=wl=e:wl=wl.next=e),eo=!0,Bu||(Bu=!0,b1())}function bs(e,n){if(!Iu&&eo){Iu=!0;do for(var l=!1,i=Ji;i!==null;){if(e!==0){var f=i.pendingLanes;if(f===0)var x=0;else{var j=i.suspendedLanes,R=i.pingedLanes;x=(1<<31-gt(42|e)+1)-1,x&=f&~(j&~R),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(l=!0,Hh(i,x))}else x=Ye,x=Se(i,i===ht?x:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(x&3)===0||Me(i,x)||(l=!0,Hh(i,x));i=i.next}while(l);Iu=!1}}function y1(){Bh()}function Bh(){eo=Bu=!1;var e=0;Qr!==0&&A1()&&(e=Qr);for(var n=Ze(),l=null,i=Ji;i!==null;){var f=i.next,x=Ih(i,n);x===0?(i.next=null,l===null?Ji=f:l.next=f,f===null&&(wl=l)):(l=i,(e!==0||(x&3)!==0)&&(eo=!0)),i=f}Vt!==0&&Vt!==5||bs(e),Qr!==0&&(Qr=0)}function Ih(e,n){for(var l=e.suspendedLanes,i=e.pingedLanes,f=e.expirationTimes,x=e.pendingLanes&-62914561;0<x;){var j=31-gt(x),R=1<<j,P=f[j];P===-1?((R&l)===0||(R&i)!==0)&&(f[j]=Fa(R,n)):P<=n&&(e.expiredLanes|=R),x&=~R}if(n=ht,l=Ye,l=Se(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,l===0||e===n&&(st===2||st===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&xt(i),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Me(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(i!==null&&xt(i),Dr(l)){case 2:case 8:l=mt;break;case 32:l=Et;break;case 268435456:l=fn;break;default:l=Et}return i=Uh.bind(null,e),l=Nt(l,i),e.callbackPriority=n,e.callbackNode=l,n}return i!==null&&i!==null&&xt(i),e.callbackPriority=2,e.callbackNode=null,2}function Uh(e,n){if(Vt!==0&&Vt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Zi()&&e.callbackNode!==l)return null;var i=Ye;return i=Se(e,e===ht?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(bh(e,i,n),Ih(e,Ze()),e.callbackNode!=null&&e.callbackNode===l?Uh.bind(null,e):null)}function Hh(e,n){if(Zi())return null;bh(e,n,!0)}function b1(){L1(function(){(rt&6)!==0?Nt(ye,y1):Bh()})}function Uu(){if(Qr===0){var e=cl;e===0&&(e=Rt,Rt<<=1,(Rt&261888)===0&&(Rt=256)),Qr=e}return Qr}function $h(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:oi(""+e)}function Vh(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 j1(e,n,l,i,f){if(n==="submit"&&l&&l.stateNode===f){var x=$h((f[ct]||null).action),j=i.submitter;j&&(n=(n=j[ct]||null)?$h(n.formAction):j.getAttribute("formAction"),n!==null&&(x=n,j=null));var R=new fi("action","action",null,i,f);e.push({event:R,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Qr!==0){var P=j?Vh(f,j):new FormData(f);lu(l,{pending:!0,data:P,method:f.method,action:x},null,P)}}else typeof x=="function"&&(R.preventDefault(),P=j?Vh(f,j):new FormData(f),lu(l,{pending:!0,data:P,method:f.method,action:x},x,P))},currentTarget:f}]})}}for(var Hu=0;Hu<Sc.length;Hu++){var $u=Sc[Hu],S1=$u.toLowerCase(),k1=$u[0].toUpperCase()+$u.slice(1);Yn(S1,"on"+k1)}Yn(yp,"onAnimationEnd"),Yn(bp,"onAnimationIteration"),Yn(jp,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(Ub,"onTransitionRun"),Yn(Hb,"onTransitionStart"),Yn($b,"onTransitionCancel"),Yn(Sp,"onTransitionEnd"),Ka("onMouseEnter",["mouseout","mouseover"]),Ka("onMouseLeave",["mouseout","mouseover"]),Ka("onPointerEnter",["pointerout","pointerover"]),Ka("onPointerLeave",["pointerout","pointerover"]),ga("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ga("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ga("onBeforeInput",["compositionend","keypress","textInput","paste"]),ga("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var js="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),w1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(js));function Ph(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var i=e[l],f=i.event;i=i.listeners;e:{var x=void 0;if(n)for(var j=i.length-1;0<=j;j--){var R=i[j],P=R.instance,Z=R.currentTarget;if(R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(se){hi(se)}f.currentTarget=null,x=P}else for(j=0;j<i.length;j++){if(R=i[j],P=R.instance,Z=R.currentTarget,R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(se){hi(se)}f.currentTarget=null,x=P}}}}function qe(e,n){var l=n[nr];l===void 0&&(l=n[nr]=new Set);var i=e+"__bubble";l.has(i)||(Fh(n,e,2,!1),l.add(i))}function Vu(e,n,l){var i=0;n&&(i|=4),Fh(l,e,i,n)}var to="_reactListening"+Math.random().toString(36).slice(2);function Pu(e){if(!e[to]){e[to]=!0,Bf.forEach(function(l){l!=="selectionchange"&&(w1.has(l)||Vu(l,!1,e),Vu(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[to]||(n[to]=!0,Vu("selectionchange",!1,n))}}function Fh(e,n,l,i){switch(yx(n)){case 2:var f=Z1;break;case 8:f=J1;break;default:f=ad}l=f.bind(null,n,l,e),f=void 0,!cc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),i?f!==void 0?e.addEventListener(n,l,{capture:!0,passive:f}):e.addEventListener(n,l,!0):f!==void 0?e.addEventListener(n,l,{passive:f}):e.addEventListener(n,l,!1)}function Fu(e,n,l,i,f){var x=i;if((n&1)===0&&(n&2)===0&&i!==null)e:for(;;){if(i===null)return;var j=i.tag;if(j===3||j===4){var R=i.stateNode.containerInfo;if(R===f)break;if(j===4)for(j=i.return;j!==null;){var P=j.tag;if((P===3||P===4)&&j.stateNode.containerInfo===f)return;j=j.return}for(;R!==null;){if(j=Wa(R),j===null)return;if(P=j.tag,P===5||P===6||P===26||P===27){i=x=j;continue e}R=R.parentNode}}i=i.return}Kf(function(){var Z=x,se=ic(l),ue=[];e:{var ee=kp.get(e);if(ee!==void 0){var re=fi,we=e;switch(e){case"keypress":if(ui(l)===0)break e;case"keydown":case"keyup":re=gb;break;case"focusin":we="focus",re=pc;break;case"focusout":we="blur",re=pc;break;case"beforeblur":case"afterblur":re=pc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=Zf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=lb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=bb;break;case yp:case bp:case jp:re=ob;break;case Sp:re=Sb;break;case"scroll":case"scrollend":re=rb;break;case"wheel":re=wb;break;case"copy":case"cut":case"paste":re=ub;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=ep;break;case"toggle":case"beforetoggle":re=Eb}var Le=(n&4)!==0,ft=!Le&&(e==="scroll"||e==="scrollend"),K=Le?ee!==null?ee+"Capture":null:ee;Le=[];for(var W=Z,Q;W!==null;){var ce=W;if(Q=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||Q===null||K===null||(ce=Pl(W,K),ce!=null&&Le.push(Ss(W,ce,Q))),ft)break;W=W.return}0<Le.length&&(ee=new re(ee,we,null,l,se),ue.push({event:ee,listeners:Le}))}}if((n&7)===0){e:{if(ee=e==="mouseover"||e==="pointerover",re=e==="mouseout"||e==="pointerout",ee&&l!==sc&&(we=l.relatedTarget||l.fromElement)&&(Wa(we)||we[xa]))break e;if((re||ee)&&(ee=se.window===se?se:(ee=se.ownerDocument)?ee.defaultView||ee.parentWindow:window,re?(we=l.relatedTarget||l.toElement,re=Z,we=we?Wa(we):null,we!==null&&(ft=u(we),Le=we.tag,we!==ft||Le!==5&&Le!==27&&Le!==6)&&(we=null)):(re=null,we=Z),re!==we)){if(Le=Zf,ce="onMouseLeave",K="onMouseEnter",W="mouse",(e==="pointerout"||e==="pointerover")&&(Le=ep,ce="onPointerLeave",K="onPointerEnter",W="pointer"),ft=re==null?ee:Vl(re),Q=we==null?ee:Vl(we),ee=new Le(ce,W+"leave",re,l,se),ee.target=ft,ee.relatedTarget=Q,ce=null,Wa(se)===Z&&(Le=new Le(K,W+"enter",we,l,se),Le.target=Q,Le.relatedTarget=ft,ce=Le),ft=ce,re&&we)t:{for(Le=C1,K=re,W=we,Q=0,ce=K;ce;ce=Le(ce))Q++;ce=0;for(var Ae=W;Ae;Ae=Le(Ae))ce++;for(;0<Q-ce;)K=Le(K),Q--;for(;0<ce-Q;)W=Le(W),ce--;for(;Q--;){if(K===W||W!==null&&K===W.alternate){Le=K;break t}K=Le(K),W=Le(W)}Le=null}else Le=null;re!==null&&Gh(ue,ee,re,Le,!1),we!==null&&ft!==null&&Gh(ue,ft,we,Le,!0)}}e:{if(ee=Z?Vl(Z):window,re=ee.nodeName&&ee.nodeName.toLowerCase(),re==="select"||re==="input"&&ee.type==="file")var Je=op;else if(sp(ee))if(cp)Je=Ob;else{Je=Db;var Ee=zb}else re=ee.nodeName,!re||re.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?Z&&lc(Z.elementType)&&(Je=op):Je=_b;if(Je&&(Je=Je(e,Z))){ip(ue,Je,l,se);break e}Ee&&Ee(e,ee,Z),e==="focusout"&&Z&&ee.type==="number"&&Z.memoizedProps.value!=null&&ac(ee,"number",ee.value)}switch(Ee=Z?Vl(Z):window,e){case"focusin":(sp(Ee)||Ee.contentEditable==="true")&&(tl=Ee,yc=Z,Ql=null);break;case"focusout":Ql=yc=tl=null;break;case"mousedown":bc=!0;break;case"contextmenu":case"mouseup":case"dragend":bc=!1,gp(ue,l,se);break;case"selectionchange":if(Ib)break;case"keydown":case"keyup":gp(ue,l,se)}var Pe;if(hc)e:{switch(e){case"compositionstart":var Ke="onCompositionStart";break e;case"compositionend":Ke="onCompositionEnd";break e;case"compositionupdate":Ke="onCompositionUpdate";break e}Ke=void 0}else el?ap(e,l)&&(Ke="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Ke="onCompositionStart");Ke&&(tp&&l.locale!=="ko"&&(el||Ke!=="onCompositionStart"?Ke==="onCompositionEnd"&&el&&(Pe=Xf()):(_r=se,uc="value"in _r?_r.value:_r.textContent,el=!0)),Ee=no(Z,Ke),0<Ee.length&&(Ke=new Jf(Ke,e,null,l,se),ue.push({event:Ke,listeners:Ee}),Pe?Ke.data=Pe:(Pe=lp(l),Pe!==null&&(Ke.data=Pe)))),(Pe=Tb?Rb(e,l):Ab(e,l))&&(Ke=no(Z,"onBeforeInput"),0<Ke.length&&(Ee=new Jf("onBeforeInput","beforeinput",null,l,se),ue.push({event:Ee,listeners:Ke}),Ee.data=Pe)),j1(ue,e,Z,l,se)}Ph(ue,n)})}function Ss(e,n,l){return{instance:e,listener:n,currentTarget:l}}function no(e,n){for(var l=n+"Capture",i=[];e!==null;){var f=e,x=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||x===null||(f=Pl(e,l),f!=null&&i.unshift(Ss(e,f,x)),f=Pl(e,n),f!=null&&i.push(Ss(e,f,x))),e.tag===3)return i;e=e.return}return[]}function C1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Gh(e,n,l,i,f){for(var x=n._reactName,j=[];l!==null&&l!==i;){var R=l,P=R.alternate,Z=R.stateNode;if(R=R.tag,P!==null&&P===i)break;R!==5&&R!==26&&R!==27||Z===null||(P=Z,f?(Z=Pl(l,x),Z!=null&&j.unshift(Ss(l,Z,P))):f||(Z=Pl(l,x),Z!=null&&j.push(Ss(l,Z,P)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var E1=/\r\n?/g,N1=/\u0000|\uFFFD/g;function Wh(e){return(typeof e=="string"?e:""+e).replace(E1,`
50
+ `).replace(N1,"")}function qh(e,n){return n=Wh(n),Wh(e)===n}function dt(e,n,l,i,f,x){switch(l){case"children":typeof i=="string"?n==="body"||n==="textarea"&&i===""||Qa(e,i):(typeof i=="number"||typeof i=="bigint")&&n!=="body"&&Qa(e,""+i);break;case"className":si(e,"class",i);break;case"tabIndex":si(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":si(e,l,i);break;case"style":qf(e,i,x);break;case"data":if(n!=="object"){si(e,"data",i);break}case"src":case"href":if(i===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=oi(""+i),e.setAttribute(l,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof x=="function"&&(l==="formAction"?(n!=="input"&&dt(e,n,"name",f.name,f,null),dt(e,n,"formEncType",f.formEncType,f,null),dt(e,n,"formMethod",f.formMethod,f,null),dt(e,n,"formTarget",f.formTarget,f,null)):(dt(e,n,"encType",f.encType,f,null),dt(e,n,"method",f.method,f,null),dt(e,n,"target",f.target,f,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=oi(""+i),e.setAttribute(l,i);break;case"onClick":i!=null&&(e.onclick=pr);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}l=oi(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""+i):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":i===!0?e.setAttribute(l,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,i):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(l,i):e.removeAttribute(l);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(l):e.setAttribute(l,i);break;case"popover":qe("beforetoggle",e),qe("toggle",e),li(e,"popover",i);break;case"xlinkActuate":fr(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":fr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":fr(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":fr(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":fr(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":fr(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":fr(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":fr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":fr(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":li(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=tb.get(l)||l,li(e,l,i))}}function Gu(e,n,l,i,f,x){switch(l){case"style":qf(e,i,x);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"children":typeof i=="string"?Qa(e,i):(typeof i=="number"||typeof i=="bigint")&&Qa(e,""+i);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("scrollend",e);break;case"onClick":i!=null&&(e.onclick=pr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!If.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),x=e[ct]||null,x=x!=null?x[l]:null,typeof x=="function"&&e.removeEventListener(n,x,f),typeof i=="function")){typeof x!="function"&&x!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,i,f);break e}l in e?e[l]=i:i===!0?e.setAttribute(l,""):li(e,l,i)}}}function en(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":qe("error",e),qe("load",e);var i=!1,f=!1,x;for(x in l)if(l.hasOwnProperty(x)){var j=l[x];if(j!=null)switch(x){case"src":i=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:dt(e,n,x,j,l,null)}}f&&dt(e,n,"srcSet",l.srcSet,l,null),i&&dt(e,n,"src",l.src,l,null);return;case"input":qe("invalid",e);var R=x=j=f=null,P=null,Z=null;for(i in l)if(l.hasOwnProperty(i)){var se=l[i];if(se!=null)switch(i){case"name":f=se;break;case"type":j=se;break;case"checked":P=se;break;case"defaultChecked":Z=se;break;case"value":x=se;break;case"defaultValue":R=se;break;case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(o(137,n));break;default:dt(e,n,i,se,l,null)}}Pf(e,x,R,P,Z,j,f,!1);return;case"select":qe("invalid",e),i=j=x=null;for(f in l)if(l.hasOwnProperty(f)&&(R=l[f],R!=null))switch(f){case"value":x=R;break;case"defaultValue":j=R;break;case"multiple":i=R;default:dt(e,n,f,R,l,null)}n=x,l=j,e.multiple=!!i,n!=null?Xa(e,!!i,n,!1):l!=null&&Xa(e,!!i,l,!0);return;case"textarea":qe("invalid",e),x=f=i=null;for(j in l)if(l.hasOwnProperty(j)&&(R=l[j],R!=null))switch(j){case"value":i=R;break;case"defaultValue":f=R;break;case"children":x=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(o(91));break;default:dt(e,n,j,R,l,null)}Gf(e,i,f,x);return;case"option":for(P in l)if(l.hasOwnProperty(P)&&(i=l[P],i!=null))switch(P){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:dt(e,n,P,i,l,null)}return;case"dialog":qe("beforetoggle",e),qe("toggle",e),qe("cancel",e),qe("close",e);break;case"iframe":case"object":qe("load",e);break;case"video":case"audio":for(i=0;i<js.length;i++)qe(js[i],e);break;case"image":qe("error",e),qe("load",e);break;case"details":qe("toggle",e);break;case"embed":case"source":case"link":qe("error",e),qe("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in l)if(l.hasOwnProperty(Z)&&(i=l[Z],i!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:dt(e,n,Z,i,l,null)}return;default:if(lc(n)){for(se in l)l.hasOwnProperty(se)&&(i=l[se],i!==void 0&&Gu(e,n,se,i,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(i=l[R],i!=null&&dt(e,n,R,i,l,null))}function T1(e,n,l,i){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,x=null,j=null,R=null,P=null,Z=null,se=null;for(re in l){var ue=l[re];if(l.hasOwnProperty(re)&&ue!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":P=ue;default:i.hasOwnProperty(re)||dt(e,n,re,null,i,ue)}}for(var ee in i){var re=i[ee];if(ue=l[ee],i.hasOwnProperty(ee)&&(re!=null||ue!=null))switch(ee){case"type":x=re;break;case"name":f=re;break;case"checked":Z=re;break;case"defaultChecked":se=re;break;case"value":j=re;break;case"defaultValue":R=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(o(137,n));break;default:re!==ue&&dt(e,n,ee,re,i,ue)}}rc(e,j,R,P,Z,se,x,f);return;case"select":re=j=R=ee=null;for(x in l)if(P=l[x],l.hasOwnProperty(x)&&P!=null)switch(x){case"value":break;case"multiple":re=P;default:i.hasOwnProperty(x)||dt(e,n,x,null,i,P)}for(f in i)if(x=i[f],P=l[f],i.hasOwnProperty(f)&&(x!=null||P!=null))switch(f){case"value":ee=x;break;case"defaultValue":R=x;break;case"multiple":j=x;default:x!==P&&dt(e,n,f,x,i,P)}n=R,l=j,i=re,ee!=null?Xa(e,!!l,ee,!1):!!i!=!!l&&(n!=null?Xa(e,!!l,n,!0):Xa(e,!!l,l?[]:"",!1));return;case"textarea":re=ee=null;for(R in l)if(f=l[R],l.hasOwnProperty(R)&&f!=null&&!i.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:dt(e,n,R,null,i,f)}for(j in i)if(f=i[j],x=l[j],i.hasOwnProperty(j)&&(f!=null||x!=null))switch(j){case"value":ee=f;break;case"defaultValue":re=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(o(91));break;default:f!==x&&dt(e,n,j,f,i,x)}Ff(e,ee,re);return;case"option":for(var we in l)if(ee=l[we],l.hasOwnProperty(we)&&ee!=null&&!i.hasOwnProperty(we))switch(we){case"selected":e.selected=!1;break;default:dt(e,n,we,null,i,ee)}for(P in i)if(ee=i[P],re=l[P],i.hasOwnProperty(P)&&ee!==re&&(ee!=null||re!=null))switch(P){case"selected":e.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:dt(e,n,P,ee,i,re)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Le in l)ee=l[Le],l.hasOwnProperty(Le)&&ee!=null&&!i.hasOwnProperty(Le)&&dt(e,n,Le,null,i,ee);for(Z in i)if(ee=i[Z],re=l[Z],i.hasOwnProperty(Z)&&ee!==re&&(ee!=null||re!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(o(137,n));break;default:dt(e,n,Z,ee,i,re)}return;default:if(lc(n)){for(var ft in l)ee=l[ft],l.hasOwnProperty(ft)&&ee!==void 0&&!i.hasOwnProperty(ft)&&Gu(e,n,ft,void 0,i,ee);for(se in i)ee=i[se],re=l[se],!i.hasOwnProperty(se)||ee===re||ee===void 0&&re===void 0||Gu(e,n,se,ee,i,re);return}}for(var K in l)ee=l[K],l.hasOwnProperty(K)&&ee!=null&&!i.hasOwnProperty(K)&&dt(e,n,K,null,i,ee);for(ue in i)ee=i[ue],re=l[ue],!i.hasOwnProperty(ue)||ee===re||ee==null&&re==null||dt(e,n,ue,ee,i,re)}function Yh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function R1(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),i=0;i<l.length;i++){var f=l[i],x=f.transferSize,j=f.initiatorType,R=f.duration;if(x&&R&&Yh(j)){for(j=0,R=f.responseEnd,i+=1;i<l.length;i++){var P=l[i],Z=P.startTime;if(Z>R)break;var se=P.transferSize,ue=P.initiatorType;se&&Yh(ue)&&(P=P.responseEnd,j+=se*(P<R?1:(R-Z)/(P-Z)))}if(--i,n+=8*(x+j)/(f.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Wu=null,qu=null;function ro(e){return e.nodeType===9?e:e.ownerDocument}function Kh(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 Xh(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 Yu(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 Ku=null;function A1(){var e=window.event;return e&&e.type==="popstate"?e===Ku?!1:(Ku=e,!0):(Ku=null,!1)}var Qh=typeof setTimeout=="function"?setTimeout:void 0,M1=typeof clearTimeout=="function"?clearTimeout:void 0,Zh=typeof Promise=="function"?Promise:void 0,L1=typeof queueMicrotask=="function"?queueMicrotask:typeof Zh<"u"?function(e){return Zh.resolve(null).then(e).catch(z1)}:Qh;function z1(e){setTimeout(function(){throw e})}function Zr(e){return e==="head"}function Jh(e,n){var l=n,i=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(i===0){e.removeChild(f),Tl(n);return}i--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")i++;else if(l==="html")ks(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,ks(l);for(var x=l.firstChild;x;){var j=x.nextSibling,R=x.nodeName;x[$l]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&x.rel.toLowerCase()==="stylesheet"||l.removeChild(x),x=j}}else l==="body"&&ks(e.ownerDocument.body);l=f}while(l);Tl(n)}function ex(e,n){var l=e;e=0;do{var i=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),i&&i.nodeType===8)if(l=i.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=i}while(l)}function Xu(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":Xu(l),tc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function D1(e,n,l,i){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[$l])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(x=e.getAttribute("rel"),x==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(x!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(x=e.getAttribute("src"),(x!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&x&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var x=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===x)return e}else return e;if(e=Hn(e.nextSibling),e===null)break}return null}function _1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Hn(e.nextSibling),e===null))return null;return e}function tx(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Hn(e.nextSibling),e===null))return null;return e}function Qu(e){return e.data==="$?"||e.data==="$~"}function Zu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function O1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var i=function(){n(),l.removeEventListener("DOMContentLoaded",i)};l.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function Hn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var Ju=null;function nx(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Hn(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function rx(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 ax(e,n,l){switch(n=ro(l),e){case"html":if(e=n.documentElement,!e)throw Error(o(452));return e;case"head":if(e=n.head,!e)throw Error(o(453));return e;case"body":if(e=n.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function ks(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);tc(e)}var $n=new Map,lx=new Set;function ao(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Rr=_.d;_.d={f:B1,r:I1,D:U1,C:H1,L:$1,m:V1,X:F1,S:P1,M:G1};function B1(){var e=Rr.f(),n=Ki();return e||n}function I1(e){var n=qa(e);n!==null&&n.tag===5&&n.type==="form"?Sm(n):Rr.r(e)}var Cl=typeof document>"u"?null:document;function sx(e,n,l){var i=Cl;if(i&&typeof n=="string"&&n){var f=zn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),lx.has(f)||(lx.add(f),e={rel:e,crossOrigin:l,href:n},i.querySelector(f)===null&&(n=i.createElement("link"),en(n,"link",e),Yt(n),i.head.appendChild(n)))}}function U1(e){Rr.D(e),sx("dns-prefetch",e,null)}function H1(e,n){Rr.C(e,n),sx("preconnect",e,n)}function $1(e,n,l){Rr.L(e,n,l);var i=Cl;if(i&&e&&n){var f='link[rel="preload"][as="'+zn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+zn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+zn(l.imageSizes)+'"]')):f+='[href="'+zn(e)+'"]';var x=f;switch(n){case"style":x=El(e);break;case"script":x=Nl(e)}$n.has(x)||(e=v({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),$n.set(x,e),i.querySelector(f)!==null||n==="style"&&i.querySelector(ws(x))||n==="script"&&i.querySelector(Cs(x))||(n=i.createElement("link"),en(n,"link",e),Yt(n),i.head.appendChild(n)))}}function V1(e,n){Rr.m(e,n);var l=Cl;if(l&&e){var i=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+zn(i)+'"][href="'+zn(e)+'"]',x=f;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Nl(e)}if(!$n.has(x)&&(e=v({rel:"modulepreload",href:e},n),$n.set(x,e),l.querySelector(f)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Cs(x)))return}i=l.createElement("link"),en(i,"link",e),Yt(i),l.head.appendChild(i)}}}function P1(e,n,l){Rr.S(e,n,l);var i=Cl;if(i&&e){var f=Ya(i).hoistableStyles,x=El(e);n=n||"default";var j=f.get(x);if(!j){var R={loading:0,preload:null};if(j=i.querySelector(ws(x)))R.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":n},l),(l=$n.get(x))&&ed(e,l);var P=j=i.createElement("link");Yt(P),en(P,"link",e),P._p=new Promise(function(Z,se){P.onload=Z,P.onerror=se}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,lo(j,n,i)}j={type:"stylesheet",instance:j,count:1,state:R},f.set(x,j)}}}function F1(e,n){Rr.X(e,n);var l=Cl;if(l&&e){var i=Ya(l).hoistableScripts,f=Nl(e),x=i.get(f);x||(x=l.querySelector(Cs(f)),x||(e=v({src:e,async:!0},n),(n=$n.get(f))&&td(e,n),x=l.createElement("script"),Yt(x),en(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function G1(e,n){Rr.M(e,n);var l=Cl;if(l&&e){var i=Ya(l).hoistableScripts,f=Nl(e),x=i.get(f);x||(x=l.querySelector(Cs(f)),x||(e=v({src:e,async:!0,type:"module"},n),(n=$n.get(f))&&td(e,n),x=l.createElement("script"),Yt(x),en(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function ix(e,n,l,i){var f=(f=oe.current)?ao(f):null;if(!f)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=El(l.href),l=Ya(f).hoistableStyles,i=l.get(n),i||(i={type:"style",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=El(l.href);var x=Ya(f).hoistableStyles,j=x.get(e);if(j||(f=f.ownerDocument||f,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(e,j),(x=f.querySelector(ws(e)))&&!x._p&&(j.instance=x,j.state.loading=5),$n.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},$n.set(e,l),x||W1(f,e,l,j.state))),n&&i===null)throw Error(o(528,""));return j}if(n&&i!==null)throw Error(o(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Nl(l),l=Ya(f).hoistableScripts,i=l.get(n),i||(i={type:"script",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function El(e){return'href="'+zn(e)+'"'}function ws(e){return'link[rel="stylesheet"]['+e+"]"}function ox(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function W1(e,n,l,i){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?i.loading=1:(n=e.createElement("link"),i.preload=n,n.addEventListener("load",function(){return i.loading|=1}),n.addEventListener("error",function(){return i.loading|=2}),en(n,"link",l),Yt(n),e.head.appendChild(n))}function Nl(e){return'[src="'+zn(e)+'"]'}function Cs(e){return"script[async]"+e}function cx(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var i=e.querySelector('style[data-href~="'+zn(l.href)+'"]');if(i)return n.instance=i,Yt(i),i;var f=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Yt(i),en(i,"style",f),lo(i,l.precedence,e),n.instance=i;case"stylesheet":f=El(l.href);var x=e.querySelector(ws(f));if(x)return n.state.loading|=4,n.instance=x,Yt(x),x;i=ox(l),(f=$n.get(f))&&ed(i,f),x=(e.ownerDocument||e).createElement("link"),Yt(x);var j=x;return j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),en(x,"link",i),n.state.loading|=4,lo(x,l.precedence,e),n.instance=x;case"script":return x=Nl(l.src),(f=e.querySelector(Cs(x)))?(n.instance=f,Yt(f),f):(i=l,(f=$n.get(x))&&(i=v({},l),td(i,f)),e=e.ownerDocument||e,f=e.createElement("script"),Yt(f),en(f,"link",i),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(o(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(i=n.instance,n.state.loading|=4,lo(i,l.precedence,e));return n.instance}function lo(e,n,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=i.length?i[i.length-1]:null,x=f,j=0;j<i.length;j++){var R=i[j];if(R.dataset.precedence===n)x=R;else if(x!==f)break}x?x.parentNode.insertBefore(e,x.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function ed(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function td(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var so=null;function ux(e,n,l){if(so===null){var i=new Map,f=so=new Map;f.set(l,i)}else f=so,i=f.get(l),i||(i=new Map,f.set(l,i));if(i.has(e))return i;for(i.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var x=l[f];if(!(x[$l]||x[$t]||e==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var j=x.getAttribute(n)||"";j=e+j;var R=i.get(j);R?R.push(x):i.set(j,[x])}}return i}function dx(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function q1(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 fx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Y1(e,n,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=El(i.href),x=n.querySelector(ws(f));if(x){n=x._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=io.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=x,Yt(x);return}x=n.ownerDocument||n,i=ox(i),(f=$n.get(f))&&ed(i,f),x=x.createElement("link"),Yt(x);var j=x;j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),en(x,"link",i),l.instance=x}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=io.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var nd=0;function K1(e,n){return e.stylesheets&&e.count===0&&co(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var i=setTimeout(function(){if(e.stylesheets&&co(e,e.stylesheets),e.unsuspend){var x=e.unsuspend;e.unsuspend=null,x()}},6e4+n);0<e.imgBytes&&nd===0&&(nd=62500*R1());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&co(e,e.stylesheets),e.unsuspend)){var x=e.unsuspend;e.unsuspend=null,x()}},(e.imgBytes>nd?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(f)}}:null}function io(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)co(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var oo=null;function co(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oo=new Map,n.forEach(X1,e),oo=null,io.call(e))}function X1(e,n){if(!(n.state.loading&4)){var l=oo.get(e);if(l)var i=l.get(null);else{l=new Map,oo.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<f.length;x++){var j=f[x];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(l.set(j.dataset.precedence,j),i=j)}i&&l.set(null,i)}f=n.instance,j=f.getAttribute("data-precedence"),x=l.get(j)||i,x===i&&l.set(null,f),l.set(j,f),this.count++,i=io.bind(this),f.addEventListener("load",i),f.addEventListener("error",i),x?x.parentNode.insertBefore(f,x.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var Es={$$typeof:A,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function Q1(e,n,l,i,f,x,j,R,P){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ul(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ul(0),this.hiddenUpdates=Ul(null),this.identifierPrefix=i,this.onUncaughtError=f,this.onCaughtError=x,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function px(e,n,l,i,f,x,j,R,P,Z,se,ue){return e=new Q1(e,n,l,j,P,Z,se,ue,R),n=1,x===!0&&(n|=24),x=bn(3,null,null,n),e.current=x,x.stateNode=e,n=_c(),n.refCount++,e.pooledCache=n,n.refCount++,x.memoizedState={element:i,isDehydrated:l,cache:n},Uc(x),e}function mx(e){return e?(e=al,e):al}function hx(e,n,l,i,f,x){f=mx(f),i.context===null?i.context=f:i.pendingContext=f,i=$r(n),i.payload={element:l},x=x===void 0?null:x,x!==null&&(i.callback=x),l=Vr(e,i,n),l!==null&&(vn(l,e,n),as(l,e,n))}function xx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function rd(e,n){xx(e,n),(e=e.alternate)&&xx(e,n)}function gx(e){if(e.tag===13||e.tag===31){var n=ja(e,67108864);n!==null&&vn(n,e,67108864),rd(e,67108864)}}function vx(e){if(e.tag===13||e.tag===31){var n=Cn();n=Ga(n);var l=ja(e,n);l!==null&&vn(l,e,n),rd(e,n)}}var uo=!0;function Z1(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=2,ad(e,n,l,i)}finally{_.p=x,L.T=f}}function J1(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=8,ad(e,n,l,i)}finally{_.p=x,L.T=f}}function ad(e,n,l,i){if(uo){var f=ld(i);if(f===null)Fu(e,n,i,fo,l),bx(e,i);else if(t0(f,e,n,l,i))i.stopPropagation();else if(bx(e,i),n&4&&-1<e0.indexOf(e)){for(;f!==null;){var x=qa(f);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var j=le(x.pendingLanes);if(j!==0){var R=x;for(R.pendingLanes|=2,R.entangledLanes|=2;j;){var P=1<<31-gt(j);R.entanglements[1]|=P,j&=~P}sr(x),(rt&6)===0&&(qi=Ze()+500,bs(0))}}break;case 31:case 13:R=ja(x,2),R!==null&&vn(R,x,2),Ki(),rd(x,2)}if(x=ld(i),x===null&&Fu(e,n,i,fo,l),x===f)break;f=x}f!==null&&i.stopPropagation()}else Fu(e,n,i,null,l)}}function ld(e){return e=ic(e),sd(e)}var fo=null;function sd(e){if(fo=null,e=Wa(e),e!==null){var n=u(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=d(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return fo=e,null}function yx(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(nt()){case ye:return 2;case mt:return 8;case Et:case Xt:return 32;case fn:return 268435456;default:return 32}default:return 32}}var id=!1,Jr=null,ea=null,ta=null,Ns=new Map,Ts=new Map,na=[],e0="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 bx(e,n){switch(e){case"focusin":case"focusout":Jr=null;break;case"dragenter":case"dragleave":ea=null;break;case"mouseover":case"mouseout":ta=null;break;case"pointerover":case"pointerout":Ns.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ts.delete(n.pointerId)}}function Rs(e,n,l,i,f,x){return e===null||e.nativeEvent!==x?(e={blockedOn:n,domEventName:l,eventSystemFlags:i,nativeEvent:x,targetContainers:[f]},n!==null&&(n=qa(n),n!==null&&gx(n)),e):(e.eventSystemFlags|=i,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function t0(e,n,l,i,f){switch(n){case"focusin":return Jr=Rs(Jr,e,n,l,i,f),!0;case"dragenter":return ea=Rs(ea,e,n,l,i,f),!0;case"mouseover":return ta=Rs(ta,e,n,l,i,f),!0;case"pointerover":var x=f.pointerId;return Ns.set(x,Rs(Ns.get(x)||null,e,n,l,i,f)),!0;case"gotpointercapture":return x=f.pointerId,Ts.set(x,Rs(Ts.get(x)||null,e,n,l,i,f)),!0}return!1}function jx(e){var n=Wa(e.target);if(n!==null){var l=u(n);if(l!==null){if(n=l.tag,n===13){if(n=d(l),n!==null){e.blockedOn=n,ha(e.priority,function(){vx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,ha(e.priority,function(){vx(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function po(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=ld(e.nativeEvent);if(l===null){l=e.nativeEvent;var i=new l.constructor(l.type,l);sc=i,l.target.dispatchEvent(i),sc=null}else return n=qa(l),n!==null&&gx(n),e.blockedOn=l,!1;n.shift()}return!0}function Sx(e,n,l){po(e)&&l.delete(n)}function n0(){id=!1,Jr!==null&&po(Jr)&&(Jr=null),ea!==null&&po(ea)&&(ea=null),ta!==null&&po(ta)&&(ta=null),Ns.forEach(Sx),Ts.forEach(Sx)}function mo(e,n){e.blockedOn===n&&(e.blockedOn=null,id||(id=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,n0)))}var ho=null;function kx(e){ho!==e&&(ho=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ho===e&&(ho=null);for(var n=0;n<e.length;n+=3){var l=e[n],i=e[n+1],f=e[n+2];if(typeof i!="function"){if(sd(i||l)===null)continue;break}var x=qa(l);x!==null&&(e.splice(n,3),n-=3,lu(x,{pending:!0,data:f,method:l.method,action:i},i,f))}}))}function Tl(e){function n(P){return mo(P,e)}Jr!==null&&mo(Jr,e),ea!==null&&mo(ea,e),ta!==null&&mo(ta,e),Ns.forEach(n),Ts.forEach(n);for(var l=0;l<na.length;l++){var i=na[l];i.blockedOn===e&&(i.blockedOn=null)}for(;0<na.length&&(l=na[0],l.blockedOn===null);)jx(l),l.blockedOn===null&&na.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(i=0;i<l.length;i+=3){var f=l[i],x=l[i+1],j=f[ct]||null;if(typeof x=="function")j||kx(l);else if(j){var R=null;if(x&&x.hasAttribute("formAction")){if(f=x,j=x[ct]||null)R=j.formAction;else if(sd(f)!==null)continue}else R=j.action;typeof R=="function"?l[i+1]=R:(l.splice(i,3),i-=3),kx(l)}}}function wx(){function e(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(j){return f=j})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),i||setTimeout(l,20)}function l(){if(!i&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function od(e){this._internalRoot=e}xo.prototype.render=od.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(o(409));var l=n.current,i=Cn();hx(l,i,e,n,null,null)},xo.prototype.unmount=od.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;hx(e.current,2,null,e,null,null),Ki(),n[xa]=null}};function xo(e){this._internalRoot=e}xo.prototype.unstable_scheduleHydration=function(e){if(e){var n=ot();e={blockedOn:null,target:e,priority:n};for(var l=0;l<na.length&&n!==0&&n<na[l].priority;l++);na.splice(l,0,e),l===0&&jx(e)}};var Cx=a.version;if(Cx!=="19.2.4")throw Error(o(527,Cx,"19.2.4"));_.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var r0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var go=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!go.isDisabled&&go.supportsFiber)try{Mn=go.inject(r0),Lt=go}catch{}}return Ms.createRoot=function(e,n){if(!c(e))throw Error(o(299));var l=!1,i="",f=Lm,x=zm,j=Dm;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(x=n.onCaughtError),n.onRecoverableError!==void 0&&(j=n.onRecoverableError)),n=px(e,1,!1,null,null,l,i,null,f,x,j,wx),e[xa]=n.current,Pu(e),new od(n)},Ms.hydrateRoot=function(e,n,l){if(!c(e))throw Error(o(299));var i=!1,f="",x=Lm,j=zm,R=Dm,P=null;return l!=null&&(l.unstable_strictMode===!0&&(i=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(x=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError),l.formState!==void 0&&(P=l.formState)),n=px(e,1,!0,n,l??null,i,f,P,x,j,R,wx),n.context=mx(null),l=n.current,i=Cn(),i=Ga(i),f=$r(i),f.callback=null,Vr(l,f,i),l=i,n.current.lanes=l,fa(n,l),sr(n),e[xa]=n.current,Pu(e),new xo(n)},Ms.version="19.2.4",Ms}var _x;function f0(){if(_x)return dd.exports;_x=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(),dd.exports=d0(),dd.exports}var p0=f0();/**
51
51
  * react-router v7.13.1
52
52
  *
53
53
  * Copyright (c) Remix Software Inc.
@@ -56,47 +56,47 @@ Error generating stack: `+i.message+`
56
56
  * LICENSE.md file in the root directory of this source tree.
57
57
  *
58
58
  * @license MIT
59
- */var Ox="popstate";function Bx(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function m0(t={}){function a(c,u){let{pathname:d="/",search:h="",hash:g=""}=zl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),qd("",{pathname:d,search:h,hash:g},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),h="";if(d&&d.getAttribute("href")){let g=c.location.href,p=g.indexOf("#");h=p===-1?g:g.slice(0,p)}return h+"#"+(typeof u=="string"?u:$s(u))}function o(c,u){Zn(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return x0(a,s,o,t)}function Ft(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Zn(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function h0(){return Math.random().toString(36).substring(2,10)}function Ix(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 qd(t,a,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?zl(a):a,state:s,key:a&&a.key||o||h0(),unstable_mask:c}}function $s({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 zl(t){let a={};if(t){let s=t.indexOf("#");s>=0&&(a.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(a.search=t.substring(o),t=t.substring(0,o)),t&&(a.pathname=t)}return a}function x0(t,a,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,h="POP",g=null,p=y();p==null&&(p=0,d.replaceState({...d.state,idx:p},""));function y(){return(d.state||{idx:null}).idx}function v(){h="POP";let C=y(),N=C==null?null:C-p;p=C,g&&g({action:h,location:E.location,delta:N})}function b(C,N){h="PUSH";let T=Bx(C)?C:qd(E.location,C,N);s&&s(T,C),p=y()+1;let A=Ix(T,p),B=E.createHref(T.unstable_mask||T);try{d.pushState(A,"",B)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(B)}u&&g&&g({action:h,location:E.location,delta:1})}function S(C,N){h="REPLACE";let T=Bx(C)?C:qd(E.location,C,N);s&&s(T,C),p=y();let A=Ix(T,p),B=E.createHref(T.unstable_mask||T);d.replaceState(A,"",B),u&&g&&g({action:h,location:E.location,delta:0})}function k(C){return g0(C)}let E={get action(){return h},get location(){return t(c,d)},listen(C){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(Ox,v),g=C,()=>{c.removeEventListener(Ox,v),g=null}},createHref(C){return a(c,C)},createURL:k,encodeLocation(C){let N=k(C);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(C){return d.go(C)}};return E}function g0(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Ft(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:$s(t);return o=o.replace(/ $/,"%20"),!a&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function ov(t,a,s="/"){return v0(t,a,s,!1)}function v0(t,a,s,o){let c=typeof a=="string"?zl(a):a,u=Mr(c.pathname||"/",s);if(u==null)return null;let d=cv(t);y0(d);let h=null;for(let g=0;h==null&&g<d.length;++g){let p=A0(u);h=T0(d[g],p,o)}return h}function cv(t,a=[],s=[],o="",c=!1){let u=(d,h,g=c,p)=>{let y={relativePath:p===void 0?d.path||"":p,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;Ft(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=cr([o,y.relativePath]),b=s.concat(y);d.children&&d.children.length>0&&(Ft(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),cv(d.children,a,b,v,g)),!(d.path==null&&!d.index)&&a.push({path:v,score:E0(v,d.index),routesMeta:b})};return t.forEach((d,h)=>{var g;if(d.path===""||!((g=d.path)!=null&&g.includes("?")))u(d,h);else for(let p of uv(d.path))u(d,h,!0,p)}),a}function uv(t){let a=t.split("/");if(a.length===0)return[];let[s,...o]=a,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=uv(o.join("/")),h=[];return h.push(...d.map(g=>g===""?u:[u,g].join("/"))),c&&h.push(...d),h.map(g=>t.startsWith("/")&&g===""?"/":g)}function y0(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:N0(a.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var b0=/^:[\w-]+$/,j0=3,S0=2,k0=1,w0=10,C0=-2,Ux=t=>t==="*";function E0(t,a){let s=t.split("/"),o=s.length;return s.some(Ux)&&(o+=C0),a&&(o+=S0),s.filter(c=>!Ux(c)).reduce((c,u)=>c+(b0.test(u)?j0:u===""?k0:w0),o)}function N0(t,a){return t.length===a.length&&t.slice(0,-1).every((o,c)=>o===a[c])?t[t.length-1]-a[a.length-1]:0}function T0(t,a,s=!1){let{routesMeta:o}=t,c={},u="/",d=[];for(let h=0;h<o.length;++h){let g=o[h],p=h===o.length-1,y=u==="/"?a:a.slice(u.length)||"/",v=Oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:p},y),b=g.route;if(!v&&p&&s&&!o[o.length-1].route.index&&(v=Oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),d.push({params:c,pathname:cr([u,v.pathname]),pathnameBase:D0(cr([u,v.pathnameBase])),route:b}),v.pathnameBase!=="/"&&(u=cr([u,v.pathnameBase]))}return d}function Oo(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=R0(t.path,t.caseSensitive,t.end),c=a.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((p,{paramName:y,isOptional:v},b)=>{if(y==="*"){let k=h[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[b];return v&&!S?p[y]=void 0:p[y]=(S||"").replace(/%2F/g,"/"),p},{}),pathname:u,pathnameBase:d,pattern:t}}function R0(t,a=!1,s=!0){Zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,h,g,p,y)=>{if(o.push({paramName:h,isOptional:g!=null}),g){let v=y.charAt(p+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,a?void 0:"i"),o]}function A0(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return Zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),t}}function Mr(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let s=a.endsWith("/")?a.length-1:a.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var M0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function L0(t,a="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?zl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Hx(s.substring(1),"/"):u=Hx(s,a)):u=a,{pathname:u,search:_0(o),hash:O0(c)}}function Hx(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 hd(t,a,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function z0(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function dv(t){let a=z0(t);return a.map((s,o)=>o===a.length-1?s.pathname:s.pathnameBase)}function pf(t,a,s,o=!1){let c;typeof t=="string"?c=zl(t):(c={...t},Ft(!c.pathname||!c.pathname.includes("?"),hd("?","pathname","search",c)),Ft(!c.pathname||!c.pathname.includes("#"),hd("#","pathname","hash",c)),Ft(!c.search||!c.search.includes("#"),hd("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let v=a.length-1;if(!o&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),v-=1;c.pathname=b.join("/")}h=v>=0?a[v]:"/"}let g=L0(c,h),p=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&s.endsWith("/");return!g.pathname.endsWith("/")&&(p||y)&&(g.pathname+="/"),g}var cr=t=>t.join("/").replace(/\/\/+/g,"/"),D0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),_0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,O0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,B0=class{constructor(t,a,s,o=!1){this.status=t,this.statusText=a||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function I0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function U0(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var fv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pv(t,a){let s=t;if(typeof s!="string"||!M0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(fv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Mr(d.pathname,a);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{Zn(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var mv=["POST","PUT","PATCH","DELETE"];new Set(mv);var H0=["GET",...mv];new Set(H0);var Dl=m.createContext(null);Dl.displayName="DataRouter";var Vo=m.createContext(null);Vo.displayName="DataRouterState";var $0=m.createContext(!1),hv=m.createContext({isTransitioning:!1});hv.displayName="ViewTransition";var V0=m.createContext(new Map);V0.displayName="Fetchers";var P0=m.createContext(null);P0.displayName="Await";var Gn=m.createContext(null);Gn.displayName="Navigation";var Po=m.createContext(null);Po.displayName="Location";var Lr=m.createContext({outlet:null,matches:[],isDataRoute:!1});Lr.displayName="Route";var mf=m.createContext(null);mf.displayName="RouteError";var xv="REACT_ROUTER_ERROR",F0="REDIRECT",G0="ROUTE_ERROR_RESPONSE";function W0(t){if(t.startsWith(`${xv}:${F0}:{`))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 q0(t){if(t.startsWith(`${xv}:${G0}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new B0(a.status,a.statusText,a.data)}catch{}}function Y0(t,{relative:a}={}){Ft(Ks(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=m.useContext(Gn),{hash:c,pathname:u,search:d}=Xs(t,{relative:a}),h=u;return s!=="/"&&(h=u==="/"?s:cr([s,u])),o.createHref({pathname:h,search:d,hash:c})}function Ks(){return m.useContext(Po)!=null}function oa(){return Ft(Ks(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Po).location}var gv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function vv(t){m.useContext(Gn).static||m.useLayoutEffect(t)}function K0(){let{isDataRoute:t}=m.useContext(Lr);return t?oj():X0()}function X0(){Ft(Ks(),"useNavigate() may be used only in the context of a <Router> component.");let t=m.useContext(Dl),{basename:a,navigator:s}=m.useContext(Gn),{matches:o}=m.useContext(Lr),{pathname:c}=oa(),u=JSON.stringify(dv(o)),d=m.useRef(!1);return vv(()=>{d.current=!0}),m.useCallback((g,p={})=>{if(Zn(d.current,gv),!d.current)return;if(typeof g=="number"){s.go(g);return}let y=pf(g,JSON.parse(u),c,p.relative==="path");t==null&&a!=="/"&&(y.pathname=y.pathname==="/"?a:cr([a,y.pathname])),(p.replace?s.replace:s.push)(y,p.state,p)},[a,s,u,c,t])}m.createContext(null);function Xs(t,{relative:a}={}){let{matches:s}=m.useContext(Lr),{pathname:o}=oa(),c=JSON.stringify(dv(s));return m.useMemo(()=>pf(t,JSON.parse(c),o,a==="path"),[t,c,o,a])}function Q0(t,a,s){Ft(Ks(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=m.useContext(Gn),{matches:c}=m.useContext(Lr),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",g=u?u.pathnameBase:"/",p=u&&u.route;{let C=p&&p.path||"";bv(h,!p||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
59
+ */var Ox="popstate";function Bx(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function m0(t={}){function a(c,u){let{pathname:d="/",search:h="",hash:g=""}=_l(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),qd("",{pathname:d,search:h,hash:g},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),h="";if(d&&d.getAttribute("href")){let g=c.location.href,m=g.indexOf("#");h=m===-1?g:g.slice(0,m)}return h+"#"+(typeof u=="string"?u:Ps(u))}function o(c,u){Zn(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return x0(a,s,o,t)}function Gt(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Zn(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function h0(){return Math.random().toString(36).substring(2,10)}function Ix(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 qd(t,a,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?_l(a):a,state:s,key:a&&a.key||o||h0(),unstable_mask:c}}function Ps({pathname:t="/",search:a="",hash:s=""}){return a&&a!=="?"&&(t+=a.charAt(0)==="?"?a:"?"+a),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function _l(t){let a={};if(t){let s=t.indexOf("#");s>=0&&(a.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(a.search=t.substring(o),t=t.substring(0,o)),t&&(a.pathname=t)}return a}function x0(t,a,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,h="POP",g=null,m=y();m==null&&(m=0,d.replaceState({...d.state,idx:m},""));function y(){return(d.state||{idx:null}).idx}function v(){h="POP";let C=y(),N=C==null?null:C-m;m=C,g&&g({action:h,location:E.location,delta:N})}function b(C,N){h="PUSH";let T=Bx(C)?C:qd(E.location,C,N);s&&s(T,C),m=y()+1;let A=Ix(T,m),B=E.createHref(T.unstable_mask||T);try{d.pushState(A,"",B)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(B)}u&&g&&g({action:h,location:E.location,delta:1})}function S(C,N){h="REPLACE";let T=Bx(C)?C:qd(E.location,C,N);s&&s(T,C),m=y();let A=Ix(T,m),B=E.createHref(T.unstable_mask||T);d.replaceState(A,"",B),u&&g&&g({action:h,location:E.location,delta:0})}function k(C){return g0(C)}let E={get action(){return h},get location(){return t(c,d)},listen(C){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(Ox,v),g=C,()=>{c.removeEventListener(Ox,v),g=null}},createHref(C){return a(c,C)},createURL:k,encodeLocation(C){let N=k(C);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(C){return d.go(C)}};return E}function g0(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Gt(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Ps(t);return o=o.replace(/ $/,"%20"),!a&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function ov(t,a,s="/"){return v0(t,a,s,!1)}function v0(t,a,s,o){let c=typeof a=="string"?_l(a):a,u=Mr(c.pathname||"/",s);if(u==null)return null;let d=cv(t);y0(d);let h=null;for(let g=0;h==null&&g<d.length;++g){let m=A0(u);h=T0(d[g],m,o)}return h}function cv(t,a=[],s=[],o="",c=!1){let u=(d,h,g=c,m)=>{let y={relativePath:m===void 0?d.path||"":m,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;Gt(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=cr([o,y.relativePath]),b=s.concat(y);d.children&&d.children.length>0&&(Gt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),cv(d.children,a,b,v,g)),!(d.path==null&&!d.index)&&a.push({path:v,score:E0(v,d.index),routesMeta:b})};return t.forEach((d,h)=>{var g;if(d.path===""||!((g=d.path)!=null&&g.includes("?")))u(d,h);else for(let m of uv(d.path))u(d,h,!0,m)}),a}function uv(t){let a=t.split("/");if(a.length===0)return[];let[s,...o]=a,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=uv(o.join("/")),h=[];return h.push(...d.map(g=>g===""?u:[u,g].join("/"))),c&&h.push(...d),h.map(g=>t.startsWith("/")&&g===""?"/":g)}function y0(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:N0(a.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var b0=/^:[\w-]+$/,j0=3,S0=2,k0=1,w0=10,C0=-2,Ux=t=>t==="*";function E0(t,a){let s=t.split("/"),o=s.length;return s.some(Ux)&&(o+=C0),a&&(o+=S0),s.filter(c=>!Ux(c)).reduce((c,u)=>c+(b0.test(u)?j0:u===""?k0:w0),o)}function N0(t,a){return t.length===a.length&&t.slice(0,-1).every((o,c)=>o===a[c])?t[t.length-1]-a[a.length-1]:0}function T0(t,a,s=!1){let{routesMeta:o}=t,c={},u="/",d=[];for(let h=0;h<o.length;++h){let g=o[h],m=h===o.length-1,y=u==="/"?a:a.slice(u.length)||"/",v=Oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:m},y),b=g.route;if(!v&&m&&s&&!o[o.length-1].route.index&&(v=Oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),d.push({params:c,pathname:cr([u,v.pathname]),pathnameBase:D0(cr([u,v.pathnameBase])),route:b}),v.pathnameBase!=="/"&&(u=cr([u,v.pathnameBase]))}return d}function Oo(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=R0(t.path,t.caseSensitive,t.end),c=a.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((m,{paramName:y,isOptional:v},b)=>{if(y==="*"){let k=h[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[b];return v&&!S?m[y]=void 0:m[y]=(S||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:d,pattern:t}}function R0(t,a=!1,s=!0){Zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,h,g,m,y)=>{if(o.push({paramName:h,isOptional:g!=null}),g){let v=y.charAt(m+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,a?void 0:"i"),o]}function A0(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return Zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),t}}function Mr(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let s=a.endsWith("/")?a.length-1:a.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var M0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function L0(t,a="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?_l(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Hx(s.substring(1),"/"):u=Hx(s,a)):u=a,{pathname:u,search:_0(o),hash:O0(c)}}function Hx(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 hd(t,a,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function z0(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function dv(t){let a=z0(t);return a.map((s,o)=>o===a.length-1?s.pathname:s.pathnameBase)}function pf(t,a,s,o=!1){let c;typeof t=="string"?c=_l(t):(c={...t},Gt(!c.pathname||!c.pathname.includes("?"),hd("?","pathname","search",c)),Gt(!c.pathname||!c.pathname.includes("#"),hd("#","pathname","hash",c)),Gt(!c.search||!c.search.includes("#"),hd("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let v=a.length-1;if(!o&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),v-=1;c.pathname=b.join("/")}h=v>=0?a[v]:"/"}let g=L0(c,h),m=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&s.endsWith("/");return!g.pathname.endsWith("/")&&(m||y)&&(g.pathname+="/"),g}var cr=t=>t.join("/").replace(/\/\/+/g,"/"),D0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),_0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,O0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,B0=class{constructor(t,a,s,o=!1){this.status=t,this.statusText=a||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function I0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function U0(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var fv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pv(t,a){let s=t;if(typeof s!="string"||!M0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(fv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Mr(d.pathname,a);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{Zn(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var mv=["POST","PUT","PATCH","DELETE"];new Set(mv);var H0=["GET",...mv];new Set(H0);var Ol=p.createContext(null);Ol.displayName="DataRouter";var Vo=p.createContext(null);Vo.displayName="DataRouterState";var $0=p.createContext(!1),hv=p.createContext({isTransitioning:!1});hv.displayName="ViewTransition";var V0=p.createContext(new Map);V0.displayName="Fetchers";var P0=p.createContext(null);P0.displayName="Await";var Gn=p.createContext(null);Gn.displayName="Navigation";var Po=p.createContext(null);Po.displayName="Location";var Lr=p.createContext({outlet:null,matches:[],isDataRoute:!1});Lr.displayName="Route";var mf=p.createContext(null);mf.displayName="RouteError";var xv="REACT_ROUTER_ERROR",F0="REDIRECT",G0="ROUTE_ERROR_RESPONSE";function W0(t){if(t.startsWith(`${xv}:${F0}:{`))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 q0(t){if(t.startsWith(`${xv}:${G0}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new B0(a.status,a.statusText,a.data)}catch{}}function Y0(t,{relative:a}={}){Gt(Qs(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=p.useContext(Gn),{hash:c,pathname:u,search:d}=Zs(t,{relative:a}),h=u;return s!=="/"&&(h=u==="/"?s:cr([s,u])),o.createHref({pathname:h,search:d,hash:c})}function Qs(){return p.useContext(Po)!=null}function oa(){return Gt(Qs(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(Po).location}var gv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function vv(t){p.useContext(Gn).static||p.useLayoutEffect(t)}function K0(){let{isDataRoute:t}=p.useContext(Lr);return t?oj():X0()}function X0(){Gt(Qs(),"useNavigate() may be used only in the context of a <Router> component.");let t=p.useContext(Ol),{basename:a,navigator:s}=p.useContext(Gn),{matches:o}=p.useContext(Lr),{pathname:c}=oa(),u=JSON.stringify(dv(o)),d=p.useRef(!1);return vv(()=>{d.current=!0}),p.useCallback((g,m={})=>{if(Zn(d.current,gv),!d.current)return;if(typeof g=="number"){s.go(g);return}let y=pf(g,JSON.parse(u),c,m.relative==="path");t==null&&a!=="/"&&(y.pathname=y.pathname==="/"?a:cr([a,y.pathname])),(m.replace?s.replace:s.push)(y,m.state,m)},[a,s,u,c,t])}p.createContext(null);function Zs(t,{relative:a}={}){let{matches:s}=p.useContext(Lr),{pathname:o}=oa(),c=JSON.stringify(dv(s));return p.useMemo(()=>pf(t,JSON.parse(c),o,a==="path"),[t,c,o,a])}function Q0(t,a,s){Gt(Qs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=p.useContext(Gn),{matches:c}=p.useContext(Lr),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",g=u?u.pathnameBase:"/",m=u&&u.route;{let C=m&&m.path||"";bv(h,!m||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
60
60
 
61
- Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=oa(),v;v=y;let b=v.pathname||"/",S=b;if(g!=="/"){let C=g.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=ov(t,{pathname:S});return Zn(p||k!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Zn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),nj(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:cr([g,o.encodeLocation?o.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?g:cr([g,o.encodeLocation?o.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s)}function Z0(){let t=ij(),a=I0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:u},"ErrorBoundary")," or"," ",m.createElement("code",{style:u},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},a),s?m.createElement("pre",{style:c},s):null,d)}var J0=m.createElement(Z0,null),yv=class extends m.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=q0(t.digest);s&&(t=s)}let a=t!==void 0?m.createElement(Lr.Provider,{value:this.props.routeContext},m.createElement(mf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?m.createElement(ej,{error:t},a):a}};yv.contextType=$0;var xd=new WeakMap;function ej({children:t,error:a}){let{basename:s}=m.useContext(Gn);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let o=W0(a.digest);if(o){let c=xd.get(a);if(c)throw c;let u=pv(o.location,s);if(fv&&!xd.get(a))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw xd.set(a,d),d}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function tj({routeContext:t,match:a,children:s}){let o=m.useContext(Dl);return o&&o.static&&o.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=a.route.id),m.createElement(Lr.Provider,{value:t},s)}function nj(t,a=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(a.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let d=!1,h=-1;if(s&&o){d=o.renderFallback;for(let y=0;y<c.length;y++){let v=c[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(h=y),v.route.id){let{loaderData:b,errors:S}=o,k=v.route.loader&&!b.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||k){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let g=s==null?void 0:s.onError,p=o&&g?(y,v)=>{var b,S;g(y,{location:o.location,params:((S=(b=o.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:U0(o.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,b)=>{let S,k=!1,E=null,C=null;o&&(S=u&&v.route.id?u[v.route.id]:void 0,E=v.route.errorElement||J0,d&&(h<0&&b===0?(bv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,C=null):h===b&&(k=!0,C=v.route.hydrateFallbackElement||null)));let N=a.concat(c.slice(0,b+1)),T=()=>{let A;return S?A=E:k?A=C:v.route.Component?A=m.createElement(v.route.Component,null):v.route.element?A=v.route.element:A=y,m.createElement(tj,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:o!=null},children:A})};return o&&(v.route.ErrorBoundary||v.route.errorElement||b===0)?m.createElement(yv,{location:o.location,revalidation:o.revalidation,component:E,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:p}):T()},null)}function hf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rj(t){let a=m.useContext(Dl);return Ft(a,hf(t)),a}function aj(t){let a=m.useContext(Vo);return Ft(a,hf(t)),a}function lj(t){let a=m.useContext(Lr);return Ft(a,hf(t)),a}function xf(t){let a=lj(t),s=a.matches[a.matches.length-1];return Ft(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function sj(){return xf("useRouteId")}function ij(){var o;let t=m.useContext(mf),a=aj("useRouteError"),s=xf("useRouteError");return t!==void 0?t:(o=a.errors)==null?void 0:o[s]}function oj(){let{router:t}=rj("useNavigate"),a=xf("useNavigate"),s=m.useRef(!1);return vv(()=>{s.current=!0}),m.useCallback(async(c,u={})=>{Zn(s.current,gv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var $x={};function bv(t,a,s){!a&&!$x[t]&&($x[t]=!0,Zn(!1,s))}m.memo(cj);function cj({routes:t,future:a,state:s,isStatic:o,onError:c}){return Q0(t,void 0,{state:s,isStatic:o,onError:c})}function uj({basename:t="/",children:a=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Ft(!Ks(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),g=m.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=zl(s));let{pathname:p="/",search:y="",hash:v="",state:b=null,key:S="default",unstable_mask:k}=s,E=m.useMemo(()=>{let C=Mr(p,h);return C==null?null:{location:{pathname:C,search:y,hash:v,state:b,key:S,unstable_mask:k},navigationType:o}},[h,p,y,v,b,S,o,k]);return Zn(E!=null,`<Router basename="${h}"> is not able to match the URL "${p}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:m.createElement(Gn.Provider,{value:g},m.createElement(Po.Provider,{children:a,value:E}))}var Ro="get",Ao="application/x-www-form-urlencoded";function Fo(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function dj(t){return Fo(t)&&t.tagName.toLowerCase()==="button"}function fj(t){return Fo(t)&&t.tagName.toLowerCase()==="form"}function pj(t){return Fo(t)&&t.tagName.toLowerCase()==="input"}function mj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function hj(t,a){return t.button===0&&(!a||a==="_self")&&!mj(t)}var vo=null;function xj(){if(vo===null)try{new FormData(document.createElement("form"),0),vo=!1}catch{vo=!0}return vo}var gj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function gd(t){return t!=null&&!gj.has(t)?(Zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ao}"`),null):t}function vj(t,a){let s,o,c,u,d;if(fj(t)){let h=t.getAttribute("action");o=h?Mr(h,a):null,s=t.getAttribute("method")||Ro,c=gd(t.getAttribute("enctype"))||Ao,u=new FormData(t)}else if(dj(t)||pj(t)&&(t.type==="submit"||t.type==="image")){let h=t.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=t.getAttribute("formaction")||h.getAttribute("action");if(o=g?Mr(g,a):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||Ro,c=gd(t.getAttribute("formenctype"))||gd(h.getAttribute("enctype"))||Ao,u=new FormData(h,t),!xj()){let{name:p,type:y,value:v}=t;if(y==="image"){let b=p?`${p}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else p&&u.append(p,v)}}else{if(Fo(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Ro,o=null,c=Ao,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function gf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function yj(t,a,s,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:a&&Mr(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function bj(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 jj(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 Sj(t,a,s){let o=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await bj(u,s);return d.links?d.links():[]}return[]}));return Ej(o.flat(1).filter(jj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Vx(t,a,s,o,c,u){let d=(g,p)=>s[p]?g.route.id!==s[p].route.id:!0,h=(g,p)=>{var y;return s[p].pathname!==g.pathname||((y=s[p].route.path)==null?void 0:y.endsWith("*"))&&s[p].params["*"]!==g.params["*"]};return u==="assets"?a.filter((g,p)=>d(g,p)||h(g,p)):u==="data"?a.filter((g,p)=>{var v;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(d(g,p)||h(g,p))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(t,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function kj(t,a,{includeHydrateFallback:s}={}){return wj(t.map(o=>{let c=a.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function wj(t){return[...new Set(t)]}function Cj(t){let a={},s=Object.keys(t).sort();for(let o of s)a[o]=t[o];return a}function Ej(t,a){let s=new Set;return new Set(a),t.reduce((o,c)=>{let u=JSON.stringify(Cj(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function jv(){let t=m.useContext(Dl);return gf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Nj(){let t=m.useContext(Vo);return gf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var vf=m.createContext(void 0);vf.displayName="FrameworkContext";function Sv(){let t=m.useContext(vf);return gf(t,"You must render this element inside a <HydratedRouter> element"),t}function Tj(t,a){let s=m.useContext(vf),[o,c]=m.useState(!1),[u,d]=m.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:p,onMouseLeave:y,onTouchStart:v}=a,b=m.useRef(null);m.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let E=N=>{N.forEach(T=>{d(T.isIntersecting)})},C=new IntersectionObserver(E,{threshold:.5});return b.current&&C.observe(b.current),()=>{C.disconnect()}}},[t]),m.useEffect(()=>{if(o){let E=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(E)}}},[o]);let S=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:As(h,S),onBlur:As(g,k),onMouseEnter:As(p,S),onMouseLeave:As(y,k),onTouchStart:As(v,S)}]:[!1,b,{}]}function As(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function Rj({page:t,...a}){let{router:s}=jv(),o=m.useMemo(()=>ov(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?m.createElement(Mj,{page:t,matches:o,...a}):null}function Aj(t){let{manifest:a,routeModules:s}=Sv(),[o,c]=m.useState([]);return m.useEffect(()=>{let u=!1;return Sj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),o}function Mj({page:t,matches:a,...s}){let o=oa(),{future:c,manifest:u,routeModules:d}=Sv(),{basename:h}=jv(),{loaderData:g,matches:p}=Nj(),y=m.useMemo(()=>Vx(t,a,p,u,o,"data"),[t,a,p,u,o]),v=m.useMemo(()=>Vx(t,a,p,u,o,"assets"),[t,a,p,u,o]),b=m.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let E=new Set,C=!1;if(a.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!y.some(D=>D.route.id===T.route.id)&&T.route.id in g&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?C=!0:E.add(T.route.id))}),E.size===0)return[];let N=yj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return C&&E.size>0&&N.searchParams.set("_routes",a.filter(T=>E.has(T.route.id)).map(T=>T.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,g,o,u,y,a,t,d]),S=m.useMemo(()=>kj(v,u),[v,u]),k=Aj(v);return m.createElement(m.Fragment,null,b.map(E=>m.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...s})),S.map(E=>m.createElement("link",{key:E,rel:"modulepreload",href:E,...s})),k.map(({key:E,link:C})=>m.createElement("link",{key:E,nonce:s.nonce,...C,crossOrigin:C.crossOrigin??s.crossOrigin})))}function Lj(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var zj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{zj&&(window.__reactRouterVersion="7.13.1")}catch{}function Dj({basename:t,children:a,unstable_useTransitions:s,window:o}){let c=m.useRef();c.current==null&&(c.current=m0({window:o,v5Compat:!0}));let u=c.current,[d,h]=m.useState({action:u.action,location:u.location}),g=m.useCallback(p=>{s===!1?h(p):m.startTransition(()=>h(p))},[s]);return m.useLayoutEffect(()=>u.listen(g),[u,g]),m.createElement(uj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var kv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wv=m.forwardRef(function({onClick:a,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:g,target:p,to:y,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:S,...k},E){let{basename:C,navigator:N,unstable_useTransitions:T}=m.useContext(Gn),A=typeof y=="string"&&kv.test(y),B=pv(y,C);y=B.to;let D=Y0(y,{relative:c}),F=oa(),w=null;if(h){let $=pf(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);C!=="/"&&($.pathname=$.pathname==="/"?C:cr([C,$.pathname])),w=N.createHref($)}let[O,z,U]=Tj(o,k),H=Ij(y,{replace:d,unstable_mask:h,state:g,target:p,preventScrollReset:v,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function q($){a&&a($),$.defaultPrevented||H($)}let X=!(B.isExternal||u),J=m.createElement("a",{...k,...U,href:(X?w:void 0)||B.absoluteURL||D,onClick:X?q:a,ref:Lj(E,z),target:p,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?m.createElement(m.Fragment,null,J,m.createElement(Rj,{page:D})):J});wv.displayName="Link";var _j=m.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:h,children:g,...p},y){let v=Xs(d,{relative:p.relative}),b=oa(),S=m.useContext(Vo),{navigator:k,basename:E}=m.useContext(Gn),C=S!=null&&Pj(v)&&h===!0,N=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,T=b.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(T=T.toLowerCase(),A=A?A.toLowerCase():null,N=N.toLowerCase()),A&&E&&(A=Mr(A,E)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let D=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",F=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),w={isActive:D,isPending:F,isTransitioning:C},O=D?a:void 0,z;typeof o=="function"?z=o(w):z=[o,D?"active":null,F?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let U=typeof u=="function"?u(w):u;return m.createElement(wv,{...p,"aria-current":O,className:z,ref:y,style:U,to:d,viewTransition:h},typeof g=="function"?g(w):g)});_j.displayName="NavLink";var Oj=m.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:o,replace:c,state:u,method:d=Ro,action:h,onSubmit:g,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b,...S},k)=>{let{unstable_useTransitions:E}=m.useContext(Gn),C=$j(),N=Vj(h,{relative:p}),T=d.toLowerCase()==="get"?"get":"post",A=typeof h=="string"&&kv.test(h),B=D=>{if(g&&g(D),D.defaultPrevented)return;D.preventDefault();let F=D.nativeEvent.submitter,w=(F==null?void 0:F.getAttribute("formmethod"))||d,O=()=>C(F||D.currentTarget,{fetcherKey:a,method:w,navigate:s,replace:c,state:u,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b});E&&s!==!1?m.startTransition(()=>O()):O()};return m.createElement("form",{ref:k,method:T,action:N,onSubmit:o?g:B,...S,"data-discover":!A&&t==="render"?"true":void 0})});Oj.displayName="Form";function Bj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Cv(t){let a=m.useContext(Dl);return Ft(a,Bj(t)),a}function Ij(t,{target:a,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:p}={}){let y=K0(),v=oa(),b=Xs(t,{relative:d});return m.useCallback(S=>{if(hj(S,a)){S.preventDefault();let k=s!==void 0?s:$s(v)===$s(b),E=()=>y(t,{replace:k,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g});p?m.startTransition(()=>E()):E()}},[v,y,b,s,o,c,a,t,u,d,h,g,p])}var Uj=0,Hj=()=>`__${String(++Uj)}__`;function $j(){let{router:t}=Cv("useSubmit"),{basename:a}=m.useContext(Gn),s=sj(),o=t.fetch,c=t.navigate;return m.useCallback(async(u,d={})=>{let{action:h,method:g,encType:p,formData:y,body:v}=vj(u,a);if(d.navigate===!1){let b=d.fetcherKey||Hj();await o(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||p,flushSync:d.flushSync})}else await c(d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||p,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,a,s])}function Vj(t,{relative:a}={}){let{basename:s}=m.useContext(Gn),o=m.useContext(Lr);Ft(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Xs(t||".",{relative:a})},d=oa();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),g=h.getAll("index");if(g.some(y=>y==="")){h.delete("index"),g.filter(v=>v).forEach(v=>h.append("index",v));let y=h.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:cr([s,u.pathname])),$s(u)}function Pj(t,{relative:a}={}){let s=m.useContext(hv);Ft(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Cv("useViewTransitionState"),c=Xs(t,{relative:a});if(!s.isTransitioning)return!1;let u=Mr(s.currentLocation.pathname,o)||s.currentLocation.pathname,d=Mr(s.nextLocation.pathname,o)||s.nextLocation.pathname;return Oo(c.pathname,d)!=null||Oo(c.pathname,u)!=null}var Go=iv();const Fj=sv(Go),Gj="modulepreload",Wj=function(t){return"/"+t},Px={},Qs=function(a,s,o){let c=Promise.resolve();if(s&&s.length>0){let d=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(p=>{if(p=Wj(p),p in Px)return;Px[p]=!0;const y=p.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${v}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":Gj,y||(b.as="script"),b.crossOrigin="",b.href=p,g&&b.setAttribute("nonce",g),document.head.appendChild(b),y)return new Promise((S,k)=>{b.addEventListener("load",S),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${p}`)))})}))}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)})},Fx={own:"authoring-project",installed:"available-project",global:"available-personal"},Yd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function qj(t){if(typeof t=="string"){if(Yd.has(t))return t;if(Object.prototype.hasOwnProperty.call(Fx,t))return Fx[t]}return"authoring-project"}function Yj(t){return t.startsWith("available-")?"available":"authoring"}function Kj(t){const a=t.indexOf("-");return t.slice(a+1)}const Vn="";class Bs extends Error{constructor(a,s){super(a),this.name="ApiError",this.status=s}}async function $e(t,a){const s=await fetch(`${Vn}${t}`,a);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Bs(o.error||`HTTP ${s.status}`,s.status)}return s.json()}function Jt(t){return typeof t=="string"&&t.length>0?t:null}function Xj(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function vd(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 Qj(t){const a=t??{};let s;a.origin==="source"||a.origin==="installed"?s=a.origin:(s="source",console.warn(`[api.getSkills] skill ${String(a.plugin)}/${String(a.skill)} has invalid origin=${JSON.stringify(a.origin)}; defaulting to 'source'`));let o;a.scope==="own"||a.scope==="installed"||a.scope==="global"?o=a.scope:o=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=o==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&Yd.has(a.scopeV2)?a.scopeV2:qj(a.scope),d=Yj(u),h=Kj(u),g=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let p;a.shadowedBy===null?p=null:typeof a.shadowedBy=="string"&&Yd.has(a.shadowedBy)?p=a.shadowedBy:p=void 0;const y={plugin:typeof a.plugin=="string"?a.plugin:"",skill:typeof a.skill=="string"?a.skill:"",dir:typeof a.dir=="string"?a.dir:"",hasEvals:!!a.hasEvals,hasBenchmark:!!a.hasBenchmark,evalCount:typeof a.evalCount=="number"?a.evalCount:0,assertionCount:typeof a.assertionCount=="number"?a.assertionCount:0,benchmarkStatus:a.benchmarkStatus==="pass"||a.benchmarkStatus==="fail"||a.benchmarkStatus==="pending"||a.benchmarkStatus==="stale"||a.benchmarkStatus==="missing"?a.benchmarkStatus:"missing",lastBenchmark:typeof a.lastBenchmark=="string"?a.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:Jt(a.symlinkTarget),installMethod:c,scopeV2:u,group:d,source:h,pluginName:Jt(a.pluginName),pluginNamespace:Jt(a.pluginNamespace),pluginMarketplace:Jt(a.pluginMarketplace),pluginManifestPath:Jt(a.pluginManifestPath),pluginVersion:Jt(a.pluginVersion),precedenceRank:g,shadowedBy:p,description:Jt(a.description),version:Jt(a.version),category:Jt(a.category),author:Jt(a.author),license:Jt(a.license),homepage:Jt(a.homepage),repoUrl:Jt(a.repoUrl),skillPath:Jt(a.skillPath),tags:vd(a.tags),deps:vd(a.deps),mcpDeps:vd(a.mcpDeps),entryPoint:Jt(a.entryPoint),lastModified:Jt(a.lastModified),sizeBytes:Xj(a.sizeBytes),sourceAgent:Jt(a.sourceAgent)};if(a.provenance&&typeof a.provenance=="object"){const v=a.provenance;(v.promotedFrom==="installed"||v.promotedFrom==="global")&&typeof v.sourcePath=="string"&&typeof v.promotedAt=="number"?y.provenance={promotedFrom:v.promotedFrom,sourcePath:v.sourcePath,promotedAt:v.promotedAt,sourceSkillVersion:typeof v.sourceSkillVersion=="string"?v.sourceSkillVersion:void 0}:y.provenance=null}else a.provenance===null&&(y.provenance=null);return typeof a.updateAvailable=="boolean"&&(y.updateAvailable=a.updateAvailable),typeof a.currentVersion=="string"&&(y.currentVersion=a.currentVersion),typeof a.latestVersion=="string"&&(y.latestVersion=a.latestVersion),typeof a.pinnedVersion=="string"&&(y.pinnedVersion=a.pinnedVersion),y}const Ce={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(),o=await $e(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(Qj):[]},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:o,...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(`${Vn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Bs(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,s){const o=new URLSearchParams;s!=null&&s.model&&o.set("model",s.model),s!=null&&s.type&&o.set("type",s.type),s!=null&&s.from&&o.set("from",s.from),s!=null&&s.to&&o.set("to",s.to);const c=o.toString();return $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,o){return $e(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,a,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return $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")},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,o){return $e(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},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 o=`${Vn}/api/skills/${t}/${a}/sweep`,c=new EventSource(o);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,a){return $e(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,o){return $e(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,a){return $e(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return $e(`/api/credentials/${t}/${a}/params?${o}`)},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,o){return $e(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const a=`${Vn}/api/skills/batch-update`,s=new EventSource(a);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,a){const s=`${Vn}/api/skills/${t}/${a}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(t,a,s){const o=`${Vn}/api/skills/${t}/${a}/update`,c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},signal:s});let u,d="";if(c.body){const h=c.body.getReader(),g=new TextDecoder;let p=!1,y="";for(;!p;){const b=await h.read();if(p=b.done,b.value){const S=g.decode(b.value,{stream:!p});y+=S,d.length<200&&(d+=S)}}const v=y.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(v)try{u=JSON.parse(v[1]).version}catch{}d=d.slice(0,200)}else{const h=await c.text();d=h.slice(0,200);const g=h.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(g)try{u=JSON.parse(g[1]).version}catch{}}return{ok:c.ok,status:c.status,body:d,version:u}},async rescanSkill(t,a){const s=`${t}/${a}`,o=await fetch(`${Vn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const t=await fetch(`${Vn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const a=[...t].sort(),s=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(c=>({name:c,currentVersion:"0.0.0"}))})});if(!s.ok)return[];const o=await s.json().catch(()=>null);return Array.isArray(o)?o:o&&typeof o=="object"&&Array.isArray(o.results)?o.results.map(c=>({skillId:typeof c.skillId=="string"?c.skillId:typeof c.name=="string"?c.name:"",version:typeof c.version=="string"?c.version:typeof c.latest=="string"?c.latest:"",eventId:typeof c.eventId=="string"?c.eventId:"",publishedAt:typeof c.publishedAt=="string"?c.publishedAt:"",diffSummary:typeof c.diffSummary=="string"?c.diffSummary:void 0,trackedForUpdates:typeof c.trackedForUpdates=="boolean"?c.trackedForUpdates:void 0,updateAvailable:typeof c.updateAvailable=="boolean"?c.updateAvailable:void 0,installed:typeof c.installed=="string"?c.installed:void 0,latest:typeof c.latest=="string"?c.latest:void 0,name:typeof c.name=="string"?c.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const a=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!a.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await a.json().catch(()=>null),o=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(o.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,a,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return yd(`/api/skills/${t}/${a}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,s){const o=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&o.set("dest","global"),s!=null&&s.overwrite&&o.set("overwrite","true");const c=o.toString();return yd(`/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 yd(`/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(`${Vn}/api/studio/ops/stream`)}};async function yd(t,a,s){const o=await fetch(`${Vn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let y=`HTTP ${o.status}`,v;try{const S=await o.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const b=new Bs(y,o.status);throw v&&(b.code=v),b}const c=o.body.getReader(),u=new TextDecoder;let d="",h="",g=null,p=null;for(;;){const{done:y,value:v}=await c.read();if(y)break;d+=u.decode(v,{stream:!0});const b=d.split(`
62
- `);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};a==null||a(E),E.type==="done"&&(g=E),E.type==="error"&&(p=E)}h=""}}if(p){const y=new Bs(p.message,500);throw y.code=p.code,y}if(!g)throw new Bs("Transfer stream ended without 'done' event",500);return g}function Zj(t,a){if(!a.length)return t;const s=new Map,o=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};return typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates),d})}function Jj(t){const[a,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),a}const eS=500,Kd="vskill.updates.seenLastId";function tS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Kd)}catch{return null}}function bd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Kd):window.localStorage.setItem(Kd,t)}catch{}}function nS(){let t=new Map;const a=new Set,s=new Set,o=[];let c=tS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(a))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>eS){const g=o.shift();g&&s.delete(g)}c=h,bd(h)}}return{getSnapshot(){return t},subscribe(h){return a.add(h),()=>{a.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,bd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,bd(null),u()}}}const Da=nS(),rS=3e5,aS=500,lS=15e3,sS=6e4,iS=6e4,oS="/api/v1/skills/stream";function Gx(t){const a=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;a.set(o,s)}return a}function Wx(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function cS(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 uS(t){const a=(t==null?void 0:t.intervalMs)??rS,s=(t==null?void 0:t.debounceMs)??aS,o=(t==null?void 0:t.timeoutMs)??lS,c=(t==null?void 0:t.staleAfterMs)??sS,u=(t==null?void 0:t.disconnectFallbackMs)??iS,d=(t==null?void 0:t.streamUrlBase)??oS,h=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=m.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[p,y]=m.useState([]),[v,b]=m.useState(()=>new Map),[S,k]=m.useState(0),[E,C]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),D=m.useRef(null),F=m.useRef(null),w=m.useRef(null),O=m.useRef(null),z=m.useRef(!0),[U,H]=m.useState(()=>h?"connecting":"fallback"),q=m.useRef(U);q.current=U;const X=m.useSyncExternalStore(M=>Da.subscribe(M),()=>Da.getSnapshot(),()=>Da.getSnapshot()),J=X.size,$=m.useCallback(async()=>{C(!0);const M=new AbortController,Y=setTimeout(()=>M.abort(),o);try{const G=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{M.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(G==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(G),b(Gx(G)),k(Wx(G)),F.current=Date.now(),T(F.current),B(null)}catch(G){if(!z.current)return;B(G instanceof Error?G:new Error(String(G)))}finally{clearTimeout(Y),z.current&&C(!1)}},[o]),L=m.useCallback(()=>{if(D.current)return D.current;const M=$().finally(()=>{D.current=null});return D.current=M,M},[$]),_=m.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{L()},a))},[a,L]),I=m.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);m.useEffect(()=>{z.current=!0,(F.current==null||Date.now()-F.current>c)&&L(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const G=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){I();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&L(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",G),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",G),O.current&&clearTimeout(O.current),I()}},[]);const V=m.useCallback(async M=>{if(M.length!==0)try{const Y=await Ce.checkSkillUpdates(M);if(!z.current||Y.length===0)return;const G=Date.now(),te=Y.filter(ie=>ie.skillId&&ie.eventId&&ie.version).map(ie=>({skillId:ie.skillId,version:ie.version,eventId:ie.eventId,publishedAt:ie.publishedAt,diffSummary:ie.diffSummary,receivedAt:G}));te.length>0&&Da.mergeBulk(te);const fe=Y.filter(ie=>typeof ie.trackedForUpdates=="boolean"||typeof ie.updateAvailable=="boolean").map(ie=>({name:ie.name??ie.skillId,installed:ie.installed??"",latest:ie.latest??null,updateAvailable:ie.updateAvailable??!1,trackedForUpdates:typeof ie.trackedForUpdates=="boolean"?ie.trackedForUpdates:void 0}));fe.length>0&&y(ie=>{const ye=new Map;for(const Ae of ie)ye.set(Ae.name.split("/").pop()||Ae.name,Ae);let de=0;for(const Ae of fe){const _e=Ae.name.split("/").pop()||Ae.name,ae=ye.get(_e);if(ae){const he={...ae};ae.trackedForUpdates===void 0&&Ae.trackedForUpdates!==void 0&&(he.trackedForUpdates=Ae.trackedForUpdates),ye.set(_e,he)}else ye.set(_e,{name:Ae.name,installed:Ae.installed??"",latest:Ae.latest??null,updateAvailable:Ae.updateAvailable??!1,trackedForUpdates:Ae.trackedForUpdates}),de+=1}if(de===0&&ye.size===ie.length)return ie;const Se=[...ye.values()];return b(Gx(Se)),k(Wx(Se)),Se})}catch{}},[]);m.useEffect(()=>{const M=h||g;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const Y=M.split(","),G=`${d}?skills=${encodeURIComponent(M)}`;let te=null,fe=null,ie=null;const ye=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,z.current&&q.current!=="connected"&&H("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ye();const Se=1e3,Ae=()=>{z.current&&ie==null&&(ie=setTimeout(()=>{if(ie=null,!!z.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},Se))},_e=pe=>{if(!z.current)return;let ge;try{ge=JSON.parse(pe.data)}catch{return}if(!cS(ge)||Da.ingest(ge)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${ge.skillId} updated to ${ge.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId}}))}},ae=()=>{z.current&&(Da.clearSeen(),V(Y))},he=()=>{z.current&&(te=new EventSource(G),te.onopen=()=>{z.current&&(de(),H("connected"))},te.onerror=()=>{z.current&&(ye(),te&&te.readyState===EventSource.CLOSED&&Ae())},te.onmessage=_e,te.addEventListener("gone",ae))};return he(),()=>{if(de(),ie!=null&&(clearTimeout(ie),ie=null),te){try{te.removeEventListener("gone",ae)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),m.useEffect(()=>{if(!g)return;const M=g.split(",");V(M)},[g,V]);const se=m.useCallback(M=>{Da.dismiss(M)},[]);return{updates:p,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:L,updatesById:X,pushUpdateCount:J,status:U,dismiss:se}}function dS(t){const a=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const fS={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 Ev=m.createContext(null),Nv=Ev;function er(){const t=m.useContext(Nv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function mS({children:t}){const[a,s]=m.useReducer(pS,fS),o=Jj("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=m.useState(()=>{try{const I=window.localStorage.getItem("vskill.studio.prefs");if(!I)return null;const V=JSON.parse(I);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=m.useState(c!==null);m.useEffect(()=>{function I(V){if(!(V instanceof CustomEvent))return;const se=V.detail;se!=null&&se.agentId&&(u(se.agentId),h(!0))}return window.addEventListener("studio:agent-changed",I),()=>window.removeEventListener("studio:agent-changed",I)},[]),m.useEffect(()=>{if(d)return;let I=!1;return Ce.getAgents().then(V=>{if(I)return;const se=(V==null?void 0:V.suggested)??"claude-code";u(M=>M??se),h(!0)}).catch(()=>{I||(u(V=>V??"claude-code"),h(!0))}),()=>{I=!0}},[d]);const g=m.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const I={agent:c};Ce.getSkills(I).then(V=>{s({type:"SET_SKILLS",skills:V});const M=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(M){const[,Y,G]=M,te=V.find(fe=>fe.plugin===Y&&fe.skill===G);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:G,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);m.useEffect(()=>{g()},[g]);const p=m.useCallback(I=>{s({type:"SELECT_SKILL",skill:I}),window.location.hash=`/skills/${I.plugin}/${I.skill}`},[]),y=m.useRef(a.skills);m.useEffect(()=>{y.current=a.skills},[a.skills]);const v=m.useCallback((I,V)=>{const se=y.current,M=I?se.find(te=>te.plugin===I&&te.skill===V):se.find(te=>te.skill===V&&te.source!=="plugin");if(!I&&!M){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(M==null?void 0:M.plugin)??I,G=(M==null?void 0:M.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:G}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=m.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=m.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=m.useCallback(I=>{s({type:"SET_MODE",mode:I})},[]),E=m.useCallback(I=>{s({type:"SET_SEARCH",query:I})},[]),C=m.useCallback(I=>{s({type:"SET_MOBILE_VIEW",view:I})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[D,F]=m.useState(""),w=m.useMemo(()=>a.skills.map(I=>`${I.plugin}/${I.skill}`),[a.skills]),O=m.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=uS({skillIds:O,trackingSkillIds:w}),U=m.useRef("");m.useEffect(()=>{const I=a.skills.filter(G=>G.origin==="installed");if(I.length===0){F(""),U.current="";return}const V=new Map;for(const G of z.updates)V.set(G.name.split("/").pop()||G.name,G);const se=I.map(G=>{const te=V.get(G.skill),fe=G.currentVersion??(te==null?void 0:te.installed)??G.version??G.pluginVersion??"0.0.0";return{plugin:G.plugin,skill:G.skill,name:(te==null?void 0:te.name)??G.skill,currentVersion:fe}}),M=se.map(G=>`${G.plugin}/${G.skill}@${G.currentVersion}#${G.name}`).sort().join("|");if(M===U.current)return;U.current=M;let Y=!1;return Ce.resolveInstalledSkillIds(se).then(G=>{if(Y)return;const ie=[...dS(G).flatMap(ye=>[ye.uuid,ye.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(G.map(ye=>[`${ye.plugin}/${ye.skill}`,{uuid:ye.uuid,slug:ye.slug}])),F(ie))}).catch(G=>{if(Y||(U.current=""),!B.current){B.current=!0;const te=G instanceof Error?G.message:String(G);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[a.skills,z.updates]);const H=m.useMemo(()=>{const I=a.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const se={...V};return delete se.updateAvailable,delete se.currentVersion,delete se.latestVersion,delete se.trackedForUpdates,se});return Zj(I,z.updates)},[a.skills,z.updates]),q=m.useMemo(()=>{const I={source:0,installed:0};for(const V of H)V.updateAvailable&&(I[V.origin]+=1);return I},[H]),X=m.useMemo(()=>({...a,skills:H}),[a,H]),J=z.updateCount,$=z.refresh,L=z.isRefreshing,_=m.useMemo(()=>({state:X,selectSkill:p,clearSelection:S,setMode:k,setSearch:E,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:L,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss}),[X,p,S,k,E,C,g,J,N,z.updates,q,L,$,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss]);return r.jsx(Nv.Provider,{value:_,children:t})}const hS={config:null,loading:!0};function xS(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 Tv=m.createContext(null);function Ha(){const t=m.useContext(Tv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function gS({children:t}){const[a,s]=m.useReducer(xS,hS),o=m.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{o()},[o]);const c=m.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=m.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:o}),[a,c,o]);return r.jsx(Tv.Provider,{value:u,children:t})}function vS({topRail:t,sidebar:a,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const p={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:p,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:y,children:[!g&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!g&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const qx=["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"},bS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},jS={"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"},SS={"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 kS(t,a){var h,g;const s=yS[t.id]??null,o=bS[t.id]??null,c=s?!!((h=a==null?void 0:a.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=a==null?void 0:a.binaries)!=null&&g[o]):!0,d=t.models.map(p=>({id:p.id,displayName:p.label,billingMode:SS[t.id]??"per-token",...p.pricing?{pricing:p.pricing}:{},...p.resolvedId?{resolvedId:p.resolvedId}:{}}));return{id:t.id,displayName:wS(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:jS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function wS(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 CS(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of qx){const c=a.get(o);c&&s.push(c)}for(const o of t)qx.includes(o.id)||s.push(o);return s}function ES(t){const[a,s]=m.useState(null),[o,c]=m.useState("loading"),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null),y=m.useRef(0),v=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=m.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=CS((A.providers||[]).map(D=>kS(D,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const k=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const D=await B.json();y.current=T,g(null),s(O=>{if(!O)return O;const z=O.agents.map(U=>{if(U.id!=="openrouter")return U;const H=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:H,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...O,agents:z}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((A=v.current)==null||A.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=m.useCallback(T=>{p.current=T,T==="openrouter"&&k()},[k]),C=m.useCallback(()=>{y.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var F,w;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let D=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(D=O.error)}catch{}(w=b.current)==null||w.call(b,D)},[]);return{status:o,catalog:a,error:u,openRouterError:h,focusAgent:E,refresh:C,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function jd({variant:t,label:a,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return r.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":a,...c?{title:c}:{},children:a})}function Xd({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 NS={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}`},TS={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"},RS={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"},AS={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"},MS={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"},LS={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"},zS={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."},DS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},_S={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},OS={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},BS={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"},IS={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)."}},US={subscriptionBilling:"· subscription",free:"· free"},HS={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`},$S={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.`},VS={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},PS={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.`},FS={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"},GS={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."},WS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},qS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:NS,shell:TS,detail:RS,actions:AS,palette:MS,shortcuts:LS,toasts:zS,connection:DS,forms:_S,errors:OS,picker:BS,providers:IS,models:US,settings:HS,statusBar:$S,scopePicker:VS,scopeSection:PS,claudeCodeLabel:FS,setupDrawer:GS,setupProviders:qS,scopeLabels:WS},YS=new Set(["claude-cli","claude-code"]);function Yx(t){return YS.has(t)}const Kx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function KS({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Kx.has(g.id)),h=t.filter(g=>!Kx.has(g.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>r.jsx(Xx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>r.jsx(Xx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Xx({agent:t,isActive:a,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},p=Yx(t.id),y={minHeight:36,height:p?"auto":36,padding:p?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),Yx(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),r.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?r.jsx(Xd,{unlocked:!0,size:10}):r.jsx(Xd,{size:10})}),a&&r.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(jd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&r.jsx(jd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(jd,{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 XS(t,a,s,o){const d=t>=80,h=m.useRef(null),[g,p]=m.useState(0),y=m.useCallback(S=>{p(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/a)-4),k=Math.ceil(s/a)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[d,g,a,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*a,offsetTop:v*a,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Rv=44,QS=352,ZS=60,Qx=480;function JS(t){var u,d;const a=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return a?`${a} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function e2(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 t2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>g(u),ZS);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&p.current&&p.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Qx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[r.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),r.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=m.useMemo(()=>e2(t.models,h),[t.models,h]),v=XS(y.length,Rv,QS);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Qx,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:p,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?r.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[r.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),r.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):r.jsx("div",{...v.containerProps,children:r.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return r.jsx(r2,{model:b,isActive:b.id===a,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function n2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function r2({model:t,isActive:a,isFocused:s,onSelect:o,resolvedModel:c}){const u=JS(t),d=n2(t.id,c,t.resolvedId),h=d!==null,g=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",p=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Rv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:p,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 Zx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function a2(){const[t,a]=m.useState(null),[s,o]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{o(!0);try{const p=await fetch("/api/settings/keys");if(!p.ok)throw new Error(`GET /api/settings/keys returned ${p.status}`);const y=await p.json();a({...Zx,...y}),u(null)}catch(p){u(p.message),a(Zx)}finally{o(!1)}},[]);m.useEffect(()=>{d()},[d]);const h=m.useCallback(async(p,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=m.useCallback(async p=>{const y=await fetch(`/api/settings/keys/${p}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${p} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function l2({onMigrated:t,fetchImpl:a}){const[s,o]=m.useState({kind:"loading"}),c=a??globalThis.fetch,u=m.useCallback(async()=>{var p;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((p=v.darwinKeys)==null?void 0:p.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{o({kind:"working"});try{const p=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!p.ok){o({kind:"error",message:`Migration failed (${p.status})`});return}const y=await p.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(p){o({kind:"error",message:p.message})}},[c,u,t]),h=m.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:Sd,children:"Retry"})]});const g=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...Sd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...Sd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Sd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},s2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function i2(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 Av({open:t,onClose:a,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=a2(),g=m.useRef(null),p=m.useRef(null),[y,v]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(E);C==null||C.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),a();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const C=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=m.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),r.jsx(l2,{onMigrated:()=>{h()}}),r.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),r.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[r.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),s2.map(S=>r.jsx(o2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?p:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Oa,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function o2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[p,y]=m.useState(""),[v,b]=m.useState(!1),[S,k]=m.useState(!1),[E,C]=m.useState(!1),[N,T]=m.useState(null),A=p.trim(),B=A.length===0,D=A.length>0&&!A.startsWith(o),F=m.useCallback(async()=>{if(B)return;k(!0);const z=A;y("");try{const U=await d(z);U.warning?T(U.warning):T(null)}finally{k(!1)}},[B,d,A]),w=m.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const U=await navigator.clipboard.readText();y(U)}catch{}},[]),O=m.useCallback(async()=>{C(!1),await h()},[h]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:g,type:v?"text":"password",value:p,onChange:z=>{y(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!v),style:Oa,children:v?ne.settings.hide:ne.settings.show}),r.jsx("button",{type:"button",onClick:w,style:Oa,children:ne.settings.paste})]}),D&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Jx,children:ne.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:Jx,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Oa,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Oa,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>C(!1),style:Oa,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Oa,color:"var(--text-muted)"},children:ne.settings.remove})}),r.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(i2(u.updatedAt)):ne.settings.noKey})]})]})}const Oa={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Jx={fontSize:11,color:"var(--warning, var(--text-muted))"};function c2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function u2({onToast:t}){const{status:a,catalog:s,focusAgent:o,setActive:c}=ES({onStaleCatalog:(U,H)=>{const q=Math.round(H/6e4);t==null||t(`Using cached ${U} catalog (${q} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(),[v,b]=m.useState(null),[S,k]=m.useState("agents"),[E,C]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var U;s&&!v&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(U=>U.id===v)??T[0],[T,v]);m.useEffect(()=>{C(0)},[v]);const B=m.useCallback(()=>{var U;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((U=T[0])==null?void 0:U.id)??null),C(0)},[s,T]),D=m.useCallback(()=>{var U;d(!1),(U=N.current)==null||U.focus()},[]);m.useEffect(()=>{const U=H=>{var X;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(H.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),m.useEffect(()=>{if(!u)return;const U=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),H(1);return}if(q.key==="ArrowUp"){q.preventDefault(),H(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)k("models"),C(0);else if(S==="models"&&A){const X=Math.max(0,Math.min(A.models.length-1,E)),J=A.models[X];J&&(c(A.id,J.id),D())}return}};function H(q){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&A){const X=A.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,T,v,A,E,D,o,c]);const F=m.useCallback(U=>{y(U==="anthropic"||U==="openrouter"?U:void 0),g(!0),d(!1)},[]),w=T.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=w==null?void 0:w.models.find(U=>U.id===(s==null?void 0:s.activeModel)),z=m.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const U=(w==null?void 0:w.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${H}`},[a,s,w,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:z})]}),u&&typeof document<"u"&&Go.createPortal(r.jsxs(d2,{reducedMotion:c2(),onClickOutside:D,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(KS,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),k("models")},onOpenSettings:F}),A&&r.jsx(t2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:U=>{c(A.id,U),D()},onOpenSettings:F})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),r.jsx(Av,{open:h,onClose:()=>g(!1),initialProvider:p,onToast:t})]})}function d2({children:t,reducedMotion:a,onClickOutside:s}){const o=m.useRef(null);return m.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
61
+ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=oa(),v;v=y;let b=v.pathname||"/",S=b;if(g!=="/"){let C=g.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=ov(t,{pathname:S});return Zn(m||k!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Zn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),nj(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:cr([g,o.encodeLocation?o.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?g:cr([g,o.encodeLocation?o.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s)}function Z0(){let t=ij(),a=I0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=p.createElement(p.Fragment,null,p.createElement("p",null,"💿 Hey developer 👋"),p.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",p.createElement("code",{style:u},"ErrorBoundary")," or"," ",p.createElement("code",{style:u},"errorElement")," prop on your route.")),p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},a),s?p.createElement("pre",{style:c},s):null,d)}var J0=p.createElement(Z0,null),yv=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=q0(t.digest);s&&(t=s)}let a=t!==void 0?p.createElement(Lr.Provider,{value:this.props.routeContext},p.createElement(mf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?p.createElement(ej,{error:t},a):a}};yv.contextType=$0;var xd=new WeakMap;function ej({children:t,error:a}){let{basename:s}=p.useContext(Gn);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let o=W0(a.digest);if(o){let c=xd.get(a);if(c)throw c;let u=pv(o.location,s);if(fv&&!xd.get(a))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw xd.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 o=p.useContext(Ol);return o&&o.static&&o.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=a.route.id),p.createElement(Lr.Provider,{value:t},s)}function nj(t,a=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(a.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Gt(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let d=!1,h=-1;if(s&&o){d=o.renderFallback;for(let y=0;y<c.length;y++){let v=c[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(h=y),v.route.id){let{loaderData:b,errors:S}=o,k=v.route.loader&&!b.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||k){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let g=s==null?void 0:s.onError,m=o&&g?(y,v)=>{var b,S;g(y,{location:o.location,params:((S=(b=o.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:U0(o.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,b)=>{let S,k=!1,E=null,C=null;o&&(S=u&&v.route.id?u[v.route.id]:void 0,E=v.route.errorElement||J0,d&&(h<0&&b===0?(bv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,C=null):h===b&&(k=!0,C=v.route.hydrateFallbackElement||null)));let N=a.concat(c.slice(0,b+1)),T=()=>{let A;return S?A=E:k?A=C:v.route.Component?A=p.createElement(v.route.Component,null):v.route.element?A=v.route.element:A=y,p.createElement(tj,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:o!=null},children:A})};return o&&(v.route.ErrorBoundary||v.route.errorElement||b===0)?p.createElement(yv,{location:o.location,revalidation:o.revalidation,component:E,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:m}):T()},null)}function hf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rj(t){let a=p.useContext(Ol);return Gt(a,hf(t)),a}function aj(t){let a=p.useContext(Vo);return Gt(a,hf(t)),a}function lj(t){let a=p.useContext(Lr);return Gt(a,hf(t)),a}function xf(t){let a=lj(t),s=a.matches[a.matches.length-1];return Gt(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function sj(){return xf("useRouteId")}function ij(){var o;let t=p.useContext(mf),a=aj("useRouteError"),s=xf("useRouteError");return t!==void 0?t:(o=a.errors)==null?void 0:o[s]}function oj(){let{router:t}=rj("useNavigate"),a=xf("useNavigate"),s=p.useRef(!1);return vv(()=>{s.current=!0}),p.useCallback(async(c,u={})=>{Zn(s.current,gv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var $x={};function bv(t,a,s){!a&&!$x[t]&&($x[t]=!0,Zn(!1,s))}p.memo(cj);function cj({routes:t,future:a,state:s,isStatic:o,onError:c}){return Q0(t,void 0,{state:s,isStatic:o,onError:c})}function uj({basename:t="/",children:a=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Gt(!Qs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),g=p.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=_l(s));let{pathname:m="/",search:y="",hash:v="",state:b=null,key:S="default",unstable_mask:k}=s,E=p.useMemo(()=>{let C=Mr(m,h);return C==null?null:{location:{pathname:C,search:y,hash:v,state:b,key:S,unstable_mask:k},navigationType:o}},[h,m,y,v,b,S,o,k]);return Zn(E!=null,`<Router basename="${h}"> is not able to match the URL "${m}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:p.createElement(Gn.Provider,{value:g},p.createElement(Po.Provider,{children:a,value:E}))}var Ro="get",Ao="application/x-www-form-urlencoded";function Fo(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function dj(t){return Fo(t)&&t.tagName.toLowerCase()==="button"}function fj(t){return Fo(t)&&t.tagName.toLowerCase()==="form"}function pj(t){return Fo(t)&&t.tagName.toLowerCase()==="input"}function mj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function hj(t,a){return t.button===0&&(!a||a==="_self")&&!mj(t)}var vo=null;function xj(){if(vo===null)try{new FormData(document.createElement("form"),0),vo=!1}catch{vo=!0}return vo}var gj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function gd(t){return t!=null&&!gj.has(t)?(Zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ao}"`),null):t}function vj(t,a){let s,o,c,u,d;if(fj(t)){let h=t.getAttribute("action");o=h?Mr(h,a):null,s=t.getAttribute("method")||Ro,c=gd(t.getAttribute("enctype"))||Ao,u=new FormData(t)}else if(dj(t)||pj(t)&&(t.type==="submit"||t.type==="image")){let h=t.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=t.getAttribute("formaction")||h.getAttribute("action");if(o=g?Mr(g,a):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||Ro,c=gd(t.getAttribute("formenctype"))||gd(h.getAttribute("enctype"))||Ao,u=new FormData(h,t),!xj()){let{name:m,type:y,value:v}=t;if(y==="image"){let b=m?`${m}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else m&&u.append(m,v)}}else{if(Fo(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Ro,o=null,c=Ao,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function gf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function yj(t,a,s,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:a&&Mr(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function bj(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 jj(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 Sj(t,a,s){let o=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await bj(u,s);return d.links?d.links():[]}return[]}));return Ej(o.flat(1).filter(jj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Vx(t,a,s,o,c,u){let d=(g,m)=>s[m]?g.route.id!==s[m].route.id:!0,h=(g,m)=>{var y;return s[m].pathname!==g.pathname||((y=s[m].route.path)==null?void 0:y.endsWith("*"))&&s[m].params["*"]!==g.params["*"]};return u==="assets"?a.filter((g,m)=>d(g,m)||h(g,m)):u==="data"?a.filter((g,m)=>{var v;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(d(g,m)||h(g,m))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(t,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function kj(t,a,{includeHydrateFallback:s}={}){return wj(t.map(o=>{let c=a.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function wj(t){return[...new Set(t)]}function Cj(t){let a={},s=Object.keys(t).sort();for(let o of s)a[o]=t[o];return a}function Ej(t,a){let s=new Set;return new Set(a),t.reduce((o,c)=>{let u=JSON.stringify(Cj(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function jv(){let t=p.useContext(Ol);return gf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Nj(){let t=p.useContext(Vo);return gf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var vf=p.createContext(void 0);vf.displayName="FrameworkContext";function Sv(){let t=p.useContext(vf);return gf(t,"You must render this element inside a <HydratedRouter> element"),t}function Tj(t,a){let s=p.useContext(vf),[o,c]=p.useState(!1),[u,d]=p.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:m,onMouseLeave:y,onTouchStart:v}=a,b=p.useRef(null);p.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let E=N=>{N.forEach(T=>{d(T.isIntersecting)})},C=new IntersectionObserver(E,{threshold:.5});return b.current&&C.observe(b.current),()=>{C.disconnect()}}},[t]),p.useEffect(()=>{if(o){let E=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(E)}}},[o]);let S=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Ls(h,S),onBlur:Ls(g,k),onMouseEnter:Ls(m,S),onMouseLeave:Ls(y,k),onTouchStart:Ls(v,S)}]:[!1,b,{}]}function Ls(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function Rj({page:t,...a}){let{router:s}=jv(),o=p.useMemo(()=>ov(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?p.createElement(Mj,{page:t,matches:o,...a}):null}function Aj(t){let{manifest:a,routeModules:s}=Sv(),[o,c]=p.useState([]);return p.useEffect(()=>{let u=!1;return Sj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),o}function Mj({page:t,matches:a,...s}){let o=oa(),{future:c,manifest:u,routeModules:d}=Sv(),{basename:h}=jv(),{loaderData:g,matches:m}=Nj(),y=p.useMemo(()=>Vx(t,a,m,u,o,"data"),[t,a,m,u,o]),v=p.useMemo(()=>Vx(t,a,m,u,o,"assets"),[t,a,m,u,o]),b=p.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let E=new Set,C=!1;if(a.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!y.some(D=>D.route.id===T.route.id)&&T.route.id in g&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?C=!0:E.add(T.route.id))}),E.size===0)return[];let N=yj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return C&&E.size>0&&N.searchParams.set("_routes",a.filter(T=>E.has(T.route.id)).map(T=>T.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,g,o,u,y,a,t,d]),S=p.useMemo(()=>kj(v,u),[v,u]),k=Aj(v);return p.createElement(p.Fragment,null,b.map(E=>p.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...s})),S.map(E=>p.createElement("link",{key:E,rel:"modulepreload",href:E,...s})),k.map(({key:E,link:C})=>p.createElement("link",{key:E,nonce:s.nonce,...C,crossOrigin:C.crossOrigin??s.crossOrigin})))}function Lj(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var zj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{zj&&(window.__reactRouterVersion="7.13.1")}catch{}function Dj({basename:t,children:a,unstable_useTransitions:s,window:o}){let c=p.useRef();c.current==null&&(c.current=m0({window:o,v5Compat:!0}));let u=c.current,[d,h]=p.useState({action:u.action,location:u.location}),g=p.useCallback(m=>{s===!1?h(m):p.startTransition(()=>h(m))},[s]);return p.useLayoutEffect(()=>u.listen(g),[u,g]),p.createElement(uj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var kv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wv=p.forwardRef(function({onClick:a,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:g,target:m,to:y,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:S,...k},E){let{basename:C,navigator:N,unstable_useTransitions:T}=p.useContext(Gn),A=typeof y=="string"&&kv.test(y),B=pv(y,C);y=B.to;let D=Y0(y,{relative:c}),F=oa(),w=null;if(h){let $=pf(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);C!=="/"&&($.pathname=$.pathname==="/"?C:cr([C,$.pathname])),w=N.createHref($)}let[O,z,U]=Tj(o,k),H=Ij(y,{replace:d,unstable_mask:h,state:g,target:m,preventScrollReset:v,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function q($){a&&a($),$.defaultPrevented||H($)}let X=!(B.isExternal||u),J=p.createElement("a",{...k,...U,href:(X?w:void 0)||B.absoluteURL||D,onClick:X?q:a,ref:Lj(E,z),target:m,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?p.createElement(p.Fragment,null,J,p.createElement(Rj,{page:D})):J});wv.displayName="Link";var _j=p.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:h,children:g,...m},y){let v=Zs(d,{relative:m.relative}),b=oa(),S=p.useContext(Vo),{navigator:k,basename:E}=p.useContext(Gn),C=S!=null&&Pj(v)&&h===!0,N=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,T=b.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(T=T.toLowerCase(),A=A?A.toLowerCase():null,N=N.toLowerCase()),A&&E&&(A=Mr(A,E)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let D=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",F=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),w={isActive:D,isPending:F,isTransitioning:C},O=D?a:void 0,z;typeof o=="function"?z=o(w):z=[o,D?"active":null,F?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let U=typeof u=="function"?u(w):u;return p.createElement(wv,{...m,"aria-current":O,className:z,ref:y,style:U,to:d,viewTransition:h},typeof g=="function"?g(w):g)});_j.displayName="NavLink";var Oj=p.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:o,replace:c,state:u,method:d=Ro,action:h,onSubmit:g,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b,...S},k)=>{let{unstable_useTransitions:E}=p.useContext(Gn),C=$j(),N=Vj(h,{relative:m}),T=d.toLowerCase()==="get"?"get":"post",A=typeof h=="string"&&kv.test(h),B=D=>{if(g&&g(D),D.defaultPrevented)return;D.preventDefault();let F=D.nativeEvent.submitter,w=(F==null?void 0:F.getAttribute("formmethod"))||d,O=()=>C(F||D.currentTarget,{fetcherKey:a,method:w,navigate:s,replace:c,state:u,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b});E&&s!==!1?p.startTransition(()=>O()):O()};return p.createElement("form",{ref:k,method:T,action:N,onSubmit:o?g:B,...S,"data-discover":!A&&t==="render"?"true":void 0})});Oj.displayName="Form";function Bj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Cv(t){let a=p.useContext(Ol);return Gt(a,Bj(t)),a}function Ij(t,{target:a,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:m}={}){let y=K0(),v=oa(),b=Zs(t,{relative:d});return p.useCallback(S=>{if(hj(S,a)){S.preventDefault();let k=s!==void 0?s:Ps(v)===Ps(b),E=()=>y(t,{replace:k,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g});m?p.startTransition(()=>E()):E()}},[v,y,b,s,o,c,a,t,u,d,h,g,m])}var Uj=0,Hj=()=>`__${String(++Uj)}__`;function $j(){let{router:t}=Cv("useSubmit"),{basename:a}=p.useContext(Gn),s=sj(),o=t.fetch,c=t.navigate;return p.useCallback(async(u,d={})=>{let{action:h,method:g,encType:m,formData:y,body:v}=vj(u,a);if(d.navigate===!1){let b=d.fetcherKey||Hj();await o(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||m,flushSync:d.flushSync})}else await c(d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||m,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,a,s])}function Vj(t,{relative:a}={}){let{basename:s}=p.useContext(Gn),o=p.useContext(Lr);Gt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Zs(t||".",{relative:a})},d=oa();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),g=h.getAll("index");if(g.some(y=>y==="")){h.delete("index"),g.filter(v=>v).forEach(v=>h.append("index",v));let y=h.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:cr([s,u.pathname])),Ps(u)}function Pj(t,{relative:a}={}){let s=p.useContext(hv);Gt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Cv("useViewTransitionState"),c=Zs(t,{relative:a});if(!s.isTransitioning)return!1;let u=Mr(s.currentLocation.pathname,o)||s.currentLocation.pathname,d=Mr(s.nextLocation.pathname,o)||s.nextLocation.pathname;return Oo(c.pathname,d)!=null||Oo(c.pathname,u)!=null}var Go=iv();const Fj=sv(Go),Gj="modulepreload",Wj=function(t){return"/"+t},Px={},Ha=function(a,s,o){let c=Promise.resolve();if(s&&s.length>0){let d=function(m){return Promise.all(m.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(m=>{if(m=Wj(m),m in Px)return;Px[m]=!0;const y=m.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${v}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":Gj,y||(b.as="script"),b.crossOrigin="",b.href=m,g&&b.setAttribute("nonce",g),document.head.appendChild(b),y)return new Promise((S,k)=>{b.addEventListener("load",S),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return c.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return a().catch(u)})},Fx={own:"authoring-project",installed:"available-project",global:"available-personal"},Yd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function qj(t){if(typeof t=="string"){if(Yd.has(t))return t;if(Object.prototype.hasOwnProperty.call(Fx,t))return Fx[t]}return"authoring-project"}function Yj(t){return t.startsWith("available-")?"available":"authoring"}function Kj(t){const a=t.indexOf("-");return t.slice(a+1)}const Vn="";class Us extends Error{constructor(a,s){super(a),this.name="ApiError",this.status=s}}async function Ve(t,a){const s=await fetch(`${Vn}${t}`,a);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Us(o.error||`HTTP ${s.status}`,s.status)}return s.json()}function tn(t){return typeof t=="string"&&t.length>0?t:null}function Xj(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function vd(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 Qj(t){const a=t??{};let s;a.origin==="source"||a.origin==="installed"?s=a.origin:(s="source",console.warn(`[api.getSkills] skill ${String(a.plugin)}/${String(a.skill)} has invalid origin=${JSON.stringify(a.origin)}; defaulting to 'source'`));let o;a.scope==="own"||a.scope==="installed"||a.scope==="global"?o=a.scope:o=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=o==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&Yd.has(a.scopeV2)?a.scopeV2:qj(a.scope),d=Yj(u),h=Kj(u),g=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let m;a.shadowedBy===null?m=null:typeof a.shadowedBy=="string"&&Yd.has(a.shadowedBy)?m=a.shadowedBy:m=void 0;const y={plugin:typeof a.plugin=="string"?a.plugin:"",skill:typeof a.skill=="string"?a.skill:"",dir:typeof a.dir=="string"?a.dir:"",hasEvals:!!a.hasEvals,hasBenchmark:!!a.hasBenchmark,evalCount:typeof a.evalCount=="number"?a.evalCount:0,assertionCount:typeof a.assertionCount=="number"?a.assertionCount:0,benchmarkStatus:a.benchmarkStatus==="pass"||a.benchmarkStatus==="fail"||a.benchmarkStatus==="pending"||a.benchmarkStatus==="stale"||a.benchmarkStatus==="missing"?a.benchmarkStatus:"missing",lastBenchmark:typeof a.lastBenchmark=="string"?a.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:tn(a.symlinkTarget),installMethod:c,scopeV2:u,group:d,source:h,pluginName:tn(a.pluginName),pluginNamespace:tn(a.pluginNamespace),pluginMarketplace:tn(a.pluginMarketplace),pluginManifestPath:tn(a.pluginManifestPath),pluginVersion:tn(a.pluginVersion),precedenceRank:g,shadowedBy:m,description:tn(a.description),version:tn(a.version),category:tn(a.category),author:tn(a.author),license:tn(a.license),homepage:tn(a.homepage),repoUrl:tn(a.repoUrl),skillPath:tn(a.skillPath),tags:vd(a.tags),deps:vd(a.deps),mcpDeps:vd(a.mcpDeps),entryPoint:tn(a.entryPoint),lastModified:tn(a.lastModified),sizeBytes:Xj(a.sizeBytes),sourceAgent:tn(a.sourceAgent)};if(a.provenance&&typeof a.provenance=="object"){const v=a.provenance;(v.promotedFrom==="installed"||v.promotedFrom==="global")&&typeof v.sourcePath=="string"&&typeof v.promotedAt=="number"?y.provenance={promotedFrom:v.promotedFrom,sourcePath:v.sourcePath,promotedAt:v.promotedAt,sourceSkillVersion:typeof v.sourceSkillVersion=="string"?v.sourceSkillVersion:void 0}:y.provenance=null}else a.provenance===null&&(y.provenance=null);return typeof a.updateAvailable=="boolean"&&(y.updateAvailable=a.updateAvailable),typeof a.currentVersion=="string"&&(y.currentVersion=a.currentVersion),typeof a.latestVersion=="string"&&(y.latestVersion=a.latestVersion),typeof a.pinnedVersion=="string"&&(y.pinnedVersion=a.pinnedVersion),y}const Ce={getConfig(){return Ve("/api/config")},setConfig(t,a){return Ve("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:a})})},async getSkills(t){const a=new URLSearchParams;t!=null&&t.scope&&a.set("scope",t.scope),t!=null&&t.agent&&a.set("agent",t.agent);const s=a.toString(),o=await Ve(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(Qj):[]},getAgents(){return Ve("/api/agents")},getSkillDetail(t,a){return Ve(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await Ve(`/api/skills/${t}/${a}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:a,evals:[]};const{exists:o,...c}=s;return c}return s},getEvalsEnvelope(t,a){return Ve(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return Ve(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return Ve(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return Ve(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${Vn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Us(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,s){const o=new URLSearchParams;s!=null&&s.model&&o.set("model",s.model),s!=null&&s.type&&o.set("type",s.type),s!=null&&s.from&&o.set("from",s.from),s!=null&&s.to&&o.set("to",s.to);const c=o.toString();return Ve(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return Ve(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,o){return Ve(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,a,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return Ve(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return Ve(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return Ve(`/api/skills/${t}/${a}`,{method:"DELETE"})},improveSkill(t,a,s){return Ve(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return Ve(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return Ve(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return Ve(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return Ve(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return Ve("/api/project-layout")},createSkill(t){return Ve("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return Ve("/api/studio/detect-engines")},saveDraft(t){return Ve("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return Ve("/api/skill-creator-status")},generateSkill(t){return Ve("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return Ve(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return Ve(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,o){return Ve(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},getLeaderboard(t,a){return Ve(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return Ve(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const o=`${Vn}/api/skills/${t}/${a}/sweep`,c=new EventSource(o);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,a){return Ve(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,o){return Ve(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,a){return Ve(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return Ve(`/api/credentials/${t}/${a}/params?${o}`)},searchModels(){return Ve("/api/openrouter/models")},async getSkillVersions(t,a){const s=await Ve(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return Ve(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,o){return Ve(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const a=`${Vn}/api/skills/batch-update`,s=new EventSource(a);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,a){const s=`${Vn}/api/skills/${t}/${a}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(t,a,s){const o=`${Vn}/api/skills/${t}/${a}/update`,c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},signal:s});let u,d="";if(c.body){const h=c.body.getReader(),g=new TextDecoder;let m=!1,y="";for(;!m;){const b=await h.read();if(m=b.done,b.value){const S=g.decode(b.value,{stream:!m});y+=S,d.length<200&&(d+=S)}}const v=y.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(v)try{u=JSON.parse(v[1]).version}catch{}d=d.slice(0,200)}else{const h=await c.text();d=h.slice(0,200);const g=h.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(g)try{u=JSON.parse(g[1]).version}catch{}}return{ok:c.ok,status:c.status,body:d,version:u}},async rescanSkill(t,a){const s=`${t}/${a}`,o=await fetch(`${Vn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const t=await fetch(`${Vn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const a=[...t].sort(),s=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(c=>({name:c,currentVersion:"0.0.0"}))})});if(!s.ok)return[];const o=await s.json().catch(()=>null);return Array.isArray(o)?o:o&&typeof o=="object"&&Array.isArray(o.results)?o.results.map(c=>({skillId:typeof c.skillId=="string"?c.skillId:typeof c.name=="string"?c.name:"",version:typeof c.version=="string"?c.version:typeof c.latest=="string"?c.latest:"",eventId:typeof c.eventId=="string"?c.eventId:"",publishedAt:typeof c.publishedAt=="string"?c.publishedAt:"",diffSummary:typeof c.diffSummary=="string"?c.diffSummary:void 0,trackedForUpdates:typeof c.trackedForUpdates=="boolean"?c.trackedForUpdates:void 0,updateAvailable:typeof c.updateAvailable=="boolean"?c.updateAvailable:void 0,installed:typeof c.installed=="string"?c.installed:void 0,latest:typeof c.latest=="string"?c.latest:void 0,name:typeof c.name=="string"?c.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const a=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!a.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await a.json().catch(()=>null),o=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(o.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,a,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return yd(`/api/skills/${t}/${a}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,s){const o=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&o.set("dest","global"),s!=null&&s.overwrite&&o.set("overwrite","true");const c=o.toString();return yd(`/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 yd(`/api/skills/${t}/${a}/revert`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},listStudioOps(t){const a=new URLSearchParams;(t==null?void 0:t.before)!=null&&a.set("before",String(t.before)),(t==null?void 0:t.limit)!=null&&a.set("limit",String(t.limit));const s=a.toString();return Ve(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return Ve(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Vn}/api/studio/ops/stream`)}};async function yd(t,a,s){const o=await fetch(`${Vn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let y=`HTTP ${o.status}`,v;try{const S=await o.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const b=new Us(y,o.status);throw v&&(b.code=v),b}const c=o.body.getReader(),u=new TextDecoder;let d="",h="",g=null,m=null;for(;;){const{done:y,value:v}=await c.read();if(y)break;d+=u.decode(v,{stream:!0});const b=d.split(`
62
+ `);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};a==null||a(E),E.type==="done"&&(g=E),E.type==="error"&&(m=E)}h=""}}if(m){const y=new Us(m.message,500);throw y.code=m.code,y}if(!g)throw new Us("Transfer stream ended without 'done' event",500);return g}function Zj(t,a){if(!a.length)return t;const s=new Map,o=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};return typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates),d})}function Jj(t){const[a,s]=p.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return p.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),a}const eS=500,Kd="vskill.updates.seenLastId";function tS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Kd)}catch{return null}}function bd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Kd):window.localStorage.setItem(Kd,t)}catch{}}function nS(){let t=new Map;const a=new Set,s=new Set,o=[];let c=tS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(a))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>eS){const g=o.shift();g&&s.delete(g)}c=h,bd(h)}}return{getSnapshot(){return t},subscribe(h){return a.add(h),()=>{a.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,bd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,bd(null),u()}}}const Da=nS(),rS=3e5,aS=500,lS=15e3,sS=6e4,iS=6e4,oS="/api/v1/skills/stream";function Gx(t){const a=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;a.set(o,s)}return a}function Wx(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function cS(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 uS(t){const a=(t==null?void 0:t.intervalMs)??rS,s=(t==null?void 0:t.debounceMs)??aS,o=(t==null?void 0:t.timeoutMs)??lS,c=(t==null?void 0:t.staleAfterMs)??sS,u=(t==null?void 0:t.disconnectFallbackMs)??iS,d=(t==null?void 0:t.streamUrlBase)??oS,h=p.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=p.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[m,y]=p.useState([]),[v,b]=p.useState(()=>new Map),[S,k]=p.useState(0),[E,C]=p.useState(!1),[N,T]=p.useState(null),[A,B]=p.useState(null),D=p.useRef(null),F=p.useRef(null),w=p.useRef(null),O=p.useRef(null),z=p.useRef(!0),[U,H]=p.useState(()=>h?"connecting":"fallback"),q=p.useRef(U);q.current=U;const X=p.useSyncExternalStore(M=>Da.subscribe(M),()=>Da.getSnapshot(),()=>Da.getSnapshot()),J=X.size,$=p.useCallback(async()=>{C(!0);const M=new AbortController,Y=setTimeout(()=>M.abort(),o);try{const G=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{M.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(G==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(G),b(Gx(G)),k(Wx(G)),F.current=Date.now(),T(F.current),B(null)}catch(G){if(!z.current)return;B(G instanceof Error?G:new Error(String(G)))}finally{clearTimeout(Y),z.current&&C(!1)}},[o]),L=p.useCallback(()=>{if(D.current)return D.current;const M=$().finally(()=>{D.current=null});return D.current=M,M},[$]),_=p.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{L()},a))},[a,L]),I=p.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);p.useEffect(()=>{z.current=!0,(F.current==null||Date.now()-F.current>c)&&L(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const G=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){I();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&L(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",G),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",G),O.current&&clearTimeout(O.current),I()}},[]);const V=p.useCallback(async M=>{if(M.length!==0)try{const Y=await Ce.checkSkillUpdates(M);if(!z.current||Y.length===0)return;const G=Date.now(),te=Y.filter(oe=>oe.skillId&&oe.eventId&&oe.version).map(oe=>({skillId:oe.skillId,version:oe.version,eventId:oe.eventId,publishedAt:oe.publishedAt,diffSummary:oe.diffSummary,receivedAt:G}));te.length>0&&Da.mergeBulk(te);const fe=Y.filter(oe=>typeof oe.trackedForUpdates=="boolean"||typeof oe.updateAvailable=="boolean").map(oe=>({name:oe.name??oe.skillId,installed:oe.installed??"",latest:oe.latest??null,updateAvailable:oe.updateAvailable??!1,trackedForUpdates:typeof oe.trackedForUpdates=="boolean"?oe.trackedForUpdates:void 0}));fe.length>0&&y(oe=>{const ve=new Map;for(const Re of oe)ve.set(Re.name.split("/").pop()||Re.name,Re);let de=0;for(const Re of fe){const _e=Re.name.split("/").pop()||Re.name,ae=ve.get(_e);if(ae){const he={...ae};ae.trackedForUpdates===void 0&&Re.trackedForUpdates!==void 0&&(he.trackedForUpdates=Re.trackedForUpdates),ve.set(_e,he)}else ve.set(_e,{name:Re.name,installed:Re.installed??"",latest:Re.latest??null,updateAvailable:Re.updateAvailable??!1,trackedForUpdates:Re.trackedForUpdates}),de+=1}if(de===0&&ve.size===oe.length)return oe;const je=[...ve.values()];return b(Gx(je)),k(Wx(je)),je})}catch{}},[]);p.useEffect(()=>{const M=h||g;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const Y=M.split(","),G=`${d}?skills=${encodeURIComponent(M)}`;let te=null,fe=null,oe=null;const ve=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,z.current&&q.current!=="connected"&&H("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ve();const je=1e3,Re=()=>{z.current&&oe==null&&(oe=setTimeout(()=>{if(oe=null,!!z.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},je))},_e=pe=>{if(!z.current)return;let xe;try{xe=JSON.parse(pe.data)}catch{return}if(!cS(xe)||Da.ingest(xe)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${xe.skillId} updated to ${xe.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:xe.skillId,version:xe.version,eventId:xe.eventId}}))}},ae=()=>{z.current&&(Da.clearSeen(),V(Y))},he=()=>{z.current&&(te=new EventSource(G),te.onopen=()=>{z.current&&(de(),H("connected"))},te.onerror=()=>{z.current&&(ve(),te&&te.readyState===EventSource.CLOSED&&Re())},te.onmessage=_e,te.addEventListener("gone",ae))};return he(),()=>{if(de(),oe!=null&&(clearTimeout(oe),oe=null),te){try{te.removeEventListener("gone",ae)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),p.useEffect(()=>{if(!g)return;const M=g.split(",");V(M)},[g,V]);const ie=p.useCallback(M=>{Da.dismiss(M)},[]);return{updates:m,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:L,updatesById:X,pushUpdateCount:J,status:U,dismiss:ie}}function dS(t){const a=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const fS={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 Ev=p.createContext(null),Nv=Ev;function er(){const t=p.useContext(Nv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function mS({children:t}){const[a,s]=p.useReducer(pS,fS),o=Jj("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=p.useState(()=>{try{const I=window.localStorage.getItem("vskill.studio.prefs");if(!I)return null;const V=JSON.parse(I);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=p.useState(c!==null);p.useEffect(()=>{function I(V){if(!(V instanceof CustomEvent))return;const ie=V.detail;ie!=null&&ie.agentId&&(u(ie.agentId),h(!0))}return window.addEventListener("studio:agent-changed",I),()=>window.removeEventListener("studio:agent-changed",I)},[]),p.useEffect(()=>{if(d)return;let I=!1;return Ce.getAgents().then(V=>{if(I)return;const ie=(V==null?void 0:V.suggested)??"claude-code";u(M=>M??ie),h(!0)}).catch(()=>{I||(u(V=>V??"claude-code"),h(!0))}),()=>{I=!0}},[d]);const g=p.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const I={agent:c};Ce.getSkills(I).then(V=>{s({type:"SET_SKILLS",skills:V});const M=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(M){const[,Y,G]=M,te=V.find(fe=>fe.plugin===Y&&fe.skill===G);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:G,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);p.useEffect(()=>{g()},[g]);const m=p.useCallback(I=>{s({type:"SELECT_SKILL",skill:I}),window.location.hash=`/skills/${I.plugin}/${I.skill}`},[]),y=p.useRef(a.skills);p.useEffect(()=>{y.current=a.skills},[a.skills]);const v=p.useCallback((I,V)=>{const ie=y.current,M=I?ie.find(te=>te.plugin===I&&te.skill===V):ie.find(te=>te.skill===V&&te.source!=="plugin");if(!I&&!M){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(M==null?void 0:M.plugin)??I,G=(M==null?void 0:M.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:G}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=p.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=p.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=p.useCallback(I=>{s({type:"SET_MODE",mode:I})},[]),E=p.useCallback(I=>{s({type:"SET_SEARCH",query:I})},[]),C=p.useCallback(I=>{s({type:"SET_MOBILE_VIEW",view:I})},[]),N=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=p.useRef(new Map),A=p.useRef(""),B=p.useRef(!1),[D,F]=p.useState(""),w=p.useMemo(()=>a.skills.map(I=>`${I.plugin}/${I.skill}`),[a.skills]),O=p.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=uS({skillIds:O,trackingSkillIds:w}),U=p.useRef("");p.useEffect(()=>{const I=a.skills.filter(G=>G.origin==="installed");if(I.length===0){F(""),U.current="";return}const V=new Map;for(const G of z.updates)V.set(G.name.split("/").pop()||G.name,G);const ie=I.map(G=>{const te=V.get(G.skill),fe=G.currentVersion??(te==null?void 0:te.installed)??G.version??G.pluginVersion??"0.0.0";return{plugin:G.plugin,skill:G.skill,name:(te==null?void 0:te.name)??G.skill,currentVersion:fe}}),M=ie.map(G=>`${G.plugin}/${G.skill}@${G.currentVersion}#${G.name}`).sort().join("|");if(M===U.current)return;U.current=M;let Y=!1;return Ce.resolveInstalledSkillIds(ie).then(G=>{if(Y)return;const oe=[...dS(G).flatMap(ve=>[ve.uuid,ve.slug].filter(Boolean))].sort().join(",");oe!==A.current&&(A.current=oe,T.current=new Map(G.map(ve=>[`${ve.plugin}/${ve.skill}`,{uuid:ve.uuid,slug:ve.slug}])),F(oe))}).catch(G=>{if(Y||(U.current=""),!B.current){B.current=!0;const te=G instanceof Error?G.message:String(G);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[a.skills,z.updates]);const H=p.useMemo(()=>{const I=a.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const ie={...V};return delete ie.updateAvailable,delete ie.currentVersion,delete ie.latestVersion,delete ie.trackedForUpdates,ie});return Zj(I,z.updates)},[a.skills,z.updates]),q=p.useMemo(()=>{const I={source:0,installed:0};for(const V of H)V.updateAvailable&&(I[V.origin]+=1);return I},[H]),X=p.useMemo(()=>({...a,skills:H}),[a,H]),J=z.updateCount,$=z.refresh,L=z.isRefreshing,_=p.useMemo(()=>({state:X,selectSkill:m,clearSelection:S,setMode:k,setSearch:E,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:L,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss}),[X,m,S,k,E,C,g,J,N,z.updates,q,L,$,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss]);return r.jsx(Nv.Provider,{value:_,children:t})}const hS={config:null,loading:!0};function xS(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 Tv=p.createContext(null);function $a(){const t=p.useContext(Tv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function gS({children:t}){const[a,s]=p.useReducer(xS,hS),o=p.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{o()},[o]);const c=p.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=p.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:o}),[a,c,o]);return r.jsx(Tv.Provider,{value:u,children:t})}function vS({topRail:t,sidebar:a,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const m={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:m,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:y,children:[!g&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!g&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const qx=["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"},bS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},jS={"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"},SS={"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 kS(t,a){var h,g;const s=yS[t.id]??null,o=bS[t.id]??null,c=s?!!((h=a==null?void 0:a.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=a==null?void 0:a.binaries)!=null&&g[o]):!0,d=t.models.map(m=>({id:m.id,displayName:m.label,billingMode:SS[t.id]??"per-token",...m.pricing?{pricing:m.pricing}:{},...m.resolvedId?{resolvedId:m.resolvedId}:{}}));return{id:t.id,displayName:wS(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:jS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function wS(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 CS(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of qx){const c=a.get(o);c&&s.push(c)}for(const o of t)qx.includes(o.id)||s.push(o);return s}function ES(t){const[a,s]=p.useState(null),[o,c]=p.useState("loading"),[u,d]=p.useState(null),[h,g]=p.useState(null),m=p.useRef(null),y=p.useRef(0),v=p.useRef(t==null?void 0:t.onStaleCatalog),b=p.useRef(t==null?void 0:t.onSetActiveError);p.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=p.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=CS((A.providers||[]).map(D=>kS(D,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);p.useEffect(()=>{S()},[S]);const k=p.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const D=await B.json();y.current=T,g(null),s(O=>{if(!O)return O;const z=O.agents.map(U=>{if(U.id!=="openrouter")return U;const H=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:H,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...O,agents:z}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((A=v.current)==null||A.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=p.useCallback(T=>{m.current=T,T==="openrouter"&&k()},[k]),C=p.useCallback(()=>{y.current=0,S()},[S]),N=p.useCallback(async(T,A)=>{var F,w;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let D=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(D=O.error)}catch{}(w=b.current)==null||w.call(b,D)},[]);return{status:o,catalog:a,error:u,openRouterError:h,focusAgent:E,refresh:C,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function jd({variant:t,label:a,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return r.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":a,...c?{title:c}:{},children:a})}function Xd({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 NS={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}`},TS={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"},RS={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"},AS={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"},MS={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"},LS={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"},zS={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."},DS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},_S={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},OS={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},BS={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"},IS={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)."}},US={subscriptionBilling:"· subscription",free:"· free"},HS={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`},$S={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.`},VS={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},PS={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.`},FS={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"},GS={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."},WS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},qS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:NS,shell:TS,detail:RS,actions:AS,palette:MS,shortcuts:LS,toasts:zS,connection:DS,forms:_S,errors:OS,picker:BS,providers:IS,models:US,settings:HS,statusBar:$S,scopePicker:VS,scopeSection:PS,claudeCodeLabel:FS,setupDrawer:GS,setupProviders:qS,scopeLabels:WS},YS=new Set(["claude-cli","claude-code"]);function Yx(t){return YS.has(t)}const Kx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function KS({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Kx.has(g.id)),h=t.filter(g=>!Kx.has(g.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>r.jsx(Xx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>r.jsx(Xx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Xx({agent:t,isActive:a,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},m=Yx(t.id),y={minHeight:36,height:m?"auto":36,padding:m?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),Yx(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),r.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?r.jsx(Xd,{unlocked:!0,size:10}):r.jsx(Xd,{size:10})}),a&&r.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(jd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&r.jsx(jd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(jd,{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 XS(t,a,s,o){const d=t>=80,h=p.useRef(null),[g,m]=p.useState(0),y=p.useCallback(S=>{m(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=p.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/a)-4),k=Math.ceil(s/a)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[d,g,a,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*a,offsetTop:v*a,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Rv=44,QS=352,ZS=60,Qx=480;function JS(t){var u,d;const a=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return a?`${a} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function e2(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 t2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=p.useState(""),[h,g]=p.useState(""),m=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>g(u),ZS);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:Qx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[r.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),r.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=p.useMemo(()=>e2(t.models,h),[t.models,h]),v=XS(y.length,Rv,QS);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Qx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&r.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:r.jsx("input",{ref:m,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?r.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[r.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),r.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):r.jsx("div",{...v.containerProps,children:r.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return r.jsx(r2,{model:b,isActive:b.id===a,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function n2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function r2({model:t,isActive:a,isFocused:s,onSelect:o,resolvedModel:c}){const u=JS(t),d=n2(t.id,c,t.resolvedId),h=d!==null,g=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",m=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Rv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:m,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[r.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&r.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Zx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function a2(){const[t,a]=p.useState(null),[s,o]=p.useState(!0),[c,u]=p.useState(null),d=p.useCallback(async()=>{o(!0);try{const m=await fetch("/api/settings/keys");if(!m.ok)throw new Error(`GET /api/settings/keys returned ${m.status}`);const y=await m.json();a({...Zx,...y}),u(null)}catch(m){u(m.message),a(Zx)}finally{o(!1)}},[]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async(m,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:m,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=p.useCallback(async m=>{const y=await fetch(`/api/settings/keys/${m}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${m} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function l2({onMigrated:t,fetchImpl:a}){const[s,o]=p.useState({kind:"loading"}),c=a??globalThis.fetch,u=p.useCallback(async()=>{var m;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((m=v.darwinKeys)==null?void 0:m.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);p.useEffect(()=>{u()},[u]);const d=p.useCallback(async()=>{o({kind:"working"});try{const m=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!m.ok){o({kind:"error",message:`Migration failed (${m.status})`});return}const y=await m.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(m){o({kind:"error",message:m.message})}},[c,u,t]),h=p.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:Sd,children:"Retry"})]});const g=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...Sd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...Sd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Sd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},s2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function i2(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 Av({open:t,onClose:a,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=a2(),g=p.useRef(null),m=p.useRef(null),[y,v]=p.useState(null);p.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),p.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(E);C==null||C.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),p.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),a();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const C=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=p.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),r.jsx(l2,{onMigrated:()=>{h()}}),r.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),r.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[r.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),s2.map(S=>r.jsx(o2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?m:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Oa,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function o2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[m,y]=p.useState(""),[v,b]=p.useState(!1),[S,k]=p.useState(!1),[E,C]=p.useState(!1),[N,T]=p.useState(null),A=m.trim(),B=A.length===0,D=A.length>0&&!A.startsWith(o),F=p.useCallback(async()=>{if(B)return;k(!0);const z=A;y("");try{const U=await d(z);U.warning?T(U.warning):T(null)}finally{k(!1)}},[B,d,A]),w=p.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const U=await navigator.clipboard.readText();y(U)}catch{}},[]),O=p.useCallback(async()=>{C(!1),await h()},[h]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:g,type:v?"text":"password",value:m,onChange:z=>{y(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!v),style:Oa,children:v?ne.settings.hide:ne.settings.show}),r.jsx("button",{type:"button",onClick:w,style:Oa,children:ne.settings.paste})]}),D&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Jx,children:ne.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:Jx,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Oa,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Oa,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>C(!1),style:Oa,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Oa,color:"var(--text-muted)"},children:ne.settings.remove})}),r.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(i2(u.updatedAt)):ne.settings.noKey})]})]})}const Oa={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Jx={fontSize:11,color:"var(--warning, var(--text-muted))"};function c2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function u2({onToast:t}){const{status:a,catalog:s,focusAgent:o,setActive:c}=ES({onStaleCatalog:(U,H)=>{const q=Math.round(H/6e4);t==null||t(`Using cached ${U} catalog (${q} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[m,y]=p.useState(),[v,b]=p.useState(null),[S,k]=p.useState("agents"),[E,C]=p.useState(0),N=p.useRef(null);p.useRef(null),p.useEffect(()=>{var U;s&&!v&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=p.useMemo(()=>T.find(U=>U.id===v)??T[0],[T,v]);p.useEffect(()=>{C(0)},[v]);const B=p.useCallback(()=>{var U;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((U=T[0])==null?void 0:U.id)??null),C(0)},[s,T]),D=p.useCallback(()=>{var U;d(!1),(U=N.current)==null||U.focus()},[]);p.useEffect(()=>{const U=H=>{var X;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(H.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),p.useEffect(()=>{if(!u)return;const U=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),H(1);return}if(q.key==="ArrowUp"){q.preventDefault(),H(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)k("models"),C(0);else if(S==="models"&&A){const X=Math.max(0,Math.min(A.models.length-1,E)),J=A.models[X];J&&(c(A.id,J.id),D())}return}};function H(q){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&A){const X=A.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,T,v,A,E,D,o,c]);const F=p.useCallback(U=>{y(U==="anthropic"||U==="openrouter"?U:void 0),g(!0),d(!1)},[]),w=T.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=w==null?void 0:w.models.find(U=>U.id===(s==null?void 0:s.activeModel)),z=p.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const U=(w==null?void 0:w.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${H}`},[a,s,w,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:z})]}),u&&typeof document<"u"&&Go.createPortal(r.jsxs(d2,{reducedMotion:c2(),onClickOutside:D,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(KS,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),k("models")},onOpenSettings:F}),A&&r.jsx(t2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:U=>{c(A.id,U),D()},onOpenSettings:F})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),r.jsx(Av,{open:h,onClose:()=>g(!1),initialProvider:m,onToast:t})]})}function d2({children:t,reducedMotion:a,onClickOutside:s}){const o=p.useRef(null);return p.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
63
63
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
64
64
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
65
- }`})]})}function eg(){typeof window>"u"||(window.location.hash="#/")}function f2({onHome:t}){const[a,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),eg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),eg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const p2="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",m2=m.lazy(()=>Qs(()=>import("./UpdateDropdown-Dw9BDVCE.js"),__vite__mapDeps([0,1])));function h2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=er(),d=m.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,C]of u)C.diffSummary&&k.set(E,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=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:p,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),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:v,cursor:"pointer"},children:[r.jsx("img",{src:p2,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:b})]}),h&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(m2,{updates:a,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),C=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function tg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function x2({projectName:t,selected:a,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(f2,{onHome:o}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&d&&r.jsxs(r.Fragment,{children:[r.jsx(ng,{segment:"origin",onClick:()=>tg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),r.jsx(rg,{}),r.jsx(ng,{segment:"plugin",onClick:()=>tg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(rg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&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(u2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(h2,{})}),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 ng({segment:t,onClick:a,style:s,children:o}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function rg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Wo="vskill-theme";function Mv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function g2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function v2(t){try{const a=t.getItem(Wo);return Mv(a)}catch{return"auto"}}function y2(t,a){try{t.setItem(Wo,a)}catch{}}function b2(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 Lv=m.createContext(null);function S2({storage:t,matchMedia:a,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?v2(c):"auto"),[p,y]=m.useState(()=>j2(u)),v=m.useMemo(()=>g2(h,p),[h,p]);m.useEffect(()=>{d&&b2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Wo&&g(Mv(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=m.useCallback(k=>{g(k),c&&y2(c,k)},[c]),S=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(Lv.Provider,{value:S,children:o})}function zv(){const t=m.useContext(Lv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function k2(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=a.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function w2(t){const[a,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),a}function C2({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const o=k2(t),c=w2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?a==null||a(g.id):s==null||s(g.id)},[a,s]);if(c){const g=o.filter(p=>p.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>r.jsx(lg,{p,onClick:h},p.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>r.jsx(lg,{p:g,onClick:h,compact:!0},g.id))})}function lg({p:t,onClick:a,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(Xd,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function E2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Wo)}catch{return null}}function N2({projectPath:t,modelName:a,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=zv(),v=E2()==="auto",b=T2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(sg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(R2,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(sg,{}),r.jsx(C2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(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(A2,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function T2(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function R2({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function sg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function A2({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 Qd=new Set;function Dv(){for(const t of Qd)t()}const M2=5,L2=1e3,z2=6e4;function D2(){const[t,a]=m.useState(void 0),[s,o]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),h=m.useRef(null),g=m.useRef(null),p=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=m.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=m.useCallback(async()=>{if(!p.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!p.current)return;const A=await T.json();if(!p.current)return;d.current=0,a(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{p.current&&b(B=>B+1)},z2)}catch(T){if(!p.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>M2){o(!0);return}const A=L2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{p.current&&b(B=>B+1)},A)}},[k]);m.useEffect(()=>(p.current=!0,()=>{p.current=!1,S(),k()}),[k]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=m.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(Qd.add(C),()=>{Qd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const qo=0,ca=1,_l=2,_v=4;function ig(t){return()=>t}function _2(t){t()}function Ov(t,a){return s=>t(a(s))}function og(t,a){return()=>t(a)}function O2(t,a){return s=>t(a,s)}function yf(t){return t!==void 0}function B2(...t){return()=>{t.map(_2)}}function Ol(){}function Yo(t,a){return a(t),t}function I2(t,a){return a(t)}function jt(...t){return t}function rt(t,a){return t(ca,a)}function Pe(t,a){t(qo,a)}function bf(t){t(_l)}function wt(t){return t(_v)}function Re(t,a){return rt(t,O2(a,qo))}function Qn(t,a){const s=t(ca,o=>{s(),a(o)});return s}function cg(t){let a,s;return o=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{o(a)},t)}}function Bv(t,a){return t===a}function bt(t=Bv){let a;return s=>o=>{t(a,o)||(a=o,s(o))}}function De(t){return a=>s=>{t(s)&&a(s)}}function ke(t){return a=>Ov(a,t)}function ir(t){return a=>()=>{a(t)}}function me(t,...a){const s=U2(...a);return((o,c)=>{switch(o){case _l:bf(t);return;case ca:return rt(t,s(c))}})}function or(t,a){return s=>o=>{s(a=t(a,o))}}function Ua(t){return a=>s=>{t>0?t--:a(s)}}function Ar(t){let a=null,s;return o=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,o(a)},t))}}function Fe(...t){const a=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,g=>{const p=s;s|=h,a[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():o=h}}function U2(...t){return a=>t.reduceRight(I2,a)}function H2(t){let a,s;const o=()=>a==null?void 0:a();return function(c,u){switch(c){case ca:return u?s===u?void 0:(o(),s=u,a=rt(t,u),a):(o(),Ol);case _l:o(),s=null;return}}}function ve(t){let a=t;const s=Xe();return((o,c)=>{switch(o){case qo:a=c;break;case ca:{c(a);break}case _v:return a}return s(o,c)})}function nn(t,a){return Yo(ve(a),s=>Re(t,s))}function Xe(){const t=[];return((a,s)=>{switch(a){case qo:t.slice().forEach(o=>{o(s)});return;case _l:t.splice(0,t.length);return;case ca:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return Yo(Xe(),a=>Re(t,a))}function et(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:$2(),singleton:s}}const $2=()=>Symbol();function V2(t){const a=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=o(c.map(g=>s(g)));return d&&a.set(u,h),h};return s(t)}function Ut(...t){const a=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,g=>{s[d]=g,o|=h,o===c&&Pe(a,s)})}),function(u,d){switch(u){case _l:{bf(a);return}case ca:return o===c&&d(s),rt(a,d)}}}function ze(t,a=Bv){return me(t,bt(a))}function Zd(...t){return function(a,s){switch(a){case _l:return;case ca:return B2(...t.map(o=>rt(o,s)))}}}const Pt={DEBUG:0,INFO:1,WARN:2,ERROR:3},P2={[Pt.DEBUG]:"debug",[Pt.ERROR]:"error",[Pt.INFO]:"log",[Pt.WARN]:"warn"},F2=()=>typeof globalThis>"u"?window:globalThis,ua=et(()=>{const t=ve(Pt.ERROR);return{log:ve((a,s,o=Pt.INFO)=>{const c=F2().VIRTUOSO_LOG_LEVEL??wt(t);o>=c&&console[P2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function $a(t,a,s){return jf(t,a,s).callbackRef}function jf(t,a,s){const o=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function G2(t,a,s,o,c,u,d,h,g){const p=Te.useCallback(y=>{const v=W2(y.children,a,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?ug("column-gap",getComputedStyle(y).columnGap,c):ug("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,o,h]);return jf(p,s,g)}function W2(t,a,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Pt.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function ug(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Pt.WARN),a==="normal"?0:parseInt(a??"0",10)}function Iv(t,a,s){const o=Te.useRef(null),c=Te.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(a){const S=a.getBoundingClientRect(),k=p.top-S.top;b=S.height-Math.max(0,k),v=k+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,p.top),v=p.top+S.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,a]),{callbackRef:u,ref:d}=jf(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var p;if(a){a.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(a),()=>{a.removeEventListener("scroll",h),y.unobserve(a)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,a,d]),u}const cn=et(()=>{const t=Xe(),a=Xe(),s=ve(0),o=Xe(),c=ve(0),u=Xe(),d=Xe(),h=ve(0),g=ve(0),p=ve(0),y=ve(0),v=Xe(),b=Xe(),S=ve(!1),k=ve(!1),E=ve(!1);return Re(me(t,ke(({scrollTop:C})=>C)),a),Re(me(t,ke(({scrollHeight:C})=>C)),d),Re(a,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Vs={lvl:0};function Uv(t,a){const s=t.length;if(s===0)return[];let{index:o,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=a(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ft(t){return t===Vs}function Ps(t,a){if(!ft(t))return a===t.k?t.v:a<t.k?Ps(t.l,a):Ps(t.r,a)}function Jn(t,a,s="k"){if(ft(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const o=Jn(t.r,a,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,a,s)}function En(t,a,s){return ft(t)?Vv(a,s,1):a===t.k?Vt(t,{k:a,v:s}):a<t.k?dg(Vt(t,{l:En(t.l,a,s)})):dg(Vt(t,{r:En(t.r,a,s)}))}function Rl(){return Vs}function Al(t,a,s){if(ft(t))return[];const o=Jn(t,a)[0];return q2(ef(t,o,s))}function Jd(t,a){if(ft(t))return Vs;const{k:s,l:o,r:c}=t;if(a===s){if(ft(o))return c;if(ft(c))return o;const[u,d]=$v(o);return Mo(Vt(t,{k:u,l:Hv(o),v:d}))}return a<s?Mo(Vt(t,{l:Jd(o,a)})):Mo(Vt(t,{r:Jd(c,a)}))}function Ia(t){return ft(t)?[]:[...Ia(t.l),{k:t.k,v:t.v},...Ia(t.r)]}function ef(t,a,s){if(ft(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>a&&(h=h.concat(ef(c,a,s))),o>=a&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(ef(u,a,s))),h}function Mo(t){const{l:a,lvl:s,r:o}=t;if(o.lvl>=s-1&&a.lvl>=s-1)return t;if(s>o.lvl+1){if(kd(a))return Pv(Vt(t,{lvl:s-1}));if(!ft(a)&&!ft(a.r))return Vt(a.r,{l:Vt(a,{r:a.r.l}),lvl:s,r:Vt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(kd(t))return tf(Vt(t,{lvl:s-1}));if(!ft(o)&&!ft(o.l)){const c=o.l,u=kd(c)?o.lvl-1:o.lvl;return Vt(c,{l:Vt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:tf(Vt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Vt(t,a){return Vv(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 Hv(t){return ft(t.r)?t.l:Mo(Vt(t,{r:Hv(t.r)}))}function kd(t){return ft(t)||t.lvl>t.r.lvl}function $v(t){return ft(t.r)?[t.k,t.v]:$v(t.r)}function Vv(t,a,s,o=Vs,c=Vs){return{k:t,l:o,lvl:s,r:c,v:a}}function dg(t){return tf(Pv(t))}function Pv(t){const{l:a}=t;return!ft(a)&&a.lvl===t.lvl?Vt(a,{r:Vt(t,{l:a.r})}):t}function tf(t){const{lvl:a,r:s}=t;return!ft(s)&&!ft(s.r)&&s.lvl===a&&s.r.lvl===a?Vt(s,{l:Vt(t,{r:s.l}),lvl:a+1}):t}function q2(t){return Uv(t,({k:a,v:s})=>({index:a,value:s}))}function Fv(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Fs(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Sf=et(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function Gv(t,a,s){return t[Bo(t,a,s)]}function Bo(t,a,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Y2(t,a,s,o){const c=Bo(t,a,o),u=Bo(t,s,o,c);return t.slice(c,u+1)}function ia(t,a){return Math.round(t.getBoundingClientRect()[a])}function Ko(t){return!ft(t.groupOffsetTree)}function kf({index:t},a){return a===t?0:a<t?-1:1}function K2(){return{groupIndices:[],groupOffsetTree:Rl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rl()}}function X2(t,a){let s=ft(t)?0:1/0;for(const o of a){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ft(t)){t=En(t,0,u);continue}const h=Al(t,d-1,c+1);if(h.some(rk(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Jd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));p&&(t=En(t,d,u))}return[t,s]}function Q2(t){return typeof t.groupIndex<"u"}function Z2({offset:t},a){return a===t?0:a<t?-1:1}function Gs(t,a,s){if(a.length===0)return 0;const{index:o,offset:c,size:u}=Gv(a,t,kf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Wv(t,a){if(!Ko(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function qv(t,a,s){if(Q2(t))return a.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Wv(o,a);return c=Math.max(0,c,Math.min(s,c)),c}function J2(t,a,s,o=0){return o>0&&(a=Math.max(a,Gv(t,o,kf).offset)),Uv(Y2(t,a,s,Z2),nk)}function ek(t,[a,s,o,c]){a.length>0&&o("received item sizes",a,Pt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ft(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=X2(d,a);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=nf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,Gs(S,v,c)),Rl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function tk(t){return Ia(t).map(({k:a,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function fg(t,a){let s=0,o=0;for(;s<t;)s+=a[o+1]-a[o]-1,o++;return o-(s===t?0:1)}function nf(t,a,s,o){let c=t,u=0,d=0,h=0,g=0;if(a!==0){g=Bo(c,a-1,kf),h=c[g].offset;const p=Jn(s,a-1);u=p[0],d=p[1],c.length&&c[g].size===Jn(s,a)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of Al(s,a,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function nk(t){return{index:t.index,value:t}}function rk(t){const{endIndex:a,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===a||c.end===1/0)&&c.value===s}const ak={offsetHeight:"height",offsetWidth:"width"},ur=et(([{log:t},{recalcInProgress:a}])=>{const s=Xe(),o=Xe(),c=nn(o,0),u=Xe(),d=Xe(),h=ve(0),g=ve([]),p=ve(void 0),y=ve(void 0),v=ve(void 0),b=ve(void 0),S=ve((w,O)=>ia(w,ak[O])),k=ve(void 0),E=ve(0),C=K2(),N=nn(me(s,Fe(g,t,E),or(ek,C),bt()),C),T=nn(me(g,bt(),or((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Re(me(g,De(w=>w.length>0),Fe(N,E),ke(([w,O,z])=>{const U=w.reduce((H,q,X)=>En(H,q,Gs(q,O.offsetTree,z)||X),Rl());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Re(me(o,Fe(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:w}])),s),Re(p,y);const A=nn(me(p,ke(w=>w===void 0)),!0);Re(me(y,De(w=>w!==void 0&&ft(wt(N).sizeTree)),ke(w=>{const O=wt(v),z=wt(g).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(me(b,De(w=>w!==void 0&&w.length>0&&ft(wt(N).sizeTree)),ke(w=>{const O=[];let z=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==z&&(O.push({endIndex:H-1,size:z,startIndex:U}),z=q,U=H)}return O.push({endIndex:w.length-1,size:z,startIndex:U}),O})),s),Re(me(g,Fe(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,z])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:z})}return U})),s);const B=Nn(me(s,Fe(N),or(({sizes:w},[O,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:C}),ke(w=>w.changed)));rt(me(h,or((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=wt(N);if(w>0)Pe(a,!0),Pe(u,w+fg(w,O));else if(w<0){const z=wt(T);z.length>0&&(w-=fg(-w,z)),Pe(d,w)}}),rt(me(h,Fe(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Pt.ERROR)});const D=Nn(u);Re(me(u,Fe(N),ke(([w,O])=>{const z=O.groupIndices.length>0,U=[],H=O.lastSize;if(z){const q=Ps(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ia(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ia(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Fe(N,E),ke(([w,{offsetTree:O},z])=>{const U=-w;return Gs(U,O,z)})));return Re(me(d,Fe(N,E),ke(([w,O,z])=>{if(O.groupIndices.length>0){if(ft(O.sizeTree))return O;let H=Rl();const q=wt(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ia(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Ps(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...nf(O.offsetTree,0,H,z)}}const U=Ia(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Rl());return{...O,sizeTree:U,...nf(O.offsetTree,0,U,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},jt(ua,Sf),{singleton:!0});function lk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const Yv=et(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),d=Xe(),h=Nn(me(u,ke(lk)));return Re(me(h,ke(g=>g.totalCount)),s),Re(me(h,ke(g=>g.groupIndices)),t),Re(me(Ut(c,a,o),De(([g,p])=>Ko(p)),ke(([g,p,y])=>Jn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),bt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},jt(ur,cn)),da=et(([{log:t}])=>{const a=ve(!1),s=Nn(me(a,De(o=>o),bt()));return rt(a,o=>{o&&wt(t)("props updated",{},Pt.DEBUG)}),{didMount:s,propsReady:a}},jt(ua),{singleton:!0}),sk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Kv(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!sk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const Zs=et(([{gap:t,listRefresh:a,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Xe(),k=Xe(),E=ve(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Pe(g,!1)}return Re(me(S,Fe(s,v,o,E,h,d,b),Fe(t,u,c),ke(([[B,D,F,w,O,z,U,H],q,X,J])=>{const $=Kv(B),{align:L,behavior:_,offset:I}=$,V=w-1,se=qv($,D,V);let M=Gs(se,D.offsetTree,q)+z;L==="end"?(M+=X+Jn(D.sizeTree,se)[1]-F+J,se===V&&(M+=U)):L==="center"?M+=(X+Jn(D.sizeTree,se)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=G=>{A(),G?(H("retrying to scroll to",{location:B},Pt.DEBUG),Pe(S,B)):(Pe(k,!0),H("list did not change, scroll successful",{},Pt.DEBUG))};if(A(),_==="smooth"){let G=!1;T=rt(a,te=>{G=G||te}),C=Qn(y,()=>{Y(G)})}else C=Qn(me(a,ik(150)),Y);return N=setTimeout(()=>{A()},1200),Pe(g,!0),H("scrolling from index to",{behavior:_,index:se,top:M},Pt.DEBUG),{behavior:_,top:M}})),p),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},jt(ur,cn,ua),{singleton:!0});function ik(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return o=>{o&&(a(!0),clearTimeout(s))}}}function wf(t,a){t===0?a():requestAnimationFrame(()=>{wf(t-1,a)})}function Cf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Js=et(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ve(!0),g=ve(0),p=ve(!0);return Re(me(d,Fe(g),De(([y,v])=>v!==0),ir(!1)),h),Re(me(d,Fe(g),De(([y,v])=>v!==0),ir(!1)),p),rt(me(Ut(a,d),Fe(h,s,t,p),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!ft(b)||yf(S))&&!v&&!k),Fe(g)),([,y])=>{Qn(c,()=>{Pe(p,!0)}),wf(4,()=>{Qn(o,()=>{Pe(h,!0)}),Pe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},jt(ur,cn,Zs,da),{singleton:!0});function Xv(t,a){return Math.abs(t-a)<1.01}const Ws="up",Is="down",ok="none",ck={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},uk=0,ei=et(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ve(!1),h=ve(!0),g=Xe(),p=Xe(),y=ve(4),v=ve(uk),b=nn(me(Zd(me(ze(c),Ua(1),ir(!0)),me(ze(c),Ua(1),ir(!1),cg(100))),bt()),!1),S=nn(me(Zd(me(s,ir(!0)),me(s,ir(!1),cg(200))),bt()),!1);Re(me(Ut(ze(c),ze(v)),ke(([T,A])=>T<=A),bt()),h),Re(me(h,Ar(50)),p);const k=Nn(me(Ut(o,ze(u),ze(a),ze(t),ze(y)),or((T,[{scrollHeight:A,scrollTop:B},D,F,w,O])=>{const z=B+D-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":D<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},ck),bt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=nn(me(o,or((T,{scrollHeight:A,scrollTop:B,viewportHeight:D})=>{if(!Xv(T.scrollHeight,A)){const F=A-(B+D)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Re(me(k,ke(T=>T.atBottom)),d),Re(me(d,Ar(50)),g);const C=ve(Is);Re(me(o,ke(({scrollTop:T})=>T),bt(),or((T,A)=>wt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Ws:Is,prevScrollTop:A},{direction:Is,prevScrollTop:0}),ke(T=>T.direction)),C),Re(me(o,Ar(50),ir(ok)),C);const N=ve(0);return Re(me(b,De(T=>!T),ir(0)),N),Re(me(c,Ar(100),Fe(b),De(([T,A])=>A),or(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},jt(cn)),qs="top",Ys="bottom",pg="none";function mg(t,a,s){return typeof t=="number"?s===Ws&&a===qs||s===Is&&a===Ys?t:0:s===Ws?a===qs?t.main:t.reverse:a===Ys?t.main:t.reverse}function hg(t,a){return typeof t=="number"?t:t[a]??0}const Ef=et(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),d=ve(0),h=ve(0),g=ve(0),p=nn(me(Ut(ze(o),ze(c),ze(s),ze(u,Fs),ze(g),ze(d),ze(a),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,D=C+N,F=Math.max(b-B,0);let w=pg;const O=hg(A,qs),z=hg(A,Ys);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+D-O&&(w=Ws),k<y-F+v+z&&(w=Is),w!==pg?[Math.max(B-b-mg(E,qs,w)-O,0),B-F-N+v+mg(E,Ys,w)+z]:null}),De(y=>y!==null),bt(Fs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},jt(cn),{singleton:!0});function dk(t,a,s){if(Ko(a)){const o=Wv(t,a);return[{index:Jn(a.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const wd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Lo(t,a,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=p,k=b-y;return{bottom:y,firstItemIndex:u,items:xg(t,c,u),offsetBottom:k,offsetTop:p,top:S,topItems:xg(a,c,u),topListHeight:a.reduce((E,C)=>C.size+E,0),totalCount:s}}function Qv(t,a,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=Cf(a,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Lo(p,[],h,c,s,o)}function xg(t,a,s){if(t.length===0)return[];if(!Ko(a))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Al(a.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=a.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function gg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Va=et(([{data:t,firstItemIndex:a,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ve([]),C=ve(0),N=Xe(),T=ve(0);Re(u.topItemsIndexes,E);const A=nn(me(Ut(S,k,ze(g,Fs),ze(c),ze(o),ze(p),y,ze(E),ze(a),ze(s),ze(T),t),De(([w,O,,z,,,,,,,,U])=>{const H=U!==void 0&&U.length!==z;return w&&!O&&!H}),ke(([,,[w,O],z,U,H,q,X,J,$,L,_])=>{var Se,Ae;const I=U,{offsetTree:V,sizeTree:se}=I,M=wt(C);if(z===0)return{...wd,totalCount:z};if(w===0&&O===0)return M===0?{...wd,totalCount:z}:Qv(M,H,U,J,$,_||[]);if(ft(se))return M>0?null:Lo(dk(Cf(H,z),I,_),[],z,$,I,J);const Y=[];if(X.length>0){const _e=X[0],ae=X[X.length-1];let he=0;for(const pe of Al(se,_e,ae)){const ge=pe.value,je=Math.max(pe.start,_e),Be=Math.min(pe.end,ae);for(let Oe=je;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:ge}),he+=ge}}if(!q)return Lo([],Y,z,$,I,J);const G=X.length>0?X[X.length-1]+1:0,te=J2(V,w,O,G);if(te.length===0)return null;const fe=z-1,ie=Yo([],_e=>{for(const ae of te){const he=ae.value;let pe=he.offset,ge=ae.start;const je=he.size;if(he.offset<w){ge+=Math.floor((w-he.offset+$)/(je+$));const Oe=ge-ae.start;pe+=Oe*je+Oe*$}ge<G&&(pe+=(G-ge)*je,ge=G);const Be=Math.min(ae.end,fe);for(let Oe=ge;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:je}),pe+=je+$}}),ye=gg(L,qs),de=gg(L,Ys);if(ie.length>0&&(ye>0||de>0)){const _e=ie[0],ae=ie[ie.length-1];if(ye>0&&_e.index>G){const he=Math.min(ye,_e.index-G),pe=[];let ge=_e.offset;for(let je=_e.index-1;je>=_e.index-he;je--){const Be=((Se=Al(se,je,je)[0])==null?void 0:Se.value)??_e.size;ge-=Be+$,pe.unshift({data:_==null?void 0:_[je],index:je,offset:ge,size:Be})}ie.unshift(...pe)}if(de>0&&ae.index<fe){const he=Math.min(de,fe-ae.index);let pe=ae.offset+ae.size+$;for(let ge=ae.index+1;ge<=ae.index+he;ge++){const je=((Ae=Al(se,ge,ge)[0])==null?void 0:Ae.value)??ae.size;ie.push({data:_==null?void 0:_[ge],index:ge,offset:pe,size:je}),pe+=je+$}}}return Lo(ie,Y,z,$,I,J)}),De(w=>w!==null),bt()),wd);Re(me(t,De(yf),ke(w=>w==null?void 0:w.length)),c),Re(me(A,ke(w=>w.topListHeight)),v),Re(v,h),Re(me(A,ke(w=>[w.top,w.bottom])),d),Re(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Fe(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),bt(Fs),ke(([w])=>w))),D=Nn(me(A,Ar(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),bt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,z=w.length-1;for(;w[O].type==="group"&&O<z;)O++;for(;w[z].type==="group"&&z>O;)z--;return{endIndex:w[z].index,startIndex:w[O].index}}),bt(Fv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:D,topItemsIndexes:E,...b}},jt(ur,Yv,Ef,Js,Zs,ei,da,Sf),{singleton:!0}),Zv=et(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),d=nn(me(Ut(s,t,o,a,c),ke(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Re(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},jt(cn,Va),{singleton:!0}),fk=et(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ve(!1),o=nn(me(Ut(s,t,a),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Ar(0),bt()),0);return{alignToBottom:s,paddingTopAddition:o}},jt(cn,Zv),{singleton:!0}),Jv=et(()=>({context:ve(null)})),pk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,ey=et(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Xe();return Re(me(y,Fe(a,g,s,u,c,o,h),Fe(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=pk,done:D,...F}=v,w=qv(v,b,k-1),O=Gs(w,b.offsetTree,A)+E+C,z=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:z,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?D&&Qn(me(d,De(X=>!X),Ua(wt(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),p),{scrollIntoView:y}},jt(ur,cn,Zs,Va,ua),{singleton:!0});function vg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const mk=(t,a)=>typeof t=="function"?vg(t(a)):a&&vg(t),hk=et(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ve(!1),E=Xe();let C=null;function N(D){Pe(d,{align:"end",behavior:D,index:"LAST"})}rt(me(Ut(me(ze(a),Ua(1)),g),Fe(ze(k),u,h,v),ke(([[D,F],w,O,z,U])=>{let H=F&&z,q="auto";return H&&(q=mk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D)}):C=Qn(t,()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D),C=null})});function T(D){const F=Qn(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(wt(y)("scrolling to bottom due to increased size",{},Pt.DEBUG),N("auto"))});setTimeout(F,100)}rt(me(Ut(ze(k),a,p),De(([D,,F])=>D!==!1&&F),or(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Fe(k,a)),([,D])=>{wt(h)&&T(D!==!1)}),rt(E,()=>{T(wt(k)!==!1)}),rt(Ut(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ve(null),B=Xe();return Re(Zd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(a))),B),rt(me(Ut(me(B,Ua(1)),g),Fe(ze(A),h,v,b),ke(([[D,F],w,O,z,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Ar(0)),D=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("scrolling into view",{}),Pe(S,D)}):C=Qn(t,()=>{wt(y)("scrolling into view",{}),Pe(S,D),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},jt(ur,ei,Zs,Js,da,ua,cn,Jv,ey)),xk=et(([{data:t,firstItemIndex:a,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(me(h,Fe(u),De(([,g])=>g!==0),Fe(c,o,a,s,t),ke(([[,g],p,y,v,b,S=[]])=>Qv(g,p,y,v,b,S))),d),{}),jt(ur,Js,Va,da),{singleton:!0}),gk=et(([{didMount:t},{scrollTo:a},{listState:s}])=>{const o=ve(0);return rt(me(t,Fe(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ua(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(a,c)})})}),{initialScrollTop:o}},jt(da,cn,Va),{singleton:!0}),ty=et(([{scrollVelocity:t}])=>{const a=ve(!1),s=Xe(),o=ve(!1);return Re(me(t,Fe(o,a,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),bt()),a),rt(me(Ut(a,t,s),Fe(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},jt(ei),{singleton:!0}),Nf=et(([{scrollContainerState:t,scrollTo:a}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ve(!1),d=ve(void 0);return Re(me(Ut(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Re(me(a,Fe(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},jt(cn)),vk=et(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Xe(),y=ve(void 0),v=ve(null),b=ve(null);return Re(h,v),Re(g,b),rt(me(p,Fe(a,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=tk(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Re(me(y,De(yf),ke(yk)),c),Re(me(u,Fe(y),De(([,S])=>S!==void 0),bt(),ke(([,S])=>S.ranges)),t),{getState:p,restoreStateFrom:y}},jt(ur,cn,Js,da,Nf));function yk(t){return{align:"start",index:0,offset:t.scrollTop}}const bk=et(([{topItemsIndexes:t}])=>{const a=ve(0);return Re(me(a,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:a}},jt(Va));function ny(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const jk=ny(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sk=et(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Fe(d),or(([,N,T,A],[{bottom:B,items:D,offsetBottom:F,totalCount:w},O])=>{const z=B+F;let U=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(U=z-A,U!==0&&(U+=O))),[U,D,w,z]},[0,[],0,0]),De(([N])=>N!==0),Fe(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Ws),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Pt.DEBUG),N))));function C(N){N>0?(Pe(a,{behavior:"auto",top:-N}),Pe(t,0)):(Pe(t,0),Pe(a,{behavior:"auto",top:-N}))}return rt(me(E,Fe(t,u)),([N,T,A])=>{A&&jk()?Pe(t,T-N):C(-N)}),rt(me(Ut(nn(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Ar(1)),C),Re(me(v,ke(N=>({top:-N}))),a),rt(me(p,Fe(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},D])=>{function F(H){return H*(A+D)}if(T.length===0)return F(N);let w=0;const O=Ps(B,0);let z=0,U=0;for(;z<N;){z++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;z+H>N&&(w-=O,H=N-z+1),z+=H,w+=F(H),U++}return w})),N=>{Pe(t,N),requestAnimationFrame(()=>{Pe(a,{top:N}),requestAnimationFrame(()=>{Pe(t,0),Pe(k,!1)})})}),{deviation:t}},jt(cn,ei,Va,ur,ua,Sf)),kk=et(([t,a,s,o,c,u,d,h,g,p,y])=>({...t,...a,...s,...o,...c,...u,...d,...h,...g,...p,...y}),jt(Ef,xk,da,ty,Zv,gk,fk,Nf,ey,ua,Jv)),ry=et(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:D},F,{topItemCount:w},{groupCounts:O},z])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Re(X,z.scrollSeekRangeChanged),Re(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:p,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...T}},jt(ur,Js,cn,vk,hk,Va,Zs,Sk,bk,Yv,kk));function wk(t,a){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(o,d)||(s[d]=a[d]);return s}const yo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function ay(t,a,s){const o=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Te.createContext({});function g(C,N){C.propsReady!==void 0&&Pe(C.propsReady,!1);for(const T of o){const A=C[a.required[T]];Pe(A,N[T])}for(const T of c)if(T in N){const A=C[a.optional[T]];Pe(A,N[T])}C.propsReady!==void 0&&Pe(C.propsReady,!0)}function p(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[a.methods[T]];Pe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=H2(C[a.events[T]]),N),{})}const v=Te.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Te.useState(()=>Yo(V2(t),w=>{g(w,A)})),[D]=Te.useState(og(y,B));yo(()=>{for(const w of d)w in A&&rt(D[w],A[w]);return()=>{Object.values(D).map(bf)}},[A,D,B]),yo(()=>{g(B,A)}),Te.useImperativeHandle(N,ig(p(B)));const F=s;return r.jsx(h.Provider,{value:B,children:s!==void 0?r.jsx(F,{...wk([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Te.useContext(h);return Te.useCallback(T=>{Pe(N[C],T)},[N,C])},S=C=>{const N=Te.useContext(h)[C],T=Te.useCallback(A=>rt(N,A),[N]);return Te.useSyncExternalStore(T,()=>wt(N),()=>wt(N))},k=C=>{const N=Te.useContext(h)[C],[T,A]=Te.useState(og(wt,N));return yo(()=>rt(N,B=>{B!==T&&A(ig(B))}),[N,T]),T},E=parseInt(Te.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Te.useContext(h)[C];yo(()=>rt(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const ly=Te.createContext(void 0),sy=Te.createContext(void 0),Cd="-webkit-sticky",yg="sticky",Tf=ny(()=>{if(typeof document>"u")return yg;const t=document.createElement("div");return t.style.position=Cd,t.style.position===Cd?Cd:yg}),iy=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Ed(t){return"self"in t}function Ck(t){return"body"in t}function oy(t,a,s,o=Ol,c,u){const d=Te.useRef(null),h=Te.useRef(null),g=Te.useRef(null),p=Te.useCallback(b=>{let S,k,E;const C=b.target;if(Ck(C)||Ed(C)){const T=Ed(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Fj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,a(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,a,u]);Te.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Ed(S)?(C=Math.max(ia(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ia(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Xv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&a(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Rf(t){return t}const Ek=et(()=>{const t=ve(h=>`Item ${h}`),a=ve(h=>`Group ${h}`),s=ve({}),o=ve(Rf),c=ve("div"),u=ve(Ol),d=(h,g=null)=>nn(me(s,ke(p=>p[h]),bt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),Nk=et(([t,a])=>({...t,...a}),jt(ry,Ek)),Tk=({height:t})=>r.jsx("div",{style:{height:t}}),Rk={overflowAnchor:"none",position:Tf(),zIndex:1},cy={overflowAnchor:"none"},Ak={...cy,display:"inline-block",height:"100%"},bg=Te.memo(function({showTopList:t=!1}){const a=Ue("listState"),s=Pn("sizeRanges"),o=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=Ue("itemContent"),p=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),k=Pn("gap"),E=Ue("horizontalDirection"),{callbackRef:C}=G2(s,b,v,t?Ol:h,S,k,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Af("deviation",J=>{N!==J&&T(J)});const A=Ue("EmptyPlaceholder"),B=Ue("ScrollSeekPlaceholder")??Tk,D=Ue("ListComponent"),F=Ue("ItemComponent"),w=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),U=Ue("groupIndices").length>0,H=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...tn(A,p)}):r.jsx(D,{...tn(D,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?a.topItems:a.items).map(J=>{const $=J.originalIndex,L=O($+a.firstItemIndex,J.data,p);return z?m.createElement(B,{...tn(B,p),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?m.createElement(w,{...tn(w,p),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:Rk},y(J.index,p)):m.createElement(F,{...tn(F,p),...Dk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Ak:cy},U?g(J.index,J.groupIndex,J.data,p):g(J.index,J.data,p))})})}),Mk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Lk={outline:"none",overflowX:"auto",position:"relative"},Xo=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),zk={position:Tf(),top:0,width:"100%",zIndex:1};function tn(t,a){if(typeof t!="string")return{context:a}}function Dk(t,a){return{item:typeof t=="string"?void 0:a}}const _k=Te.memo(function(){const t=Ue("HeaderComponent"),a=Pn("headerHeight"),s=Ue("HeaderFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),Ok=Te.memo(function(){const t=Ue("FooterComponent"),a=Pn("footerHeight"),s=Ue("HeaderFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null});function uy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=a("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=oy(h,p,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),r.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Lk:Mk,...c},tabIndex:0,...d,...tn(g,u),children:o})})}function dy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=a("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Te.useRef(null),k=a("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=oy(h,p,g,k,b);return iy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...tn(g,u),children:o})})}const Bk=({children:t})=>{const a=Te.useContext(ly),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>Ov(s,g=>ia(g,u?"width":"height")),[s,u]),h=$a(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{a&&(s(a.viewportHeight),o(a.itemHeight))},[a,s,o]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:Xo(c),children:t})},Ik=({children:t})=>{const a=Te.useContext(ly),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=Ue("customScrollParent"),u=Iv(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{a&&(o(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,o]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:Xo(d),children:t})},Uk=({children:t})=>{const a=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),o={...zk,marginTop:`${s}px`},c=Ue("context");return r.jsx(a,{style:o,...tn(a,c),children:t})},Hk=Te.memo(function(t){const a=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,o=Ue("customScrollParent"),c=Ue("context");return r.jsxs(o||a?Pk:Vk,{...t,context:c,children:[s&&r.jsx(Uk,{children:r.jsx(bg,{showTopList:!0})}),r.jsxs(o||a?Ik:Bk,{children:[r.jsx(_k,{}),r.jsx(bg,{}),r.jsx(Ok,{})]})]})}),{Component:$k,useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}=ay(Nk,{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"}},Hk),Vk=uy({useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}),Pk=dy({useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}),Fk=$k,Gk=et(()=>{const t=ve(p=>r.jsxs("td",{children:["Item $",p]})),a=ve(null),s=ve(p=>r.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ve(null),c=ve(null),u=ve({}),d=ve(Rf),h=ve(Ol),g=(p,y=null)=>nn(me(u,ke(v=>v[p]),bt()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});jt(ry,Gk);Tf();const jg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Wk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Sg,floor:Io,max:Us,min:Nd,round:kg}=Math;function wg(t,a,s){return Array.from({length:a-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function qk(t){return{...Wk,items:t}}function bo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Yk(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Kk=et(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},D])=>{const F=ve(0),w=ve(0),O=ve(jg),z=ve({height:0,width:0}),U=ve({height:0,width:0}),H=Xe(),q=Xe(),X=ve(0),J=ve(null),$=ve({column:0,row:0}),L=Xe(),_=Xe(),I=ve(!1),V=ve(0),se=ve(!0),M=ve(!1),Y=ve(!1);rt(me(k,Fe(V),De(([de,Se])=>Se!==0)),()=>{Pe(se,!1)}),rt(me(Ut(k,se,U,z,V,M),De(([de,Se,Ae,_e,,ae])=>de&&!Se&&Ae.height!==0&&_e.height!==0&&!ae)),([,,,,de])=>{Pe(M,!0),wf(1,()=>{Pe(H,de)}),Qn(me(p),()=>{Pe(a,[0,0]),Pe(se,!0)})}),Re(me(_,De(de=>de!=null&&de.scrollTop>0),ir(0)),w),rt(me(k,Fe(_),De(([,de])=>de!=null)),([,de])=>{de&&(Pe(z,de.viewport),Pe(U,de.item),Pe($,de.gap),de.scrollTop>0&&(Pe(I,!0),Qn(me(p,Ua(1)),Se=>{Pe(I,!1)}),Pe(g,{top:de.scrollTop})))}),Re(me(z,ke(({height:de})=>de)),v),Re(me(Ut(ze(z,bo),ze(U,bo),ze($,(de,Se)=>de!==void 0&&de.column===Se.column&&de.row===Se.row),ze(p)),ke(([de,Se,Ae,_e])=>({gap:Ae,item:Se,scrollTop:_e,viewport:de}))),L),Re(me(Ut(ze(F),o,ze($,Yk),ze(U,bo),ze(z,bo),ze(J),ze(w),ze(I),ze(se),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[Se,Ae],_e,ae,he,pe,ge,,je,Be])=>{const{column:Oe,row:at}=_e,{height:Nt,width:ht}=ae,{width:Dt}=he;if(ge===0&&(de===0||Dt===0))return jg;if(ht===0){const Gt=Cf(Be,de),rn=Gt+Math.max(ge-1,0);return qk(wg(Gt,rn,pe))}const Tt=fy(Dt,ht,Oe);let Qe,tt;je?Se===0&&Ae===0&&ge>0?(Qe=0,tt=ge-1):(Qe=Tt*Io((Se+at)/(Nt+at)),tt=Tt*Sg((Ae+at)/(Nt+at))-1,tt=Nd(de-1,Us(tt,Tt-1)),Qe=Nd(tt,Us(0,Qe))):(Qe=0,tt=-1);const be=wg(Qe,tt,pe),{bottom:pt,top:Ct}=Cg(he,_e,ae,be),Yt=Sg(de/Tt),un=Yt*Nt+(Yt-1)*at-pt;return{bottom:pt,itemHeight:Nt,items:be,itemWidth:ht,offsetBottom:un,offsetTop:Ct,top:Ct}})),O),Re(me(J,De(de=>de!==null),ke(de=>de.length)),F),Re(me(Ut(z,U,O,$),De(([de,Se,{items:Ae}])=>Ae.length>0&&Se.height!==0&&de.height!==0),ke(([de,Se,{items:Ae},_e])=>{const{bottom:ae,top:he}=Cg(de,_e,Se,Ae);return[he,ae]}),bt(Fs)),a);const G=ve(!1);Re(me(p,Fe(G),ke(([de,Se])=>Se||de!==0)),G);const te=Nn(me(Ut(O,F),De(([{items:de}])=>de.length>0),Fe(G),De(([[de,Se],Ae])=>{const _e=de.items[de.items.length-1].index===Se-1;return(Ae||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===Se)&&_e}),ke(([[,de]])=>de-1),bt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ir(0),bt())),ie=Nn(me(ze(O),Fe(I),De(([{items:de},Se])=>de.length>0&&!Se),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),bt(Fv),Ar(0)));Re(ie,S.scrollSeekRangeChanged),Re(me(H,Fe(z,U,F,$),ke(([de,Se,Ae,_e,ae])=>{const he=Kv(de),{align:pe,behavior:ge,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=Us(0,Be,Nd(_e-1,Be));let Oe=rf(Se,ae,Ae,Be);return pe==="end"?Oe=kg(Oe-Se.height+Ae.height):pe==="center"&&(Oe=kg(Oe-Se.height/2+Ae.height/2)),je!==void 0&&je!==0&&(Oe+=je),{behavior:ge,top:Oe}})),g);const ye=nn(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Re(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ye,...b,endReached:te,propsReady:E,rangeChanged:ie,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...D}},jt(Ef,cn,ei,ty,da,Nf,ua));function fy(t,a,s){return Us(1,Io((t+s)/(Io(a)+s)))}function Cg(t,a,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=rf(t,a,s,o[0].index);return{bottom:rf(t,a,s,o[o.length-1].index)+c,top:u}}function rf(t,a,s,o){const c=fy(t.width,s.width,a.column),u=Io(o/c),d=u*s.height+Us(0,u-1)*a.row;return d>0?d+a.row:d}const Xk=et(()=>{const t=ve(v=>`Item ${v}`),a=ve({}),s=ve(null),o=ve("virtuoso-grid-item"),c=ve("virtuoso-grid-list"),u=ve(Rf),d=ve("div"),h=ve(Ol),g=(v,b=null)=>nn(me(a,ke(S=>S[v]),bt()),b),p=ve(!1),y=ve(!1);return Re(ze(y),p),{components:a,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Qk=et(([t,a])=>({...t,...a}),jt(Kk,Xk)),Zk=Te.memo(function(){const t=kt("gridState"),a=kt("listClassName"),s=kt("itemClassName"),o=kt("itemContent"),c=kt("computeItemKey"),u=kt("isSeeking"),d=Fn("scrollHeight"),h=kt("ItemComponent"),g=kt("ListComponent"),p=kt("ScrollSeekPlaceholder"),y=kt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=kt("log"),k=kt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=$a(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:D}=A.getBoundingClientRect();v({height:B,width:D})}b({column:Eg("column-gap",getComputedStyle(N).columnGap,S),row:Eg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return iy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:r.jsx(g,{className:a,ref:C,...tn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?r.jsx(p,{...tn(p,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(h,{...tn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),Jk=Te.memo(function(){const t=kt("HeaderComponent"),a=Fn("headerHeight"),s=kt("headerFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=kt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),ew=Te.memo(function(){const t=kt("FooterComponent"),a=Fn("footerHeight"),s=kt("headerFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=kt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),tw=({children:t})=>{const a=Te.useContext(sy),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=$a(Te.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Te.useEffect(()=>{a&&(o({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,o,s]),r.jsx("div",{ref:c,style:Xo(!1),children:t})},nw=({children:t})=>{const a=Te.useContext(sy),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=kt("customScrollParent"),u=Iv(s,c,!1);return Te.useEffect(()=>{a&&(o({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,o]),r.jsx("div",{ref:u,style:Xo(!1),children:t})},rw=Te.memo(function({...t}){const a=kt("useWindowScroll"),s=kt("customScrollParent"),o=s||a?lw:aw,c=s||a?nw:tw,u=kt("context");return r.jsx(o,{...t,...tn(o,u),children:r.jsxs(c,{children:[r.jsx(Jk,{}),r.jsx(Zk,{}),r.jsx(ew,{})]})})}),{useEmitter:py,useEmitterValue:kt,usePublisher:Fn}=ay(Qk,{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"}},rw),aw=uy({useEmitter:py,useEmitterValue:kt,usePublisher:Fn}),lw=dy({useEmitter:py,useEmitterValue:kt,usePublisher:Fn});function Eg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Pt.WARN),a==="normal"?0:parseInt(a??"0",10)}const sw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},my={source:"Own",installed:"Installed"};function iw(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 ow(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Ng({origin:t,count:a,filteredCount:s,updateCount:o,children:c}){const u=sw[t],[d,h]=m.useState(()=>iw(u)),g=m.useCallback(()=>{h(b=>{const S=!b;return ow(u,S),S})},[u]),p=my[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(uw,{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:p}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),o!=null&&o>0&&r.jsx(cw,{origin:t,updateCount:o})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function cw({origin:t,updateCount:a}){const[s,o]=m.useState(!1),c=my[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function uw({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 Mf(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 dw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>a(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(a(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function fw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function pw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function mw({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(Ev)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ti(t){const{version:a,showPrefix:s=!0,size:o="md"}=t;if(!a||typeof a!="string"||a.trim()==="")return null;const c=s&&!a.startsWith("v")?`v${a}`:a,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":a,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}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:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function hw({skill:t,isSelected:a,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&r.jsx(ti,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(fw,{target:t.symlinkTarget??null}),r.jsx(pw,{skill:t}),r.jsx(mw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Uo=m.memo(hw);function xw({plugin:t,skills:a,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...a].sort((d,h)=>d.skill.localeCompare(h.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Uo,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function gw(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 Tg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>gw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>r.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const zo=new Map,Ba=new Map,_s=new Map;function Tn(t){zo.delete(t),Ba.delete(t);const a=_s.get(t);if(a)for(const s of a)s()}function ni(t,a,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>Tn(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return _s.has(t)||_s.set(t,new Set),_s.get(t).add(b),()=>{var S;(S=_s.get(t))==null||S.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=zo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Ba.has(t)){const C=Ba.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=a().then(C=>{zo.set(t,{data:C,fetchedAt:Date.now()}),Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Ba.set(t,k)},[t,a,o,c]);const p=zo.get(t),y=c&&!p&&Ba.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}function vw({pluginName:t,enabled:a,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),Dv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return r.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Td,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Td,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Td,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Td({onClick:t,disabled:a,busy:s,label:o,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Rg({name:t,count:a,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[p&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(yw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function yw({label:t,title:a,icon:s,onClick:o,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function bw(){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 jw(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function Sw(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 kw(t,a){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||o!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function af(t,a={}){const{enabled:s=!0,target:o}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(jw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=Sw(p.target);for(const v of c.current){if(!kw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const ww=200;function Cw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Ew(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Mf(g,a)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Nw(t,a){const s=[],o=[],c=[];for(const d of t){const h=Cw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Mf(v,a)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function Tw(t,a){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Mf(y,a)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Rw({skills:t,selectedKey:a,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(G=>G.scope!==void 0&&G.scope!==null),k=g??"claude-cli",[E,C]=m.useState(""),N=m.useDeferredValue(E),T=m.useMemo(()=>Nw(t,N),[t,N]),A=m.useMemo(()=>Ew(t,N),[t,N]),B=k==="claude-code",{plugins:D}=D2(),F=B?{plugins:D??[]}:void 0,w=m.useMemo(()=>{const G=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=G.get(te.name);G.set(te.name,!!fe||!!te.enabled)}return G},[F==null?void 0:F.plugins]),[O,z]=m.useState(()=>lf(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=m.useState(()=>lf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=m.useCallback(G=>{z(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(G))}catch{}},[k]),X=m.useCallback(G=>{H(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(G))}catch{}},[k]),{own:J,installed:$}=m.useMemo(()=>Tw(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=ww,I=m.useMemo(()=>{const G=te=>{const fe=[];for(const[,ie]of te){const ye=[...ie].sort((de,Se)=>de.skill.localeCompare(Se.skill));fe.push(...ye)}return fe};return S?[...G(T.own.byPlugin),...G(T.installed.byPlugin),...G(T.global.byPlugin)]:[...G(J.byPlugin),...G($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=m.useMemo(()=>a?I.findIndex(G=>G.plugin===a.plugin&&G.skill===a.skill):-1,[I,a]),se=m.useCallback(G=>{if(I.length===0)return;const te=V<0?G>0?0:I.length-1:Math.min(Math.max(V+G,0),I.length-1);s(I[te])},[I,V,s]),M=m.useMemo(()=>{if(!v)return null;const[G,te]=v.split("/");if(!G||!te)return null;const fe=t.find(de=>de.plugin===G&&de.skill===te);if(!fe)return{plugin:G,skill:te,bucket:null,pluginName:null};const ie=fe.source==="plugin"?"plugin":"project",ye=ie==="plugin"?fe.pluginName??G:null;return{plugin:G,skill:te,bucket:ie,pluginName:ye}},[v,t]),Y=m.useRef(null);return m.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const G=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${G}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>se(1)},{key:"k",handler:()=>se(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(dw,{value:E,onChange:C}),o&&r.jsx(Dw,{}),!o&&c&&r.jsx(_w,{error:c,onRetry:u}),!o&&!c&&S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Rg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&r.jsxs(r.Fragment,{children:[r.jsx(Ms,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?r.jsx(Mg,{queryActive:!!E,agentId:k}):r.jsx(Ls,{items:A.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Ms,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:A.availablePersonal.filtered===0?r.jsx(Mw,{queryActive:!!E,agentId:k}):r.jsx(Ls,{items:A.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsxs(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?r.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-available-${G}-collapsed`,headerActionSlot:B?r.jsx(vw,{pluginName:G,enabled:w.get(G)??!0}):void 0,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${G}`))]})]}),r.jsx(zw,{}),r.jsx(Rg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&r.jsxs(r.Fragment,{children:[r.jsx(Ms,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ls,{items:A.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsx(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?r.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",r.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-authoring-${G}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===G,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${G}`))})]})]}),!o&&!c&&!S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ng,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ls,{items:J.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Lw,{}),r.jsx(Ng,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?r.jsx(Mg,{queryActive:!!E}):r.jsx(Ls,{items:$.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function lf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ms({label:t,storageKey:a,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>lf(a)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(a,String(S))}catch{}return S})},[a]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function Aw(t){const a=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Ls({items:t,selectedKey:a,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Aw(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Fk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!a&&a.plugin===g.plugin&&a.skill===g.skill;return r.jsx(Uo,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>r.jsx(xw,{plugin:u,skills:d,selectedKey:a,onSelect:s,onContextMenu:o},u))})}function Ag({queryActive:t}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Lf,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Mg({queryActive:t,agentId:a}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install <skill>"})," to add one."]})})}function Mw({queryActive:t,agentId:a}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install --global <skill>"})," to add one."]})})}function Ml({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 Lf({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 Lw(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function zw(){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 Dw(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(bw,{},t))})}function _w({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:Ow(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 Ow(t){const a=t.split(`
66
- `)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const hy=240,xy=480,gy="vskill-sidebar-width",Hs=320;function zf(t){return Number.isFinite(t)?Math.round(Math.max(hy,Math.min(xy,t))):Hs}function Bw(){try{const t=localStorage.getItem(gy);if(!t)return Hs;const a=Number(t);return Number.isFinite(a)?zf(a):Hs}catch{return Hs}}function Iw(t){try{localStorage.setItem(gy,String(zf(t)))}catch{}}function Uw({initialWidth:t,onChange:a}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),o=m.useRef(t);return m.useEffect(()=>{o.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=zf(s.current.startWidth+h);o.current=g,a(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,Iw(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":hy,"aria-valuemax":xy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Hw({connected:t,hint:a,onRetry:s}){return t?null:r.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),r.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&r.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),r.jsx("div",{style:{flex:1}}),s&&r.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function vy(t,a){if(t!==401||typeof window>"u"||!a||typeof a!="object")return;const s=a;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function yy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Rd(){const[t,a]=m.useState([]),[s,o]=m.useState(!1),[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useCallback(async(v,b)=>{a([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=yy(b),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw vy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
67
- `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};A==="done"?(u(!0),a(U=>[...U,z])):a(U=>[...U,z])}catch{}A=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=m.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:p,stop:y}}function $w(t){const a=m.useRef(t);a.current=t;const[s,o]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(p,y,v)=>{var S;(S=c.current.get(p))==null||S.abort();const b=new AbortController;c.current.set(p,b),o(k=>{const E=new Set(k);return E.add(p),E});try{const k=yy(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw vy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
68
- `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};a.current.onEvent(p,z)}catch{}A=""}}a.current.onDone(p)}catch(k){k.name!=="AbortError"&&a.current.onError(p,k.message)}finally{o(k=>{const E=new Set(k);return E.delete(p),E}),c.current.delete(p)}},[]),d=m.useCallback(p=>{var y;(y=c.current.get(p))==null||y.abort()},[]),h=m.useCallback(()=>{for(const p of c.current.values())p.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const Vw={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 Pw(t,a){var s,o;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:a.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:a.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function Fw(t){if(t==="unit"||t==="integration")return t}function Gw(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}a.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const by=m.createContext(null);function An(){const t=m.useContext(by);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Ww({plugin:t,skill:a,origin:s,children:o}){const c=s==="installed",[u,d]=m.useReducer(Pw,{...Vw,plugin:t,skill:a}),h=m.useRef(new Set),g=m.useRef(new Set),p=m.useRef(new Map),y=m.useCallback((ae,he)=>{let pe=p.current.get(ae);pe||(pe={assertions:[]},p.current.set(ae,pe)),Gw(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:ae,result:{...pe,assertions:[...pe.assertions]}})},[]),v=m.useCallback(ae=>{if(g.current.has(ae))return;g.current.add(ae);const he=p.current.get(ae)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:ae,result:{...he,assertions:[...he.assertions]}}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=m.useCallback((ae,he)=>{g.current.has(ae)||(g.current.add(ae),d({type:"CASE_RUN_ERROR",caseId:ae,error:he}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:k,stopAll:E}=$w({onEvent:y,onDone:v,onError:b});m.useEffect(()=>()=>{E()},[E]);const C=m.useCallback(async()=>{try{const ae=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!ae.ok){if(ae.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await ae.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,a]);m.useEffect(()=>{let ae=!1;async function he(){try{const[pe,ge,je]=await Promise.allSettled([Ce.getSkillDetail(t,a),Ce.getEvals(t,a),Ce.getLatestBenchmark(t,a)]);if(ae)return;let Be=null,Oe=null;if(ge.status==="fulfilled")Be=ge.value;else{const at=ge.reason;Oe=(at==null?void 0:at.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:je.status==="fulfilled"?je.value:null})}catch(pe){ae||d({type:"SET_ERROR",error:pe.message})}}return he(),C(),()=>{ae=!0}},[t,a,C]);const N=m.useCallback(async()=>{if(!c)try{await Ce.applyImprovement(t,a,u.skillContent),d({type:"CONTENT_SAVED"})}catch(ae){d({type:"SET_ERROR",error:ae.message})}},[c,t,a,u.skillContent]),T=m.useCallback(async ae=>{if(!c)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,a]),A=m.useCallback((ae,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(ae);if((pe==null?void 0:pe.status)!=="running")if(p.current.delete(ae),g.current.delete(ae),d({type:"CASE_RUN_START",caseId:ae,mode:he}),he==="comparison"){const ge=`/api/skills/${t}/${a}/compare`;S(ae,ge,{eval_ids:[ae]})}else{const ge=`/api/skills/${t}/${a}/benchmark/case/${ae}`;S(ae,ge,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),B=m.useCallback((ae="benchmark")=>{var ge;if(c)return;const he=((ge=u.evals)==null?void 0:ge.evals)??[];if(he.length===0)return;const pe=he.map(je=>je.id);for(const je of pe)p.current.delete(je),g.current.delete(je);d({type:"BULK_RUN_START",caseIds:pe,mode:ae}),h.current=new Set(pe);for(const je of pe)if(ae==="comparison")S(je,`/api/skills/${t}/${a}/compare`,{eval_ids:[je]});else{const Be=`/api/skills/${t}/${a}/benchmark/case/${je}`;S(je,Be,ae==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),D=m.useCallback(ae=>{k(ae),d({type:"CASE_RUN_CANCEL",caseId:ae}),h.current.delete(ae),g.current.add(ae)},[k]),F=m.useCallback(()=>{E(),d({type:"CANCEL_ALL"}),h.current.clear()},[E]),w=m.useCallback(async(ae,he)=>{d({type:"OPEN_IMPROVE",evalId:ae})},[]),O=m.useCallback(async(ae,he)=>{try{await Ce.applyImprovement(t,a,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),A(ae,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,a,A]),z=Rd(),U=m.useRef(null),H=m.useRef(0);m.useEffect(()=>{const ae=z.events;for(let he=H.current;he<ae.length;he++){const pe=ae[he],ge=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge.improved,Be=ge.reasoning,Oe=ge.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Be,evalChanges:Oe})}if(pe.event==="error"){const je=ge;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}H.current=ae.length},[z.events]),m.useEffect(()=>{z.error&&d({type:"AI_EDIT_ERROR",message:z.error})},[z.error]),m.useEffect(()=>()=>{z.stop()},[z.stop]);const q=m.useCallback(async(ae,he,pe)=>{c||(H.current=0,d({type:"AI_EDIT_LOADING"}),U.current=z.stop,z.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:ae,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:he,model:pe}))},[c,t,a,u.skillContent,u.evals,z]),X=m.useCallback(()=>{z.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[z]),J=m.useCallback(async()=>{const ae=u.aiEditResult;if(ae!=null&&ae.improved)try{if(await Ce.applyImprovement(t,a,ae.improved),d({type:"SET_CONTENT",content:ae.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Qs(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),ge=u.evals??{skill_name:a,evals:[]},je=pe(ge,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ce.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]),$=m.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),L=m.useCallback(ae=>{d({type:"TOGGLE_EVAL_CHANGE",index:ae})},[]),_=m.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=m.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=m.useCallback(async()=>{const ae=u.aiEditEvalsRetry;if(ae)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,a,u.aiEditEvalsRetry]),se=m.useCallback(async()=>{try{const ae=await Ce.getSkillDetail(t,a);d({type:"SET_CONTENT",content:ae.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:M}=Ha(),Y=Rd(),G=m.useRef(0);m.useEffect(()=>{const ae=Y.events;for(let he=G.current;he<ae.length;he++){const pe=ae[he],ge=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge;Ce.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:ge})}G.current=ae.length},[Y.events,t,a]),m.useEffect(()=>{Y.error&&d({type:"SET_ERROR",error:Y.error})},[Y.error]),m.useEffect(()=>()=>{Y.stop()},[Y.stop]);const te=m.useCallback(async ae=>{if(c)return;G.current=0,d({type:"GENERATE_EVALS_START"});const he={};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=Fw(ae==null?void 0:ae.testType);pe&&(he.testType=pe),Y.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,a,Y,M]),fe=Rd(),ie=m.useRef(0);m.useEffect(()=>()=>{fe.stop()},[fe.stop]),m.useEffect(()=>{const ae=fe.events;for(let he=ie.current;he<ae.length;he++){const pe=ae[he];if(pe.event==="classifying"){const ge=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:ge.index,total:ge.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const ge=pe.data;if(ge.error)d({type:"ACTIVATION_ERROR",error:ge.error});else{d({type:"ACTIVATION_DONE",summary:ge});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(M==null?void 0:M.model)||"unknown",provider:(M==null?void 0:M.provider)||"unknown",promptCount:ge.total,summary:{precision:ge.precision,recall:ge.recall,reliability:ge.reliability,tp:ge.tp,tn:ge.tn,fp:ge.fp,fn:ge.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...u.activationHistory??[]]})}}}ie.current=ae.length},[fe.events,M,u.activationHistory]),m.useEffect(()=>{fe.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:fe.error}))},[fe.error]);const ye=m.useRef(null),de=m.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),fe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[fe]),Se=m.useCallback(ae=>{const pe=ae.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"});ie.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:ae});const ge={prompts:pe};M!=null&&M.provider&&(ge.provider=M.provider),M!=null&&M.model&&(ge.model=M.model),fe.start(`/api/skills/${t}/${a}/activation-test`,ge),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{fe.stop(),d({type:"ACTIVATION_TIMEOUT"}),ye.current=null},12e4)},[t,a,fe,M]),Ae=m.useCallback(async(ae=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const he={count:ae};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=await fetch(`/api/skills/${t}/${a}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!pe.ok){let ht=`HTTP ${pe.status}`;try{const Dt=await pe.json();Dt.error&&(ht=Dt.error)}catch{}throw new Error(ht)}const ge=pe.body.getReader(),je=new TextDecoder;let Be="",Oe="",at=[];for(;;){const{done:ht,value:Dt}=await ge.read();if(ht)break;Be+=je.decode(Dt,{stream:!0});const Tt=Be.split(`
70
- `);Be=Tt.pop()||"";for(const Qe of Tt)if(Qe.startsWith("event: "))Oe=Qe.slice(7).trim();else if(Qe.startsWith("data: ")){try{const tt=JSON.parse(Qe.slice(6));if(Oe==="done"){if(tt.error)throw new Error(tt.error);at=tt.prompts||[]}if(Oe==="error")throw new Error(tt.message||tt.description||"Generation failed")}catch(tt){if(!(tt instanceof SyntaxError))throw tt}Oe=""}}const Nt=at.map(ht=>`${ht.expected==="should_activate"?"+":"!"}${ht.prompt}`).join(`
71
- `);d({type:"SET_ACTIVATION_PROMPTS",prompts:Nt}),d({type:"GENERATE_PROMPTS_DONE"})}catch(he){d({type:"GENERATE_PROMPTS_ERROR",error:he.message})}},[t,a,M]),_e=m.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:N,saveEvals:T,runCase:A,runAll:B,cancelCase:D,cancelAll:F,improveForCase:w,applyImproveAndRerun:O,refreshSkillContent:se,generateEvals:te,runActivationTest:Se,cancelActivation:de,generateActivationPrompts:Ae,fetchActivationHistory:C,submitAiEdit:q,cancelAiEdit:X,applyAiEdit:J,discardAiEdit:$,toggleEvalChange:L,selectAllEvalChanges:_,deselectAllEvalChanges:I,retryEvalsSave:V}),[u,c,N,T,A,B,D,F,w,O,se,te,Se,de,Ae,C,q,X,J,$,L,_,I,V]);return r.jsx(by.Provider,{value:_e,children:o})}function qw(t){if(!t)return[];const a=t.split(`
72
- `),s=[];for(const o of a)if(!(o.startsWith("--- ")||o.startsWith("+++ "))){if(o.startsWith("@@")){s.push({type:"header",content:o});continue}if(o.startsWith("+")){s.push({type:"add",content:o.slice(1)});continue}if(o.startsWith("-")){s.push({type:"remove",content:o.slice(1)});continue}(o.startsWith(" ")||o===""&&s.length>0)&&s.push({type:"context",content:o.startsWith(" ")?o.slice(1):""})}return s}function Df({contentDiff:t,fromLabel:a,toLabel:s,diffSummary:o,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:h}){const[g,p]=m.useState(u),[y,v]=m.useState("unified"),b=m.useRef(null),S=m.useRef(null),k=m.useMemo(()=>qw(t),[t]),E=m.useMemo(()=>{const D=k.filter(w=>w.type==="add").length,F=k.filter(w=>w.type==="remove").length;return{added:D,removed:F}},[k]),C=m.useMemo(()=>{let D=0,F=0;return k.filter(w=>w.type!=="header").map(w=>w.type==="remove"?(D++,{...w,origNum:D,newNum:null}):w.type==="add"?(F++,{...w,origNum:null,newNum:F}):(D++,F++,{...w,origNum:D,newNum:F}))},[k]),N=m.useMemo(()=>{const D=[],F=[];for(const w of C)if(w.type==="remove")D.push(w);else if(w.type==="add")F.push(w);else{for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});D.push(w),F.push(w)}for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});return{left:D,right:F}},[C]),T=m.useCallback(D=>{const F=D==="left"?b.current:S.current,w=D==="left"?S.current:b.current;F&&w&&(w.scrollTop=F.scrollTop)},[]);if(!t||k.length===0)return r.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&r.jsx("button",{onClick:h,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const A=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",B=r.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[a," → ",s]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",E.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",E.removed]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>v(y==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:y==="unified"?"Side-by-side":"Unified"}),u&&r.jsx("button",{onClick:()=>p(!g),className:"btn btn-ghost text-[11px]",children:g?"Expand":"Collapse"})]})]}),o&&r.jsx("div",{className:"mx-4 mt-3 px-4 py-2 rounded-lg text-[12px]",style:{background:"var(--accent-muted)",color:"var(--text-secondary)"},children:o}),!g&&(y==="unified"?r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:C.map((D,F)=>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||"​"})]},F))})})}):r.jsxs("div",{className:"mx-4 my-4 grid grid-cols-2 gap-0 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{ref:b,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>T("left"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.left.map((D,F)=>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||"​"})]},F))})})}),r.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>T("right"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.right.map((D,F)=>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||"​"})]},F))})})})]}))]});return d==="modal"?r.jsx("div",{className:A,children:r.jsx("div",{style:{width:"80%",maxWidth:900},children:B})}):B}const Ad="https://verified-skill.com/submit",Yw=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function Kw(t){if(!t)return Ad;const a=t.trim();return!a||!Yw.test(a)?Ad:`${Ad}?repo=${encodeURIComponent(a)}`}const Lg={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 Xw(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function Qw(){const{state:t}=An(),{plugin:a,skill:s}=t,o=er(),{refreshSkills:c,updateCount:u}=o,d=m.useMemo(()=>o.state.skills.find(L=>L.plugin===a&&L.skill===s)??null,[o.state.skills,a,s]),h=`versions/${a}/${s}`,g=m.useCallback(()=>Ce.getSkillVersions(a,s),[a,s]),{data:p,loading:y}=ni(h,g),[v,b]=m.useState(null),[S,k]=m.useState(null),[E,C]=m.useState(null),[N,T]=m.useState(!1),[A,B]=m.useState("idle"),[D,F]=m.useState(null),w=m.useRef(null),O=m.useRef(null),z=m.useMemo(()=>(p==null?void 0:p.find(L=>L.isInstalled))??null,[p]),U=m.useMemo(()=>(p==null?void 0:p[0])??null,[p]),H=z&&U&&z.version!==U.version,q=m.useCallback(L=>{v?!S&&L!==v?k(L):(b(L),k(null),C(null)):(b(L),C(null))},[v,S]),X=m.useCallback(async(L,_)=>{T(!0);try{const I=await Ce.getVersionDiff(a,s,L,_);C(I)}catch{C(null)}finally{T(!1)}},[a,s]);m.useEffect(()=>{if(v&&S){const L=p||[],_=L.findIndex(M=>M.version===v),I=L.findIndex(M=>M.version===S),[V,se]=_>I?[v,S]:[S,v];X(V,se)}},[v,S,p,X]);const J=m.useCallback(()=>{!z||!U||(b(z.version),k(U.version))},[z,U]),$=m.useCallback(async()=>{B("updating"),F(null);const L=new AbortController;w.current=L;try{const _=await Ce.postSkillUpdate(a,s,L.signal);if(_.ok)B("done"),c(),Tn(h);else{const I=`Update failed (HTTP ${_.status}): ${_.body||"no response body"}`;B("error"),F(I)}}catch(_){if(_ instanceof DOMException&&_.name==="AbortError")return;const I=_ instanceof Error?_.message:"Network error";B("error"),F(I)}finally{w.current===L&&(w.current=null)}},[a,s,h,c]);if(m.useEffect(()=>()=>{var L;(L=w.current)==null||L.abort(),w.current=null},[]),y)return r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!p||p.length===0){if((d==null?void 0:d.origin)==="source"){const _=Kw((d==null?void 0:d.homepage)??null);return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),r.jsx("div",{className:"text-[13px] text-center mb-5 max-w-md",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:"This skill is local-only — the version history shown here is sourced from verified-skill.com. Submit your skill to start tracking versions and share it with others."}),r.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary text-[12px]","data-testid":"versions-empty-state-cta",children:"Submit on verified-skill.com"})]})}return d!=null&&d.version?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsxs("div",{"data-testid":"version-row-local",className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg",style:{background:"transparent",border:"1px solid transparent"},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:10,height:10,background:"var(--accent)",border:"2px solid var(--accent)"}}),r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:d.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"LOCAL"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]})}),r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Local-only — this skill is not registered on verified-skill.com, so no upstream history is available."})]})]})]}):r.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:r.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return r.jsxs("div",{className:"p-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"flex items-center gap-2",children:[H&&r.jsx("button",{onClick:J,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),H&&A!=="done"&&(A==="error"?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:D||"Update failed"}),r.jsx("button",{onClick:$,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):r.jsx("button",{onClick:$,disabled:A!=="idle",className:"btn btn-primary text-[11px]",children:A==="idle"?`Update to ${U==null?void 0:U.version}`:A==="updating"?"Starting update...":A==="scanning"?"Scanning...":"Installing..."})),u>1&&r.jsxs("button",{onClick:()=>{window.location.hash="#/updates"},className:"text-[11px] hover:underline",style:{color:"var(--text-tertiary)",background:"transparent",border:"none",cursor:"pointer"},children:["Manage all updates (",u,")"]})]})]}),v&&!S&&r.jsxs("div",{className:"text-[11px] mb-3 px-3 py-2 rounded-lg",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:["Click another version to compare with ",v]}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsx("div",{className:"space-y-1",children:p.map(L=>{const _=Lg[L.certTier]||Lg.COMMUNITY,I=L.version===v||L.version===S,V=L.isInstalled;return r.jsxs("button",{onClick:()=>q(L.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:I?"var(--accent-muted)":"transparent",border:I?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:se=>{I||(se.currentTarget.style.background="var(--surface-1)")},onMouseLeave:se=>{I||(se.currentTarget.style.background="transparent")},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:V?10:8,height:V?10:8,background:V?"var(--accent)":"var(--surface-3)",border:V?"2px solid var(--accent)":"2px solid var(--border-default)"}}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:L.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.bg,color:_.text},children:L.certTier}),V&&r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(L.createdAt).toLocaleDateString()})]}),L.diffSummary&&r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:Xw(L.diffSummary,80)})]},L.version)})}),r.jsx("div",{ref:O,style:{height:1}})]}),N&&r.jsx("div",{className:"mt-4",children:r.jsx("div",{className:"skeleton h-48 rounded-xl"})}),E&&!N&&r.jsx("div",{className:"mt-4",children:r.jsx(Df,{contentDiff:E.contentDiff,fromLabel:E.from,toLabel:E.to,diffSummary:E.diffSummary,renderContext:"inline",onRetry:()=>v&&S&&X(E.from,E.to)})})]})}function Zw(t){const a=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!a)return{metadata:{},body:t};const s=a[1],o=a[2].trim(),c={},u=s.split(`
73
- `);let d="",h=!1;for(const g of u){const p=g.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(p&&d&&h){const b=p[1],S=p[2].trim();let k=c[d];if((typeof k!="object"||Array.isArray(k))&&(k={},c[d]=k),!S)k[b]=[];else{const E=S.match(/^\[(.+)\]$/);E?k[b]=E[1].split(",").map(C=>C.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[b]=S.replace(/^["']|["']$/g,"")}continue}const y=g.match(/^\s+-\s+(.+)$/);if(y&&d){h=!1;const b=c[d];Array.isArray(b)?b.push(y[1].trim().replace(/^["']|["']$/g,"")):c[d]=[y[1].trim().replace(/^["']|["']$/g,"")];continue}const v=g.match(/^([\w-]+):\s*(.*)$/);if(v){d=v[1];const b=v[2].trim();if(h=!1,!b){c[d]={},h=!0;continue}const S=b.match(/^\[(.+)\]$/);if(S){c[d]=S[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:o}}function Qo(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=Jw(a);return s=s.replace(/```(\w*)\n([\s\S]*?)```/g,'<pre style="background:var(--surface-2);padding:0.75rem;border-radius:6px;overflow-x:auto;font-size:12px;line-height:1.5;margin:0.5rem 0;border:1px solid var(--border-subtle)"><code>$2</code></pre>'),s=s.replace(/^### (.+)$/gm,'<div style="font-weight:600;font-size:14px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^## (.+)$/gm,'<div style="font-weight:700;font-size:15px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^# (.+)$/gm,'<div style="font-weight:700;font-size:1rem;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer" style="color:var(--accent);text-decoration:underline">$1</a>'),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/\*([^*]+)\*/g,"<em>$1</em>"),s=s.replace(/`([^`]+)`/g,'<code style="background:var(--surface-3);padding:0.1rem 0.3rem;border-radius:3px;font-size:0.85em">$1</code>'),s=s.replace(/^- (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">• $1</div>'),s=s.replace(/^(\d+)\. (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">$1. $2</div>'),s=s.replace(/\n\n/g,'<div style="height:0.5rem"></div>'),s=s.replace(/\n/g,"<br/>"),s}catch{return`<pre style="white-space:pre-wrap;font-size:12px;line-height:1.5">${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`}}function Jw(t){const a=t.split(`
74
- `),s=[];let o=0;for(;o<a.length;)if(a[o].trim().startsWith("|")&&o+1<a.length&&a[o+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(a[o+1])){const c=zg(a[o]);o+=2;const u=[];for(;o<a.length&&a[o].trim().startsWith("|");)u.push(zg(a[o])),o++;const d='style="text-align:left;padding:0.4rem 0.6rem;font-weight:600;font-size:12px;color:var(--text-primary);border-bottom:1px solid var(--border-default)"',h='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let g='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';g+="<thead><tr>";for(const p of c)g+=`<th ${d}>${p}</th>`;g+="</tr></thead><tbody>";for(const p of u){g+="<tr>";for(const y of p)g+=`<td ${h}>${y}</td>`;g+="</tr>"}g+="</tbody></table>",s.push(g)}else s.push(a[o]),o++;return s.join(`
65
+ }`})]})}function eg(){typeof window>"u"||(window.location.hash="#/")}function f2({onHome:t}){const[a,s]=p.useState(!1),[o,c]=p.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),eg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),eg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const p2="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",m2=p.lazy(()=>Ha(()=>import("./UpdateDropdown-BsAm4uMW.js"),__vite__mapDeps([0,1])));function h2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=er(),d=p.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,C]of u)C.diffSummary&&k.set(E,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=p.useState(!1),m=p.useRef(null),y=p.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=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:m,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),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:v,cursor:"pointer"},children:[r.jsx("img",{src:p2,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:b})]}),h&&r.jsx(p.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(m2,{updates:a,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),C=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:m})})]})}function tg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function x2({projectName:t,selected:a,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u,findSkillsSlot:d}){const h=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(f2,{onHome:o}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&h&&r.jsxs(r.Fragment,{children:[r.jsx(ng,{segment:"origin",onClick:()=>tg({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(rg,{}),r.jsx(ng,{segment:"plugin",onClick:()=>tg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(rg,{}),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(u2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(h2,{})}),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 ng({segment:t,onClick:a,style:s,children:o}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function rg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Wo="vskill-theme";function Mv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function g2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function v2(t){try{const a=t.getItem(Wo);return Mv(a)}catch{return"auto"}}function y2(t,a){try{t.setItem(Wo,a)}catch{}}function b2(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 Lv=p.createContext(null);function S2({storage:t,matchMedia:a,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=p.useState(()=>c?v2(c):"auto"),[m,y]=p.useState(()=>j2(u)),v=p.useMemo(()=>g2(h,m),[h,m]);p.useEffect(()=>{d&&b2(d,h,v)},[d,h,v]),p.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Wo&&g(Mv(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),p.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=p.useCallback(k=>{g(k),c&&y2(c,k)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(Lv.Provider,{value:S,children:o})}function zv(){const t=p.useContext(Lv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function k2(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=a.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function w2(t){const[a,s]=p.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return p.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),a}function C2({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const o=k2(t),c=w2(640),[u,d]=p.useState(!1),h=p.useCallback(g=>{g.available||g.kind==="api-key"?a==null||a(g.id):s==null||s(g.id)},[a,s]);if(c){const g=o.filter(m=>m.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(m=>r.jsx(lg,{p:m,onClick:h},m.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>r.jsx(lg,{p:g,onClick:h,compact:!0},g.id))})}function lg({p:t,onClick:a,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(Xd,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function E2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Wo)}catch{return null}}function N2({projectPath:t,modelName:a,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:m}=zv(),v=E2()==="auto",b=T2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(sg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(R2,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(sg,{}),r.jsx(C2,{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(A2,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function T2(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function R2({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function sg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function A2({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 Qd=new Set;function Dv(){for(const t of Qd)t()}const M2=5,L2=1e3,z2=6e4;function D2(){const[t,a]=p.useState(void 0),[s,o]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),h=p.useRef(null),g=p.useRef(null),m=p.useRef(!0),y=p.useRef(0),[v,b]=p.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!m.current)return;const A=await T.json();if(!m.current)return;d.current=0,a(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{m.current&&b(B=>B+1)},z2)}catch(T){if(!m.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>M2){o(!0);return}const A=L2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{m.current&&b(B=>B+1)},A)}},[k]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),k()}),[k]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),p.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=p.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return p.useEffect(()=>(Qd.add(C),()=>{Qd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const qo=0,ca=1,Bl=2,_v=4;function ig(t){return()=>t}function _2(t){t()}function Ov(t,a){return s=>t(a(s))}function og(t,a){return()=>t(a)}function O2(t,a){return s=>t(a,s)}function yf(t){return t!==void 0}function B2(...t){return()=>{t.map(_2)}}function Il(){}function Yo(t,a){return a(t),t}function I2(t,a){return a(t)}function St(...t){return t}function at(t,a){return t(ca,a)}function Fe(t,a){t(qo,a)}function bf(t){t(Bl)}function Ct(t){return t(_v)}function Te(t,a){return at(t,O2(a,qo))}function Qn(t,a){const s=t(ca,o=>{s(),a(o)});return s}function cg(t){let a,s;return o=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{o(a)},t)}}function Bv(t,a){return t===a}function jt(t=Bv){let a;return s=>o=>{t(a,o)||(a=o,s(o))}}function De(t){return a=>s=>{t(s)&&a(s)}}function ke(t){return a=>Ov(a,t)}function ir(t){return a=>()=>{a(t)}}function me(t,...a){const s=U2(...a);return((o,c)=>{switch(o){case Bl:bf(t);return;case ca:return at(t,s(c))}})}function or(t,a){return s=>o=>{s(a=t(a,o))}}function Ua(t){return a=>s=>{t>0?t--:a(s)}}function Ar(t){let a=null,s;return o=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,o(a)},t))}}function Ge(...t){const a=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{const m=s;s|=h,a[d]=g,m!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():o=h}}function U2(...t){return a=>t.reduceRight(I2,a)}function H2(t){let a,s;const o=()=>a==null?void 0:a();return function(c,u){switch(c){case ca:return u?s===u?void 0:(o(),s=u,a=at(t,u),a):(o(),Il);case Bl:o(),s=null;return}}}function ge(t){let a=t;const s=Qe();return((o,c)=>{switch(o){case qo:a=c;break;case ca:{c(a);break}case _v:return a}return s(o,c)})}function an(t,a){return Yo(ge(a),s=>Te(t,s))}function Qe(){const t=[];return((a,s)=>{switch(a){case qo:t.slice().forEach(o=>{o(s)});return;case Bl:t.splice(0,t.length);return;case ca:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return Yo(Qe(),a=>Te(t,a))}function tt(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:$2(),singleton:s}}const $2=()=>Symbol();function V2(t){const a=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=o(c.map(g=>s(g)));return d&&a.set(u,h),h};return s(t)}function Ht(...t){const a=Qe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{s[d]=g,o|=h,o===c&&Fe(a,s)})}),function(u,d){switch(u){case Bl:{bf(a);return}case ca:return o===c&&d(s),at(a,d)}}}function ze(t,a=Bv){return me(t,jt(a))}function Zd(...t){return function(a,s){switch(a){case Bl:return;case ca:return B2(...t.map(o=>at(o,s)))}}}const Ft={DEBUG:0,INFO:1,WARN:2,ERROR:3},P2={[Ft.DEBUG]:"debug",[Ft.ERROR]:"error",[Ft.INFO]:"log",[Ft.WARN]:"warn"},F2=()=>typeof globalThis>"u"?window:globalThis,ua=tt(()=>{const t=ge(Ft.ERROR);return{log:ge((a,s,o=Ft.INFO)=>{const c=F2().VIRTUOSO_LOG_LEVEL??Ct(t);o>=c&&console[P2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Va(t,a,s){return jf(t,a,s).callbackRef}function jf(t,a,s){const o=Ne.useRef(null);let c=d=>{};const u=Ne.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function G2(t,a,s,o,c,u,d,h,g){const m=Ne.useCallback(y=>{const v=W2(y.children,a,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?ug("column-gap",getComputedStyle(y).columnGap,c):ug("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,o,h]);return jf(m,s,g)}function W2(t,a,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),m=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Ft.ERROR),y===m)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function ug(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Ft.WARN),a==="normal"?0:parseInt(a??"0",10)}function Iv(t,a,s){const o=Ne.useRef(null),c=Ne.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const m=g.getBoundingClientRect(),y=m.width;let v,b;if(a){const S=a.getBoundingClientRect(),k=m.top-S.top;b=S.height-Math.max(0,k),v=k+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),v=m.top+S.scrollY}o.current={listHeight:m.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,a]),{callbackRef:u,ref:d}=jf(c,!0,s),h=Ne.useCallback(()=>{c(d.current)},[c,d]);return Ne.useEffect(()=>{var m;if(a){a.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(a),()=>{a.removeEventListener("scroll",h),y.unobserve(a)}}const g=(m=d.current)==null?void 0:m.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,a,d]),u}const dn=tt(()=>{const t=Qe(),a=Qe(),s=ge(0),o=Qe(),c=ge(0),u=Qe(),d=Qe(),h=ge(0),g=ge(0),m=ge(0),y=ge(0),v=Qe(),b=Qe(),S=ge(!1),k=ge(!1),E=ge(!1);return Te(me(t,ke(({scrollTop:C})=>C)),a),Te(me(t,ke(({scrollHeight:C})=>C)),d),Te(a,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Fs={lvl:0};function Uv(t,a){const s=t.length;if(s===0)return[];let{index:o,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=a(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function pt(t){return t===Fs}function Gs(t,a){if(!pt(t))return a===t.k?t.v:a<t.k?Gs(t.l,a):Gs(t.r,a)}function Jn(t,a,s="k"){if(pt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const o=Jn(t.r,a,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,a,s)}function En(t,a,s){return pt(t)?Vv(a,s,1):a===t.k?Pt(t,{k:a,v:s}):a<t.k?dg(Pt(t,{l:En(t.l,a,s)})):dg(Pt(t,{r:En(t.r,a,s)}))}function Ml(){return Fs}function Ll(t,a,s){if(pt(t))return[];const o=Jn(t,a)[0];return q2(ef(t,o,s))}function Jd(t,a){if(pt(t))return Fs;const{k:s,l:o,r:c}=t;if(a===s){if(pt(o))return c;if(pt(c))return o;const[u,d]=$v(o);return Mo(Pt(t,{k:u,l:Hv(o),v:d}))}return a<s?Mo(Pt(t,{l:Jd(o,a)})):Mo(Pt(t,{r:Jd(c,a)}))}function Ia(t){return pt(t)?[]:[...Ia(t.l),{k:t.k,v:t.v},...Ia(t.r)]}function ef(t,a,s){if(pt(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>a&&(h=h.concat(ef(c,a,s))),o>=a&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(ef(u,a,s))),h}function Mo(t){const{l:a,lvl:s,r:o}=t;if(o.lvl>=s-1&&a.lvl>=s-1)return t;if(s>o.lvl+1){if(kd(a))return Pv(Pt(t,{lvl:s-1}));if(!pt(a)&&!pt(a.r))return Pt(a.r,{l:Pt(a,{r:a.r.l}),lvl:s,r:Pt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(kd(t))return tf(Pt(t,{lvl:s-1}));if(!pt(o)&&!pt(o.l)){const c=o.l,u=kd(c)?o.lvl-1:o.lvl;return Pt(c,{l:Pt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:tf(Pt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Pt(t,a){return Vv(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 Hv(t){return pt(t.r)?t.l:Mo(Pt(t,{r:Hv(t.r)}))}function kd(t){return pt(t)||t.lvl>t.r.lvl}function $v(t){return pt(t.r)?[t.k,t.v]:$v(t.r)}function Vv(t,a,s,o=Fs,c=Fs){return{k:t,l:o,lvl:s,r:c,v:a}}function dg(t){return tf(Pv(t))}function Pv(t){const{l:a}=t;return!pt(a)&&a.lvl===t.lvl?Pt(a,{r:Pt(t,{l:a.r})}):t}function tf(t){const{lvl:a,r:s}=t;return!pt(s)&&!pt(s.r)&&s.lvl===a&&s.r.lvl===a?Pt(s,{l:Pt(t,{r:s.l}),lvl:a+1}):t}function q2(t){return Uv(t,({k:a,v:s})=>({index:a,value:s}))}function Fv(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Ws(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Sf=tt(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function Gv(t,a,s){return t[Bo(t,a,s)]}function Bo(t,a,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Y2(t,a,s,o){const c=Bo(t,a,o),u=Bo(t,s,o,c);return t.slice(c,u+1)}function ia(t,a){return Math.round(t.getBoundingClientRect()[a])}function Ko(t){return!pt(t.groupOffsetTree)}function kf({index:t},a){return a===t?0:a<t?-1:1}function K2(){return{groupIndices:[],groupOffsetTree:Ml(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ml()}}function X2(t,a){let s=pt(t)?0:1/0;for(const o of a){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),pt(t)){t=En(t,0,u);continue}const h=Ll(t,d-1,c+1);if(h.some(rk(o)))continue;let g=!1,m=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Jd(t,v)):(m=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));m&&(t=En(t,d,u))}return[t,s]}function Q2(t){return typeof t.groupIndex<"u"}function Z2({offset:t},a){return a===t?0:a<t?-1:1}function qs(t,a,s){if(a.length===0)return 0;const{index:o,offset:c,size:u}=Gv(a,t,kf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Wv(t,a){if(!Ko(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function qv(t,a,s){if(Q2(t))return a.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Wv(o,a);return c=Math.max(0,c,Math.min(s,c)),c}function J2(t,a,s,o=0){return o>0&&(a=Math.max(a,Gv(t,o,kf).offset)),Uv(Y2(t,a,s,Z2),nk)}function ek(t,[a,s,o,c]){a.length>0&&o("received item sizes",a,Ft.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&pt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=X2(d,a);if(d===u)return t;const{lastIndex:g,lastOffset:m,lastSize:y,offsetTree:v}=nf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,qs(S,v,c)),Ml()),lastIndex:g,lastOffset:m,lastSize:y,offsetTree:v,sizeTree:d}}function tk(t){return Ia(t).map(({k:a,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function fg(t,a){let s=0,o=0;for(;s<t;)s+=a[o+1]-a[o]-1,o++;return o-(s===t?0:1)}function nf(t,a,s,o){let c=t,u=0,d=0,h=0,g=0;if(a!==0){g=Bo(c,a-1,kf),h=c[g].offset;const m=Jn(s,a-1);u=m[0],d=m[1],c.length&&c[g].size===Jn(s,a)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:m,value:y}of Ll(s,a,1/0)){const v=m-u,b=v*d+h+v*o;c.push({index:m,offset:b,size:y}),u=m,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function nk(t){return{index:t.index,value:t}}function rk(t){const{endIndex:a,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===a||c.end===1/0)&&c.value===s}const ak={offsetHeight:"height",offsetWidth:"width"},ur=tt(([{log:t},{recalcInProgress:a}])=>{const s=Qe(),o=Qe(),c=an(o,0),u=Qe(),d=Qe(),h=ge(0),g=ge([]),m=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),S=ge((w,O)=>ia(w,ak[O])),k=ge(void 0),E=ge(0),C=K2(),N=an(me(s,Ge(g,t,E),or(ek,C),jt()),C),T=an(me(g,jt(),or((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Te(me(g,De(w=>w.length>0),Ge(N,E),ke(([w,O,z])=>{const U=w.reduce((H,q,X)=>En(H,q,qs(q,O.offsetTree,z)||X),Ml());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Te(me(o,Ge(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:w}])),s),Te(m,y);const A=an(me(m,ke(w=>w===void 0)),!0);Te(me(y,De(w=>w!==void 0&&pt(Ct(N).sizeTree)),ke(w=>{const O=Ct(v),z=Ct(g).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Te(me(b,De(w=>w!==void 0&&w.length>0&&pt(Ct(N).sizeTree)),ke(w=>{const O=[];let z=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==z&&(O.push({endIndex:H-1,size:z,startIndex:U}),z=q,U=H)}return O.push({endIndex:w.length-1,size:z,startIndex:U}),O})),s),Te(me(g,Ge(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,z])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:z})}return U})),s);const B=Nn(me(s,Ge(N),or(({sizes:w},[O,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:C}),ke(w=>w.changed)));at(me(h,or((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=Ct(N);if(w>0)Fe(a,!0),Fe(u,w+fg(w,O));else if(w<0){const z=Ct(T);z.length>0&&(w-=fg(-w,z)),Fe(d,w)}}),at(me(h,Ge(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Ft.ERROR)});const D=Nn(u);Te(me(u,Ge(N),ke(([w,O])=>{const z=O.groupIndices.length>0,U=[],H=O.lastSize;if(z){const q=Gs(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ia(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ia(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Ge(N,E),ke(([w,{offsetTree:O},z])=>{const U=-w;return qs(U,O,z)})));return Te(me(d,Ge(N,E),ke(([w,O,z])=>{if(O.groupIndices.length>0){if(pt(O.sizeTree))return O;let H=Ml();const q=Ct(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ia(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Gs(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...nf(O.offsetTree,0,H,z)}}const U=Ia(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Ml());return{...O,sizeTree:U,...nf(O.offsetTree,0,U,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},St(ua,Sf),{singleton:!0});function lk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const Yv=tt(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Qe(),d=Qe(),h=Nn(me(u,ke(lk)));return Te(me(h,ke(g=>g.totalCount)),s),Te(me(h,ke(g=>g.groupIndices)),t),Te(me(Ht(c,a,o),De(([g,m])=>Ko(m)),ke(([g,m,y])=>Jn(m.groupOffsetTree,Math.max(g-y,0),"v")[0]),jt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},St(ur,dn)),da=tt(([{log:t}])=>{const a=ge(!1),s=Nn(me(a,De(o=>o),jt()));return at(a,o=>{o&&Ct(t)("props updated",{},Ft.DEBUG)}),{didMount:s,propsReady:a}},St(ua),{singleton:!0}),sk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Kv(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!sk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const Js=tt(([{gap:t,listRefresh:a,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:m,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Qe(),k=Qe(),E=ge(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Fe(g,!1)}return Te(me(S,Ge(s,v,o,E,h,d,b),Ge(t,u,c),ke(([[B,D,F,w,O,z,U,H],q,X,J])=>{const $=Kv(B),{align:L,behavior:_,offset:I}=$,V=w-1,ie=qv($,D,V);let M=qs(ie,D.offsetTree,q)+z;L==="end"?(M+=X+Jn(D.sizeTree,ie)[1]-F+J,ie===V&&(M+=U)):L==="center"?M+=(X+Jn(D.sizeTree,ie)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=G=>{A(),G?(H("retrying to scroll to",{location:B},Ft.DEBUG),Fe(S,B)):(Fe(k,!0),H("list did not change, scroll successful",{},Ft.DEBUG))};if(A(),_==="smooth"){let G=!1;T=at(a,te=>{G=G||te}),C=Qn(y,()=>{Y(G)})}else C=Qn(me(a,ik(150)),Y);return N=setTimeout(()=>{A()},1200),Fe(g,!0),H("scrolling from index to",{behavior:_,index:ie,top:M},Ft.DEBUG),{behavior:_,top:M}})),m),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},St(ur,dn,ua),{singleton:!0});function ik(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return o=>{o&&(a(!0),clearTimeout(s))}}}function wf(t,a){t===0?a():requestAnimationFrame(()=>{wf(t-1,a)})}function Cf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const ei=tt(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),g=ge(0),m=ge(!0);return Te(me(d,Ge(g),De(([y,v])=>v!==0),ir(!1)),h),Te(me(d,Ge(g),De(([y,v])=>v!==0),ir(!1)),m),at(me(Ht(a,d),Ge(h,s,t,m),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!pt(b)||yf(S))&&!v&&!k),Ge(g)),([,y])=>{Qn(c,()=>{Fe(m,!0)}),wf(4,()=>{Qn(o,()=>{Fe(h,!0)}),Fe(u,y)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:g,scrolledToInitialItem:h}},St(ur,dn,Js,da),{singleton:!0});function Xv(t,a){return Math.abs(t-a)<1.01}const Ys="up",Hs="down",ok="none",ck={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},uk=0,ti=tt(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),g=Qe(),m=Qe(),y=ge(4),v=ge(uk),b=an(me(Zd(me(ze(c),Ua(1),ir(!0)),me(ze(c),Ua(1),ir(!1),cg(100))),jt()),!1),S=an(me(Zd(me(s,ir(!0)),me(s,ir(!1),cg(200))),jt()),!1);Te(me(Ht(ze(c),ze(v)),ke(([T,A])=>T<=A),jt()),h),Te(me(h,Ar(50)),m);const k=Nn(me(Ht(o,ze(u),ze(a),ze(t),ze(y)),or((T,[{scrollHeight:A,scrollTop:B},D,F,w,O])=>{const z=B+D-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":D<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},ck),jt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=an(me(o,or((T,{scrollHeight:A,scrollTop:B,viewportHeight:D})=>{if(!Xv(T.scrollHeight,A)){const F=A-(B+D)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Te(me(k,ke(T=>T.atBottom)),d),Te(me(d,Ar(50)),g);const C=ge(Hs);Te(me(o,ke(({scrollTop:T})=>T),jt(),or((T,A)=>Ct(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Ys:Hs,prevScrollTop:A},{direction:Hs,prevScrollTop:0}),ke(T=>T.direction)),C),Te(me(o,Ar(50),ir(ok)),C);const N=ge(0);return Te(me(b,De(T=>!T),ir(0)),N),Te(me(c,Ar(100),Ge(b),De(([T,A])=>A),or(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:m,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},St(dn)),Ks="top",Xs="bottom",pg="none";function mg(t,a,s){return typeof t=="number"?s===Ys&&a===Ks||s===Hs&&a===Xs?t:0:s===Ys?a===Ks?t.main:t.reverse:a===Xs?t.main:t.reverse}function hg(t,a){return typeof t=="number"?t:t[a]??0}const Ef=tt(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Qe(),d=ge(0),h=ge(0),g=ge(0),m=an(me(Ht(ze(o),ze(c),ze(s),ze(u,Ws),ze(g),ze(d),ze(a),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,D=C+N,F=Math.max(b-B,0);let w=pg;const O=hg(A,Ks),z=hg(A,Xs);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+D-O&&(w=Ys),k<y-F+v+z&&(w=Hs),w!==pg?[Math.max(B-b-mg(E,Ks,w)-O,0),B-F-N+v+mg(E,Xs,w)+z]:null}),De(y=>y!==null),jt(Ws)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:m}},St(dn),{singleton:!0});function dk(t,a,s){if(Ko(a)){const o=Wv(t,a);return[{index:Jn(a.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const wd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Lo(t,a,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let m=0,y=0;if(t.length>0){m=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=m,k=b-y;return{bottom:y,firstItemIndex:u,items:xg(t,c,u),offsetBottom:k,offsetTop:m,top:S,topItems:xg(a,c,u),topListHeight:a.reduce((E,C)=>C.size+E,0),totalCount:s}}function Qv(t,a,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=Cf(a,h),m=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Lo(m,[],h,c,s,o)}function xg(t,a,s){if(t.length===0)return[];if(!Ko(a))return t.map(m=>({...m,index:m.index+s,originalIndex:m.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Ll(a.groupOffsetTree,o,c);let h,g=0;for(const m of t){(!h||h.end<m.index)&&(h=d.shift(),g=a.groupIndices.indexOf(h.start));let y;m.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:m.index-(g+1)+s},u.push({...y,data:m.data,offset:m.offset,originalIndex:m.index,size:m.size})}return u}function gg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Pa=tt(([{data:t,firstItemIndex:a,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:m,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ge([]),C=ge(0),N=Qe(),T=ge(0);Te(u.topItemsIndexes,E);const A=an(me(Ht(S,k,ze(g,Ws),ze(c),ze(o),ze(m),y,ze(E),ze(a),ze(s),ze(T),t),De(([w,O,,z,,,,,,,,U])=>{const H=U!==void 0&&U.length!==z;return w&&!O&&!H}),ke(([,,[w,O],z,U,H,q,X,J,$,L,_])=>{var je,Re;const I=U,{offsetTree:V,sizeTree:ie}=I,M=Ct(C);if(z===0)return{...wd,totalCount:z};if(w===0&&O===0)return M===0?{...wd,totalCount:z}:Qv(M,H,U,J,$,_||[]);if(pt(ie))return M>0?null:Lo(dk(Cf(H,z),I,_),[],z,$,I,J);const Y=[];if(X.length>0){const _e=X[0],ae=X[X.length-1];let he=0;for(const pe of Ll(ie,_e,ae)){const xe=pe.value,be=Math.max(pe.start,_e),Be=Math.min(pe.end,ae);for(let Oe=be;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:xe}),he+=xe}}if(!q)return Lo([],Y,z,$,I,J);const G=X.length>0?X[X.length-1]+1:0,te=J2(V,w,O,G);if(te.length===0)return null;const fe=z-1,oe=Yo([],_e=>{for(const ae of te){const he=ae.value;let pe=he.offset,xe=ae.start;const be=he.size;if(he.offset<w){xe+=Math.floor((w-he.offset+$)/(be+$));const Oe=xe-ae.start;pe+=Oe*be+Oe*$}xe<G&&(pe+=(G-xe)*be,xe=G);const Be=Math.min(ae.end,fe);for(let Oe=xe;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:be}),pe+=be+$}}),ve=gg(L,Ks),de=gg(L,Xs);if(oe.length>0&&(ve>0||de>0)){const _e=oe[0],ae=oe[oe.length-1];if(ve>0&&_e.index>G){const he=Math.min(ve,_e.index-G),pe=[];let xe=_e.offset;for(let be=_e.index-1;be>=_e.index-he;be--){const Be=((je=Ll(ie,be,be)[0])==null?void 0:je.value)??_e.size;xe-=Be+$,pe.unshift({data:_==null?void 0:_[be],index:be,offset:xe,size:Be})}oe.unshift(...pe)}if(de>0&&ae.index<fe){const he=Math.min(de,fe-ae.index);let pe=ae.offset+ae.size+$;for(let xe=ae.index+1;xe<=ae.index+he;xe++){const be=((Re=Ll(ie,xe,xe)[0])==null?void 0:Re.value)??ae.size;oe.push({data:_==null?void 0:_[xe],index:xe,offset:pe,size:be}),pe+=be+$}}}return Lo(oe,Y,z,$,I,J)}),De(w=>w!==null),jt()),wd);Te(me(t,De(yf),ke(w=>w==null?void 0:w.length)),c),Te(me(A,ke(w=>w.topListHeight)),v),Te(v,h),Te(me(A,ke(w=>[w.top,w.bottom])),d),Te(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Ge(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),jt(Ws),ke(([w])=>w))),D=Nn(me(A,Ar(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),jt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,z=w.length-1;for(;w[O].type==="group"&&O<z;)O++;for(;w[z].type==="group"&&z>O;)z--;return{endIndex:w[z].index,startIndex:w[O].index}}),jt(Fv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:D,topItemsIndexes:E,...b}},St(ur,Yv,Ef,ei,Js,ti,da,Sf),{singleton:!0}),Zv=tt(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Qe(),d=an(me(Ht(s,t,o,a,c),ke(([h,g,m,y,v])=>h+g+m+y+v.offsetBottom+v.bottom)),0);return Te(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},St(dn,Pa),{singleton:!0}),fk=tt(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),o=an(me(Ht(s,t,a),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Ar(0),jt()),0);return{alignToBottom:s,paddingTopAddition:o}},St(dn,Zv),{singleton:!0}),Jv=tt(()=>({context:ge(null)})),pk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,ey=tt(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:m}])=>{const y=Qe();return Te(me(y,Ge(a,g,s,u,c,o,h),Ge(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=pk,done:D,...F}=v,w=qv(v,b,k-1),O=qs(w,b.offsetTree,A)+E+C,z=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:z,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?D&&Qn(me(d,De(X=>!X),Ua(Ct(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),m),{scrollIntoView:y}},St(ur,dn,Js,Pa,ua),{singleton:!0});function vg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const mk=(t,a)=>typeof t=="function"?vg(t(a)):a&&vg(t),hk=tt(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:m},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ge(!1),E=Qe();let C=null;function N(D){Fe(d,{align:"end",behavior:D,index:"LAST"})}at(me(Ht(me(ze(a),Ua(1)),g),Ge(ze(k),u,h,v),ke(([[D,F],w,O,z,U])=>{let H=F&&z,q="auto";return H&&(q=mk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(y)("following output to ",{totalCount:F},Ft.DEBUG),N(D)}):C=Qn(t,()=>{Ct(y)("following output to ",{totalCount:F},Ft.DEBUG),N(D),C=null})});function T(D){const F=Qn(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(Ct(y)("scrolling to bottom due to increased size",{},Ft.DEBUG),N("auto"))});setTimeout(F,100)}at(me(Ht(ze(k),a,m),De(([D,,F])=>D!==!1&&F),or(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Ge(k,a)),([,D])=>{Ct(h)&&T(D!==!1)}),at(E,()=>{T(Ct(k)!==!1)}),at(Ht(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ge(null),B=Qe();return Te(Zd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(a))),B),at(me(Ht(me(B,Ua(1)),g),Ge(ze(A),h,v,b),ke(([[D,F],w,O,z,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Ar(0)),D=>{C!==null&&(C(),C=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(y)("scrolling into view",{}),Fe(S,D)}):C=Qn(t,()=>{Ct(y)("scrolling into view",{}),Fe(S,D),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},St(ur,ti,Js,ei,da,ua,dn,Jv,ey)),xk=tt(([{data:t,firstItemIndex:a,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Te(me(h,Ge(u),De(([,g])=>g!==0),Ge(c,o,a,s,t),ke(([[,g],m,y,v,b,S=[]])=>Qv(g,m,y,v,b,S))),d),{}),St(ur,ei,Pa,da),{singleton:!0}),gk=tt(([{didMount:t},{scrollTo:a},{listState:s}])=>{const o=ge(0);return at(me(t,Ge(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ua(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(a,c)})})}),{initialScrollTop:o}},St(da,dn,Pa),{singleton:!0}),ty=tt(([{scrollVelocity:t}])=>{const a=ge(!1),s=Qe(),o=ge(!1);return Te(me(t,Ge(o,a,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:m}=u;if(d){if(m(c,h))return!1}else if(g(c,h))return!0;return d}),jt()),a),at(me(Ht(a,t,s),Ge(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},St(ti),{singleton:!0}),Nf=tt(([{scrollContainerState:t,scrollTo:a}])=>{const s=Qe(),o=Qe(),c=Qe(),u=ge(!1),d=ge(void 0);return Te(me(Ht(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:m,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-m),viewportHeight:g}))),t),Te(me(a,Ge(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},St(dn)),vk=tt(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const m=Qe(),y=ge(void 0),v=ge(null),b=ge(null);return Te(h,v),Te(g,b),at(me(m,Ge(a,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=tk(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Te(me(y,De(yf),ke(yk)),c),Te(me(u,Ge(y),De(([,S])=>S!==void 0),jt(),ke(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:y}},St(ur,dn,ei,da,Nf));function yk(t){return{align:"start",index:0,offset:t.scrollTop}}const bk=tt(([{topItemsIndexes:t}])=>{const a=ge(0);return Te(me(a,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:a}},St(Pa));function ny(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const jk=ny(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sk=tt(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:m,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Ge(d),or(([,N,T,A],[{bottom:B,items:D,offsetBottom:F,totalCount:w},O])=>{const z=B+F;let U=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(U=z-A,U!==0&&(U+=O))),[U,D,w,z]},[0,[],0,0]),De(([N])=>N!==0),Ge(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Ys),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Ft.DEBUG),N))));function C(N){N>0?(Fe(a,{behavior:"auto",top:-N}),Fe(t,0)):(Fe(t,0),Fe(a,{behavior:"auto",top:-N}))}return at(me(E,Ge(t,u)),([N,T,A])=>{A&&jk()?Fe(t,T-N):C(-N)}),at(me(Ht(an(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Ar(1)),C),Te(me(v,ke(N=>({top:-N}))),a),at(me(m,Ge(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},D])=>{function F(H){return H*(A+D)}if(T.length===0)return F(N);let w=0;const O=Gs(B,0);let z=0,U=0;for(;z<N;){z++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;z+H>N&&(w-=O,H=N-z+1),z+=H,w+=F(H),U++}return w})),N=>{Fe(t,N),requestAnimationFrame(()=>{Fe(a,{top:N}),requestAnimationFrame(()=>{Fe(t,0),Fe(k,!1)})})}),{deviation:t}},St(dn,ti,Pa,ur,ua,Sf)),kk=tt(([t,a,s,o,c,u,d,h,g,m,y])=>({...t,...a,...s,...o,...c,...u,...d,...h,...g,...m,...y}),St(Ef,xk,da,ty,Zv,gk,fk,Nf,ey,ua,Jv)),ry=tt(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:m,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:D},F,{topItemCount:w},{groupCounts:O},z])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Te(X,z.scrollSeekRangeChanged),Te(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:m,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...T}},St(ur,ei,dn,vk,hk,Pa,Js,Sk,bk,Yv,kk));function wk(t,a){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(o,d)||(s[d]=a[d]);return s}const yo=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function ay(t,a,s){const o=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Ne.createContext({});function g(C,N){C.propsReady!==void 0&&Fe(C.propsReady,!1);for(const T of o){const A=C[a.required[T]];Fe(A,N[T])}for(const T of c)if(T in N){const A=C[a.optional[T]];Fe(A,N[T])}C.propsReady!==void 0&&Fe(C.propsReady,!0)}function m(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[a.methods[T]];Fe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=H2(C[a.events[T]]),N),{})}const v=Ne.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Ne.useState(()=>Yo(V2(t),w=>{g(w,A)})),[D]=Ne.useState(og(y,B));yo(()=>{for(const w of d)w in A&&at(D[w],A[w]);return()=>{Object.values(D).map(bf)}},[A,D,B]),yo(()=>{g(B,A)}),Ne.useImperativeHandle(N,ig(m(B)));const F=s;return r.jsx(h.Provider,{value:B,children:s!==void 0?r.jsx(F,{...wk([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Ne.useContext(h);return Ne.useCallback(T=>{Fe(N[C],T)},[N,C])},S=C=>{const N=Ne.useContext(h)[C],T=Ne.useCallback(A=>at(N,A),[N]);return Ne.useSyncExternalStore(T,()=>Ct(N),()=>Ct(N))},k=C=>{const N=Ne.useContext(h)[C],[T,A]=Ne.useState(og(Ct,N));return yo(()=>at(N,B=>{B!==T&&A(ig(B))}),[N,T]),T},E=parseInt(Ne.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Ne.useContext(h)[C];yo(()=>at(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const ly=Ne.createContext(void 0),sy=Ne.createContext(void 0),Cd="-webkit-sticky",yg="sticky",Tf=ny(()=>{if(typeof document>"u")return yg;const t=document.createElement("div");return t.style.position=Cd,t.style.position===Cd?Cd:yg}),iy=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Ed(t){return"self"in t}function Ck(t){return"body"in t}function oy(t,a,s,o=Il,c,u){const d=Ne.useRef(null),h=Ne.useRef(null),g=Ne.useRef(null),m=Ne.useCallback(b=>{let S,k,E;const C=b.target;if(Ck(C)||Ed(C)){const T=Ed(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Fj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,a(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,a,u]);Ne.useEffect(()=>{const b=c||d.current;return o(c||d.current),m({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",m,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",m)}},[d,m,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Ed(S)?(C=Math.max(ia(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ia(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Xv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&a(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Rf(t){return t}const Ek=tt(()=>{const t=ge(h=>`Item ${h}`),a=ge(h=>`Group ${h}`),s=ge({}),o=ge(Rf),c=ge("div"),u=ge(Il),d=(h,g=null)=>an(me(s,ke(m=>m[h]),jt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),Nk=tt(([t,a])=>({...t,...a}),St(ry,Ek)),Tk=({height:t})=>r.jsx("div",{style:{height:t}}),Rk={overflowAnchor:"none",position:Tf(),zIndex:1},cy={overflowAnchor:"none"},Ak={...cy,display:"inline-block",height:"100%"},bg=Ne.memo(function({showTopList:t=!1}){const a=He("listState"),s=Pn("sizeRanges"),o=He("useWindowScroll"),c=He("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=He("itemContent"),m=He("context"),y=He("groupContent"),v=He("trackItemSizes"),b=He("itemSize"),S=He("log"),k=Pn("gap"),E=He("horizontalDirection"),{callbackRef:C}=G2(s,b,v,t?Il:h,S,k,c,E,He("skipAnimationFrameInResizeObserver")),[N,T]=Ne.useState(0);Af("deviation",J=>{N!==J&&T(J)});const A=He("EmptyPlaceholder"),B=He("ScrollSeekPlaceholder")??Tk,D=He("ListComponent"),F=He("ItemComponent"),w=He("GroupComponent"),O=He("computeItemKey"),z=He("isSeeking"),U=He("groupIndices").length>0,H=He("alignToBottom"),q=He("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...rn(A,m)}):r.jsx(D,{...rn(D,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?a.topItems:a.items).map(J=>{const $=J.originalIndex,L=O($+a.firstItemIndex,J.data,m);return z?p.createElement(B,{...rn(B,m),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?p.createElement(w,{...rn(w,m),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:Rk},y(J.index,m)):p.createElement(F,{...rn(F,m),...Dk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Ak:cy},U?g(J.index,J.groupIndex,J.data,m):g(J.index,J.data,m))})})}),Mk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Lk={outline:"none",overflowX:"auto",position:"relative"},Xo=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),zk={position:Tf(),top:0,width:"100%",zIndex:1};function rn(t,a){if(typeof t!="string")return{context:a}}function Dk(t,a){return{item:typeof t=="string"?void 0:a}}const _k=Ne.memo(function(){const t=He("HeaderComponent"),a=Pn("headerHeight"),s=He("HeaderFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null}),Ok=Ne.memo(function(){const t=He("FooterComponent"),a=Pn("footerHeight"),s=He("HeaderFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null});function uy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=oy(h,m,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),r.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Lk:Mk,...c},tabIndex:0,...d,...rn(g,u),children:o})})}function dy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Ne.useRef(null),k=a("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=oy(h,m,g,k,b);return iy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...rn(g,u),children:o})})}const Bk=({children:t})=>{const a=Ne.useContext(ly),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=He("alignToBottom"),u=He("horizontalDirection"),d=Ne.useMemo(()=>Ov(s,g=>ia(g,u?"width":"height")),[s,u]),h=Va(d,!0,He("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{a&&(s(a.viewportHeight),o(a.itemHeight))},[a,s,o]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:Xo(c),children:t})},Ik=({children:t})=>{const a=Ne.useContext(ly),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=He("customScrollParent"),u=Iv(s,c,He("skipAnimationFrameInResizeObserver")),d=He("alignToBottom");return Ne.useEffect(()=>{a&&(o(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,o]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:Xo(d),children:t})},Uk=({children:t})=>{const a=He("TopItemListComponent")??"div",s=He("headerHeight"),o={...zk,marginTop:`${s}px`},c=He("context");return r.jsx(a,{style:o,...rn(a,c),children:t})},Hk=Ne.memo(function(t){const a=He("useWindowScroll"),s=He("topItemsIndexes").length>0,o=He("customScrollParent"),c=He("context");return r.jsxs(o||a?Pk:Vk,{...t,context:c,children:[s&&r.jsx(Uk,{children:r.jsx(bg,{showTopList:!0})}),r.jsxs(o||a?Ik:Bk,{children:[r.jsx(_k,{}),r.jsx(bg,{}),r.jsx(Ok,{})]})]})}),{Component:$k,useEmitter:Af,useEmitterValue:He,usePublisher:Pn}=ay(Nk,{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"}},Hk),Vk=uy({useEmitter:Af,useEmitterValue:He,usePublisher:Pn}),Pk=dy({useEmitter:Af,useEmitterValue:He,usePublisher:Pn}),Fk=$k,Gk=tt(()=>{const t=ge(m=>r.jsxs("td",{children:["Item $",m]})),a=ge(null),s=ge(m=>r.jsxs("td",{colSpan:1e3,children:["Group ",m]})),o=ge(null),c=ge(null),u=ge({}),d=ge(Rf),h=ge(Il),g=(m,y=null)=>an(me(u,ke(v=>v[m]),jt()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});St(ry,Gk);Tf();const jg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Wk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Sg,floor:Io,max:$s,min:Nd,round:kg}=Math;function wg(t,a,s){return Array.from({length:a-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function qk(t){return{...Wk,items:t}}function bo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Yk(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Kk=tt(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:m,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},D])=>{const F=ge(0),w=ge(0),O=ge(jg),z=ge({height:0,width:0}),U=ge({height:0,width:0}),H=Qe(),q=Qe(),X=ge(0),J=ge(null),$=ge({column:0,row:0}),L=Qe(),_=Qe(),I=ge(!1),V=ge(0),ie=ge(!0),M=ge(!1),Y=ge(!1);at(me(k,Ge(V),De(([de,je])=>je!==0)),()=>{Fe(ie,!1)}),at(me(Ht(k,ie,U,z,V,M),De(([de,je,Re,_e,,ae])=>de&&!je&&Re.height!==0&&_e.height!==0&&!ae)),([,,,,de])=>{Fe(M,!0),wf(1,()=>{Fe(H,de)}),Qn(me(m),()=>{Fe(a,[0,0]),Fe(ie,!0)})}),Te(me(_,De(de=>de!=null&&de.scrollTop>0),ir(0)),w),at(me(k,Ge(_),De(([,de])=>de!=null)),([,de])=>{de&&(Fe(z,de.viewport),Fe(U,de.item),Fe($,de.gap),de.scrollTop>0&&(Fe(I,!0),Qn(me(m,Ua(1)),je=>{Fe(I,!1)}),Fe(g,{top:de.scrollTop})))}),Te(me(z,ke(({height:de})=>de)),v),Te(me(Ht(ze(z,bo),ze(U,bo),ze($,(de,je)=>de!==void 0&&de.column===je.column&&de.row===je.row),ze(m)),ke(([de,je,Re,_e])=>({gap:Re,item:je,scrollTop:_e,viewport:de}))),L),Te(me(Ht(ze(F),o,ze($,Yk),ze(U,bo),ze(z,bo),ze(J),ze(w),ze(I),ze(ie),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[je,Re],_e,ae,he,pe,xe,,be,Be])=>{const{column:Oe,row:lt}=_e,{height:Nt,width:xt}=ae,{width:_t}=he;if(xe===0&&(de===0||_t===0))return jg;if(xt===0){const Wt=Cf(Be,de),ln=Wt+Math.max(xe-1,0);return qk(wg(Wt,ln,pe))}const Tt=fy(_t,xt,Oe);let Ze,nt;be?je===0&&Re===0&&xe>0?(Ze=0,nt=xe-1):(Ze=Tt*Io((je+lt)/(Nt+lt)),nt=Tt*Sg((Re+lt)/(Nt+lt))-1,nt=Nd(de-1,$s(nt,Tt-1)),Ze=Nd(nt,$s(0,Ze))):(Ze=0,nt=-1);const ye=wg(Ze,nt,pe),{bottom:mt,top:Et}=Cg(he,_e,ae,ye),Xt=Sg(de/Tt),fn=Xt*Nt+(Xt-1)*lt-mt;return{bottom:mt,itemHeight:Nt,items:ye,itemWidth:xt,offsetBottom:fn,offsetTop:Et,top:Et}})),O),Te(me(J,De(de=>de!==null),ke(de=>de.length)),F),Te(me(Ht(z,U,O,$),De(([de,je,{items:Re}])=>Re.length>0&&je.height!==0&&de.height!==0),ke(([de,je,{items:Re},_e])=>{const{bottom:ae,top:he}=Cg(de,_e,je,Re);return[he,ae]}),jt(Ws)),a);const G=ge(!1);Te(me(m,Ge(G),ke(([de,je])=>je||de!==0)),G);const te=Nn(me(Ht(O,F),De(([{items:de}])=>de.length>0),Ge(G),De(([[de,je],Re])=>{const _e=de.items[de.items.length-1].index===je-1;return(Re||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===je)&&_e}),ke(([[,de]])=>de-1),jt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ir(0),jt())),oe=Nn(me(ze(O),Ge(I),De(([{items:de},je])=>de.length>0&&!je),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),jt(Fv),Ar(0)));Te(oe,S.scrollSeekRangeChanged),Te(me(H,Ge(z,U,F,$),ke(([de,je,Re,_e,ae])=>{const he=Kv(de),{align:pe,behavior:xe,offset:be}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=$s(0,Be,Nd(_e-1,Be));let Oe=rf(je,ae,Re,Be);return pe==="end"?Oe=kg(Oe-je.height+Re.height):pe==="center"&&(Oe=kg(Oe-je.height/2+Re.height/2)),be!==void 0&&be!==0&&(Oe+=be),{behavior:xe,top:Oe}})),g);const ve=an(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Te(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:m,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ve,...b,endReached:te,propsReady:E,rangeChanged:oe,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...D}},St(Ef,dn,ti,ty,da,Nf,ua));function fy(t,a,s){return $s(1,Io((t+s)/(Io(a)+s)))}function Cg(t,a,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=rf(t,a,s,o[0].index);return{bottom:rf(t,a,s,o[o.length-1].index)+c,top:u}}function rf(t,a,s,o){const c=fy(t.width,s.width,a.column),u=Io(o/c),d=u*s.height+$s(0,u-1)*a.row;return d>0?d+a.row:d}const Xk=tt(()=>{const t=ge(v=>`Item ${v}`),a=ge({}),s=ge(null),o=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Rf),d=ge("div"),h=ge(Il),g=(v,b=null)=>an(me(a,ke(S=>S[v]),jt()),b),m=ge(!1),y=ge(!1);return Te(ze(y),m),{components:a,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:m,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Qk=tt(([t,a])=>({...t,...a}),St(Kk,Xk)),Zk=Ne.memo(function(){const t=wt("gridState"),a=wt("listClassName"),s=wt("itemClassName"),o=wt("itemContent"),c=wt("computeItemKey"),u=wt("isSeeking"),d=Fn("scrollHeight"),h=wt("ItemComponent"),g=wt("ListComponent"),m=wt("ScrollSeekPlaceholder"),y=wt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=wt("log"),k=wt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=Va(Ne.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:D}=A.getBoundingClientRect();v({height:B,width:D})}b({column:Eg("column-gap",getComputedStyle(N).columnGap,S),row:Eg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return iy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:r.jsx(g,{className:a,ref:C,...rn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?r.jsx(m,{...rn(m,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):p.createElement(h,{...rn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),Jk=Ne.memo(function(){const t=wt("HeaderComponent"),a=Fn("headerHeight"),s=wt("headerFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null}),ew=Ne.memo(function(){const t=wt("FooterComponent"),a=Fn("footerHeight"),s=wt("headerFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null}),tw=({children:t})=>{const a=Ne.useContext(sy),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=Va(Ne.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Ne.useEffect(()=>{a&&(o({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,o,s]),r.jsx("div",{ref:c,style:Xo(!1),children:t})},nw=({children:t})=>{const a=Ne.useContext(sy),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=wt("customScrollParent"),u=Iv(s,c,!1);return Ne.useEffect(()=>{a&&(o({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,o]),r.jsx("div",{ref:u,style:Xo(!1),children:t})},rw=Ne.memo(function({...t}){const a=wt("useWindowScroll"),s=wt("customScrollParent"),o=s||a?lw:aw,c=s||a?nw:tw,u=wt("context");return r.jsx(o,{...t,...rn(o,u),children:r.jsxs(c,{children:[r.jsx(Jk,{}),r.jsx(Zk,{}),r.jsx(ew,{})]})})}),{useEmitter:py,useEmitterValue:wt,usePublisher:Fn}=ay(Qk,{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"}},rw),aw=uy({useEmitter:py,useEmitterValue:wt,usePublisher:Fn}),lw=dy({useEmitter:py,useEmitterValue:wt,usePublisher:Fn});function Eg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Ft.WARN),a==="normal"?0:parseInt(a??"0",10)}const sw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},my={source:"Own",installed:"Installed"};function iw(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 ow(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Ng({origin:t,count:a,filteredCount:s,updateCount:o,children:c}){const u=sw[t],[d,h]=p.useState(()=>iw(u)),g=p.useCallback(()=>{h(b=>{const S=!b;return ow(u,S),S})},[u]),m=my[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(uw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:m}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),o!=null&&o>0&&r.jsx(cw,{origin:t,updateCount:o})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function cw({origin:t,updateCount:a}){const[s,o]=p.useState(!1),c=my[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function uw({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 Mf(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 dw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=p.useRef(null),d=p.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return p.useEffect(()=>{function g(m){var b;if(m.key!=="/")return;const y=m.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(m.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>a(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(a(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function fw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function pw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function mw({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(Ev)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ni(t){const{version:a,showPrefix:s=!0,size:o="md"}=t;if(!a||typeof a!="string"||a.trim()==="")return null;const c=s&&!a.startsWith("v")?`v${a}`:a,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":a,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}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:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function hw({skill:t,isSelected:a,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&r.jsx(ni,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(fw,{target:t.symlinkTarget??null}),r.jsx(pw,{skill:t}),r.jsx(mw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Uo=p.memo(hw);function xw({plugin:t,skills:a,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...a].sort((d,h)=>d.skill.localeCompare(h.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Uo,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function gw(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 Tg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,m]=p.useState(()=>gw(o,s)),y=d?!1:g,v=p.useCallback(()=>{m(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>r.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const zo=new Map,Ba=new Map,Bs=new Map;function Tn(t){zo.delete(t),Ba.delete(t);const a=Bs.get(t);if(a)for(const s of a)s()}function ri(t,a,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=p.useState(0),d=p.useRef(!0),h=p.useRef(t);h.current=t;const g=()=>Tn(t);p.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),p.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return Bs.has(t)||Bs.set(t,new Set),Bs.get(t).add(b),()=>{var S;(S=Bs.get(t))==null||S.delete(b)}},[t,c]),p.useEffect(()=>{if(!c)return;const b=zo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Ba.has(t)){const C=Ba.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=a().then(C=>{zo.set(t,{data:C,fetchedAt:Date.now()}),Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Ba.set(t,k)},[t,a,o,c]);const m=zo.get(t),y=c&&!m&&Ba.has(t);return{data:m==null?void 0:m.data,loading:y||c&&!m,error:void 0,revalidate:g}}function vw({pluginName:t,enabled:a,onAfterAction:s}){const[o,c]=p.useState(!1),[u,d]=p.useState(null),[h,g]=p.useState(null),m=p.useRef(null);p.useEffect(()=>{if(!o)return;function v(b){m.current&&!m.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),Dv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return r.jsxs("div",{ref:m,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Td,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Td,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Td,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Td({onClick:t,disabled:a,busy:s,label:o,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Rg({name:t,count:a,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",m=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:m?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[m&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(yw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return m?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function yw({label:t,title:a,icon:s,onClick:o,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function bw(){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 jw(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function Sw(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 kw(t,a){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||o!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function af(t,a={}){const{enabled:s=!0,target:o}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(jw),p.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const m=g,y=Sw(m.target);for(const v of c.current){if(!kw(m,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(m);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const ww=200;function Cw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Ew(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Mf(g,a)),d={};for(const g of u){const m=g.pluginName??g.plugin;(d[m]||(d[m]=[])).push(g)}const h=Object.entries(d).sort((g,m)=>g[0].localeCompare(m[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Nw(t,a){const s=[],o=[],c=[];for(const d of t){const h=Cw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Mf(v,a)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const m=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(o),global:u(c)}}function Tw(t,a){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var m;const d=u.filter(y=>Mf(y,a)),h={};for(const y of d)(h[m=y.plugin]||(h[m]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Rw({skills:t,selectedKey:a,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:m,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(G=>G.scope!==void 0&&G.scope!==null),k=g??"claude-cli",[E,C]=p.useState(""),N=p.useDeferredValue(E),T=p.useMemo(()=>Nw(t,N),[t,N]),A=p.useMemo(()=>Ew(t,N),[t,N]),B=k==="claude-code",{plugins:D}=D2(),F=B?{plugins:D??[]}:void 0,w=p.useMemo(()=>{const G=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=G.get(te.name);G.set(te.name,!!fe||!!te.enabled)}return G},[F==null?void 0:F.plugins]),[O,z]=p.useState(()=>lf(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=p.useState(()=>lf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=p.useCallback(G=>{z(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(G))}catch{}},[k]),X=p.useCallback(G=>{H(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(G))}catch{}},[k]),{own:J,installed:$}=p.useMemo(()=>Tw(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=ww,I=p.useMemo(()=>{const G=te=>{const fe=[];for(const[,oe]of te){const ve=[...oe].sort((de,je)=>de.skill.localeCompare(je.skill));fe.push(...ve)}return fe};return S?[...G(T.own.byPlugin),...G(T.installed.byPlugin),...G(T.global.byPlugin)]:[...G(J.byPlugin),...G($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=p.useMemo(()=>a?I.findIndex(G=>G.plugin===a.plugin&&G.skill===a.skill):-1,[I,a]),ie=p.useCallback(G=>{if(I.length===0)return;const te=V<0?G>0?0:I.length-1:Math.min(Math.max(V+G,0),I.length-1);s(I[te])},[I,V,s]),M=p.useMemo(()=>{if(!v)return null;const[G,te]=v.split("/");if(!G||!te)return null;const fe=t.find(de=>de.plugin===G&&de.skill===te);if(!fe)return{plugin:G,skill:te,bucket:null,pluginName:null};const oe=fe.source==="plugin"?"plugin":"project",ve=oe==="plugin"?fe.pluginName??G:null;return{plugin:G,skill:te,bucket:oe,pluginName:ve}},[v,t]),Y=p.useRef(null);return p.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const G=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${G}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>ie(1)},{key:"k",handler:()=>ie(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(dw,{value:E,onChange:C}),o&&r.jsx(Dw,{}),!o&&c&&r.jsx(_w,{error:c,onRetry:u}),!o&&!c&&S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Rg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&r.jsxs(r.Fragment,{children:[r.jsx(zs,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?r.jsx(Mg,{queryActive:!!E,agentId:k}):r.jsx(Ds,{items:A.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(zs,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:A.availablePersonal.filtered===0?r.jsx(Mw,{queryActive:!!E,agentId:k}):r.jsx(Ds,{items:A.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsxs(zs,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?r.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-available-${G}-collapsed`,headerActionSlot:B?r.jsx(vw,{pluginName:G,enabled:w.get(G)??!0}):void 0,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${G}`))]})]}),r.jsx(zw,{}),r.jsx(Rg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&r.jsxs(r.Fragment,{children:[r.jsx(zs,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(m==null?void 0:m.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ds,{items:A.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsx(zs,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?r.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",r.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-authoring-${G}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===G,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${G}`))})]})]}),!o&&!c&&!S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ng,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ds,{items:J.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Lw,{}),r.jsx(Ng,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?r.jsx(Mg,{queryActive:!!E}):r.jsx(Ds,{items:$.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function lf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function zs({label:t,storageKey:a,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=p.useState(()=>lf(a)),m=d?!1:h,y=p.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(a,String(S))}catch{}return S})},[a]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!m,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:m?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!m&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function Aw(t){const a=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Ds({items:t,selectedKey:a,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Aw(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Fk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,m=!!a&&a.plugin===g.plugin&&a.skill===g.skill;return r.jsx(Uo,{skill:g,isSelected:m,onSelect:()=>s(g),onContextMenu:o})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>r.jsx(xw,{plugin:u,skills:d,selectedKey:a,onSelect:s,onContextMenu:o},u))})}function Ag({queryActive:t}){return t?r.jsx(zl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(zl,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Lf,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Mg({queryActive:t,agentId:a}){return t?r.jsx(zl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(zl,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install <skill>"})," to add one."]})})}function Mw({queryActive:t,agentId:a}){return t?r.jsx(zl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(zl,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install --global <skill>"})," to add one."]})})}function zl({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function Lf({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 Lw(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function zw(){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 Dw(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(bw,{},t))})}function _w({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:Ow(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 Ow(t){const a=t.split(`
66
+ `)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const hy=240,xy=480,gy="vskill-sidebar-width",Vs=320;function zf(t){return Number.isFinite(t)?Math.round(Math.max(hy,Math.min(xy,t))):Vs}function Bw(){try{const t=localStorage.getItem(gy);if(!t)return Vs;const a=Number(t);return Number.isFinite(a)?zf(a):Vs}catch{return Vs}}function Iw(t){try{localStorage.setItem(gy,String(zf(t)))}catch{}}function Uw({initialWidth:t,onChange:a}){const s=p.useRef({startX:0,startWidth:t,pointerId:null}),o=p.useRef(t);return p.useEffect(()=>{o.current=t},[t]),p.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=zf(s.current.startWidth+h);o.current=g,a(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,Iw(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":hy,"aria-valuemax":xy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Hw({connected:t,hint:a,onRetry:s}){return t?null:r.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),r.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&r.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),r.jsx("div",{style:{flex:1}}),s&&r.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function vy(t,a){if(t!==401||typeof window>"u"||!a||typeof a!="object")return;const s=a;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function yy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Rd(){const[t,a]=p.useState([]),[s,o]=p.useState(!1),[c,u]=p.useState(!1),[d,h]=p.useState(null),g=p.useRef(null),m=p.useCallback(async(v,b)=>{a([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=yy(b),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw vy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
67
+ `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};A==="done"?(u(!0),a(U=>[...U,z])):a(U=>[...U,z])}catch{}A=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=p.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:m,stop:y}}function $w(t){const a=p.useRef(t);a.current=t;const[s,o]=p.useState(new Set),c=p.useRef(new Map),u=p.useCallback(async(m,y,v)=>{var S;(S=c.current.get(m))==null||S.abort();const b=new AbortController;c.current.set(m,b),o(k=>{const E=new Set(k);return E.add(m),E});try{const k=yy(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw vy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
68
+ `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};a.current.onEvent(m,z)}catch{}A=""}}a.current.onDone(m)}catch(k){k.name!=="AbortError"&&a.current.onError(m,k.message)}finally{o(k=>{const E=new Set(k);return E.delete(m),E}),c.current.delete(m)}},[]),d=p.useCallback(m=>{var y;(y=c.current.get(m))==null||y.abort()},[]),h=p.useCallback(()=>{for(const m of c.current.values())m.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const Vw={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 Pw(t,a){var s,o;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:a.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:a.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function Fw(t){if(t==="unit"||t==="integration")return t}function Gw(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}a.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const by=p.createContext(null);function An(){const t=p.useContext(by);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Ww({plugin:t,skill:a,origin:s,children:o}){const c=s==="installed",[u,d]=p.useReducer(Pw,{...Vw,plugin:t,skill:a}),h=p.useRef(new Set),g=p.useRef(new Set),m=p.useRef(new Map),y=p.useCallback((ae,he)=>{let pe=m.current.get(ae);pe||(pe={assertions:[]},m.current.set(ae,pe)),Gw(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:ae,result:{...pe,assertions:[...pe.assertions]}})},[]),v=p.useCallback(ae=>{if(g.current.has(ae))return;g.current.add(ae);const he=m.current.get(ae)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:ae,result:{...he,assertions:[...he.assertions]}}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=p.useCallback((ae,he)=>{g.current.has(ae)||(g.current.add(ae),d({type:"CASE_RUN_ERROR",caseId:ae,error:he}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:k,stopAll:E}=$w({onEvent:y,onDone:v,onError:b});p.useEffect(()=>()=>{E()},[E]);const C=p.useCallback(async()=>{try{const ae=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!ae.ok){if(ae.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await ae.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,a]);p.useEffect(()=>{let ae=!1;async function he(){try{const[pe,xe,be]=await Promise.allSettled([Ce.getSkillDetail(t,a),Ce.getEvals(t,a),Ce.getLatestBenchmark(t,a)]);if(ae)return;let Be=null,Oe=null;if(xe.status==="fulfilled")Be=xe.value;else{const lt=xe.reason;Oe=(lt==null?void 0:lt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:be.status==="fulfilled"?be.value:null})}catch(pe){ae||d({type:"SET_ERROR",error:pe.message})}}return he(),C(),()=>{ae=!0}},[t,a,C]);const N=p.useCallback(async()=>{if(!c)try{await Ce.applyImprovement(t,a,u.skillContent),d({type:"CONTENT_SAVED"})}catch(ae){d({type:"SET_ERROR",error:ae.message})}},[c,t,a,u.skillContent]),T=p.useCallback(async ae=>{if(!c)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,a]),A=p.useCallback((ae,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(ae);if((pe==null?void 0:pe.status)!=="running")if(m.current.delete(ae),g.current.delete(ae),d({type:"CASE_RUN_START",caseId:ae,mode:he}),he==="comparison"){const xe=`/api/skills/${t}/${a}/compare`;S(ae,xe,{eval_ids:[ae]})}else{const xe=`/api/skills/${t}/${a}/benchmark/case/${ae}`;S(ae,xe,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),B=p.useCallback((ae="benchmark")=>{var xe;if(c)return;const he=((xe=u.evals)==null?void 0:xe.evals)??[];if(he.length===0)return;const pe=he.map(be=>be.id);for(const be of pe)m.current.delete(be),g.current.delete(be);d({type:"BULK_RUN_START",caseIds:pe,mode:ae}),h.current=new Set(pe);for(const be of pe)if(ae==="comparison")S(be,`/api/skills/${t}/${a}/compare`,{eval_ids:[be]});else{const Be=`/api/skills/${t}/${a}/benchmark/case/${be}`;S(be,Be,ae==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),D=p.useCallback(ae=>{k(ae),d({type:"CASE_RUN_CANCEL",caseId:ae}),h.current.delete(ae),g.current.add(ae)},[k]),F=p.useCallback(()=>{E(),d({type:"CANCEL_ALL"}),h.current.clear()},[E]),w=p.useCallback(async(ae,he)=>{d({type:"OPEN_IMPROVE",evalId:ae})},[]),O=p.useCallback(async(ae,he)=>{try{await Ce.applyImprovement(t,a,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),A(ae,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,a,A]),z=Rd(),U=p.useRef(null),H=p.useRef(0);p.useEffect(()=>{const ae=z.events;for(let he=H.current;he<ae.length;he++){const pe=ae[he],xe=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const be=xe.improved,Be=xe.reasoning,Oe=xe.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:be,reasoning:Be,evalChanges:Oe})}if(pe.event==="error"){const be=xe;d({type:"AI_EDIT_ERROR",message:be.description||"Unknown error",classified:be})}}H.current=ae.length},[z.events]),p.useEffect(()=>{z.error&&d({type:"AI_EDIT_ERROR",message:z.error})},[z.error]),p.useEffect(()=>()=>{z.stop()},[z.stop]);const q=p.useCallback(async(ae,he,pe)=>{c||(H.current=0,d({type:"AI_EDIT_LOADING"}),U.current=z.stop,z.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:ae,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:he,model:pe}))},[c,t,a,u.skillContent,u.evals,z]),X=p.useCallback(()=>{z.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[z]),J=p.useCallback(async()=>{const ae=u.aiEditResult;if(ae!=null&&ae.improved)try{if(await Ce.applyImprovement(t,a,ae.improved),d({type:"SET_CONTENT",content:ae.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Ha(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),xe=u.evals??{skill_name:a,evals:[]},be=pe(xe,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ce.saveEvals(t,a,be);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:be}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:he.message})}},[t,a,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),$=p.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),L=p.useCallback(ae=>{d({type:"TOGGLE_EVAL_CHANGE",index:ae})},[]),_=p.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=p.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=p.useCallback(async()=>{const ae=u.aiEditEvalsRetry;if(ae)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,a,u.aiEditEvalsRetry]),ie=p.useCallback(async()=>{try{const ae=await Ce.getSkillDetail(t,a);d({type:"SET_CONTENT",content:ae.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:M}=$a(),Y=Rd(),G=p.useRef(0);p.useEffect(()=>{const ae=Y.events;for(let he=G.current;he<ae.length;he++){const pe=ae[he],xe=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const be=xe;Ce.saveEvals(t,a,be).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}pe.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:xe})}G.current=ae.length},[Y.events,t,a]),p.useEffect(()=>{Y.error&&d({type:"SET_ERROR",error:Y.error})},[Y.error]),p.useEffect(()=>()=>{Y.stop()},[Y.stop]);const te=p.useCallback(async ae=>{if(c)return;G.current=0,d({type:"GENERATE_EVALS_START"});const he={};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=Fw(ae==null?void 0:ae.testType);pe&&(he.testType=pe),Y.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,a,Y,M]),fe=Rd(),oe=p.useRef(0);p.useEffect(()=>()=>{fe.stop()},[fe.stop]),p.useEffect(()=>{const ae=fe.events;for(let he=oe.current;he<ae.length;he++){const pe=ae[he];if(pe.event==="classifying"){const xe=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:xe.index,total:xe.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){ve.current&&(clearTimeout(ve.current),ve.current=null);const xe=pe.data;if(xe.error)d({type:"ACTIVATION_ERROR",error:xe.error});else{d({type:"ACTIVATION_DONE",summary:xe});const be={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(M==null?void 0:M.model)||"unknown",provider:(M==null?void 0:M.provider)||"unknown",promptCount:xe.total,summary:{precision:xe.precision,recall:xe.recall,reliability:xe.reliability,tp:xe.tp,tn:xe.tn,fp:xe.fp,fn:xe.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[be,...u.activationHistory??[]]})}}}oe.current=ae.length},[fe.events,M,u.activationHistory]),p.useEffect(()=>{fe.error&&(ve.current&&(clearTimeout(ve.current),ve.current=null),d({type:"ACTIVATION_ERROR",error:fe.error}))},[fe.error]);const ve=p.useRef(null),de=p.useCallback(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),fe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[fe]),je=p.useCallback(ae=>{const pe=ae.trim().split(`
69
+ `).filter(Boolean).map(be=>be.startsWith("!")?{prompt:be.slice(1).trim(),expected:"should_not_activate"}:be.startsWith("+")?{prompt:be.slice(1).trim(),expected:"should_activate"}:{prompt:be.trim(),expected:"auto"});oe.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:ae});const xe={prompts:pe};M!=null&&M.provider&&(xe.provider=M.provider),M!=null&&M.model&&(xe.model=M.model),fe.start(`/api/skills/${t}/${a}/activation-test`,xe),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{fe.stop(),d({type:"ACTIVATION_TIMEOUT"}),ve.current=null},12e4)},[t,a,fe,M]),Re=p.useCallback(async(ae=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const he={count:ae};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=await fetch(`/api/skills/${t}/${a}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!pe.ok){let xt=`HTTP ${pe.status}`;try{const _t=await pe.json();_t.error&&(xt=_t.error)}catch{}throw new Error(xt)}const xe=pe.body.getReader(),be=new TextDecoder;let Be="",Oe="",lt=[];for(;;){const{done:xt,value:_t}=await xe.read();if(xt)break;Be+=be.decode(_t,{stream:!0});const Tt=Be.split(`
70
+ `);Be=Tt.pop()||"";for(const Ze of Tt)if(Ze.startsWith("event: "))Oe=Ze.slice(7).trim();else if(Ze.startsWith("data: ")){try{const nt=JSON.parse(Ze.slice(6));if(Oe==="done"){if(nt.error)throw new Error(nt.error);lt=nt.prompts||[]}if(Oe==="error")throw new Error(nt.message||nt.description||"Generation failed")}catch(nt){if(!(nt instanceof SyntaxError))throw nt}Oe=""}}const Nt=lt.map(xt=>`${xt.expected==="should_activate"?"+":"!"}${xt.prompt}`).join(`
71
+ `);d({type:"SET_ACTIVATION_PROMPTS",prompts:Nt}),d({type:"GENERATE_PROMPTS_DONE"})}catch(he){d({type:"GENERATE_PROMPTS_ERROR",error:he.message})}},[t,a,M]),_e=p.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:N,saveEvals:T,runCase:A,runAll:B,cancelCase:D,cancelAll:F,improveForCase:w,applyImproveAndRerun:O,refreshSkillContent:ie,generateEvals:te,runActivationTest:je,cancelActivation:de,generateActivationPrompts:Re,fetchActivationHistory:C,submitAiEdit:q,cancelAiEdit:X,applyAiEdit:J,discardAiEdit:$,toggleEvalChange:L,selectAllEvalChanges:_,deselectAllEvalChanges:I,retryEvalsSave:V}),[u,c,N,T,A,B,D,F,w,O,ie,te,je,de,Re,C,q,X,J,$,L,_,I,V]);return r.jsx(by.Provider,{value:_e,children:o})}function qw(t){if(!t)return[];const a=t.split(`
72
+ `),s=[];for(const o of a)if(!(o.startsWith("--- ")||o.startsWith("+++ "))){if(o.startsWith("@@")){s.push({type:"header",content:o});continue}if(o.startsWith("+")){s.push({type:"add",content:o.slice(1)});continue}if(o.startsWith("-")){s.push({type:"remove",content:o.slice(1)});continue}(o.startsWith(" ")||o===""&&s.length>0)&&s.push({type:"context",content:o.startsWith(" ")?o.slice(1):""})}return s}function Df({contentDiff:t,fromLabel:a,toLabel:s,diffSummary:o,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:h}){const[g,m]=p.useState(u),[y,v]=p.useState("unified"),b=p.useRef(null),S=p.useRef(null),k=p.useMemo(()=>qw(t),[t]),E=p.useMemo(()=>{const D=k.filter(w=>w.type==="add").length,F=k.filter(w=>w.type==="remove").length;return{added:D,removed:F}},[k]),C=p.useMemo(()=>{let D=0,F=0;return k.filter(w=>w.type!=="header").map(w=>w.type==="remove"?(D++,{...w,origNum:D,newNum:null}):w.type==="add"?(F++,{...w,origNum:null,newNum:F}):(D++,F++,{...w,origNum:D,newNum:F}))},[k]),N=p.useMemo(()=>{const D=[],F=[];for(const w of C)if(w.type==="remove")D.push(w);else if(w.type==="add")F.push(w);else{for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});D.push(w),F.push(w)}for(;D.length<F.length;)D.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<D.length;)F.push({type:"context",content:"",origNum:null,newNum:null});return{left:D,right:F}},[C]),T=p.useCallback(D=>{const F=D==="left"?b.current:S.current,w=D==="left"?S.current:b.current;F&&w&&(w.scrollTop=F.scrollTop)},[]);if(!t||k.length===0)return r.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&r.jsx("button",{onClick:h,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const A=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",B=r.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[a," → ",s]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",E.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",E.removed]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>v(y==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:y==="unified"?"Side-by-side":"Unified"}),u&&r.jsx("button",{onClick:()=>m(!g),className:"btn btn-ghost text-[11px]",children:g?"Expand":"Collapse"})]})]}),o&&r.jsx("div",{className:"mx-4 mt-3 px-4 py-2 rounded-lg text-[12px]",style:{background:"var(--accent-muted)",color:"var(--text-secondary)"},children:o}),!g&&(y==="unified"?r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:C.map((D,F)=>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||"​"})]},F))})})}):r.jsxs("div",{className:"mx-4 my-4 grid grid-cols-2 gap-0 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{ref:b,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>T("left"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.left.map((D,F)=>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||"​"})]},F))})})}),r.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>T("right"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.right.map((D,F)=>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||"​"})]},F))})})})]}))]});return d==="modal"?r.jsx("div",{className:A,children:r.jsx("div",{style:{width:"80%",maxWidth:900},children:B})}):B}const Ad="https://verified-skill.com/submit",Yw=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function Kw(t){if(!t)return Ad;const a=t.trim();return!a||!Yw.test(a)?Ad:`${Ad}?repo=${encodeURIComponent(a)}`}const Lg={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 Xw(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function Qw(){const{state:t}=An(),{plugin:a,skill:s}=t,o=er(),{refreshSkills:c,updateCount:u}=o,d=p.useMemo(()=>o.state.skills.find(L=>L.plugin===a&&L.skill===s)??null,[o.state.skills,a,s]),h=`versions/${a}/${s}`,g=p.useCallback(()=>Ce.getSkillVersions(a,s),[a,s]),{data:m,loading:y}=ri(h,g),[v,b]=p.useState(null),[S,k]=p.useState(null),[E,C]=p.useState(null),[N,T]=p.useState(!1),[A,B]=p.useState("idle"),[D,F]=p.useState(null),w=p.useRef(null),O=p.useRef(null),z=p.useMemo(()=>(m==null?void 0:m.find(L=>L.isInstalled))??null,[m]),U=p.useMemo(()=>(m==null?void 0:m[0])??null,[m]),H=z&&U&&z.version!==U.version,q=p.useCallback(L=>{v?!S&&L!==v?k(L):(b(L),k(null),C(null)):(b(L),C(null))},[v,S]),X=p.useCallback(async(L,_)=>{T(!0);try{const I=await Ce.getVersionDiff(a,s,L,_);C(I)}catch{C(null)}finally{T(!1)}},[a,s]);p.useEffect(()=>{if(v&&S){const L=m||[],_=L.findIndex(M=>M.version===v),I=L.findIndex(M=>M.version===S),[V,ie]=_>I?[v,S]:[S,v];X(V,ie)}},[v,S,m,X]);const J=p.useCallback(()=>{!z||!U||(b(z.version),k(U.version))},[z,U]),$=p.useCallback(async()=>{B("updating"),F(null);const L=new AbortController;w.current=L;try{const _=await Ce.postSkillUpdate(a,s,L.signal);if(_.ok)B("done"),c(),Tn(h);else{const I=`Update failed (HTTP ${_.status}): ${_.body||"no response body"}`;B("error"),F(I)}}catch(_){if(_ instanceof DOMException&&_.name==="AbortError")return;const I=_ instanceof Error?_.message:"Network error";B("error"),F(I)}finally{w.current===L&&(w.current=null)}},[a,s,h,c]);if(p.useEffect(()=>()=>{var L;(L=w.current)==null||L.abort(),w.current=null},[]),y)return r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!m||m.length===0){if((d==null?void 0:d.origin)==="source"){const _=Kw((d==null?void 0:d.homepage)??null);return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),r.jsx("div",{className:"text-[13px] text-center mb-5 max-w-md",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:"This skill is local-only — the version history shown here is sourced from verified-skill.com. Submit your skill to start tracking versions and share it with others."}),r.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary text-[12px]","data-testid":"versions-empty-state-cta",children:"Submit on verified-skill.com"})]})}return d!=null&&d.version?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsxs("div",{"data-testid":"version-row-local",className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg",style:{background:"transparent",border:"1px solid transparent"},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:10,height:10,background:"var(--accent)",border:"2px solid var(--accent)"}}),r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:d.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"LOCAL"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]})}),r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Local-only — this skill is not registered on verified-skill.com, so no upstream history is available."})]})]})]}):r.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:r.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return r.jsxs("div",{className:"p-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"flex items-center gap-2",children:[H&&r.jsx("button",{onClick:J,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),H&&A!=="done"&&(A==="error"?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:D||"Update failed"}),r.jsx("button",{onClick:$,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):r.jsx("button",{onClick:$,disabled:A!=="idle",className:"btn btn-primary text-[11px]",children:A==="idle"?`Update to ${U==null?void 0:U.version}`:A==="updating"?"Starting update...":A==="scanning"?"Scanning...":"Installing..."})),u>1&&r.jsxs("button",{onClick:()=>{window.location.hash="#/updates"},className:"text-[11px] hover:underline",style:{color:"var(--text-tertiary)",background:"transparent",border:"none",cursor:"pointer"},children:["Manage all updates (",u,")"]})]})]}),v&&!S&&r.jsxs("div",{className:"text-[11px] mb-3 px-3 py-2 rounded-lg",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:["Click another version to compare with ",v]}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsx("div",{className:"space-y-1",children:m.map(L=>{const _=Lg[L.certTier]||Lg.COMMUNITY,I=L.version===v||L.version===S,V=L.isInstalled;return r.jsxs("button",{onClick:()=>q(L.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:I?"var(--accent-muted)":"transparent",border:I?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:ie=>{I||(ie.currentTarget.style.background="var(--surface-1)")},onMouseLeave:ie=>{I||(ie.currentTarget.style.background="transparent")},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:V?10:8,height:V?10:8,background:V?"var(--accent)":"var(--surface-3)",border:V?"2px solid var(--accent)":"2px solid var(--border-default)"}}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:L.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.bg,color:_.text},children:L.certTier}),V&&r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(L.createdAt).toLocaleDateString()})]}),L.diffSummary&&r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:Xw(L.diffSummary,80)})]},L.version)})}),r.jsx("div",{ref:O,style:{height:1}})]}),N&&r.jsx("div",{className:"mt-4",children:r.jsx("div",{className:"skeleton h-48 rounded-xl"})}),E&&!N&&r.jsx("div",{className:"mt-4",children:r.jsx(Df,{contentDiff:E.contentDiff,fromLabel:E.from,toLabel:E.to,diffSummary:E.diffSummary,renderContext:"inline",onRetry:()=>v&&S&&X(E.from,E.to)})})]})}function Zw(t){const a=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!a)return{metadata:{},body:t};const s=a[1],o=a[2].trim(),c={},u=s.split(`
73
+ `);let d="",h=!1;for(const g of u){const m=g.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(m&&d&&h){const b=m[1],S=m[2].trim();let k=c[d];if((typeof k!="object"||Array.isArray(k))&&(k={},c[d]=k),!S)k[b]=[];else{const E=S.match(/^\[(.+)\]$/);E?k[b]=E[1].split(",").map(C=>C.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[b]=S.replace(/^["']|["']$/g,"")}continue}const y=g.match(/^\s+-\s+(.+)$/);if(y&&d){h=!1;const b=c[d];Array.isArray(b)?b.push(y[1].trim().replace(/^["']|["']$/g,"")):c[d]=[y[1].trim().replace(/^["']|["']$/g,"")];continue}const v=g.match(/^([\w-]+):\s*(.*)$/);if(v){d=v[1];const b=v[2].trim();if(h=!1,!b){c[d]={},h=!0;continue}const S=b.match(/^\[(.+)\]$/);if(S){c[d]=S[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:o}}function Qo(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=Jw(a);return s=s.replace(/```(\w*)\n([\s\S]*?)```/g,'<pre style="background:var(--surface-2);padding:0.75rem;border-radius:6px;overflow-x:auto;font-size:12px;line-height:1.5;margin:0.5rem 0;border:1px solid var(--border-subtle)"><code>$2</code></pre>'),s=s.replace(/^### (.+)$/gm,'<div style="font-weight:600;font-size:14px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^## (.+)$/gm,'<div style="font-weight:700;font-size:15px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^# (.+)$/gm,'<div style="font-weight:700;font-size:1rem;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer" style="color:var(--accent);text-decoration:underline">$1</a>'),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/\*([^*]+)\*/g,"<em>$1</em>"),s=s.replace(/`([^`]+)`/g,'<code style="background:var(--surface-3);padding:0.1rem 0.3rem;border-radius:3px;font-size:0.85em">$1</code>'),s=s.replace(/^- (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">• $1</div>'),s=s.replace(/^(\d+)\. (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">$1. $2</div>'),s=s.replace(/\n\n/g,'<div style="height:0.5rem"></div>'),s=s.replace(/\n/g,"<br/>"),s}catch{return`<pre style="white-space:pre-wrap;font-size:12px;line-height:1.5">${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`}}function Jw(t){const a=t.split(`
74
+ `),s=[];let o=0;for(;o<a.length;)if(a[o].trim().startsWith("|")&&o+1<a.length&&a[o+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(a[o+1])){const c=zg(a[o]);o+=2;const u=[];for(;o<a.length&&a[o].trim().startsWith("|");)u.push(zg(a[o])),o++;const d='style="text-align:left;padding:0.4rem 0.6rem;font-weight:600;font-size:12px;color:var(--text-primary);border-bottom:1px solid var(--border-default)"',h='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let g='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';g+="<thead><tr>";for(const m of c)g+=`<th ${d}>${m}</th>`;g+="</tr></thead><tbody>";for(const m of u){g+="<tr>";for(const y of m)g+=`<td ${h}>${y}</td>`;g+="</tr>"}g+="</tbody></table>",s.push(g)}else s.push(a[o]),o++;return s.join(`
75
75
  `)}function zg(t){return t.split("|").map(a=>a.trim()).filter(a=>a.length>0)}function Zo(t,a){const s=t.split(`
76
76
  `),o=a.split(`
77
- `);if(s.length>1e3||o.length>1e3)return[...s.map(y=>({type:"unchanged",content:y}))];const c=s.length,u=o.length,d=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let y=1;y<=c;y++)for(let v=1;v<=u;v++)s[y-1]===o[v-1]?d[y][v]=d[y-1][v-1]+1:d[y][v]=Math.max(d[y-1][v],d[y][v-1]);const h=[];let g=c,p=u;for(;g>0||p>0;)g>0&&p>0&&s[g-1]===o[p-1]?(h.push({type:"unchanged",content:s[g-1]}),g--,p--):p>0&&(g===0||d[g][p-1]>=d[g-1][p])?(h.push({type:"added",content:o[p-1]}),p--):(h.push({type:"removed",content:s[g-1]}),g--);return h.reverse()}function eC(t,a){if(a&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return r.jsx("div",{className:"spinner",style:{width:10,height:10,flexShrink:0}});const o=new Set(["generating","comparing","preparing","generating_skill","generating_baseline","scoring","action_items"]);return r.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.has(t)?"var(--accent)":"var(--green)"}})}function ri({entries:t,isRunning:a}){const[s,o]=m.useState(!1),c=m.useRef(null);return m.useEffect(()=>{c.current&&!s&&(c.current.scrollTop=c.current.scrollHeight)},[t,s]),t.length===0&&!a?null:r.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between px-3 py-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-tertiary)"},children:[r.jsxs("span",{className:"flex items-center gap-2",children:[a&&r.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{transform:s?"rotate(0)":"rotate(180deg)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&r.jsx("div",{ref:c,className:"px-3 pb-3 space-y-1 max-h-48 overflow-y-auto",children:t.map((u,d)=>{const h=d===t.length-1&&a,g=d===0?"0s":`+${((u.timestamp-t[0].timestamp)/1e3).toFixed(1)}s`;return r.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:h?1:.7},children:[eC(u.phase,h),r.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:g}),r.jsx("span",{style:{color:h?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&r.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},d)})})]})}const Dg={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 Jo({error:t,onRetry:a,onDismiss:s}){const[o,c]=m.useState(null),u=m.useRef(null);m.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),m.useEffect(()=>{if(!(o==null||o<=0))return u.current=setInterval(()=>{c(g=>g==null||g<=1?(u.current&&clearInterval(u.current),0):g-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[o!=null&&o>0]);const d=Dg[t.category]||Dg.unknown,h=o!=null&&o>0;return r.jsxs("div",{className:"rounded-lg overflow-hidden animate-fade-in",style:{border:`1px solid color-mix(in srgb, ${d.color} 30%, transparent)`,background:`color-mix(in srgb, ${d.color} 6%, var(--surface-1))`},children:[r.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{style:{fontSize:14},children:d.icon}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:d.color},children:t.title})]}),s&&r.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-3.5 pb-3",children:[r.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),r.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(a||o!=null)&&r.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:a&&r.jsx("button",{onClick:a,disabled:h,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:h?.5:1},children:h?`Retry in ${o}s`:"Retry"})})]})]})}function tC({plugin:t,skill:a,skillContent:s,onApplied:o}){const[c,u]=m.useState("closed"),{config:d}=Ha(),[h,g]=m.useState("claude-cli"),[p,y]=m.useState("opus"),[v,b]=m.useState([]),[S,k]=m.useState(""),[E,C]=m.useState(""),[N,T]=m.useState(null),[A,B]=m.useState(null),[D,F]=m.useState([]),[w,O]=m.useState(!1),z=m.useRef(null);m.useEffect(()=>{if(!d)return;d.providers.find(_=>_.id==="claude-cli"&&_.available)&&(g("claude-cli"),y("opus"))},[d]),m.useEffect(()=>()=>{var L;(L=z.current)==null||L.abort()},[]);function U(){return d==null?void 0:d.providers.find(L=>L.id===h&&L.available)}const H=m.useCallback(()=>{var L;(L=z.current)==null||L.abort(),u("open")},[]);async function q(){u("loading"),T(null),B(null),F([]);const L=new AbortController;z.current=L;try{const _=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(a)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,model:p}),signal:L.signal});if(!_.ok||!_.body){let Y=`HTTP ${_.status}`;try{const G=await _.json();G.error&&(Y=G.error)}catch{}throw new Error(Y)}const I=_.body.getReader(),V=new TextDecoder;let se="",M="";for(;;){const{done:Y,value:G}=await I.read();if(Y)break;se+=V.decode(G,{stream:!0});const te=se.split(`
78
- `);se=te.pop()||"";for(const fe of te)if(fe.startsWith("event: "))M=fe.slice(7).trim();else if(fe.startsWith("data: ")){try{const ie=JSON.parse(fe.slice(6));M==="progress"?F(ye=>[...ye,{phase:ie.phase,message:ie.message,timestamp:Date.now()}]):M==="done"||M==="complete"?(k(ie.improved),C(ie.reasoning||""),b(Zo(ie.original||s,ie.improved)),u("diff_shown")):M==="error"&&(T(ie.message||ie.description||"Unknown error"),ie.category&&B(ie),u("open"))}catch{}M=""}}}catch(_){_.name!=="AbortError"&&(T(_.message),u("open"))}finally{z.current=null}}async function X(){O(!0);try{await Ce.applyImprovement(t,a,S),o(S),u("closed")}catch(L){T(L.message)}finally{O(!1)}}function J(){u("closed"),b([]),k(""),C(""),T(null)}if(c==="closed")return r.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const $=U();return r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),r.jsx("button",{onClick:J,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:L=>{L.currentTarget.style.background="var(--surface-3)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:h,onChange:L=>{g(L.target.value);const _=d==null?void 0:d.providers.find(I=>I.id===L.target.value);_!=null&&_.models[0]&&y(_.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(L=>L.available).map(L=>r.jsx("option",{value:L.id,children:L.label},L.id))})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:p,onChange:L=>y(L.target.value),disabled:c==="loading",children:$==null?void 0:$.models.map(L=>r.jsx("option",{value:L.id,children:L.label},L.id))})]}),c==="loading"?r.jsx("button",{onClick:H,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):r.jsx("button",{onClick:q,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&D.length>0&&r.jsx("div",{className:"mt-3",children:r.jsx(ri,{entries:D,isRunning:!0})})]}),N&&r.jsx("div",{className:"mb-4",children:A?r.jsx(Jo,{error:A,onRetry:q,onDismiss:()=>{T(null),B(null)}}):r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:N})}),c==="diff_shown"&&r.jsxs(r.Fragment,{children:[E&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),E]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:v.map((L,_)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:L.type==="added"?"rgba(34,197,94,0.1)":L.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:L.type==="added"?"var(--green)":L.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:L.type==="added"?"3px solid var(--green)":L.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:L.type==="added"?"+":L.type==="removed"?"-":" "}),L.content]},_))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:X,disabled:w,className:"btn btn-primary",children:w?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),r.jsx("button",{onClick:J,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const _g={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"}},nC={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function rC({change:t,index:a,selected:s,onToggle:o,originalEval:c}){var v;const[u,d]=m.useState(!1),h=_g[t.action]??_g.add,g=nC[t.action]??"var(--border-subtle)",p=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((v=t.eval)==null?void 0:v.name)??"Unnamed",y=m.useCallback(()=>o(a),[o,a]);return r.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${g}`,opacity:s?1:.5},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[r.jsx("input",{type:"checkbox",checked:s,onChange:y,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),r.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:h.bg,color:h.color,padding:"1px 6px"},children:h.label}),r.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:p}),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(aC,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&r.jsx(lC,{original:c,proposed:t.eval}),t.action==="remove"&&c&&r.jsx(sC,{evalCase:c})]})]})}function aC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[r.jsx(sf,{label:"Prompt",value:t.prompt}),r.jsx(sf,{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 lC({original:t,proposed:a}){const s=[];t.name!==a.name&&s.push({label:"Name",old:t.name,new:a.name}),t.prompt!==a.prompt&&s.push({label:"Prompt",old:t.prompt,new:a.prompt}),t.expected_output!==a.expected_output&&s.push({label:"Expected",old:t.expected_output,new:a.expected_output});const o=t.assertions??[],c=a.assertions??[],u=new Set(o.map(p=>p.text)),d=new Set(c.map(p=>p.text)),h=c.filter(p=>!u.has(p.text)),g=o.filter(p=>!d.has(p.text));return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(p=>r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:p.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:["- ",of(p.old,120)]}),r.jsxs("div",{style:{color:"var(--green)"},children:["+ ",of(p.new,120)]})]})]},p.label)),(h.length>0||g.length>0)&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),r.jsxs("div",{className:"mt-1 space-y-0.5",children:[g.map(p=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",p.text]},p.id)),h.map(p=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",p.text]},p.id))]})]}),s.length===0&&h.length===0&&g.length===0&&r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function sC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[r.jsx(sf,{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 sf({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:of(a,300)})]})}function of(t,a){return t.length>a?t.slice(0,a)+"...":t}const Og={remove:0,modify:1,add:2};function iC({changes:t,selections:a,currentEvals:s,onToggle:o,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((g,p)=>({change:g,originalIndex:p}));d.sort((g,p)=>(Og[g.change.action]??2)-(Og[p.change.action]??2));const h=Array.from(a.values()).filter(Boolean).length;return r.jsxs("div",{className:"mt-3 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",h,"/",t.length," selected)"]})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("button",{onClick:c,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Select All"}),r.jsx("button",{onClick:u,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--surface-3)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),r.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:g,originalIndex:p})=>r.jsx(rC,{change:g,index:p,selected:a.get(p)??!1,onToggle:o,originalEval:g.evalId!=null?s.find(y=>y.id===g.evalId):void 0},p))})]})}function oC(){var L;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:o,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:g,retryEvalsSave:p}=An(),{aiEditLoading:y,aiEditResult:v,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:k,aiEditEvalChanges:E,aiEditEvalSelections:C,aiEditEvalsRetry:N}=t,[T,A]=m.useState(""),{config:B}=Ha(),[D,F]=m.useState("claude-cli"),[w,O]=m.useState("opus"),z=m.useRef(null);m.useEffect(()=>{var _;(_=z.current)==null||_.focus()},[]),m.useEffect(()=>{if(!B)return;B.providers.find(I=>I.id==="claude-cli"&&I.available)&&(F("claude-cli"),O("opus"))},[B]);const U=B==null?void 0:B.providers.find(_=>_.id===D&&_.available),H=m.useCallback(()=>{const _=T.trim();!_||y||s(_,D,w)},[T,y,s,D,w]),q=m.useCallback(_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),H()),_.key==="Escape"&&(_.preventDefault(),y?u():c())},[H,y,u,c]),X=m.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),J=v?Zo(t.skillContent,v.improved):[],$=((L=t.evals)==null?void 0:L.evals)??[];return r.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M15 4V2"}),r.jsx("path",{d:"M15 16v-2"}),r.jsx("path",{d:"M8 9h2"}),r.jsx("path",{d:"M20 9h2"}),r.jsx("path",{d:"M17.8 11.8L19 13"}),r.jsx("path",{d:"M15 9h.01"}),r.jsx("path",{d:"M17.8 6.2L19 5"}),r.jsx("path",{d:"M11 6.2L9.7 5"}),r.jsx("path",{d:"M3 21l9-9"})]})}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),r.jsx("button",{onClick:c,className:"w-6 h-6 rounded-md flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--surface-3)"},onMouseLeave:_=>{_.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-4 py-3",children:[!v&&r.jsxs(r.Fragment,{children:[r.jsx("textarea",{ref:z,value:T,onChange:_=>A(_.target.value),onKeyDown:q,placeholder:"e.g., Add an error handling section...",disabled:y,rows:4,className:"w-full resize-y outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12.5,lineHeight:1.5,fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",minHeight:96,maxHeight:240}}),r.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:D,onChange:_=>{F(_.target.value);const I=B==null?void 0:B.providers.find(V=>V.id===_.target.value);I!=null&&I.models[0]&&O(I.models[0].id)},disabled:y,style:{width:"100%"},children:B==null?void 0:B.providers.filter(_=>_.available).map(_=>r.jsx("option",{value:_.id,children:_.label},_.id))})]}),r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:w,onChange:_=>O(_.target.value),disabled:y,style:{width:"100%"},children:U==null?void 0:U.models.map(_=>r.jsx("option",{value:_.id,children:_.label},_.id))})]}),r.jsx("div",{className:"flex-1"}),y?r.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):r.jsx("button",{onClick:H,disabled:!T.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),y&&k.length>0&&r.jsx("div",{className:"mt-2.5",children:r.jsx(ri,{entries:k,isRunning:!0})})]}),b&&r.jsx("div",{className:"mt-3",children:S?r.jsx(Jo,{error:S,onRetry:X,onDismiss:c}):r.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),v&&r.jsxs("div",{className:"animate-fade-in",children:[v.reasoning&&r.jsxs("div",{className:"mb-3 px-3 py-2.5 rounded-lg text-[11.5px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),v.reasoning]}),r.jsx("div",{className:"mb-1",children:r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:J.map((_,I)=>r.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:_.type==="added"?"rgba(34,197,94,0.1)":_.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:_.type==="added"?"var(--green)":_.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:_.type==="added"?"3px solid var(--green)":_.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:_.type==="added"?"+":_.type==="removed"?"-":" "}),_.content]},I))}),r.jsx(iC,{changes:E,selections:C,currentEvals:$,onToggle:d,onSelectAll:h,onDeselectAll:g}),N&&r.jsxs("div",{className:"mt-3 px-3 py-2.5 rounded-lg text-[12px] flex items-center justify-between",style:{background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.3)",color:"#fbbf24"},children:[r.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),r.jsx("button",{onClick:p,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("button",{onClick:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),r.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),r.jsx("button",{onClick:X,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function cC(t,a){const[s,o]=m.useState([]),[c,u]=m.useState("SKILL.md"),[d,h]=m.useState(null),[g,p]=m.useState(!1),[y,v]=m.useState(null),b=m.useCallback(async()=>{try{const E=await Ce.getSkillFiles(t,a);o(E.files)}catch{o([])}},[t,a]);m.useEffect(()=>{u("SKILL.md"),h(null),v(null),b()},[t,a,b]);const S=m.useCallback(async E=>{if(u(E),E==="SKILL.md"){h(null),v(null);return}p(!0),v(null);try{const C=await Ce.getSkillFile(t,a,E);h(C)}catch(C){v(`Unable to open file: ${C.message}`),h(null)}finally{p(!1)}},[t,a]),k=m.useCallback(()=>{b()},[b]);return{files:s,activeFile:c,secondaryContent:d,loading:g,error:y,selectFile:S,refresh:k,isSkillMd:c==="SKILL.md"}}function uC(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function dC(t){const a=[],s=new Map;for(const o of t){const c=o.path.split("/"),d={name:c[c.length-1],path:o.path,type:o.type,size:o.size,children:[]};s.set(o.path,d)}for(const o of t){const c=o.path.split("/");if(c.length===1){const u=s.get(o.path);u&&a.push(u)}else{const u=c.slice(0,-1).join("/"),d=s.get(u),h=s.get(o.path);d&&h&&d.children.push(h)}}return a}function jy({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 Sy(){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 fC(){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 pC(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"23 4 23 10 17 10"}),r.jsx("polyline",{points:"1 20 1 14 7 14"}),r.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function ky({node:t,depth:a,activeFile:s,onSelect:o}){const[c,u]=m.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(jy,{expanded:c}),r.jsx(Sy,{}),r.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>r.jsx(ky,{node:h,depth:a+1,activeFile:s,onSelect:o},h.path))]}):r.jsxs("button",{onClick:()=>o(t.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+a*14}px`,paddingTop:2,paddingBottom:2,background:d?"var(--accent-muted)":"none",border:"none",cursor:"pointer",color:d?"var(--accent)":"var(--text-tertiary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left",borderRadius:3},children:[r.jsx("span",{style:{width:10}}),r.jsx(fC,{}),r.jsx("span",{style:{flex:1},children:t.name}),r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:uC(t.size)})]})}function mC({files:t,activeFile:a,onSelect:s,onRefresh:o}){const[c,u]=m.useState(!1),d=m.useMemo(()=>dC(t),[t]);return r.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>u(!c),children:[r.jsx(jy,{expanded:c}),r.jsx(Sy,{}),r.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),r.jsx("button",{onClick:h=>{h.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:"2px 4px",display:"flex",alignItems:"center",borderRadius:3},title:"Refresh file list",children:r.jsx(pC,{})})]}),c&&r.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:d.length===0?r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):d.map(h=>r.jsx(ky,{node:h,depth:0,activeFile:a,onSelect:s},h.path))})]})}function jo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function hC(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function xC(t){const a=t.toLowerCase();return a.endsWith(".json")?"json":a.endsWith(".md")?"md":"other"}function Bg({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 Ig({content:t,fileType:a}){if(a==="json"){const s=hC(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:Qo(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 Ug(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"\\]|\\.)*"\s*:/g,s=>`<span style="color:#6383ff">${s}</span>`).replace(/:\s*"([^"\\]|\\.)*"/g,s=>`<span style="color:#22c55e">${s.slice(0,2)}<span style="color:#22c55e">${s.slice(2)}</span></span>`).replace(/:\s*(-?\d+\.?\d*)/g,(s,o)=>`: <span style="color:#fb923c">${o}</span>`).replace(/:\s*(true|false|null)/g,(s,o)=>`: <span style="color:#a855f7">${o}</span>`)}catch{return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}function gC({file:t,loading:a,error:s,viewMode:o,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[g,p]=m.useState(o),[y,v]=m.useState(!1),[b,S]=m.useState(""),[k,E]=m.useState(!1),[C,N]=m.useState(null),T=o!==g?o:g;m.useEffect(()=>{h==null||h(y)},[y,h]);const A=m.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),v(!0))},[t]),B=m.useCallback(()=>{v(!1)},[]),D=m.useCallback(async()=>{if(!(!c||!u||!t)){E(!0);try{await Ce.saveSkillFile(c,u,t.path,b),N("Saved"),v(!1),d==null||d(),setTimeout(()=>N(null),2e3)}catch(O){N(`Save failed: ${O.message}`),setTimeout(()=>N(null),3e3)}finally{E(!1)}}},[c,u,t,b,d]);if(m.useEffect(()=>{if(!y)return;const O=z=>{(z.ctrlKey||z.metaKey)&&z.key==="s"&&(z.preventDefault(),D())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[y,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 (",jo(t.size),") — cannot be displayed"]});const F=t.content??"",w=xC(t.path);return r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&r.jsxs("div",{style:{padding:"4px 12px",background:"var(--warning-muted, #fef3c7)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:"var(--warning-text, #92400e)"},children:["File truncated at ",jo(512*1024)," — ",jo(t.size)," total"]}),r.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(w==="md"||w==="json")&&["raw","split","preview"].map(O=>r.jsx("button",{onClick:()=>p(O),style:{padding:"2px 8px",fontSize:11,background:T===O?"var(--accent-muted)":"none",color:T===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:O},O)),r.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[jo(t.size),c&&u&&!t.binary&&!y&&r.jsx("button",{onClick:A,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),y&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick: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:B,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),C&&r.jsx("div",{style:{padding:"4px 12px",background:C.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:C.startsWith("Save failed")?"var(--red)":"var(--green)"},children:C}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:y?r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[r.jsx("textarea",{value:b,onChange:O=>S(O.target.value),style:{flex:1,width:"100%",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}}),r.jsxs("div",{style:{position:"sticky",bottom:0,display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),r.jsx("button",{onClick: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:B,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):T==="split"&&w!=="other"?r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:r.jsx(Bg,{content:F})}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:w==="json"?r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ug(F)}}):r.jsx(Ig,{content:F,fileType:w})})]}):T==="preview"&&w!=="other"?w==="json"?r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ug(F)}}):r.jsx(Ig,{content:F,fileType:w}):r.jsx(Bg,{content:F})})]})}function vC({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 yC({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 bC({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 jC({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 Md({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 SC(){const{state:t,dispatch:a,saveContent:s,isReadOnly:o}=An(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:g,aiEditOpen:p}=t,[y,v]=m.useState("split"),[b,S]=m.useState(!1),k=m.useRef(null),[E,C]=m.useState(!1),[N,T]=m.useState(""),[A,B]=m.useState(!1),[D,F]=m.useState(null),[w,O]=m.useState([]),[z,U]=m.useState([]),[H,q]=m.useState(null),X=m.useRef(null),{config:J}=Ha(),{files:$,activeFile:L,secondaryContent:_,loading:I,error:V,selectFile:se,refresh:M,isSkillMd:Y}=cC(c??"",u??""),[G,te]=m.useState(!1),fe=m.useCallback(be=>{G&&!window.confirm("You have unsaved changes. Discard?")||se(be)},[G,se]);m.useEffect(()=>()=>{var be;(be=X.current)==null||be.abort()},[]);const{metadata:ie,body:ye}=Zw(d),de=ie["allowed-tools"],Se=Array.isArray(de)?de:typeof de=="string"?[de]:[],Ae=ie.name,_e=ie.description,ae=ie.metadata,he=typeof ae=="object"&&!Array.isArray(ae)?ae:null,pe=ie.version||(he==null?void 0:he.version),ge=ie.tags||(he==null?void 0:he.tags),je=Array.isArray(ge)?ge:typeof ge=="string"?ge.split(",").map(be=>be.trim()).filter(Boolean):[],Be=new Set(["name","description","metadata","allowed-tools","version","tags"]),Oe=Object.entries(ie).filter(([be])=>!Be.has(be)),at=m.useCallback(async()=>{S(!0),await s(),S(!1)},[s]),Nt=m.useCallback(be=>{(be.ctrlKey||be.metaKey)&&be.key==="s"&&(be.preventDefault(),be.stopPropagation(),h&&at()),(be.ctrlKey||be.metaKey)&&be.key==="k"&&(be.preventDefault(),be.stopPropagation(),a({type:p?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,at,p,a]),ht=m.useCallback(async()=>{var pt,Ct;if(!N.trim())return;(pt=X.current)==null||pt.abort();const be=new AbortController;X.current=be,B(!0),q(null),U([]),F(null),O([]);try{const Yt=(J==null?void 0:J.provider)||"claude-cli",un=(J==null?void 0:J.model)||"sonnet",Gt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:Yt,model:un}),signal:be.signal});if(!Gt.ok||!Gt.body){let gt=`HTTP ${Gt.status}`;try{const dr=await Gt.json();dr.error&&(gt=dr.error)}catch{}throw new Error(gt)}const rn=Gt.body.getReader(),Mn=new TextDecoder;let Mt="",xt="";for(;;){const{done:gt,value:dr}=await rn.read();if(gt)break;Mt+=Mn.decode(dr,{stream:!0});const zr=Mt.split(`
79
- `);Mt=zr.pop()||"";for(const Wn of zr)if(Wn.startsWith("event: "))xt=Wn.slice(7).trim();else if(Wn.startsWith("data: ")){try{const Et=JSON.parse(Wn.slice(6));if(xt==="progress")U(oe=>[...oe,{phase:Et.phase,message:Et.message,timestamp:Date.now()}]);else if(xt==="done"||xt==="complete"){const oe=["---"];Et.name&&oe.push(`name: ${Et.name}`),Et.description&&oe.push(`description: "${Et.description.replace(/"/g,'\\"')}"`),Et.model&&oe.push(`model: ${Et.model}`),(Ct=Et.allowedTools)!=null&&Ct.trim()&&oe.push(`allowed-tools: ${Et.allowedTools.trim()}`),oe.push("---","",Et.body||"");const xe=oe.join(`
80
- `);F(xe),O(Zo(d,xe)),B(!1)}else xt==="error"&&(q(Et.message||Et.description||"Generation failed"),B(!1))}catch{}xt=""}}}catch(Yt){Yt.name!=="AbortError"&&q(Yt.message)}finally{B(!1),X.current=null}},[N,J,d]),Dt=m.useCallback(()=>{D&&a({type:"SET_CONTENT",content:D}),C(!1),F(null),O([]),T(""),U([])},[D,a]),Tt=m.useCallback(()=>{C(!1),F(null),O([]),T(""),U([]),q(null)},[]),Qe=m.useCallback(()=>{var be;E?((be=X.current)==null||be.abort(),Tt()):(p&&a({type:"CLOSE_AI_EDIT"}),C(!0))},[E,p,a,Tt]),tt=[{mode:"raw",icon:r.jsx(vC,{}),label:"Editor"},{mode:"split",icon:r.jsx(yC,{}),label:"Split"},{mode:"preview",icon:r.jsx(bC,{}),label:"Preview"}];return r.jsxs("div",{className:"flex flex-col h-full",onKeyDown:Nt,tabIndex:-1,children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:tt.map(({mode:be,icon:pt,label:Ct})=>r.jsxs("button",{onClick:()=>v(be),title:Ct,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:y===be?"var(--surface-4)":"transparent",color:y===be?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:y===be?600:400,border:"none",cursor:"pointer"},children:[pt,r.jsx("span",{style:{letterSpacing:"0.01em"},children:Ct})]},be))}),Y?o?r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>{p?a({type:"CLOSE_AI_EDIT"}):(E&&Tt(),a({type:"OPEN_AI_EDIT"}))},title:"Edit with AI (Ctrl+K)",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:p?600:400,border:"none",cursor:"pointer",color:p?"var(--purple)":"var(--text-tertiary)",background:p?"var(--purple-muted)":"transparent"},children:[r.jsx(jC,{size:13}),r.jsx("span",{children:"AI Edit"})]}),r.jsxs("button",{onClick:Qe,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:E?600:400,border:"none",cursor:"pointer",color:E?"var(--purple)":"var(--text-tertiary)",background:E?"var(--purple-muted)":"transparent"},children:[r.jsx(Md,{size:13}),r.jsx("span",{children:"Regenerate"})]}),r.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),h&&r.jsx("button",{onClick:()=>a({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),r.jsx("button",{onClick:at,disabled:!h||b,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"})]}):null]}),c&&u&&r.jsx(mC,{files:$,activeFile:L,onSelect:fe,onRefresh:M}),!Y&&r.jsx(gC,{file:_,loading:I,error:V,viewMode:y,plugin:c??void 0,skill:u??void 0,onSaved:()=>{se(L),M()},onDirtyChange:te}),Y&&r.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:y==="raw"||y==="preview"?"1fr":"1fr 1fr"},children:[y!=="preview"&&r.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:y==="split"?"1px solid var(--border-subtle)":"none"},children:r.jsx("textarea",{ref:k,value:d,onChange:be=>{o||a({type:"SET_CONTENT",content:be.target.value})},onKeyDown:Nt,spellCheck:!1,readOnly:o,className:"flex-1 w-full resize-none outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",fontSize:12.5,lineHeight:1.7,tabSize:2,border:"none",padding:"16px 20px",opacity:o?.7:1}})}),y!=="raw"&&r.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:r.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(Ae||pe||_e)&&r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Ae&&r.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Ae}),pe&&r.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4,letterSpacing:"0.03em",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:["v",pe]})]}),_e&&r.jsx("p",{style:{fontSize:12.5,lineHeight:1.65,color:"var(--text-secondary)",margin:0,paddingLeft:12,borderLeft:"2px solid var(--accent)",maxWidth:600},children:_e})]}),je.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:je.map(be=>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:be},be))}),Se.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"}),Se.map(be=>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:be},be))]})}),Oe.length>0&&r.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:Oe.map(([be,pt],Ct)=>{const Yt=Array.isArray(pt)?pt.join(", "):typeof pt=="object"?Object.entries(pt).map(([un,Gt])=>`${un}: ${Array.isArray(Gt)?Gt.join(", "):Gt}`).join(" | "):pt;return r.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Ct>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:be}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Yt})]},be)})}),(Ae||_e||je.length>0||Se.length>0||Oe.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:Qo(ye)}})]})})]}),Y&&p&&r.jsx(oC,{}),Y&&E&&r.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:r.jsxs("div",{className:"px-4 py-3",children:[!D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Md,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),r.jsx("div",{className:"flex gap-2 mb-2",children:r.jsx("textarea",{value:N,onChange:be=>T(be.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:A,className:"flex-1 px-3 py-2 rounded-lg text-[12px] resize-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",outline:"none",opacity:A?.5:1},onKeyDown:be=>{be.key==="Enter"&&(be.ctrlKey||be.metaKey)&&N.trim()&&!A&&(be.preventDefault(),ht())}})}),r.jsxs("div",{className:"flex items-center gap-2",children:[A?r.jsx("button",{onClick:()=>{var be;(be=X.current)==null||be.abort(),B(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):r.jsx("button",{onClick:ht,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),r.jsx("button",{onClick:Tt,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),A&&z.length>0&&r.jsx("div",{className:"mt-2",children:r.jsx(ri,{entries:z,isRunning:!0})}),H&&r.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[H,r.jsx("button",{onClick:ht,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(Md,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:w.map((be,pt)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:be.type==="added"?"var(--green-muted)":be.type==="removed"?"var(--red-muted)":"transparent",color:be.type==="added"?"var(--green)":be.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:be.type==="added"?"3px solid var(--green)":be.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:be.type==="added"?"+":be.type==="removed"?"-":" "}),be.content]},pt))}),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:Tt,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Y&&g!==null&&c&&u&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(tC,{plugin:c,skill:u,skillContent:d,onApplied:be=>{a({type:"SET_CONTENT",content:be}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})})]})}function Nl(t){return t.testType==="integration"?"integration":"unit"}function Ll(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function wy(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 Cy(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const kC=new Set(["benchmark","comparison","baseline"]);function Hg(t,a,s,o){return t.map(({rate:c,idx:u,total:d})=>{const h=o+u/(d-1)*(a-o*2),g=o+(s-o*2)-c*(s-o*2);return`${h},${g}`})}function Ey({entries:t}){const a=t.filter(v=>kC.has(v.type)).slice().reverse(),s=a.map((v,b,S)=>({rate:v.pass_rate,idx:b,total:S.length})).filter((v,b)=>{const S=a[b].type;return S==="benchmark"||S==="comparison"}),o=a.flatMap((v,b)=>v.type==="baseline"?[{rate:v.pass_rate,idx:b,total:a.length}]:v.type==="comparison"&&v.baselinePassRate!=null?[{rate:v.baselinePassRate,idx:b,total:a.length}]:[]);if(s.length<2&&o.length<2)return null;const c=80,u=24,d=2,h=s.length>=2?Hg(s,c,u,d):[],g=o.length>=2?Hg(o,c,u,d):[],p=h[h.length-1],y=g[g.length-1];return r.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[g.length>0&&r.jsx("polyline",{points:g.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),h.length>0&&r.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),y&&r.jsx("circle",{cx:parseFloat(y.split(",")[0]),cy:parseFloat(y.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),p&&r.jsx("circle",{cx:parseFloat(p.split(",")[0]),cy:parseFloat(p.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function Ny(t,a,s){const o=isNaN(a)?0:a,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&o>=.7){const p=c.length>0?` Met criteria: ${c.map(y=>y.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): evaluation met expectations.${p}`}}if(t==="FAIL"||t==="DEGRADING"){const p=u.length>0?` Failed criteria: ${u.map(v=>v.criterion).join(", ")}.`:"",y=[...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return y.length===0&&y.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${o.toFixed(2)}): evaluation did not meet expectations.${p}`,recommendations:y}}if(t==="INEFFECTIVE"){if(o<.2){const y=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),"Consider adding examples to your system prompt","Review the rubric criteria for achievability"];return{explanation:`${t} (score ${o.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:y}}const p=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.score.toFixed(2)}`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push("Consider restructuring your prompt approach"),{explanation:`${t} (score ${o.toFixed(2)}): below expectations but showing some capability.`,recommendations:p}}if(t==="MARGINAL"){const p=[...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`),...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Review prompt instructions for areas of improvement"),{explanation:`${t} (score ${o.toFixed(2)}): moderate improvement detected.`,recommendations:p}}if(t==="EMERGING"){const p=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Add more specific guidance to your prompt instructions"),{explanation:`${t} (score ${o.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:p}}const h=c.length>0?` Passing: ${c.map(p=>p.criterion).join(", ")}.`:"",g=d.length>0?` Needs improvement: ${d.map(p=>p.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): mixed results.${h}${g}`}}const Ty={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function wC(t){return Object.hasOwn(Ty,t)}function CC(t){return wC(t)?Ty[t]:t}function EC(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=m.useState([]),[u,d]=m.useState([]),[h,g]=m.useState(!0),[p,y]=m.useState(null),[v,b]=m.useState(new Set),[S,k]=m.useState({}),[E,C]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState(!1),[D,F]=m.useState(""),[w,O]=m.useState(""),z=m.useCallback(async()=>{g(!0),y(null);try{const[$,L]=await Promise.all([Ce.getCredentials(a,s),Ce.getParams(a,s)]);c($.credentials),d(L.params)}catch($){y($ instanceof Error?$.message:"Failed to load parameters"),c([]),d([])}finally{g(!1)}},[a,s]);m.useEffect(()=>{z()},[z]);const U=m.useCallback(async($,L)=>{B(!0),y(null);try{await Ce.setCredential(a,s,$,L),C(null),T(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to save ${$}`)}finally{B(!1)}},[a,s,z]),H=m.useCallback(async()=>{const $=D.trim().toUpperCase(),L=w.trim();if(!(!$||!L)){B(!0),y(null);try{await Ce.setCredential(a,s,$,L),F(""),O(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to add ${$}`)}finally{B(!1)}}},[a,s,D,w,z]),q=m.useCallback(async $=>{if(v.has($)){b(L=>{const _=new Set(L);return _.delete($),_}),k(L=>{const _={...L};return delete _[$],_});return}try{const _=(await Ce.getParamsRevealed(a,s,$)).params.find(I=>I.name===$);_!=null&&_.value&&(k(I=>({...I,[$]:_.value})),b(I=>new Set(I).add($)))}catch{}},[a,s,v]),X=new Set(o.map($=>$.name)),J=[...o.map($=>{const L=u.find(_=>_.name===$.name);return{name:$.name,status:$.status,maskedValue:(L==null?void 0:L.maskedValue)??""}}),...u.filter($=>!X.has($.name)).map($=>({name:$.name,status:$.status,maskedValue:$.maskedValue}))];return r.jsxs("div",{className:"py-2 px-3",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),p&&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:p}),h&&J.length===0&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&J.length===0&&!p&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),J.map($=>r.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:$.name}),r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:$.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:$.status==="ready"?"var(--green)":"var(--red)"},children:$.status}),($.maskedValue||$.status==="ready")&&r.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[v.has($.name)?S[$.name]??$.maskedValue:$.maskedValue||"***",r.jsx("button",{onClick:()=>q($.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${v.has($.name)?"Hide":"Reveal"} value for ${$.name}`,children:v.has($.name)?"hide":"show"})]}),E===$.name?r.jsxs("div",{className:"flex gap-1",children:[r.jsx("input",{value:N,onChange:L=>T(L.target.value),onKeyDown:L=>{L.key==="Enter"&&N.trim()&&U($.name,N)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${$.name}`,autoFocus:!0}),r.jsx("button",{onClick:()=>U($.name,N),disabled:A||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),r.jsx("button",{onClick:()=>{C(null),T("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):r.jsx("button",{onClick:()=>{C($.name),T("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},$.name)),r.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:D,onChange:$=>F($.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),r.jsx("input",{value:w,onChange:$=>O($.target.value),onKeyDown:$=>{$.key==="Enter"&&D.trim()&&w.trim()&&H()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),r.jsx("button",{onClick:H,disabled:A||!D.trim()||!w.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:A?"not-allowed":"pointer"},children:"Add"})]})]})]})}const zs="This is an installed copy (read-only). Open the source skill to edit.";function NC(t,a,s){const[o,c]=m.useState(null),[u,d]=m.useState(!1),h=m.useRef("");m.useEffect(()=>{const p=`${t}/${a}/${s}`;h.current!==p&&(h.current=p,d(!0),Ce.getCaseHistory(t,a,s).then(y=>c(y)).catch(()=>c([])).finally(()=>d(!1)))},[t,a,s]);const g=m.useCallback(()=>{d(!0),h.current="",Ce.getCaseHistory(t,a,s).then(p=>c(p)).catch(()=>c([])).finally(()=>d(!1))},[t,a,s]);return{entries:o,loading:u,refetch:g}}function TC(t,a,s){const o={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return o;const u=s.slice(0,10).map(g=>g.assertions.find(p=>p.id===t)).filter(Boolean);if(u.length>=2){const p=u.filter(y=>y.pass).length/u.length;p>=.3&&p<=.7&&(o.flaky=!0)}const d=s.find(g=>g.type==="benchmark"),h=s.find(g=>g.type==="baseline");if(d&&h){const g=d.assertions.find(y=>y.id===t),p=h.assertions.find(y=>y.id===t);g!=null&&g.pass&&(p!=null&&p.pass)&&(o.nonDiscriminating=!0)}if(a&&!a.pass&&s.length>=1){const p=s[0].assertions.find(y=>y.id===t);p!=null&&p.pass&&(o.regression=!0)}return o}function RC(){var I;const{state:t,dispatch:a,saveEvals:s,runCase:o,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:g}=An(),{evals:p,evalsError:y,selectedCaseId:v,inlineResults:b,caseRunStates:S,generateEvalsLoading:k,generateEvalsProgress:E,generateEvalsError:C}=t,N=m.useMemo(()=>{for(const V of S.values())if(V.status==="running"||V.status==="queued")return!0;return!1},[S]),[T,A]=m.useState(!1),[B,D]=m.useState("all"),F={skill_name:t.skill,evals:[]},w=p??F,O=w.evals,z=m.useMemo(()=>B==="all"?O:O.filter(V=>Nl(V)===B),[B,O]),U=z.find(V=>V.id===v)??null;m.useEffect(()=>{v!==null&&!z.find(V=>V.id===v)&&a({type:"SELECT_CASE",caseId:z.length>0?z[0].id:null})},[z,v,a]);const[H,q]=m.useState([]),X=m.useMemo(()=>O.some(V=>Nl(V)==="integration"),[O]);m.useEffect(()=>{X&&Ce.getCredentials(t.plugin,t.skill).then(V=>q(V.credentials)).catch(()=>q([]))},[t.plugin,t.skill,X]);const J=m.useMemo(()=>new Set(H.filter(V=>V.status==="missing").map(V=>V.name)),[H]),[$,L]=m.useState(!1),_=m.useCallback(V=>{L(!1),h(V?{testType:V}:void 0)},[h]);return!p||O.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:y?"var(--red-muted)":"var(--accent-muted)"},children:y?r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M9 11l3 3L22 4"}),r.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),r.jsx("div",{className:"text-center",children:y?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),r.jsx("div",{className:"text-[11px] font-mono px-3 py-2 rounded mt-1 max-w-sm text-left break-words",style:{color:"var(--text-secondary)",background:"var(--surface-2)"},children:y}),r.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Fix the evals.json file and reload, or regenerate test cases with AI"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>A(!0),disabled:g,title:g?zs:void 0,className:"btn btn-primary text-[12px]",children:"Create Test Case"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{className:"flex",children:[r.jsx("button",{onClick:()=>_("unit"),disabled:k||g,title:g?zs:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:k?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),r.jsx("button",{onClick:()=>L(!$),disabled:k||g,title:g?zs:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),$&&r.jsx("div",{className:"absolute right-0 mt-1 rounded-lg py-1 z-50",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",minWidth:180,boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:r.jsx("button",{onClick:()=>_("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.background="var(--surface-2)"},onMouseLeave:V=>{V.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),k&&E.length>0&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ri,{entries:E,isRunning:!0})}),C&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(Jo,{error:C,onRetry:()=>_()})}),T&&r.jsx($g,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]}):r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",height:"100%",overflow:"hidden"},children:[r.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:6,columnGap:8},children:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",z.length,")"]}),r.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:N?r.jsx("button",{onClick:d,className:"btn text-[10px] px-2 py-0.5",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:"Cancel All"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>c("benchmark"),disabled:z.length===0||g,title:g?zs: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:z.length===0||g,title:g?zs:void 0,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]})})]}),r.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(V=>r.jsx("button",{onClick:()=>D(V),style:{padding:"2px 8px",fontSize:10,fontWeight:B===V?600:400,background:B===V?"var(--accent-muted)":"transparent",color:B===V?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:V==="all"?`All (${O.length})`:V==="unit"?`Unit (${O.filter(se=>Nl(se)==="unit").length})`:`Integration (${O.filter(se=>Nl(se)==="integration").length})`},V))}),r.jsxs("div",{className:"py-1",children:[z.length===0&&O.length>0&&r.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",B==="all"?"":B+" ","tests yet"]}),z.map(V=>{var G;const se=b.get(V.id),M=v===V.id,Y=Nl(V);return r.jsxs("button",{onClick:()=>a({type:"SELECT_CASE",caseId:V.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:M?"var(--accent-muted)":"transparent",borderLeft:M?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:te=>{M||(te.currentTarget.style.background="var(--surface-2)")},onMouseLeave:te=>{M||(te.currentTarget.style.background="transparent")},children:[r.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[r.jsxs("span",{className:"text-[12px] font-medium truncate flex items-center gap-1.5",style:{color:M?"var(--text-primary)":"var(--text-secondary)"},children:["#",V.id," ",V.name,r.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:Y==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:Y==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:Y==="unit"?"U":"I"}),Y==="integration"&&((G=V.requiredCredentials)==null?void 0:G.some(te=>J.has(te)))&&r.jsx("span",{title:"Configure credentials to run",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),r.jsx(Ry,{result:se})]}),r.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[V.assertions.length," assertion",V.assertions.length!==1?"s":"",(se==null?void 0:se.passRate)!=null&&r.jsx(LC,{passRate:se.passRate})]})]},V.id)})]}),r.jsx("div",{className:"px-3 py-2",children:!g&&r.jsx("button",{onClick:()=>A(!0),className:"w-full py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{border:"1px dashed var(--border-default)",color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--accent)",V.currentTarget.style.color="var(--accent)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-default)",V.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(EC,{})})]}),r.jsx("div",{className:"overflow-auto",children:U?r.jsx(AC,{evalCase:U,result:b.get(U.id),evals:p,caseStatus:((I=S.get(U.id))==null?void 0:I.status)??"idle",onSaveEvals:s,onRun:V=>o(V,"benchmark"),onCompare:V=>o(V,"comparison"),onCancel:V=>u(V),onImprove:V=>a({type:"OPEN_IMPROVE",evalId:V})}):r.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),T&&r.jsx($g,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]})}function AC({evalCase:t,result:a,evals:s,caseStatus:o,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:g}){const{state:p,isReadOnly:y}=An(),{plugin:v,skill:b}=p,{entries:S,loading:k}=NC(v,b,t.id),[E,C]=m.useState(!1),[N,T]=m.useState(t.prompt),[A,B]=m.useState(!1),[D,F]=m.useState(t.expected_output);m.useState(()=>{T(t.prompt),F(t.expected_output)});const w=m.useCallback(V=>{c({...s,evals:s.evals.map(se=>se.id===V.id?V:se)})},[s,c]),O=m.useCallback(()=>{w({...t,prompt:N}),C(!1)},[t,N,w]),z=m.useCallback(()=>{w({...t,expected_output:D}),B(!1)},[t,D,w]),U=m.useCallback(()=>{w({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,w]),H=m.useCallback((V,se)=>{w({...t,assertions:t.assertions.map(M=>M.id===V?{...M,text:se}:M)})},[t,w]),q=m.useCallback(V=>{w({...t,assertions:t.assertions.filter(se=>se.id!==V)})},[t,w]),X=m.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(V=>V.id!==t.id)})},[s,t.id,c]),J=a&&a.assertions.length>0&&a.assertions.every(V=>V.pass),$=a&&a.assertions.some(V=>!V.pass),L=Nl(t),_=t.requiredCredentials??[],I=L==="integration"&&_.length>0;return r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[r.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[r.jsxs("span",{className:"text-[16px] font-semibold",title:`#${t.id} ${t.name}`,style:{color:"var(--text-primary)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["#",t.id," ",t.name]}),y?r.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)"},children:L==="unit"?"Unit":"Integration"}):r.jsx("button",{onClick:()=>{if((L==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:se,requirements:M,cleanup:Y,...G}=t;w({...G,testType:"unit"})}else w({...t,testType:"integration"})},title:`Click to switch to ${L==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:L==="unit"?"Unit":"Integration"}),r.jsx(Ry,{result:a})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[o==="running"||o==="queued"?r.jsxs("button",{onClick:()=>h(t.id),className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>u(t.id),disabled:y,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),r.jsx("button",{onClick:()=>d(t.id),disabled:y,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),$&&!y&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:()=>g(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!y&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:X,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),y&&L==="integration"&&r.jsxs("div",{"data-testid":"platform-integration-note",className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--accent-muted)",border:"1px solid var(--accent-muted)"},children:[r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),r.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),J&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--green-muted)",border:"1px solid var(--green-muted)"},children:[r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),I&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:_.map(V=>r.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:V},V))})]}),!y&&L==="integration"&&r.jsx(_C,{evalCase:t,onUpdate:w}),r.jsx(So,{title:"Prompt",children:E?r.jsxs("div",{children:[r.jsx("textarea",{value:N,onChange:V=>T(V.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:O,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{T(t.prompt),C(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-secondary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||C(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||r.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"No prompt":"Click to edit prompt..."})})}),r.jsx(So,{title:"Expected Output",children:A?r.jsxs("div",{children:[r.jsx("textarea",{value:D,onChange:V=>F(V.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:z,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{F(t.expected_output),B(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||B(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||r.jsx("span",{style:{fontStyle:"italic"},children:y?"No expected output":"Click to edit expected output..."})})}),r.jsx(So,{title:`Assertions (${t.assertions.length})`,action:y?void 0:r.jsx("button",{onClick:U,className:"btn btn-ghost text-[11px]",children:"+ Add"}),children:t.assertions.length===0?r.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):r.jsx("div",{className:"space-y-2",children:t.assertions.map(V=>{const se=a==null?void 0:a.assertions.find(Y=>Y.assertion_id===V.id),M=TC(V.id,se,S);return r.jsx(MC,{assertion:V,result:se,badges:M,isReadOnly:y,onUpdate:Y=>H(V.id,Y),onDelete:()=>q(V.id)},V.id)})})}),(a==null?void 0:a.output)&&r.jsx(zC,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const V=Ny("INEFFECTIVE",a.passRate);return V.recommendations&&V.recommendations.length>0?r.jsx(So,{title:"Recommendations",children:r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),r.jsx("ul",{className:"space-y-1.5 ml-1",children:V.recommendations.map((se,M)=>r.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[r.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),se]},M))})]})}):null})(),r.jsx(DC,{evalId:t.id,sharedEntries:S,sharedLoading:k})]},t.id)}function MC({assertion:t,result:a,badges:s,isReadOnly:o,onUpdate:c,onDelete:u}){const[d,h]=m.useState(!1),[g,p]=m.useState(t.text),[y,v]=m.useState(!1),b=()=>{c(g),h(!1)};return r.jsx("div",{className:"rounded-lg px-3 py-2.5 transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:r.jsxs("div",{className:"flex items-start gap-2",children:[a?r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,border:"1.5px dashed var(--text-tertiary)",background:"transparent"},title:"Not run yet"}),(s==null?void 0:s.regression)&&r.jsx("span",{className:"mt-0.5 flex-shrink-0",title:"Regression: was passing, now failing",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:18,color:"var(--red)",fontSize:14,fontWeight:700,lineHeight:1},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&r.jsx("span",{title:"Flaky: 30-70% pass rate across recent runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--yellow-muted)",color:"var(--yellow)",whiteSpace:"nowrap"},children:"Flaky"}),(s==null?void 0:s.nonDiscriminating)&&r.jsx("span",{title:"Non-discriminating: passes on both skill and baseline runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--surface-3)",color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:"Non-Discrim."})]}),d?r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:g,onChange:S=>p(S.target.value),onKeyDown:S=>{S.key==="Enter"&&b(),S.key==="Escape"&&h(!1)},className:"input-field flex-1 text-[12px]",autoFocus:!0}),r.jsx("button",{onClick:b,className:"btn btn-primary text-[11px]",children:"Save"})]}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:o?"default":"pointer"},onClick:()=>{o||(p(t.text),h(!0))},children:t.text}),(a==null?void 0:a.reasoning)&&r.jsx("button",{onClick:()=>v(!y),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:y?"Hide reasoning":"Show reasoning"}),y&&(a==null?void 0:a.reasoning)&&r.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:a.reasoning})]}),!o&&r.jsx("button",{onClick:u,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:S=>{S.currentTarget.style.color="var(--red)",S.currentTarget.style.opacity="1"},onMouseLeave:S=>{S.currentTarget.style.color="var(--text-tertiary)",S.currentTarget.style.opacity=""},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function So({title:t,action:a,children:s}){return r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a]}),s]})}function Ry({result:t}){const[a,s]=m.useState(!1);if(!t||t.status==null)return r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const o=t.status==="pass",c=t.passRate??0,d=Ny(o?"PASS":"FAIL",c);return r.jsxs("span",{className:"pill text-[10px]",style:{background:o?"var(--green-muted)":"var(--red-muted)",color:o?"var(--green)":"var(--red)",position:"relative",cursor:"default"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-describedby":a?"verdict-tooltip":void 0,children:[t.passRate!=null?`${Math.round(t.passRate*100)}%`:t.status,a&&r.jsx("div",{id:"verdict-tooltip",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,padding:"6px 10px",background:"var(--surface-4)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:11,color:"var(--text-secondary)",whiteSpace:"nowrap",zIndex:50,maxWidth:300,width:"max-content",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:d.explanation})]})}function LC({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 zC({output:t,durationMs:a,tokens:s}){const[o,c]=m.useState(!1);return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:()=>c(!o),className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:o?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",a!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",(a/1e3).toFixed(1),"s)"]}),s!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),o&&r.jsx("pre",{className:"text-[12px] p-4 rounded-lg overflow-auto animate-fade-in",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:400,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Ld(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function zd({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:wy(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:Ll(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:Cy(t.durationMs)}),t.tokens!=null&&r.jsxs("span",{children:[t.tokens>=1e3?`${(t.tokens/1e3).toFixed(1)}k`:t.tokens," tok"]})]}),t.type==="comparison"&&t.baselinePassRate!=null&&(()=>{const a=t.pass_rate-t.baselinePassRate,s=a>.001?"skill":a<-.001?"baseline":"tie",o=a>0?"+":"",c=s==="skill"?"var(--green)":s==="baseline"?"var(--red)":"var(--text-tertiary)";return r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:a>=0?"var(--green)":"var(--red)"},children:[o,(a*100).toFixed(1),"%"]}),r.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),r.jsx("div",{className:"space-y-0.5",children:t.assertions.map(a=>r.jsxs("div",{className:"flex items-start gap-1.5",children:[r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a.text})]},a.id))})]})}function DC({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:o,dispatch:c}=An(),{plugin:u,skill:d}=o,[h,g]=m.useState(!0),p=a??null,y=s??!1,v=m.useCallback(()=>{g(E=>!E)},[]),b=p?p.slice(0,10):[],S=b.some(E=>{const C=Ld(E.type);return C==="left"||C==="full"}),k=b.some(E=>{const C=Ld(E.type);return C==="right"||C==="full"});return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:v,className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:h?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",p&&p.length>0&&r.jsxs("span",{style:{fontWeight:400},children:["(",p.length," run",p.length!==1?"s":"",")"]})]}),h&&r.jsx("div",{className:"animate-fade-in",children:y?r.jsxs("div",{className:"flex items-center gap-2 py-3",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!p||p.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(Ey,{entries:b})}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&r.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&r.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((E,C)=>{const N=Ld(E.type);return N==="full"?r.jsx("div",{style:{gridColumn:"1 / -1"},children:r.jsx(zd,{entry:E})},C):N==="left"?r.jsxs(m.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"},children:r.jsx(zd,{entry:E})}),r.jsx("div",{style:{gridColumn:"2"}})]},C):r.jsxs(m.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"}}),r.jsx("div",{style:{gridColumn:"2"},children:r.jsx(zd,{entry:E})})]},C)})]}),r.jsx("button",{onClick:()=>c({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:E=>{E.currentTarget.style.textDecoration="underline"},onMouseLeave:E=>{E.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function $g({evals:t,onSave:a,onCancel:s}){const[o,c]=m.useState(""),[u,d]=m.useState(""),[h,g]=m.useState(""),[p,y]=m.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[v,b]=m.useState("unit"),[S,k]=m.useState(""),[E,C]=m.useState([]),[N,T]=m.useState(""),[A,B]=m.useState(""),D=Math.max(0,...t.evals.map(z=>z.id))+1,F=z=>{b(z),z==="unit"&&(C([]),k(""),T(""),B(""))},w=()=>{const z=S.trim().toUpperCase();z&&!E.includes(z)&&C([...E,z]),k("")},O=()=>{if(!o.trim()||!u.trim())return;const z={id:D,name:o.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:p.filter(U=>U.text.trim()),...v==="integration"?{testType:"integration",...E.length>0?{requiredCredentials:E}:{},...N||A?{requirements:{...N?{platform:N}:{},...A?{chromeProfile:A}:{}}}:{}}:{}};a({...t,evals:[...t.evals,z]})};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(z=>r.jsx("button",{onClick:()=>F(z),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:v===z?z==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:v===z?z==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:z},z))})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),r.jsx("input",{value:o,onChange:z=>c(z.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:z=>d(z.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:z=>g(z.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"}),p.map((z,U)=>r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:z.text,onChange:H=>y(p.map((q,X)=>X===U?{...q,text:H.target.value}:q)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),p.length>1&&r.jsx("button",{onClick:()=>y(p.filter((H,q)=>q!==U)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z.id)),r.jsx("button",{onClick:()=>y([...p,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),v==="integration"&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:E.map(z=>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:[z,r.jsx("button",{onClick:()=>C(E.filter(U=>U!==z)),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"})]})})]},z))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:S,onChange:z=>k(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),w())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),r.jsx("button",{onClick:w,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:N,onChange:z=>T(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("label",{className:"block",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:A,onChange:z=>B(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsx("button",{onClick:O,disabled:!o.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function _C({evalCase:t,onUpdate:a}){var d,h;const[s,o]=m.useState(""),c=()=>{const g=s.trim().toUpperCase();g&&!(t.requiredCredentials??[]).includes(g)&&a({...t,requiredCredentials:[...t.requiredCredentials??[],g]}),o("")},u=g=>{const p=(t.requiredCredentials??[]).filter(y=>y!==g);a({...t,requiredCredentials:p.length>0?p:void 0})};return r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(g=>r.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[g,r.jsx("button",{onClick:()=>u(g),style:{color:"var(--orange)",lineHeight:1},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),c())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),r.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:((d=t.requirements)==null?void 0:d.platform)??"",onChange:g=>a({...t,requirements:{...t.requirements,platform:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:((h=t.requirements)==null?void 0:h.chromeProfile)??"",onChange:g=>a({...t,requirements:{...t.requirements,chromeProfile:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Rn(t,a){return a==="free"?"Free":a==="subscription"&&t==null?"Included":t==null?"N/A":t>=1?`$${t.toFixed(2)}`:t===0?"$0.00":t>=.001?`$${t.toFixed(4)}`:`$${t.toPrecision(3).replace(/0+$/,"").replace(/\.$/,"")}`}function Ay(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function OC(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function BC(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 IC(t,a,s){const o=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const c=Math.round(Math.abs(t)*a);if(c===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${o}`}function Vg(t,a){const s=o=>{const c=o/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(a)}}function UC(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function HC(t,a){const s=t+a,o=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(o)}–${u(c)}`}const $C={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function VC(t,a){if(!t)return null;const s=$C[t];if(s==null||s===0)return null;const o=s*a*.5,c=s*a*2;return`${Rn(o)}–${Rn(c)}`}function PC(){const{state:t,runCase:a,runAll:s,cancelCase:o,cancelAll:c,isReadOnly:u}=An(),{evals:d,caseRunStates:h,bulkRunActive:g,latestBenchmark:p,inlineResults:y}=t,{config:v}=Ha(),b=(d==null?void 0:d.evals)??[],S=m.useMemo(()=>{for(const w of h.values())if(w.status==="running"||w.status==="queued")return!0;return!1},[h]),k=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="complete"||O.status==="error"||O.status==="cancelled")}).length,E=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="running"||O.status==="queued")}).length,C=m.useRef(null),[N,T]=m.useState(0);m.useEffect(()=>{if(S&&!C.current&&(C.current=Date.now()),!S){C.current=null,T(0);return}const w=setInterval(()=>{C.current&&T(Math.round((Date.now()-C.current)/1e3))},1e3);return()=>clearInterval(w)},[S]);const A=b.reduce((w,O)=>w+O.assertions.length,0),B=b.length+A,D=m.useMemo(()=>HC(b.length,A),[b.length,A]),F=m.useMemo(()=>VC((v==null?void 0:v.provider)??null,B),[v==null?void 0:v.provider,B]);return r.jsxs("div",{className:"p-5",children:[u&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-4 text-[11px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Installed skill — benchmarking is disabled. Edit the source skill to run benchmarks."]}),r.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),S&&r.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[E," running"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),r.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||S||u,className:"btn btn-primary text-[12px]",title:"Runs both your skill and the baseline, then compares results side by side",children:"Run A/B Test"}),r.jsx("button",{onClick:()=>s("benchmark"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using your skill only",children:"Test Skill"}),r.jsx("button",{onClick:()=>s("baseline"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!S&&b.length>0&&r.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("span",{children:["Est. duration: ",D]}),F&&r.jsxs("span",{children:["Est. cost: ",F]}),!F&&(v==null?void 0:v.provider)&&(v.provider==="claude-cli"||v.provider==="codex-cli")&&r.jsx("span",{children:"Cost: Included"}),!F&&(v==null?void 0:v.provider)&&(v.provider==="ollama"||v.provider==="lm-studio"||v.provider==="gemini-cli")&&r.jsx("span",{children:"Cost: Free"})]})]}),S&&b.length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",k,"/",b.length," cases"]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(k/b.length*100),"%"]})]}),r.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${k/b.length*100}%`,background:"var(--accent)"}})}),r.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",N>=60?`${Math.floor(N/60)}m ${N%60}s`:`${N}s`]}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",D]})]})]}),r.jsx("div",{className:"space-y-3 stagger-children",children:b.map(w=>{const O=y.get(w.id),z=h.get(w.id),U=(z==null?void 0:z.status)??"idle",H=p==null?void 0:p.cases.find(q=>q.eval_id===w.id);return r.jsx(GC,{name:w.name,evalId:w.id,result:O,caseCost:H==null?void 0:H.cost,caseBillingMode:H==null?void 0:H.billingMode,caseInputTokens:H==null?void 0:H.inputTokens,caseOutputTokens:H==null?void 0:H.outputTokens,caseStatus:U,runMode:(z==null?void 0:z.mode)??null,comparisonDetail:H==null?void 0:H.comparisonDetail,isReadOnly:u,onRun:q=>a(q,"benchmark"),onBaseline:q=>a(q,"baseline"),onCompare:q=>a(q,"comparison"),onCancel:q=>o(q)},w.id)})}),!S&&p&&p.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:OC(p.type)}),r.jsx("span",{className:"text-[20px] font-bold",style:{color:(p.overall_pass_rate??0)>=.8?"var(--green)":(p.overall_pass_rate??0)>=.5?"var(--yellow)":"var(--red)"},children:p.overall_pass_rate!=null?`${Math.round(p.overall_pass_rate*100)}%`:"--"})]}),p.totalDurationMs!=null&&r.jsxs("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:["Total: ",(p.totalDurationMs/1e3).toFixed(1),"s",p.model&&` | Model: ${p.model}`,p.totalInputTokens!=null&&p.totalOutputTokens!=null&&` | Tokens: ${Ay(p.totalInputTokens,p.totalOutputTokens)}`,p.totalCost!=null&&` | Cost: ${Rn(p.totalCost)}`]}),p.overall_pass_rate>=.9999&&!p.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"})]}),p.comparison&&r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const w=BC(p.model,p.timestamp);return w?r.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:w}):r.jsx("div",{className:"mb-3"})})(),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Pg,{label:"Skill",value:p.comparison.skillPassRate,color:"var(--accent)"}),r.jsx(Pg,{label:"Baseline",value:p.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),r.jsxs("div",{className:"mt-3 text-[12px] font-medium",style:{color:p.comparison.delta>0?"var(--green)":p.comparison.delta<0?"var(--red)":"var(--text-tertiary)"},children:["Delta: ",p.comparison.delta>0?"+":"",(p.comparison.delta*100).toFixed(1),"%",p.verdict&&` | ${CC(p.verdict)}`]}),(()=>{const w=p.cases.reduce((z,U)=>z+U.assertions.length,0),O=IC(p.comparison.delta,w,p.cases.length);return r.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:O})})()]})]})]})}const FC={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 GC({name:t,evalId:a,result:s,caseCost:o,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:g,comparisonDetail:p,isReadOnly:y,onRun:v,onBaseline:b,onCompare:S,onCancel:k}){const[E,C]=m.useState(!1),N=h==="running"||h==="queued",T=h==="complete"||h==="error";return r.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:N?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[h==="running"&&r.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),h==="queued"&&r.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),r.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",a," ",t]}),g&&(N||T)&&(()=>{const A=FC[g];return A?r.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:A.bg,color:A.color,padding:"1px 6px"},children:A.label}):null})()]}),r.jsxs("div",{className:"flex items-center gap-2",children:[N?r.jsx("button",{onClick:()=>k(a),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>S(a),disabled:y,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),r.jsx("button",{onClick:()=>v(a),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),r.jsx("button",{onClick:()=>b(a),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&r.jsx("span",{className:"pill text-[10px]",style:{background:s.status==="pass"?"var(--green-muted)":"var(--red-muted)",color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.passRate!=null?`${Math.round(s.passRate*100)}%`:s.status}),u!=null&&d!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Ay(u,d)}),o!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Rn(o,c)}),h==="cancelled"&&r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"space-y-1",children:s.assertions.map(A=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{style:{color:A.pass?"var(--green)":"var(--red)"},children:A.pass?"PASS":"FAIL"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:A.text})]},A.assertion_id))}),s.output&&r.jsx("button",{onClick:()=>C(!E),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:E?"Hide output":"Show output"}),E&&s.output&&r.jsx("pre",{className:"text-[11px] mt-2 p-3 rounded-lg overflow-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:200,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap"},children:s.output})]}),p&&r.jsx("div",{className:"px-4 pb-3",children:r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:r.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const A=Vg(p.skillContentScore,p.baselineContentScore),B=Vg(p.skillStructureScore,p.baselineStructureScore),D=UC(p.winner);return r.jsxs(r.Fragment,{children:[r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",A.skill,"% / Baseline ",A.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",B.skill,"% / Baseline ",B.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsx("span",{style:{color:D.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:D.text})]})})()})})}),s&&s.errorMessage&&r.jsx(WC,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const Dd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function WC({errorMessage:t,classifiedError:a}){const[s,o]=m.useState(!1),c=(a==null?void 0:a.title)??"Error",u=a==null?void 0:a.hint,d=a?Dd[a.category]??Dd.unknown:Dd.unknown;return r.jsx("div",{className:"px-4 pb-3",children:r.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[r.jsx("span",{style:{fontSize:12},children:d}),r.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),r.jsx("button",{onClick:()=>o(!s),className:"text-[10px] px-1.5 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},children:s?"Hide details":"Details"})]}),u&&r.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&r.jsx("pre",{className:"text-[10px] px-3 pb-2.5 overflow-auto",style:{color:"var(--text-tertiary)",maxHeight:120,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:t})]})})}function Pg({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 Fg={TP:{bg:"var(--green-muted)",text:"var(--green)"},TN:{bg:"var(--green-muted)",text:"var(--green)"},FP:{bg:"var(--red-muted)",text:"var(--red)"},FN:{bg:"var(--red-muted)",text:"var(--red)"}};function qC(){var _;const{state:t,dispatch:a,runActivationTest:s,cancelActivation:o,generateActivationPrompts:c}=An(),{plugin:u,skill:d,activationPrompts:h,activationResults:g,activationSummary:p,activationRunning:y,activationError:v,activationStartedAt:b,activationClassifyingStatus:S,generatingPrompts:k,generatingPromptsError:E,activationHistory:C}=t,{state:N}=er(),T=((_=N.skills.find(I=>I.plugin===u&&I.skill===d))==null?void 0:_.version)??null,[A,B]=m.useState(h),[D,F]=m.useState(null),[w,O]=m.useState(!1);m.useEffect(()=>{h&&h!==A&&B(h)},[h]),m.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:A})},[A,a]),m.useEffect(()=>{fetch(`/api/skills/${u}/${d}/description`).then(I=>I.json()).then(I=>F(I.rawContent||I.description||null)).catch(()=>F(null))},[u,d]);function z(){s(A)}function U(){c(8)}const H=A.trim().split(`
77
+ `);if(s.length>1e3||o.length>1e3)return[...s.map(y=>({type:"unchanged",content:y}))];const c=s.length,u=o.length,d=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let y=1;y<=c;y++)for(let v=1;v<=u;v++)s[y-1]===o[v-1]?d[y][v]=d[y-1][v-1]+1:d[y][v]=Math.max(d[y-1][v],d[y][v-1]);const h=[];let g=c,m=u;for(;g>0||m>0;)g>0&&m>0&&s[g-1]===o[m-1]?(h.push({type:"unchanged",content:s[g-1]}),g--,m--):m>0&&(g===0||d[g][m-1]>=d[g-1][m])?(h.push({type:"added",content:o[m-1]}),m--):(h.push({type:"removed",content:s[g-1]}),g--);return h.reverse()}function eC(t,a){if(a&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return r.jsx("div",{className:"spinner",style:{width:10,height:10,flexShrink:0}});const o=new Set(["generating","comparing","preparing","generating_skill","generating_baseline","scoring","action_items"]);return r.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.has(t)?"var(--accent)":"var(--green)"}})}function ai({entries:t,isRunning:a}){const[s,o]=p.useState(!1),c=p.useRef(null);return p.useEffect(()=>{c.current&&!s&&(c.current.scrollTop=c.current.scrollHeight)},[t,s]),t.length===0&&!a?null:r.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between px-3 py-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-tertiary)"},children:[r.jsxs("span",{className:"flex items-center gap-2",children:[a&&r.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{transform:s?"rotate(0)":"rotate(180deg)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&r.jsx("div",{ref:c,className:"px-3 pb-3 space-y-1 max-h-48 overflow-y-auto",children:t.map((u,d)=>{const h=d===t.length-1&&a,g=d===0?"0s":`+${((u.timestamp-t[0].timestamp)/1e3).toFixed(1)}s`;return r.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:h?1:.7},children:[eC(u.phase,h),r.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:g}),r.jsx("span",{style:{color:h?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&r.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},d)})})]})}const Dg={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 Jo({error:t,onRetry:a,onDismiss:s}){const[o,c]=p.useState(null),u=p.useRef(null);p.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),p.useEffect(()=>{if(!(o==null||o<=0))return u.current=setInterval(()=>{c(g=>g==null||g<=1?(u.current&&clearInterval(u.current),0):g-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[o!=null&&o>0]);const d=Dg[t.category]||Dg.unknown,h=o!=null&&o>0;return r.jsxs("div",{className:"rounded-lg overflow-hidden animate-fade-in",style:{border:`1px solid color-mix(in srgb, ${d.color} 30%, transparent)`,background:`color-mix(in srgb, ${d.color} 6%, var(--surface-1))`},children:[r.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{style:{fontSize:14},children:d.icon}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:d.color},children:t.title})]}),s&&r.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-3.5 pb-3",children:[r.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),r.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(a||o!=null)&&r.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:a&&r.jsx("button",{onClick:a,disabled:h,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:h?.5:1},children:h?`Retry in ${o}s`:"Retry"})})]})]})}function tC({plugin:t,skill:a,skillContent:s,onApplied:o}){const[c,u]=p.useState("closed"),{config:d}=$a(),[h,g]=p.useState("claude-cli"),[m,y]=p.useState("opus"),[v,b]=p.useState([]),[S,k]=p.useState(""),[E,C]=p.useState(""),[N,T]=p.useState(null),[A,B]=p.useState(null),[D,F]=p.useState([]),[w,O]=p.useState(!1),z=p.useRef(null);p.useEffect(()=>{if(!d)return;d.providers.find(_=>_.id==="claude-cli"&&_.available)&&(g("claude-cli"),y("opus"))},[d]),p.useEffect(()=>()=>{var L;(L=z.current)==null||L.abort()},[]);function U(){return d==null?void 0:d.providers.find(L=>L.id===h&&L.available)}const H=p.useCallback(()=>{var L;(L=z.current)==null||L.abort(),u("open")},[]);async function q(){u("loading"),T(null),B(null),F([]);const L=new AbortController;z.current=L;try{const _=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(a)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,model:m}),signal:L.signal});if(!_.ok||!_.body){let Y=`HTTP ${_.status}`;try{const G=await _.json();G.error&&(Y=G.error)}catch{}throw new Error(Y)}const I=_.body.getReader(),V=new TextDecoder;let ie="",M="";for(;;){const{done:Y,value:G}=await I.read();if(Y)break;ie+=V.decode(G,{stream:!0});const te=ie.split(`
78
+ `);ie=te.pop()||"";for(const fe of te)if(fe.startsWith("event: "))M=fe.slice(7).trim();else if(fe.startsWith("data: ")){try{const oe=JSON.parse(fe.slice(6));M==="progress"?F(ve=>[...ve,{phase:oe.phase,message:oe.message,timestamp:Date.now()}]):M==="done"||M==="complete"?(k(oe.improved),C(oe.reasoning||""),b(Zo(oe.original||s,oe.improved)),u("diff_shown")):M==="error"&&(T(oe.message||oe.description||"Unknown error"),oe.category&&B(oe),u("open"))}catch{}M=""}}}catch(_){_.name!=="AbortError"&&(T(_.message),u("open"))}finally{z.current=null}}async function X(){O(!0);try{await Ce.applyImprovement(t,a,S),o(S),u("closed")}catch(L){T(L.message)}finally{O(!1)}}function J(){u("closed"),b([]),k(""),C(""),T(null)}if(c==="closed")return r.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const $=U();return r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),r.jsx("button",{onClick:J,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:L=>{L.currentTarget.style.background="var(--surface-3)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:h,onChange:L=>{g(L.target.value);const _=d==null?void 0:d.providers.find(I=>I.id===L.target.value);_!=null&&_.models[0]&&y(_.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(L=>L.available).map(L=>r.jsx("option",{value:L.id,children:L.label},L.id))})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:m,onChange:L=>y(L.target.value),disabled:c==="loading",children:$==null?void 0:$.models.map(L=>r.jsx("option",{value:L.id,children:L.label},L.id))})]}),c==="loading"?r.jsx("button",{onClick:H,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):r.jsx("button",{onClick:q,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&D.length>0&&r.jsx("div",{className:"mt-3",children:r.jsx(ai,{entries:D,isRunning:!0})})]}),N&&r.jsx("div",{className:"mb-4",children:A?r.jsx(Jo,{error:A,onRetry:q,onDismiss:()=>{T(null),B(null)}}):r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:N})}),c==="diff_shown"&&r.jsxs(r.Fragment,{children:[E&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),E]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:v.map((L,_)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:L.type==="added"?"rgba(34,197,94,0.1)":L.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:L.type==="added"?"var(--green)":L.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:L.type==="added"?"3px solid var(--green)":L.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:L.type==="added"?"+":L.type==="removed"?"-":" "}),L.content]},_))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:X,disabled:w,className:"btn btn-primary",children:w?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),r.jsx("button",{onClick:J,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const _g={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"}},nC={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function rC({change:t,index:a,selected:s,onToggle:o,originalEval:c}){var v;const[u,d]=p.useState(!1),h=_g[t.action]??_g.add,g=nC[t.action]??"var(--border-subtle)",m=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((v=t.eval)==null?void 0:v.name)??"Unnamed",y=p.useCallback(()=>o(a),[o,a]);return r.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${g}`,opacity:s?1:.5},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[r.jsx("input",{type:"checkbox",checked:s,onChange:y,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),r.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:h.bg,color:h.color,padding:"1px 6px"},children:h.label}),r.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:m}),r.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:t.reason}),r.jsx("button",{onClick:()=>d(!u),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-3)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:u?"rotate(90deg)":"rotate(0)",transition:"transform 0.15s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),u&&r.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.action==="add"&&t.eval&&r.jsx(aC,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&r.jsx(lC,{original:c,proposed:t.eval}),t.action==="remove"&&c&&r.jsx(sC,{evalCase:c})]})]})}function aC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[r.jsx(sf,{label:"Prompt",value:t.prompt}),r.jsx(sf,{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 lC({original:t,proposed:a}){const s=[];t.name!==a.name&&s.push({label:"Name",old:t.name,new:a.name}),t.prompt!==a.prompt&&s.push({label:"Prompt",old:t.prompt,new:a.prompt}),t.expected_output!==a.expected_output&&s.push({label:"Expected",old:t.expected_output,new:a.expected_output});const o=t.assertions??[],c=a.assertions??[],u=new Set(o.map(m=>m.text)),d=new Set(c.map(m=>m.text)),h=c.filter(m=>!u.has(m.text)),g=o.filter(m=>!d.has(m.text));return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(m=>r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:m.label}),r.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[r.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",of(m.old,120)]}),r.jsxs("div",{style:{color:"var(--green)"},children:["+ ",of(m.new,120)]})]})]},m.label)),(h.length>0||g.length>0)&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),r.jsxs("div",{className:"mt-1 space-y-0.5",children:[g.map(m=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",m.text]},m.id)),h.map(m=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",m.text]},m.id))]})]}),s.length===0&&h.length===0&&g.length===0&&r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function sC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[r.jsx(sf,{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 sf({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:of(a,300)})]})}function of(t,a){return t.length>a?t.slice(0,a)+"...":t}const Og={remove:0,modify:1,add:2};function iC({changes:t,selections:a,currentEvals:s,onToggle:o,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((g,m)=>({change:g,originalIndex:m}));d.sort((g,m)=>(Og[g.change.action]??2)-(Og[m.change.action]??2));const h=Array.from(a.values()).filter(Boolean).length;return r.jsxs("div",{className:"mt-3 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",h,"/",t.length," selected)"]})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("button",{onClick:c,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Select All"}),r.jsx("button",{onClick:u,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--surface-3)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),r.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:g,originalIndex:m})=>r.jsx(rC,{change:g,index:m,selected:a.get(m)??!1,onToggle:o,originalEval:g.evalId!=null?s.find(y=>y.id===g.evalId):void 0},m))})]})}function oC(){var L;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:o,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:g,retryEvalsSave:m}=An(),{aiEditLoading:y,aiEditResult:v,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:k,aiEditEvalChanges:E,aiEditEvalSelections:C,aiEditEvalsRetry:N}=t,[T,A]=p.useState(""),{config:B}=$a(),[D,F]=p.useState("claude-cli"),[w,O]=p.useState("opus"),z=p.useRef(null);p.useEffect(()=>{var _;(_=z.current)==null||_.focus()},[]),p.useEffect(()=>{if(!B)return;B.providers.find(I=>I.id==="claude-cli"&&I.available)&&(F("claude-cli"),O("opus"))},[B]);const U=B==null?void 0:B.providers.find(_=>_.id===D&&_.available),H=p.useCallback(()=>{const _=T.trim();!_||y||s(_,D,w)},[T,y,s,D,w]),q=p.useCallback(_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),H()),_.key==="Escape"&&(_.preventDefault(),y?u():c())},[H,y,u,c]),X=p.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),J=v?Zo(t.skillContent,v.improved):[],$=((L=t.evals)==null?void 0:L.evals)??[];return r.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M15 4V2"}),r.jsx("path",{d:"M15 16v-2"}),r.jsx("path",{d:"M8 9h2"}),r.jsx("path",{d:"M20 9h2"}),r.jsx("path",{d:"M17.8 11.8L19 13"}),r.jsx("path",{d:"M15 9h.01"}),r.jsx("path",{d:"M17.8 6.2L19 5"}),r.jsx("path",{d:"M11 6.2L9.7 5"}),r.jsx("path",{d:"M3 21l9-9"})]})}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),r.jsx("button",{onClick:c,className:"w-6 h-6 rounded-md flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--surface-3)"},onMouseLeave:_=>{_.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-4 py-3",children:[!v&&r.jsxs(r.Fragment,{children:[r.jsx("textarea",{ref:z,value:T,onChange:_=>A(_.target.value),onKeyDown:q,placeholder:"e.g., Add an error handling section...",disabled:y,rows:4,className:"w-full resize-y outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12.5,lineHeight:1.5,fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",minHeight:96,maxHeight:240}}),r.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:D,onChange:_=>{F(_.target.value);const I=B==null?void 0:B.providers.find(V=>V.id===_.target.value);I!=null&&I.models[0]&&O(I.models[0].id)},disabled:y,style:{width:"100%"},children:B==null?void 0:B.providers.filter(_=>_.available).map(_=>r.jsx("option",{value:_.id,children:_.label},_.id))})]}),r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:w,onChange:_=>O(_.target.value),disabled:y,style:{width:"100%"},children:U==null?void 0:U.models.map(_=>r.jsx("option",{value:_.id,children:_.label},_.id))})]}),r.jsx("div",{className:"flex-1"}),y?r.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):r.jsx("button",{onClick:H,disabled:!T.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),y&&k.length>0&&r.jsx("div",{className:"mt-2.5",children:r.jsx(ai,{entries:k,isRunning:!0})})]}),b&&r.jsx("div",{className:"mt-3",children:S?r.jsx(Jo,{error:S,onRetry:X,onDismiss:c}):r.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),v&&r.jsxs("div",{className:"animate-fade-in",children:[v.reasoning&&r.jsxs("div",{className:"mb-3 px-3 py-2.5 rounded-lg text-[11.5px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),v.reasoning]}),r.jsx("div",{className:"mb-1",children:r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:J.map((_,I)=>r.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:_.type==="added"?"rgba(34,197,94,0.1)":_.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:_.type==="added"?"var(--green)":_.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:_.type==="added"?"3px solid var(--green)":_.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:_.type==="added"?"+":_.type==="removed"?"-":" "}),_.content]},I))}),r.jsx(iC,{changes:E,selections:C,currentEvals:$,onToggle:d,onSelectAll:h,onDeselectAll:g}),N&&r.jsxs("div",{className:"mt-3 px-3 py-2.5 rounded-lg text-[12px] flex items-center justify-between",style:{background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.3)",color:"#fbbf24"},children:[r.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),r.jsx("button",{onClick:m,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("button",{onClick:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),r.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),r.jsx("button",{onClick:X,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function cC(t,a){const[s,o]=p.useState([]),[c,u]=p.useState("SKILL.md"),[d,h]=p.useState(null),[g,m]=p.useState(!1),[y,v]=p.useState(null),b=p.useCallback(async()=>{try{const E=await Ce.getSkillFiles(t,a);o(E.files)}catch{o([])}},[t,a]);p.useEffect(()=>{u("SKILL.md"),h(null),v(null),b()},[t,a,b]);const S=p.useCallback(async E=>{if(u(E),E==="SKILL.md"){h(null),v(null);return}m(!0),v(null);try{const C=await Ce.getSkillFile(t,a,E);h(C)}catch(C){v(`Unable to open file: ${C.message}`),h(null)}finally{m(!1)}},[t,a]),k=p.useCallback(()=>{b()},[b]);return{files:s,activeFile:c,secondaryContent:d,loading:g,error:y,selectFile:S,refresh:k,isSkillMd:c==="SKILL.md"}}function uC(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function dC(t){const a=[],s=new Map;for(const o of t){const c=o.path.split("/"),d={name:c[c.length-1],path:o.path,type:o.type,size:o.size,children:[]};s.set(o.path,d)}for(const o of t){const c=o.path.split("/");if(c.length===1){const u=s.get(o.path);u&&a.push(u)}else{const u=c.slice(0,-1).join("/"),d=s.get(u),h=s.get(o.path);d&&h&&d.children.push(h)}}return a}function jy({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 Sy(){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 fC(){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 pC(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"23 4 23 10 17 10"}),r.jsx("polyline",{points:"1 20 1 14 7 14"}),r.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function ky({node:t,depth:a,activeFile:s,onSelect:o}){const[c,u]=p.useState(!0),d=t.path===s;return t.type==="dir"?r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>u(!c),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+a*14}px`,paddingTop:2,paddingBottom:2,background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left"},children:[r.jsx(jy,{expanded:c}),r.jsx(Sy,{}),r.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>r.jsx(ky,{node:h,depth:a+1,activeFile:s,onSelect:o},h.path))]}):r.jsxs("button",{onClick:()=>o(t.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+a*14}px`,paddingTop:2,paddingBottom:2,background:d?"var(--accent-muted)":"none",border:"none",cursor:"pointer",color:d?"var(--accent)":"var(--text-tertiary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left",borderRadius:3},children:[r.jsx("span",{style:{width:10}}),r.jsx(fC,{}),r.jsx("span",{style:{flex:1},children:t.name}),r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:uC(t.size)})]})}function mC({files:t,activeFile:a,onSelect:s,onRefresh:o}){const[c,u]=p.useState(!1),d=p.useMemo(()=>dC(t),[t]);return r.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>u(!c),children:[r.jsx(jy,{expanded:c}),r.jsx(Sy,{}),r.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),r.jsx("button",{onClick:h=>{h.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:"2px 4px",display:"flex",alignItems:"center",borderRadius:3},title:"Refresh file list",children:r.jsx(pC,{})})]}),c&&r.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:d.length===0?r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):d.map(h=>r.jsx(ky,{node:h,depth:0,activeFile:a,onSelect:s},h.path))})]})}function jo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function hC(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function xC(t){const a=t.toLowerCase();return a.endsWith(".json")?"json":a.endsWith(".md")?"md":"other"}function Bg({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 Ig({content:t,fileType:a}){if(a==="json"){const s=hC(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:Qo(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 Ug(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"\\]|\\.)*"\s*:/g,s=>`<span style="color:#6383ff">${s}</span>`).replace(/:\s*"([^"\\]|\\.)*"/g,s=>`<span style="color:#22c55e">${s.slice(0,2)}<span style="color:#22c55e">${s.slice(2)}</span></span>`).replace(/:\s*(-?\d+\.?\d*)/g,(s,o)=>`: <span style="color:#fb923c">${o}</span>`).replace(/:\s*(true|false|null)/g,(s,o)=>`: <span style="color:#a855f7">${o}</span>`)}catch{return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}function gC({file:t,loading:a,error:s,viewMode:o,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[g,m]=p.useState(o),[y,v]=p.useState(!1),[b,S]=p.useState(""),[k,E]=p.useState(!1),[C,N]=p.useState(null),T=o!==g?o:g;p.useEffect(()=>{h==null||h(y)},[y,h]);const A=p.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),v(!0))},[t]),B=p.useCallback(()=>{v(!1)},[]),D=p.useCallback(async()=>{if(!(!c||!u||!t)){E(!0);try{await Ce.saveSkillFile(c,u,t.path,b),N("Saved"),v(!1),d==null||d(),setTimeout(()=>N(null),2e3)}catch(O){N(`Save failed: ${O.message}`),setTimeout(()=>N(null),3e3)}finally{E(!1)}}},[c,u,t,b,d]);if(p.useEffect(()=>{if(!y)return;const O=z=>{(z.ctrlKey||z.metaKey)&&z.key==="s"&&(z.preventDefault(),D())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[y,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 (",jo(t.size),") — cannot be displayed"]});const F=t.content??"",w=xC(t.path);return r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&r.jsxs("div",{style:{padding:"4px 12px",background:"var(--warning-muted, #fef3c7)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:"var(--warning-text, #92400e)"},children:["File truncated at ",jo(512*1024)," — ",jo(t.size)," total"]}),r.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(w==="md"||w==="json")&&["raw","split","preview"].map(O=>r.jsx("button",{onClick:()=>m(O),style:{padding:"2px 8px",fontSize:11,background:T===O?"var(--accent-muted)":"none",color:T===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:O},O)),r.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[jo(t.size),c&&u&&!t.binary&&!y&&r.jsx("button",{onClick:A,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),y&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick: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:B,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),C&&r.jsx("div",{style:{padding:"4px 12px",background:C.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:C.startsWith("Save failed")?"var(--red)":"var(--green)"},children:C}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:y?r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[r.jsx("textarea",{value:b,onChange:O=>S(O.target.value),style:{flex:1,width:"100%",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}}),r.jsxs("div",{style:{position:"sticky",bottom:0,display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),r.jsx("button",{onClick: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:B,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):T==="split"&&w!=="other"?r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:r.jsx(Bg,{content:F})}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:w==="json"?r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ug(F)}}):r.jsx(Ig,{content:F,fileType:w})})]}):T==="preview"&&w!=="other"?w==="json"?r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ug(F)}}):r.jsx(Ig,{content:F,fileType:w}):r.jsx(Bg,{content:F})})]})}function vC({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 yC({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 bC({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 jC({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 Md({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 SC(){const{state:t,dispatch:a,saveContent:s,isReadOnly:o}=An(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:g,aiEditOpen:m}=t,[y,v]=p.useState("split"),[b,S]=p.useState(!1),k=p.useRef(null),[E,C]=p.useState(!1),[N,T]=p.useState(""),[A,B]=p.useState(!1),[D,F]=p.useState(null),[w,O]=p.useState([]),[z,U]=p.useState([]),[H,q]=p.useState(null),X=p.useRef(null),{config:J}=$a(),{files:$,activeFile:L,secondaryContent:_,loading:I,error:V,selectFile:ie,refresh:M,isSkillMd:Y}=cC(c??"",u??""),[G,te]=p.useState(!1),fe=p.useCallback(ye=>{G&&!window.confirm("You have unsaved changes. Discard?")||ie(ye)},[G,ie]);p.useEffect(()=>()=>{var ye;(ye=X.current)==null||ye.abort()},[]);const{metadata:oe,body:ve}=Zw(d),de=oe["allowed-tools"],je=Array.isArray(de)?de:typeof de=="string"?[de]:[],Re=oe.name,_e=oe.description,ae=oe.metadata,he=typeof ae=="object"&&!Array.isArray(ae)?ae:null,pe=oe.version||(he==null?void 0:he.version),xe=oe.tags||(he==null?void 0:he.tags),be=Array.isArray(xe)?xe:typeof xe=="string"?xe.split(",").map(ye=>ye.trim()).filter(Boolean):[],Be=new Set(["name","description","metadata","allowed-tools","version","tags"]),Oe=Object.entries(oe).filter(([ye])=>!Be.has(ye)),lt=p.useCallback(async()=>{S(!0),await s(),S(!1)},[s]),Nt=p.useCallback(ye=>{(ye.ctrlKey||ye.metaKey)&&ye.key==="s"&&(ye.preventDefault(),ye.stopPropagation(),h&&lt()),(ye.ctrlKey||ye.metaKey)&&ye.key==="k"&&(ye.preventDefault(),ye.stopPropagation(),a({type:m?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,lt,m,a]),xt=p.useCallback(async()=>{var mt,Et;if(!N.trim())return;(mt=X.current)==null||mt.abort();const ye=new AbortController;X.current=ye,B(!0),q(null),U([]),F(null),O([]);try{const Xt=(J==null?void 0:J.provider)||"claude-cli",fn=(J==null?void 0:J.model)||"sonnet",Wt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:Xt,model:fn}),signal:ye.signal});if(!Wt.ok||!Wt.body){let gt=`HTTP ${Wt.status}`;try{const Wn=await Wt.json();Wn.error&&(gt=Wn.error)}catch{}throw new Error(gt)}const ln=Wt.body.getReader(),Mn=new TextDecoder;let Lt="",vt="";for(;;){const{done:gt,value:Wn}=await ln.read();if(gt)break;Lt+=Mn.decode(Wn,{stream:!0});const zr=Lt.split(`
79
+ `);Lt=zr.pop()||"";for(const dr of zr)if(dr.startsWith("event: "))vt=dr.slice(7).trim();else if(dr.startsWith("data: ")){try{const Rt=JSON.parse(dr.slice(6));if(vt==="progress")U(qt=>[...qt,{phase:Rt.phase,message:Rt.message,timestamp:Date.now()}]);else if(vt==="done"||vt==="complete"){const qt=["---"];Rt.name&&qt.push(`name: ${Rt.name}`),Rt.description&&qt.push(`description: "${Rt.description.replace(/"/g,'\\"')}"`),Rt.model&&qt.push(`model: ${Rt.model}`),(Et=Rt.allowedTools)!=null&&Et.trim()&&qt.push(`allowed-tools: ${Rt.allowedTools.trim()}`),qt.push("---","",Rt.body||"");const Ie=qt.join(`
80
+ `);F(Ie),O(Zo(d,Ie)),B(!1)}else vt==="error"&&(q(Rt.message||Rt.description||"Generation failed"),B(!1))}catch{}vt=""}}}catch(Xt){Xt.name!=="AbortError"&&q(Xt.message)}finally{B(!1),X.current=null}},[N,J,d]),_t=p.useCallback(()=>{D&&a({type:"SET_CONTENT",content:D}),C(!1),F(null),O([]),T(""),U([])},[D,a]),Tt=p.useCallback(()=>{C(!1),F(null),O([]),T(""),U([]),q(null)},[]),Ze=p.useCallback(()=>{var ye;E?((ye=X.current)==null||ye.abort(),Tt()):(m&&a({type:"CLOSE_AI_EDIT"}),C(!0))},[E,m,a,Tt]),nt=[{mode:"raw",icon:r.jsx(vC,{}),label:"Editor"},{mode:"split",icon:r.jsx(yC,{}),label:"Split"},{mode:"preview",icon:r.jsx(bC,{}),label:"Preview"}];return r.jsxs("div",{className:"flex flex-col h-full",onKeyDown:Nt,tabIndex:-1,children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:nt.map(({mode:ye,icon:mt,label:Et})=>r.jsxs("button",{onClick:()=>v(ye),title:Et,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:y===ye?"var(--surface-4)":"transparent",color:y===ye?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:y===ye?600:400,border:"none",cursor:"pointer"},children:[mt,r.jsx("span",{style:{letterSpacing:"0.01em"},children:Et})]},ye))}),Y?o?r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>{m?a({type:"CLOSE_AI_EDIT"}):(E&&Tt(),a({type:"OPEN_AI_EDIT"}))},title:"Edit with AI (Ctrl+K)",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:m?600:400,border:"none",cursor:"pointer",color:m?"var(--purple)":"var(--text-tertiary)",background:m?"var(--purple-muted)":"transparent"},children:[r.jsx(jC,{size:13}),r.jsx("span",{children:"AI Edit"})]}),r.jsxs("button",{onClick:Ze,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:E?600:400,border:"none",cursor:"pointer",color:E?"var(--purple)":"var(--text-tertiary)",background:E?"var(--purple-muted)":"transparent"},children:[r.jsx(Md,{size:13}),r.jsx("span",{children:"Regenerate"})]}),r.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),h&&r.jsx("button",{onClick:()=>a({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),r.jsx("button",{onClick:lt,disabled:!h||b,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"})]}):null]}),c&&u&&r.jsx(mC,{files:$,activeFile:L,onSelect:fe,onRefresh:M}),!Y&&r.jsx(gC,{file:_,loading:I,error:V,viewMode:y,plugin:c??void 0,skill:u??void 0,onSaved:()=>{ie(L),M()},onDirtyChange:te}),Y&&r.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:y==="raw"||y==="preview"?"1fr":"1fr 1fr"},children:[y!=="preview"&&r.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:y==="split"?"1px solid var(--border-subtle)":"none"},children:r.jsx("textarea",{ref:k,value:d,onChange:ye=>{o||a({type:"SET_CONTENT",content:ye.target.value})},onKeyDown:Nt,spellCheck:!1,readOnly:o,className:"flex-1 w-full resize-none outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",fontSize:12.5,lineHeight:1.7,tabSize:2,border:"none",padding:"16px 20px",opacity:o?.7:1}})}),y!=="raw"&&r.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:r.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(Re||pe||_e)&&r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Re&&r.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Re}),pe&&r.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4,letterSpacing:"0.03em",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:["v",pe]})]}),_e&&r.jsx("p",{style:{fontSize:12.5,lineHeight:1.65,color:"var(--text-secondary)",margin:0,paddingLeft:12,borderLeft:"2px solid var(--accent)",maxWidth:600},children:_e})]}),be.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:be.map(ye=>r.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-tertiary)",background:"var(--surface-2)",padding:"3px 8px",borderRadius:4,letterSpacing:"0.02em"},children:ye},ye))}),je.length>0&&r.jsx("div",{style:{marginBottom:16},children:r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),je.map(ye=>r.jsx("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono, ui-monospace, monospace)",color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4},children:ye},ye))]})}),Oe.length>0&&r.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:Oe.map(([ye,mt],Et)=>{const Xt=Array.isArray(mt)?mt.join(", "):typeof mt=="object"?Object.entries(mt).map(([fn,Wt])=>`${fn}: ${Array.isArray(Wt)?Wt.join(", "):Wt}`).join(" | "):mt;return r.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Et>0?"1px solid var(--border-subtle)":"none"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:ye}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Xt})]},ye)})}),(Re||_e||be.length>0||je.length>0||Oe.length>0)&&ve&&r.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ve&&r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Qo(ve)}})]})})]}),Y&&m&&r.jsx(oC,{}),Y&&E&&r.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:r.jsxs("div",{className:"px-4 py-3",children:[!D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Md,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),r.jsx("div",{className:"flex gap-2 mb-2",children:r.jsx("textarea",{value:N,onChange:ye=>T(ye.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:A,className:"flex-1 px-3 py-2 rounded-lg text-[12px] resize-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",outline:"none",opacity:A?.5:1},onKeyDown:ye=>{ye.key==="Enter"&&(ye.ctrlKey||ye.metaKey)&&N.trim()&&!A&&(ye.preventDefault(),xt())}})}),r.jsxs("div",{className:"flex items-center gap-2",children:[A?r.jsx("button",{onClick:()=>{var ye;(ye=X.current)==null||ye.abort(),B(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):r.jsx("button",{onClick:xt,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),r.jsx("button",{onClick:Tt,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),A&&z.length>0&&r.jsx("div",{className:"mt-2",children:r.jsx(ai,{entries:z,isRunning:!0})}),H&&r.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[H,r.jsx("button",{onClick:xt,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Md,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:w.map((ye,mt)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:ye.type==="added"?"var(--green-muted)":ye.type==="removed"?"var(--red-muted)":"transparent",color:ye.type==="added"?"var(--green)":ye.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:ye.type==="added"?"3px solid var(--green)":ye.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:ye.type==="added"?"+":ye.type==="removed"?"-":" "}),ye.content]},mt))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:_t,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),r.jsx("button",{onClick:Tt,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Y&&g!==null&&c&&u&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(tC,{plugin:c,skill:u,skillContent:d,onApplied:ye=>{a({type:"SET_CONTENT",content:ye}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})})]})}function Rl(t){return t.testType==="integration"?"integration":"unit"}function Dl(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function wy(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 Cy(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const kC=new Set(["benchmark","comparison","baseline"]);function Hg(t,a,s,o){return t.map(({rate:c,idx:u,total:d})=>{const h=o+u/(d-1)*(a-o*2),g=o+(s-o*2)-c*(s-o*2);return`${h},${g}`})}function Ey({entries:t}){const a=t.filter(v=>kC.has(v.type)).slice().reverse(),s=a.map((v,b,S)=>({rate:v.pass_rate,idx:b,total:S.length})).filter((v,b)=>{const S=a[b].type;return S==="benchmark"||S==="comparison"}),o=a.flatMap((v,b)=>v.type==="baseline"?[{rate:v.pass_rate,idx:b,total:a.length}]:v.type==="comparison"&&v.baselinePassRate!=null?[{rate:v.baselinePassRate,idx:b,total:a.length}]:[]);if(s.length<2&&o.length<2)return null;const c=80,u=24,d=2,h=s.length>=2?Hg(s,c,u,d):[],g=o.length>=2?Hg(o,c,u,d):[],m=h[h.length-1],y=g[g.length-1];return r.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[g.length>0&&r.jsx("polyline",{points:g.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),h.length>0&&r.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),y&&r.jsx("circle",{cx:parseFloat(y.split(",")[0]),cy:parseFloat(y.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),m&&r.jsx("circle",{cx:parseFloat(m.split(",")[0]),cy:parseFloat(m.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function Ny(t,a,s){const o=isNaN(a)?0:a,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&o>=.7){const m=c.length>0?` Met criteria: ${c.map(y=>y.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): evaluation met expectations.${m}`}}if(t==="FAIL"||t==="DEGRADING"){const m=u.length>0?` Failed criteria: ${u.map(v=>v.criterion).join(", ")}.`:"",y=[...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return y.length===0&&y.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${o.toFixed(2)}): evaluation did not meet expectations.${m}`,recommendations:y}}if(t==="INEFFECTIVE"){if(o<.2){const y=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),"Consider adding examples to your system prompt","Review the rubric criteria for achievability"];return{explanation:`${t} (score ${o.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:y}}const m=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.score.toFixed(2)}`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push("Consider restructuring your prompt approach"),{explanation:`${t} (score ${o.toFixed(2)}): below expectations but showing some capability.`,recommendations:m}}if(t==="MARGINAL"){const m=[...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`),...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Review prompt instructions for areas of improvement"),{explanation:`${t} (score ${o.toFixed(2)}): moderate improvement detected.`,recommendations:m}}if(t==="EMERGING"){const m=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Add more specific guidance to your prompt instructions"),{explanation:`${t} (score ${o.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:m}}const h=c.length>0?` Passing: ${c.map(m=>m.criterion).join(", ")}.`:"",g=d.length>0?` Needs improvement: ${d.map(m=>m.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): mixed results.${h}${g}`}}const Ty={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function wC(t){return Object.hasOwn(Ty,t)}function CC(t){return wC(t)?Ty[t]:t}function EC(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=p.useState([]),[u,d]=p.useState([]),[h,g]=p.useState(!0),[m,y]=p.useState(null),[v,b]=p.useState(new Set),[S,k]=p.useState({}),[E,C]=p.useState(null),[N,T]=p.useState(""),[A,B]=p.useState(!1),[D,F]=p.useState(""),[w,O]=p.useState(""),z=p.useCallback(async()=>{g(!0),y(null);try{const[$,L]=await Promise.all([Ce.getCredentials(a,s),Ce.getParams(a,s)]);c($.credentials),d(L.params)}catch($){y($ instanceof Error?$.message:"Failed to load parameters"),c([]),d([])}finally{g(!1)}},[a,s]);p.useEffect(()=>{z()},[z]);const U=p.useCallback(async($,L)=>{B(!0),y(null);try{await Ce.setCredential(a,s,$,L),C(null),T(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to save ${$}`)}finally{B(!1)}},[a,s,z]),H=p.useCallback(async()=>{const $=D.trim().toUpperCase(),L=w.trim();if(!(!$||!L)){B(!0),y(null);try{await Ce.setCredential(a,s,$,L),F(""),O(""),await z()}catch(_){y(_ instanceof Error?_.message:`Failed to add ${$}`)}finally{B(!1)}}},[a,s,D,w,z]),q=p.useCallback(async $=>{if(v.has($)){b(L=>{const _=new Set(L);return _.delete($),_}),k(L=>{const _={...L};return delete _[$],_});return}try{const _=(await Ce.getParamsRevealed(a,s,$)).params.find(I=>I.name===$);_!=null&&_.value&&(k(I=>({...I,[$]:_.value})),b(I=>new Set(I).add($)))}catch{}},[a,s,v]),X=new Set(o.map($=>$.name)),J=[...o.map($=>{const L=u.find(_=>_.name===$.name);return{name:$.name,status:$.status,maskedValue:(L==null?void 0:L.maskedValue)??""}}),...u.filter($=>!X.has($.name)).map($=>({name:$.name,status:$.status,maskedValue:$.maskedValue}))];return r.jsxs("div",{className:"py-2 px-3",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),m&&r.jsx("div",{className:"text-[10px] px-2 py-1.5 rounded mb-2",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},role:"alert",children:m}),h&&J.length===0&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&J.length===0&&!m&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),J.map($=>r.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:$.name}),r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:$.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:$.status==="ready"?"var(--green)":"var(--red)"},children:$.status}),($.maskedValue||$.status==="ready")&&r.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[v.has($.name)?S[$.name]??$.maskedValue:$.maskedValue||"***",r.jsx("button",{onClick:()=>q($.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${v.has($.name)?"Hide":"Reveal"} value for ${$.name}`,children:v.has($.name)?"hide":"show"})]}),E===$.name?r.jsxs("div",{className:"flex gap-1",children:[r.jsx("input",{value:N,onChange:L=>T(L.target.value),onKeyDown:L=>{L.key==="Enter"&&N.trim()&&U($.name,N)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${$.name}`,autoFocus:!0}),r.jsx("button",{onClick:()=>U($.name,N),disabled:A||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),r.jsx("button",{onClick:()=>{C(null),T("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):r.jsx("button",{onClick:()=>{C($.name),T("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},$.name)),r.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:D,onChange:$=>F($.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),r.jsx("input",{value:w,onChange:$=>O($.target.value),onKeyDown:$=>{$.key==="Enter"&&D.trim()&&w.trim()&&H()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),r.jsx("button",{onClick:H,disabled:A||!D.trim()||!w.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:A?"not-allowed":"pointer"},children:"Add"})]})]})]})}const _s="This is an installed copy (read-only). Open the source skill to edit.";function NC(t,a,s){const[o,c]=p.useState(null),[u,d]=p.useState(!1),h=p.useRef("");p.useEffect(()=>{const m=`${t}/${a}/${s}`;h.current!==m&&(h.current=m,d(!0),Ce.getCaseHistory(t,a,s).then(y=>c(y)).catch(()=>c([])).finally(()=>d(!1)))},[t,a,s]);const g=p.useCallback(()=>{d(!0),h.current="",Ce.getCaseHistory(t,a,s).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1))},[t,a,s]);return{entries:o,loading:u,refetch:g}}function TC(t,a,s){const o={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return o;const u=s.slice(0,10).map(g=>g.assertions.find(m=>m.id===t)).filter(Boolean);if(u.length>=2){const m=u.filter(y=>y.pass).length/u.length;m>=.3&&m<=.7&&(o.flaky=!0)}const d=s.find(g=>g.type==="benchmark"),h=s.find(g=>g.type==="baseline");if(d&&h){const g=d.assertions.find(y=>y.id===t),m=h.assertions.find(y=>y.id===t);g!=null&&g.pass&&(m!=null&&m.pass)&&(o.nonDiscriminating=!0)}if(a&&!a.pass&&s.length>=1){const m=s[0].assertions.find(y=>y.id===t);m!=null&&m.pass&&(o.regression=!0)}return o}function RC(){var I;const{state:t,dispatch:a,saveEvals:s,runCase:o,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:g}=An(),{evals:m,evalsError:y,selectedCaseId:v,inlineResults:b,caseRunStates:S,generateEvalsLoading:k,generateEvalsProgress:E,generateEvalsError:C}=t,N=p.useMemo(()=>{for(const V of S.values())if(V.status==="running"||V.status==="queued")return!0;return!1},[S]),[T,A]=p.useState(!1),[B,D]=p.useState("all"),F={skill_name:t.skill,evals:[]},w=m??F,O=w.evals,z=p.useMemo(()=>B==="all"?O:O.filter(V=>Rl(V)===B),[B,O]),U=z.find(V=>V.id===v)??null;p.useEffect(()=>{v!==null&&!z.find(V=>V.id===v)&&a({type:"SELECT_CASE",caseId:z.length>0?z[0].id:null})},[z,v,a]);const[H,q]=p.useState([]),X=p.useMemo(()=>O.some(V=>Rl(V)==="integration"),[O]);p.useEffect(()=>{X&&Ce.getCredentials(t.plugin,t.skill).then(V=>q(V.credentials)).catch(()=>q([]))},[t.plugin,t.skill,X]);const J=p.useMemo(()=>new Set(H.filter(V=>V.status==="missing").map(V=>V.name)),[H]),[$,L]=p.useState(!1),_=p.useCallback(V=>{L(!1),h(V?{testType:V}:void 0)},[h]);return!m||O.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:y?"var(--red-muted)":"var(--accent-muted)"},children:y?r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M9 11l3 3L22 4"}),r.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),r.jsx("div",{className:"text-center",children:y?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),r.jsx("div",{className:"text-[11px] font-mono px-3 py-2 rounded mt-1 max-w-sm text-left break-words",style:{color:"var(--text-secondary)",background:"var(--surface-2)"},children:y}),r.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Fix the evals.json file and reload, or regenerate test cases with AI"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>A(!0),disabled:g,title:g?_s:void 0,className:"btn btn-primary text-[12px]",children:"Create Test Case"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{className:"flex",children:[r.jsx("button",{onClick:()=>_("unit"),disabled:k||g,title:g?_s:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:k?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),r.jsx("button",{onClick:()=>L(!$),disabled:k||g,title:g?_s:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),$&&r.jsx("div",{className:"absolute right-0 mt-1 rounded-lg py-1 z-50",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",minWidth:180,boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:r.jsx("button",{onClick:()=>_("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.background="var(--surface-2)"},onMouseLeave:V=>{V.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),k&&E.length>0&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ai,{entries:E,isRunning:!0})}),C&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(Jo,{error:C,onRetry:()=>_()})}),T&&r.jsx($g,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]}):r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",height:"100%",overflow:"hidden"},children:[r.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:6,columnGap:8},children:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",z.length,")"]}),r.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:N?r.jsx("button",{onClick:d,className:"btn text-[10px] px-2 py-0.5",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:"Cancel All"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>c("benchmark"),disabled:z.length===0||g,title:g?_s:void 0,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),r.jsx("button",{onClick:()=>c("comparison"),disabled:z.length===0||g,title:g?_s:void 0,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]})})]}),r.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(V=>r.jsx("button",{onClick:()=>D(V),style:{padding:"2px 8px",fontSize:10,fontWeight:B===V?600:400,background:B===V?"var(--accent-muted)":"transparent",color:B===V?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:V==="all"?`All (${O.length})`:V==="unit"?`Unit (${O.filter(ie=>Rl(ie)==="unit").length})`:`Integration (${O.filter(ie=>Rl(ie)==="integration").length})`},V))}),r.jsxs("div",{className:"py-1",children:[z.length===0&&O.length>0&&r.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",B==="all"?"":B+" ","tests yet"]}),z.map(V=>{var G;const ie=b.get(V.id),M=v===V.id,Y=Rl(V);return r.jsxs("button",{onClick:()=>a({type:"SELECT_CASE",caseId:V.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:M?"var(--accent-muted)":"transparent",borderLeft:M?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:te=>{M||(te.currentTarget.style.background="var(--surface-2)")},onMouseLeave:te=>{M||(te.currentTarget.style.background="transparent")},children:[r.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[r.jsxs("span",{className:"text-[12px] font-medium truncate flex items-center gap-1.5",style:{color:M?"var(--text-primary)":"var(--text-secondary)"},children:["#",V.id," ",V.name,r.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:Y==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:Y==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:Y==="unit"?"U":"I"}),Y==="integration"&&((G=V.requiredCredentials)==null?void 0:G.some(te=>J.has(te)))&&r.jsx("span",{title:"Configure credentials to run",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),r.jsx(Ry,{result:ie})]}),r.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[V.assertions.length," assertion",V.assertions.length!==1?"s":"",(ie==null?void 0:ie.passRate)!=null&&r.jsx(LC,{passRate:ie.passRate})]})]},V.id)})]}),r.jsx("div",{className:"px-3 py-2",children:!g&&r.jsx("button",{onClick:()=>A(!0),className:"w-full py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{border:"1px dashed var(--border-default)",color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--accent)",V.currentTarget.style.color="var(--accent)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-default)",V.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(EC,{})})]}),r.jsx("div",{className:"overflow-auto",children:U?r.jsx(AC,{evalCase:U,result:b.get(U.id),evals:m,caseStatus:((I=S.get(U.id))==null?void 0:I.status)??"idle",onSaveEvals:s,onRun:V=>o(V,"benchmark"),onCompare:V=>o(V,"comparison"),onCancel:V=>u(V),onImprove:V=>a({type:"OPEN_IMPROVE",evalId:V})}):r.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),T&&r.jsx($g,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]})}function AC({evalCase:t,result:a,evals:s,caseStatus:o,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:g}){const{state:m,isReadOnly:y}=An(),{plugin:v,skill:b}=m,{entries:S,loading:k}=NC(v,b,t.id),[E,C]=p.useState(!1),[N,T]=p.useState(t.prompt),[A,B]=p.useState(!1),[D,F]=p.useState(t.expected_output);p.useState(()=>{T(t.prompt),F(t.expected_output)});const w=p.useCallback(V=>{c({...s,evals:s.evals.map(ie=>ie.id===V.id?V:ie)})},[s,c]),O=p.useCallback(()=>{w({...t,prompt:N}),C(!1)},[t,N,w]),z=p.useCallback(()=>{w({...t,expected_output:D}),B(!1)},[t,D,w]),U=p.useCallback(()=>{w({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,w]),H=p.useCallback((V,ie)=>{w({...t,assertions:t.assertions.map(M=>M.id===V?{...M,text:ie}:M)})},[t,w]),q=p.useCallback(V=>{w({...t,assertions:t.assertions.filter(ie=>ie.id!==V)})},[t,w]),X=p.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(V=>V.id!==t.id)})},[s,t.id,c]),J=a&&a.assertions.length>0&&a.assertions.every(V=>V.pass),$=a&&a.assertions.some(V=>!V.pass),L=Rl(t),_=t.requiredCredentials??[],I=L==="integration"&&_.length>0;return r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[r.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[r.jsxs("span",{className:"text-[16px] font-semibold",title:`#${t.id} ${t.name}`,style:{color:"var(--text-primary)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["#",t.id," ",t.name]}),y?r.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)"},children:L==="unit"?"Unit":"Integration"}):r.jsx("button",{onClick:()=>{if((L==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:ie,requirements:M,cleanup:Y,...G}=t;w({...G,testType:"unit"})}else w({...t,testType:"integration"})},title:`Click to switch to ${L==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:L==="unit"?"Unit":"Integration"}),r.jsx(Ry,{result:a})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[o==="running"||o==="queued"?r.jsxs("button",{onClick:()=>h(t.id),className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>u(t.id),disabled:y,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),r.jsx("button",{onClick:()=>d(t.id),disabled:y,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),$&&!y&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:()=>g(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!y&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:X,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),y&&L==="integration"&&r.jsxs("div",{"data-testid":"platform-integration-note",className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--accent-muted)",border:"1px solid var(--accent-muted)"},children:[r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),r.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),J&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--green-muted)",border:"1px solid var(--green-muted)"},children:[r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),I&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:_.map(V=>r.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:V},V))})]}),!y&&L==="integration"&&r.jsx(_C,{evalCase:t,onUpdate:w}),r.jsx(So,{title:"Prompt",children:E?r.jsxs("div",{children:[r.jsx("textarea",{value:N,onChange:V=>T(V.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:O,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{T(t.prompt),C(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-secondary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||C(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||r.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"No prompt":"Click to edit prompt..."})})}),r.jsx(So,{title:"Expected Output",children:A?r.jsxs("div",{children:[r.jsx("textarea",{value:D,onChange:V=>F(V.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:z,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{F(t.expected_output),B(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||B(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||r.jsx("span",{style:{fontStyle:"italic"},children:y?"No expected output":"Click to edit expected output..."})})}),r.jsx(So,{title:`Assertions (${t.assertions.length})`,action:y?void 0:r.jsx("button",{onClick:U,className:"btn btn-ghost text-[11px]",children:"+ Add"}),children:t.assertions.length===0?r.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):r.jsx("div",{className:"space-y-2",children:t.assertions.map(V=>{const ie=a==null?void 0:a.assertions.find(Y=>Y.assertion_id===V.id),M=TC(V.id,ie,S);return r.jsx(MC,{assertion:V,result:ie,badges:M,isReadOnly:y,onUpdate:Y=>H(V.id,Y),onDelete:()=>q(V.id)},V.id)})})}),(a==null?void 0:a.output)&&r.jsx(zC,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const V=Ny("INEFFECTIVE",a.passRate);return V.recommendations&&V.recommendations.length>0?r.jsx(So,{title:"Recommendations",children:r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),r.jsx("ul",{className:"space-y-1.5 ml-1",children:V.recommendations.map((ie,M)=>r.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[r.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),ie]},M))})]})}):null})(),r.jsx(DC,{evalId:t.id,sharedEntries:S,sharedLoading:k})]},t.id)}function MC({assertion:t,result:a,badges:s,isReadOnly:o,onUpdate:c,onDelete:u}){const[d,h]=p.useState(!1),[g,m]=p.useState(t.text),[y,v]=p.useState(!1),b=()=>{c(g),h(!1)};return r.jsx("div",{className:"rounded-lg px-3 py-2.5 transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:r.jsxs("div",{className:"flex items-start gap-2",children:[a?r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,border:"1.5px dashed var(--text-tertiary)",background:"transparent"},title:"Not run yet"}),(s==null?void 0:s.regression)&&r.jsx("span",{className:"mt-0.5 flex-shrink-0",title:"Regression: was passing, now failing",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:18,color:"var(--red)",fontSize:14,fontWeight:700,lineHeight:1},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&r.jsx("span",{title:"Flaky: 30-70% pass rate across recent runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--yellow-muted)",color:"var(--yellow)",whiteSpace:"nowrap"},children:"Flaky"}),(s==null?void 0:s.nonDiscriminating)&&r.jsx("span",{title:"Non-discriminating: passes on both skill and baseline runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--surface-3)",color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:"Non-Discrim."})]}),d?r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:g,onChange:S=>m(S.target.value),onKeyDown:S=>{S.key==="Enter"&&b(),S.key==="Escape"&&h(!1)},className:"input-field flex-1 text-[12px]",autoFocus:!0}),r.jsx("button",{onClick:b,className:"btn btn-primary text-[11px]",children:"Save"})]}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:o?"default":"pointer"},onClick:()=>{o||(m(t.text),h(!0))},children:t.text}),(a==null?void 0:a.reasoning)&&r.jsx("button",{onClick:()=>v(!y),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:y?"Hide reasoning":"Show reasoning"}),y&&(a==null?void 0:a.reasoning)&&r.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:a.reasoning})]}),!o&&r.jsx("button",{onClick:u,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:S=>{S.currentTarget.style.color="var(--red)",S.currentTarget.style.opacity="1"},onMouseLeave:S=>{S.currentTarget.style.color="var(--text-tertiary)",S.currentTarget.style.opacity=""},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function So({title:t,action:a,children:s}){return r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a]}),s]})}function Ry({result:t}){const[a,s]=p.useState(!1);if(!t||t.status==null)return r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const o=t.status==="pass",c=t.passRate??0,d=Ny(o?"PASS":"FAIL",c);return r.jsxs("span",{className:"pill text-[10px]",style:{background:o?"var(--green-muted)":"var(--red-muted)",color:o?"var(--green)":"var(--red)",position:"relative",cursor:"default"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-describedby":a?"verdict-tooltip":void 0,children:[t.passRate!=null?`${Math.round(t.passRate*100)}%`:t.status,a&&r.jsx("div",{id:"verdict-tooltip",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,padding:"6px 10px",background:"var(--surface-4)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:11,color:"var(--text-secondary)",whiteSpace:"nowrap",zIndex:50,maxWidth:300,width:"max-content",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:d.explanation})]})}function LC({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 zC({output:t,durationMs:a,tokens:s}){const[o,c]=p.useState(!1);return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:()=>c(!o),className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:o?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",a!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",(a/1e3).toFixed(1),"s)"]}),s!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),o&&r.jsx("pre",{className:"text-[12px] p-4 rounded-lg overflow-auto animate-fade-in",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:400,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Ld(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function zd({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:wy(t.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:t.type==="benchmark"?"var(--accent-muted)":t.type==="comparison"?"var(--purple-muted)":"var(--orange-muted)",color:t.type==="benchmark"?"var(--accent)":t.type==="comparison"?"var(--purple)":"var(--orange)"},children:t.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Dl(t.pass_rate)},children:[Math.round(t.pass_rate*100),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-1.5 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[t.durationMs!=null&&r.jsx("span",{children:Cy(t.durationMs)}),t.tokens!=null&&r.jsxs("span",{children:[t.tokens>=1e3?`${(t.tokens/1e3).toFixed(1)}k`:t.tokens," tok"]})]}),t.type==="comparison"&&t.baselinePassRate!=null&&(()=>{const a=t.pass_rate-t.baselinePassRate,s=a>.001?"skill":a<-.001?"baseline":"tie",o=a>0?"+":"",c=s==="skill"?"var(--green)":s==="baseline"?"var(--red)":"var(--text-tertiary)";return r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:a>=0?"var(--green)":"var(--red)"},children:[o,(a*100).toFixed(1),"%"]}),r.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),r.jsx("div",{className:"space-y-0.5",children:t.assertions.map(a=>r.jsxs("div",{className:"flex items-start gap-1.5",children:[r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a.text})]},a.id))})]})}function DC({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:o,dispatch:c}=An(),{plugin:u,skill:d}=o,[h,g]=p.useState(!0),m=a??null,y=s??!1,v=p.useCallback(()=>{g(E=>!E)},[]),b=m?m.slice(0,10):[],S=b.some(E=>{const C=Ld(E.type);return C==="left"||C==="full"}),k=b.some(E=>{const C=Ld(E.type);return C==="right"||C==="full"});return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:v,className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:h?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",m&&m.length>0&&r.jsxs("span",{style:{fontWeight:400},children:["(",m.length," run",m.length!==1?"s":"",")"]})]}),h&&r.jsx("div",{className:"animate-fade-in",children:y?r.jsxs("div",{className:"flex items-center gap-2 py-3",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!m||m.length===0?r.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):r.jsxs("div",{children:[b.length>=2&&r.jsx("div",{className:"mb-2",children:r.jsx(Ey,{entries:b})}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&r.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&r.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((E,C)=>{const N=Ld(E.type);return N==="full"?r.jsx("div",{style:{gridColumn:"1 / -1"},children:r.jsx(zd,{entry:E})},C):N==="left"?r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"},children:r.jsx(zd,{entry:E})}),r.jsx("div",{style:{gridColumn:"2"}})]},C):r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"}}),r.jsx("div",{style:{gridColumn:"2"},children:r.jsx(zd,{entry:E})})]},C)})]}),r.jsx("button",{onClick:()=>c({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:E=>{E.currentTarget.style.textDecoration="underline"},onMouseLeave:E=>{E.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function $g({evals:t,onSave:a,onCancel:s}){const[o,c]=p.useState(""),[u,d]=p.useState(""),[h,g]=p.useState(""),[m,y]=p.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[v,b]=p.useState("unit"),[S,k]=p.useState(""),[E,C]=p.useState([]),[N,T]=p.useState(""),[A,B]=p.useState(""),D=Math.max(0,...t.evals.map(z=>z.id))+1,F=z=>{b(z),z==="unit"&&(C([]),k(""),T(""),B(""))},w=()=>{const z=S.trim().toUpperCase();z&&!E.includes(z)&&C([...E,z]),k("")},O=()=>{if(!o.trim()||!u.trim())return;const z={id:D,name:o.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:m.filter(U=>U.text.trim()),...v==="integration"?{testType:"integration",...E.length>0?{requiredCredentials:E}:{},...N||A?{requirements:{...N?{platform:N}:{},...A?{chromeProfile:A}:{}}}:{}}:{}};a({...t,evals:[...t.evals,z]})};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(z=>r.jsx("button",{onClick:()=>F(z),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:v===z?z==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:v===z?z==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:z},z))})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),r.jsx("input",{value:o,onChange:z=>c(z.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:z=>d(z.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:z=>g(z.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((z,U)=>r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:z.text,onChange:H=>y(m.map((q,X)=>X===U?{...q,text:H.target.value}:q)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),m.length>1&&r.jsx("button",{onClick:()=>y(m.filter((H,q)=>q!==U)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},z.id)),r.jsx("button",{onClick:()=>y([...m,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),v==="integration"&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:E.map(z=>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:[z,r.jsx("button",{onClick:()=>C(E.filter(U=>U!==z)),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"})]})})]},z))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:S,onChange:z=>k(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),w())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),r.jsx("button",{onClick:w,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:N,onChange:z=>T(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("label",{className:"block",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:A,onChange:z=>B(z.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsx("button",{onClick:O,disabled:!o.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function _C({evalCase:t,onUpdate:a}){var d,h;const[s,o]=p.useState(""),c=()=>{const g=s.trim().toUpperCase();g&&!(t.requiredCredentials??[]).includes(g)&&a({...t,requiredCredentials:[...t.requiredCredentials??[],g]}),o("")},u=g=>{const m=(t.requiredCredentials??[]).filter(y=>y!==g);a({...t,requiredCredentials:m.length>0?m:void 0})};return r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(g=>r.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[g,r.jsx("button",{onClick:()=>u(g),style:{color:"var(--orange)",lineHeight:1},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),c())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),r.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:((d=t.requirements)==null?void 0:d.platform)??"",onChange:g=>a({...t,requirements:{...t.requirements,platform:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:((h=t.requirements)==null?void 0:h.chromeProfile)??"",onChange:g=>a({...t,requirements:{...t.requirements,chromeProfile:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Rn(t,a){return a==="free"?"Free":a==="subscription"&&t==null?"Included":t==null?"N/A":t>=1?`$${t.toFixed(2)}`:t===0?"$0.00":t>=.001?`$${t.toFixed(4)}`:`$${t.toPrecision(3).replace(/0+$/,"").replace(/\.$/,"")}`}function Ay(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function OC(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function BC(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 IC(t,a,s){const o=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const c=Math.round(Math.abs(t)*a);if(c===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${o}`}function Vg(t,a){const s=o=>{const c=o/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(a)}}function UC(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function HC(t,a){const s=t+a,o=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(o)}–${u(c)}`}const $C={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function VC(t,a){if(!t)return null;const s=$C[t];if(s==null||s===0)return null;const o=s*a*.5,c=s*a*2;return`${Rn(o)}–${Rn(c)}`}function PC(){const{state:t,runCase:a,runAll:s,cancelCase:o,cancelAll:c,isReadOnly:u}=An(),{evals:d,caseRunStates:h,bulkRunActive:g,latestBenchmark:m,inlineResults:y}=t,{config:v}=$a(),b=(d==null?void 0:d.evals)??[],S=p.useMemo(()=>{for(const w of h.values())if(w.status==="running"||w.status==="queued")return!0;return!1},[h]),k=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="complete"||O.status==="error"||O.status==="cancelled")}).length,E=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="running"||O.status==="queued")}).length,C=p.useRef(null),[N,T]=p.useState(0);p.useEffect(()=>{if(S&&!C.current&&(C.current=Date.now()),!S){C.current=null,T(0);return}const w=setInterval(()=>{C.current&&T(Math.round((Date.now()-C.current)/1e3))},1e3);return()=>clearInterval(w)},[S]);const A=b.reduce((w,O)=>w+O.assertions.length,0),B=b.length+A,D=p.useMemo(()=>HC(b.length,A),[b.length,A]),F=p.useMemo(()=>VC((v==null?void 0:v.provider)??null,B),[v==null?void 0:v.provider,B]);return r.jsxs("div",{className:"p-5",children:[u&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-4 text-[11px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Installed skill — benchmarking is disabled. Edit the source skill to run benchmarks."]}),r.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),S&&r.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[E," running"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),r.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||S||u,className:"btn btn-primary text-[12px]",title:"Runs both your skill and the baseline, then compares results side by side",children:"Run A/B Test"}),r.jsx("button",{onClick:()=>s("benchmark"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using your skill only",children:"Test Skill"}),r.jsx("button",{onClick:()=>s("baseline"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!S&&b.length>0&&r.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("span",{children:["Est. duration: ",D]}),F&&r.jsxs("span",{children:["Est. cost: ",F]}),!F&&(v==null?void 0:v.provider)&&(v.provider==="claude-cli"||v.provider==="codex-cli")&&r.jsx("span",{children:"Cost: Included"}),!F&&(v==null?void 0:v.provider)&&(v.provider==="ollama"||v.provider==="lm-studio"||v.provider==="gemini-cli")&&r.jsx("span",{children:"Cost: Free"})]})]}),S&&b.length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",k,"/",b.length," cases"]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(k/b.length*100),"%"]})]}),r.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${k/b.length*100}%`,background:"var(--accent)"}})}),r.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",N>=60?`${Math.floor(N/60)}m ${N%60}s`:`${N}s`]}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",D]})]})]}),r.jsx("div",{className:"space-y-3 stagger-children",children:b.map(w=>{const O=y.get(w.id),z=h.get(w.id),U=(z==null?void 0:z.status)??"idle",H=m==null?void 0:m.cases.find(q=>q.eval_id===w.id);return r.jsx(GC,{name:w.name,evalId:w.id,result:O,caseCost:H==null?void 0:H.cost,caseBillingMode:H==null?void 0:H.billingMode,caseInputTokens:H==null?void 0:H.inputTokens,caseOutputTokens:H==null?void 0:H.outputTokens,caseStatus:U,runMode:(z==null?void 0:z.mode)??null,comparisonDetail:H==null?void 0:H.comparisonDetail,isReadOnly:u,onRun:q=>a(q,"benchmark"),onBaseline:q=>a(q,"baseline"),onCompare:q=>a(q,"comparison"),onCancel:q=>o(q)},w.id)})}),!S&&m&&m.cases.length>0&&r.jsxs("div",{className:"mt-5",children:[r.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:OC(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: ${Ay(m.totalInputTokens,m.totalOutputTokens)}`,m.totalCost!=null&&` | Cost: ${Rn(m.totalCost)}`]}),m.overall_pass_rate>=.9999&&!m.comparison&&r.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||u,className:"text-[13px] font-semibold mt-3 w-full rounded-lg transition-opacity duration-150",style:{padding:"10px 0",background:"var(--green)",color:"var(--color-paper)",border:"none",cursor:"pointer",opacity:b.length===0?.5:1},children:"Run Final A/B Comparison"})]}),m.comparison&&r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const w=BC(m.model,m.timestamp);return w?r.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:w}):r.jsx("div",{className:"mb-3"})})(),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Pg,{label:"Skill",value:m.comparison.skillPassRate,color:"var(--accent)"}),r.jsx(Pg,{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&&` | ${CC(m.verdict)}`]}),(()=>{const w=m.cases.reduce((z,U)=>z+U.assertions.length,0),O=IC(m.comparison.delta,w,m.cases.length);return r.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:O})})()]})]})]})}const FC={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 GC({name:t,evalId:a,result:s,caseCost:o,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:g,comparisonDetail:m,isReadOnly:y,onRun:v,onBaseline:b,onCompare:S,onCancel:k}){const[E,C]=p.useState(!1),N=h==="running"||h==="queued",T=h==="complete"||h==="error";return r.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:N?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[h==="running"&&r.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),h==="queued"&&r.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),r.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",a," ",t]}),g&&(N||T)&&(()=>{const A=FC[g];return A?r.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:A.bg,color:A.color,padding:"1px 6px"},children:A.label}):null})()]}),r.jsxs("div",{className:"flex items-center gap-2",children:[N?r.jsx("button",{onClick:()=>k(a),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>S(a),disabled:y,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),r.jsx("button",{onClick:()=>v(a),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),r.jsx("button",{onClick:()=>b(a),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&r.jsx("span",{className:"pill text-[10px]",style:{background:s.status==="pass"?"var(--green-muted)":"var(--red-muted)",color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.passRate!=null?`${Math.round(s.passRate*100)}%`:s.status}),u!=null&&d!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Ay(u,d)}),o!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Rn(o,c)}),h==="cancelled"&&r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"space-y-1",children:s.assertions.map(A=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{style:{color:A.pass?"var(--green)":"var(--red)"},children:A.pass?"PASS":"FAIL"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:A.text})]},A.assertion_id))}),s.output&&r.jsx("button",{onClick:()=>C(!E),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:E?"Hide output":"Show output"}),E&&s.output&&r.jsx("pre",{className:"text-[11px] mt-2 p-3 rounded-lg overflow-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:200,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap"},children:s.output})]}),m&&r.jsx("div",{className:"px-4 pb-3",children:r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:r.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const A=Vg(m.skillContentScore,m.baselineContentScore),B=Vg(m.skillStructureScore,m.baselineStructureScore),D=UC(m.winner);return r.jsxs(r.Fragment,{children:[r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",A.skill,"% / Baseline ",A.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",B.skill,"% / Baseline ",B.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsx("span",{style:{color:D.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:D.text})]})})()})})}),s&&s.errorMessage&&r.jsx(WC,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const Dd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function WC({errorMessage:t,classifiedError:a}){const[s,o]=p.useState(!1),c=(a==null?void 0:a.title)??"Error",u=a==null?void 0:a.hint,d=a?Dd[a.category]??Dd.unknown:Dd.unknown;return r.jsx("div",{className:"px-4 pb-3",children:r.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[r.jsx("span",{style:{fontSize:12},children:d}),r.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),r.jsx("button",{onClick:()=>o(!s),className:"text-[10px] px-1.5 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},children:s?"Hide details":"Details"})]}),u&&r.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&r.jsx("pre",{className:"text-[10px] px-3 pb-2.5 overflow-auto",style:{color:"var(--text-tertiary)",maxHeight:120,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:t})]})})}function Pg({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 Fg={TP:{bg:"var(--green-muted)",text:"var(--green)"},TN:{bg:"var(--green-muted)",text:"var(--green)"},FP:{bg:"var(--red-muted)",text:"var(--red)"},FN:{bg:"var(--red-muted)",text:"var(--red)"}};function qC(){var _;const{state:t,dispatch:a,runActivationTest:s,cancelActivation:o,generateActivationPrompts:c}=An(),{plugin:u,skill:d,activationPrompts:h,activationResults:g,activationSummary:m,activationRunning:y,activationError:v,activationStartedAt:b,activationClassifyingStatus:S,generatingPrompts:k,generatingPromptsError:E,activationHistory:C}=t,{state:N}=er(),T=((_=N.skills.find(I=>I.plugin===u&&I.skill===d))==null?void 0:_.version)??null,[A,B]=p.useState(h),[D,F]=p.useState(null),[w,O]=p.useState(!1);p.useEffect(()=>{h&&h!==A&&B(h)},[h]),p.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:A})},[A,a]),p.useEffect(()=>{fetch(`/api/skills/${u}/${d}/description`).then(I=>I.json()).then(I=>F(I.rawContent||I.description||null)).catch(()=>F(null))},[u,d]);function z(){s(A)}function U(){c(8)}const H=A.trim().split(`
81
81
  `).filter(Boolean).length,q=g.filter(I=>I.classification==="TP"||I.classification==="TN"),X=g.filter(I=>I.classification==="FP"||I.classification==="FN"),J=(D==null?void 0:D.replace(/^---[\s\S]*?---\s*/,"").trim())??null,$=A.trim().length>0,L=J?Qo(J):"";return r.jsxs("div",{className:"p-5 space-y-5",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),r.jsx("div",{className:"text-[12px] mt-0.5",style:{color:"var(--text-tertiary)"},children:"Test whether this skill's description activates for relevant prompts and stays silent for irrelevant ones."})]}),r.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[r.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),r.jsx("div",{className:"flex gap-1.5",children:r.jsx("button",{onClick:U,disabled:k||!J||y,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:k?"var(--surface-3)":"var(--surface-2)",color:J?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:J?1:.5,cursor:J?"pointer":"not-allowed"},title:J?void 0:"No skill description available",onMouseEnter:I=>{J&&!k&&(I.currentTarget.style.background="var(--surface-3)")},onMouseLeave:I=>{k||(I.currentTarget.style.background="var(--surface-2)")},children:k?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 3v3m6.36.64l-2.12 2.12M21 12h-3m-.64 6.36l-2.12-2.12M12 21v-3m-4.24.64l2.12-2.12M3 12h3m.64-6.36l2.12 2.12"})}),$?"Regenerate":"Generate"," Test Prompts"]})})})]}),!J&&!y&&r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},"aria-live":"polite",children:"Add a description to your skill's frontmatter to enable prompt generation."}),E&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:E}),r.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:A,onChange:I=>B(I.target.value),placeholder:`How do I write a unit test?
82
82
  What edge cases should I test?
83
83
  +Deploy this to production
84
84
  !What's the weather like today?
85
- !Write me a poem about flowers`}),r.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsx("span",{children:"One prompt per line"}),r.jsx(ko,{}),r.jsx("span",{children:"No prefix = auto-classify"}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),r.jsx(ko,{}),r.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[H," prompt",H!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:z,disabled:y||!A.trim(),className:"btn btn-primary",children:y?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("circle",{cx:"12",cy:"12",r:"6"}),r.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[S||`${g.length} / ${H} prompts tested`,b&&r.jsx(QC,{startedAt:b})]})]})]})]}),r.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[r.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:J?r.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:L}}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&r.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[r.jsx("div",{className:"spinner-lg mx-auto mb-4"}),r.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&r.jsxs("div",{className:"space-y-5",children:[X.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),r.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",X.length,")"]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((I,V)=>r.jsx(Gg,{result:I},`incorrect-${V}`))})]}),q.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("polyline",{points:"16 10 11 15 8 12"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",q.length,")"]})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:q.map((I,V)=>r.jsx(Gg,{result:I},`correct-${V}`))})]})]}),p&&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"}),p.autoClassifiedCount!=null&&p.autoClassifiedCount>0&&r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[p.autoClassifiedCount," of ",p.total," prompts auto-classified from skill name and tags"]}),r.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[r.jsx(_d,{label:"Precision",value:p.precision,description:"Of all activations, how many were correct?",detail:`${p.tp} true / ${p.tp+p.fp} total activations`}),r.jsx(_d,{label:"Recall",value:p.recall,description:"Of expected activations, how many fired?",detail:`${p.tp} activated / ${p.tp+p.fn} expected`}),r.jsx(_d,{label:"Reliability",value:p.reliability,description:"Overall correct classification rate",detail:`${p.tp+p.tn} correct / ${p.total} total`})]}),r.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[r.jsx(wo,{label:"True Positive",abbr:"TP",count:p.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),r.jsx(wo,{label:"False Positive",abbr:"FP",count:p.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),r.jsx(wo,{label:"False Negative",abbr:"FN",count:p.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),r.jsx(wo,{label:"True Negative",abbr:"TN",count:p.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),r.jsx(YC,{history:C,expanded:w,onToggle:()=>O(!w),skillVersion:T})]})}function YC({history:t,expanded:a,onToggle:s,skillVersion:o}){return t===null?null:r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:a?"1px solid var(--border-subtle)":"none"},onClick:s,children:[r.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&r.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&r.jsx("div",{className:"px-4 py-3",children:t.length===0?r.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):r.jsx("div",{className:"space-y-2",children:t.map(c=>r.jsx(KC,{run:c,skillVersion:o},c.id))})})]})}function KC({run:t,skillVersion:a}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:XC(t.timestamp)}),r.jsx(ti,{version:a??null,size:"sm","data-testid":"activation-row-version"}),r.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),r.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),r.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function XC(t){const a=Date.now(),s=new Date(t).getTime(),o=Math.floor((a-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<7?`${d}d ago`:new Date(t).toLocaleDateString()}function ko(){return r.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function Gg({result:t}){const a=Fg[t.classification]||Fg.FN,s=t.classification==="TP"||t.classification==="TN";return r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:a.bg,border:"1px solid transparent"},children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${a.text} 20%, transparent)`},children:s?r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),r.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[r.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:a.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),r.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&r.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&r.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function _d({label:t,value:a,description:s,detail:o}){const c=Math.round(a*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return r.jsxs("div",{className:"text-center",children:[r.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),r.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),r.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),r.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function wo({abbr:t,count:a,bg:s,color:o,description:c}){return r.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[r.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:a}),r.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),r.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function QC({startedAt:t}){const[a,s]=m.useState(0);return m.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),r.jsxs("span",{className:"ml-2",children:["(",a,"s)"]})}const Od={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},Wg={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},cf=600,uf=180,sn=40,Bd=cf-sn*2,aa=uf-sn*2,ZC=[25,50,75,100];function qg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function JC(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function eE({entries:t,onPointClick:a}){const[s,o]=m.useState(null),c=m.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((p,y)=>{const v=sn+y/(u-1)*Bd,b=p.passRate*100,S=sn+aa-b/100*aa;return{x:v,y:S,pct:b,entry:p}}),h=d.map(p=>`${p.x},${p.y}`).join(" "),g=Array.from(new Set(c.map(p=>p.type)));return r.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[r.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),r.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(p=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Od[p]??"var(--text-tertiary)"}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:Wg[p]??p})]},p))}),r.jsxs("svg",{width:cf,height:uf,viewBox:`0 0 ${cf} ${uf}`,style:{display:"block",overflow:"visible"},children:[ZC.map(p=>{const y=sn+aa-p/100*aa;return r.jsxs("g",{children:[r.jsx("line",{x1:sn,y1:y,x2:sn+Bd,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),r.jsxs("text",{x:sn-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[p,"%"]})]},p)}),r.jsx("line",{x1:sn,y1:sn+aa,x2:sn+Bd,y2:sn+aa,stroke:"var(--border-subtle)",strokeWidth:1}),r.jsx("text",{x:sn-8,y:sn+aa+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),r.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((p,y)=>r.jsx("circle",{cx:p.x,cy:p.y,r:5,fill:Od[p.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:p.x,y:p.y,entry:p.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>a==null?void 0:a(p.entry)},y)),tE(u).map(p=>r.jsx("text",{x:d[p].x,y:sn+aa+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:qg(c[p].timestamp)},p))]}),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:qg(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:Od[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:Wg[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:JC(s.entry.totalDurationMs)}),r.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function tE(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const a=Math.ceil(t/10),s=[0];for(let o=a;o<t-1;o+=a)s.push(o);return s.push(t-1),s}const Os=new Map;let on=null,Do=null,Co=1e3,Tl=0;function My(){if(on)return;on=new EventSource("/api/events");const t=a=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=Os.get(a);if(c)for(const u of c)u(o)};on.addEventListener("benchmark:complete",t("benchmark:complete")),on.addEventListener("history:written",t("history:written")),on.addEventListener("leaderboard:updated",t("leaderboard:updated")),on.onerror=()=>{on==null||on.close(),on=null,Tl>0&&(Do=setTimeout(()=>{Co=Math.min(Co*2,3e4),My()},Co))},on.onopen=()=>{Co=1e3}}function nE(){Do!=null&&(clearTimeout(Do),Do=null),on==null||on.close(),on=null}function rE(t,a){return Os.has(t)||Os.set(t,new Set),Os.get(t).add(a),Tl++,My(),()=>{var s;(s=Os.get(t))==null||s.delete(a),Tl--,Tl<=0&&(Tl=0,queueMicrotask(()=>{Tl<=0&&nE()}))}}function Ho(t,a){const s=m.useRef(a);s.current=a,m.useEffect(()=>rE(t,c=>s.current(c)),[t])}function $o(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function aE(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function lE({rate:t,label:a}){const s=Math.round(t*100);return r.jsx("div",{className:"flex items-center gap-3",children:r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:a}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:$o(t)},children:[s,"%"]})]}),r.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:$o(t)}})})]})})}function sE({points:t}){if(t.length<2)return null;const a=200,s=48,o=4,c=t.length,u=t.map((g,p)=>{const y=o+p/(c-1)*(a-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,p)=>`${p===0?"M":"L"} ${g.x},${g.y}`).join(" ");return r.jsxs("svg",{width:a,height:s,style:{display:"block"},children:[r.jsx("path",{d,fill:"var(--accent-muted)"}),r.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function iE({plugin:t,skill:a}){const s=`stats/${t}/${a}`,o=m.useCallback(()=>Ce.getStats(t,a),[t,a]),{data:c,loading:u}=ni(s,o),d=m.useCallback(()=>Tn(s),[s]);if(Ho("benchmark:complete",d),Ho("history:written",d),u)return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"skeleton h-24 rounded-xl"}),r.jsx("div",{className:"skeleton h-48 rounded-xl"}),r.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),r.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,p=h-g,y=c.assertionStats.slice(0,10);return r.jsxs("div",{className:"space-y-4 stagger-children",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:$o(h)},children:[Math.round(h*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:p>=0?"var(--green)":"var(--red)"},children:[p>=0?"+":"",Math.round(p*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.totalCost)})]}),c.costPerRun!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),r.jsx(sE,{points:c.trendPoints})]}),c.modelStats.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),r.jsx("tbody",{children:c.modelStats.map(v=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),r.jsx("td",{style:{padding:"8px",textAlign:"center"},children:r.jsxs("span",{className:"font-semibold",style:{color:$o(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:aE(v.avgDurationMs)}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Rn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),r.jsx("div",{className:"space-y-3",children:y.map(v=>r.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-2)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),r.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),r.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),r.jsx(lE,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function oE({plugin:t,skill:a}){const[s,o]=m.useState(null),[c,u]=m.useState(null),[d,h]=m.useState({}),[g,p]=m.useState({});m.useEffect(()=>{Ce.getEvals(t,a).then(o).catch(()=>o(null))},[t,a]);async function y(v){if(c===v){u(null);return}if(u(v),!d[v]){p(b=>({...b,[v]:!0}));try{const b=await Ce.getCaseHistory(t,a,v);h(S=>({...S,[v]:b}))}catch{h(b=>({...b,[v]:[]}))}finally{p(b=>({...b,[v]:!1}))}}}return s?r.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const b=d[v.id]||[],S=c===v.id,k=g[v.id],E=b.length>0?b[0].pass_rate:null;return r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:S?"var(--surface-2)":"transparent"},onMouseEnter:C=>{S||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{S||(C.currentTarget.style.background="transparent")},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:S?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),r.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),r.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),b.length>=2&&r.jsx(Ey,{entries:b}),E!=null&&r.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Ll(E)},children:[Math.round(E*100),"%"]}),b.length>0&&r.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),S&&r.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?r.jsxs("div",{className:"p-4 flex items-center gap-2",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?r.jsx("div",{className:"p-4",children:r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):r.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,N)=>r.jsxs("div",{className:"p-4",style:{background:N===0?"var(--surface-2)":"transparent"},children:[r.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:wy(C.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Ll(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&r.jsx("span",{children:Cy(C.durationMs)}),C.tokens!=null&&r.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),r.jsx("div",{className:"space-y-1",children:C.assertions.map(T=>r.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[r.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:T.pass?"var(--green)":"var(--red)"},children:r.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:T.pass?r.jsx("polyline",{points:"20 6 9 17 4 12"}):r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:T.text}),T.reasoning&&r.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:T.reasoning})]})]},T.id))})]},N))})})]},v.id)})}):r.jsx("div",{className:"text-center py-12",children:r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function cE(){const{state:t,dispatch:a}=An(),{plugin:s,skill:o}=t,{state:c}=er(),u=c.skills.find(I=>I.plugin===s&&I.skill===o),d=(u==null?void 0:u.version)??null,[h,g]=m.useState("timeline"),[p,y]=m.useState(""),[v,b]=m.useState(""),[S,k]=m.useState(!1),[E,C]=m.useState([]),[N,T]=m.useState(null),[A,B]=m.useState(!1),[D,F]=m.useState(null),[w,O]=m.useState(!1),z=`history/${s}/${o}?model=${p}&type=${v}`,U=m.useCallback(()=>Ce.getHistory(s,o,{model:p||void 0,type:v||void 0}),[s,o,p,v]),{data:H,loading:q}=ni(z,U),X=H??[];m.useEffect(()=>{!H||H.length<2||Ce.compareRuns(s,o,H[0].timestamp,H[1].timestamp).then(I=>{const V=I.regressions.filter(se=>se.change==="regression");a({type:"SET_REGRESSIONS",regressions:V})}).catch(()=>{})},[H,s,o,a]);const J=m.useCallback(()=>Tn(z),[z]);Ho("history:written",J);const $=m.useCallback(async I=>{if(S){C(V=>V.includes(I)?V.filter(se=>se!==I):V.length>=2?[V[1],I]:[...V,I]);return}O(!0);try{const V=await Ce.getHistoryEntry(s,o,I);F(V)}catch{}finally{O(!1)}},[s,o,S]),L=m.useCallback(async()=>{if(E.length===2){B(!0);try{const I=await Ce.compareRuns(s,o,E[0],E[1]);T(I)}catch{}finally{B(!1)}}},[s,o,E]),_=[...new Set(X.map(I=>I.model))];return q?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"skeleton h-12 rounded-lg"}),r.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(I=>r.jsx("button",{onClick:()=>g(I),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===I?"var(--accent-muted)":"transparent",color:h===I?"var(--accent)":"var(--text-tertiary)"},children:I==="timeline"?"Timeline":I==="per-eval"?"Per Eval":"Statistics"},I))}),h==="timeline"&&r.jsxs("div",{children:[X.length>0&&r.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:r.jsx(eE,{entries:X,onPointClick:I=>$(I.timestamp)})}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("select",{value:p,onChange:I=>y(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Models"}),_.map(I=>r.jsx("option",{value:I,children:I},I))]}),r.jsxs("select",{value:v,onChange:I=>b(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Types"}),r.jsx("option",{value:"benchmark",children:"Benchmark"}),r.jsx("option",{value:"comparison",children:"Comparison"}),r.jsx("option",{value:"baseline",children:"Baseline"}),r.jsx("option",{value:"model-compare",children:"Model Compare"}),r.jsx("option",{value:"improve",children:"AI Improve"}),r.jsx("option",{value:"instruct",children:"AI Edit"}),r.jsx("option",{value:"ai-generate",children:"AI Generate"}),r.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:()=>{k(!S),C([]),T(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&E.length===2&&r.jsx("button",{onClick:L,disabled:A,className:"btn btn-primary text-[12px]",children:A?"Comparing...":"Compare"})]}),r.jsx("div",{className:"space-y-2",children:X.length===0?r.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(I=>{const V=E.includes(I.timestamp);return r.jsx("button",{onClick:()=>$(I.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:V?"var(--accent-muted)":"var(--surface-1)",border:V?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:se=>{V||(se.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:se=>{V||(se.currentTarget.style.borderColor="var(--border-subtle)")},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:V?"var(--accent)":"var(--border-default)",background:V?"var(--accent)":"transparent"},children:V&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(I.timestamp).toLocaleString()}),r.jsx("span",{className:"pill text-[9px]",style:{background:I.type==="comparison"?"var(--purple-muted)":I.type==="baseline"?"var(--surface-3)":I.type==="model-compare"?"var(--accent-muted)":I.type==="improve"||I.type==="instruct"?"var(--purple-muted)":I.type==="ai-generate"?"var(--green-muted)":I.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:I.type==="comparison"?"var(--purple)":I.type==="baseline"?"var(--text-tertiary)":I.type==="model-compare"?"var(--accent)":I.type==="improve"||I.type==="instruct"?"var(--purple)":I.type==="ai-generate"?"var(--green)":I.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:I.type==="model-compare"?"model compare":I.type==="improve"?"ai improve":I.type==="instruct"?"ai edit":I.type==="ai-generate"?"ai generate":I.type==="eval-generate"?"eval generate":I.type})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ti,{version:d,size:"sm","data-testid":"history-row-version"}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:I.model}),I.totalCost!=null&&I.totalCost>0&&r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(I.totalCost)}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:I.passRate>=.8?"var(--green)":I.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(I.passRate*100),"%"]})]})]})},I.timestamp)})}),N&&r.jsx(uE,{result:N}),D&&!S&&r.jsx(dE,{run:D,onClose:()=>F(null)})]}),h==="per-eval"&&r.jsx(oE,{plugin:s,skill:o}),h==="statistics"&&r.jsx(iE,{plugin:s,skill:o})]})}function uE({result:t}){const a=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&r.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[r.jsxs("span",{children:["Run A cost: ",Rn(t.runA.totalCost??null)]}),r.jsxs("span",{children:["Run B cost: ",Rn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&r.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Rn(t.runB.totalCost-t.runA.totalCost)]})]}),a.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",a.length,")"]}),a.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),r.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:r.jsxs("table",{className:"w-full text-[12px]",children:[r.jsx("thead",{children:r.jsxs("tr",{style:{background:"var(--surface-2)"},children:[r.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),r.jsx("tbody",{children:t.caseDiffs.map(o=>r.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function dE({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?r.jsx(fE,{run:t,onClose:a}):r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),r.jsx("button",{onClick:a,className:"btn btn-ghost text-[11px]",children:"Close"})]}),r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Rn(t.totalCost)}`]}),r.jsx("div",{className:"space-y-2",children:t.cases.map(s=>r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),r.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&r.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(s.cost)}),r.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function fE({run:t,onClose:a}){var u;const s=m.useMemo(()=>t.improve?Zo(t.improve.original,t.improve.improved):[],[t.improve]),o=m.useMemo(()=>{const d=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:d,removed:h}},[s]),c=m.useMemo(()=>{let d=0,h=0;return s.map(g=>g.type==="removed"?(d++,{...g,origNum:d,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(d++,h++,{...g,origNum:d,newNum:h}))},[s]);return r.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),r.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),r.jsx("button",{onClick:a,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&r.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:c.map((d,h)=>r.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:d.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.origNum??""}),r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:d.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.newNum??""}),r.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"transparent",borderRight:d.type==="added"?"2px solid var(--green)":d.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:d.type==="added"?"+":d.type==="removed"?"-":" "}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"var(--text-secondary)"},children:d.content||"​"})]},h))})})})]})}function Ly({data:t}){if(t.length<2)return r.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const a=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=a.length,g=Math.min(...a),y=Math.max(...a)-g||1,v=a.map((k,E)=>{const C=c+E/(h-1)*u,N=c+d-(k-g)/y*d;return`${C.toFixed(1)},${N.toFixed(1)}`}),b=a[a.length-1],S=Ll(b);return r.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[r.jsx("polyline",{points:v.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,E]=v[v.length-1].split(",");return r.jsx("circle",{cx:k,cy:E,r:2.5,fill:S})})()]})}function pE(){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 mE({pct:t}){const a=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return r.jsxs("span",{className:"pill",style:{background:s,color:a,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function hE({score:t,rating:a}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[a]??s.minimal,c=t>=0?"+":"";return r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),r.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",a.toUpperCase(),")"]})]})}function xE({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 gE({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 vE(t){var o,c,u;if(t.length===0)return[];const a=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;a.has(g)||a.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const p=a.get(g);p.passRates.push(h.passRate.mean),p.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,p.lastDuration=h.duration.mean,p.lastCost=((c=h.cost)==null?void 0:c.total)??null,p.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(p.lastBaselinePassRate=h.baselinePassRate.mean,p.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,p.lastAmplificationPct=h.amplificationPct,p.hasBaseline=!0)}const s=[];for(const[d,h]of a){const[g,...p]=d.split("/");s.push({rank:0,model:p.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((d,h)=>{const g=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const zy=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function yE({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:zy(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(pE,{})]})}),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:Ll(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(Ly,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function bE({entries:t}){const a=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return a.length===0?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"text-center",children:r.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",r.jsx("code",{children:"--baseline"})," flag."]})})}):r.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>r.jsx("th",{style:zy(s==="#"?"center":"left"),children:s},s))})}),r.jsx("tbody",{children:a.map((s,o)=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[r.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Ll(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(mE,{pct:s.amplificationPct}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(Ly,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function jE(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=m.useState("rankings"),u=`leaderboard/${a}/${s}`,d=m.useCallback(()=>Ce.getLeaderboard(a,s),[a,s]),{data:h,loading:g}=ni(u,d),p=(h==null?void 0:h.entries)??[];m.useEffect(()=>{c("rankings")},[a,s]);const y=m.useCallback(()=>Tn(u),[u]);Ho("leaderboard:updated",y);const v=m.useMemo(()=>vE(p),[p]),b=v.some(E=>E.hasBaseline),S=p[0],k=S==null?void 0:S.judgeBiasWarning;return g?r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),r.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),r.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),r.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",r.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),r.jsx(gE,{active:o,onChange:c,hasBaseline:b})]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[p.length," sweep",p.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),k&&r.jsx(xE,{warning:k}),o==="rankings"?r.jsx(yE,{entries:v}):r.jsx(bE,{entries:v}),o==="amplification"&&(S==null?void 0:S.skillQualityScore)!=null&&(S==null?void 0:S.skillQualityRating)&&r.jsx(hE,{score:S.skillQualityScore,rating:S.skillQualityRating})]})}function SE({plugin:t,skill:a}){const[s,o]=m.useState([]),[c,u]=m.useState([]),[d,h]=m.useState(!0),[g,p]=m.useState(null);m.useEffect(()=>{Ce.getDependencies(t,a).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,a]);async function y(v,b){try{await navigator.clipboard.writeText(b),p(v),setTimeout(()=>p(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?r.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),r.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&r.jsxs("div",{className:"space-y-3 mb-4",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>r.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),r.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),r.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(b=>r.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:b},b))})]},v.server))]}),c.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),r.jsx("div",{className:"space-y-1.5",children:c.map(v=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function Yg({plugin:t,skill:a}){const[s,o]=m.useState([]),[c,u]=m.useState(!0),[d,h]=m.useState(null),[g,p]=m.useState(""),[y,v]=m.useState(!1),[b,S]=m.useState(null),[k,E]=m.useState(""),[C,N]=m.useState(""),[T,A]=m.useState(!1),[B,D]=m.useState(new Set),F=m.useCallback(async()=>{u(!0);try{const[U,H]=await Promise.all([Ce.getCredentials(t,a).catch(()=>({credentials:[]})),Ce.getParams(t,a).catch(()=>({params:[]}))]),q=new Map(H.params.map($=>[$.name,$])),X=new Set,J=[];for(const $ of U.credentials){X.add($.name);const L=q.get($.name);J.push({name:$.name,status:$.status==="ready"||$.status==="resolved"?"ready":"missing",source:$.source,maskedValue:L==null?void 0:L.maskedValue})}for(const $ of H.params)X.has($.name)||J.push({name:$.name,status:$.status,maskedValue:$.maskedValue});o(J)}finally{u(!1)}},[t,a]);m.useEffect(()=>{F()},[F]);const w=m.useCallback(async U=>{if(B.has(U)){D(H=>{const q=new Set(H);return q.delete(U),q}),o(H=>H.map(q=>q.name===U?{...q,revealedValue:void 0}:q));return}try{const q=(await Ce.getParamsRevealed(t,a,U)).params.find(X=>X.name===U);q&&(o(X=>X.map(J=>J.name===U?{...J,revealedValue:q.value}:J)),D(X=>new Set(X).add(U)))}catch{}},[t,a,B]),O=async(U,H)=>{if(!(!U.trim()||!H.trim())){v(!0),S(null);try{await Ce.setCredential(t,a,U,H),h(null),p(""),D(new Set),F()}catch(q){S(q.message)}finally{v(!1)}}},z=async()=>{if(!(!k.trim()||!C.trim())){v(!0),S(null);try{await Ce.setCredential(t,a,k.trim().toUpperCase(),C),E(""),N(""),A(!1),F()}catch(U){S(U.message)}finally{v(!1)}}};return c?r.jsxs("div",{className:"mt-6",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):r.jsxs("div",{className:"mt-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("button",{onClick:()=>A(!T),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&r.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b}),s.length===0&&!T?r.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):r.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(U=>r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:U.name}),U.maskedValue&&r.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:B.has(U.name)&&U.revealedValue!=null?U.revealedValue:U.maskedValue}),U.maskedValue&&r.jsx("button",{onClick:()=>w(U.name),className:"btn btn-ghost px-1",title:B.has(U.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:B.has(U.name)?r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),r.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),r.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:U.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:U.status==="ready"?"var(--green)":"var(--orange)"},children:U.status==="ready"?"ready":"missing"}),U.source&&r.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:U.source}),d===U.name?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("input",{value:g,onChange:H=>p(H.target.value),onKeyDown:H=>{H.key==="Enter"&&O(U.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),r.jsx("button",{onClick:()=>O(U.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),r.jsx("button",{onClick:()=>{h(null),p("")},className:"btn btn-ghost text-[10px] px-1",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):r.jsx("button",{onClick:()=>{h(U.name),p("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},U.name))}),T&&r.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:k,onChange:U=>E(U.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),r.jsx("input",{value:C,onChange:U=>N(U.target.value),onKeyDown:U=>{U.key==="Enter"&&z()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx("button",{onClick:()=>{A(!1),E(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),r.jsx("button",{onClick:z,disabled:y||!k.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function kE(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=m.useState(null),[u,d]=m.useState(!0);return m.useEffect(()=>{Ce.getDependencies(a,s).then(c).catch(()=>{}).finally(()=>d(!1))},[a,s]),u?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?r.jsxs("div",{className:"p-5 max-w-3xl",children:[r.jsx(SE,{plugin:a,skill:s}),r.jsx(Yg,{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(Yg,{plugin:a,skill:s})]})}function wE(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 CE(t){var c;const a=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,o=t.forceLayout===3;return{applyName:a?null:t.aiName??null,applySuggestedPlugin:!o&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:o||s?null:t.aiSuggestedPlugin??null}}function df(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function EE(t,a,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(a){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function NE({onCreated:t,resolveAiConfigOverride:a,forceLayout:s}){const[o,c]=m.useState("ai"),[u,d]=m.useState(null),[h,g]=m.useState(!0),{config:p}=Ha(),[y,v]=m.useState(""),[b,S]=m.useState(s??3),[k,E]=m.useState(""),[C,N]=m.useState(""),[T,A]=m.useState(""),[B,D]=m.useState(""),[F,w]=m.useState(""),[O,z]=m.useState(""),[U,H]=m.useState("write"),[q,X]=m.useState([]),[J,$]=m.useState(!1),[L,_]=m.useState(null),[I,V]=m.useState(null),[se,M]=m.useState("vskill"),[Y,G]=m.useState("1.0.0"),[te,fe]=m.useState(!0),ie=m.useCallback(async()=>{try{const xe=await Ce.detectEngines();V(xe),M(Ee=>Ee!=="vskill"?Ee:xe.vskillSkillBuilder?"vskill":xe.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{V({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);m.useEffect(()=>{ie()},[ie]);const[ye,de]=m.useState(""),[Se,Ae]=m.useState(!1),[_e,ae]=m.useState(!1),[he,pe]=m.useState(null),[ge,je]=m.useState(null),[Be,Oe]=m.useState([]),at=m.useRef(null),Nt=m.useRef(null),ht=m.useRef(null),Dt=m.useRef(null),Tt=m.useRef(null),[Qe,tt]=m.useState(!1),[be,pt]=m.useState(!1),Ct=m.useRef(y),Yt=m.useRef(k),un=m.useRef(C);m.useEffect(()=>{Ct.current=y},[y]),m.useEffect(()=>{Yt.current=k},[k]),m.useEffect(()=>{un.current=C},[C]),m.useEffect(()=>{Ce.getProjectLayout().then(xe=>{if(d(xe),s)return;S(xe.suggestedLayout);const Ee=xe.detectedLayouts.find(dn=>dn.layout===xe.suggestedLayout);Ee!=null&&Ee.existingPlugins.length&&E(Ee.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),m.useEffect(()=>{var xe;o==="ai"&&((xe=at.current)==null||xe.focus())},[o]),m.useEffect(()=>()=>{var xe;(xe=Nt.current)==null||xe.abort()},[]);const Gt=m.useMemo(()=>{var xe;return u?((xe=u.detectedLayouts.find(Ee=>Ee.layout===b))==null?void 0:xe.existingPlugins)||[]:[]},[u,b]),rn=k==="__new__"?C:k,Mn=u?EE(u.root,b,rn||"{plugin}",y||"{skill}"):"",Mt=m.useMemo(()=>u?u.detectedLayouts.filter(xe=>xe.layout!==4):[],[u]),xt=m.useMemo(()=>{if(!u)return null;const xe=u.detectedLayouts.find(fn=>fn.layout===2&&fn.existingPlugins.length>0),Ee=u.detectedLayouts.find(fn=>fn.layout===1&&fn.existingPlugins.length>0),dn=xe||Ee;return dn?{layout:dn.layout,plugins:dn.existingPlugins}:null},[u]),gt=m.useCallback(()=>{if(a)return a();if(!p)return{provider:"claude-cli",model:"sonnet"};const xe=p.provider||"claude-cli",Ee=p.model||"sonnet";return{provider:xe,model:Ee}},[p,a]),dr=m.useCallback(()=>{var xe;(xe=Nt.current)==null||xe.abort(),Ae(!1)},[]),zr=m.useCallback(()=>{pe(null),je(null)},[]),Wn=m.useCallback(async()=>{var fn,ai;if(pe(null),je(null),Oe([]),ht.current=null,Dt.current=null,!ye.trim()){pe("Describe what your skill should do");return}Ae(!0);const xe=new AbortController;Nt.current=xe;const{provider:Ee,model:dn}=gt();try{const qn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(wE({prompt:ye.trim(),provider:Ee,model:dn,targetAgents:q})),signal:xe.signal});if(!qn.ok||!qn.body){let pa=`HTTP ${qn.status}`;try{const ma=await qn.json();ma.error&&(pa=ma.error)}catch{}throw new Error(pa)}const Bl=qn.body.getReader(),fa=new TextDecoder;let Il="",tr="";for(;;){const{done:pa,value:ma}=await Bl.read();if(pa)break;Il+=fa.decode(ma,{stream:!0});const Pa=Il.split(`
86
- `);Il=Pa.pop()||"";for(const Dr of Pa)if(Dr.startsWith("event: "))tr=Dr.slice(7).trim();else if(Dr.startsWith("data: ")){try{const it=JSON.parse(Dr.slice(6));if(tr==="progress")Oe(ha=>[...ha,{phase:it.phase,message:it.message,timestamp:Date.now()}]);else if(tr==="provenance")Dt.current={resolvedModelId:typeof it.resolvedModelId=="string"?it.resolvedModelId:null,snapshotDate:typeof it.snapshotDate=="string"?it.snapshotDate:null};else if(tr==="done"||tr==="complete"){const ha={prompt:ye.trim(),provider:gt().provider,model:gt().model,resolvedModelId:((fn=Dt.current)==null?void 0:fn.resolvedModelId)??null,snapshotDate:((ai=Dt.current)==null?void 0:ai.snapshotDate)??null,reasoning:it.reasoning||""},an=CE({userName:Ct.current,userPlugin:Yt.current,userNewPlugin:un.current,aiName:it.name,aiSuggestedPlugin:it.suggestedPlugin&&it.suggestedPlugin.plugin?{plugin:it.suggestedPlugin.plugin,layout:it.suggestedPlugin.layout}:null,forceLayout:s});if(an.applyName!==null&&v(an.applyName),A(it.description),D(it.model||""),w(it.allowedTools||""),z(it.body),ae(!0),ht.current=ha,c("manual"),s===3)S(3),E(""),N("");else if(an.applySuggestedPlugin&&an.suggestedPluginValue){const ot=an.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(nr=>nr.existingPlugins))??[]).includes(ot.plugin))if(E(ot.plugin),ot.layout&&(ot.layout===1||ot.layout===2))S(ot.layout);else{const nr=u==null?void 0:u.detectedLayouts.find(ec=>ec.existingPlugins.includes(ot.plugin));nr&&(nr.layout===1||nr.layout===2)&&S(nr.layout)}else E("__new__"),N(ot.plugin)}else!an.applySuggestedPlugin&&Yt.current.trim().length===0&&un.current.trim().length===0&&b===3&&xt&&pt(!0);const Ht={name:it.name,plugin:rn||"",layout:b,description:it.description,model:it.model||void 0,allowedTools:it.allowedTools||void 0,body:it.body,aiMeta:ha};Ce.saveDraft(Ht).then(ot=>{tt(!0),ot!=null&&ot.dir&&(Tt.current=ot.dir)}).catch(()=>{})}else tr==="error"&&(pe(it.message||it.description||"Unknown error"),it.category&&je(it))}catch{}tr=""}}}catch(qn){qn.name!=="AbortError"&&pe(qn.message)}finally{Ae(!1),Nt.current=null}},[ye,gt,b,xt,rn,u,q,s]),Et=m.useCallback(async()=>{if(_(null),!y.trim()){_("Skill name is required");return}if(!T.trim()){_("Description is required");return}if(b!==3&&!rn.trim()){_("Plugin name is required");return}if(!te){_("Version is not valid semver");return}$(!0);try{const xe=await Ce.createSkill({name:df(y),plugin:rn||"",layout:b,description:T,model:B||void 0,allowedTools:F||void 0,body:O,aiMeta:ht.current||void 0,draftDir:Tt.current||void 0,version:Y.trim()||void 0,engine:se});Tt.current=null,t(xe.plugin,xe.skill)}catch(xe){_(xe.message)}finally{$(!1)}},[y,T,b,rn,B,F,O,Y,te,se,t]),oe=m.useCallback(()=>{xt&&(S(xt.layout),E(xt.plugins[0]),pt(!1))},[xt]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:S,creatableLayouts:Mt,availablePlugins:Gt,pathPreview:Mn,plugin:k,setPlugin:E,newPlugin:C,setNewPlugin:N,effectivePlugin:rn,name:y,setName:v,description:T,setDescription:A,model:B,setModel:D,allowedTools:F,setAllowedTools:w,body:O,setBody:z,bodyViewMode:U,setBodyViewMode:H,aiPrompt:ye,setAiPrompt:de,generating:Se,aiGenerated:_e,aiError:he,aiClassifiedError:ge,aiProgress:Be,promptRef:at,handleGenerate:Wn,handleCancelGenerate:dr,clearAiError:zr,targetAgents:q,setTargetAgents:X,draftSaved:Qe,showPluginRecommendation:be,setShowPluginRecommendation:pt,pluginLayoutInfo:xt,applyPluginRecommendation:oe,creating:J,error:L,handleCreate:Et,engineDetection:I,refreshEngineDetection:ie,engine:se,setEngine:M,version:Y,setVersion:G,versionValid:te,setVersionValid:fe,standaloneLocked:s===3}}function Dy(){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 TE(){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 _y({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(Dy,{}):r.jsx(TE,{}),r.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>r.jsx(_y,{node:o,depth:a+1},o.name))]})}function RE(t,a,s){const o=[];a&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function AE({skillName:t,hasEvals:a,isDraft:s}){const o=RE(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(Dy,{})}),"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(_y,{node:o})})]})}const la={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Id({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 ME({onCreated:t,onCancel:a}){const s=NE({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(Id,{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(Id,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),r.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
85
+ !Write me a poem about flowers`}),r.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsx("span",{children:"One prompt per line"}),r.jsx(ko,{}),r.jsx("span",{children:"No prefix = auto-classify"}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),r.jsx(ko,{}),r.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[H," prompt",H!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:z,disabled:y||!A.trim(),className:"btn btn-primary",children:y?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("circle",{cx:"12",cy:"12",r:"6"}),r.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[S||`${g.length} / ${H} prompts tested`,b&&r.jsx(QC,{startedAt:b})]})]})]})]}),r.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[r.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:J?r.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:L}}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&r.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[r.jsx("div",{className:"spinner-lg mx-auto mb-4"}),r.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&r.jsxs("div",{className:"space-y-5",children:[X.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),r.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",X.length,")"]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((I,V)=>r.jsx(Gg,{result:I},`incorrect-${V}`))})]}),q.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("polyline",{points:"16 10 11 15 8 12"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",q.length,")"]})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:q.map((I,V)=>r.jsx(Gg,{result:I},`correct-${V}`))})]})]}),m&&r.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),m.autoClassifiedCount!=null&&m.autoClassifiedCount>0&&r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[m.autoClassifiedCount," of ",m.total," prompts auto-classified from skill name and tags"]}),r.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[r.jsx(_d,{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(_d,{label:"Recall",value:m.recall,description:"Of expected activations, how many fired?",detail:`${m.tp} activated / ${m.tp+m.fn} expected`}),r.jsx(_d,{label:"Reliability",value:m.reliability,description:"Overall correct classification rate",detail:`${m.tp+m.tn} correct / ${m.total} total`})]}),r.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[r.jsx(wo,{label:"True Positive",abbr:"TP",count:m.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),r.jsx(wo,{label:"False Positive",abbr:"FP",count:m.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),r.jsx(wo,{label:"False Negative",abbr:"FN",count:m.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),r.jsx(wo,{label:"True Negative",abbr:"TN",count:m.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),r.jsx(YC,{history:C,expanded:w,onToggle:()=>O(!w),skillVersion:T})]})}function YC({history:t,expanded:a,onToggle:s,skillVersion:o}){return t===null?null:r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:a?"1px solid var(--border-subtle)":"none"},onClick:s,children:[r.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&r.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&r.jsx("div",{className:"px-4 py-3",children:t.length===0?r.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):r.jsx("div",{className:"space-y-2",children:t.map(c=>r.jsx(KC,{run:c,skillVersion:o},c.id))})})]})}function KC({run:t,skillVersion:a}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:XC(t.timestamp)}),r.jsx(ni,{version:a??null,size:"sm","data-testid":"activation-row-version"}),r.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),r.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),r.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function XC(t){const a=Date.now(),s=new Date(t).getTime(),o=Math.floor((a-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<7?`${d}d ago`:new Date(t).toLocaleDateString()}function ko(){return r.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function Gg({result:t}){const a=Fg[t.classification]||Fg.FN,s=t.classification==="TP"||t.classification==="TN";return r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:a.bg,border:"1px solid transparent"},children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${a.text} 20%, transparent)`},children:s?r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),r.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[r.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:a.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),r.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&r.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&r.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function _d({label:t,value:a,description:s,detail:o}){const c=Math.round(a*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return r.jsxs("div",{className:"text-center",children:[r.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),r.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),r.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),r.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function wo({abbr:t,count:a,bg:s,color:o,description:c}){return r.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[r.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:a}),r.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),r.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function QC({startedAt:t}){const[a,s]=p.useState(0);return p.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),r.jsxs("span",{className:"ml-2",children:["(",a,"s)"]})}const Od={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},Wg={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},cf=600,uf=180,cn=40,Bd=cf-cn*2,aa=uf-cn*2,ZC=[25,50,75,100];function qg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function JC(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function eE({entries:t,onPointClick:a}){const[s,o]=p.useState(null),c=p.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((m,y)=>{const v=cn+y/(u-1)*Bd,b=m.passRate*100,S=cn+aa-b/100*aa;return{x:v,y:S,pct:b,entry:m}}),h=d.map(m=>`${m.x},${m.y}`).join(" "),g=Array.from(new Set(c.map(m=>m.type)));return r.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[r.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),r.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(m=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Od[m]??"var(--text-tertiary)"}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:Wg[m]??m})]},m))}),r.jsxs("svg",{width:cf,height:uf,viewBox:`0 0 ${cf} ${uf}`,style:{display:"block",overflow:"visible"},children:[ZC.map(m=>{const y=cn+aa-m/100*aa;return r.jsxs("g",{children:[r.jsx("line",{x1:cn,y1:y,x2:cn+Bd,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),r.jsxs("text",{x:cn-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[m,"%"]})]},m)}),r.jsx("line",{x1:cn,y1:cn+aa,x2:cn+Bd,y2:cn+aa,stroke:"var(--border-subtle)",strokeWidth:1}),r.jsx("text",{x:cn-8,y:cn+aa+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),r.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((m,y)=>r.jsx("circle",{cx:m.x,cy:m.y,r:5,fill:Od[m.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:m.x,y:m.y,entry:m.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>a==null?void 0:a(m.entry)},y)),tE(u).map(m=>r.jsx("text",{x:d[m].x,y:cn+aa+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:qg(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:qg(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:Od[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:Wg[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:JC(s.entry.totalDurationMs)}),r.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function tE(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const a=Math.ceil(t/10),s=[0];for(let o=a;o<t-1;o+=a)s.push(o);return s.push(t-1),s}const Is=new Map;let un=null,Do=null,Co=1e3,Al=0;function My(){if(un)return;un=new EventSource("/api/events");const t=a=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=Is.get(a);if(c)for(const u of c)u(o)};un.addEventListener("benchmark:complete",t("benchmark:complete")),un.addEventListener("history:written",t("history:written")),un.addEventListener("leaderboard:updated",t("leaderboard:updated")),un.onerror=()=>{un==null||un.close(),un=null,Al>0&&(Do=setTimeout(()=>{Co=Math.min(Co*2,3e4),My()},Co))},un.onopen=()=>{Co=1e3}}function nE(){Do!=null&&(clearTimeout(Do),Do=null),un==null||un.close(),un=null}function rE(t,a){return Is.has(t)||Is.set(t,new Set),Is.get(t).add(a),Al++,My(),()=>{var s;(s=Is.get(t))==null||s.delete(a),Al--,Al<=0&&(Al=0,queueMicrotask(()=>{Al<=0&&nE()}))}}function Ho(t,a){const s=p.useRef(a);s.current=a,p.useEffect(()=>rE(t,c=>s.current(c)),[t])}function $o(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function aE(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function lE({rate:t,label:a}){const s=Math.round(t*100);return r.jsx("div",{className:"flex items-center gap-3",children:r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:a}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:$o(t)},children:[s,"%"]})]}),r.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:$o(t)}})})]})})}function sE({points:t}){if(t.length<2)return null;const a=200,s=48,o=4,c=t.length,u=t.map((g,m)=>{const y=o+m/(c-1)*(a-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,m)=>`${m===0?"M":"L"} ${g.x},${g.y}`).join(" ");return r.jsxs("svg",{width:a,height:s,style:{display:"block"},children:[r.jsx("path",{d,fill:"var(--accent-muted)"}),r.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function iE({plugin:t,skill:a}){const s=`stats/${t}/${a}`,o=p.useCallback(()=>Ce.getStats(t,a),[t,a]),{data:c,loading:u}=ri(s,o),d=p.useCallback(()=>Tn(s),[s]);if(Ho("benchmark:complete",d),Ho("history:written",d),u)return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"skeleton h-24 rounded-xl"}),r.jsx("div",{className:"skeleton h-48 rounded-xl"}),r.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),r.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,m=h-g,y=c.assertionStats.slice(0,10);return r.jsxs("div",{className:"space-y-4 stagger-children",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:$o(h)},children:[Math.round(h*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:m>=0?"var(--green)":"var(--red)"},children:[m>=0?"+":"",Math.round(m*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.totalCost)})]}),c.costPerRun!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),r.jsx(sE,{points:c.trendPoints})]}),c.modelStats.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),r.jsx("tbody",{children:c.modelStats.map(v=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),r.jsx("td",{style:{padding:"8px",textAlign:"center"},children:r.jsxs("span",{className:"font-semibold",style:{color:$o(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:aE(v.avgDurationMs)}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Rn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),r.jsx("div",{className:"space-y-3",children:y.map(v=>r.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-2)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),r.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),r.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),r.jsx(lE,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function oE({plugin:t,skill:a}){const[s,o]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState({}),[g,m]=p.useState({});p.useEffect(()=>{Ce.getEvals(t,a).then(o).catch(()=>o(null))},[t,a]);async function y(v){if(c===v){u(null);return}if(u(v),!d[v]){m(b=>({...b,[v]:!0}));try{const b=await Ce.getCaseHistory(t,a,v);h(S=>({...S,[v]:b}))}catch{h(b=>({...b,[v]:[]}))}finally{m(b=>({...b,[v]:!1}))}}}return s?r.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const b=d[v.id]||[],S=c===v.id,k=g[v.id],E=b.length>0?b[0].pass_rate:null;return r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:S?"var(--surface-2)":"transparent"},onMouseEnter:C=>{S||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{S||(C.currentTarget.style.background="transparent")},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:S?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),r.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),r.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),b.length>=2&&r.jsx(Ey,{entries:b}),E!=null&&r.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Dl(E)},children:[Math.round(E*100),"%"]}),b.length>0&&r.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),S&&r.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?r.jsxs("div",{className:"p-4 flex items-center gap-2",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?r.jsx("div",{className:"p-4",children:r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):r.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,N)=>r.jsxs("div",{className:"p-4",style:{background:N===0?"var(--surface-2)":"transparent"},children:[r.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:wy(C.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Dl(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&r.jsx("span",{children:Cy(C.durationMs)}),C.tokens!=null&&r.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),r.jsx("div",{className:"space-y-1",children:C.assertions.map(T=>r.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[r.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:T.pass?"var(--green)":"var(--red)"},children:r.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:T.pass?r.jsx("polyline",{points:"20 6 9 17 4 12"}):r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:T.text}),T.reasoning&&r.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:T.reasoning})]})]},T.id))})]},N))})})]},v.id)})}):r.jsx("div",{className:"text-center py-12",children:r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function cE(){const{state:t,dispatch:a}=An(),{plugin:s,skill:o}=t,{state:c}=er(),u=c.skills.find(I=>I.plugin===s&&I.skill===o),d=(u==null?void 0:u.version)??null,[h,g]=p.useState("timeline"),[m,y]=p.useState(""),[v,b]=p.useState(""),[S,k]=p.useState(!1),[E,C]=p.useState([]),[N,T]=p.useState(null),[A,B]=p.useState(!1),[D,F]=p.useState(null),[w,O]=p.useState(!1),z=`history/${s}/${o}?model=${m}&type=${v}`,U=p.useCallback(()=>Ce.getHistory(s,o,{model:m||void 0,type:v||void 0}),[s,o,m,v]),{data:H,loading:q}=ri(z,U),X=H??[];p.useEffect(()=>{!H||H.length<2||Ce.compareRuns(s,o,H[0].timestamp,H[1].timestamp).then(I=>{const V=I.regressions.filter(ie=>ie.change==="regression");a({type:"SET_REGRESSIONS",regressions:V})}).catch(()=>{})},[H,s,o,a]);const J=p.useCallback(()=>Tn(z),[z]);Ho("history:written",J);const $=p.useCallback(async I=>{if(S){C(V=>V.includes(I)?V.filter(ie=>ie!==I):V.length>=2?[V[1],I]:[...V,I]);return}O(!0);try{const V=await Ce.getHistoryEntry(s,o,I);F(V)}catch{}finally{O(!1)}},[s,o,S]),L=p.useCallback(async()=>{if(E.length===2){B(!0);try{const I=await Ce.compareRuns(s,o,E[0],E[1]);T(I)}catch{}finally{B(!1)}}},[s,o,E]),_=[...new Set(X.map(I=>I.model))];return q?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"skeleton h-12 rounded-lg"}),r.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(I=>r.jsx("button",{onClick:()=>g(I),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===I?"var(--accent-muted)":"transparent",color:h===I?"var(--accent)":"var(--text-tertiary)"},children:I==="timeline"?"Timeline":I==="per-eval"?"Per Eval":"Statistics"},I))}),h==="timeline"&&r.jsxs("div",{children:[X.length>0&&r.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:r.jsx(eE,{entries:X,onPointClick:I=>$(I.timestamp)})}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("select",{value:m,onChange:I=>y(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Models"}),_.map(I=>r.jsx("option",{value:I,children:I},I))]}),r.jsxs("select",{value:v,onChange:I=>b(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Types"}),r.jsx("option",{value:"benchmark",children:"Benchmark"}),r.jsx("option",{value:"comparison",children:"Comparison"}),r.jsx("option",{value:"baseline",children:"Baseline"}),r.jsx("option",{value:"model-compare",children:"Model Compare"}),r.jsx("option",{value:"improve",children:"AI Improve"}),r.jsx("option",{value:"instruct",children:"AI Edit"}),r.jsx("option",{value:"ai-generate",children:"AI Generate"}),r.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:()=>{k(!S),C([]),T(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&E.length===2&&r.jsx("button",{onClick:L,disabled:A,className:"btn btn-primary text-[12px]",children:A?"Comparing...":"Compare"})]}),r.jsx("div",{className:"space-y-2",children:X.length===0?r.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(I=>{const V=E.includes(I.timestamp);return r.jsx("button",{onClick:()=>$(I.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:V?"var(--accent-muted)":"var(--surface-1)",border:V?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:ie=>{V||(ie.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:ie=>{V||(ie.currentTarget.style.borderColor="var(--border-subtle)")},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:V?"var(--accent)":"var(--border-default)",background:V?"var(--accent)":"transparent"},children:V&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(I.timestamp).toLocaleString()}),r.jsx("span",{className:"pill text-[9px]",style:{background:I.type==="comparison"?"var(--purple-muted)":I.type==="baseline"?"var(--surface-3)":I.type==="model-compare"?"var(--accent-muted)":I.type==="improve"||I.type==="instruct"?"var(--purple-muted)":I.type==="ai-generate"?"var(--green-muted)":I.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:I.type==="comparison"?"var(--purple)":I.type==="baseline"?"var(--text-tertiary)":I.type==="model-compare"?"var(--accent)":I.type==="improve"||I.type==="instruct"?"var(--purple)":I.type==="ai-generate"?"var(--green)":I.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:I.type==="model-compare"?"model compare":I.type==="improve"?"ai improve":I.type==="instruct"?"ai edit":I.type==="ai-generate"?"ai generate":I.type==="eval-generate"?"eval generate":I.type})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ni,{version:d,size:"sm","data-testid":"history-row-version"}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:I.model}),I.totalCost!=null&&I.totalCost>0&&r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(I.totalCost)}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:I.passRate>=.8?"var(--green)":I.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(I.passRate*100),"%"]})]})]})},I.timestamp)})}),N&&r.jsx(uE,{result:N}),D&&!S&&r.jsx(dE,{run:D,onClose:()=>F(null)})]}),h==="per-eval"&&r.jsx(oE,{plugin:s,skill:o}),h==="statistics"&&r.jsx(iE,{plugin:s,skill:o})]})}function uE({result:t}){const a=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&r.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[r.jsxs("span",{children:["Run A cost: ",Rn(t.runA.totalCost??null)]}),r.jsxs("span",{children:["Run B cost: ",Rn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&r.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Rn(t.runB.totalCost-t.runA.totalCost)]})]}),a.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",a.length,")"]}),a.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),r.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:r.jsxs("table",{className:"w-full text-[12px]",children:[r.jsx("thead",{children:r.jsxs("tr",{style:{background:"var(--surface-2)"},children:[r.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),r.jsx("tbody",{children:t.caseDiffs.map(o=>r.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function dE({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?r.jsx(fE,{run:t,onClose:a}):r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),r.jsx("button",{onClick:a,className:"btn btn-ghost text-[11px]",children:"Close"})]}),r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Rn(t.totalCost)}`]}),r.jsx("div",{className:"space-y-2",children:t.cases.map(s=>r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),r.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&r.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(s.cost)}),r.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function fE({run:t,onClose:a}){var u;const s=p.useMemo(()=>t.improve?Zo(t.improve.original,t.improve.improved):[],[t.improve]),o=p.useMemo(()=>{const d=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:d,removed:h}},[s]),c=p.useMemo(()=>{let d=0,h=0;return s.map(g=>g.type==="removed"?(d++,{...g,origNum:d,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(d++,h++,{...g,origNum:d,newNum:h}))},[s]);return r.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),r.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),r.jsx("button",{onClick:a,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&r.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:c.map((d,h)=>r.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:d.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.origNum??""}),r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:d.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.newNum??""}),r.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"transparent",borderRight:d.type==="added"?"2px solid var(--green)":d.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:d.type==="added"?"+":d.type==="removed"?"-":" "}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"var(--text-secondary)"},children:d.content||"​"})]},h))})})})]})}function Ly({data:t}){if(t.length<2)return r.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const a=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=a.length,g=Math.min(...a),y=Math.max(...a)-g||1,v=a.map((k,E)=>{const C=c+E/(h-1)*u,N=c+d-(k-g)/y*d;return`${C.toFixed(1)},${N.toFixed(1)}`}),b=a[a.length-1],S=Dl(b);return r.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[r.jsx("polyline",{points:v.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,E]=v[v.length-1].split(",");return r.jsx("circle",{cx:k,cy:E,r:2.5,fill:S})})()]})}function pE(){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 mE({pct:t}){const a=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return r.jsxs("span",{className:"pill",style:{background:s,color:a,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function hE({score:t,rating:a}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[a]??s.minimal,c=t>=0?"+":"";return r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),r.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",a.toUpperCase(),")"]})]})}function xE({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 gE({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 vE(t){var o,c,u;if(t.length===0)return[];const a=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;a.has(g)||a.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const m=a.get(g);m.passRates.push(h.passRate.mean),m.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,m.lastDuration=h.duration.mean,m.lastCost=((c=h.cost)==null?void 0:c.total)??null,m.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(m.lastBaselinePassRate=h.baselinePassRate.mean,m.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,m.lastAmplificationPct=h.amplificationPct,m.hasBaseline=!0)}const s=[];for(const[d,h]of a){const[g,...m]=d.split("/");s.push({rank:0,model:m.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((d,h)=>{const g=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const zy=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function yE({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:zy(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(pE,{})]})}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("span",{className:"pill",style:{background:a.passRate>=.7?"var(--green-muted)":a.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Dl(a.passRate),fontSize:11,fontWeight:600},children:[Math.round(a.passRate*100),"%"]})}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.rubricScore!=null?a.rubricScore.toFixed(1):"--"}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.duration<1e3?`${Math.round(a.duration)}ms`:`${(a.duration/1e3).toFixed(1)}s`}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.cost!=null?`$${a.cost.toFixed(4)}`:"N/A"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(Ly,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function bE({entries:t}){const a=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return a.length===0?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"text-center",children:r.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",r.jsx("code",{children:"--baseline"})," flag."]})})}):r.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>r.jsx("th",{style:zy(s==="#"?"center":"left"),children:s},s))})}),r.jsx("tbody",{children:a.map((s,o)=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[r.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Dl(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),r.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?r.jsxs("span",{className:"text-[11px] font-medium",style:{color:s.skillDelta>=0?"var(--green)":"var(--red)"},children:[s.skillDelta>=0?"+":"",(s.skillDelta*100).toFixed(1),"pp"]}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?r.jsx(mE,{pct:s.amplificationPct}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(Ly,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function jE(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=p.useState("rankings"),u=`leaderboard/${a}/${s}`,d=p.useCallback(()=>Ce.getLeaderboard(a,s),[a,s]),{data:h,loading:g}=ri(u,d),m=(h==null?void 0:h.entries)??[];p.useEffect(()=>{c("rankings")},[a,s]);const y=p.useCallback(()=>Tn(u),[u]);Ho("leaderboard:updated",y);const v=p.useMemo(()=>vE(m),[m]),b=v.some(E=>E.hasBaseline),S=m[0],k=S==null?void 0:S.judgeBiasWarning;return g?r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),r.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),r.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),r.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",r.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),r.jsx(gE,{active:o,onChange:c,hasBaseline:b})]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[m.length," sweep",m.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),k&&r.jsx(xE,{warning:k}),o==="rankings"?r.jsx(yE,{entries:v}):r.jsx(bE,{entries:v}),o==="amplification"&&(S==null?void 0:S.skillQualityScore)!=null&&(S==null?void 0:S.skillQualityRating)&&r.jsx(hE,{score:S.skillQualityScore,rating:S.skillQualityRating})]})}function SE({plugin:t,skill:a}){const[s,o]=p.useState([]),[c,u]=p.useState([]),[d,h]=p.useState(!0),[g,m]=p.useState(null);p.useEffect(()=>{Ce.getDependencies(t,a).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,a]);async function y(v,b){try{await navigator.clipboard.writeText(b),m(v),setTimeout(()=>m(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?r.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),r.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&r.jsxs("div",{className:"space-y-3 mb-4",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>r.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),r.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),r.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(b=>r.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:b},b))})]},v.server))]}),c.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),r.jsx("div",{className:"space-y-1.5",children:c.map(v=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function Yg({plugin:t,skill:a}){const[s,o]=p.useState([]),[c,u]=p.useState(!0),[d,h]=p.useState(null),[g,m]=p.useState(""),[y,v]=p.useState(!1),[b,S]=p.useState(null),[k,E]=p.useState(""),[C,N]=p.useState(""),[T,A]=p.useState(!1),[B,D]=p.useState(new Set),F=p.useCallback(async()=>{u(!0);try{const[U,H]=await Promise.all([Ce.getCredentials(t,a).catch(()=>({credentials:[]})),Ce.getParams(t,a).catch(()=>({params:[]}))]),q=new Map(H.params.map($=>[$.name,$])),X=new Set,J=[];for(const $ of U.credentials){X.add($.name);const L=q.get($.name);J.push({name:$.name,status:$.status==="ready"||$.status==="resolved"?"ready":"missing",source:$.source,maskedValue:L==null?void 0:L.maskedValue})}for(const $ of H.params)X.has($.name)||J.push({name:$.name,status:$.status,maskedValue:$.maskedValue});o(J)}finally{u(!1)}},[t,a]);p.useEffect(()=>{F()},[F]);const w=p.useCallback(async U=>{if(B.has(U)){D(H=>{const q=new Set(H);return q.delete(U),q}),o(H=>H.map(q=>q.name===U?{...q,revealedValue:void 0}:q));return}try{const q=(await Ce.getParamsRevealed(t,a,U)).params.find(X=>X.name===U);q&&(o(X=>X.map(J=>J.name===U?{...J,revealedValue:q.value}:J)),D(X=>new Set(X).add(U)))}catch{}},[t,a,B]),O=async(U,H)=>{if(!(!U.trim()||!H.trim())){v(!0),S(null);try{await Ce.setCredential(t,a,U,H),h(null),m(""),D(new Set),F()}catch(q){S(q.message)}finally{v(!1)}}},z=async()=>{if(!(!k.trim()||!C.trim())){v(!0),S(null);try{await Ce.setCredential(t,a,k.trim().toUpperCase(),C),E(""),N(""),A(!1),F()}catch(U){S(U.message)}finally{v(!1)}}};return c?r.jsxs("div",{className:"mt-6",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):r.jsxs("div",{className:"mt-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("button",{onClick:()=>A(!T),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&r.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b}),s.length===0&&!T?r.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):r.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(U=>r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:U.name}),U.maskedValue&&r.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:B.has(U.name)&&U.revealedValue!=null?U.revealedValue:U.maskedValue}),U.maskedValue&&r.jsx("button",{onClick:()=>w(U.name),className:"btn btn-ghost px-1",title:B.has(U.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:B.has(U.name)?r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),r.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),r.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:U.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:U.status==="ready"?"var(--green)":"var(--orange)"},children:U.status==="ready"?"ready":"missing"}),U.source&&r.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:U.source}),d===U.name?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("input",{value:g,onChange:H=>m(H.target.value),onKeyDown:H=>{H.key==="Enter"&&O(U.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),r.jsx("button",{onClick:()=>O(U.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),r.jsx("button",{onClick:()=>{h(null),m("")},className:"btn btn-ghost text-[10px] px-1",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):r.jsx("button",{onClick:()=>{h(U.name),m("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},U.name))}),T&&r.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:k,onChange:U=>E(U.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),r.jsx("input",{value:C,onChange:U=>N(U.target.value),onKeyDown:U=>{U.key==="Enter"&&z()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx("button",{onClick:()=>{A(!1),E(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),r.jsx("button",{onClick:z,disabled:y||!k.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function kE(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=p.useState(null),[u,d]=p.useState(!0);return p.useEffect(()=>{Ce.getDependencies(a,s).then(c).catch(()=>{}).finally(()=>d(!1))},[a,s]),u?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?r.jsxs("div",{className:"p-5 max-w-3xl",children:[r.jsx(SE,{plugin:a,skill:s}),r.jsx(Yg,{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(Yg,{plugin:a,skill:s})]})}function wE(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 CE(t){var c;const a=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,o=t.forceLayout===3;return{applyName:a?null:t.aiName??null,applySuggestedPlugin:!o&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:o||s?null:t.aiSuggestedPlugin??null}}function df(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function EE(t,a,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(a){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function NE({onCreated:t,resolveAiConfigOverride:a,forceLayout:s}){const[o,c]=p.useState("ai"),[u,d]=p.useState(null),[h,g]=p.useState(!0),{config:m}=$a(),[y,v]=p.useState(""),[b,S]=p.useState(s??3),[k,E]=p.useState(""),[C,N]=p.useState(""),[T,A]=p.useState(""),[B,D]=p.useState(""),[F,w]=p.useState(""),[O,z]=p.useState(""),[U,H]=p.useState("write"),[q,X]=p.useState([]),[J,$]=p.useState(!1),[L,_]=p.useState(null),[I,V]=p.useState(null),[ie,M]=p.useState("vskill"),[Y,G]=p.useState("1.0.0"),[te,fe]=p.useState(!0),oe=p.useCallback(async()=>{try{const Ie=await Ce.detectEngines();V(Ie),M(le=>le!=="vskill"?le:Ie.vskillSkillBuilder?"vskill":Ie.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{V({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);p.useEffect(()=>{oe()},[oe]);const[ve,de]=p.useState(""),[je,Re]=p.useState(!1),[_e,ae]=p.useState(!1),[he,pe]=p.useState(null),[xe,be]=p.useState(null),[Be,Oe]=p.useState([]),lt=p.useRef(null),Nt=p.useRef(null),xt=p.useRef(null),_t=p.useRef(null),Tt=p.useRef(null),[Ze,nt]=p.useState(!1),[ye,mt]=p.useState(!1),Et=p.useRef(y),Xt=p.useRef(k),fn=p.useRef(C);p.useEffect(()=>{Et.current=y},[y]),p.useEffect(()=>{Xt.current=k},[k]),p.useEffect(()=>{fn.current=C},[C]),p.useEffect(()=>{Ce.getProjectLayout().then(Ie=>{if(d(Ie),s)return;S(Ie.suggestedLayout);const le=Ie.detectedLayouts.find(Se=>Se.layout===Ie.suggestedLayout);le!=null&&le.existingPlugins.length&&E(le.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),p.useEffect(()=>{var Ie;o==="ai"&&((Ie=lt.current)==null||Ie.focus())},[o]),p.useEffect(()=>()=>{var Ie;(Ie=Nt.current)==null||Ie.abort()},[]);const Wt=p.useMemo(()=>{var Ie;return u?((Ie=u.detectedLayouts.find(le=>le.layout===b))==null?void 0:Ie.existingPlugins)||[]:[]},[u,b]),ln=k==="__new__"?C:k,Mn=u?EE(u.root,b,ln||"{plugin}",y||"{skill}"):"",Lt=p.useMemo(()=>u?u.detectedLayouts.filter(Ie=>Ie.layout!==4):[],[u]),vt=p.useMemo(()=>{if(!u)return null;const Ie=u.detectedLayouts.find(Me=>Me.layout===2&&Me.existingPlugins.length>0),le=u.detectedLayouts.find(Me=>Me.layout===1&&Me.existingPlugins.length>0),Se=Ie||le;return Se?{layout:Se.layout,plugins:Se.existingPlugins}:null},[u]),gt=p.useCallback(()=>{if(a)return a();if(!m)return{provider:"claude-cli",model:"sonnet"};const Ie=m.provider||"claude-cli",le=m.model||"sonnet";return{provider:Ie,model:le}},[m,a]),Wn=p.useCallback(()=>{var Ie;(Ie=Nt.current)==null||Ie.abort(),Re(!1)},[]),zr=p.useCallback(()=>{pe(null),be(null)},[]),dr=p.useCallback(async()=>{var Me,Fa;if(pe(null),be(null),Oe([]),xt.current=null,_t.current=null,!ve.trim()){pe("Describe what your skill should do");return}Re(!0);const Ie=new AbortController;Nt.current=Ie;const{provider:le,model:Se}=gt();try{const qn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(wE({prompt:ve.trim(),provider:le,model:Se,targetAgents:q})),signal:Ie.signal});if(!qn.ok||!qn.body){let pa=`HTTP ${qn.status}`;try{const ma=await qn.json();ma.error&&(pa=ma.error)}catch{}throw new Error(pa)}const Ul=qn.body.getReader(),fa=new TextDecoder;let Hl="",tr="";for(;;){const{done:pa,value:ma}=await Ul.read();if(pa)break;Hl+=fa.decode(ma,{stream:!0});const Ga=Hl.split(`
86
+ `);Hl=Ga.pop()||"";for(const Dr of Ga)if(Dr.startsWith("event: "))tr=Dr.slice(7).trim();else if(Dr.startsWith("data: ")){try{const ot=JSON.parse(Dr.slice(6));if(tr==="progress")Oe(ha=>[...ha,{phase:ot.phase,message:ot.message,timestamp:Date.now()}]);else if(tr==="provenance")_t.current={resolvedModelId:typeof ot.resolvedModelId=="string"?ot.resolvedModelId:null,snapshotDate:typeof ot.snapshotDate=="string"?ot.snapshotDate:null};else if(tr==="done"||tr==="complete"){const ha={prompt:ve.trim(),provider:gt().provider,model:gt().model,resolvedModelId:((Me=_t.current)==null?void 0:Me.resolvedModelId)??null,snapshotDate:((Fa=_t.current)==null?void 0:Fa.snapshotDate)??null,reasoning:ot.reasoning||""},sn=CE({userName:Et.current,userPlugin:Xt.current,userNewPlugin:fn.current,aiName:ot.name,aiSuggestedPlugin:ot.suggestedPlugin&&ot.suggestedPlugin.plugin?{plugin:ot.suggestedPlugin.plugin,layout:ot.suggestedPlugin.layout}:null,forceLayout:s});if(sn.applyName!==null&&v(sn.applyName),A(ot.description),D(ot.model||""),w(ot.allowedTools||""),z(ot.body),ae(!0),xt.current=ha,c("manual"),s===3)S(3),E(""),N("");else if(sn.applySuggestedPlugin&&sn.suggestedPluginValue){const ct=sn.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(nr=>nr.existingPlugins))??[]).includes(ct.plugin))if(E(ct.plugin),ct.layout&&(ct.layout===1||ct.layout===2))S(ct.layout);else{const nr=u==null?void 0:u.detectedLayouts.find(ec=>ec.existingPlugins.includes(ct.plugin));nr&&(nr.layout===1||nr.layout===2)&&S(nr.layout)}else E("__new__"),N(ct.plugin)}else!sn.applySuggestedPlugin&&Xt.current.trim().length===0&&fn.current.trim().length===0&&b===3&&vt&&mt(!0);const $t={name:ot.name,plugin:ln||"",layout:b,description:ot.description,model:ot.model||void 0,allowedTools:ot.allowedTools||void 0,body:ot.body,aiMeta:ha};Ce.saveDraft($t).then(ct=>{nt(!0),ct!=null&&ct.dir&&(Tt.current=ct.dir)}).catch(()=>{})}else tr==="error"&&(pe(ot.message||ot.description||"Unknown error"),ot.category&&be(ot))}catch{}tr=""}}}catch(qn){qn.name!=="AbortError"&&pe(qn.message)}finally{Re(!1),Nt.current=null}},[ve,gt,b,vt,ln,u,q,s]),Rt=p.useCallback(async()=>{if(_(null),!y.trim()){_("Skill name is required");return}if(!T.trim()){_("Description is required");return}if(b!==3&&!ln.trim()){_("Plugin name is required");return}if(!te){_("Version is not valid semver");return}$(!0);try{const Ie=await Ce.createSkill({name:df(y),plugin:ln||"",layout:b,description:T,model:B||void 0,allowedTools:F||void 0,body:O,aiMeta:xt.current||void 0,draftDir:Tt.current||void 0,version:Y.trim()||void 0,engine:ie});Tt.current=null,t(Ie.plugin,Ie.skill)}catch(Ie){_(Ie.message)}finally{$(!1)}},[y,T,b,ln,B,F,O,Y,te,ie,t]),qt=p.useCallback(()=>{vt&&(S(vt.layout),E(vt.plugins[0]),mt(!1))},[vt]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:S,creatableLayouts:Lt,availablePlugins:Wt,pathPreview:Mn,plugin:k,setPlugin:E,newPlugin:C,setNewPlugin:N,effectivePlugin:ln,name:y,setName:v,description:T,setDescription:A,model:B,setModel:D,allowedTools:F,setAllowedTools:w,body:O,setBody:z,bodyViewMode:U,setBodyViewMode:H,aiPrompt:ve,setAiPrompt:de,generating:je,aiGenerated:_e,aiError:he,aiClassifiedError:xe,aiProgress:Be,promptRef:lt,handleGenerate:dr,handleCancelGenerate:Wn,clearAiError:zr,targetAgents:q,setTargetAgents:X,draftSaved:Ze,showPluginRecommendation:ye,setShowPluginRecommendation:mt,pluginLayoutInfo:vt,applyPluginRecommendation:qt,creating:J,error:L,handleCreate:Rt,engineDetection:I,refreshEngineDetection:oe,engine:ie,setEngine:M,version:Y,setVersion:G,versionValid:te,setVersionValid:fe,standaloneLocked:s===3}}function Dy(){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 TE(){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 _y({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(Dy,{}):r.jsx(TE,{}),r.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>r.jsx(_y,{node:o,depth:a+1},o.name))]})}function RE(t,a,s){const o=[];a&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function AE({skillName:t,hasEvals:a,isDraft:s}){const o=RE(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(Dy,{})}),"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(_y,{node:o})})]})}const la={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Id({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 ME({onCreated:t,onCancel:a}){const s=NE({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(Id,{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(Id,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),r.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
87
87
 
88
- Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...la,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),r.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&r.jsx(ri,{entries:s.aiProgress,isRunning:!0}),s.aiError&&r.jsx("div",{children:s.aiClassifiedError?r.jsx(Jo,{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(Id,{size:14}),"Generate"]}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",r.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),r.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>r.jsx("button",{onClick:()=>{s.setSelectedLayout(o.layout),s.setPlugin(o.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===o.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===o.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===o.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:o.label},o.layout))})]}),s.selectedLayout!==3&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),r.jsxs("select",{value:s.plugin,onChange:o=>{s.setPlugin(o.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la,children:[s.availablePlugins.map(o=>r.jsx("option",{value:o,children:o},o)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&r.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(df(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:la})]}),r.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&r.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),r.jsxs("span",{children:["Plugins detected (",r.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),r.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(df(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la})]}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("textarea",{value:s.description,onChange:o=>s.setDescription(o.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...la,minHeight:"72px"}})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la,children:[r.jsx("option",{value:"",children:"Any"}),r.jsx("option",{value:"opus",children:"Opus"}),r.jsx("option",{value:"sonnet",children:"Sonnet"}),r.jsx("option",{value:"haiku",children:"Haiku"})]})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),r.jsx("input",{type:"text",value:s.allowedTools,onChange:o=>s.setAllowedTools(o.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la})]})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"}),r.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),r.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),r.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>r.jsxs("button",{onClick:()=>s.setBodyViewMode(o),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===o?"var(--surface-4)":"transparent",color:s.bodyViewMode===o?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===o?600:400,border:"none",cursor:"pointer"},children:[o==="write"?r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 18 22 12 16 6"}),r.jsx("polyline",{points:"8 6 2 12 8 18"})]}):r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),r.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?r.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
88
+ Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...la,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),r.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&r.jsx(ai,{entries:s.aiProgress,isRunning:!0}),s.aiError&&r.jsx("div",{children:s.aiClassifiedError?r.jsx(Jo,{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(Id,{size:14}),"Generate"]}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",r.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),r.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>r.jsx("button",{onClick:()=>{s.setSelectedLayout(o.layout),s.setPlugin(o.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===o.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===o.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===o.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:o.label},o.layout))})]}),s.selectedLayout!==3&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),r.jsxs("select",{value:s.plugin,onChange:o=>{s.setPlugin(o.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la,children:[s.availablePlugins.map(o=>r.jsx("option",{value:o,children:o},o)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&r.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(df(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:la})]}),r.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&r.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),r.jsxs("span",{children:["Plugins detected (",r.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),r.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(df(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la})]}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("textarea",{value:s.description,onChange:o=>s.setDescription(o.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...la,minHeight:"72px"}})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la,children:[r.jsx("option",{value:"",children:"Any"}),r.jsx("option",{value:"opus",children:"Opus"}),r.jsx("option",{value:"sonnet",children:"Sonnet"}),r.jsx("option",{value:"haiku",children:"Haiku"})]})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),r.jsx("input",{type:"text",value:s.allowedTools,onChange:o=>s.setAllowedTools(o.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la})]})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"}),r.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),r.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),r.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>r.jsxs("button",{onClick:()=>s.setBodyViewMode(o),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===o?"var(--surface-4)":"transparent",color:s.bodyViewMode===o?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===o?600:400,border:"none",cursor:"pointer"},children:[o==="write"?r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 18 22 12 16 6"}),r.jsx("polyline",{points:"8 6 2 12 8 18"})]}):r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),r.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?r.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
89
89
 
90
90
  You are an expert at...
91
- `,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...la,minHeight:"150px"}}):s.body.trim()?r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Qo(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(AE,{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 LE(){return r.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),r.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),r.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function _o({variant:t,message:a,onRetry:s}){const{setMode:o,setSearch:c}=er(),[u,d]=m.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(LE,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?r.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:r.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),r.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),r.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),r.jsxs("button",{onClick:()=>o("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="error"?r.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:r.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[r.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:a||"Failed to load skill data"}),s&&r.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):r.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[r.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),r.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function zE(t,a){const[s,o]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>o?"minor":"patch"}const DE={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 Oy(){const[t,a]=m.useState([]),[s,o]=m.useState(!0),[c,u]=m.useState(new Set),[d,h]=m.useState(new Map),[g,p]=m.useState(!1),[y,v]=m.useState(new Set),[b,S]=m.useState(new Map),[k,E]=m.useState(null),[C,N]=m.useState(null),[T,A]=m.useState(!1),B=m.useCallback(async()=>{o(!0);try{const H=await Ce.getSkillUpdates();a(H.filter(q=>q.updateAvailable))}catch{a([])}finally{o(!1)}},[]);m.useEffect(()=>{B()},[B]);const D=m.useMemo(()=>t.filter(H=>!H.pinned),[t]),F=m.useCallback(H=>{u(q=>{const X=new Set(q);return X.has(H)?X.delete(H):X.add(H),X})},[]),w=m.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map(H=>H.name)))},[c,D]),O=m.useCallback(()=>{const H=[...c];if(!H.length)return;p(!0),h(new Map(H.map(X=>[X,{skill:X,status:"pending"}])));const q=Ce.startBatchUpdate(H);q.addEventListener("progress",X=>{try{const J=JSON.parse(X.data);h($=>new Map($).set(J.skill,J))}catch{}}),q.addEventListener("done",X=>{q.close(),p(!1);try{const J=JSON.parse(X.data);E(`Updated ${J.updated??0} skills, ${J.failed??0} failed`),setTimeout(()=>E(null),5e3)}catch{}B()}),q.addEventListener("error",()=>{q.close(),p(!1),E("Batch update failed"),setTimeout(()=>E(null),5e3)})},[c,B]),z=m.useCallback(async H=>{const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];v($=>new Set($).add(H.name)),S($=>{const L=new Map($);return L.delete(H.name),L});try{const $=await Ce.postSkillUpdate(X,J);if($.ok)B();else{const L=`Update failed (HTTP ${$.status}): ${$.body}`;S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — HTTP ${$.status}`),setTimeout(()=>E(null),5e3)}}catch($){const L=$ instanceof Error?$.message:"Network error";S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — ${L}`),setTimeout(()=>E(null),5e3)}finally{v($=>{const L=new Set($);return L.delete(H.name),L})}},[B]),U=m.useCallback(async H=>{if(!H.latest)return;const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];A(!0);try{const $=await Ce.getVersionDiff(X,J,H.installed,H.latest);N({skill:H,diff:$})}catch{N(null)}finally{A(!1)}},[]);return s?r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[r.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-16 rounded-lg"}),r.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?r.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[r.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),r.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),r.jsx("button",{onClick:B,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[k&&r.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:k}),r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:B,className:"btn btn-ghost text-[12px]",disabled:g,children:"Refresh"}),r.jsx("button",{onClick:O,disabled:c.size===0||g,className:"btn btn-primary text-[12px]",children:g?"Updating...":`Update Selected (${c.size})`})]})]}),r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsxs("button",{onClick:w,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===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(H=>{const q=H.name.split("/").pop()||H.name,X=H.latest?zE(H.installed,H.latest):"patch",J=DE[X],$=!!H.pinned,L=y.has(H.name),_=d.get(H.name),I=c.has(H.name);return r.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:$?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!$&&F(H.name),disabled:$,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:$?"not-allowed":"pointer"},children:r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:I?"var(--accent)":"var(--border-default)",background:I?"var(--accent)":"transparent",opacity:$?.4:1},children:I&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:q}),$&&r.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),r.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:J.bg,color:J.text},children:X})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[H.installed," → ",H.latest||"?",$&&` (pinned at ${H.pinnedVersion||H.installed})`]})]}),_&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.status==="done"?"var(--green-muted)":_.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:_.status==="done"?"var(--green)":_.status==="error"?"var(--red)":"var(--yellow)"},children:[_.status,_.error&&`: ${_.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>U(H),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),r.jsx("button",{onClick:()=>z(H),disabled:$||L||g,title:$?"Pinned — unpin from CLI to update":"",className:`btn ${$?"btn-ghost":"btn-primary"} text-[11px]`,children:L?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(_==null?void 0:_.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},H.name)})}),C&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>N(null),children:r.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:H=>H.stopPropagation(),children:[r.jsx("div",{className:"mb-2 flex justify-end",children:r.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(Df,{contentDiff:C.diff.contentDiff,fromLabel:C.diff.from,toLabel:C.diff.to,diffSummary:C.diff.diffSummary,renderContext:"inline"})]})})]})}const _E=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:Oy},Symbol.toStringTag,{value:"Module"}));function OE(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function BE(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function IE(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;if(!a.includes("://")){const[s]=a.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(a),o=s.hostname.toLowerCase();if(o!=="github.com"&&o!=="www.github.com"&&o!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function By(t){const{author:a,repoUrl:s}=t,o=IE(s??null),c=a&&a.trim()!==""?a:o??"—",[u,d]=m.useState(!1),h=m.useCallback(async()=>{var g;try{await((g=navigator.clipboard)==null?void 0:g.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return o?r.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${o}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!a||a.trim()===""?r.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function UE(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function HE(t,a){const s=UE(t),o=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return o?`${s}/blob/HEAD/${o}`:`${s}/blob/HEAD/`}function Kg(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function Iy(t){const{repoUrl:a,skillPath:s,absolutePath:o}=t,[c,u]=m.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),h=s?Kg(s):o?Kg(o):"source",g=m.useCallback(async()=>{var v;const y=o??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[o,s]);if(d){const y=HE(a,s);return r.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!o&&!s)return r.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const p=o??s??"";return r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${p}`,onClick:g,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function Xg(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Uy(t){return t.skill?VE({skill:t.skill}):FE({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function $E(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),o=t.slice(t.length-(a-12-1));return`${s}…${o}`}function VE({skill:t}){const[a,s]=m.useState(!1),o=m.useCallback(async()=>{var d;try{await((d=navigator.clipboard)==null?void 0:d.writeText(t.dir)),s(!0),setTimeout(()=>s(!1),1500),Xg(ne.toasts.pathCopied,"info")}catch{Xg(ne.toasts.permissionDenied,"error")}},[t.dir]),c=t.origin==="installed"?"Project":"Skills",u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[r.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[r.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${c}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),c]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[r.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(ti,{version:t.version??null})})]}),r.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(By,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(Iy,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(PE,{skill:t}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:t.dir,"aria-label":`Copy path ${t.dir} to clipboard`,onClick:o,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:$E(t.dir||"—")}),r.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:o,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[r.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),a?"Copied":"Copy"]})]})]})}function PE({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let o="";switch(a){case"symlinked":o=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":o="Copied (independent)";break;case"authored":o="Authored";break;default:return null}return r.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[r.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:o})]})}function FE({state:t,isReadOnly:a,onDelete:s}){const{plugin:o,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:g,regressions:p,iterationCount:y}=t,v=Array.from(g.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,T)=>N+T.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,E=OE(b),C=BE(b);return r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[r.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[r.jsx("span",{style:{color:"var(--text-tertiary)"},children:o}),r.jsx(GE,{}),r.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),a&&r.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&r.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&r.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s&&r.jsx("button",{disabled:v,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:o,skill:c,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(WE,{})}),p.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"})]}),p.length," regression",p.length>1?"s":""]}),y>0&&r.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),r.jsx("span",{className:"pill",style:{background:C,color:E},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function GE(){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 WE(){return r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),r.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),r.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function sa(t){const{title:a,label:s,value:o,subtitle:c,description:u,linkLabel:d,children:h,onClick:g}=t,p=a??s??"",y=typeof g=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),g==null||g())};return r.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>g==null?void 0:g():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[p?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:p}):null,r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(o)}),c?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?r.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?r.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:d}):null]})}const qE="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 YE(t){const{onNavigate:a}=t,[s,o]=m.useState(t.open??!1),c=m.useCallback(()=>o(!1),[]);m.useEffect(()=>{if(!s)return;const d=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=m.useCallback(d=>{a==null||a(d),o(!1)},[a]);return r.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>o(d=>!d),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&r.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[r.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:qE}),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:Ud,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Ud,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Ud,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Ud={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function KE(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 Ds(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.getTime(),o=Math.floor(s/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const d=Math.floor(u/24);if(d<30)return`${d} day${d===1?"":"s"} ago`;const h=Math.floor(d/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const g=Math.floor(h/12);return`${g} year${g===1?"":"s"} ago`}function XE(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function QE(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 ZE(t){var y,v;const{skill:a,onNavigate:s,activationsCount:o=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(JE(a.homepage)?a.homepage??null:null),g=((y=a.mcpDeps)==null?void 0:y.length)??0,p=((v=a.deps)==null?void 0:v.length)??0;return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"flex",flexDirection:"column",gap:12,padding:16},children:[r.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:a.skill}),r.jsx(ti,{version:a.version??null}),QE(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(By,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(Iy,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Ds(a.lastModified)]}):null]})]}),r.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[r.jsx(sa,{title:"Benchmark",value:XE(a),subtitle:a.lastBenchmark?Ds(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(YE,{onNavigate:s})})}),r.jsx(sa,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(sa,{title:"Activations",value:o,subtitle:c?`Last: ${Ds(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(sa,{title:"Last run",value:Ds(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(sa,{title:"MCP deps",value:g,subtitle:g>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(sa,{title:"Skill deps",value:p,subtitle:p>0&&a.deps?a.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(sa,{title:"Size",value:KE(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(sa,{title:"Last modified",value:Ds(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]})}function JE(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}const Qg=m.memo(function({message:a,politeness:s="polite",role:o}){const c=o??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function eN({toast:t,onDismiss:a}){const[s,o]=m.useState(!0),c=m.useRef(null);m.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>o(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function tN({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:o}){return r.jsxs(r.Fragment,{children:[r.jsx(Qg,{politeness:"polite",message:s}),r.jsx(Qg,{politeness:"assertive",message:o}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(eN,{toast:c,onDismiss:a})},c.id))})]})}const Hy=m.createContext(null);function _f(){const t=m.useContext(Hy);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function nN({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[o,c]=m.useState([]),[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(new Map),y=m.useCallback(C=>{const N=p.current.get(C);N&&(clearTimeout(N),p.current.delete(C)),c(T=>T.filter(A=>A.id!==C))},[]),v=m.useCallback((C,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(C)},N);p.current.set(C,T)},[y]),b=m.useCallback(C=>{const N=C.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:C.message,severity:C.severity??"info",durationMs:C.durationMs??s,action:C.action};return c(A=>[...A,T]),T.severity==="error"?g(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=m.useCallback(()=>{for(const C of p.current.values())clearTimeout(C);p.current.clear(),c([])},[]);m.useEffect(()=>{function C(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),B=A[A.length-1],D=p.current.get(B.id);return D&&(clearTimeout(D),p.current.delete(B.id)),T.filter(F=>F.id!==B.id)})}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[a]),m.useEffect(()=>()=>{for(const C of p.current.values())clearTimeout(C);p.current.clear()},[]);const k=o.slice(0,a),E=m.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(Hy.Provider,{value:E,children:[t,r.jsx(tN,{toasts:k,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function rN({skill:t}){const{refreshUpdates:a,dismissPushUpdate:s}=er(),{toast:o}=_f(),[c,u]=m.useState("idle"),[d,h]=m.useState(null),[g,p]=m.useState(!1),[y,v]=m.useState(null),[b,S]=m.useState(!1),k=m.useRef(null),E=m.useCallback(async()=>{if(!t||c==="updating")return;const A=new AbortController;k.current=A,u("updating"),h(null);try{const B=await Ce.postSkillUpdate(t.plugin,t.skill,A.signal);if(B.ok)u("done"),a(),s(`${t.plugin}/${t.skill}`),o({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const D=`Update failed (HTTP ${B.status}): ${B.body}`;u("idle"),h(D),o({message:`Couldn't update ${t.skill} — HTTP ${B.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}}catch(B){if(B instanceof DOMException&&B.name==="AbortError")return;const D=B instanceof Error?B.message:"Network error";u("idle"),h(D),o({message:`Couldn't update ${t.skill} — ${D}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}finally{k.current===A&&(k.current=null)}},[t,c,a,s,o]);if(m.useEffect(()=>{if(!g||y!=null||!t||!t.latestVersion)return;let A=!1;return S(!0),Ce.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(B=>{A||v(B)}).catch(()=>{A||v(null)}).finally(()=>{A||S(!1)}),()=>{A=!0}},[g,y,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),m.useEffect(()=>()=>{var A;(A=k.current)==null||A.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,N=c==="updating"?"Updating…":C?`Update to ${C}`:"Update",T=c==="updating";return r.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{E()},disabled:T,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:T?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:N}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>p(A=>!A),disabled:T||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:g?"Hide changelog":"Preview changelog"})]}),c==="updating"&&r.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),d&&c!=="updating"&&r.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:d}),g&&C&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[b&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!b&&y&&r.jsx(Df,{contentDiff:y.contentDiff,fromLabel:y.from,toLabel:y.to,diffSummary:y.diffSummary??void 0,renderContext:"inline"}),!b&&!y&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const aN=3e4;function lN({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:o=!1}){const c=er(),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[,p]=m.useState(0),y=m.useRef(null),v=m.useRef(null),b=`${t}/${a}`,S=c.updatesById.get(b);if(m.useEffect(()=>{if(!u)return;const E=setInterval(()=>p(C=>(C+1)%1e6),250);return()=>clearInterval(E)},[u]),m.useEffect(()=>{if(!u||!S)return;const E=v.current??0;S.receivedAt<E||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),g(!1),v.current=null)},[u,S]),m.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||o)return null;const k=async()=>{if(!u){g(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),g(!0),y.current=null,v.current=null},aN);try{await Ce.rescanSkill(t,a)}catch{y.current&&(clearTimeout(y.current),y.current=null),d(!1),v.current=null}}};return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx("button",{type:"button","data-testid":"check-now-button",onClick:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&r.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}const $y=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"],sN={overview:"Overview",editor:"Editor",tests:"Tests",run:"Run",activation:"Activation",history:"History",leaderboard:"Leaderboard",deps:"Deps",versions:"Versions"};function iN(t){return typeof t=="string"&&$y.includes(t)}function oN(){if(typeof window>"u")return"overview";const a=new URLSearchParams(window.location.search).get("panel");return iN(a)?a:"overview"}function Hd(){const{state:t,setMobileView:a}=er();return t.isMobile?r.jsxs("button",{onClick:()=>a("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function cN(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return uN(t);const{state:a,selectSkill:s,setMode:o,refreshSkills:c}=er(),[u,d]=m.useState(typeof window<"u"?window.location.hash:"");if(m.useEffect(()=>{const p=()=>d(window.location.hash);return window.addEventListener("hashchange",p),()=>window.removeEventListener("hashchange",p)},[]),u==="#/updates")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Hd,{}),r.jsx(Oy,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Hd,{}),r.jsx(ME,{onCreated:(p,y)=>{o("browse"),c(),s({plugin:p,skill:y,origin:"source"})},onCancel:()=>o("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(_o,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(_o,{variant:"no-skills"}):r.jsx(_o,{variant:"no-selection"});const h=a.selectedSkill,g=a.skills.find(p=>p.plugin===h.plugin&&p.skill===h.skill)??null;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx(Hd,{}),r.jsx(dN,{skillInfo:g,allSkills:a.skills,onSelectSkill:p=>s(p)})]})}function uN(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return pN();if(t.loadError)return mN(a,t.loadError);const o=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return Vy(a,s,t.onDetailTabChange,o)}function dN({skillInfo:t,allSkills:a,onSelectSkill:s}){const[o,c]=m.useState(oN());m.useEffect(()=>{if(typeof window>"u")return;const d=new URLSearchParams(window.location.search);o==="overview"?d.delete("panel"):d.set("panel",o);const h=d.toString(),g=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",g)},[o]);const u=m.useMemo(()=>t?Vy(t,o,c,{}):r.jsx(_o,{variant:"no-selection"}),[t,o,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:u})}function fN(t,a){return r.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:$y.map(s=>{const o=s===t;return r.jsx("button",{type:"button",role:"tab","aria-selected":o,tabIndex:o?0:-1,id:`detail-tab-${s}`,"aria-controls":`detail-panel-${s}`,"data-testid":`detail-tab-${s}`,onClick:()=>a==null?void 0:a(s),style:{background:"transparent",border:"none",borderBottom:o?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:o?500:400,color:o?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:sN[s]},s)})})}function pN(){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 mN(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[Uy({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 hN({active:t}){return t==="editor"?r.jsx(SC,{}):t==="tests"?r.jsx(RC,{}):t==="run"?r.jsx(PC,{}):t==="activation"?r.jsx(qC,{}):t==="history"?r.jsx(cE,{}):t==="leaderboard"?r.jsx(jE,{}):t==="deps"?r.jsx(kE,{}):t==="versions"?r.jsx(Qw,{}):null}function xN({active:t}){const{state:a,dispatch:s}=An();return m.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function Vy(t,a,s,o){const c=h=>{s==null||s(h)},u=r.jsx(ZE,{skill:t,onNavigate:c,repoUrl:t.homepage??null}),d=o!=null?r.jsxs(Ww,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(xN,{active:a}),r.jsx(hN,{active:a})]},`${t.plugin}/${t.skill}`):r.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",a," view."]});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[r.jsx("div",{style:{padding:16,paddingBottom:12},children:Uy({skill:t})}),r.jsx(rN,{skill:t}),t.origin==="installed"&&r.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{children:"This is an installed copy of the skill. Editing, generating tests, and running evals are disabled. Open the source skill to make changes."})]}),t.origin==="installed"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(lN,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),fN(a,s),r.jsx("div",{role:"tabpanel",id:`detail-panel-${a}`,"aria-labelledby":`detail-tab-${a}`,"data-testid":`detail-panel-${a}`,style:{flex:1,minHeight:0,overflow:"auto"},children:a==="overview"?u:d})]})}function gN(){const{updateCount:t,state:a,dismissUpdateNotification:s}=er(),o=t>0&&!a.updateNotificationDismissed;return m.useEffect(()=>{if(!o)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[o,s]),o?r.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[r.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),r.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),r.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const vN=[{name:ne.shortcuts.groupNavigation,items:[{keys:"/",label:ne.shortcuts.search},{keys:"j",label:ne.shortcuts.moveDown},{keys:"k",label:ne.shortcuts.moveUp},{keys:"Enter",label:ne.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ne.shortcuts.groupActions,items:[{keys:"⌘K",label:ne.shortcuts.openPalette},{keys:"?",label:ne.shortcuts.openShortcuts},{keys:"⌘B",label:ne.shortcuts.toggleSidebar},{keys:"E",label:ne.actions.edit}]},{name:ne.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ne.shortcuts.toggleTheme}]}];function yN({open:t,onClose:a,groups:s=vN,title:o=ne.shortcuts.title}){const c=m.useRef(null),u=m.useRef(null);return m.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var h,g;(g=(h=c.current)==null?void 0:h.focus)==null||g.call(h),c.current=null}},[t]),m.useEffect(()=>{if(!t)return;function d(h){var g;if(h.key==="Escape"){h.preventDefault(),a();return}h.key==="Tab"&&(h.preventDefault(),(g=u.current)==null||g.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,a]),t?r.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:d=>{d.target===d.currentTarget&&a()},children:r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:o}),r.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:a,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(d=>r.jsxs("section",{style:{marginBottom:12},children:[r.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),r.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[r.jsx("span",{children:h.label}),r.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${d.name}:${h.keys}`))})]},d.name))]})}):null}function bN(t){const a=ne.actions,s=[{action:"open",label:a.open},{action:"copy-path",label:a.copyPath},{action:"reveal",label:a.revealInEditor},{action:"run-benchmark",label:a.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:a.edit},{action:"duplicate",label:a.duplicate},{action:"delete",label:a.delete}];const o=[...s];return t.updateAvailable&&o.push({action:"update",label:a.update}),o.push({action:"uninstall",label:a.uninstall}),o.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),o}function jN({state:t,onClose:a,onAction:s,itemsOverride:o}){const c=m.useRef(null),u=m.useRef(null),[d,h]=m.useState(0),g=m.useMemo(()=>t.skill?o??bN(t.skill):[],[t.skill,o]),p=m.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+g.length*28;let k=t.x,E=t.y;return k+b+v>window.innerWidth&&(k=Math.max(v,t.x-b)),E+S+v>window.innerHeight&&(E=Math.max(v,t.y-S)),{left:k,top:E}},[t.x,t.y,g.length]);m.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,b;(b=(v=u.current)==null?void 0:v.focus)==null||b.call(v),u.current=null}},[t.open]);const y=m.useCallback(()=>{if(!t.skill)return;const v=g[d];!v||v.disabled||(s(v.action,t.skill),a())},[g,d,t.skill,s,a]);return m.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),a();return}if(S.key==="ArrowDown"){S.preventDefault(),h(k=>Math.min(k+1,Math.max(g.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(k=>Math.max(k-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||a())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,a,g.length,y]),!t.open||!t.skill?null:r.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:p.left,top:p.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:g.map((v,b)=>r.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{v.disabled||(s(v.action,t.skill),a())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}function SN({open:t,title:a,body:s,confirmLabel:o="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const g=m.useRef(null),p=m.useRef(null),y=m.useRef(null);if(m.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=p.current)==null||k.focus()}),()=>{var k,E;(E=(k=y.current)==null?void 0:k.focus)==null||E.call(k),y.current=null}},[t]),m.useEffect(()=>{if(!t)return;function k(E){if(E.key==="Escape"){E.preventDefault(),h();return}if(E.key==="Tab"&&g.current){const C=g.current.querySelectorAll("button:not([disabled])");if(C.length===0)return;const N=C[0],T=C[C.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[t,h]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:k=>{k.target===k.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:g,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:p,type:"button","data-testid":"confirm-dialog-cancel",onClick:h,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:o})]})]})})}function kN(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}const Zg=t=>`${t.plugin}/${t.skill}`;function wN(t){const a=t==null?void 0:t.delayMs,s=t==null?void 0:t.onCommit,o=t==null?void 0:t.onFailure,c=m.useRef(s),u=m.useRef(o);c.current=s,u.current=o;const d=m.useRef(new Map),[,h]=m.useState(0),g=m.useCallback(()=>h(k=>k+1),[]),p=m.useCallback(async k=>{var E,C;try{await Ce.deleteSkill(k.skill.plugin,k.skill.skill),(E=c.current)==null||E.call(c,k.skill)}catch(N){(C=u.current)==null||C.call(u,k.skill,N)}finally{d.current.delete(Zg(k.skill)),g()}},[g]),y=m.useCallback(k=>{const E=Zg(k),C=d.current.get(E);C!=null&&C.timeoutId&&clearTimeout(C.timeoutId);const N={skill:k,timeoutId:null};N.timeoutId=setTimeout(()=>{N.timeoutId=null,p(N)},a),d.current.set(E,N),g()},[a,p,g]),v=m.useCallback(k=>{const E=d.current.get(k);E&&(E.timeoutId&&clearTimeout(E.timeoutId),d.current.delete(k),g())},[g]),b=m.useCallback(async()=>{const k=Array.from(d.current.values());for(const E of k)E.timeoutId&&(clearTimeout(E.timeoutId),E.timeoutId=null);await Promise.all(k.map(E=>p(E)))},[p]),S=m.useCallback(k=>d.current.has(k),[]);return m.useEffect(()=>{const k=()=>{b()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[b]),m.useEffect(()=>{const k=d.current;return()=>{for(const E of k.values())E.timeoutId&&clearTimeout(E.timeoutId);k.clear()}},[]),{enqueueDelete:y,cancelDelete:v,flushPending:b,isPending:S}}const CN={"anthropic-api":{name:ne.setupProviders.anthropic.name,description:ne.setupProviders.anthropic.description,envVars:ne.setupProviders.anthropic.envVars,keyUrl:ne.setupProviders.anthropic.keyUrl,learnMoreUrl:ne.setupProviders.anthropic.learnMoreUrl},openai:{name:ne.setupProviders.openai.name,description:ne.setupProviders.openai.description,envVars:ne.setupProviders.openai.envVars,keyUrl:ne.setupProviders.openai.keyUrl,learnMoreUrl:ne.setupProviders.openai.learnMoreUrl},openrouter:{name:ne.setupProviders.openrouter.name,description:ne.setupProviders.openrouter.description,envVars:ne.setupProviders.openrouter.envVars,keyUrl:ne.setupProviders.openrouter.keyUrl,learnMoreUrl:ne.setupProviders.openrouter.learnMoreUrl},gemini:{name:ne.setupProviders.gemini.name,description:ne.setupProviders.gemini.description,envVars:ne.setupProviders.gemini.envVars,keyUrl:ne.setupProviders.gemini.keyUrl,learnMoreUrl:ne.setupProviders.gemini.learnMoreUrl},ollama:{name:ne.setupProviders.ollama.name,description:ne.setupProviders.ollama.description,envVars:ne.setupProviders.ollama.envVars,install:[ne.setupProviders.ollama.installCmd],start:[ne.setupProviders.ollama.startCmd],pullExample:ne.setupProviders.ollama.pullExample,learnMoreUrl:ne.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ne.setupProviders.lmStudio.name,description:ne.setupProviders.lmStudio.description,envVars:ne.setupProviders.lmStudio.envVars,install:[ne.setupProviders.lmStudio.installCmd],start:[ne.setupProviders.lmStudio.startCmd],pullExample:ne.setupProviders.lmStudio.pullExample,learnMoreUrl:ne.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ne.setupProviders.claudeCode.name,description:ne.setupProviders.claudeCode.description,envVars:[],notes:[ne.setupProviders.claudeCode.loginHint,ne.claudeCodeLabel.compactLabel],learnMoreUrl:ne.setupProviders.claudeCode.learnMoreUrl}};function EN(t){return t?CN[t]??null:null}function NN({open:t,providerKey:a,onClose:s}){const o=m.useRef(null);if(m.useEffect(()=>{if(!t)return;const d=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),m.useEffect(()=>{if(!t)return;const d=o.current;if(!d)return;const h=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=EN(a),u=(c==null?void 0:c.name)??ne.setupDrawer.fallbackTitle;return Go.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),r.jsxs("div",{"data-testid":"setup-drawer",ref:o,role:"dialog","aria-modal":"true","aria-label":ne.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsx(TN,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(RN,{content:c}):r.jsx(AN,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
91
+ `,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...la,minHeight:"150px"}}):s.body.trim()?r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Qo(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(AE,{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 LE(){return r.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),r.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),r.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function _o({variant:t,message:a,onRetry:s}){const{setMode:o,setSearch:c}=er(),[u,d]=p.useState(!1);return t==="no-selection"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(LE,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?r.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:r.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),r.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),r.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),r.jsxs("button",{onClick:()=>o("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="error"?r.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:r.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[r.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:a||"Failed to load skill data"}),s&&r.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):r.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[r.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),r.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function zE(t,a){const[s,o]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>o?"minor":"patch"}const DE={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 Oy(){const[t,a]=p.useState([]),[s,o]=p.useState(!0),[c,u]=p.useState(new Set),[d,h]=p.useState(new Map),[g,m]=p.useState(!1),[y,v]=p.useState(new Set),[b,S]=p.useState(new Map),[k,E]=p.useState(null),[C,N]=p.useState(null),[T,A]=p.useState(!1),B=p.useCallback(async()=>{o(!0);try{const H=await Ce.getSkillUpdates();a(H.filter(q=>q.updateAvailable))}catch{a([])}finally{o(!1)}},[]);p.useEffect(()=>{B()},[B]);const D=p.useMemo(()=>t.filter(H=>!H.pinned),[t]),F=p.useCallback(H=>{u(q=>{const X=new Set(q);return X.has(H)?X.delete(H):X.add(H),X})},[]),w=p.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map(H=>H.name)))},[c,D]),O=p.useCallback(()=>{const H=[...c];if(!H.length)return;m(!0),h(new Map(H.map(X=>[X,{skill:X,status:"pending"}])));const q=Ce.startBatchUpdate(H);q.addEventListener("progress",X=>{try{const J=JSON.parse(X.data);h($=>new Map($).set(J.skill,J))}catch{}}),q.addEventListener("done",X=>{q.close(),m(!1);try{const J=JSON.parse(X.data);E(`Updated ${J.updated??0} skills, ${J.failed??0} failed`),setTimeout(()=>E(null),5e3)}catch{}B()}),q.addEventListener("error",()=>{q.close(),m(!1),E("Batch update failed"),setTimeout(()=>E(null),5e3)})},[c,B]),z=p.useCallback(async H=>{const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];v($=>new Set($).add(H.name)),S($=>{const L=new Map($);return L.delete(H.name),L});try{const $=await Ce.postSkillUpdate(X,J);if($.ok)B();else{const L=`Update failed (HTTP ${$.status}): ${$.body}`;S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — HTTP ${$.status}`),setTimeout(()=>E(null),5e3)}}catch($){const L=$ instanceof Error?$.message:"Network error";S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — ${L}`),setTimeout(()=>E(null),5e3)}finally{v($=>{const L=new Set($);return L.delete(H.name),L})}},[B]),U=p.useCallback(async H=>{if(!H.latest)return;const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];A(!0);try{const $=await Ce.getVersionDiff(X,J,H.installed,H.latest);N({skill:H,diff:$})}catch{N(null)}finally{A(!1)}},[]);return s?r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[r.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-16 rounded-lg"}),r.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?r.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[r.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),r.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),r.jsx("button",{onClick:B,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[k&&r.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:k}),r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:B,className:"btn btn-ghost text-[12px]",disabled:g,children:"Refresh"}),r.jsx("button",{onClick:O,disabled:c.size===0||g,className:"btn btn-primary text-[12px]",children:g?"Updating...":`Update Selected (${c.size})`})]})]}),r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsxs("button",{onClick:w,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===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(H=>{const q=H.name.split("/").pop()||H.name,X=H.latest?zE(H.installed,H.latest):"patch",J=DE[X],$=!!H.pinned,L=y.has(H.name),_=d.get(H.name),I=c.has(H.name);return r.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:$?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!$&&F(H.name),disabled:$,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:$?"not-allowed":"pointer"},children:r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:I?"var(--accent)":"var(--border-default)",background:I?"var(--accent)":"transparent",opacity:$?.4:1},children:I&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:q}),$&&r.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),r.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:J.bg,color:J.text},children:X})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[H.installed," → ",H.latest||"?",$&&` (pinned at ${H.pinnedVersion||H.installed})`]})]}),_&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.status==="done"?"var(--green-muted)":_.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:_.status==="done"?"var(--green)":_.status==="error"?"var(--red)":"var(--yellow)"},children:[_.status,_.error&&`: ${_.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>U(H),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),r.jsx("button",{onClick:()=>z(H),disabled:$||L||g,title:$?"Pinned — unpin from CLI to update":"",className:`btn ${$?"btn-ghost":"btn-primary"} text-[11px]`,children:L?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(_==null?void 0:_.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},H.name)})}),C&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>N(null),children:r.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:H=>H.stopPropagation(),children:[r.jsx("div",{className:"mb-2 flex justify-end",children:r.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(Df,{contentDiff:C.diff.contentDiff,fromLabel:C.diff.from,toLabel:C.diff.to,diffSummary:C.diff.diffSummary,renderContext:"inline"})]})})]})}const _E=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:Oy},Symbol.toStringTag,{value:"Module"}));function OE(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function BE(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function IE(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;if(!a.includes("://")){const[s]=a.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(a),o=s.hostname.toLowerCase();if(o!=="github.com"&&o!=="www.github.com"&&o!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function By(t){const{author:a,repoUrl:s}=t,o=IE(s??null),c=a&&a.trim()!==""?a:o??"—",[u,d]=p.useState(!1),h=p.useCallback(async()=>{var g;try{await((g=navigator.clipboard)==null?void 0:g.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return o?r.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${o}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!a||a.trim()===""?r.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function UE(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function HE(t,a){const s=UE(t),o=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return o?`${s}/blob/HEAD/${o}`:`${s}/blob/HEAD/`}function Kg(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function Iy(t){const{repoUrl:a,skillPath:s,absolutePath:o}=t,[c,u]=p.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),h=s?Kg(s):o?Kg(o):"source",g=p.useCallback(async()=>{var v;const y=o??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[o,s]);if(d){const y=HE(a,s);return r.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!o&&!s)return r.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const m=o??s??"";return r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${m}`,onClick:g,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function Xg(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Uy(t){return t.skill?VE({skill:t.skill}):FE({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function $E(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),o=t.slice(t.length-(a-12-1));return`${s}…${o}`}function VE({skill:t}){const[a,s]=p.useState(!1),o=p.useCallback(async()=>{var d;try{await((d=navigator.clipboard)==null?void 0:d.writeText(t.dir)),s(!0),setTimeout(()=>s(!1),1500),Xg(ne.toasts.pathCopied,"info")}catch{Xg(ne.toasts.permissionDenied,"error")}},[t.dir]),c=t.origin==="installed"?"Project":"Skills",u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[r.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[r.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${c}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),c]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[r.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(ni,{version:t.version??null})})]}),r.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(By,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(Iy,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(PE,{skill:t}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:t.dir,"aria-label":`Copy path ${t.dir} to clipboard`,onClick:o,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:$E(t.dir||"—")}),r.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:o,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[r.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),a?"Copied":"Copy"]})]})]})}function PE({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let o="";switch(a){case"symlinked":o=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":o="Copied (independent)";break;case"authored":o="Authored";break;default:return null}return r.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[r.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:o})]})}function FE({state:t,isReadOnly:a,onDelete:s}){const{plugin:o,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:g,regressions:m,iterationCount:y}=t,v=Array.from(g.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,T)=>N+T.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,E=OE(b),C=BE(b);return r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[r.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[r.jsx("span",{style:{color:"var(--text-tertiary)"},children:o}),r.jsx(GE,{}),r.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),a&&r.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&r.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&r.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s&&r.jsx("button",{disabled:v,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:o,skill:c,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(WE,{})}),m.length>0&&r.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),m.length," regression",m.length>1?"s":""]}),y>0&&r.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),r.jsx("span",{className:"pill",style:{background:C,color:E},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function GE(){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 WE(){return r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),r.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),r.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function sa(t){const{title:a,label:s,value:o,subtitle:c,description:u,linkLabel:d,children:h,onClick:g}=t,m=a??s??"",y=typeof g=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),g==null||g())};return r.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>g==null?void 0:g():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[m?r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:m}):null,r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(o)}),c?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?r.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?r.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:d}):null]})}const qE="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 YE(t){const{onNavigate:a}=t,[s,o]=p.useState(t.open??!1),c=p.useCallback(()=>o(!1),[]);p.useEffect(()=>{if(!s)return;const d=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=p.useCallback(d=>{a==null||a(d),o(!1)},[a]);return r.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>o(d=>!d),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&r.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[r.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:qE}),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:Ud,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Ud,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Ud,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Ud={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function KE(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const a=t/1024;if(a<1024)return a>=10?`${Math.round(a)} KB`:`${a.toFixed(1).replace(/\.0$/,"")} KB`;const s=a/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function Os(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.getTime(),o=Math.floor(s/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const d=Math.floor(u/24);if(d<30)return`${d} day${d===1?"":"s"} ago`;const h=Math.floor(d/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const g=Math.floor(h/12);return`${g} year${g===1?"":"s"} ago`}function XE(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function QE(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 ZE(t){var y,v;const{skill:a,onNavigate:s,activationsCount:o=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(JE(a.homepage)?a.homepage??null:null),g=((y=a.mcpDeps)==null?void 0:y.length)??0,m=((v=a.deps)==null?void 0:v.length)??0;return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"flex",flexDirection:"column",gap:12,padding:16},children:[r.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:a.skill}),r.jsx(ni,{version:a.version??null}),QE(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(By,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(Iy,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Os(a.lastModified)]}):null]})]}),r.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[r.jsx(sa,{title:"Benchmark",value:XE(a),subtitle:a.lastBenchmark?Os(a.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:r.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:r.jsx(YE,{onNavigate:s})})}),r.jsx(sa,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(sa,{title:"Activations",value:o,subtitle:c?`Last: ${Os(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(sa,{title:"Last run",value:Os(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(sa,{title:"MCP deps",value:g,subtitle:g>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(sa,{title:"Skill deps",value:m,subtitle:m>0&&a.deps?a.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(sa,{title:"Size",value:KE(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(sa,{title:"Last modified",value:Os(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]})}function JE(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}const Qg=p.memo(function({message:a,politeness:s="polite",role:o}){const c=o??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function eN({toast:t,onDismiss:a}){const[s,o]=p.useState(!0),c=p.useRef(null);p.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>o(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function tN({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:o}){return r.jsxs(r.Fragment,{children:[r.jsx(Qg,{politeness:"polite",message:s}),r.jsx(Qg,{politeness:"assertive",message:o}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(eN,{toast:c,onDismiss:a})},c.id))})]})}const Hy=p.createContext(null);function _f(){const t=p.useContext(Hy);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function nN({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[o,c]=p.useState([]),[u,d]=p.useState(""),[h,g]=p.useState(""),m=p.useRef(new Map),y=p.useCallback(C=>{const N=m.current.get(C);N&&(clearTimeout(N),m.current.delete(C)),c(T=>T.filter(A=>A.id!==C))},[]),v=p.useCallback((C,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(C)},N);m.current.set(C,T)},[y]),b=p.useCallback(C=>{const N=C.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:C.message,severity:C.severity??"info",durationMs:C.durationMs??s,action:C.action};return c(A=>[...A,T]),T.severity==="error"?g(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=p.useCallback(()=>{for(const C of m.current.values())clearTimeout(C);m.current.clear(),c([])},[]);p.useEffect(()=>{function C(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),B=A[A.length-1],D=m.current.get(B.id);return D&&(clearTimeout(D),m.current.delete(B.id)),T.filter(F=>F.id!==B.id)})}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[a]),p.useEffect(()=>()=>{for(const C of m.current.values())clearTimeout(C);m.current.clear()},[]);const k=o.slice(0,a),E=p.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(Hy.Provider,{value:E,children:[t,r.jsx(tN,{toasts:k,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function rN({skill:t}){const{refreshUpdates:a,dismissPushUpdate:s}=er(),{toast:o}=_f(),[c,u]=p.useState("idle"),[d,h]=p.useState(null),[g,m]=p.useState(!1),[y,v]=p.useState(null),[b,S]=p.useState(!1),k=p.useRef(null),E=p.useCallback(async()=>{if(!t||c==="updating")return;const A=new AbortController;k.current=A,u("updating"),h(null);try{const B=await Ce.postSkillUpdate(t.plugin,t.skill,A.signal);if(B.ok)u("done"),a(),s(`${t.plugin}/${t.skill}`),o({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const D=`Update failed (HTTP ${B.status}): ${B.body}`;u("idle"),h(D),o({message:`Couldn't update ${t.skill} — HTTP ${B.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}}catch(B){if(B instanceof DOMException&&B.name==="AbortError")return;const D=B instanceof Error?B.message:"Network error";u("idle"),h(D),o({message:`Couldn't update ${t.skill} — ${D}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}finally{k.current===A&&(k.current=null)}},[t,c,a,s,o]);if(p.useEffect(()=>{if(!g||y!=null||!t||!t.latestVersion)return;let A=!1;return S(!0),Ce.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(B=>{A||v(B)}).catch(()=>{A||v(null)}).finally(()=>{A||S(!1)}),()=>{A=!0}},[g,y,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),p.useEffect(()=>()=>{var A;(A=k.current)==null||A.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,N=c==="updating"?"Updating…":C?`Update to ${C}`:"Update",T=c==="updating";return r.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{E()},disabled:T,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:T?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:N}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>m(A=>!A),disabled:T||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:g?"Hide changelog":"Preview changelog"})]}),c==="updating"&&r.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),d&&c!=="updating"&&r.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:d}),g&&C&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[b&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!b&&y&&r.jsx(Df,{contentDiff:y.contentDiff,fromLabel:y.from,toLabel:y.to,diffSummary:y.diffSummary??void 0,renderContext:"inline"}),!b&&!y&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const aN=3e4;function lN({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:o=!1}){const c=er(),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[,m]=p.useState(0),y=p.useRef(null),v=p.useRef(null),b=`${t}/${a}`,S=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const E=setInterval(()=>m(C=>(C+1)%1e6),250);return()=>clearInterval(E)},[u]),p.useEffect(()=>{if(!u||!S)return;const E=v.current??0;S.receivedAt<E||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),g(!1),v.current=null)},[u,S]),p.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||o)return null;const k=async()=>{if(!u){g(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),g(!0),y.current=null,v.current=null},aN);try{await Ce.rescanSkill(t,a)}catch{y.current&&(clearTimeout(y.current),y.current=null),d(!1),v.current=null}}};return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx("button",{type:"button","data-testid":"check-now-button",onClick:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&r.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}const $y=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"],sN={overview:"Overview",editor:"Editor",tests:"Tests",run:"Run",activation:"Activation",history:"History",leaderboard:"Leaderboard",deps:"Deps",versions:"Versions"};function iN(t){return typeof t=="string"&&$y.includes(t)}function oN(){if(typeof window>"u")return"overview";const a=new URLSearchParams(window.location.search).get("panel");return iN(a)?a:"overview"}function Hd(){const{state:t,setMobileView:a}=er();return t.isMobile?r.jsxs("button",{onClick:()=>a("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function cN(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return uN(t);const{state:a,selectSkill:s,setMode:o,refreshSkills:c}=er(),[u,d]=p.useState(typeof window<"u"?window.location.hash:"");if(p.useEffect(()=>{const m=()=>d(window.location.hash);return window.addEventListener("hashchange",m),()=>window.removeEventListener("hashchange",m)},[]),u==="#/updates")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Hd,{}),r.jsx(Oy,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Hd,{}),r.jsx(ME,{onCreated:(m,y)=>{o("browse"),c(),s({plugin:m,skill:y,origin:"source"})},onCancel:()=>o("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(_o,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(_o,{variant:"no-skills"}):r.jsx(_o,{variant:"no-selection"});const h=a.selectedSkill,g=a.skills.find(m=>m.plugin===h.plugin&&m.skill===h.skill)??null;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx(Hd,{}),r.jsx(dN,{skillInfo:g,allSkills:a.skills,onSelectSkill:m=>s(m)})]})}function uN(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return pN();if(t.loadError)return mN(a,t.loadError);const o=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return Vy(a,s,t.onDetailTabChange,o)}function dN({skillInfo:t,allSkills:a,onSelectSkill:s}){const[o,c]=p.useState(oN());p.useEffect(()=>{if(typeof window>"u")return;const d=new URLSearchParams(window.location.search);o==="overview"?d.delete("panel"):d.set("panel",o);const h=d.toString(),g=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",g)},[o]);const u=p.useMemo(()=>t?Vy(t,o,c,{}):r.jsx(_o,{variant:"no-selection"}),[t,o,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:u})}function fN(t,a){return r.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:$y.map(s=>{const o=s===t;return r.jsx("button",{type:"button",role:"tab","aria-selected":o,tabIndex:o?0:-1,id:`detail-tab-${s}`,"aria-controls":`detail-panel-${s}`,"data-testid":`detail-tab-${s}`,onClick:()=>a==null?void 0:a(s),style:{background:"transparent",border:"none",borderBottom:o?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:o?500:400,color:o?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:sN[s]},s)})})}function pN(){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 mN(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[Uy({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 hN({active:t}){return t==="editor"?r.jsx(SC,{}):t==="tests"?r.jsx(RC,{}):t==="run"?r.jsx(PC,{}):t==="activation"?r.jsx(qC,{}):t==="history"?r.jsx(cE,{}):t==="leaderboard"?r.jsx(jE,{}):t==="deps"?r.jsx(kE,{}):t==="versions"?r.jsx(Qw,{}):null}function xN({active:t}){const{state:a,dispatch:s}=An();return p.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function Vy(t,a,s,o){const c=h=>{s==null||s(h)},u=r.jsx(ZE,{skill:t,onNavigate:c,repoUrl:t.homepage??null}),d=o!=null?r.jsxs(Ww,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(xN,{active:a}),r.jsx(hN,{active:a})]},`${t.plugin}/${t.skill}`):r.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",a," view."]});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[r.jsx("div",{style:{padding:16,paddingBottom:12},children:Uy({skill:t})}),r.jsx(rN,{skill:t}),t.origin==="installed"&&r.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{children:"This is an installed copy of the skill. Editing, generating tests, and running evals are disabled. Open the source skill to make changes."})]}),t.origin==="installed"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(lN,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),fN(a,s),r.jsx("div",{role:"tabpanel",id:`detail-panel-${a}`,"aria-labelledby":`detail-tab-${a}`,"data-testid":`detail-panel-${a}`,style:{flex:1,minHeight:0,overflow:"auto"},children:a==="overview"?u:d})]})}function gN(){const{updateCount:t,state:a,dismissUpdateNotification:s}=er(),o=t>0&&!a.updateNotificationDismissed;return p.useEffect(()=>{if(!o)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[o,s]),o?r.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[r.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),r.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),r.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const vN=[{name:ne.shortcuts.groupNavigation,items:[{keys:"/",label:ne.shortcuts.search},{keys:"j",label:ne.shortcuts.moveDown},{keys:"k",label:ne.shortcuts.moveUp},{keys:"Enter",label:ne.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ne.shortcuts.groupActions,items:[{keys:"⌘K",label:ne.shortcuts.openPalette},{keys:"?",label:ne.shortcuts.openShortcuts},{keys:"⌘B",label:ne.shortcuts.toggleSidebar},{keys:"E",label:ne.actions.edit}]},{name:ne.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ne.shortcuts.toggleTheme}]}];function yN({open:t,onClose:a,groups:s=vN,title:o=ne.shortcuts.title}){const c=p.useRef(null),u=p.useRef(null);return p.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var h,g;(g=(h=c.current)==null?void 0:h.focus)==null||g.call(h),c.current=null}},[t]),p.useEffect(()=>{if(!t)return;function d(h){var g;if(h.key==="Escape"){h.preventDefault(),a();return}h.key==="Tab"&&(h.preventDefault(),(g=u.current)==null||g.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,a]),t?r.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:d=>{d.target===d.currentTarget&&a()},children:r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:o}),r.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:a,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(d=>r.jsxs("section",{style:{marginBottom:12},children:[r.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),r.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[r.jsx("span",{children:h.label}),r.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${d.name}:${h.keys}`))})]},d.name))]})}):null}function bN(t){const a=ne.actions,s=[{action:"open",label:a.open},{action:"copy-path",label:a.copyPath},{action:"reveal",label:a.revealInEditor},{action:"run-benchmark",label:a.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:a.edit},{action:"duplicate",label:a.duplicate},{action:"delete",label:a.delete}];const o=[...s];return t.updateAvailable&&o.push({action:"update",label:a.update}),o.push({action:"uninstall",label:a.uninstall}),o.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),o}function jN({state:t,onClose:a,onAction:s,itemsOverride:o}){const c=p.useRef(null),u=p.useRef(null),[d,h]=p.useState(0),g=p.useMemo(()=>t.skill?o??bN(t.skill):[],[t.skill,o]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+g.length*28;let k=t.x,E=t.y;return k+b+v>window.innerWidth&&(k=Math.max(v,t.x-b)),E+S+v>window.innerHeight&&(E=Math.max(v,t.y-S)),{left:k,top:E}},[t.x,t.y,g.length]);p.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,b;(b=(v=u.current)==null?void 0:v.focus)==null||b.call(v),u.current=null}},[t.open]);const y=p.useCallback(()=>{if(!t.skill)return;const v=g[d];!v||v.disabled||(s(v.action,t.skill),a())},[g,d,t.skill,s,a]);return p.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),a();return}if(S.key==="ArrowDown"){S.preventDefault(),h(k=>Math.min(k+1,Math.max(g.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(k=>Math.max(k-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||a())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,a,g.length,y]),!t.open||!t.skill?null:r.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:m.left,top:m.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:g.map((v,b)=>r.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{v.disabled||(s(v.action,t.skill),a())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}function SN({open:t,title:a,body:s,confirmLabel:o="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const g=p.useRef(null),m=p.useRef(null),y=p.useRef(null);if(p.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=m.current)==null||k.focus()}),()=>{var k,E;(E=(k=y.current)==null?void 0:k.focus)==null||E.call(k),y.current=null}},[t]),p.useEffect(()=>{if(!t)return;function k(E){if(E.key==="Escape"){E.preventDefault(),h();return}if(E.key==="Tab"&&g.current){const C=g.current.querySelectorAll("button:not([disabled])");if(C.length===0)return;const N=C[0],T=C[C.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[t,h]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:k=>{k.target===k.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:g,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:m,type:"button","data-testid":"confirm-dialog-cancel",onClick:h,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:o})]})]})})}function kN(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}const Zg=t=>`${t.plugin}/${t.skill}`;function wN(t){const a=t==null?void 0:t.delayMs,s=t==null?void 0:t.onCommit,o=t==null?void 0:t.onFailure,c=p.useRef(s),u=p.useRef(o);c.current=s,u.current=o;const d=p.useRef(new Map),[,h]=p.useState(0),g=p.useCallback(()=>h(k=>k+1),[]),m=p.useCallback(async k=>{var E,C;try{await Ce.deleteSkill(k.skill.plugin,k.skill.skill),(E=c.current)==null||E.call(c,k.skill)}catch(N){(C=u.current)==null||C.call(u,k.skill,N)}finally{d.current.delete(Zg(k.skill)),g()}},[g]),y=p.useCallback(k=>{const E=Zg(k),C=d.current.get(E);C!=null&&C.timeoutId&&clearTimeout(C.timeoutId);const N={skill:k,timeoutId:null};N.timeoutId=setTimeout(()=>{N.timeoutId=null,m(N)},a),d.current.set(E,N),g()},[a,m,g]),v=p.useCallback(k=>{const E=d.current.get(k);E&&(E.timeoutId&&clearTimeout(E.timeoutId),d.current.delete(k),g())},[g]),b=p.useCallback(async()=>{const k=Array.from(d.current.values());for(const E of k)E.timeoutId&&(clearTimeout(E.timeoutId),E.timeoutId=null);await Promise.all(k.map(E=>m(E)))},[m]),S=p.useCallback(k=>d.current.has(k),[]);return p.useEffect(()=>{const k=()=>{b()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[b]),p.useEffect(()=>{const k=d.current;return()=>{for(const E of k.values())E.timeoutId&&clearTimeout(E.timeoutId);k.clear()}},[]),{enqueueDelete:y,cancelDelete:v,flushPending:b,isPending:S}}const CN={"anthropic-api":{name:ne.setupProviders.anthropic.name,description:ne.setupProviders.anthropic.description,envVars:ne.setupProviders.anthropic.envVars,keyUrl:ne.setupProviders.anthropic.keyUrl,learnMoreUrl:ne.setupProviders.anthropic.learnMoreUrl},openai:{name:ne.setupProviders.openai.name,description:ne.setupProviders.openai.description,envVars:ne.setupProviders.openai.envVars,keyUrl:ne.setupProviders.openai.keyUrl,learnMoreUrl:ne.setupProviders.openai.learnMoreUrl},openrouter:{name:ne.setupProviders.openrouter.name,description:ne.setupProviders.openrouter.description,envVars:ne.setupProviders.openrouter.envVars,keyUrl:ne.setupProviders.openrouter.keyUrl,learnMoreUrl:ne.setupProviders.openrouter.learnMoreUrl},gemini:{name:ne.setupProviders.gemini.name,description:ne.setupProviders.gemini.description,envVars:ne.setupProviders.gemini.envVars,keyUrl:ne.setupProviders.gemini.keyUrl,learnMoreUrl:ne.setupProviders.gemini.learnMoreUrl},ollama:{name:ne.setupProviders.ollama.name,description:ne.setupProviders.ollama.description,envVars:ne.setupProviders.ollama.envVars,install:[ne.setupProviders.ollama.installCmd],start:[ne.setupProviders.ollama.startCmd],pullExample:ne.setupProviders.ollama.pullExample,learnMoreUrl:ne.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ne.setupProviders.lmStudio.name,description:ne.setupProviders.lmStudio.description,envVars:ne.setupProviders.lmStudio.envVars,install:[ne.setupProviders.lmStudio.installCmd],start:[ne.setupProviders.lmStudio.startCmd],pullExample:ne.setupProviders.lmStudio.pullExample,learnMoreUrl:ne.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ne.setupProviders.claudeCode.name,description:ne.setupProviders.claudeCode.description,envVars:[],notes:[ne.setupProviders.claudeCode.loginHint,ne.claudeCodeLabel.compactLabel],learnMoreUrl:ne.setupProviders.claudeCode.learnMoreUrl}};function EN(t){return t?CN[t]??null:null}function NN({open:t,providerKey:a,onClose:s}){const o=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const d=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),p.useEffect(()=>{if(!t)return;const d=o.current;if(!d)return;const h=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=EN(a),u=(c==null?void 0:c.name)??ne.setupDrawer.fallbackTitle;return Go.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),r.jsxs("div",{"data-testid":"setup-drawer",ref:o,role:"dialog","aria-modal":"true","aria-label":ne.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsx(TN,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(RN,{content:c}):r.jsx(AN,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
92
92
  from { transform: translateX(100%); }
93
93
  to { transform: translateX(0); }
94
94
  }
95
95
  @keyframes vskillDrawerBackdropIn {
96
96
  from { opacity: 0; }
97
97
  to { opacity: 1; }
98
- }`})]})]}),document.body)}function TN({title:t,onClose:a}){return r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ne.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":ne.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function RN({content:t}){var a,s;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(o=>r.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:o},o))}),t.envVars.length>0&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.requiredEnv}),r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(o=>r.jsx("li",{children:r.jsx(MN,{name:o})},o))})]}),t.keyUrl&&r.jsx(LN,{href:t.keyUrl,label:ne.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.installRun}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((o,c)=>r.jsx($d,{code:o},`install-${c}`)),(s=t.start)==null?void 0:s.map((o,c)=>r.jsx($d,{code:o},`start-${c}`)),t.pullExample&&r.jsx($d,{code:t.pullExample})]})]}),r.jsx("footer",{style:{marginTop:8},children:r.jsxs("a",{href:t.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[ne.setupDrawer.learnMore," →"]})})]})}function AN(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ne.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ne.setupDrawer.fallbackBody})]})}function MN({name:t}){const a=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),r.jsx("button",{type:"button",onClick:a,"aria-label":`Copy ${t} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:ne.setupDrawer.copy})]})}function $d({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 LN({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 zN(){const[t,a]=m.useState(!1),[s,o]=m.useState(null),c=m.useRef(null),u=m.useCallback((h,g)=>{var p;c.current=typeof document<"u"?document.activeElement:null,(p=g==null?void 0:g.beforeOpen)==null||p.call(g),o(h),a(!0)},[]),d=m.useCallback(()=>{a(!1);const h=c.current;h&&"focus"in h&&typeof h.focus=="function"&&queueMicrotask(()=>h.focus())},[]);return m.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function DN(t){const a=[],s=[],o=new Set;for(const c of t){if(c.presence==="absent"||c.health==="missing"){s.push({kind:"individual",key:c.id,agent:c});continue}if(c.sharedFolderGroup&&c.sharedFolderGroup.length>1){const u=[...c.sharedFolderGroup].sort().join("+");if(o.has(u))continue;o.add(u);const d=t.filter(h=>c.sharedFolderGroup.includes(h.id));a.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((h,g)=>h+g.globalCount,0)});continue}a.push({kind:"individual",key:c.id,agent:c})}return{detected:a,notDetected:s}}function _N({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:o,onSwitch:c,onOpenSetup:u,onClose:d}){const h=m.useRef(null);m.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),d())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[d]),m.useEffect(()=>{const y=b=>{h.current&&!h.current.contains(b.target)&&d()},v=setTimeout(()=>{document.addEventListener("mousedown",y)},0);return()=>{clearTimeout(v),document.removeEventListener("mousedown",y)}},[d]);const g=m.useMemo(()=>DN(t),[t]),p=t.find(y=>y.id===s)??t.find(y=>y.id===a)??t[0];return typeof document>"u"?null:Go.createPortal(r.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ne.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[r.jsxs("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:[g.detected.length===0&&g.notDetected.length===0&&r.jsx(Jg,{}),g.detected.map(y=>y.kind==="aggregate"?r.jsx(BN,{row:y,onFocus:()=>{var v;return o(((v=y.consumers[0])==null?void 0:v.id)??a??"")}},y.key):r.jsx(ON,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===a,onClick:()=>o(y.agent.id)},y.key)),g.notDetected.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:ne.scopePicker.notDetectedSubheading}),g.notDetected.map(y=>r.jsx(IN,{agent:y.agent},y.key))]})]}),r.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:p?r.jsx(UN,{agent:p,activeAgentId:a,onSwitch:()=>c(p.id)}):r.jsx(Jg,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
98
+ }`})]})]}),document.body)}function TN({title:t,onClose:a}){return r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ne.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":ne.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function RN({content:t}){var a,s;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(o=>r.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:o},o))}),t.envVars.length>0&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.requiredEnv}),r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(o=>r.jsx("li",{children:r.jsx(MN,{name:o})},o))})]}),t.keyUrl&&r.jsx(LN,{href:t.keyUrl,label:ne.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.installRun}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((o,c)=>r.jsx($d,{code:o},`install-${c}`)),(s=t.start)==null?void 0:s.map((o,c)=>r.jsx($d,{code:o},`start-${c}`)),t.pullExample&&r.jsx($d,{code:t.pullExample})]})]}),r.jsx("footer",{style:{marginTop:8},children:r.jsxs("a",{href:t.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[ne.setupDrawer.learnMore," →"]})})]})}function AN(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ne.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ne.setupDrawer.fallbackBody})]})}function MN({name:t}){const a=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),r.jsx("button",{type:"button",onClick:a,"aria-label":`Copy ${t} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:ne.setupDrawer.copy})]})}function $d({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 LN({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 zN(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),c=p.useRef(null),u=p.useCallback((h,g)=>{var m;c.current=typeof document<"u"?document.activeElement:null,(m=g==null?void 0:g.beforeOpen)==null||m.call(g),o(h),a(!0)},[]),d=p.useCallback(()=>{a(!1);const h=c.current;h&&"focus"in h&&typeof h.focus=="function"&&queueMicrotask(()=>h.focus())},[]);return p.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function DN(t){const a=[],s=[],o=new Set;for(const c of t){if(c.presence==="absent"||c.health==="missing"){s.push({kind:"individual",key:c.id,agent:c});continue}if(c.sharedFolderGroup&&c.sharedFolderGroup.length>1){const u=[...c.sharedFolderGroup].sort().join("+");if(o.has(u))continue;o.add(u);const d=t.filter(h=>c.sharedFolderGroup.includes(h.id));a.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((h,g)=>h+g.globalCount,0)});continue}a.push({kind:"individual",key:c.id,agent:c})}return{detected:a,notDetected:s}}function _N({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:o,onSwitch:c,onOpenSetup:u,onClose:d}){const h=p.useRef(null);p.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),d())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[d]),p.useEffect(()=>{const y=b=>{h.current&&!h.current.contains(b.target)&&d()},v=setTimeout(()=>{document.addEventListener("mousedown",y)},0);return()=>{clearTimeout(v),document.removeEventListener("mousedown",y)}},[d]);const g=p.useMemo(()=>DN(t),[t]),m=t.find(y=>y.id===s)??t.find(y=>y.id===a)??t[0];return typeof document>"u"?null:Go.createPortal(r.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ne.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[r.jsxs("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:[g.detected.length===0&&g.notDetected.length===0&&r.jsx(Jg,{}),g.detected.map(y=>y.kind==="aggregate"?r.jsx(BN,{row:y,onFocus:()=>{var v;return o(((v=y.consumers[0])==null?void 0:v.id)??a??"")}},y.key):r.jsx(ON,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===a,onClick:()=>o(y.agent.id)},y.key)),g.notDetected.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:ne.scopePicker.notDetectedSubheading}),g.notDetected.map(y=>r.jsx(IN,{agent:y.agent},y.key))]})]}),r.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:m?r.jsx(UN,{agent:m,activeAgentId:a,onSwitch:()=>c(m.id)}):r.jsx(Jg,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
99
99
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
100
100
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
101
- }`})]}),document.body)}function ON({agent:t,focused:a,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function BN({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 IN({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 UN({agent:t,activeAgentId:a,onSwitch:s}){const o=t.id===a,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":$N(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Vd,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Vd,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Vd,{label:ne.scopePicker.statsLastSync,value:t.lastSync?HN(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 Vd({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 Jg(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function HN(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function $N(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function VN(t){const a=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)a.set(o,s);return t.agents.map(s=>{const o=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function PN({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),y=m.useMemo(()=>p?p.health==="ok"?"var(--color-ok, #22c55e)":p.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[p]),v=m.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),b=m.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(p==null?void 0:p.displayName)??"Select agent"}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(p==null?void 0:p.installedCount)??0," · ",(p==null?void 0:p.globalCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(_N,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const Py="vskill-ccode-banner-dismissed",FN=new Set(["claude-cli","claude-code"]);function GN(){try{return sessionStorage.getItem(Py)==="true"}catch{return!1}}function WN(){try{sessionStorage.setItem(Py,"true")}catch{}}function qN({activeAgentId:t}){const[a,s]=m.useState(()=>GN()),o=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{WN(),s(!0)},[]);return!t||!FN.has(t)||a?null:r.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function YN(){const[t,a]=m.useState(null),[s,o]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const h=await Ce.getAgents();a(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Eo="workspace",KN=["skills","agents"];async function XN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function QN(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 ZN(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 JN(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 Pd(){for(const t of KN)Tn(t)}function eT(){const{data:t,loading:a,error:s,revalidate:o}=ni(Eo,XN),c=t,u=c==null?void 0:c.projects.find(p=>p.id===c.activeProjectId),d=m.useCallback(async p=>{await QN(p),Tn(Eo),Pd()},[]),h=m.useCallback(async p=>{await ZN(p),Tn(Eo),Pd()},[]),g=m.useCallback(async p=>{await JN(p),Tn(Eo),Pd()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function tT({workspace:t,onSwitch:a,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(""),[v,b]=m.useState(null),[S,k]=m.useState(null),[E,C]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),B=(t==null?void 0:t.projects)??[],D=B.find(z=>z.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function z(U){A.current&&!A.current.contains(U.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function F(){b(null);const z=p.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),y(""),g(!1)}catch(U){const H=U instanceof Error?U.message:String(U);/does not exist/i.test(H)?b(`Path not found on disk: ${z}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function w(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),g(!0)}catch{}else g(!0)}function O(z){if(z.length<=50)return z;const U=z.split("/");return U.length<=4?z:`${U.slice(0,3).join("/")}/…/${U.slice(-2).join("/")}`}return r.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"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:[B.length===0&&r.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),B.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(z=>{const U=c?c(z.path):!1,H=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return r.jsxs("li",{role:"menuitem","data-stale":U?"true":"false",onMouseEnter:()=>k(z.id),onMouseLeave:()=>k(X=>X===z.id?null:X),onClick:()=>{if(!U){if(H){d(!1);return}C(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:U?"not-allowed":"pointer",background:q&&!U?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:U?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:H?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),H&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),U&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:X=>{X.stopPropagation(),o(z.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"})]})})]},z.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&r.jsxs("button",{type:"button",onClick:()=>void w(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.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:p,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&F(),z.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),r.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${E.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),r.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function nT(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function rT({open:t,projects:a,onSwitch:s,onClose:o}){const[c,u]=m.useState(""),[d,h]=m.useState(0),g=m.useMemo(()=>nT(a,c),[a,c]);m.useEffect(()=>{t||(u(""),h(0))},[t]),m.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const p=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:p,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>r.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:y.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const ev=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function aT({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=m.useState("destination"),[g,p]=m.useState(s),[y,v]=m.useState(""),[b,S]=m.useState(""),[k,E]=m.useState(""),[C,N]=m.useState([]),[T,A]=m.useState(!1),[B,D]=m.useState(null);if(m.useEffect(()=>{t&&(h("destination"),p(s),v(""),S(""),E(""),D(null))},[t,s]),m.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(L=>L.json()).then(L=>{$&&N(L.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),m.useEffect(()=>{if(!t)return;function $(L){L.key==="Escape"&&(L.preventDefault(),a())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,a]),!t)return null;const F=C.length>0,w=o&&F,O=o,z=ev.test(y),U=g==="existing-plugin"?b.length>0:ev.test(b),H=!T&&z&&(g==="standalone"||U),q=lT(c,g,b,y);async function X(){D(null),A(!0);try{const _=new URLSearchParams;_.set("mode",g),_.set("skillName",y),b&&_.set("pluginName",b);const I=await fetch(`/api/authoring/skill-exists?${_.toString()}`),V=await I.json();if(!I.ok){D(V.error??`Check failed: ${I.status}`);return}if(V.exists){D(`Skill '${y}' already exists${V.path?` at ${V.path}`:""}`);return}}catch(_){D(_ instanceof Error?_.message:String(_));return}finally{A(!1)}const $=new URLSearchParams;$.set("mode",g),$.set("skillName",y),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const L=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=L),a()}async function J(){D(null),A(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),L=await $.json();if(!$.ok||!L.ok){D(L.error??`Create failed: ${$.status}`);return}Tn("skills"),u==null||u({mode:g,skillName:y,pluginName:L.pluginName??null,skillMdPath:L.skillMdPath}),a()}catch($){D($ instanceof Error?$.message:String($))}finally{A(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(Fd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>p("standalone")}),r.jsx(Fd,{title:"Add to existing plugin",subtitle:w?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:g==="existing-plugin",onClick:()=>w&&p("existing-plugin")}),r.jsx(Fd,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&p("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&r.jsx(No,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:$=>S($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:To(!b||U)})}),g==="existing-plugin"&&r.jsx(No,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...To(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>r.jsx("option",{value:$.name,children:$.name},$.path))]})}),r.jsx(No,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:To(!y||z)})}),r.jsx(No,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:k,onChange:$=>E($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...To(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map(($,L)=>r.jsx("div",{children:$},L))]}),B&&r.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:B})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[r.jsx("button",{type:"button",onClick:a,style:Gd,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:tv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:Gd,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!H,style:{...Gd,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void J(),disabled:!H,style:{...tv,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function Fd({title:t,subtitle:a,description:s,icon:o,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function No({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function To(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const tv={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"},Gd={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 lT(t,a,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function Fy(t){return t.trim().toLowerCase()}function sT(t,a){const s=Fy(a);return s?t.filter(o=>o.name.toLowerCase().includes(s)||o.source.toLowerCase().includes(s)):t}function iT(t,a){const s=Fy(a);return s?t.filter(o=>[o.name,o.description??"",o.category??"",o.author??""].join(" ").toLowerCase().includes(s)):t}function oT({open:t,onClose:a,onInstall:s,onUninstall:o,installedNames:c}){const[u,d]=m.useState(null),[h,g]=m.useState([]),[p,y]=m.useState(null),[v,b]=m.useState(null),[S,k]=m.useState(!1),[E,C]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState("");m.useEffect(()=>{p?T(""):B("")},[p]);const D=m.useMemo(()=>sT(h,N),[h,N]),F=m.useMemo(()=>iT((v==null?void 0:v.plugins)??[],A),[v,A]);return m.useEffect(()=>{t&&(k(!0),C(null),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);g(w.marketplaces??[])}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1)))},[t]),m.useEffect(()=>{if(!p){b(null);return}k(!0),C(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(p)}`).then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);b(w)}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1))},[p]),m.useEffect(()=>{if(!t)return;function w(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[p&&r.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:p?(v==null?void 0:v.name)??p:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&r.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!p&&!S&&h.length===0&&!E&&r.jsx(cT,{}),!p&&h.length>0&&r.jsx(nv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!p&&h.length>0&&D.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!p&&D.map(w=>r.jsxs("button",{type:"button",onClick:()=>y(w.name),style:dT,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:w.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.source})]},w.name)),p&&v&&r.jsxs(r.Fragment,{children:[v.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&r.jsx(nv,{value:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&F.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),F.map(w=>{const O=c.has(w.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[w.name,w.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:w.version}),w.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:w.category})]}),w.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:w.description})]}),O&&o?r.jsx("button",{type:"button",disabled:u===w.name,onClick:async()=>{d(w.name);try{await o(w.name)}finally{d(null)}},"aria-label":`Uninstall ${w.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===w.name?"wait":"pointer",opacity:u===w.name?.6:1,fontFamily:"inherit"},children:u===w.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(w.name,p),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:O?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:O?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:O?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:O?"default":"pointer",fontFamily:"inherit",boxShadow:O?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:O?"Installed":"Install"})]})},w.name)})]})]}),!p&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(uT,{onAdded:()=>{Tn("marketplaces"),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>g(w.marketplaces??[]))}})})]})]}):null}function nv({value:t,onChange:a,placeholder:s,ariaLabel:o,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":o,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function cT(){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 uT({onAdded:t}){const[a,s]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(null);async function h(){const g=a.trim();if(g){c(!0),d(null);try{const p=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await p.json().catch(()=>({}));if(!p.ok||!y.ok){d(y.error??`Add failed (${p.status})`);return}s(""),t()}catch(p){d(p instanceof Error?p.message:String(p))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!a.trim()?"not-allowed":"pointer",opacity:o||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const dT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Wd=12;function fT({job:t,onDone:a}){const[s,o]=m.useState([]),[c,u]=m.useState("running"),[d,h]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),a({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const E=k.body.getReader(),C=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=C.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const D of B){const F=D.match(/^data:\s*(.*)$/m);if(F)try{const w=JSON.parse(F[1]);w.type==="stdout"&&w.line?(b=[...b,w.line].slice(-Wd),o(b)):w.type==="stderr"&&w.line?(b=[...b,`⚠ ${w.line}`].slice(-Wd),o(b)):w.type==="done"?(S=w.ok?"ok":"failed",u(S),Dv(),Tn("skills"),a({ok:w.ok??!1,code:w.code??null,lines:b})):w.type==="error"&&w.error&&(b=[...b,`✘ ${w.error}`].slice(-Wd),o(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",p=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?r.jsx(pT,{}):p}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
102
- `)})]})}function pT(){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 mT=3e3,hT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function rv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function xT(){const{toast:t}=_f(),a=m.useRef(new Map),s=m.useCallback(o=>{if(!rv(o.provider))return;const c=Date.now(),u=a.current.get(o.provider)??0;if(c-u<mT)return;a.current.set(o.provider,c);const d=hT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!rv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Gy="vskill.studio.prefs";function Wy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function qy(){const t=Wy();if(!t)return{};try{const a=t.getItem(Gy);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function gT(t,a){const s=Wy();if(s)try{const c={...qy(),[t]:a};s.setItem(Gy,JSON.stringify(c))}catch{}}function vT(t,a){const o=qy()[t];return o===void 0?a:o}const av={open:!1,x:0,y:0,skill:null};function yT(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function _a(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function bT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function jT(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{_a(ne.toasts.permissionDenied,"error");return}_a(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_a(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_a(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_a(ne.toasts.skillDuplicated,"info");return;case"update":_a(ne.toasts.skillUpdated,"info");return;case"uninstall":_a(ne.actions.editPlaceholder,"info");return;case"delete":bT(a);return;default:return}}function ST(t){return t.startsWith("#/create")}function kT(t){return t.startsWith("#/updates")}function Yy(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),a}function wT(){return Yy(ST)}function CT(){return Yy(kT)}const ET=m.lazy(()=>Qs(()=>import("./CommandPalette-DVR-q8QQ.js"),__vite__mapDeps([2,1]))),NT=m.lazy(()=>Qs(()=>import("./CreateSkillPage-CZUWGR8T.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage}))),TT=m.lazy(()=>Qs(()=>Promise.resolve().then(()=>_E),void 0).then(t=>({default:t.UpdatesPanel})));function RT(){return r.jsx(gS,{children:r.jsx(mS,{children:r.jsxs(nN,{children:[r.jsx(AT,{}),r.jsx(gN,{})]})})})}function AT(){var Wn,Et;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=er(),{config:h}=Ha(),{mode:g,resolvedTheme:p,setTheme:y}=zv(),{toast:v}=_f(),[b,S]=m.useState(()=>Bw()),[k]=m.useState(!0),[E,C]=m.useState(!1),[N,T]=m.useState(!1),[A,B]=m.useState(!1),[D,F]=m.useState("overview"),[w,O]=m.useState(av),z=m.useCallback((oe,xe)=>{O(yT(oe,xe))},[]),U=YN(),[H,q]=m.useState(()=>vT("activeAgent",null)),X=m.useCallback(oe=>{q(oe),gT("activeAgent",oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:oe}}))},[]);m.useEffect(()=>{var oe;!H&&((oe=U.response)!=null&&oe.suggested)&&X(U.response.suggested)},[H,(Wn=U.response)==null?void 0:Wn.suggested,X]);const J=m.useMemo(()=>U.response?VN(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=eT(),[se,M]=m.useState(!1),[Y,G]=m.useState(!1),[te,fe]=m.useState("standalone"),ie=m.useCallback((oe="standalone")=>{fe(oe),G(!0)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;ie((Ee==null?void 0:Ee.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",oe),()=>window.removeEventListener("studio:request-create-skill",oe)},[ie]);const[ye,de]=m.useState(!1),[Se,Ae]=m.useState(null);m.useEffect(()=>{function oe(){de(!0)}return window.addEventListener("studio:open-marketplace",oe),()=>window.removeEventListener("studio:open-marketplace",oe)},[]);const _e=m.useMemo(()=>{const oe=new Set;for(const xe of t.skills)xe.source==="plugin"&&xe.pluginName&&oe.add(xe.pluginName);return oe},[t.skills]);af([{key:"p",meta:!0,handler:oe=>{var Ee;const xe=typeof document<"u"?document.activeElement:null;xe&&xe.tagName==="INPUT"||((Ee=oe==null?void 0:oe.preventDefault)==null||Ee.call(oe),M(dn=>!dn))}}],{enabled:!0});const ae=zN(),he=ae.open;m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.provider&&he(Ee.provider)}return window.addEventListener("studio:open-setup-drawer",oe),()=>window.removeEventListener("studio:open-setup-drawer",oe)},[he]);const pe=m.useCallback(()=>{O(av)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.message&&v({message:Ee.message,severity:Ee.severity??"info"})}return window.addEventListener("studio:toast",oe),()=>window.removeEventListener("studio:toast",oe)},[v]),xT();const[ge,je]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Oe(Ee==null?void 0:Ee.provider),je(!0)}return window.addEventListener("studio:open-settings",oe),()=>window.removeEventListener("studio:open-settings",oe)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[at,Nt]=m.useState(null),[ht,Dt]=m.useState(()=>new Set),Tt=m.useRef(!1),Qe=m.useMemo(()=>kN(),[]),tt=m.useCallback(oe=>`${oe.plugin}/${oe.skill}`,[]),be=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.add(tt(oe)),Ee})},[tt]),pt=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.delete(tt(oe)),Ee})},[tt]),Ct=wN({delayMs:1e4,onCommit:oe=>{o(),pt(oe)},onFailure:(oe,xe)=>{pt(oe),v({message:`Couldn't delete ${oe.skill}: ${xe.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{be(oe),Ct.enqueueDelete(oe)}}})}});m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.skill&&Nt(Ee.skill)}return window.addEventListener("studio:request-delete",oe),()=>window.removeEventListener("studio:request-delete",oe)},[]);const Yt=m.useCallback(()=>{const oe=at;if(Nt(null),!oe)return;const xe={plugin:oe.plugin,skill:oe.skill};be(xe),Ct.enqueueDelete(xe);const Ee=Tt.current?"":`Sent to your ${Qe}. Open Trash to restore. `;Tt.current=!0,v({message:`${Ee}Deleted ${oe.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ct.cancelDelete(tt(xe)),pt(xe)}}})},[at,be,pt,Ct,v,Qe,tt]),un=m.useCallback(()=>{Nt(null)},[]),Gt=m.useMemo(()=>t.skills.filter(oe=>!ht.has(tt(oe))),[t.skills,ht,tt]),rn=m.useMemo(()=>t.selectedSkill?t.skills.find(oe=>oe.plugin===t.selectedSkill.plugin&&oe.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=m.useCallback(oe=>{a({plugin:oe.plugin,skill:oe.skill,origin:oe.origin})},[a]),Mt=m.useMemo(()=>{if(!t.selectedSkill)return"";const oe=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${oe})`},[t.selectedSkill]),xt=m.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(oe=>!oe)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);af([{key:"cmd+k",handler:()=>C(oe=>!oe)},{key:"ctrl+k",handler:()=>C(oe=>!oe)},{key:"?",handler:()=>T(oe=>!oe)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(oe=>!oe)},{key:"ctrl+b",handler:()=>B(oe=>!oe)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const gt=wT(),zr=CT()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(TT,{})}):gt?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(NT,{})}):r.jsx(cN,{selectedSkillInfo:rn,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return r.jsxs(r.Fragment,{children:[r.jsx(vS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:r.jsx(Hw,{connected:k}),liveMessage:Mt,topRail:r.jsx(x2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ie("standalone"),projectPickerSlot:$&&$.projects.length>0?r.jsx(tT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0}),sidebar:r.jsx(Rw,{skills:Gt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?r.jsxs(r.Fragment,{children:[r.jsx(PN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:oe=>ae.open(oe)}),r.jsx(qN,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(Uw,{initialWidth:b??Hs,onChange:S}),main:zr,statusBar:r.jsx(N2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Et=h==null?void 0:h.providers)==null?void 0:Et.map(oe=>{const xe=oe.id;return{id:xe,label:oe.label,available:oe.available,kind:xe==="ollama"||xe==="lm-studio"?"start-service":xe==="anthropic"||xe==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(yN,{open:N,onClose:()=>T(!1)}),r.jsx(NN,{open:ae.isOpen,providerKey:ae.providerKey,onClose:ae.close}),r.jsx(jN,{state:w,onClose:pe,onAction:(oe,xe)=>jT(oe,xe)}),E&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(ET,{open:E,onClose:()=>C(!1),commands:xt})}),r.jsx(rT,{open:se,projects:($==null?void 0:$.projects)??[],onSwitch:oe=>{L(oe)},onClose:()=>M(!1)}),r.jsx(aT,{open:Y,onClose:()=>G(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:oe=>{o(),setTimeout(()=>{u(oe.pluginName??"",oe.skillName)},500)}}),r.jsx(oT,{open:ye,onClose:()=>de(!1),installedNames:_e,onInstall:(oe,xe)=>{Ae({plugin:oe,marketplace:xe,ref:`${oe}@${xe}`}),de(!1)},onUninstall:async oe=>{if(window.confirm(`Uninstall ${oe}? This removes the plugin and its skills.`))try{const xe=await fetch(`/api/plugins/${encodeURIComponent(oe)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Ee=await xe.json().catch(()=>({}));if(!xe.ok||!Ee.ok){v({message:Ee.error??`Uninstall failed (${xe.status})`,severity:"error"});return}v({message:`Uninstalled ${oe}.`,severity:"info"}),o()}catch(xe){v({message:xe instanceof Error?xe.message:String(xe),severity:"error"})}}}),r.jsx(Av,{open:ge,onClose:()=>je(!1),initialProvider:Be,onToast:oe=>v({message:oe,severity:"info"})}),r.jsx(fT,{job:Se,onDone:oe=>{oe.ok&&(o(),setTimeout(()=>Ae(null),3e3))}}),r.jsx(SN,{open:at!==null,title:at?`Delete "${at.skill}"?`:"",body:`It will be sent to your ${Qe}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:un})]})}const lv="vskill.migrations.scope-rename.v1",MT={own:"authoring-project",installed:"available-project",global:"available-personal"},LT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function zT(t){if(t.getItem(lv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(LT);if(!c)continue;const[,u,d]=c,h=MT[d];if(!h)continue;const g=t.getItem(o);g!==null&&a.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of a)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(lv,"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{zT(window.localStorage)}catch{}p0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(Dj,{children:r.jsx(S2,{children:r.jsx(RT,{})})})}));export{Jo as E,wv as L,ri as P,Te as R,AE as S,Ha as a,qy as b,NE as c,Qo as d,vT as g,r as j,m as r,ne as s,df as t,K0 as u,gT as w};
101
+ }`})]}),document.body)}function ON({agent:t,focused:a,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function BN({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 IN({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 UN({agent:t,activeAgentId:a,onSwitch:s}){const o=t.id===a,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":$N(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Vd,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Vd,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Vd,{label:ne.scopePicker.statsLastSync,value:t.lastSync?HN(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 Vd({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 Jg(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function HN(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function $N(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function VN(t){const a=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)a.set(o,s);return t.agents.map(s=>{const o=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function PN({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=p.useState(!1),[d,h]=p.useState(null),g=p.useRef(null),m=p.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),y=p.useMemo(()=>m?m.health==="ok"?"var(--color-ok, #22c55e)":m.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[m]),v=p.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),b=p.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(m==null?void 0:m.displayName)??"Select agent"}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(m==null?void 0:m.installedCount)??0," · ",(m==null?void 0:m.globalCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(_N,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const Py="vskill-ccode-banner-dismissed",FN=new Set(["claude-cli","claude-code"]);function GN(){try{return sessionStorage.getItem(Py)==="true"}catch{return!1}}function WN(){try{sessionStorage.setItem(Py,"true")}catch{}}function qN({activeAgentId:t}){const[a,s]=p.useState(()=>GN()),o=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{WN(),s(!0)},[]);return!t||!FN.has(t)||a?null:r.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function YN(){const[t,a]=p.useState(null),[s,o]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const h=await Ce.getAgents();a(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return p.useEffect(()=>{d()},[d]),p.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Eo="workspace",KN=["skills","agents"];async function XN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function QN(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 ZN(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 JN(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 Pd(){for(const t of KN)Tn(t)}function eT(){const{data:t,loading:a,error:s,revalidate:o}=ri(Eo,XN),c=t,u=c==null?void 0:c.projects.find(m=>m.id===c.activeProjectId),d=p.useCallback(async m=>{await QN(m),Tn(Eo),Pd()},[]),h=p.useCallback(async m=>{await ZN(m),Tn(Eo),Pd()},[]),g=p.useCallback(async m=>{await JN(m),Tn(Eo),Pd()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function tT({workspace:t,onSwitch:a,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=p.useState(!1),[h,g]=p.useState(!1),[m,y]=p.useState(""),[v,b]=p.useState(null),[S,k]=p.useState(null),[E,C]=p.useState(null),[N,T]=p.useState(!1),A=p.useRef(null),B=(t==null?void 0:t.projects)??[],D=B.find(z=>z.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function z(U){A.current&&!A.current.contains(U.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function F(){b(null);const z=m.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),y(""),g(!1)}catch(U){const H=U instanceof Error?U.message:String(U);/does not exist/i.test(H)?b(`Path not found on disk: ${z}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function w(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),g(!0)}catch{}else g(!0)}function O(z){if(z.length<=50)return z;const U=z.split("/");return U.length<=4?z:`${U.slice(0,3).join("/")}/…/${U.slice(-2).join("/")}`}return r.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"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:[B.length===0&&r.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),B.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(z=>{const U=c?c(z.path):!1,H=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return r.jsxs("li",{role:"menuitem","data-stale":U?"true":"false",onMouseEnter:()=>k(z.id),onMouseLeave:()=>k(X=>X===z.id?null:X),onClick:()=>{if(!U){if(H){d(!1);return}C(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:U?"not-allowed":"pointer",background:q&&!U?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:U?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:H?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),H&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),U&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:X=>{X.stopPropagation(),o(z.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"})]})})]},z.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&r.jsxs("button",{type:"button",onClick:()=>void w(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.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:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&F(),z.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),r.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${E.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),r.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function nT(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function rT({open:t,projects:a,onSwitch:s,onClose:o}){const[c,u]=p.useState(""),[d,h]=p.useState(0),g=p.useMemo(()=>nT(a,c),[a,c]);p.useEffect(()=>{t||(u(""),h(0))},[t]),p.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const m=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:m,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>r.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:y.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const ev=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function aT({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=p.useState("destination"),[g,m]=p.useState(s),[y,v]=p.useState(""),[b,S]=p.useState(""),[k,E]=p.useState(""),[C,N]=p.useState([]),[T,A]=p.useState(!1),[B,D]=p.useState(null);if(p.useEffect(()=>{t&&(h("destination"),m(s),v(""),S(""),E(""),D(null))},[t,s]),p.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(L=>L.json()).then(L=>{$&&N(L.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),p.useEffect(()=>{if(!t)return;function $(L){L.key==="Escape"&&(L.preventDefault(),a())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,a]),!t)return null;const F=C.length>0,w=o&&F,O=o,z=ev.test(y),U=g==="existing-plugin"?b.length>0:ev.test(b),H=!T&&z&&(g==="standalone"||U),q=lT(c,g,b,y);async function X(){D(null),A(!0);try{const _=new URLSearchParams;_.set("mode",g),_.set("skillName",y),b&&_.set("pluginName",b);const I=await fetch(`/api/authoring/skill-exists?${_.toString()}`),V=await I.json();if(!I.ok){D(V.error??`Check failed: ${I.status}`);return}if(V.exists){D(`Skill '${y}' already exists${V.path?` at ${V.path}`:""}`);return}}catch(_){D(_ instanceof Error?_.message:String(_));return}finally{A(!1)}const $=new URLSearchParams;$.set("mode",g),$.set("skillName",y),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const L=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=L),a()}async function J(){D(null),A(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),L=await $.json();if(!$.ok||!L.ok){D(L.error??`Create failed: ${$.status}`);return}Tn("skills"),u==null||u({mode:g,skillName:y,pluginName:L.pluginName??null,skillMdPath:L.skillMdPath}),a()}catch($){D($ instanceof Error?$.message:String($))}finally{A(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(Fd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>m("standalone")}),r.jsx(Fd,{title:"Add to existing plugin",subtitle:w?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:g==="existing-plugin",onClick:()=>w&&m("existing-plugin")}),r.jsx(Fd,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&m("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&r.jsx(No,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:$=>S($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:To(!b||U)})}),g==="existing-plugin"&&r.jsx(No,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...To(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>r.jsx("option",{value:$.name,children:$.name},$.path))]})}),r.jsx(No,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:To(!y||z)})}),r.jsx(No,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:k,onChange:$=>E($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...To(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map(($,L)=>r.jsx("div",{children:$},L))]}),B&&r.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:B})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[r.jsx("button",{type:"button",onClick:a,style:Gd,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:tv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:Gd,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!H,style:{...Gd,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void J(),disabled:!H,style:{...tv,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function Fd({title:t,subtitle:a,description:s,icon:o,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function No({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function To(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const tv={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"},Gd={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 lT(t,a,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function Fy(t){return t.trim().toLowerCase()}function sT(t,a){const s=Fy(a);return s?t.filter(o=>o.name.toLowerCase().includes(s)||o.source.toLowerCase().includes(s)):t}function iT(t,a){const s=Fy(a);return s?t.filter(o=>[o.name,o.description??"",o.category??"",o.author??""].join(" ").toLowerCase().includes(s)):t}function oT({open:t,onClose:a,onInstall:s,onUninstall:o,installedNames:c}){const[u,d]=p.useState(null),[h,g]=p.useState([]),[m,y]=p.useState(null),[v,b]=p.useState(null),[S,k]=p.useState(!1),[E,C]=p.useState(null),[N,T]=p.useState(""),[A,B]=p.useState("");p.useEffect(()=>{m?T(""):B("")},[m]);const D=p.useMemo(()=>sT(h,N),[h,N]),F=p.useMemo(()=>iT((v==null?void 0:v.plugins)??[],A),[v,A]);return p.useEffect(()=>{t&&(k(!0),C(null),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);g(w.marketplaces??[])}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1)))},[t]),p.useEffect(()=>{if(!m){b(null);return}k(!0),C(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(m)}`).then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);b(w)}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1))},[m]),p.useEffect(()=>{if(!t)return;function w(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[m&&r.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:m?(v==null?void 0:v.name)??m:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&r.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!m&&!S&&h.length===0&&!E&&r.jsx(cT,{}),!m&&h.length>0&&r.jsx(nv,{value:N,onChange:T,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 “",N,"”."]}),!m&&D.map(w=>r.jsxs("button",{type:"button",onClick:()=>y(w.name),style:dT,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:w.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.source})]},w.name)),m&&v&&r.jsxs(r.Fragment,{children:[v.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&r.jsx(nv,{value:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&F.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),F.map(w=>{const O=c.has(w.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[w.name,w.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:w.version}),w.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:w.category})]}),w.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:w.description})]}),O&&o?r.jsx("button",{type:"button",disabled:u===w.name,onClick:async()=>{d(w.name);try{await o(w.name)}finally{d(null)}},"aria-label":`Uninstall ${w.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===w.name?"wait":"pointer",opacity:u===w.name?.6:1,fontFamily:"inherit"},children:u===w.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(w.name,m),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:O?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:O?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:O?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:O?"default":"pointer",fontFamily:"inherit",boxShadow:O?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:O?"Installed":"Install"})]})},w.name)})]})]}),!m&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(uT,{onAdded:()=>{Tn("marketplaces"),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>g(w.marketplaces??[]))}})})]})]}):null}function nv({value:t,onChange:a,placeholder:s,ariaLabel:o,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":o,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function cT(){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 uT({onAdded:t}){const[a,s]=p.useState(""),[o,c]=p.useState(!1),[u,d]=p.useState(null);async function h(){const g=a.trim();if(g){c(!0),d(null);try{const m=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await m.json().catch(()=>({}));if(!m.ok||!y.ok){d(y.error??`Add failed (${m.status})`);return}s(""),t()}catch(m){d(m instanceof Error?m.message:String(m))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!a.trim()?"not-allowed":"pointer",opacity:o||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const dT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Wd=12;function fT({job:t,onDone:a}){const[s,o]=p.useState([]),[c,u]=p.useState("running"),[d,h]=p.useState(!1);if(p.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),a({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const E=k.body.getReader(),C=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=C.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const D of B){const F=D.match(/^data:\s*(.*)$/m);if(F)try{const w=JSON.parse(F[1]);w.type==="stdout"&&w.line?(b=[...b,w.line].slice(-Wd),o(b)):w.type==="stderr"&&w.line?(b=[...b,`⚠ ${w.line}`].slice(-Wd),o(b)):w.type==="done"?(S=w.ok?"ok":"failed",u(S),Dv(),Tn("skills"),a({ok:w.ok??!1,code:w.code??null,lines:b})):w.type==="error"&&w.error&&(b=[...b,`✘ ${w.error}`].slice(-Wd),o(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",m=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?r.jsx(pT,{}):m}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
102
+ `)})]})}function pT(){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 mT=3e3,hT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function rv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function xT(){const{toast:t}=_f(),a=p.useRef(new Map),s=p.useCallback(o=>{if(!rv(o.provider))return;const c=Date.now(),u=a.current.get(o.provider)??0;if(c-u<mT)return;a.current.set(o.provider,c);const d=hT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return p.useEffect(()=>{function o(c){const u=c.detail;!u||!rv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Gy="vskill.studio.prefs";function Wy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function qy(){const t=Wy();if(!t)return{};try{const a=t.getItem(Gy);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function gT(t,a){const s=Wy();if(s)try{const c={...qy(),[t]:a};s.setItem(Gy,JSON.stringify(c))}catch{}}function vT(t,a){const o=qy()[t];return o===void 0?a:o}const av={open:!1,x:0,y:0,skill:null};function yT(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function _a(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function bT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function jT(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{_a(ne.toasts.permissionDenied,"error");return}_a(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_a(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_a(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_a(ne.toasts.skillDuplicated,"info");return;case"update":_a(ne.toasts.skillUpdated,"info");return;case"uninstall":_a(ne.actions.editPlaceholder,"info");return;case"delete":bT(a);return;default:return}}function ST(t){return t.startsWith("#/create")}function kT(t){return t.startsWith("#/updates")}function Yy(t){const[a,s]=p.useState(()=>typeof window<"u"&&t(window.location.hash));return p.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),a}function wT(){return Yy(ST)}function CT(){return Yy(kT)}function ET(){var o,c;if(typeof navigator>"u")return"⌘⇧K";const t=((o=navigator.platform)==null?void 0:o.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function NT(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function TT(){const[t,a]=p.useState("⌘⇧K");p.useEffect(()=>{a(ET())},[]);const s=NT();function o(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:o,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const RT=p.lazy(()=>Ha(()=>import("./CommandPalette-CBrGufxz.js"),__vite__mapDeps([2,1]))),AT=p.lazy(()=>Ha(()=>import("./FindSkillsPalette-D99SoJx3.js"),__vite__mapDeps([3,1])).then(t=>({default:t.FindSkillsPalette}))),MT=p.lazy(()=>Ha(()=>import("./SkillDetailPanel-DzmlOsAc.js"),__vite__mapDeps([4,5,1])).then(t=>({default:t.SkillDetailPanel}))),LT=p.lazy(()=>Ha(()=>import("./CreateSkillPage-DXrpM1On.js"),__vite__mapDeps([6,1])).then(t=>({default:t.CreateSkillPage}))),zT=p.lazy(()=>Ha(()=>Promise.resolve().then(()=>_E),void 0).then(t=>({default:t.UpdatesPanel})));function DT(){return r.jsx(gS,{children:r.jsx(mS,{children:r.jsxs(nN,{children:[r.jsx(_T,{}),r.jsx(gN,{})]})})})}function _T(){var qt,Ie;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=er(),{config:h}=$a(),{mode:g,resolvedTheme:m,setTheme:y}=zv(),{toast:v}=_f(),[b,S]=p.useState(()=>Bw()),[k]=p.useState(!0),[E,C]=p.useState(!1),[N,T]=p.useState(!1),[A,B]=p.useState(!1),[D,F]=p.useState("overview"),[w,O]=p.useState(av),z=p.useCallback((le,Se)=>{O(yT(le,Se))},[]),U=YN(),[H,q]=p.useState(()=>vT("activeAgent",null)),X=p.useCallback(le=>{q(le),gT("activeAgent",le),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:le}}))},[]);p.useEffect(()=>{var le;!H&&((le=U.response)!=null&&le.suggested)&&X(U.response.suggested)},[H,(qt=U.response)==null?void 0:qt.suggested,X]);const J=p.useMemo(()=>U.response?VN(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=eT(),[ie,M]=p.useState(!1),[Y,G]=p.useState(!1),[te,fe]=p.useState("standalone"),oe=p.useCallback((le="standalone")=>{fe(le),G(!0)},[]);p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;oe((Me==null?void 0:Me.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",le),()=>window.removeEventListener("studio:request-create-skill",le)},[oe]);const[ve,de]=p.useState(!1),[je,Re]=p.useState(null);p.useEffect(()=>{function le(){de(!0)}return window.addEventListener("studio:open-marketplace",le),()=>window.removeEventListener("studio:open-marketplace",le)},[]);const _e=p.useMemo(()=>{const le=new Set;for(const Se of t.skills)Se.source==="plugin"&&Se.pluginName&&le.add(Se.pluginName);return le},[t.skills]);af([{key:"p",meta:!0,handler:le=>{var Me;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Me=le==null?void 0:le.preventDefault)==null||Me.call(le),M(Fa=>!Fa))}}],{enabled:!0});const ae=zN(),he=ae.open;p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Me!=null&&Me.provider&&he(Me.provider)}return window.addEventListener("studio:open-setup-drawer",le),()=>window.removeEventListener("studio:open-setup-drawer",le)},[he]);const pe=p.useCallback(()=>{O(av)},[]);p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Me!=null&&Me.message&&v({message:Me.message,severity:Me.severity??"info"})}return window.addEventListener("studio:toast",le),()=>window.removeEventListener("studio:toast",le)},[v]),xT();const[xe,be]=p.useState(!1),[Be,Oe]=p.useState(void 0);p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Oe(Me==null?void 0:Me.provider),be(!0)}return window.addEventListener("studio:open-settings",le),()=>window.removeEventListener("studio:open-settings",le)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[lt,Nt]=p.useState(null),[xt,_t]=p.useState(()=>new Set),Tt=p.useRef(!1),Ze=p.useMemo(()=>kN(),[]),nt=p.useCallback(le=>`${le.plugin}/${le.skill}`,[]),ye=p.useCallback(le=>{_t(Se=>{const Me=new Set(Se);return Me.add(nt(le)),Me})},[nt]),mt=p.useCallback(le=>{_t(Se=>{const Me=new Set(Se);return Me.delete(nt(le)),Me})},[nt]),Et=wN({delayMs:1e4,onCommit:le=>{o(),mt(le)},onFailure:(le,Se)=>{mt(le),v({message:`Couldn't delete ${le.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{ye(le),Et.enqueueDelete(le)}}})}});p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Me!=null&&Me.skill&&Nt(Me.skill)}return window.addEventListener("studio:request-delete",le),()=>window.removeEventListener("studio:request-delete",le)},[]);const Xt=p.useCallback(()=>{const le=lt;if(Nt(null),!le)return;const Se={plugin:le.plugin,skill:le.skill};ye(Se),Et.enqueueDelete(Se);const Me=Tt.current?"":`Sent to your ${Ze}. Open Trash to restore. `;Tt.current=!0,v({message:`${Me}Deleted ${le.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Et.cancelDelete(nt(Se)),mt(Se)}}})},[lt,ye,mt,Et,v,Ze,nt]),fn=p.useCallback(()=>{Nt(null)},[]),Wt=p.useMemo(()=>t.skills.filter(le=>!xt.has(nt(le))),[t.skills,xt,nt]),ln=p.useMemo(()=>t.selectedSkill?t.skills.find(le=>le.plugin===t.selectedSkill.plugin&&le.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=p.useCallback(le=>{a({plugin:le.plugin,skill:le.skill,origin:le.origin})},[a]),Lt=p.useMemo(()=>{if(!t.selectedSkill)return"";const le=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${le})`},[t.selectedSkill]),vt=p.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(le=>!le)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]),[gt,Wn]=p.useState(null);af([{key:"cmd+k",handler:()=>C(le=>!le)},{key:"ctrl+k",handler:()=>C(le=>!le)},{key:"cmd+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>T(le=>!le)},{key:"cmd+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(le=>!le)},{key:"ctrl+b",handler:()=>B(le=>!le)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const zr=wT(),Rt=CT()?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(zT,{})}):zr?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(LT,{})}):r.jsx(cN,{selectedSkillInfo:ln,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return r.jsxs(r.Fragment,{children:[r.jsx(vS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:r.jsx(Hw,{connected:k}),liveMessage:Lt,topRail:r.jsx(x2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>oe("standalone"),projectPickerSlot:$&&$.projects.length>0?r.jsx(tT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0,findSkillsSlot:r.jsx(TT,{})}),sidebar:r.jsx(Rw,{skills:Wt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?r.jsxs(r.Fragment,{children:[r.jsx(PN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:le=>ae.open(le)}),r.jsx(qN,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(Uw,{initialWidth:b??Vs,onChange:S}),main:Rt,statusBar:r.jsx(N2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Ie=h==null?void 0:h.providers)==null?void 0:Ie.map(le=>{const Se=le.id;return{id:Se,label:le.label,available:le.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(yN,{open:N,onClose:()=>T(!1)}),r.jsx(NN,{open:ae.isOpen,providerKey:ae.providerKey,onClose:ae.close}),r.jsx(jN,{state:w,onClose:pe,onAction:(le,Se)=>jT(le,Se)}),E&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(RT,{open:E,onClose:()=>C(!1),commands:vt})}),r.jsx(p.Suspense,{fallback:null,children:r.jsx(AT,{onSelect:le=>{const Se=le.name.split("/");Se.length===3&&Wn({owner:Se[0],repo:Se[1],slug:Se[2],displayName:le.displayName??le.name})}})}),gt&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(MT,{selectedSkill:gt,onClose:()=>Wn(null)})}),r.jsx(rT,{open:ie,projects:($==null?void 0:$.projects)??[],onSwitch:le=>{L(le)},onClose:()=>M(!1)}),r.jsx(aT,{open:Y,onClose:()=>G(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:le=>{o(),setTimeout(()=>{u(le.pluginName??"",le.skillName)},500)}}),r.jsx(oT,{open:ve,onClose:()=>de(!1),installedNames:_e,onInstall:(le,Se)=>{Re({plugin:le,marketplace:Se,ref:`${le}@${Se}`}),de(!1)},onUninstall:async le=>{if(window.confirm(`Uninstall ${le}? This removes the plugin and its skills.`))try{const Se=await fetch(`/api/plugins/${encodeURIComponent(le)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Me=await Se.json().catch(()=>({}));if(!Se.ok||!Me.ok){v({message:Me.error??`Uninstall failed (${Se.status})`,severity:"error"});return}v({message:`Uninstalled ${le}.`,severity:"info"}),o()}catch(Se){v({message:Se instanceof Error?Se.message:String(Se),severity:"error"})}}}),r.jsx(Av,{open:xe,onClose:()=>be(!1),initialProvider:Be,onToast:le=>v({message:le,severity:"info"})}),r.jsx(fT,{job:je,onDone:le=>{le.ok&&(o(),setTimeout(()=>Re(null),3e3))}}),r.jsx(SN,{open:lt!==null,title:lt?`Delete "${lt.skill}"?`:"",body:`It will be sent to your ${Ze}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Xt,onCancel:fn})]})}const lv="vskill.migrations.scope-rename.v1",OT={own:"authoring-project",installed:"available-project",global:"available-personal"},BT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function IT(t){if(t.getItem(lv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(BT);if(!c)continue;const[,u,d]=c,h=OT[d];if(!h)continue;const g=t.getItem(o);g!==null&&a.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of a)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(lv,"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{IT(window.localStorage)}catch{}p0.createRoot(document.getElementById("root")).render(r.jsx(p.StrictMode,{children:r.jsx(Dj,{children:r.jsx(S2,{children:r.jsx(DT,{})})})}));export{Jo as E,wv as L,ai as P,Ne as R,AE as S,Ha as _,$a as a,qy as b,NE as c,Qo as d,vT as g,r as j,p as r,ne as s,df as t,K0 as u,gT as w};