vskill 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents.json +1 -1
- package/dist/eval-ui/assets/{CreateSkillPage-BEBnDBmh.js → CreateSkillPage--g_NEIiD.js} +1 -1
- package/dist/eval-ui/assets/{FindSkillsPalette-MfuQzMDW.js → FindSkillsPalette-XKomH8zI.js} +2 -2
- package/dist/eval-ui/assets/{SearchPaletteCore-B1nVqMQj.js → SearchPaletteCore-DE6FhFNX.js} +1 -1
- package/dist/eval-ui/assets/{SkillDetailPanel-DBrDY92e.js → SkillDetailPanel-BEqkY3lG.js} +1 -1
- package/dist/eval-ui/assets/{UpdateDropdown-DlHKb6L0.js → UpdateDropdown-DcRoBdFQ.js} +1 -1
- package/dist/eval-ui/assets/{index-BRNId4SH.js → index-DhrY6PTA.js} +5 -5
- package/dist/eval-ui/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-DcRoBdFQ.js","assets/fonts-i7Lkz2zN.css","assets/FindSkillsPalette-XKomH8zI.js","assets/SkillDetailPanel-BEqkY3lG.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage--g_NEIiD.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
/* empty css */(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))i(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function Cv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var bd={exports:{}},_s={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -58,11 +58,11 @@ Error generating stack: `+o.message+`
|
|
|
58
58
|
* @license MIT
|
|
59
59
|
*/var Kx="popstate";function Xx(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function F0(t={}){function a(c,u){let{pathname:d="/",search:f="",hash:x=""}=Hl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),sf("",{pathname:d,search:f,hash:x},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),f="";if(d&&d.getAttribute("href")){let x=c.location.href,h=x.indexOf("#");f=h===-1?x:x.slice(0,h)}return f+"#"+(typeof u=="string"?u:Xs(u))}function i(c,u){ir(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return W0(a,s,i,t)}function Zt(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function ir(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function G0(){return Math.random().toString(36).substring(2,10)}function Qx(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 sf(t,a,s=null,i,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?Hl(a):a,state:s,key:a&&a.key||i||G0(),unstable_mask:c}}function Xs({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 Hl(t){let a={};if(t){let s=t.indexOf("#");s>=0&&(a.hash=t.substring(s),t=t.substring(0,s));let i=t.indexOf("?");i>=0&&(a.search=t.substring(i),t=t.substring(0,i)),t&&(a.pathname=t)}return a}function W0(t,a,s,i={}){let{window:c=document.defaultView,v5Compat:u=!1}=i,d=c.history,f="POP",x=null,h=v();h==null&&(h=0,d.replaceState({...d.state,idx:h},""));function v(){return(d.state||{idx:null}).idx}function y(){f="POP";let k=v(),N=k==null?null:k-h;h=k,x&&x({action:f,location:E.location,delta:N})}function b(k,N){f="PUSH";let T=Xx(k)?k:sf(E.location,k,N);s&&s(T,k),h=v()+1;let A=Qx(T,h),B=E.createHref(T.unstable_mask||T);try{d.pushState(A,"",B)}catch(z){if(z instanceof DOMException&&z.name==="DataCloneError")throw z;c.location.assign(B)}u&&x&&x({action:f,location:E.location,delta:1})}function S(k,N){f="REPLACE";let T=Xx(k)?k:sf(E.location,k,N);s&&s(T,k),h=v();let A=Qx(T,h),B=E.createHref(T.unstable_mask||T);d.replaceState(A,"",B),u&&x&&x({action:f,location:E.location,delta:0})}function w(k){return q0(k)}let E={get action(){return f},get location(){return t(c,d)},listen(k){if(x)throw new Error("A history only accepts one active listener");return c.addEventListener(Kx,y),x=k,()=>{c.removeEventListener(Kx,y),x=null}},createHref(k){return a(c,k)},createURL:w,encodeLocation(k){let N=w(k);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(k){return d.go(k)}};return E}function q0(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Zt(s,"No window.location.(origin|href) available to create URL");let i=typeof t=="string"?t:Xs(t);return i=i.replace(/ $/,"%20"),!a&&i.startsWith("//")&&(i=s+i),new URL(i,s)}function Nv(t,a,s="/"){return Y0(t,a,s,!1)}function Y0(t,a,s,i){let c=typeof a=="string"?Hl(a):a,u=Hr(c.pathname||"/",s);if(u==null)return null;let d=Tv(t);K0(d);let f=null;for(let x=0;f==null&&x<d.length;++x){let h=sj(u);f=aj(d[x],h,i)}return f}function Tv(t,a=[],s=[],i="",c=!1){let u=(d,f,x=c,h)=>{let v={relativePath:h===void 0?d.path||"":h,caseSensitive:d.caseSensitive===!0,childrenIndex:f,route:d};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(i)&&x)return;Zt(v.relativePath.startsWith(i),`Absolute route path "${v.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(i.length)}let y=vr([i,v.relativePath]),b=s.concat(v);d.children&&d.children.length>0&&(Zt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Tv(d.children,a,b,y,x)),!(d.path==null&&!d.index)&&a.push({path:y,score:nj(y,d.index),routesMeta:b})};return t.forEach((d,f)=>{var x;if(d.path===""||!((x=d.path)!=null&&x.includes("?")))u(d,f);else for(let h of Rv(d.path))u(d,f,!0,h)}),a}function Rv(t){let a=t.split("/");if(a.length===0)return[];let[s,...i]=a,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(i.length===0)return c?[u,""]:[u];let d=Rv(i.join("/")),f=[];return f.push(...d.map(x=>x===""?u:[u,x].join("/"))),c&&f.push(...d),f.map(x=>t.startsWith("/")&&x===""?"/":x)}function K0(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:rj(a.routesMeta.map(i=>i.childrenIndex),s.routesMeta.map(i=>i.childrenIndex)))}var X0=/^:[\w-]+$/,Q0=3,Z0=2,J0=1,ej=10,tj=-2,Zx=t=>t==="*";function nj(t,a){let s=t.split("/"),i=s.length;return s.some(Zx)&&(i+=tj),a&&(i+=Z0),s.filter(c=>!Zx(c)).reduce((c,u)=>c+(X0.test(u)?Q0:u===""?J0:ej),i)}function rj(t,a){return t.length===a.length&&t.slice(0,-1).every((i,c)=>i===a[c])?t[t.length-1]-a[a.length-1]:0}function aj(t,a,s=!1){let{routesMeta:i}=t,c={},u="/",d=[];for(let f=0;f<i.length;++f){let x=i[f],h=f===i.length-1,v=u==="/"?a:a.slice(u.length)||"/",y=Go({path:x.relativePath,caseSensitive:x.caseSensitive,end:h},v),b=x.route;if(!y&&h&&s&&!i[i.length-1].route.index&&(y=Go({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},v)),!y)return null;Object.assign(c,y.params),d.push({params:c,pathname:vr([u,y.pathname]),pathnameBase:uj(vr([u,y.pathnameBase])),route:b}),y.pathnameBase!=="/"&&(u=vr([u,y.pathnameBase]))}return d}function Go(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,i]=lj(t.path,t.caseSensitive,t.end),c=a.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),f=c.slice(1);return{params:i.reduce((h,{paramName:v,isOptional:y},b)=>{if(v==="*"){let w=f[b]||"";d=u.slice(0,u.length-w.length).replace(/(.)\/+$/,"$1")}const S=f[b];return y&&!S?h[v]=void 0:h[v]=(S||"").replace(/%2F/g,"/"),h},{}),pathname:u,pathnameBase:d,pattern:t}}function lj(t,a=!1,s=!0){ir(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let i=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,f,x,h,v)=>{if(i.push({paramName:f,isOptional:x!=null}),x){let y=v.charAt(h+d.length);return y&&y!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(i.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,a?void 0:"i"),i]}function sj(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return ir(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),t}}function Hr(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let s=a.endsWith("/")?a.length-1:a.length,i=t.charAt(s);return i&&i!=="/"?null:t.slice(s)||"/"}var ij=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function oj(t,a="/"){let{pathname:s,search:i="",hash:c=""}=typeof t=="string"?Hl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Jx(s.substring(1),"/"):u=Jx(s,a)):u=a,{pathname:u,search:dj(i),hash:fj(c)}}function Jx(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 Ed(t,a,s,i){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function cj(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function Av(t){let a=cj(t);return a.map((s,i)=>i===a.length-1?s.pathname:s.pathnameBase)}function Tf(t,a,s,i=!1){let c;typeof t=="string"?c=Hl(t):(c={...t},Zt(!c.pathname||!c.pathname.includes("?"),Ed("?","pathname","search",c)),Zt(!c.pathname||!c.pathname.includes("#"),Ed("#","pathname","hash",c)),Zt(!c.search||!c.search.includes("#"),Ed("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,f;if(d==null)f=s;else{let y=a.length-1;if(!i&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),y-=1;c.pathname=b.join("/")}f=y>=0?a[y]:"/"}let x=oj(c,f),h=d&&d!=="/"&&d.endsWith("/"),v=(u||d===".")&&s.endsWith("/");return!x.pathname.endsWith("/")&&(h||v)&&(x.pathname+="/"),x}var vr=t=>t.join("/").replace(/\/\/+/g,"/"),uj=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),dj=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,fj=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,pj=class{constructor(t,a,s,i=!1){this.status=t,this.statusText=a||"",this.internal=i,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function mj(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function hj(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Lv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Mv(t,a){let s=t;if(typeof s!="string"||!ij.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let i=s,c=!1;if(Lv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),f=Hr(d.pathname,a);d.origin===u.origin&&f!=null?s=f+d.search+d.hash:c=!0}catch{ir(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var zv=["POST","PUT","PATCH","DELETE"];new Set(zv);var xj=["GET",...zv];new Set(xj);var Pl=m.createContext(null);Pl.displayName="DataRouter";var Jo=m.createContext(null);Jo.displayName="DataRouterState";var gj=m.createContext(!1),Dv=m.createContext({isTransitioning:!1});Dv.displayName="ViewTransition";var vj=m.createContext(new Map);vj.displayName="Fetchers";var yj=m.createContext(null);yj.displayName="Await";var nr=m.createContext(null);nr.displayName="Navigation";var ec=m.createContext(null);ec.displayName="Location";var Pr=m.createContext({outlet:null,matches:[],isDataRoute:!1});Pr.displayName="Route";var Rf=m.createContext(null);Rf.displayName="RouteError";var _v="REACT_ROUTER_ERROR",bj="REDIRECT",jj="ROUTE_ERROR_RESPONSE";function Sj(t){if(t.startsWith(`${_v}:${bj}:{`))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 kj(t){if(t.startsWith(`${_v}:${jj}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new pj(a.status,a.statusText,a.data)}catch{}}function wj(t,{relative:a}={}){Zt(ai(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:i}=m.useContext(nr),{hash:c,pathname:u,search:d}=li(t,{relative:a}),f=u;return s!=="/"&&(f=u==="/"?s:vr([s,u])),i.createHref({pathname:f,search:d,hash:c})}function ai(){return m.useContext(ec)!=null}function ya(){return Zt(ai(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(ec).location}var Ov="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Bv(t){m.useContext(nr).static||m.useLayoutEffect(t)}function Cj(){let{isDataRoute:t}=m.useContext(Pr);return t?Ij():Ej()}function Ej(){Zt(ai(),"useNavigate() may be used only in the context of a <Router> component.");let t=m.useContext(Pl),{basename:a,navigator:s}=m.useContext(nr),{matches:i}=m.useContext(Pr),{pathname:c}=ya(),u=JSON.stringify(Av(i)),d=m.useRef(!1);return Bv(()=>{d.current=!0}),m.useCallback((x,h={})=>{if(ir(d.current,Ov),!d.current)return;if(typeof x=="number"){s.go(x);return}let v=Tf(x,JSON.parse(u),c,h.relative==="path");t==null&&a!=="/"&&(v.pathname=v.pathname==="/"?a:vr([a,v.pathname])),(h.replace?s.replace:s.push)(v,h.state,h)},[a,s,u,c,t])}m.createContext(null);function li(t,{relative:a}={}){let{matches:s}=m.useContext(Pr),{pathname:i}=ya(),c=JSON.stringify(Av(s));return m.useMemo(()=>Tf(t,JSON.parse(c),i,a==="path"),[t,c,i,a])}function Nj(t,a,s){Zt(ai(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=m.useContext(nr),{matches:c}=m.useContext(Pr),u=c[c.length-1],d=u?u.params:{},f=u?u.pathname:"/",x=u?u.pathnameBase:"/",h=u&&u.route;{let k=h&&h.path||"";$v(f,!h||k.endsWith("*")||k.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${k}">) 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="${k}"> to <Route path="${k==="/"?"*":`${k}/*`}">.`)}let v=ya(),y;y=v;let b=y.pathname||"/",S=b;if(x!=="/"){let k=x.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(k.length).join("/")}let w=Nv(t,{pathname:S});return ir(h||w!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),ir(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),Mj(w&&w.map(k=>Object.assign({},k,{params:Object.assign({},d,k.params),pathname:vr([x,i.encodeLocation?i.encodeLocation(k.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?x:vr([x,i.encodeLocation?i.encodeLocation(k.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathnameBase])})),c,s)}function Tj(){let t=Bj(),a=mj(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,i="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:i},u={padding:"2px 4px",backgroundColor:i},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=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 Rj=m.createElement(Tj,null),Iv=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=kj(t.digest);s&&(t=s)}let a=t!==void 0?m.createElement(Pr.Provider,{value:this.props.routeContext},m.createElement(Rf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?m.createElement(Aj,{error:t},a):a}};Iv.contextType=gj;var Nd=new WeakMap;function Aj({children:t,error:a}){let{basename:s}=m.useContext(nr);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let i=Sj(a.digest);if(i){let c=Nd.get(a);if(c)throw c;let u=Mv(i.location,s);if(Lv&&!Nd.get(a))if(u.isExternal||i.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:i.replace}));throw Nd.set(a,d),d}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function Lj({routeContext:t,match:a,children:s}){let i=m.useContext(Pl);return i&&i.static&&i.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=a.route.id),m.createElement(Pr.Provider,{value:t},s)}function Mj(t,a=[],s){let i=s==null?void 0:s.state;if(t==null){if(!i)return null;if(i.errors)t=i.matches;else if(a.length===0&&!i.initialized&&i.matches.length>0)t=i.matches;else return null}let c=t,u=i==null?void 0:i.errors;if(u!=null){let v=c.findIndex(y=>y.route.id&&(u==null?void 0:u[y.route.id])!==void 0);Zt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let d=!1,f=-1;if(s&&i){d=i.renderFallback;for(let v=0;v<c.length;v++){let y=c[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(f=v),y.route.id){let{loaderData:b,errors:S}=i,w=y.route.loader&&!b.hasOwnProperty(y.route.id)&&(!S||S[y.route.id]===void 0);if(y.route.lazy||w){s.isStatic&&(d=!0),f>=0?c=c.slice(0,f+1):c=[c[0]];break}}}}let x=s==null?void 0:s.onError,h=i&&x?(v,y)=>{var b,S;x(v,{location:i.location,params:((S=(b=i.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:hj(i.matches),errorInfo:y})}:void 0;return c.reduceRight((v,y,b)=>{let S,w=!1,E=null,k=null;i&&(S=u&&y.route.id?u[y.route.id]:void 0,E=y.route.errorElement||Rj,d&&(f<0&&b===0?($v("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,k=null):f===b&&(w=!0,k=y.route.hydrateFallbackElement||null)));let N=a.concat(c.slice(0,b+1)),T=()=>{let A;return S?A=E:w?A=k:y.route.Component?A=m.createElement(y.route.Component,null):y.route.element?A=y.route.element:A=v,m.createElement(Lj,{match:y,routeContext:{outlet:v,matches:N,isDataRoute:i!=null},children:A})};return i&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?m.createElement(Iv,{location:i.location,revalidation:i.revalidation,component:E,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:h}):T()},null)}function Af(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zj(t){let a=m.useContext(Pl);return Zt(a,Af(t)),a}function Dj(t){let a=m.useContext(Jo);return Zt(a,Af(t)),a}function _j(t){let a=m.useContext(Pr);return Zt(a,Af(t)),a}function Lf(t){let a=_j(t),s=a.matches[a.matches.length-1];return Zt(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function Oj(){return Lf("useRouteId")}function Bj(){var i;let t=m.useContext(Rf),a=Dj("useRouteError"),s=Lf("useRouteError");return t!==void 0?t:(i=a.errors)==null?void 0:i[s]}function Ij(){let{router:t}=zj("useNavigate"),a=Lf("useNavigate"),s=m.useRef(!1);return Bv(()=>{s.current=!0}),m.useCallback(async(c,u={})=>{ir(s.current,Ov),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var eg={};function $v(t,a,s){!a&&!eg[t]&&(eg[t]=!0,ir(!1,s))}m.memo($j);function $j({routes:t,future:a,state:s,isStatic:i,onError:c}){return Nj(t,void 0,{state:s,isStatic:i,onError:c})}function Uj({basename:t="/",children:a=null,location:s,navigationType:i="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Zt(!ai(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let f=t.replace(/^\/*/,"/"),x=m.useMemo(()=>({basename:f,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[f,c,u,d]);typeof s=="string"&&(s=Hl(s));let{pathname:h="/",search:v="",hash:y="",state:b=null,key:S="default",unstable_mask:w}=s,E=m.useMemo(()=>{let k=Hr(h,f);return k==null?null:{location:{pathname:k,search:v,hash:y,state:b,key:S,unstable_mask:w},navigationType:i}},[f,h,v,y,b,S,i,w]);return ir(E!=null,`<Router basename="${f}"> is not able to match the URL "${h}${v}${y}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:m.createElement(nr.Provider,{value:x},m.createElement(ec.Provider,{children:a,value:E}))}var Io="get",$o="application/x-www-form-urlencoded";function tc(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Hj(t){return tc(t)&&t.tagName.toLowerCase()==="button"}function Pj(t){return tc(t)&&t.tagName.toLowerCase()==="form"}function Vj(t){return tc(t)&&t.tagName.toLowerCase()==="input"}function Fj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Gj(t,a){return t.button===0&&(!a||a==="_self")&&!Fj(t)}var Co=null;function Wj(){if(Co===null)try{new FormData(document.createElement("form"),0),Co=!1}catch{Co=!0}return Co}var qj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Td(t){return t!=null&&!qj.has(t)?(ir(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${$o}"`),null):t}function Yj(t,a){let s,i,c,u,d;if(Pj(t)){let f=t.getAttribute("action");i=f?Hr(f,a):null,s=t.getAttribute("method")||Io,c=Td(t.getAttribute("enctype"))||$o,u=new FormData(t)}else if(Hj(t)||Vj(t)&&(t.type==="submit"||t.type==="image")){let f=t.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=t.getAttribute("formaction")||f.getAttribute("action");if(i=x?Hr(x,a):null,s=t.getAttribute("formmethod")||f.getAttribute("method")||Io,c=Td(t.getAttribute("formenctype"))||Td(f.getAttribute("enctype"))||$o,u=new FormData(f,t),!Wj()){let{name:h,type:v,value:y}=t;if(v==="image"){let b=h?`${h}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else h&&u.append(h,y)}}else{if(tc(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Io,i=null,c=$o,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:i,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Mf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Kj(t,a,s,i){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${i}`:c.pathname=`${c.pathname}.${i}`:c.pathname==="/"?c.pathname=`_root.${i}`:a&&Hr(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${i}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${i}`,c}async function Xj(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 Qj(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 Zj(t,a,s){let i=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await Xj(u,s);return d.links?d.links():[]}return[]}));return nS(i.flat(1).filter(Qj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function tg(t,a,s,i,c,u){let d=(x,h)=>s[h]?x.route.id!==s[h].route.id:!0,f=(x,h)=>{var v;return s[h].pathname!==x.pathname||((v=s[h].route.path)==null?void 0:v.endsWith("*"))&&s[h].params["*"]!==x.params["*"]};return u==="assets"?a.filter((x,h)=>d(x,h)||f(x,h)):u==="data"?a.filter((x,h)=>{var y;let v=i.routes[x.route.id];if(!v||!v.hasLoader)return!1;if(d(x,h)||f(x,h))return!0;if(x.route.shouldRevalidate){let b=x.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((y=s[0])==null?void 0:y.params)||{},nextUrl:new URL(t,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function Jj(t,a,{includeHydrateFallback:s}={}){return eS(t.map(i=>{let c=a.routes[i.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function eS(t){return[...new Set(t)]}function tS(t){let a={},s=Object.keys(t).sort();for(let i of s)a[i]=t[i];return a}function nS(t,a){let s=new Set;return new Set(a),t.reduce((i,c)=>{let u=JSON.stringify(tS(c));return s.has(u)||(s.add(u),i.push({key:u,link:c})),i},[])}function Uv(){let t=m.useContext(Pl);return Mf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function rS(){let t=m.useContext(Jo);return Mf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var zf=m.createContext(void 0);zf.displayName="FrameworkContext";function Hv(){let t=m.useContext(zf);return Mf(t,"You must render this element inside a <HydratedRouter> element"),t}function aS(t,a){let s=m.useContext(zf),[i,c]=m.useState(!1),[u,d]=m.useState(!1),{onFocus:f,onBlur:x,onMouseEnter:h,onMouseLeave:v,onTouchStart:y}=a,b=m.useRef(null);m.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let E=N=>{N.forEach(T=>{d(T.isIntersecting)})},k=new IntersectionObserver(E,{threshold:.5});return b.current&&k.observe(b.current),()=>{k.disconnect()}}},[t]),m.useEffect(()=>{if(i){let E=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(E)}}},[i]);let S=()=>{c(!0)},w=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Bs(f,S),onBlur:Bs(x,w),onMouseEnter:Bs(h,S),onMouseLeave:Bs(v,w),onTouchStart:Bs(y,S)}]:[!1,b,{}]}function Bs(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function lS({page:t,...a}){let{router:s}=Uv(),i=m.useMemo(()=>Nv(s.routes,t,s.basename),[s.routes,t,s.basename]);return i?m.createElement(iS,{page:t,matches:i,...a}):null}function sS(t){let{manifest:a,routeModules:s}=Hv(),[i,c]=m.useState([]);return m.useEffect(()=>{let u=!1;return Zj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),i}function iS({page:t,matches:a,...s}){let i=ya(),{future:c,manifest:u,routeModules:d}=Hv(),{basename:f}=Uv(),{loaderData:x,matches:h}=rS(),v=m.useMemo(()=>tg(t,a,h,u,i,"data"),[t,a,h,u,i]),y=m.useMemo(()=>tg(t,a,h,u,i,"assets"),[t,a,h,u,i]),b=m.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let E=new Set,k=!1;if(a.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!v.some(z=>z.route.id===T.route.id)&&T.route.id in x&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?k=!0:E.add(T.route.id))}),E.size===0)return[];let N=Kj(t,f,c.unstable_trailingSlashAwareDataRequests,"data");return k&&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]},[f,c.unstable_trailingSlashAwareDataRequests,x,i,u,v,a,t,d]),S=m.useMemo(()=>Jj(y,u),[y,u]),w=sS(y);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})),w.map(({key:E,link:k})=>m.createElement("link",{key:E,nonce:s.nonce,...k,crossOrigin:k.crossOrigin??s.crossOrigin})))}function oS(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var cS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{cS&&(window.__reactRouterVersion="7.13.1")}catch{}function uS({basename:t,children:a,unstable_useTransitions:s,window:i}){let c=m.useRef();c.current==null&&(c.current=F0({window:i,v5Compat:!0}));let u=c.current,[d,f]=m.useState({action:u.action,location:u.location}),x=m.useCallback(h=>{s===!1?f(h):m.startTransition(()=>f(h))},[s]);return m.useLayoutEffect(()=>u.listen(x),[u,x]),m.createElement(Uj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Pv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Vv=m.forwardRef(function({onClick:a,discover:s="render",prefetch:i="none",relative:c,reloadDocument:u,replace:d,unstable_mask:f,state:x,target:h,to:v,preventScrollReset:y,viewTransition:b,unstable_defaultShouldRevalidate:S,...w},E){let{basename:k,navigator:N,unstable_useTransitions:T}=m.useContext(nr),A=typeof v=="string"&&Pv.test(v),B=Mv(v,k);v=B.to;let z=wj(v,{relative:c}),P=ya(),C=null;if(f){let $=Tf(f,[],P.unstable_mask?P.unstable_mask.pathname:"/",!0);k!=="/"&&($.pathname=$.pathname==="/"?k:vr([k,$.pathname])),C=N.createHref($)}let[O,L,_]=aS(i,w),H=mS(v,{replace:d,unstable_mask:f,state:x,target:h,preventScrollReset:y,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function W($){a&&a($),$.defaultPrevented||H($)}let q=!(B.isExternal||u),ee=m.createElement("a",{...w,..._,href:(q?C:void 0)||B.absoluteURL||z,onClick:q?W:a,ref:oS(E,L),target:h,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?m.createElement(m.Fragment,null,ee,m.createElement(lS,{page:z})):ee});Vv.displayName="Link";var dS=m.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:i="",end:c=!1,style:u,to:d,viewTransition:f,children:x,...h},v){let y=li(d,{relative:h.relative}),b=ya(),S=m.useContext(Jo),{navigator:w,basename:E}=m.useContext(nr),k=S!=null&&yS(y)&&f===!0,N=w.encodeLocation?w.encodeLocation(y).pathname:y.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=Hr(A,E)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let z=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",P=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),C={isActive:z,isPending:P,isTransitioning:k},O=z?a:void 0,L;typeof i=="function"?L=i(C):L=[i,z?"active":null,P?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let _=typeof u=="function"?u(C):u;return m.createElement(Vv,{...h,"aria-current":O,className:L,ref:v,style:_,to:d,viewTransition:f},typeof x=="function"?x(C):x)});dS.displayName="NavLink";var fS=m.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:i,replace:c,state:u,method:d=Io,action:f,onSubmit:x,relative:h,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b,...S},w)=>{let{unstable_useTransitions:E}=m.useContext(nr),k=gS(),N=vS(f,{relative:h}),T=d.toLowerCase()==="get"?"get":"post",A=typeof f=="string"&&Pv.test(f),B=z=>{if(x&&x(z),z.defaultPrevented)return;z.preventDefault();let P=z.nativeEvent.submitter,C=(P==null?void 0:P.getAttribute("formmethod"))||d,O=()=>k(P||z.currentTarget,{fetcherKey:a,method:C,navigate:s,replace:c,state:u,relative:h,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b});E&&s!==!1?m.startTransition(()=>O()):O()};return m.createElement("form",{ref:w,method:T,action:N,onSubmit:i?x:B,...S,"data-discover":!A&&t==="render"?"true":void 0})});fS.displayName="Form";function pS(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Fv(t){let a=m.useContext(Pl);return Zt(a,pS(t)),a}function mS(t,{target:a,replace:s,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:x,unstable_useTransitions:h}={}){let v=Cj(),y=ya(),b=li(t,{relative:d});return m.useCallback(S=>{if(Gj(S,a)){S.preventDefault();let w=s!==void 0?s:Xs(y)===Xs(b),E=()=>v(t,{replace:w,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:x});h?m.startTransition(()=>E()):E()}},[y,v,b,s,i,c,a,t,u,d,f,x,h])}var hS=0,xS=()=>`__${String(++hS)}__`;function gS(){let{router:t}=Fv("useSubmit"),{basename:a}=m.useContext(nr),s=Oj(),i=t.fetch,c=t.navigate;return m.useCallback(async(u,d={})=>{let{action:f,method:x,encType:h,formData:v,body:y}=Yj(u,a);if(d.navigate===!1){let b=d.fetcherKey||xS();await i(b,s,d.action||f,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||x,formEncType:d.encType||h,flushSync:d.flushSync})}else await c(d.action||f,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||x,formEncType:d.encType||h,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[i,c,a,s])}function vS(t,{relative:a}={}){let{basename:s}=m.useContext(nr),i=m.useContext(Pr);Zt(i,"useFormAction must be used inside a RouteContext");let[c]=i.matches.slice(-1),u={...li(t||".",{relative:a})},d=ya();if(t==null){u.search=d.search;let f=new URLSearchParams(u.search),x=f.getAll("index");if(x.some(v=>v==="")){f.delete("index"),x.filter(y=>y).forEach(y=>f.append("index",y));let v=f.toString();u.search=v?`?${v}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:vr([s,u.pathname])),Xs(u)}function yS(t,{relative:a}={}){let s=m.useContext(Dv);Zt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Fv("useViewTransitionState"),c=li(t,{relative:a});if(!s.isTransitioning)return!1;let u=Hr(s.currentLocation.pathname,i)||s.currentLocation.pathname,d=Hr(s.nextLocation.pathname,i)||s.nextLocation.pathname;return Go(c.pathname,d)!=null||Go(c.pathname,u)!=null}var nc=Ev();const bS=Cv(nc),jS="modulepreload",SS=function(t){return"/"+t},ng={},Vl=function(a,s,i){let c=Promise.resolve();if(s&&s.length>0){let d=function(h){return Promise.all(h.map(v=>Promise.resolve(v).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),x=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));c=d(s.map(h=>{if(h=SS(h),h in ng)return;ng[h]=!0;const v=h.endsWith(".css"),y=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${y}`))return;const b=document.createElement("link");if(b.rel=v?"stylesheet":jS,v||(b.as="script"),b.crossOrigin="",b.href=h,x&&b.setAttribute("nonce",x),document.head.appendChild(b),v)return new Promise((S,w)=>{b.addEventListener("load",S),b.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return c.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return a().catch(u)})},kS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Eo(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!kS.test(a)||a==="0.0.0"?null:a}function Gv(t){if(t.preferInstalled){const c=Eo(t.installedCurrentVersion);if(c)return{version:c,versionSource:"registry"}}const a=Eo(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=Eo(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const i=Eo(t.pluginVersion);return i?{version:i,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const rg={own:"authoring-project",installed:"available-project",global:"available-personal"},of=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function wS(t){if(typeof t=="string"){if(of.has(t))return t;if(Object.prototype.hasOwnProperty.call(rg,t))return rg[t]}return"authoring-project"}function CS(t){return t.startsWith("available-")?"available":"authoring"}function ES(t){const a=t.indexOf("-");return t.slice(a+1)}const Jn="";class Ga extends Error{constructor(a,s,i){super(a),this.name="ApiError",this.status=s,this.details=i}}async function Oe(t,a){const s=await fetch(`${Jn}${t}`,a);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText})),c=i&&typeof i=="object"?i:void 0;throw new Ga((i==null?void 0:i.error)||`HTTP ${s.status}`,s.status,c)}return s.json()}async function ag(t,a){const s=await fetch(t,a);return s.status>=502&&s.status<=504?(await new Promise(i=>setTimeout(i,250)),fetch(t,a)):s}function nn(t){return typeof t=="string"&&t.length>0?t:null}function NS(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function Rd(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 TS(t){const a=t??{};let s;a.origin==="source"||a.origin==="installed"?s=a.origin:(s="source",console.warn(`[api.getSkills] skill ${String(a.plugin)}/${String(a.skill)} has invalid origin=${JSON.stringify(a.origin)}; defaulting to 'source'`));let i;a.scope==="own"||a.scope==="installed"||a.scope==="global"?i=a.scope:i=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=i==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&of.has(a.scopeV2)?a.scopeV2:wS(a.scope),d=CS(u),f=ES(u),x=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let h;a.shadowedBy===null?h=null:typeof a.shadowedBy=="string"&&of.has(a.shadowedBy)?h=a.shadowedBy:h=void 0;const v={plugin:typeof a.plugin=="string"?a.plugin:"",skill:typeof a.skill=="string"?a.skill:"",dir:typeof a.dir=="string"?a.dir:"",hasEvals:!!a.hasEvals,hasBenchmark:!!a.hasBenchmark,evalCount:typeof a.evalCount=="number"?a.evalCount:0,assertionCount:typeof a.assertionCount=="number"?a.assertionCount:0,benchmarkStatus:a.benchmarkStatus==="pass"||a.benchmarkStatus==="fail"||a.benchmarkStatus==="pending"||a.benchmarkStatus==="stale"||a.benchmarkStatus==="missing"?a.benchmarkStatus:"missing",lastBenchmark:typeof a.lastBenchmark=="string"?a.lastBenchmark:null,origin:s,scope:i,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:nn(a.symlinkTarget),installMethod:c,sourcePath:nn(a.sourcePath),scopeV2:u,group:d,source:f,pluginName:nn(a.pluginName),pluginNamespace:nn(a.pluginNamespace),pluginMarketplace:nn(a.pluginMarketplace),pluginManifestPath:nn(a.pluginManifestPath),pluginVersion:nn(a.pluginVersion),...typeof a.pluginDisplay=="string"&&a.pluginDisplay?{pluginDisplay:a.pluginDisplay}:{},precedenceRank:x,shadowedBy:h,description:nn(a.description),version:nn(a.version),category:nn(a.category),author:nn(a.author),license:nn(a.license),homepage:nn(a.homepage),repoUrl:nn(a.repoUrl),skillPath:nn(a.skillPath),tags:Rd(a.tags),deps:Rd(a.deps),mcpDeps:Rd(a.mcpDeps),entryPoint:nn(a.entryPoint),lastModified:nn(a.lastModified),sizeBytes:NS(a.sizeBytes),sourceAgent:nn(a.sourceAgent)};if(a.provenance&&typeof a.provenance=="object"){const b=a.provenance;(b.promotedFrom==="installed"||b.promotedFrom==="global")&&typeof b.sourcePath=="string"&&typeof b.promotedAt=="number"?v.provenance={promotedFrom:b.promotedFrom,sourcePath:b.sourcePath,promotedAt:b.promotedAt,sourceSkillVersion:typeof b.sourceSkillVersion=="string"?b.sourceSkillVersion:void 0}:v.provenance=null}else a.provenance===null&&(v.provenance=null);typeof a.updateAvailable=="boolean"&&(v.updateAvailable=a.updateAvailable),typeof a.currentVersion=="string"&&(v.currentVersion=a.currentVersion),typeof a.latestVersion=="string"&&(v.latestVersion=a.latestVersion),typeof a.pinnedVersion=="string"&&(v.pinnedVersion=a.pinnedVersion);const y=Gv({frontmatterVersion:v.version??null,registryCurrentVersion:v.currentVersion??null,pluginVersion:v.pluginVersion??null,installedCurrentVersion:v.currentVersion??null,preferInstalled:v.origin==="installed"});return v.resolvedVersion=y.version,v.versionSource=y.versionSource,v}const ke={getConfig(){return Oe("/api/config")},setConfig(t,a){return Oe("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:a})})},async getSkills(t){const a=new URLSearchParams;t!=null&&t.scope&&a.set("scope",t.scope),t!=null&&t.agent&&a.set("agent",t.agent);const s=a.toString(),i=await Oe(`/api/skills${s?"?"+s:""}`);return Array.isArray(i)?i.map(TS):[]},async convertToPlugin(t){return Oe("/api/authoring/convert-to-plugin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getAgents(){return Oe("/api/agents")},getSkillDetail(t,a){return Oe(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await Oe(`/api/skills/${t}/${a}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:a,evals:[]};const{exists:i,...c}=s;return c}return s},getEvalsEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return Oe(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return Oe(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${Jn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText}));throw new Ga(i.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,s){const i=new URLSearchParams;s!=null&&s.model&&i.set("model",s.model),s!=null&&s.type&&i.set("type",s.type),s!=null&&s.from&&i.set("from",s.from),s!=null&&s.to&&i.set("to",s.to);const c=i.toString();return Oe(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,i){return Oe(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(i)}`)},getCaseHistory(t,a,s,i){const c=new URLSearchParams;i&&c.set("model",i);const u=c.toString();return Oe(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return Oe(`/api/skills/${t}/${a}`,{method:"DELETE"})},uninstallSkill(t,a){return Oe(`/api/skills/${t}/${a}/uninstall`,{method:"POST"})},improveSkill(t,a,s){return Oe(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return Oe(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return Oe(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return Oe(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return Oe(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return Oe("/api/project-layout")},getProjectGitHubStatus(){return Oe("/api/project/github-status")},createSkill(t){return Oe("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return Oe("/api/studio/detect-engines")},saveDraft(t){return Oe("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return Oe("/api/skill-creator-status")},generateSkill(t){return Oe("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return Oe(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return Oe(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,i){return Oe(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:i})})},getLeaderboard(t,a){return Oe(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const i=`${Jn}/api/skills/${t}/${a}/sweep`,c=new EventSource(i);return fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,a){return Oe(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,i){return Oe(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:i})})},getParams(t,a){return Oe(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const i=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return Oe(`/api/credentials/${t}/${a}/params?${i}`)},searchModels(){return Oe("/api/openrouter/models")},async getSkillVersions(t,a){const s=await Oe(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,i){return Oe(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${i}`)},startBatchUpdate(t){const a=`${Jn}/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=`${Jn}/api/skills/${t}/${a}/update`,i=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),i},async postSkillUpdate(t,a,s){let i,c;if(s&&typeof s.aborted=="boolean")i=s;else if(s&&typeof s=="object"){const v=s;i=v.signal,c=v.agentId}const u=c?`?agent=${encodeURIComponent(c)}`:"",d=`${Jn}/api/skills/${t}/${a}/update${u}`,f=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},signal:i});let x,h="";if(f.body){const v=f.body.getReader(),y=new TextDecoder;let b=!1,S="";for(;!b;){const E=await v.read();if(b=E.done,E.value){const k=y.decode(E.value,{stream:!b});S+=k,h.length<200&&(h+=k)}}const w=S.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(w)try{x=JSON.parse(w[1]).version}catch{}h=h.slice(0,200)}else{const v=await f.text();h=v.slice(0,200);const y=v.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(y)try{x=JSON.parse(y[1]).version}catch{}}return{ok:f.ok,status:f.status,body:h,version:x}},async rescanSkill(t,a){const s=`${t}/${a}`,i=await fetch(`${Jn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`rescan failed: HTTP ${i.status}`);return await i.json()},async getSkillUpdates(){try{const t=await fetch(`${Jn}/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 ag(`${Jn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(c=>({name:c,currentVersion:"0.0.0"}))})});if(!s.ok)return[];const i=await s.json().catch(()=>null);return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.results)?i.results.map(c=>({skillId:typeof c.skillId=="string"?c.skillId:typeof c.name=="string"?c.name:"",version:typeof c.version=="string"?c.version:typeof c.latest=="string"?c.latest:"",eventId:typeof c.eventId=="string"?c.eventId:"",publishedAt:typeof c.publishedAt=="string"?c.publishedAt:"",diffSummary:typeof c.diffSummary=="string"?c.diffSummary:void 0,trackedForUpdates:typeof c.trackedForUpdates=="boolean"?c.trackedForUpdates:void 0,updateAvailable:typeof c.updateAvailable=="boolean"?c.updateAvailable:void 0,installed:typeof c.installed=="string"?c.installed:void 0,latest:typeof c.latest=="string"?c.latest:void 0,name:typeof c.name=="string"?c.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const a=await ag(`${Jn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!a.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await a.json().catch(()=>null),i=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(i.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,a,s){const i=s!=null&&s.overwrite?"?overwrite=true":"";return Ad(`/api/skills/${t}/${a}/promote${i}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,s){const i=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&i.set("dest","global"),s!=null&&s.overwrite&&i.set("overwrite","true");const c=i.toString();return Ad(`/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 Ad(`/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 Oe(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return Oe(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Jn}/api/studio/ops/stream`)},gitRemote(){return Oe("/api/git/remote")},gitDiff(){return Oe("/api/git/diff",{method:"POST"})},gitStatus(){return Oe("/api/git/status")},gitCommitMessage(t){return Oe("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})},gitPublish(t){return Oe("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})}};async function Ad(t,a,s){const i=await fetch(`${Jn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!i.ok||!i.body){let v=`HTTP ${i.status}`,y;try{const S=await i.json();S.error&&(v=S.error),typeof S.code=="string"&&(y=S.code)}catch{}const b=new Ga(v,i.status);throw y&&(b.code=y),b}const c=i.body.getReader(),u=new TextDecoder;let d="",f="",x=null,h=null;for(;;){const{done:v,value:y}=await c.read();if(v)break;d+=u.decode(y,{stream:!0});const b=d.split(`
|
|
62
|
-
`);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))f=S.slice(7).trim();else if(S.startsWith("data: ")){let w={};try{w=JSON.parse(S.slice(6))}catch{f="";continue}if(f==="started"||f==="copied"||f==="deleted"||f==="indexed"||f==="done"||f==="error"){const E={type:f,...w};a==null||a(E),E.type==="done"&&(x=E),E.type==="error"&&(h=E)}f=""}}if(h){const v=new Ga(h.message,500);throw v.code=h.code,v}if(!x)throw new Ga("Transfer stream ended without 'done' event",500);return x}function RS(t,a){if(!t||!a)return!1;const s=/^(\d+)\.(\d+)\.(\d+)/,i=t.match(s),c=a.match(s);if(!i||!c)return!1;const[,u,d,f]=i.map(Number),[,x,h,v]=c.map(Number);return u!==x?u>x:d!==h?d>h:f>=v}function AS(t,a){if(!a.length)return t;const s=new Map,i=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(i.set(d,c),u.length>=1){const f=u[u.length-1];s.set(`${f}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=i.get(c.skill),!u)return c;const d=u.updateAvailable&&!RS(c.version,u.latest),f={...c,updateAvailable:d,currentVersion:u.installed,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(f.trackedForUpdates=u.trackedForUpdates);const x=Gv({frontmatterVersion:f.version??null,registryCurrentVersion:f.currentVersion??null,pluginVersion:f.pluginVersion??null,installedCurrentVersion:f.currentVersion??null,preferInstalled:!0});return f.resolvedVersion=x.version,f.versionSource=x.versionSource,f})}const Uo=new Map,Pa=new Map,Hs=new Map;function In(t){Uo.delete(t),Pa.delete(t);const a=Hs.get(t);if(a)for(const s of a)s()}function qa(t,a,s={}){const{ttl:i=3e4,enabled:c=!0}=s,[,u]=m.useState(0),[d,f]=m.useState(void 0),[x,h]=m.useState(0),v=m.useRef(!0),y=m.useRef(t);y.current=t;const b=()=>{f(void 0),In(t),h(E=>E+1)};m.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),m.useEffect(()=>{if(!c)return;const E=()=>{v.current&&h(k=>k+1)};return Hs.has(t)||Hs.set(t,new Set),Hs.get(t).add(E),()=>{var k;(k=Hs.get(t))==null||k.delete(E)}},[t,c]),m.useEffect(()=>{if(!c)return;const E=Uo.get(t);if(!(!E||Date.now()-E.fetchedAt>i))return;if(Pa.has(t)){const A=Pa.get(t),B=()=>{v.current&&y.current===t&&u(z=>z+1)};A.subscribers.push(B);return}const N={promise:Promise.resolve(),subscribers:[]},T=a().then(A=>{Uo.set(t,{data:A,fetchedAt:Date.now()}),Pa.delete(t),v.current&&y.current===t&&(f(void 0),u(B=>B+1));for(const B of N.subscribers)B()},A=>{Pa.delete(t);const B=A instanceof Error?A:new Error(String(A));v.current&&y.current===t&&(f(B),u(z=>z+1));for(const z of N.subscribers)z()});N.promise=T,Pa.set(t,N)},[t,a,i,c,x]);const S=Uo.get(t),w=c&&!S&&!d&&Pa.has(t);return{data:S==null?void 0:S.data,loading:w,error:d,revalidate:b}}function LS(t){const[a,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const i=window.matchMedia(t);s(i.matches);const c=u=>s(u.matches);return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[t]),a}const MS=500,cf="vskill.updates.seenLastId";function zS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(cf)}catch{return null}}function Ld(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(cf):window.localStorage.setItem(cf,t)}catch{}}function DS(){let t=new Map;const a=new Set,s=new Set,i=[];let c=zS();c&&(s.add(c),i.push(c));function u(){t=new Map(t);for(const f of Array.from(a))f()}function d(f){if(!s.has(f)){if(s.add(f),i.push(f),i.length>MS){const x=i.shift();x&&s.delete(x)}c=f,Ld(f)}}return{getSnapshot(){return t},subscribe(f){return a.add(f),()=>{a.delete(f)}},ingest(f){return s.has(f.eventId)?"duplicate":(d(f.eventId),t.set(f.skillId,{skillId:f.skillId,version:f.version,diffSummary:f.diffSummary,eventId:f.eventId,publishedAt:f.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(f){t.has(f)&&(t.delete(f),u())},clearSeen(){s.clear(),i.length=0,c=null,Ld(null)},mergeBulk(f){if(f.length!==0){for(const x of f)t.set(x.skillId,x);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),i.length=0,c=null,Ld(null),u()}}}const Ua=DS(),_S=3e5,OS=500,BS=15e3,IS=6e4,$S=6e4,US="/api/v1/skills/stream";function lg(t){const a=new Map;for(const i of t)a.set(i.name,i);const s=new Map;for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&s.set(c,(s.get(c)??0)+1)}for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&((s.get(c)??0)>1||a.has(c)||a.set(c,i))}return a}function sg(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function HS(t){if(!t||typeof t!="object")return!1;const a=t;return a.type==="skill.updated"&&typeof a.eventId=="string"&&typeof a.skillId=="string"&&typeof a.version=="string"}function PS(t){const a=(t==null?void 0:t.intervalMs)??_S,s=(t==null?void 0:t.debounceMs)??OS,i=(t==null?void 0:t.timeoutMs)??BS,c=(t==null?void 0:t.staleAfterMs)??IS,u=(t==null?void 0:t.disconnectFallbackMs)??$S,d=(t==null?void 0:t.streamUrlBase)??US,f=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),x=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]),[h,v]=m.useState([]),[y,b]=m.useState(()=>new Map),[S,w]=m.useState(0),[E,k]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),z=m.useRef(null),P=m.useRef(null),C=m.useRef(null),O=m.useRef(null),L=m.useRef(!0),[_,H]=m.useState(()=>f?"connecting":"fallback"),W=m.useRef(_);W.current=_;const q=m.useSyncExternalStore(M=>Ua.subscribe(M),()=>Ua.getSnapshot(),()=>Ua.getSnapshot()),ee=q.size,$=m.useCallback(async()=>{k(!0);const M=new AbortController,U=setTimeout(()=>M.abort(),i);try{const K=await Promise.race([ke.getSkillUpdates(),new Promise((Q,ce)=>{M.signal.addEventListener("abort",()=>{ce(new Error("TIMEOUT"))})})]);if(K==="TIMEOUT")throw new Error("TIMEOUT");if(!L.current)return;v(K),b(lg(K)),w(sg(K)),P.current=Date.now(),T(P.current),B(null)}catch(K){if(!L.current)return;B(K instanceof Error?K:new Error(String(K)))}finally{clearTimeout(U),L.current&&k(!1)}},[i]),D=m.useCallback(()=>{if(z.current)return z.current;const M=$().finally(()=>{z.current=null});return z.current=M,M},[$]),I=m.useCallback(()=>{C.current==null&&(C.current=setInterval(()=>{D()},a))},[a,D]),F=m.useCallback(()=>{C.current!=null&&(clearInterval(C.current),C.current=null)},[]);m.useEffect(()=>{L.current=!0,(P.current==null||Date.now()-P.current>c)&&D(),(typeof document>"u"||document.visibilityState!=="hidden")&&I();const K=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){F();return}O.current=setTimeout(()=>{O.current=null,(P.current==null||Date.now()-P.current>c)&&D(),I()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",K),()=>{L.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",K),O.current&&clearTimeout(O.current),F()}},[]);const J=m.useCallback(async M=>{if(M.length!==0)try{const U=await ke.checkSkillUpdates(M);if(!L.current||U.length===0)return;const K=Date.now(),Q=U.filter(Z=>Z.skillId&&Z.eventId&&Z.version).map(Z=>({skillId:Z.skillId,version:Z.version,eventId:Z.eventId,publishedAt:Z.publishedAt,diffSummary:Z.diffSummary,receivedAt:K}));Q.length>0&&Ua.mergeBulk(Q);const ce=U.filter(Z=>typeof Z.trackedForUpdates=="boolean"||typeof Z.updateAvailable=="boolean").map(Z=>({name:Z.name??Z.skillId,installed:Z.installed??"",latest:Z.latest??null,updateAvailable:Z.updateAvailable??!1,trackedForUpdates:typeof Z.trackedForUpdates=="boolean"?Z.trackedForUpdates:void 0}));ce.length>0&&v(Z=>{const ie=new Map;for(const je of Z)ie.set(je.name,je);let X=0;for(const je of ce){const Ne=je.name,Me=ie.get(Ne);if(Me){const Fe={...Me};Me.trackedForUpdates===void 0&&je.trackedForUpdates!==void 0&&(Fe.trackedForUpdates=je.trackedForUpdates),ie.set(Ne,Fe)}else ie.set(Ne,{name:je.name,installed:je.installed??"",latest:je.latest??null,updateAvailable:je.updateAvailable??!1,trackedForUpdates:je.trackedForUpdates}),X+=1}if(X===0&&ie.size===Z.length)return Z;const me=[...ie.values()];return b(lg(me)),w(sg(me)),me})}catch{}},[]);m.useEffect(()=>{const M=f||x;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const U=M.split(","),K=`${d}?skills=${encodeURIComponent(M)}`;let Q=null,ce=null,Z=null;const ie=()=>{ce==null&&(ce=setTimeout(()=>{ce=null,L.current&&W.current!=="connected"&&H("fallback")},u))},X=()=>{ce!=null&&(clearTimeout(ce),ce=null)};ie();const me=1e3,je=()=>{L.current&&Z==null&&(Z=setTimeout(()=>{if(Z=null,!!L.current&&!(Q&&Q.readyState!==EventSource.CLOSED)){if(Q)try{Q.close()}catch{}Fe()}},me))},Ne=Ue=>{if(!L.current)return;let De;try{De=JSON.parse(Ue.data)}catch{return}if(!HS(De)||Ua.ingest(De)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const oe=`${De.skillId} updated to ${De.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:oe,severity:"info",skillId:De.skillId,version:De.version,eventId:De.eventId}}))}},Me=()=>{L.current&&(Ua.clearSeen(),J(U))},Fe=()=>{L.current&&(Q=new EventSource(K),Q.onopen=()=>{L.current&&(X(),H("connected"))},Q.onerror=()=>{L.current&&(ie(),Q&&Q.readyState===EventSource.CLOSED&&je())},Q.onmessage=Ne,Q.addEventListener("gone",Me))};return Fe(),()=>{if(X(),Z!=null&&(clearTimeout(Z),Z=null),Q){try{Q.removeEventListener("gone",Me)}catch{}try{Q.close()}catch{}}}},[f,x,d,u,J]),m.useEffect(()=>{if(!x)return;const M=x.split(",");J(M)},[x,J]);const de=m.useCallback(M=>{Ua.dismiss(M)},[]);return{updates:h,updatesMap:y,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:D,updatesById:q,pushUpdateCount:ee,status:_,dismiss:de}}function VS(t){const a=[];for(const s of t){const i=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!i&&!c)continue;const u={};i&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const FS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function GS(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 Wv=m.createContext(null),qv=Wv;function cr(){const t=m.useContext(qv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function WS({children:t}){const[a,s]=m.useReducer(GS,FS),i=LS("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=m.useState(()=>{try{const J=window.localStorage.getItem("vskill.studio.prefs");if(!J)return null;const de=JSON.parse(J);return typeof de.activeAgent=="string"?de.activeAgent:null}catch{return null}}),[d,f]=m.useState(c!==null);m.useEffect(()=>{function J(de){if(!(de instanceof CustomEvent))return;const M=de.detail;M!=null&&M.agentId&&(u(M.agentId),f(!0))}return window.addEventListener("studio:agent-changed",J),()=>window.removeEventListener("studio:agent-changed",J)},[]),m.useEffect(()=>{if(d)return;let J=!1;return ke.getAgents().then(de=>{if(J)return;const M=(de==null?void 0:de.suggested)??"claude-code";u(U=>U??M),f(!0)}).catch(()=>{J||(u(de=>de??"claude-code"),f(!0))}),()=>{J=!0}},[d]);const x=m.useCallback(()=>{if(!d||!c)return Promise.resolve();s({type:"SET_SKILLS_LOADING",loading:!0});const J={agent:c};return ke.getSkills(J).then(de=>{s({type:"SET_SKILLS",skills:de});const M=window.location.hash,U=M.match(/^#\/skills\/(project|personal|plugin)\/([^/]+)\/([^/?]+)/);if(U){const[,Q,ce,Z]=U,ie=Q,X=de.find(je=>je.plugin===ce&&je.skill===Z&&je.source===ie);if(X){s({type:"SELECT_SKILL",skill:{plugin:ce,skill:Z,origin:X.origin,source:X.source}});return}const me=de.find(je=>je.plugin===ce&&je.skill===Z);me&&s({type:"SELECT_SKILL",skill:{plugin:ce,skill:Z,origin:me.origin,source:me.source}});return}const K=M.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(K){const[,Q,ce]=K,Z=de.find(ie=>ie.plugin===Q&&ie.skill===ce);Z&&s({type:"SELECT_SKILL",skill:{plugin:Q,skill:ce,origin:Z.origin,source:Z.source}})}}).catch(de=>s({type:"SET_SKILLS_ERROR",error:de.message}))},[c,d]);m.useEffect(()=>{x()},[x]);const h=m.useCallback(J=>{s({type:"SELECT_SKILL",skill:J}),window.location.hash=J.source?`/skills/${J.source}/${J.plugin}/${J.skill}`:`/skills/${J.plugin}/${J.skill}`},[]),v=m.useRef(a.skills);m.useEffect(()=>{v.current=a.skills},[a.skills]);const y=m.useCallback((J,de)=>{const M=v.current,U=J?M.find(Z=>Z.plugin===J&&Z.skill===de):M.find(Z=>Z.skill===de&&Z.source!=="plugin");if(!J&&!U){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${de}" not yet in state — skipping reveal`);return}const K=(U==null?void 0:U.plugin)??J,Q=(U==null?void 0:U.origin)??"source",ce=U==null?void 0:U.source;s({type:"REVEAL_SKILL",skill:{plugin:K,skill:de,origin:Q,source:ce}}),window.location.hash=ce?`/skills/${ce}/${K}/${de}`:`/skills/${K}/${de}`},[]),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)},[]),w=m.useCallback(J=>{s({type:"SET_MODE",mode:J})},[]),E=m.useCallback(J=>{s({type:"SET_SEARCH",query:J})},[]),k=m.useCallback(J=>{s({type:"SET_MOBILE_VIEW",view:J})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[z,P]=m.useState(""),C=m.useMemo(()=>a.skills.map(J=>`${J.plugin}/${J.skill}`),[a.skills]),O=m.useMemo(()=>z?z.split(",").filter(Boolean):[],[z]),L=PS({skillIds:O,trackingSkillIds:C}),_=m.useRef("");m.useEffect(()=>{const J=a.skills.filter(Q=>Q.origin==="installed");if(J.length===0){P(""),_.current="";return}const de=new Map;for(const Q of L.updates)de.set(Q.name.split("/").pop()||Q.name,Q);const M=J.map(Q=>{const ce=de.get(Q.skill),Z=Q.currentVersion??(ce==null?void 0:ce.installed)??Q.version??Q.pluginVersion??"1.0.0";return{plugin:Q.plugin,skill:Q.skill,name:(ce==null?void 0:ce.name)??Q.skill,currentVersion:Z}}),U=M.map(Q=>`${Q.plugin}/${Q.skill}@${Q.currentVersion}#${Q.name}`).sort().join("|");if(U===_.current)return;_.current=U;let K=!1;return ke.resolveInstalledSkillIds(M).then(Q=>{if(K)return;const ie=[...VS(Q).flatMap(X=>[X.uuid,X.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(Q.map(X=>[`${X.plugin}/${X.skill}`,{uuid:X.uuid,slug:X.slug}])),P(ie))}).catch(Q=>{if(K||(_.current=""),!B.current){B.current=!0;const ce=Q instanceof Error?Q.message:String(Q);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",ce)}}),()=>{K=!0}},[a.skills,L.updates]);const H=m.useMemo(()=>{const J=a.skills.map(de=>{if(!de.updateAvailable&&de.latestVersion===void 0&&de.trackedForUpdates===void 0)return de;const M={...de};return delete M.updateAvailable,delete M.currentVersion,delete M.latestVersion,delete M.trackedForUpdates,M});return AS(J,L.updates)},[a.skills,L.updates]),W=m.useMemo(()=>{const J={source:0,installed:0};for(const de of H)de.updateAvailable&&(J[de.origin]+=1);return J},[H]),q=m.useMemo(()=>({...a,skills:H}),[a,H]),ee=L.updateCount,$=L.refresh,D=L.isRefreshing,I=m.useCallback((J,de)=>{$(),x(),In(`versions/${J}/${de}`),L.dismiss(`${J}/${de}`)},[$,x,L]),F=m.useMemo(()=>({state:q,selectSkill:h,clearSelection:S,setMode:w,setSearch:E,setMobileView:k,refreshSkills:x,updateCount:ee,dismissUpdateNotification:N,updates:L.updates,outdatedByOrigin:W,isRefreshingUpdates:D,refreshUpdates:$,revealSkill:y,clearReveal:b,updatesById:L.updatesById,pushUpdateCount:L.pushUpdateCount,updateStreamStatus:L.status,dismissPushUpdate:L.dismiss,activeAgent:c,onSkillUpdated:I}),[q,h,S,w,E,k,x,ee,N,L.updates,W,D,$,y,b,L.updatesById,L.pushUpdateCount,L.status,L.dismiss,c,I]);return r.jsx(qv.Provider,{value:F,children:t})}const qS={config:null,loading:!0};function YS(t,a){switch(a.type){case"SET_CONFIG":return{config:a.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Yv=m.createContext(null);function Ya(){const t=m.useContext(Yv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function KS({children:t}){const[a,s]=m.useReducer(YS,qS),i=m.useCallback(()=>{ke.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{i()},[i]);const c=m.useCallback(async(d,f)=>{const x=await ke.setConfig(d,f);return s({type:"SET_CONFIG",config:x}),x},[]),u=m.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:i}),[a,c,i]);return r.jsx(Yv.Provider,{value:u,children:t})}function XS({topRail:t,sidebar:a,main:s,statusBar:i,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:f=320,sidebarHidden:x=!1}){const h={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${f}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},v={display:"grid",gridTemplateColumns:x?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:h,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:v,children:[!x&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!x&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:i}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const QS={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}`},ZS={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"},JS={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"},e2={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"},t2={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"},n2={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"},r2={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."},a2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},l2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},s2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},i2={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"},o2={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)."}},c2={subscriptionBilling:"· subscription",free:"· free"},u2={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`},d2={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.`},f2={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsPlugins:"Plugins",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},p2={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.`},m2={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"},h2={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."},x2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},g2={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"}},le={sidebar:QS,shell:ZS,detail:JS,actions:e2,palette:t2,shortcuts:n2,toasts:r2,connection:a2,forms:l2,errors:s2,picker:i2,providers:o2,models:c2,settings:u2,statusBar:d2,scopePicker:f2,scopeSection:p2,claudeCodeLabel:m2,setupDrawer:h2,setupProviders:g2,scopeLabels:x2},ig=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],v2={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},y2={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},b2={"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"},j2={"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 S2(t,a){var f,x;const s=v2[t.id]??null,i=y2[t.id]??null,c=s?!!((f=a==null?void 0:a.wrapperFolders)!=null&&f[s]):!1,u=i?!!((x=a==null?void 0:a.binaries)!=null&&x[i]):!0,d=t.models.map(h=>({id:h.id,displayName:h.label,billingMode:j2[t.id]??"per-token",...h.pricing?{pricing:h.pricing}:{},...h.resolvedId?{resolvedId:h.resolvedId}:{}}));return{id:t.id,displayName:k2(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:b2[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function k2(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 w2(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of ig){const c=a.get(i);c&&s.push(c)}for(const i of t)ig.includes(i.id)||s.push(i);return s}function C2(t){const[a,s]=m.useState(null),[i,c]=m.useState("loading"),[u,d]=m.useState(null),[f,x]=m.useState(null),h=m.useRef(null),v=m.useRef(0),y=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{y.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=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=w2((A.providers||[]).map(z=>S2(z,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const w=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-v.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&x(`OpenRouter catalog fetch failed (${B.status})`);return}const z=await B.json();v.current=T,x(null),s(O=>{if(!O)return O;const L=O.agents.map(_=>{if(_.id!=="openrouter")return _;const H=z.models.map(q=>({id:q.id,displayName:q.name,contextWindow:q.contextWindow,pricing:q.pricing,billingMode:"per-token"}));return{..._,models:H,catalogAgeMs:z.ageSec?z.ageSec*1e3:0,cacheStale:!!z.stale}});return{...O,agents:L}});const P=z.ageSec??0;(z.stale===!0||P>600)&&((A=y.current)==null||A.call(y,"openrouter",P*1e3))}catch(B){x(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=m.useCallback(T=>{h.current=T,T==="openrouter"&&w()},[w]),k=m.useCallback(()=>{v.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var P,C;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(P=b.current)==null||P.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let z=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(z=O.error)}catch{}(C=b.current)==null||C.call(b,z)},[]);return{status:i,catalog:a,error:u,openRouterError:f,focusAgent:E,refresh:k,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function Md({variant:t,label:a,onActivate:s,installUrl:i,tooltip:c}){function u(f){if(f.stopPropagation(),t==="cli-install"&&i){window.open(i,"_blank","noopener,noreferrer");return}s()}function d(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u(f))}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 uf({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 E2=new Set(["claude-cli","claude-code"]);function og(t){return E2.has(t)}const cg=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function N2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:i,onSelect:c,onOpenSettings:u}){const d=t.filter(x=>cg.has(x.id)),f=t.filter(x=>!cg.has(x.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(x=>r.jsx(ug,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id)),f.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),f.map(x=>r.jsx(ug,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id))]})}function ug({agent:t,isActive:a,isFocused:s,onFocus:i,onSelect:c,onOpenSettings:u}){const{providers:d}=le,f={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},x={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},h=og(t.id),v={minHeight:36,height:h?"auto":36,padding:h?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(v.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>i(t.id),onFocus:()=>i(t.id),onClick:()=>c(t.id),style:v,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),og(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:le.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:le.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(uf,{unlocked:!0,size:10}):r.jsx(uf,{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:le.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(Md,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&x[t.id]&&r.jsx(Md,{variant:"cli-install",label:x[t.id].label,installUrl:x[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(Md,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),f[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:f[t.id]})]})}function T2(t,a,s,i){const d=t>=80,f=m.useRef(null),[x,h]=m.useState(0),v=m.useCallback(S=>{h(S.currentTarget.scrollTop)},[]),{visibleStart:y,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(x/a)-4),w=Math.ceil(s/a)+8,E=Math.min(t,S+w);return{visibleStart:S,visibleEnd:E}},[d,x,a,s,t,4]);return{visibleStart:y,visibleEnd:b,totalHeight:t*a,offsetTop:y*a,virtualised:d,containerProps:{onScroll:v,ref:f,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Kv=44,R2=352,A2=60,dg=480;function L2(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 ${le.models.subscriptionBilling}`:le.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,i=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${i.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function M2(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),f=u.displayName.toLowerCase().indexOf(s);return d!==f?d-f:c.displayName.length-u.displayName.length})}function z2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=m.useState(""),[f,x]=m.useState(""),h=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>x(u),A2);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&h.current&&h.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:dg,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:le.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:le.providers.openrouter.addKeyCta})]});const v=m.useMemo(()=>M2(t.models,f),[t.models,f]),y=T2(v.length,Kv,R2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:dg,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:h,type:"text",placeholder:le.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":le.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),v.length===0&&f?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:le.picker.noMatches(f)}),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:le.picker.clearSearch})]}):v.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:le.picker.noModelsYet}):r.jsx("div",{...y.containerProps,children:r.jsx("div",{style:{height:y.virtualised?y.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:y.virtualised?`translateY(${y.offsetTop}px)`:void 0},children:v.slice(y.visibleStart,y.visibleEnd).map((b,S)=>{const w=y.visibleStart+S;return r.jsx(_2,{model:b,isActive:b.id===a,isFocused:s===w,onSelect:()=>i(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function D2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function _2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=L2(t),d=D2(t.id,c,t.resolvedId),f=d!==null,x=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",h=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:i,title:t.id,style:{width:"100%",minHeight:Kv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:x,borderLeft:h,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}),f&&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 fg={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function O2(){const[t,a]=m.useState(null),[s,i]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{i(!0);try{const h=await fetch("/api/settings/keys");if(!h.ok)throw new Error(`GET /api/settings/keys returned ${h.status}`);const v=await h.json();a({...fg,...v}),u(null)}catch(h){u(h.message),a(fg)}finally{i(!1)}},[]);m.useEffect(()=>{d()},[d]);const f=m.useCallback(async(h,v)=>{const y=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,key:v})});if(!y.ok){const S=await y.json().catch(()=>({error:y.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${y.status}`)}const b=await y.json();return await d(),b},[d]),x=m.useCallback(async h=>{const v=await fetch(`/api/settings/keys/${h}`,{method:"DELETE"});if(!v.ok)throw new Error(`DELETE /api/settings/keys/${h} returned ${v.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:f,remove:x,refresh:d}}function B2({onMigrated:t,fetchImpl:a}){const[s,i]=m.useState({kind:"loading"}),c=a??globalThis.fetch,u=m.useCallback(async()=>{var h;try{const v=await c("/api/settings/migration-status");if(!v.ok){i({kind:"hidden"});return}const y=await v.json();y.pending&&(((h=y.darwinKeys)==null?void 0:h.length)??0)>0?i({kind:"visible",darwinKeys:y.darwinKeys??[]}):i({kind:"hidden"})}catch{i({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{i({kind:"working"});try{const h=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!h.ok){i({kind:"error",message:`Migration failed (${h.status})`});return}const v=await h.json().catch(()=>({migrated:[]}));t==null||t(v.migrated??[]),await u()}catch(h){i({kind:"error",message:h.message})}},[c,u,t]),f=m.useCallback(async()=>{i({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:zd,children:"Retry"})]});const x=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:x,"data-testid":"migration-migrate",style:{...zd,background:"var(--accent, var(--color-accent))",color:"white",opacity:x?.6:1},children:x?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void f(),"data-testid":"migration-dismiss",style:{...zd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const zd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},I2=[{id:"anthropic",name:le.providers.anthropic.name,keyIssuanceUrl:le.providers.anthropic.keyIssuanceUrl,prefix:le.providers.anthropic.keyPrefix,placeholder:`Paste ${le.providers.anthropic.name} key`},{id:"openai",name:le.providers.openai.name,keyIssuanceUrl:le.providers.openai.keyIssuanceUrl,prefix:le.providers.openai.keyPrefix,placeholder:le.providers.openai.pastePlaceholder},{id:"openrouter",name:le.providers.openrouter.name,keyIssuanceUrl:le.providers.openrouter.keyIssuanceUrl,prefix:le.providers.openrouter.keyPrefix,placeholder:`Paste ${le.providers.openrouter.name} key`}];function $2(t){const a=Date.now()-new Date(t).getTime();return a<6e4?"just now":a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:new Date(t).toLocaleString()}function Xv({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:f}=O2(),x=m.useRef(null),h=m.useRef(null),[v,y]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const w=await fetch("/api/settings/storage-path");if(!w.ok)throw new Error(`GET /api/settings/storage-path returned ${w.status}`);const E=await w.json();S||y(E.path??null)}catch{S||y(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,w=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",k=(N=x.current)==null?void 0:N.querySelector(E);k==null||k.focus()},0);return()=>{var E;clearTimeout(w),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=w=>{if(w.key==="Escape"){w.preventDefault(),a();return}if(w.key==="Tab"&&x.current){const E=x.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const k=E[0],N=E[E.length-1];w.shiftKey&&document.activeElement===k?(w.preventDefault(),N.focus()):!w.shiftKey&&document.activeElement===N&&(w.preventDefault(),k.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=m.useCallback(async()=>{var S,w;if(v)try{await((w=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:w.call(S,v)),i==null||i(le.settings.pathCopied)}catch{}},[i,v]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:x,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:le.settings.title}),r.jsx(B2,{onMigrated:()=>{f()}}),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:le.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:le.settings.sectionApiKeys}),I2.map(S=>r.jsx(U2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async w=>{const E=await u(S.id,w);return i==null||i(le.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),i==null||i(le.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?h:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:v?le.settings.storagePath(v):le.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!v,"data-testid":"settings-copy-path",style:{...Va,opacity:v?1:.5,cursor:v?"pointer":"not-allowed"},children:le.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function U2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:f,inputRef:x}){const[h,v]=m.useState(""),[y,b]=m.useState(!1),[S,w]=m.useState(!1),[E,k]=m.useState(!1),[N,T]=m.useState(null),A=h.trim(),B=A.length===0,z=A.length>0&&!A.startsWith(i),P=m.useCallback(async()=>{if(B)return;w(!0);const L=A;v("");try{const _=await d(L);_.warning?T(_.warning):T(null)}finally{w(!1)}},[B,d,A]),C=m.useCallback(async()=>{var L;try{if(!((L=navigator.clipboard)!=null&&L.readText))return;const _=await navigator.clipboard.readText();v(_)}catch{}},[]),O=m.useCallback(async()=>{k(!1),await f()},[f]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:x,type:y?"text":"password",value:h,onChange:L=>{v(L.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!y),style:Va,children:y?le.settings.hide:le.settings.show}),r.jsx("button",{type:"button",onClick:C,style:Va,children:le.settings.paste})]}),z&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:pg,children:le.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:pg,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:P,disabled:B||S,"data-testid":`save-${t}`,style:{...Va,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:le.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:le.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Va,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>k(!1),style:Va,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>k(!0),"data-testid":`remove-${t}`,style:{...Va,color:"var(--text-muted)"},children:le.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?le.settings.keyStoredAt($2(u.updatedAt)):le.settings.noKey})]})]})}const Va={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},pg={fontSize:11,color:"var(--warning, var(--text-muted))"};function H2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function P2({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=C2({onStaleCatalog:(_,H)=>{const W=Math.round(H/6e4);t==null||t(`Using cached ${_} catalog (${W} min old)`)},onSetActiveError:_=>t==null?void 0:t(_)}),[u,d]=m.useState(!1),[f,x]=m.useState(!1),[h,v]=m.useState(),[y,b]=m.useState(null),[S,w]=m.useState("agents"),[E,k]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var _;s&&!y&&b(s.activeAgent??((_=s.agents[0])==null?void 0:_.id)??null)},[s,y]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(_=>_.id===y)??T[0],[T,y]);m.useEffect(()=>{k(0)},[y]);const B=m.useCallback(()=>{var _;d(!0),w("agents"),b((s==null?void 0:s.activeAgent)??((_=T[0])==null?void 0:_.id)??null),k(0)},[s,T]),z=m.useCallback(()=>{var _;d(!1),(_=N.current)==null||_.focus()},[]);m.useEffect(()=>{const _=H=>{var q;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const W=(q=document.activeElement)==null?void 0:q.tagName;W==="INPUT"||W==="TEXTAREA"||(H.preventDefault(),d(ee=>!ee))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[]),m.useEffect(()=>{if(!u)return;const _=W=>{if(W.key==="Escape"){W.preventDefault(),z();return}if(W.key==="ArrowDown"){W.preventDefault(),H(1);return}if(W.key==="ArrowUp"){W.preventDefault(),H(-1);return}if(W.key==="ArrowRight"&&S==="agents"){W.preventDefault(),w("models"),k(q=>{const ee=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(q,Math.max(0,ee)))});return}if(W.key==="ArrowLeft"&&S==="models"){W.preventDefault(),w("agents");return}if(W.key==="Enter"){if(W.preventDefault(),S==="agents"&&A)w("models"),k(0);else if(S==="models"&&A){const q=Math.max(0,Math.min(A.models.length-1,E)),ee=A.models[q];ee&&(c(A.id,ee.id),z())}return}};function H(W){if(S==="agents"){const q=T.findIndex($=>$.id===y),ee=T[Math.max(0,Math.min(T.length-1,q+W))];ee&&(b(ee.id),i(ee.id));return}if(S==="models"&&A){const q=A.models.length;if(q===0)return;k(ee=>{const $=ee+W;return Math.max(0,Math.min(q-1,$))})}}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[u,S,T,y,A,E,z,i,c]);const P=m.useCallback(_=>{v(_==="anthropic"||_==="openrouter"?_:void 0),x(!0),d(!1)},[]),C=T.find(_=>_.id===(s==null?void 0:s.activeAgent)),O=C==null?void 0:C.models.find(_=>_.id===(s==null?void 0:s.activeModel)),L=m.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const _=(C==null?void 0:C.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${_} · ${H}`},[a,s,C,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?z():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:C!=null&&C.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:L})]}),u&&typeof document<"u"&&nc.createPortal(r.jsxs(V2,{reducedMotion:H2(),onClickOutside:z,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(N2,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:y,onFocus:_=>{b(_),i(_)},onSelect:_=>{b(_),i(_),w("models")},onOpenSettings:P}),A&&r.jsx(z2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:_=>{c(A.id,_),z()},onOpenSettings:P})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>P(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:le.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:le.picker.footerHint})]})]}),document.body),r.jsx(Xv,{open:f,onClose:()=>x(!1),initialProvider:h,onToast:t})]})}function V2({children:t,reducedMotion:a,onClickOutside:s}){const i=m.useRef(null);return m.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:i,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
61
|
+
Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}/*`}">.`)}let v=ya(),y;y=v;let b=y.pathname||"/",S=b;if(x!=="/"){let k=x.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(k.length).join("/")}let w=Nv(t,{pathname:S});return ir(h||w!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),ir(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),Mj(w&&w.map(k=>Object.assign({},k,{params:Object.assign({},d,k.params),pathname:vr([x,i.encodeLocation?i.encodeLocation(k.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?x:vr([x,i.encodeLocation?i.encodeLocation(k.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:k.pathnameBase])})),c,s)}function Tj(){let t=Bj(),a=mj(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,i="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:i},u={padding:"2px 4px",backgroundColor:i},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=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 Rj=m.createElement(Tj,null),Iv=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=kj(t.digest);s&&(t=s)}let a=t!==void 0?m.createElement(Pr.Provider,{value:this.props.routeContext},m.createElement(Rf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?m.createElement(Aj,{error:t},a):a}};Iv.contextType=gj;var Nd=new WeakMap;function Aj({children:t,error:a}){let{basename:s}=m.useContext(nr);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let i=Sj(a.digest);if(i){let c=Nd.get(a);if(c)throw c;let u=Mv(i.location,s);if(Lv&&!Nd.get(a))if(u.isExternal||i.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:i.replace}));throw Nd.set(a,d),d}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function Lj({routeContext:t,match:a,children:s}){let i=m.useContext(Pl);return i&&i.static&&i.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=a.route.id),m.createElement(Pr.Provider,{value:t},s)}function Mj(t,a=[],s){let i=s==null?void 0:s.state;if(t==null){if(!i)return null;if(i.errors)t=i.matches;else if(a.length===0&&!i.initialized&&i.matches.length>0)t=i.matches;else return null}let c=t,u=i==null?void 0:i.errors;if(u!=null){let v=c.findIndex(y=>y.route.id&&(u==null?void 0:u[y.route.id])!==void 0);Zt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let d=!1,f=-1;if(s&&i){d=i.renderFallback;for(let v=0;v<c.length;v++){let y=c[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(f=v),y.route.id){let{loaderData:b,errors:S}=i,w=y.route.loader&&!b.hasOwnProperty(y.route.id)&&(!S||S[y.route.id]===void 0);if(y.route.lazy||w){s.isStatic&&(d=!0),f>=0?c=c.slice(0,f+1):c=[c[0]];break}}}}let x=s==null?void 0:s.onError,h=i&&x?(v,y)=>{var b,S;x(v,{location:i.location,params:((S=(b=i.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:hj(i.matches),errorInfo:y})}:void 0;return c.reduceRight((v,y,b)=>{let S,w=!1,E=null,k=null;i&&(S=u&&y.route.id?u[y.route.id]:void 0,E=y.route.errorElement||Rj,d&&(f<0&&b===0?($v("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,k=null):f===b&&(w=!0,k=y.route.hydrateFallbackElement||null)));let N=a.concat(c.slice(0,b+1)),T=()=>{let A;return S?A=E:w?A=k:y.route.Component?A=m.createElement(y.route.Component,null):y.route.element?A=y.route.element:A=v,m.createElement(Lj,{match:y,routeContext:{outlet:v,matches:N,isDataRoute:i!=null},children:A})};return i&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?m.createElement(Iv,{location:i.location,revalidation:i.revalidation,component:E,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:h}):T()},null)}function Af(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zj(t){let a=m.useContext(Pl);return Zt(a,Af(t)),a}function Dj(t){let a=m.useContext(Jo);return Zt(a,Af(t)),a}function _j(t){let a=m.useContext(Pr);return Zt(a,Af(t)),a}function Lf(t){let a=_j(t),s=a.matches[a.matches.length-1];return Zt(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function Oj(){return Lf("useRouteId")}function Bj(){var i;let t=m.useContext(Rf),a=Dj("useRouteError"),s=Lf("useRouteError");return t!==void 0?t:(i=a.errors)==null?void 0:i[s]}function Ij(){let{router:t}=zj("useNavigate"),a=Lf("useNavigate"),s=m.useRef(!1);return Bv(()=>{s.current=!0}),m.useCallback(async(c,u={})=>{ir(s.current,Ov),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var eg={};function $v(t,a,s){!a&&!eg[t]&&(eg[t]=!0,ir(!1,s))}m.memo($j);function $j({routes:t,future:a,state:s,isStatic:i,onError:c}){return Nj(t,void 0,{state:s,isStatic:i,onError:c})}function Uj({basename:t="/",children:a=null,location:s,navigationType:i="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Zt(!ai(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let f=t.replace(/^\/*/,"/"),x=m.useMemo(()=>({basename:f,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[f,c,u,d]);typeof s=="string"&&(s=Hl(s));let{pathname:h="/",search:v="",hash:y="",state:b=null,key:S="default",unstable_mask:w}=s,E=m.useMemo(()=>{let k=Hr(h,f);return k==null?null:{location:{pathname:k,search:v,hash:y,state:b,key:S,unstable_mask:w},navigationType:i}},[f,h,v,y,b,S,i,w]);return ir(E!=null,`<Router basename="${f}"> is not able to match the URL "${h}${v}${y}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:m.createElement(nr.Provider,{value:x},m.createElement(ec.Provider,{children:a,value:E}))}var Io="get",$o="application/x-www-form-urlencoded";function tc(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Hj(t){return tc(t)&&t.tagName.toLowerCase()==="button"}function Pj(t){return tc(t)&&t.tagName.toLowerCase()==="form"}function Vj(t){return tc(t)&&t.tagName.toLowerCase()==="input"}function Fj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Gj(t,a){return t.button===0&&(!a||a==="_self")&&!Fj(t)}var Co=null;function Wj(){if(Co===null)try{new FormData(document.createElement("form"),0),Co=!1}catch{Co=!0}return Co}var qj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Td(t){return t!=null&&!qj.has(t)?(ir(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${$o}"`),null):t}function Yj(t,a){let s,i,c,u,d;if(Pj(t)){let f=t.getAttribute("action");i=f?Hr(f,a):null,s=t.getAttribute("method")||Io,c=Td(t.getAttribute("enctype"))||$o,u=new FormData(t)}else if(Hj(t)||Vj(t)&&(t.type==="submit"||t.type==="image")){let f=t.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let x=t.getAttribute("formaction")||f.getAttribute("action");if(i=x?Hr(x,a):null,s=t.getAttribute("formmethod")||f.getAttribute("method")||Io,c=Td(t.getAttribute("formenctype"))||Td(f.getAttribute("enctype"))||$o,u=new FormData(f,t),!Wj()){let{name:h,type:v,value:y}=t;if(v==="image"){let b=h?`${h}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else h&&u.append(h,y)}}else{if(tc(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Io,i=null,c=$o,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:i,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Mf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Kj(t,a,s,i){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${i}`:c.pathname=`${c.pathname}.${i}`:c.pathname==="/"?c.pathname=`_root.${i}`:a&&Hr(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${i}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${i}`,c}async function Xj(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 Qj(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 Zj(t,a,s){let i=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await Xj(u,s);return d.links?d.links():[]}return[]}));return nS(i.flat(1).filter(Qj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function tg(t,a,s,i,c,u){let d=(x,h)=>s[h]?x.route.id!==s[h].route.id:!0,f=(x,h)=>{var v;return s[h].pathname!==x.pathname||((v=s[h].route.path)==null?void 0:v.endsWith("*"))&&s[h].params["*"]!==x.params["*"]};return u==="assets"?a.filter((x,h)=>d(x,h)||f(x,h)):u==="data"?a.filter((x,h)=>{var y;let v=i.routes[x.route.id];if(!v||!v.hasLoader)return!1;if(d(x,h)||f(x,h))return!0;if(x.route.shouldRevalidate){let b=x.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((y=s[0])==null?void 0:y.params)||{},nextUrl:new URL(t,window.origin),nextParams:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function Jj(t,a,{includeHydrateFallback:s}={}){return eS(t.map(i=>{let c=a.routes[i.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function eS(t){return[...new Set(t)]}function tS(t){let a={},s=Object.keys(t).sort();for(let i of s)a[i]=t[i];return a}function nS(t,a){let s=new Set;return new Set(a),t.reduce((i,c)=>{let u=JSON.stringify(tS(c));return s.has(u)||(s.add(u),i.push({key:u,link:c})),i},[])}function Uv(){let t=m.useContext(Pl);return Mf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function rS(){let t=m.useContext(Jo);return Mf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var zf=m.createContext(void 0);zf.displayName="FrameworkContext";function Hv(){let t=m.useContext(zf);return Mf(t,"You must render this element inside a <HydratedRouter> element"),t}function aS(t,a){let s=m.useContext(zf),[i,c]=m.useState(!1),[u,d]=m.useState(!1),{onFocus:f,onBlur:x,onMouseEnter:h,onMouseLeave:v,onTouchStart:y}=a,b=m.useRef(null);m.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let E=N=>{N.forEach(T=>{d(T.isIntersecting)})},k=new IntersectionObserver(E,{threshold:.5});return b.current&&k.observe(b.current),()=>{k.disconnect()}}},[t]),m.useEffect(()=>{if(i){let E=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(E)}}},[i]);let S=()=>{c(!0)},w=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Bs(f,S),onBlur:Bs(x,w),onMouseEnter:Bs(h,S),onMouseLeave:Bs(v,w),onTouchStart:Bs(y,S)}]:[!1,b,{}]}function Bs(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function lS({page:t,...a}){let{router:s}=Uv(),i=m.useMemo(()=>Nv(s.routes,t,s.basename),[s.routes,t,s.basename]);return i?m.createElement(iS,{page:t,matches:i,...a}):null}function sS(t){let{manifest:a,routeModules:s}=Hv(),[i,c]=m.useState([]);return m.useEffect(()=>{let u=!1;return Zj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),i}function iS({page:t,matches:a,...s}){let i=ya(),{future:c,manifest:u,routeModules:d}=Hv(),{basename:f}=Uv(),{loaderData:x,matches:h}=rS(),v=m.useMemo(()=>tg(t,a,h,u,i,"data"),[t,a,h,u,i]),y=m.useMemo(()=>tg(t,a,h,u,i,"assets"),[t,a,h,u,i]),b=m.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let E=new Set,k=!1;if(a.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!v.some(z=>z.route.id===T.route.id)&&T.route.id in x&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?k=!0:E.add(T.route.id))}),E.size===0)return[];let N=Kj(t,f,c.unstable_trailingSlashAwareDataRequests,"data");return k&&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]},[f,c.unstable_trailingSlashAwareDataRequests,x,i,u,v,a,t,d]),S=m.useMemo(()=>Jj(y,u),[y,u]),w=sS(y);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})),w.map(({key:E,link:k})=>m.createElement("link",{key:E,nonce:s.nonce,...k,crossOrigin:k.crossOrigin??s.crossOrigin})))}function oS(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var cS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{cS&&(window.__reactRouterVersion="7.13.1")}catch{}function uS({basename:t,children:a,unstable_useTransitions:s,window:i}){let c=m.useRef();c.current==null&&(c.current=F0({window:i,v5Compat:!0}));let u=c.current,[d,f]=m.useState({action:u.action,location:u.location}),x=m.useCallback(h=>{s===!1?f(h):m.startTransition(()=>f(h))},[s]);return m.useLayoutEffect(()=>u.listen(x),[u,x]),m.createElement(Uj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Pv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Vv=m.forwardRef(function({onClick:a,discover:s="render",prefetch:i="none",relative:c,reloadDocument:u,replace:d,unstable_mask:f,state:x,target:h,to:v,preventScrollReset:y,viewTransition:b,unstable_defaultShouldRevalidate:S,...w},E){let{basename:k,navigator:N,unstable_useTransitions:T}=m.useContext(nr),A=typeof v=="string"&&Pv.test(v),B=Mv(v,k);v=B.to;let z=wj(v,{relative:c}),P=ya(),C=null;if(f){let $=Tf(f,[],P.unstable_mask?P.unstable_mask.pathname:"/",!0);k!=="/"&&($.pathname=$.pathname==="/"?k:vr([k,$.pathname])),C=N.createHref($)}let[O,L,_]=aS(i,w),H=mS(v,{replace:d,unstable_mask:f,state:x,target:h,preventScrollReset:y,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function W($){a&&a($),$.defaultPrevented||H($)}let q=!(B.isExternal||u),ee=m.createElement("a",{...w,..._,href:(q?C:void 0)||B.absoluteURL||z,onClick:q?W:a,ref:oS(E,L),target:h,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?m.createElement(m.Fragment,null,ee,m.createElement(lS,{page:z})):ee});Vv.displayName="Link";var dS=m.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:i="",end:c=!1,style:u,to:d,viewTransition:f,children:x,...h},v){let y=li(d,{relative:h.relative}),b=ya(),S=m.useContext(Jo),{navigator:w,basename:E}=m.useContext(nr),k=S!=null&&yS(y)&&f===!0,N=w.encodeLocation?w.encodeLocation(y).pathname:y.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=Hr(A,E)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let z=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",P=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),C={isActive:z,isPending:P,isTransitioning:k},O=z?a:void 0,L;typeof i=="function"?L=i(C):L=[i,z?"active":null,P?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let _=typeof u=="function"?u(C):u;return m.createElement(Vv,{...h,"aria-current":O,className:L,ref:v,style:_,to:d,viewTransition:f},typeof x=="function"?x(C):x)});dS.displayName="NavLink";var fS=m.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:i,replace:c,state:u,method:d=Io,action:f,onSubmit:x,relative:h,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b,...S},w)=>{let{unstable_useTransitions:E}=m.useContext(nr),k=gS(),N=vS(f,{relative:h}),T=d.toLowerCase()==="get"?"get":"post",A=typeof f=="string"&&Pv.test(f),B=z=>{if(x&&x(z),z.defaultPrevented)return;z.preventDefault();let P=z.nativeEvent.submitter,C=(P==null?void 0:P.getAttribute("formmethod"))||d,O=()=>k(P||z.currentTarget,{fetcherKey:a,method:C,navigate:s,replace:c,state:u,relative:h,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:b});E&&s!==!1?m.startTransition(()=>O()):O()};return m.createElement("form",{ref:w,method:T,action:N,onSubmit:i?x:B,...S,"data-discover":!A&&t==="render"?"true":void 0})});fS.displayName="Form";function pS(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Fv(t){let a=m.useContext(Pl);return Zt(a,pS(t)),a}function mS(t,{target:a,replace:s,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:x,unstable_useTransitions:h}={}){let v=Cj(),y=ya(),b=li(t,{relative:d});return m.useCallback(S=>{if(Gj(S,a)){S.preventDefault();let w=s!==void 0?s:Xs(y)===Xs(b),E=()=>v(t,{replace:w,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:f,unstable_defaultShouldRevalidate:x});h?m.startTransition(()=>E()):E()}},[y,v,b,s,i,c,a,t,u,d,f,x,h])}var hS=0,xS=()=>`__${String(++hS)}__`;function gS(){let{router:t}=Fv("useSubmit"),{basename:a}=m.useContext(nr),s=Oj(),i=t.fetch,c=t.navigate;return m.useCallback(async(u,d={})=>{let{action:f,method:x,encType:h,formData:v,body:y}=Yj(u,a);if(d.navigate===!1){let b=d.fetcherKey||xS();await i(b,s,d.action||f,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||x,formEncType:d.encType||h,flushSync:d.flushSync})}else await c(d.action||f,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:v,body:y,formMethod:d.method||x,formEncType:d.encType||h,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[i,c,a,s])}function vS(t,{relative:a}={}){let{basename:s}=m.useContext(nr),i=m.useContext(Pr);Zt(i,"useFormAction must be used inside a RouteContext");let[c]=i.matches.slice(-1),u={...li(t||".",{relative:a})},d=ya();if(t==null){u.search=d.search;let f=new URLSearchParams(u.search),x=f.getAll("index");if(x.some(v=>v==="")){f.delete("index"),x.filter(y=>y).forEach(y=>f.append("index",y));let v=f.toString();u.search=v?`?${v}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:vr([s,u.pathname])),Xs(u)}function yS(t,{relative:a}={}){let s=m.useContext(Dv);Zt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Fv("useViewTransitionState"),c=li(t,{relative:a});if(!s.isTransitioning)return!1;let u=Hr(s.currentLocation.pathname,i)||s.currentLocation.pathname,d=Hr(s.nextLocation.pathname,i)||s.nextLocation.pathname;return Go(c.pathname,d)!=null||Go(c.pathname,u)!=null}var nc=Ev();const bS=Cv(nc),jS="modulepreload",SS=function(t){return"/"+t},ng={},Vl=function(a,s,i){let c=Promise.resolve();if(s&&s.length>0){let d=function(h){return Promise.all(h.map(v=>Promise.resolve(v).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),x=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));c=d(s.map(h=>{if(h=SS(h),h in ng)return;ng[h]=!0;const v=h.endsWith(".css"),y=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${y}`))return;const b=document.createElement("link");if(b.rel=v?"stylesheet":jS,v||(b.as="script"),b.crossOrigin="",b.href=h,x&&b.setAttribute("nonce",x),document.head.appendChild(b),v)return new Promise((S,w)=>{b.addEventListener("load",S),b.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return c.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return a().catch(u)})},kS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Eo(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!kS.test(a)||a==="0.0.0"?null:a}function Gv(t){if(t.preferInstalled){const c=Eo(t.installedCurrentVersion);if(c)return{version:c,versionSource:"registry"}}const a=Eo(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=Eo(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const i=Eo(t.pluginVersion);return i?{version:i,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const rg={own:"authoring-project",installed:"available-project",global:"available-personal"},of=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function wS(t){if(typeof t=="string"){if(of.has(t))return t;if(Object.prototype.hasOwnProperty.call(rg,t))return rg[t]}return"authoring-project"}function CS(t){return t.startsWith("available-")?"available":"authoring"}function ES(t){const a=t.indexOf("-");return t.slice(a+1)}const Jn="";class Ga extends Error{constructor(a,s,i){super(a),this.name="ApiError",this.status=s,this.details=i}}async function Oe(t,a){const s=await fetch(`${Jn}${t}`,a);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText})),c=i&&typeof i=="object"?i:void 0;throw new Ga((i==null?void 0:i.error)||`HTTP ${s.status}`,s.status,c)}return s.json()}async function ag(t,a){const s=await fetch(t,a);return s.status>=502&&s.status<=504?(await new Promise(i=>setTimeout(i,250)),fetch(t,a)):s}function nn(t){return typeof t=="string"&&t.length>0?t:null}function NS(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function Rd(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 TS(t){const a=t??{};let s;a.origin==="source"||a.origin==="installed"?s=a.origin:(s="source",console.warn(`[api.getSkills] skill ${String(a.plugin)}/${String(a.skill)} has invalid origin=${JSON.stringify(a.origin)}; defaulting to 'source'`));let i;a.scope==="own"||a.scope==="installed"||a.scope==="global"?i=a.scope:i=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=i==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&of.has(a.scopeV2)?a.scopeV2:wS(a.scope),d=CS(u),f=ES(u),x=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let h;a.shadowedBy===null?h=null:typeof a.shadowedBy=="string"&&of.has(a.shadowedBy)?h=a.shadowedBy:h=void 0;const v={plugin:typeof a.plugin=="string"?a.plugin:"",skill:typeof a.skill=="string"?a.skill:"",dir:typeof a.dir=="string"?a.dir:"",hasEvals:!!a.hasEvals,hasBenchmark:!!a.hasBenchmark,evalCount:typeof a.evalCount=="number"?a.evalCount:0,assertionCount:typeof a.assertionCount=="number"?a.assertionCount:0,benchmarkStatus:a.benchmarkStatus==="pass"||a.benchmarkStatus==="fail"||a.benchmarkStatus==="pending"||a.benchmarkStatus==="stale"||a.benchmarkStatus==="missing"?a.benchmarkStatus:"missing",lastBenchmark:typeof a.lastBenchmark=="string"?a.lastBenchmark:null,origin:s,scope:i,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:nn(a.symlinkTarget),installMethod:c,sourcePath:nn(a.sourcePath),scopeV2:u,group:d,source:f,pluginName:nn(a.pluginName),pluginNamespace:nn(a.pluginNamespace),pluginMarketplace:nn(a.pluginMarketplace),pluginManifestPath:nn(a.pluginManifestPath),pluginVersion:nn(a.pluginVersion),...typeof a.pluginDisplay=="string"&&a.pluginDisplay?{pluginDisplay:a.pluginDisplay}:{},precedenceRank:x,shadowedBy:h,description:nn(a.description),version:nn(a.version),category:nn(a.category),author:nn(a.author),license:nn(a.license),homepage:nn(a.homepage),repoUrl:nn(a.repoUrl),skillPath:nn(a.skillPath),tags:Rd(a.tags),deps:Rd(a.deps),mcpDeps:Rd(a.mcpDeps),entryPoint:nn(a.entryPoint),lastModified:nn(a.lastModified),sizeBytes:NS(a.sizeBytes),sourceAgent:nn(a.sourceAgent)};if(a.provenance&&typeof a.provenance=="object"){const b=a.provenance;(b.promotedFrom==="installed"||b.promotedFrom==="global")&&typeof b.sourcePath=="string"&&typeof b.promotedAt=="number"?v.provenance={promotedFrom:b.promotedFrom,sourcePath:b.sourcePath,promotedAt:b.promotedAt,sourceSkillVersion:typeof b.sourceSkillVersion=="string"?b.sourceSkillVersion:void 0}:v.provenance=null}else a.provenance===null&&(v.provenance=null);typeof a.updateAvailable=="boolean"&&(v.updateAvailable=a.updateAvailable),typeof a.currentVersion=="string"&&(v.currentVersion=a.currentVersion),typeof a.latestVersion=="string"&&(v.latestVersion=a.latestVersion),typeof a.pinnedVersion=="string"&&(v.pinnedVersion=a.pinnedVersion);const y=Gv({frontmatterVersion:v.version??null,registryCurrentVersion:v.currentVersion??null,pluginVersion:v.pluginVersion??null,installedCurrentVersion:v.currentVersion??null,preferInstalled:v.origin==="installed"});return v.resolvedVersion=y.version,v.versionSource=y.versionSource,v}const ke={getConfig(){return Oe("/api/config")},setConfig(t,a){return Oe("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:a})})},async getSkills(t){const a=new URLSearchParams;t!=null&&t.scope&&a.set("scope",t.scope),t!=null&&t.agent&&a.set("agent",t.agent);const s=a.toString(),i=await Oe(`/api/skills${s?"?"+s:""}`);return Array.isArray(i)?i.map(TS):[]},async convertToPlugin(t){return Oe("/api/authoring/convert-to-plugin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getAgents(){return Oe("/api/agents")},getSkillDetail(t,a){return Oe(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await Oe(`/api/skills/${t}/${a}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:a,evals:[]};const{exists:i,...c}=s;return c}return s},getEvalsEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return Oe(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return Oe(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${Jn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText}));throw new Ga(i.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,s){const i=new URLSearchParams;s!=null&&s.model&&i.set("model",s.model),s!=null&&s.type&&i.set("type",s.type),s!=null&&s.from&&i.set("from",s.from),s!=null&&s.to&&i.set("to",s.to);const c=i.toString();return Oe(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,i){return Oe(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(i)}`)},getCaseHistory(t,a,s,i){const c=new URLSearchParams;i&&c.set("model",i);const u=c.toString();return Oe(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return Oe(`/api/skills/${t}/${a}`,{method:"DELETE"})},uninstallSkill(t,a){return Oe(`/api/skills/${t}/${a}/uninstall`,{method:"POST"})},improveSkill(t,a,s){return Oe(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return Oe(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return Oe(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return Oe(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return Oe(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return Oe("/api/project-layout")},getProjectGitHubStatus(){return Oe("/api/project/github-status")},createSkill(t){return Oe("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return Oe("/api/studio/detect-engines")},saveDraft(t){return Oe("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return Oe("/api/skill-creator-status")},generateSkill(t){return Oe("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return Oe(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return Oe(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,i){return Oe(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:i})})},getLeaderboard(t,a){return Oe(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return Oe(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const i=`${Jn}/api/skills/${t}/${a}/sweep`,c=new EventSource(i);return fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,a){return Oe(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,i){return Oe(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:i})})},getParams(t,a){return Oe(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const i=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return Oe(`/api/credentials/${t}/${a}/params?${i}`)},searchModels(){return Oe("/api/openrouter/models")},async getSkillVersions(t,a){const s=await Oe(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return Oe(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,i){return Oe(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${i}`)},startBatchUpdate(t){const a=`${Jn}/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=`${Jn}/api/skills/${t}/${a}/update`,i=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),i},async postSkillUpdate(t,a,s){let i,c;if(s&&typeof s.aborted=="boolean")i=s;else if(s&&typeof s=="object"){const v=s;i=v.signal,c=v.agentId}const u=c?`?agent=${encodeURIComponent(c)}`:"",d=`${Jn}/api/skills/${t}/${a}/update${u}`,f=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},signal:i});let x,h="";if(f.body){const v=f.body.getReader(),y=new TextDecoder;let b=!1,S="";for(;!b;){const E=await v.read();if(b=E.done,E.value){const k=y.decode(E.value,{stream:!b});S+=k,h.length<200&&(h+=k)}}const w=S.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(w)try{x=JSON.parse(w[1]).version}catch{}h=h.slice(0,200)}else{const v=await f.text();h=v.slice(0,200);const y=v.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(y)try{x=JSON.parse(y[1]).version}catch{}}return{ok:f.ok,status:f.status,body:h,version:x}},async rescanSkill(t,a){const s=`${t}/${a}`,i=await fetch(`${Jn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`rescan failed: HTTP ${i.status}`);return await i.json()},async getSkillUpdates(){try{const t=await fetch(`${Jn}/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 ag(`${Jn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(c=>({name:c,currentVersion:"0.0.0"}))})});if(!s.ok)return[];const i=await s.json().catch(()=>null);return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.results)?i.results.map(c=>({skillId:typeof c.skillId=="string"?c.skillId:typeof c.name=="string"?c.name:"",version:typeof c.version=="string"?c.version:typeof c.latest=="string"?c.latest:"",eventId:typeof c.eventId=="string"?c.eventId:"",publishedAt:typeof c.publishedAt=="string"?c.publishedAt:"",diffSummary:typeof c.diffSummary=="string"?c.diffSummary:void 0,trackedForUpdates:typeof c.trackedForUpdates=="boolean"?c.trackedForUpdates:void 0,updateAvailable:typeof c.updateAvailable=="boolean"?c.updateAvailable:void 0,installed:typeof c.installed=="string"&&c.installed!=="0.0.0"?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 ag(`${Jn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!a.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await a.json().catch(()=>null),i=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(i.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,a,s){const i=s!=null&&s.overwrite?"?overwrite=true":"";return Ad(`/api/skills/${t}/${a}/promote${i}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,s){const i=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&i.set("dest","global"),s!=null&&s.overwrite&&i.set("overwrite","true");const c=i.toString();return Ad(`/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 Ad(`/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 Oe(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return Oe(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Jn}/api/studio/ops/stream`)},gitRemote(){return Oe("/api/git/remote")},gitDiff(){return Oe("/api/git/diff",{method:"POST"})},gitStatus(){return Oe("/api/git/status")},gitCommitMessage(t){return Oe("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})},gitPublish(t){return Oe("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})}};async function Ad(t,a,s){const i=await fetch(`${Jn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!i.ok||!i.body){let v=`HTTP ${i.status}`,y;try{const S=await i.json();S.error&&(v=S.error),typeof S.code=="string"&&(y=S.code)}catch{}const b=new Ga(v,i.status);throw y&&(b.code=y),b}const c=i.body.getReader(),u=new TextDecoder;let d="",f="",x=null,h=null;for(;;){const{done:v,value:y}=await c.read();if(v)break;d+=u.decode(y,{stream:!0});const b=d.split(`
|
|
62
|
+
`);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))f=S.slice(7).trim();else if(S.startsWith("data: ")){let w={};try{w=JSON.parse(S.slice(6))}catch{f="";continue}if(f==="started"||f==="copied"||f==="deleted"||f==="indexed"||f==="done"||f==="error"){const E={type:f,...w};a==null||a(E),E.type==="done"&&(x=E),E.type==="error"&&(h=E)}f=""}}if(h){const v=new Ga(h.message,500);throw v.code=h.code,v}if(!x)throw new Ga("Transfer stream ended without 'done' event",500);return x}function RS(t,a){if(!t||!a)return!1;const s=/^(\d+)\.(\d+)\.(\d+)/,i=t.match(s),c=a.match(s);if(!i||!c)return!1;const[,u,d,f]=i.map(Number),[,x,h,v]=c.map(Number);return u!==x?u>x:d!==h?d>h:f>=v}function AS(t,a){if(!a.length)return t;const s=new Map,i=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(i.set(d,c),u.length>=1){const f=u[u.length-1];s.set(`${f}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=i.get(c.skill),!u)return c;const d=u.updateAvailable&&!RS(c.version,u.latest),f=u.installed&&u.installed!=="0.0.0"?u.installed:null,x={...c,updateAvailable:d,currentVersion:f??c.currentVersion,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(x.trackedForUpdates=u.trackedForUpdates);const h=Gv({frontmatterVersion:x.version??null,registryCurrentVersion:x.currentVersion??null,pluginVersion:x.pluginVersion??null,installedCurrentVersion:x.currentVersion??null,preferInstalled:!0});return x.resolvedVersion=h.version,x.versionSource=h.versionSource,x})}const Uo=new Map,Pa=new Map,Hs=new Map;function In(t){Uo.delete(t),Pa.delete(t);const a=Hs.get(t);if(a)for(const s of a)s()}function qa(t,a,s={}){const{ttl:i=3e4,enabled:c=!0}=s,[,u]=m.useState(0),[d,f]=m.useState(void 0),[x,h]=m.useState(0),v=m.useRef(!0),y=m.useRef(t);y.current=t;const b=()=>{f(void 0),In(t),h(E=>E+1)};m.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),m.useEffect(()=>{if(!c)return;const E=()=>{v.current&&h(k=>k+1)};return Hs.has(t)||Hs.set(t,new Set),Hs.get(t).add(E),()=>{var k;(k=Hs.get(t))==null||k.delete(E)}},[t,c]),m.useEffect(()=>{if(!c)return;const E=Uo.get(t);if(!(!E||Date.now()-E.fetchedAt>i))return;if(Pa.has(t)){const A=Pa.get(t),B=()=>{v.current&&y.current===t&&u(z=>z+1)};A.subscribers.push(B);return}const N={promise:Promise.resolve(),subscribers:[]},T=a().then(A=>{Uo.set(t,{data:A,fetchedAt:Date.now()}),Pa.delete(t),v.current&&y.current===t&&(f(void 0),u(B=>B+1));for(const B of N.subscribers)B()},A=>{Pa.delete(t);const B=A instanceof Error?A:new Error(String(A));v.current&&y.current===t&&(f(B),u(z=>z+1));for(const z of N.subscribers)z()});N.promise=T,Pa.set(t,N)},[t,a,i,c,x]);const S=Uo.get(t),w=c&&!S&&!d&&Pa.has(t);return{data:S==null?void 0:S.data,loading:w,error:d,revalidate:b}}function LS(t){const[a,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const i=window.matchMedia(t);s(i.matches);const c=u=>s(u.matches);return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[t]),a}const MS=500,cf="vskill.updates.seenLastId";function zS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(cf)}catch{return null}}function Ld(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(cf):window.localStorage.setItem(cf,t)}catch{}}function DS(){let t=new Map;const a=new Set,s=new Set,i=[];let c=zS();c&&(s.add(c),i.push(c));function u(){t=new Map(t);for(const f of Array.from(a))f()}function d(f){if(!s.has(f)){if(s.add(f),i.push(f),i.length>MS){const x=i.shift();x&&s.delete(x)}c=f,Ld(f)}}return{getSnapshot(){return t},subscribe(f){return a.add(f),()=>{a.delete(f)}},ingest(f){return s.has(f.eventId)?"duplicate":(d(f.eventId),t.set(f.skillId,{skillId:f.skillId,version:f.version,diffSummary:f.diffSummary,eventId:f.eventId,publishedAt:f.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(f){t.has(f)&&(t.delete(f),u())},clearSeen(){s.clear(),i.length=0,c=null,Ld(null)},mergeBulk(f){if(f.length!==0){for(const x of f)t.set(x.skillId,x);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),i.length=0,c=null,Ld(null),u()}}}const Ua=DS(),_S=3e5,OS=500,BS=15e3,IS=6e4,$S=6e4,US="/api/v1/skills/stream";function lg(t){const a=new Map;for(const i of t)a.set(i.name,i);const s=new Map;for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&s.set(c,(s.get(c)??0)+1)}for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&((s.get(c)??0)>1||a.has(c)||a.set(c,i))}return a}function sg(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function HS(t){if(!t||typeof t!="object")return!1;const a=t;return a.type==="skill.updated"&&typeof a.eventId=="string"&&typeof a.skillId=="string"&&typeof a.version=="string"}function PS(t){const a=(t==null?void 0:t.intervalMs)??_S,s=(t==null?void 0:t.debounceMs)??OS,i=(t==null?void 0:t.timeoutMs)??BS,c=(t==null?void 0:t.staleAfterMs)??IS,u=(t==null?void 0:t.disconnectFallbackMs)??$S,d=(t==null?void 0:t.streamUrlBase)??US,f=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),x=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]),[h,v]=m.useState([]),[y,b]=m.useState(()=>new Map),[S,w]=m.useState(0),[E,k]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),z=m.useRef(null),P=m.useRef(null),C=m.useRef(null),O=m.useRef(null),L=m.useRef(!0),[_,H]=m.useState(()=>f?"connecting":"fallback"),W=m.useRef(_);W.current=_;const q=m.useSyncExternalStore(M=>Ua.subscribe(M),()=>Ua.getSnapshot(),()=>Ua.getSnapshot()),ee=q.size,$=m.useCallback(async()=>{k(!0);const M=new AbortController,U=setTimeout(()=>M.abort(),i);try{const K=await Promise.race([ke.getSkillUpdates(),new Promise((Q,ce)=>{M.signal.addEventListener("abort",()=>{ce(new Error("TIMEOUT"))})})]);if(K==="TIMEOUT")throw new Error("TIMEOUT");if(!L.current)return;v(K),b(lg(K)),w(sg(K)),P.current=Date.now(),T(P.current),B(null)}catch(K){if(!L.current)return;B(K instanceof Error?K:new Error(String(K)))}finally{clearTimeout(U),L.current&&k(!1)}},[i]),D=m.useCallback(()=>{if(z.current)return z.current;const M=$().finally(()=>{z.current=null});return z.current=M,M},[$]),I=m.useCallback(()=>{C.current==null&&(C.current=setInterval(()=>{D()},a))},[a,D]),F=m.useCallback(()=>{C.current!=null&&(clearInterval(C.current),C.current=null)},[]);m.useEffect(()=>{L.current=!0,(P.current==null||Date.now()-P.current>c)&&D(),(typeof document>"u"||document.visibilityState!=="hidden")&&I();const K=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){F();return}O.current=setTimeout(()=>{O.current=null,(P.current==null||Date.now()-P.current>c)&&D(),I()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",K),()=>{L.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",K),O.current&&clearTimeout(O.current),F()}},[]);const J=m.useCallback(async M=>{if(M.length!==0)try{const U=await ke.checkSkillUpdates(M);if(!L.current||U.length===0)return;const K=Date.now(),Q=U.filter(Z=>Z.skillId&&Z.eventId&&Z.version).map(Z=>({skillId:Z.skillId,version:Z.version,eventId:Z.eventId,publishedAt:Z.publishedAt,diffSummary:Z.diffSummary,receivedAt:K}));Q.length>0&&Ua.mergeBulk(Q);const ce=U.filter(Z=>typeof Z.trackedForUpdates=="boolean"||typeof Z.updateAvailable=="boolean").map(Z=>({name:Z.name??Z.skillId,installed:Z.installed??"",latest:Z.latest??null,updateAvailable:Z.updateAvailable??!1,trackedForUpdates:typeof Z.trackedForUpdates=="boolean"?Z.trackedForUpdates:void 0}));ce.length>0&&v(Z=>{const ie=new Map;for(const je of Z)ie.set(je.name,je);let X=0;for(const je of ce){const Ne=je.name,Me=ie.get(Ne);if(Me){const Fe={...Me};Me.trackedForUpdates===void 0&&je.trackedForUpdates!==void 0&&(Fe.trackedForUpdates=je.trackedForUpdates),ie.set(Ne,Fe)}else ie.set(Ne,{name:je.name,installed:je.installed??"",latest:je.latest??null,updateAvailable:je.updateAvailable??!1,trackedForUpdates:je.trackedForUpdates}),X+=1}if(X===0&&ie.size===Z.length)return Z;const me=[...ie.values()];return b(lg(me)),w(sg(me)),me})}catch{}},[]);m.useEffect(()=>{const M=f||x;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const U=M.split(","),K=`${d}?skills=${encodeURIComponent(M)}`;let Q=null,ce=null,Z=null;const ie=()=>{ce==null&&(ce=setTimeout(()=>{ce=null,L.current&&W.current!=="connected"&&H("fallback")},u))},X=()=>{ce!=null&&(clearTimeout(ce),ce=null)};ie();const me=1e3,je=()=>{L.current&&Z==null&&(Z=setTimeout(()=>{if(Z=null,!!L.current&&!(Q&&Q.readyState!==EventSource.CLOSED)){if(Q)try{Q.close()}catch{}Fe()}},me))},Ne=Ue=>{if(!L.current)return;let De;try{De=JSON.parse(Ue.data)}catch{return}if(!HS(De)||Ua.ingest(De)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const oe=`${De.skillId} updated to ${De.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:oe,severity:"info",skillId:De.skillId,version:De.version,eventId:De.eventId}}))}},Me=()=>{L.current&&(Ua.clearSeen(),J(U))},Fe=()=>{L.current&&(Q=new EventSource(K),Q.onopen=()=>{L.current&&(X(),H("connected"))},Q.onerror=()=>{L.current&&(ie(),Q&&Q.readyState===EventSource.CLOSED&&je())},Q.onmessage=Ne,Q.addEventListener("gone",Me))};return Fe(),()=>{if(X(),Z!=null&&(clearTimeout(Z),Z=null),Q){try{Q.removeEventListener("gone",Me)}catch{}try{Q.close()}catch{}}}},[f,x,d,u,J]),m.useEffect(()=>{if(!x)return;const M=x.split(",");J(M)},[x,J]);const de=m.useCallback(M=>{Ua.dismiss(M)},[]);return{updates:h,updatesMap:y,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:D,updatesById:q,pushUpdateCount:ee,status:_,dismiss:de}}function VS(t){const a=[];for(const s of t){const i=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!i&&!c)continue;const u={};i&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const FS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function GS(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 Wv=m.createContext(null),qv=Wv;function cr(){const t=m.useContext(qv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function WS({children:t}){const[a,s]=m.useReducer(GS,FS),i=LS("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=m.useState(()=>{try{const J=window.localStorage.getItem("vskill.studio.prefs");if(!J)return null;const de=JSON.parse(J);return typeof de.activeAgent=="string"?de.activeAgent:null}catch{return null}}),[d,f]=m.useState(c!==null);m.useEffect(()=>{function J(de){if(!(de instanceof CustomEvent))return;const M=de.detail;M!=null&&M.agentId&&(u(M.agentId),f(!0))}return window.addEventListener("studio:agent-changed",J),()=>window.removeEventListener("studio:agent-changed",J)},[]),m.useEffect(()=>{if(d)return;let J=!1;return ke.getAgents().then(de=>{if(J)return;const M=(de==null?void 0:de.suggested)??"claude-code";u(U=>U??M),f(!0)}).catch(()=>{J||(u(de=>de??"claude-code"),f(!0))}),()=>{J=!0}},[d]);const x=m.useCallback(()=>{if(!d||!c)return Promise.resolve();s({type:"SET_SKILLS_LOADING",loading:!0});const J={agent:c};return ke.getSkills(J).then(de=>{s({type:"SET_SKILLS",skills:de});const M=window.location.hash,U=M.match(/^#\/skills\/(project|personal|plugin)\/([^/]+)\/([^/?]+)/);if(U){const[,Q,ce,Z]=U,ie=Q,X=de.find(je=>je.plugin===ce&&je.skill===Z&&je.source===ie);if(X){s({type:"SELECT_SKILL",skill:{plugin:ce,skill:Z,origin:X.origin,source:X.source}});return}const me=de.find(je=>je.plugin===ce&&je.skill===Z);me&&s({type:"SELECT_SKILL",skill:{plugin:ce,skill:Z,origin:me.origin,source:me.source}});return}const K=M.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(K){const[,Q,ce]=K,Z=de.find(ie=>ie.plugin===Q&&ie.skill===ce);Z&&s({type:"SELECT_SKILL",skill:{plugin:Q,skill:ce,origin:Z.origin,source:Z.source}})}}).catch(de=>s({type:"SET_SKILLS_ERROR",error:de.message}))},[c,d]);m.useEffect(()=>{x()},[x]);const h=m.useCallback(J=>{s({type:"SELECT_SKILL",skill:J}),window.location.hash=J.source?`/skills/${J.source}/${J.plugin}/${J.skill}`:`/skills/${J.plugin}/${J.skill}`},[]),v=m.useRef(a.skills);m.useEffect(()=>{v.current=a.skills},[a.skills]);const y=m.useCallback((J,de)=>{const M=v.current,U=J?M.find(Z=>Z.plugin===J&&Z.skill===de):M.find(Z=>Z.skill===de&&Z.source!=="plugin");if(!J&&!U){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${de}" not yet in state — skipping reveal`);return}const K=(U==null?void 0:U.plugin)??J,Q=(U==null?void 0:U.origin)??"source",ce=U==null?void 0:U.source;s({type:"REVEAL_SKILL",skill:{plugin:K,skill:de,origin:Q,source:ce}}),window.location.hash=ce?`/skills/${ce}/${K}/${de}`:`/skills/${K}/${de}`},[]),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)},[]),w=m.useCallback(J=>{s({type:"SET_MODE",mode:J})},[]),E=m.useCallback(J=>{s({type:"SET_SEARCH",query:J})},[]),k=m.useCallback(J=>{s({type:"SET_MOBILE_VIEW",view:J})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[z,P]=m.useState(""),C=m.useMemo(()=>a.skills.map(J=>`${J.plugin}/${J.skill}`),[a.skills]),O=m.useMemo(()=>z?z.split(",").filter(Boolean):[],[z]),L=PS({skillIds:O,trackingSkillIds:C}),_=m.useRef("");m.useEffect(()=>{const J=a.skills.filter(Q=>Q.origin==="installed");if(J.length===0){P(""),_.current="";return}const de=new Map;for(const Q of L.updates)de.set(Q.name.split("/").pop()||Q.name,Q);const M=J.map(Q=>{const ce=de.get(Q.skill),Z=Q.currentVersion??(ce==null?void 0:ce.installed)??Q.version??Q.pluginVersion??"1.0.0";return{plugin:Q.plugin,skill:Q.skill,name:(ce==null?void 0:ce.name)??Q.skill,currentVersion:Z}}),U=M.map(Q=>`${Q.plugin}/${Q.skill}@${Q.currentVersion}#${Q.name}`).sort().join("|");if(U===_.current)return;_.current=U;let K=!1;return ke.resolveInstalledSkillIds(M).then(Q=>{if(K)return;const ie=[...VS(Q).flatMap(X=>[X.uuid,X.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(Q.map(X=>[`${X.plugin}/${X.skill}`,{uuid:X.uuid,slug:X.slug}])),P(ie))}).catch(Q=>{if(K||(_.current=""),!B.current){B.current=!0;const ce=Q instanceof Error?Q.message:String(Q);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",ce)}}),()=>{K=!0}},[a.skills,L.updates]);const H=m.useMemo(()=>{const J=a.skills.map(de=>{if(!de.updateAvailable&&de.latestVersion===void 0&&de.trackedForUpdates===void 0)return de;const M={...de};return delete M.updateAvailable,delete M.currentVersion,delete M.latestVersion,delete M.trackedForUpdates,M});return AS(J,L.updates)},[a.skills,L.updates]),W=m.useMemo(()=>{const J={source:0,installed:0};for(const de of H)de.updateAvailable&&(J[de.origin]+=1);return J},[H]),q=m.useMemo(()=>({...a,skills:H}),[a,H]),ee=L.updateCount,$=L.refresh,D=L.isRefreshing,I=m.useCallback((J,de)=>{$(),x(),In(`versions/${J}/${de}`),L.dismiss(`${J}/${de}`)},[$,x,L]),F=m.useMemo(()=>({state:q,selectSkill:h,clearSelection:S,setMode:w,setSearch:E,setMobileView:k,refreshSkills:x,updateCount:ee,dismissUpdateNotification:N,updates:L.updates,outdatedByOrigin:W,isRefreshingUpdates:D,refreshUpdates:$,revealSkill:y,clearReveal:b,updatesById:L.updatesById,pushUpdateCount:L.pushUpdateCount,updateStreamStatus:L.status,dismissPushUpdate:L.dismiss,activeAgent:c,onSkillUpdated:I}),[q,h,S,w,E,k,x,ee,N,L.updates,W,D,$,y,b,L.updatesById,L.pushUpdateCount,L.status,L.dismiss,c,I]);return r.jsx(qv.Provider,{value:F,children:t})}const qS={config:null,loading:!0};function YS(t,a){switch(a.type){case"SET_CONFIG":return{config:a.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Yv=m.createContext(null);function Ya(){const t=m.useContext(Yv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function KS({children:t}){const[a,s]=m.useReducer(YS,qS),i=m.useCallback(()=>{ke.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{i()},[i]);const c=m.useCallback(async(d,f)=>{const x=await ke.setConfig(d,f);return s({type:"SET_CONFIG",config:x}),x},[]),u=m.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:i}),[a,c,i]);return r.jsx(Yv.Provider,{value:u,children:t})}function XS({topRail:t,sidebar:a,main:s,statusBar:i,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:f=320,sidebarHidden:x=!1}){const h={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${f}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},v={display:"grid",gridTemplateColumns:x?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:h,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:v,children:[!x&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!x&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:i}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const QS={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}`},ZS={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"},JS={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"},e2={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"},t2={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"},n2={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"},r2={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."},a2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},l2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},s2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},i2={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"},o2={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)."}},c2={subscriptionBilling:"· subscription",free:"· free"},u2={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`},d2={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.`},f2={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsPlugins:"Plugins",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},p2={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.`},m2={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"},h2={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."},x2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},g2={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"}},le={sidebar:QS,shell:ZS,detail:JS,actions:e2,palette:t2,shortcuts:n2,toasts:r2,connection:a2,forms:l2,errors:s2,picker:i2,providers:o2,models:c2,settings:u2,statusBar:d2,scopePicker:f2,scopeSection:p2,claudeCodeLabel:m2,setupDrawer:h2,setupProviders:g2,scopeLabels:x2},ig=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],v2={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},y2={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},b2={"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"},j2={"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 S2(t,a){var f,x;const s=v2[t.id]??null,i=y2[t.id]??null,c=s?!!((f=a==null?void 0:a.wrapperFolders)!=null&&f[s]):!1,u=i?!!((x=a==null?void 0:a.binaries)!=null&&x[i]):!0,d=t.models.map(h=>({id:h.id,displayName:h.label,billingMode:j2[t.id]??"per-token",...h.pricing?{pricing:h.pricing}:{},...h.resolvedId?{resolvedId:h.resolvedId}:{}}));return{id:t.id,displayName:k2(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:b2[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function k2(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 w2(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of ig){const c=a.get(i);c&&s.push(c)}for(const i of t)ig.includes(i.id)||s.push(i);return s}function C2(t){const[a,s]=m.useState(null),[i,c]=m.useState("loading"),[u,d]=m.useState(null),[f,x]=m.useState(null),h=m.useRef(null),v=m.useRef(0),y=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{y.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=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=w2((A.providers||[]).map(z=>S2(z,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const w=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-v.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&x(`OpenRouter catalog fetch failed (${B.status})`);return}const z=await B.json();v.current=T,x(null),s(O=>{if(!O)return O;const L=O.agents.map(_=>{if(_.id!=="openrouter")return _;const H=z.models.map(q=>({id:q.id,displayName:q.name,contextWindow:q.contextWindow,pricing:q.pricing,billingMode:"per-token"}));return{..._,models:H,catalogAgeMs:z.ageSec?z.ageSec*1e3:0,cacheStale:!!z.stale}});return{...O,agents:L}});const P=z.ageSec??0;(z.stale===!0||P>600)&&((A=y.current)==null||A.call(y,"openrouter",P*1e3))}catch(B){x(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=m.useCallback(T=>{h.current=T,T==="openrouter"&&w()},[w]),k=m.useCallback(()=>{v.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var P,C;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(P=b.current)==null||P.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let z=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(z=O.error)}catch{}(C=b.current)==null||C.call(b,z)},[]);return{status:i,catalog:a,error:u,openRouterError:f,focusAgent:E,refresh:k,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function Md({variant:t,label:a,onActivate:s,installUrl:i,tooltip:c}){function u(f){if(f.stopPropagation(),t==="cli-install"&&i){window.open(i,"_blank","noopener,noreferrer");return}s()}function d(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u(f))}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 uf({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 E2=new Set(["claude-cli","claude-code"]);function og(t){return E2.has(t)}const cg=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function N2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:i,onSelect:c,onOpenSettings:u}){const d=t.filter(x=>cg.has(x.id)),f=t.filter(x=>!cg.has(x.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(x=>r.jsx(ug,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id)),f.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),f.map(x=>r.jsx(ug,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id))]})}function ug({agent:t,isActive:a,isFocused:s,onFocus:i,onSelect:c,onOpenSettings:u}){const{providers:d}=le,f={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},x={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},h=og(t.id),v={minHeight:36,height:h?"auto":36,padding:h?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(v.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>i(t.id),onFocus:()=>i(t.id),onClick:()=>c(t.id),style:v,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),og(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:le.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:le.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(uf,{unlocked:!0,size:10}):r.jsx(uf,{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:le.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(Md,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&x[t.id]&&r.jsx(Md,{variant:"cli-install",label:x[t.id].label,installUrl:x[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(Md,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),f[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:f[t.id]})]})}function T2(t,a,s,i){const d=t>=80,f=m.useRef(null),[x,h]=m.useState(0),v=m.useCallback(S=>{h(S.currentTarget.scrollTop)},[]),{visibleStart:y,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(x/a)-4),w=Math.ceil(s/a)+8,E=Math.min(t,S+w);return{visibleStart:S,visibleEnd:E}},[d,x,a,s,t,4]);return{visibleStart:y,visibleEnd:b,totalHeight:t*a,offsetTop:y*a,virtualised:d,containerProps:{onScroll:v,ref:f,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Kv=44,R2=352,A2=60,dg=480;function L2(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 ${le.models.subscriptionBilling}`:le.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,i=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${i.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function M2(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),f=u.displayName.toLowerCase().indexOf(s);return d!==f?d-f:c.displayName.length-u.displayName.length})}function z2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=m.useState(""),[f,x]=m.useState(""),h=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>x(u),A2);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&h.current&&h.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:dg,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:le.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:le.providers.openrouter.addKeyCta})]});const v=m.useMemo(()=>M2(t.models,f),[t.models,f]),y=T2(v.length,Kv,R2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:dg,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:h,type:"text",placeholder:le.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":le.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),v.length===0&&f?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:le.picker.noMatches(f)}),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:le.picker.clearSearch})]}):v.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:le.picker.noModelsYet}):r.jsx("div",{...y.containerProps,children:r.jsx("div",{style:{height:y.virtualised?y.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:y.virtualised?`translateY(${y.offsetTop}px)`:void 0},children:v.slice(y.visibleStart,y.visibleEnd).map((b,S)=>{const w=y.visibleStart+S;return r.jsx(_2,{model:b,isActive:b.id===a,isFocused:s===w,onSelect:()=>i(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function D2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function _2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=L2(t),d=D2(t.id,c,t.resolvedId),f=d!==null,x=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",h=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:i,title:t.id,style:{width:"100%",minHeight:Kv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:x,borderLeft:h,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}),f&&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 fg={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function O2(){const[t,a]=m.useState(null),[s,i]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{i(!0);try{const h=await fetch("/api/settings/keys");if(!h.ok)throw new Error(`GET /api/settings/keys returned ${h.status}`);const v=await h.json();a({...fg,...v}),u(null)}catch(h){u(h.message),a(fg)}finally{i(!1)}},[]);m.useEffect(()=>{d()},[d]);const f=m.useCallback(async(h,v)=>{const y=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,key:v})});if(!y.ok){const S=await y.json().catch(()=>({error:y.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${y.status}`)}const b=await y.json();return await d(),b},[d]),x=m.useCallback(async h=>{const v=await fetch(`/api/settings/keys/${h}`,{method:"DELETE"});if(!v.ok)throw new Error(`DELETE /api/settings/keys/${h} returned ${v.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:f,remove:x,refresh:d}}function B2({onMigrated:t,fetchImpl:a}){const[s,i]=m.useState({kind:"loading"}),c=a??globalThis.fetch,u=m.useCallback(async()=>{var h;try{const v=await c("/api/settings/migration-status");if(!v.ok){i({kind:"hidden"});return}const y=await v.json();y.pending&&(((h=y.darwinKeys)==null?void 0:h.length)??0)>0?i({kind:"visible",darwinKeys:y.darwinKeys??[]}):i({kind:"hidden"})}catch{i({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{i({kind:"working"});try{const h=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!h.ok){i({kind:"error",message:`Migration failed (${h.status})`});return}const v=await h.json().catch(()=>({migrated:[]}));t==null||t(v.migrated??[]),await u()}catch(h){i({kind:"error",message:h.message})}},[c,u,t]),f=m.useCallback(async()=>{i({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:zd,children:"Retry"})]});const x=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:x,"data-testid":"migration-migrate",style:{...zd,background:"var(--accent, var(--color-accent))",color:"white",opacity:x?.6:1},children:x?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void f(),"data-testid":"migration-dismiss",style:{...zd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const zd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},I2=[{id:"anthropic",name:le.providers.anthropic.name,keyIssuanceUrl:le.providers.anthropic.keyIssuanceUrl,prefix:le.providers.anthropic.keyPrefix,placeholder:`Paste ${le.providers.anthropic.name} key`},{id:"openai",name:le.providers.openai.name,keyIssuanceUrl:le.providers.openai.keyIssuanceUrl,prefix:le.providers.openai.keyPrefix,placeholder:le.providers.openai.pastePlaceholder},{id:"openrouter",name:le.providers.openrouter.name,keyIssuanceUrl:le.providers.openrouter.keyIssuanceUrl,prefix:le.providers.openrouter.keyPrefix,placeholder:`Paste ${le.providers.openrouter.name} key`}];function $2(t){const a=Date.now()-new Date(t).getTime();return a<6e4?"just now":a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:new Date(t).toLocaleString()}function Xv({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:f}=O2(),x=m.useRef(null),h=m.useRef(null),[v,y]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const w=await fetch("/api/settings/storage-path");if(!w.ok)throw new Error(`GET /api/settings/storage-path returned ${w.status}`);const E=await w.json();S||y(E.path??null)}catch{S||y(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,w=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",k=(N=x.current)==null?void 0:N.querySelector(E);k==null||k.focus()},0);return()=>{var E;clearTimeout(w),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=w=>{if(w.key==="Escape"){w.preventDefault(),a();return}if(w.key==="Tab"&&x.current){const E=x.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const k=E[0],N=E[E.length-1];w.shiftKey&&document.activeElement===k?(w.preventDefault(),N.focus()):!w.shiftKey&&document.activeElement===N&&(w.preventDefault(),k.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=m.useCallback(async()=>{var S,w;if(v)try{await((w=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:w.call(S,v)),i==null||i(le.settings.pathCopied)}catch{}},[i,v]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:x,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:le.settings.title}),r.jsx(B2,{onMigrated:()=>{f()}}),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:le.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:le.settings.sectionApiKeys}),I2.map(S=>r.jsx(U2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async w=>{const E=await u(S.id,w);return i==null||i(le.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),i==null||i(le.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?h:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:v?le.settings.storagePath(v):le.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!v,"data-testid":"settings-copy-path",style:{...Va,opacity:v?1:.5,cursor:v?"pointer":"not-allowed"},children:le.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function U2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:f,inputRef:x}){const[h,v]=m.useState(""),[y,b]=m.useState(!1),[S,w]=m.useState(!1),[E,k]=m.useState(!1),[N,T]=m.useState(null),A=h.trim(),B=A.length===0,z=A.length>0&&!A.startsWith(i),P=m.useCallback(async()=>{if(B)return;w(!0);const L=A;v("");try{const _=await d(L);_.warning?T(_.warning):T(null)}finally{w(!1)}},[B,d,A]),C=m.useCallback(async()=>{var L;try{if(!((L=navigator.clipboard)!=null&&L.readText))return;const _=await navigator.clipboard.readText();v(_)}catch{}},[]),O=m.useCallback(async()=>{k(!1),await f()},[f]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:x,type:y?"text":"password",value:h,onChange:L=>{v(L.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!y),style:Va,children:y?le.settings.hide:le.settings.show}),r.jsx("button",{type:"button",onClick:C,style:Va,children:le.settings.paste})]}),z&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:pg,children:le.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:pg,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:P,disabled:B||S,"data-testid":`save-${t}`,style:{...Va,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:le.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:le.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Va,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>k(!1),style:Va,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>k(!0),"data-testid":`remove-${t}`,style:{...Va,color:"var(--text-muted)"},children:le.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?le.settings.keyStoredAt($2(u.updatedAt)):le.settings.noKey})]})]})}const Va={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},pg={fontSize:11,color:"var(--warning, var(--text-muted))"};function H2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function P2({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=C2({onStaleCatalog:(_,H)=>{const W=Math.round(H/6e4);t==null||t(`Using cached ${_} catalog (${W} min old)`)},onSetActiveError:_=>t==null?void 0:t(_)}),[u,d]=m.useState(!1),[f,x]=m.useState(!1),[h,v]=m.useState(),[y,b]=m.useState(null),[S,w]=m.useState("agents"),[E,k]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var _;s&&!y&&b(s.activeAgent??((_=s.agents[0])==null?void 0:_.id)??null)},[s,y]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(_=>_.id===y)??T[0],[T,y]);m.useEffect(()=>{k(0)},[y]);const B=m.useCallback(()=>{var _;d(!0),w("agents"),b((s==null?void 0:s.activeAgent)??((_=T[0])==null?void 0:_.id)??null),k(0)},[s,T]),z=m.useCallback(()=>{var _;d(!1),(_=N.current)==null||_.focus()},[]);m.useEffect(()=>{const _=H=>{var q;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const W=(q=document.activeElement)==null?void 0:q.tagName;W==="INPUT"||W==="TEXTAREA"||(H.preventDefault(),d(ee=>!ee))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[]),m.useEffect(()=>{if(!u)return;const _=W=>{if(W.key==="Escape"){W.preventDefault(),z();return}if(W.key==="ArrowDown"){W.preventDefault(),H(1);return}if(W.key==="ArrowUp"){W.preventDefault(),H(-1);return}if(W.key==="ArrowRight"&&S==="agents"){W.preventDefault(),w("models"),k(q=>{const ee=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(q,Math.max(0,ee)))});return}if(W.key==="ArrowLeft"&&S==="models"){W.preventDefault(),w("agents");return}if(W.key==="Enter"){if(W.preventDefault(),S==="agents"&&A)w("models"),k(0);else if(S==="models"&&A){const q=Math.max(0,Math.min(A.models.length-1,E)),ee=A.models[q];ee&&(c(A.id,ee.id),z())}return}};function H(W){if(S==="agents"){const q=T.findIndex($=>$.id===y),ee=T[Math.max(0,Math.min(T.length-1,q+W))];ee&&(b(ee.id),i(ee.id));return}if(S==="models"&&A){const q=A.models.length;if(q===0)return;k(ee=>{const $=ee+W;return Math.max(0,Math.min(q-1,$))})}}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[u,S,T,y,A,E,z,i,c]);const P=m.useCallback(_=>{v(_==="anthropic"||_==="openrouter"?_:void 0),x(!0),d(!1)},[]),C=T.find(_=>_.id===(s==null?void 0:s.activeAgent)),O=C==null?void 0:C.models.find(_=>_.id===(s==null?void 0:s.activeModel)),L=m.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const _=(C==null?void 0:C.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${_} · ${H}`},[a,s,C,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?z():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:C!=null&&C.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:L})]}),u&&typeof document<"u"&&nc.createPortal(r.jsxs(V2,{reducedMotion:H2(),onClickOutside:z,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(N2,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:y,onFocus:_=>{b(_),i(_)},onSelect:_=>{b(_),i(_),w("models")},onOpenSettings:P}),A&&r.jsx(z2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:_=>{c(A.id,_),z()},onOpenSettings:P})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>P(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:le.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:le.picker.footerHint})]})]}),document.body),r.jsx(Xv,{open:f,onClose:()=>x(!1),initialProvider:h,onToast:t})]})}function V2({children:t,reducedMotion:a,onClickOutside:s}){const i=m.useRef(null);return m.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:i,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
63
63
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
64
64
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
65
|
-
}`})]})}const F2="/assets/skill-studio-logo-CRyKgIrg.png";function mg(){typeof window>"u"||(window.location.hash="#/")}function G2({onHome:t}){const[a,s]=m.useState(!1),[i,c]=m.useState(!1),u=f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.button!==0||(f.preventDefault(),mg(),t==null||t())},d=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),mg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:i?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("img",{src:F2,alt:"","aria-hidden":"true",width:28,height:28,style:{display:"block",objectFit:"contain",flexShrink:0}}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const hg=m.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function W2({toast:t,onDismiss:a}){const[s,i]=m.useState(!0),c=m.useRef(null);m.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function q2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(hg,{politeness:"polite",message:s}),r.jsx(hg,{politeness:"assertive",message:i}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(W2,{toast:c,onDismiss:a})},c.id))})]})}const Qv=m.createContext(null);function rc(){const t=m.useContext(Qv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function Y2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=m.useState([]),[u,d]=m.useState(""),[f,x]=m.useState(""),h=m.useRef(new Map),v=m.useCallback(k=>{const N=h.current.get(k);N&&(clearTimeout(N),h.current.delete(k)),c(T=>T.filter(A=>A.id!==k))},[]),y=m.useCallback((k,N)=>{if(N<=0)return;const T=setTimeout(()=>{v(k)},N);h.current.set(k,T)},[v]),b=m.useCallback(k=>{const N=k.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:k.message,severity:k.severity??"info",durationMs:k.durationMs??s,action:k.action};return c(A=>[...A,T]),T.severity==="error"?x(T.message):d(T.message),y(N,T.durationMs),N},[s,y]),S=m.useCallback(()=>{for(const k of h.current.values())clearTimeout(k);h.current.clear(),c([])},[]);m.useEffect(()=>{function k(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),B=A[A.length-1],z=h.current.get(B.id);return z&&(clearTimeout(z),h.current.delete(B.id)),T.filter(P=>P.id!==B.id)})}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[a]),m.useEffect(()=>()=>{for(const k of h.current.values())clearTimeout(k);h.current.clear()},[]);const w=i.slice(0,a),E=m.useMemo(()=>({toast:b,dismiss:v,clear:S}),[b,v,S]);return r.jsxs(Qv.Provider,{value:E,children:[t,r.jsx(q2,{toasts:w,onDismiss:v,liveMessage:u,liveAssertiveMessage:f})]})}function K2(){const{data:t,loading:a}=qa("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const X2=m.lazy(()=>Vl(()=>import("./UpdateDropdown-DlHKb6L0.js"),__vite__mapDeps([0,1])));function Q2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:f,activeAgent:x}=cr(),{toast:h}=rc(),{data:v}=K2(),y=(v==null?void 0:v.degraded)===!0,b=m.useMemo(()=>{if(!f||f.size===0)return;const P=new Map;for(const[C,O]of f)O.diffSummary&&P.set(C,O.diffSummary);return P.size>0?P:void 0},[f]),[S,w]=m.useState(!1),E=m.useRef(null),k=m.useCallback(()=>w(!1),[]),N=y?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),A=t===0?"No updates available":`${t} updates available, open summary`,B=y?`${A} — platform crawler degraded`:A,z=y?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:E,type:"button","data-testid":"update-bell","aria-label":B,"aria-haspopup":"dialog","aria-expanded":S,title:z,onClick:()=>w(P=>!P),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||y?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:T})]}),S&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(X2,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:P=>{const C=P.localSkill??P.name.split("/").pop()??"",O=P.localPlugin??"";if(u)u(O,C);else{const _=P.name.split("/"),H=_.length>=2?_[_.length-2]:_[0];c({plugin:H,skill:C,origin:"installed"})}if(!(d??[]).some(_=>_.skill===C&&(O===""||_.plugin===O))){const _=P.installLocations??[];if(_.length>0){const H=x?_.filter(q=>q.agent===x):[],W=x?_.filter(q=>q.agent!==x):_;if(H.length>0&&W.length>0){const q=W.length>=2?`Also installed under ${W.length} other locations.`:`Also installed under ${W[0].agentLabel}.`;h({severity:"info",message:q})}else{const q=_[0].agentLabel;h({severity:"info",message:`Skill installed under ${q} — switch to ${q} to view details.`})}}}k()},onViewAll:()=>{window.location.hash="#/updates",k()},onClose:k,anchorRef:E})})]})}function xg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function Z2(t){return t.source==="project"?le.scopeLabels.sourceProject:t.source==="personal"?le.scopeLabels.sourcePersonal:t.source==="plugin"?le.scopeLabels.sourcePlugin:t.origin==="installed"?le.scopeLabels.sourcePersonal:le.scopeLabels.sourceProject}function J2(t){return t.source==="project"?"var(--status-installed)":t.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)"}function ek({projectName:t,selected:a,onHome:s,projectPickerSlot:i,onRequestCreateSkill:c,findSkillsSlot:u}){const d=a?Z2(a):null,f=a?J2(a):"var(--text-secondary)";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(G2,{onHome:s}),i?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:i}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&d&&r.jsxs(r.Fragment,{children:[r.jsx(gg,{segment:"origin",onClick:()=>xg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:f},children:d}),r.jsx(vg,{}),r.jsx(gg,{segment:"plugin",onClick:()=>xg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(vg,{}),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:12,flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u,c&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:c,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]})]}),r.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"var(--border-default)"}}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(P2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(Q2,{})})]})]})]})}function gg({segment:t,onClick:a,style:s,children:i}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:i})}function vg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const ac="vskill-theme";function Zv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function tk(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function nk(t){try{const a=t.getItem(ac);return Zv(a)}catch{return"auto"}}function rk(t,a){try{t.setItem(ac,a)}catch{}}function ak(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function lk(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Jv=m.createContext(null);function sk({storage:t,matchMedia:a,target:s,children:i}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[f,x]=m.useState(()=>c?nk(c):"auto"),[h,v]=m.useState(()=>lk(u)),y=m.useMemo(()=>tk(f,h),[f,h]);m.useEffect(()=>{d&&ak(d,f,y)},[d,f,y]),m.useEffect(()=>{if(!u)return;const w=u("(prefers-color-scheme: dark)"),E=N=>v(N.matches);if(typeof w.addEventListener=="function")return w.addEventListener("change",E),()=>w.removeEventListener("change",E);const k=w;return k.addListener(E),()=>k.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const w=E=>{E.key===ac&&x(Zv(E.newValue))};return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[]),m.useEffect(()=>{if(!u||!d)return;let w;try{w=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(w.matches);const k=T=>E(T.matches);if(typeof w.addEventListener=="function")return w.addEventListener("change",k),()=>w.removeEventListener("change",k);const N=w;return N.addListener(k),()=>N.removeListener(k)},[u,d]);const b=m.useCallback(w=>{x(w),c&&rk(c,w)},[c]),S=m.useMemo(()=>({mode:f,resolvedTheme:y,setTheme:b}),[f,y,b]);return r.jsx(Jv.Provider,{value:S,children:i})}function ey(){const t=m.useContext(Jv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const yg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function ik(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of yg){const c=a.get(i);c&&s.push(c)}for(const i of t)yg.includes(i.id)||s.push(i);return s}function ok(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 i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function ck({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=ik(t),c=ok(640),[u,d]=m.useState(!1),f=m.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=i.filter(h=>h.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":le.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:le.statusBar.providerSummary(x,i.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:i.map(h=>r.jsx(bg,{p:h,onClick:f},h.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(x=>r.jsx(bg,{p:x,onClick:f,compact:!0},x.id))})}function bg({p:t,onClick:a,compact:s}){const i=t.available?le.statusBar.unlocked(t.label):t.kind==="cli-install"?le.statusBar.lockedCli(t.label):le.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(uf,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function uk(){try{return typeof localStorage>"u"?null:localStorage.getItem(ac)}catch{return null}}function dk({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:f,resolvedTheme:x,setTheme:h}=ey(),y=uk()==="auto",b=fk(f,x,y),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(jg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(pk,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(jg,{}),r.jsx(ck,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>h(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${f} — 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(mk,{mode:f}),r.jsx("span",{style:{textTransform:"capitalize"},children:f})]})]})}function fk(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function pk({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function jg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function mk({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 df=new Set;function ty(){for(const t of df)t()}const hk=5,xk=1e3,gk=6e4;function vk(){const[t,a]=m.useState(void 0),[s,i]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),f=m.useRef(null),x=m.useRef(null),h=m.useRef(!0),v=m.useRef(0),[y,b]=m.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},w=m.useCallback(()=>{f.current&&(f.current.abort(),f.current=null)},[]),E=m.useCallback(async()=>{if(!h.current||document.visibilityState==="hidden")return;w();const N=new AbortController;f.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!h.current)return;const A=await T.json();if(!h.current)return;d.current=0,a(A.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{h.current&&b(B=>B+1)},gk)}catch(T){if(!h.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>hk){i(!0);return}const A=xk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{h.current&&b(B=>B+1)},A)}},[w]);m.useEffect(()=>(h.current=!0,()=>{h.current=!1,S(),w()}),[w]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[y,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),w()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[w]);const k=m.useCallback(()=>{d.current=0,i(!1),S(),v.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(df.add(k),()=>{df.delete(k)}),[k]),{plugins:t,paused:s,loading:c,retry:k}}const lc=0,ba=1,Fl=2,ny=4;function Sg(t){return()=>t}function yk(t){t()}function ry(t,a){return s=>t(a(s))}function kg(t,a){return()=>t(a)}function bk(t,a){return s=>t(a,s)}function Df(t){return t!==void 0}function jk(...t){return()=>{t.map(yk)}}function Gl(){}function sc(t,a){return a(t),t}function Sk(t,a){return a(t)}function Rt(...t){return t}function pt(t,a){return t(ba,a)}function Ke(t,a){t(lc,a)}function _f(t){t(Fl)}function zt(t){return t(ny)}function Le(t,a){return pt(t,bk(a,lc))}function sr(t,a){const s=t(ba,i=>{s(),a(i)});return s}function wg(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function ay(t,a){return t===a}function Tt(t=ay){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function $e(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>ry(a,t)}function xr(t){return a=>()=>{a(t)}}function he(t,...a){const s=kk(...a);return((i,c)=>{switch(i){case Fl:_f(t);return;case ba:return pt(t,s(c))}})}function gr(t,a){return s=>i=>{s(a=t(a,i))}}function Wa(t){return a=>s=>{t>0?t--:a(s)}}function Ur(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function Qe(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;pt(u,x=>{const h=s;s|=f,a[d]=x,h!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const f=()=>{u([d].concat(a))};s===c?f():i=f}}function kk(...t){return a=>t.reduceRight(Sk,a)}function wk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ba:return u?s===u?void 0:(i(),s=u,a=pt(t,u),a):(i(),Gl);case Fl:i(),s=null;return}}}function ge(t){let a=t;const s=it();return((i,c)=>{switch(i){case lc:a=c;break;case ba:{c(a);break}case ny:return a}return s(i,c)})}function pn(t,a){return sc(ge(a),s=>Le(t,s))}function it(){const t=[];return((a,s)=>{switch(a){case lc:t.slice().forEach(i=>{i(s)});return;case Fl:t.splice(0,t.length);return;case ba:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function $n(t){return sc(it(),a=>Le(t,a))}function ut(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:Ck(),singleton:s}}const Ck=()=>Symbol();function Ek(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const f=i(c.map(x=>s(x)));return d&&a.set(u,f),f};return s(t)}function qt(...t){const a=it(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;pt(u,x=>{s[d]=x,i|=f,i===c&&Ke(a,s)})}),function(u,d){switch(u){case Fl:{_f(a);return}case ba:return i===c&&d(s),pt(a,d)}}}function Ie(t,a=ay){return he(t,Tt(a))}function ff(...t){return function(a,s){switch(a){case Fl:return;case ba:return jk(...t.map(i=>pt(i,s)))}}}const Qt={DEBUG:0,INFO:1,WARN:2,ERROR:3},Nk={[Qt.DEBUG]:"debug",[Qt.ERROR]:"error",[Qt.INFO]:"log",[Qt.WARN]:"warn"},Tk=()=>typeof globalThis>"u"?window:globalThis,ja=ut(()=>{const t=ge(Qt.ERROR);return{log:ge((a,s,i=Qt.INFO)=>{const c=Tk().VIRTUOSO_LOG_LEVEL??zt(t);i>=c&&console[Nk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ka(t,a,s){return Of(t,a,s).callbackRef}function Of(t,a,s){const i=Ae.useRef(null);let c=d=>{};const u=Ae.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const f=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?f():requestAnimationFrame(f)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function Rk(t,a,s,i,c,u,d,f,x){const h=Ae.useCallback(v=>{const y=Ak(v.children,a,f?"offsetWidth":"offsetHeight",c);let b=v.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let w;S&&(w=b.ownerDocument.defaultView);const E=d?f?d.scrollLeft:d.scrollTop:S?f?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:f?b.scrollLeft:b.scrollTop,k=d?f?d.scrollWidth:d.scrollHeight:S?f?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:f?b.scrollWidth:b.scrollHeight,N=d?f?d.offsetWidth:d.offsetHeight:S?f?w.innerWidth:w.innerHeight:f?b.offsetWidth:b.offsetHeight;i({scrollHeight:k,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(f?Cg("column-gap",getComputedStyle(v).columnGap,c):Cg("row-gap",getComputedStyle(v).rowGap,c)),y!==null&&t(y)},[t,a,c,u,d,i,f]);return Of(h,s,x)}function Ak(t,a,s,i){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const f=t.item(d);if(f.dataset.index===void 0)continue;const x=parseInt(f.dataset.index),h=parseFloat(f.dataset.knownSize),v=a(f,s);if(v===0&&i("Zero-sized element, this should not happen",{child:f},Qt.ERROR),v===h)continue;const y=u[u.length-1];u.length===0||y.size!==v||y.endIndex!==x-1?u.push({endIndex:x,size:v,startIndex:x}):u[u.length-1].endIndex++}return u}function Cg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Qt.WARN),a==="normal"?0:parseInt(a??"0",10)}function ly(t,a,s){const i=Ae.useRef(null),c=Ae.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const h=x.getBoundingClientRect(),v=h.width;let y,b;if(a){const S=a.getBoundingClientRect(),w=h.top-S.top;b=S.height-Math.max(0,w),y=w+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,h.top),y=h.top+S.scrollY}i.current={listHeight:h.height,offsetTop:y,visibleHeight:b,visibleWidth:v},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Of(c,!0,s),f=Ae.useCallback(()=>{c(d.current)},[c,d]);return Ae.useEffect(()=>{var h;if(a){a.addEventListener("scroll",f);const v=new ResizeObserver(()=>{requestAnimationFrame(f)});return v.observe(a),()=>{a.removeEventListener("scroll",f),v.unobserve(a)}}const x=(h=d.current)==null?void 0:h.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",f),x==null||x.addEventListener("resize",f),()=>{x==null||x.removeEventListener("scroll",f),x==null||x.removeEventListener("resize",f)}},[f,a,d]),u}const yn=ut(()=>{const t=it(),a=it(),s=ge(0),i=it(),c=ge(0),u=it(),d=it(),f=ge(0),x=ge(0),h=ge(0),v=ge(0),y=it(),b=it(),S=ge(!1),w=ge(!1),E=ge(!1);return Le(he(t,we(({scrollTop:k})=>k)),a),Le(he(t,we(({scrollHeight:k})=>k)),d),Le(a,c),{deviation:s,fixedFooterHeight:h,fixedHeaderHeight:x,footerHeight:v,headerHeight:f,horizontalDirection:w,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:y,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Qs={lvl:0};function sy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:f,value:x}=a(t[d]);u.push({end:f-1,start:i,value:c}),i=f,c=x}return u.push({end:1/0,start:i,value:c}),u}function yt(t){return t===Qs}function Zs(t,a){if(!yt(t))return a===t.k?t.v:a<t.k?Zs(t.l,a):Zs(t.r,a)}function or(t,a,s="k"){if(yt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=or(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return or(t.l,a,s)}function Bn(t,a,s){return yt(t)?cy(a,s,1):a===t.k?Xt(t,{k:a,v:s}):a<t.k?Eg(Xt(t,{l:Bn(t.l,a,s)})):Eg(Xt(t,{r:Bn(t.r,a,s)}))}function Ol(){return Qs}function Bl(t,a,s){if(yt(t))return[];const i=or(t,a)[0];return Lk(mf(t,i,s))}function pf(t,a){if(yt(t))return Qs;const{k:s,l:i,r:c}=t;if(a===s){if(yt(i))return c;if(yt(c))return i;const[u,d]=oy(i);return Ho(Xt(t,{k:u,l:iy(i),v:d}))}return a<s?Ho(Xt(t,{l:pf(i,a)})):Ho(Xt(t,{r:pf(c,a)}))}function Fa(t){return yt(t)?[]:[...Fa(t.l),{k:t.k,v:t.v},...Fa(t.r)]}function mf(t,a,s){if(yt(t))return[];const{k:i,l:c,r:u,v:d}=t;let f=[];return i>a&&(f=f.concat(mf(c,a,s))),i>=a&&i<=s&&f.push({k:i,v:d}),i<=s&&(f=f.concat(mf(u,a,s))),f}function Ho(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(Dd(a))return uy(Xt(t,{lvl:s-1}));if(!yt(a)&&!yt(a.r))return Xt(a.r,{l:Xt(a,{r:a.r.l}),lvl:s,r:Xt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Dd(t))return hf(Xt(t,{lvl:s-1}));if(!yt(i)&&!yt(i.l)){const c=i.l,u=Dd(c)?i.lvl-1:i.lvl;return Xt(c,{l:Xt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:hf(Xt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Xt(t,a){return cy(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 iy(t){return yt(t.r)?t.l:Ho(Xt(t,{r:iy(t.r)}))}function Dd(t){return yt(t)||t.lvl>t.r.lvl}function oy(t){return yt(t.r)?[t.k,t.v]:oy(t.r)}function cy(t,a,s,i=Qs,c=Qs){return{k:t,l:i,lvl:s,r:c,v:a}}function Eg(t){return hf(uy(t))}function uy(t){const{l:a}=t;return!yt(a)&&a.lvl===t.lvl?Xt(a,{r:Xt(t,{l:a.r})}):t}function hf(t){const{lvl:a,r:s}=t;return!yt(s)&&!yt(s.r)&&s.lvl===a&&s.r.lvl===a?Xt(s,{l:Xt(t,{r:s.l}),lvl:a+1}):t}function Lk(t){return sy(t,({k:a,v:s})=>({index:a,value:s}))}function dy(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Js(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Bf=ut(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function fy(t,a,s){return t[Wo(t,a,s)]}function Wo(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],f=s(d,a);if(f===0)return u;if(f===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Mk(t,a,s,i){const c=Wo(t,a,i),u=Wo(t,s,i,c);return t.slice(c,u+1)}function va(t,a){return Math.round(t.getBoundingClientRect()[a])}function ic(t){return!yt(t.groupOffsetTree)}function If({index:t},a){return a===t?0:a<t?-1:1}function zk(){return{groupIndices:[],groupOffsetTree:Ol(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ol()}}function Dk(t,a){let s=yt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),yt(t)){t=Bn(t,0,u);continue}const f=Bl(t,d-1,c+1);if(f.some(Hk(i)))continue;let x=!1,h=!1;for(const{end:v,start:y,value:b}of f)x?(c>=y||u===b)&&(t=pf(t,y)):(h=b!==u,x=!0),v>c&&c>=y&&b!==u&&(t=Bn(t,c+1,b));h&&(t=Bn(t,d,u))}return[t,s]}function _k(t){return typeof t.groupIndex<"u"}function Ok({offset:t},a){return a===t?0:a<t?-1:1}function ei(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=fy(a,t,If),d=t-i,f=u*d+(d-1)*s+c;return f>0?f+s:f}function py(t,a){if(!ic(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function my(t,a,s){if(_k(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=py(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function Bk(t,a,s,i=0){return i>0&&(a=Math.max(a,fy(t,i,If).offset)),sy(Mk(t,a,s,Ok),Uk)}function Ik(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Qt.DEBUG);const u=t.sizeTree;let d=u,f=0;if(s.length>0&&yt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((w,E)=>Bn(Bn(w,E,b),E+1,S),d)}else[d,f]=Dk(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:h,lastSize:v,offsetTree:y}=xf(t.offsetTree,f,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>Bn(b,S,ei(S,y,c)),Ol()),lastIndex:x,lastOffset:h,lastSize:v,offsetTree:y,sizeTree:d}}function $k(t){return Fa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Ng(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function xf(t,a,s,i){let c=t,u=0,d=0,f=0,x=0;if(a!==0){x=Wo(c,a-1,If),f=c[x].offset;const h=or(s,a-1);u=h[0],d=h[1],c.length&&c[x].size===or(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:h,value:v}of Bl(s,a,1/0)){const y=h-u,b=y*d+f+y*i;c.push({index:h,offset:b,size:v}),u=h,f=b,d=v}return{lastIndex:u,lastOffset:f,lastSize:d,offsetTree:c}}function Uk(t){return{index:t.index,value:t}}function Hk(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Pk={offsetHeight:"height",offsetWidth:"width"},br=ut(([{log:t},{recalcInProgress:a}])=>{const s=it(),i=it(),c=pn(i,0),u=it(),d=it(),f=ge(0),x=ge([]),h=ge(void 0),v=ge(void 0),y=ge(void 0),b=ge(void 0),S=ge((C,O)=>va(C,Pk[O])),w=ge(void 0),E=ge(0),k=zk(),N=pn(he(s,Qe(x,t,E),gr(Ik,k),Tt()),k),T=pn(he(x,Tt(),gr((C,O)=>({current:O,prev:C.current}),{current:[],prev:[]}),we(({prev:C})=>C)),[]);Le(he(x,$e(C=>C.length>0),Qe(N,E),we(([C,O,L])=>{const _=C.reduce((H,W,q)=>Bn(H,W,ei(W,O.offsetTree,L)||q),Ol());return{...O,groupIndices:C,groupOffsetTree:_}})),N),Le(he(i,Qe(N),$e(([C,{lastIndex:O}])=>C<O),we(([C,{lastIndex:O,lastSize:L}])=>[{endIndex:O,size:L,startIndex:C}])),s),Le(h,v);const A=pn(he(h,we(C=>C===void 0)),!0);Le(he(v,$e(C=>C!==void 0&&yt(zt(N).sizeTree)),we(C=>{const O=zt(y),L=zt(x).length>0;return O!==void 0&&O!==0?L?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:C,startIndex:1}]:[]:[{endIndex:0,size:C,startIndex:0}]})),s),Le(he(b,$e(C=>C!==void 0&&C.length>0&&yt(zt(N).sizeTree)),we(C=>{const O=[];let L=C[0],_=0;for(let H=1;H<C.length;H++){const W=C[H];W!==L&&(O.push({endIndex:H-1,size:L,startIndex:_}),L=W,_=H)}return O.push({endIndex:C.length-1,size:L,startIndex:_}),O})),s),Le(he(x,Qe(y,v),$e(([,C,O])=>C!==void 0&&O!==void 0),we(([C,O,L])=>{const _=[];for(let H=0;H<C.length;H++){const W=C[H],q=C[H+1];_.push({startIndex:W,endIndex:W,size:O}),q!==void 0&&_.push({startIndex:W+1,endIndex:q-1,size:L})}return _})),s);const B=$n(he(s,Qe(N),gr(({sizes:C},[O,L])=>({changed:L!==C,sizes:L}),{changed:!1,sizes:k}),we(C=>C.changed)));pt(he(f,gr((C,O)=>({diff:C.prev-O,prev:O}),{diff:0,prev:0}),we(C=>C.diff)),C=>{const{groupIndices:O}=zt(N);if(C>0)Ke(a,!0),Ke(u,C+Ng(C,O));else if(C<0){const L=zt(T);L.length>0&&(C-=Ng(-C,L)),Ke(d,C)}}),pt(he(f,Qe(t)),([C,O])=>{C<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:f},Qt.ERROR)});const z=$n(u);Le(he(u,Qe(N),we(([C,O])=>{const L=O.groupIndices.length>0,_=[],H=O.lastSize;if(L){const W=Zs(O.sizeTree,0);let q=0,ee=0;for(;q<C;){const D=O.groupIndices[ee],I=O.groupIndices.length===ee+1?1/0:O.groupIndices[ee+1]-D-1;_.push({endIndex:D,size:W,startIndex:D}),_.push({endIndex:D+1+I-1,size:H,startIndex:D+1}),ee++,q+=I+1}const $=Fa(O.sizeTree);return q!==C&&$.shift(),$.reduce((D,{k:I,v:F})=>{let J=D.ranges;return D.prevSize!==0&&(J=[...D.ranges,{endIndex:I+C-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:I+C,prevSize:F,ranges:J}},{prevIndex:C,prevSize:0,ranges:_}).ranges}return Fa(O.sizeTree).reduce((W,{k:q,v:ee})=>({prevIndex:q+C,prevSize:ee,ranges:[...W.ranges,{endIndex:q+C-1,size:W.prevSize,startIndex:W.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const P=$n(he(d,Qe(N,E),we(([C,{offsetTree:O},L])=>{const _=-C;return ei(_,O,L)})));return Le(he(d,Qe(N,E),we(([C,O,L])=>{if(O.groupIndices.length>0){if(yt(O.sizeTree))return O;let H=Ol();const W=zt(T);let q=0,ee=0,$=0;for(;q<-C;){$=W[ee];const D=W[ee+1]-$-1;ee++,q+=D+1}if(H=Fa(O.sizeTree).reduce((D,{k:I,v:F})=>Bn(D,Math.max(0,I+C),F),H),q!==-C){const D=Zs(O.sizeTree,$);H=Bn(H,0,D);const I=or(O.sizeTree,-C+1)[1];H=Bn(H,1,I)}return{...O,sizeTree:H,...xf(O.offsetTree,0,H,L)}}const _=Fa(O.sizeTree).reduce((H,{k:W,v:q})=>Bn(H,Math.max(0,W+C),q),Ol());return{...O,sizeTree:_,...xf(O.offsetTree,0,_,L)}})),N),{beforeUnshiftWith:z,data:w,defaultItemSize:v,firstItemIndex:f,fixedItemSize:h,fixedGroupSize:y,gap:E,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:P,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:A,unshiftWith:u}},Rt(ja,Bf),{singleton:!0});function Vk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const hy=ut(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=it(),d=it(),f=$n(he(u,we(Vk)));return Le(he(f,we(x=>x.totalCount)),s),Le(he(f,we(x=>x.groupIndices)),t),Le(he(qt(c,a,i),$e(([x,h])=>ic(h)),we(([x,h,v])=>or(h.groupOffsetTree,Math.max(x-v,0),"v")[0]),Tt(),we(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},Rt(br,yn)),Sa=ut(([{log:t}])=>{const a=ge(!1),s=$n(he(a,$e(i=>i),Tt()));return pt(a,i=>{i&&zt(t)("props updated",{},Qt.DEBUG)}),{didMount:s,propsReady:a}},Rt(ja),{singleton:!0}),Fk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function xy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!Fk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const si=ut(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:f,scrollingInProgress:x,scrollTo:h,smoothScrollTargetReached:v,viewportHeight:y},{log:b}])=>{const S=it(),w=it(),E=ge(0);let k=null,N=null,T=null;function A(){k!==null&&(k(),k=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Ke(x,!1)}return Le(he(S,Qe(s,y,i,E,f,d,b),Qe(t,u,c),we(([[B,z,P,C,O,L,_,H],W,q,ee])=>{const $=xy(B),{align:D,behavior:I,offset:F}=$,J=C-1,de=my($,z,J);let M=ei(de,z.offsetTree,W)+L;D==="end"?(M+=q+or(z.sizeTree,de)[1]-P+ee,de===J&&(M+=_)):D==="center"?M+=(q+or(z.sizeTree,de)[1]-P+ee)/2:M-=O,F!==void 0&&F!==0&&(M+=F);const U=K=>{A(),K?(H("retrying to scroll to",{location:B},Qt.DEBUG),Ke(S,B)):(Ke(w,!0),H("list did not change, scroll successful",{},Qt.DEBUG))};if(A(),I==="smooth"){let K=!1;T=pt(a,Q=>{K=K||Q}),k=sr(v,()=>{U(K)})}else k=sr(he(a,Gk(150)),U);return N=setTimeout(()=>{A()},1200),Ke(x,!0),H("scrolling from index to",{behavior:I,index:de,top:M},Qt.DEBUG),{behavior:I,top:M}})),h),{scrollTargetReached:w,scrollToIndex:S,topListHeight:E}},Rt(br,yn,ja),{singleton:!0});function Gk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function $f(t,a){t===0?a():requestAnimationFrame(()=>{$f(t-1,a)})}function Uf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const ii=ut(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const f=ge(!0),x=ge(0),h=ge(!0);return Le(he(d,Qe(x),$e(([v,y])=>y!==0),xr(!1)),f),Le(he(d,Qe(x),$e(([v,y])=>y!==0),xr(!1)),h),pt(he(qt(a,d),Qe(f,s,t,h),$e(([[,v],y,{sizeTree:b},S,w])=>v&&(!yt(b)||Df(S))&&!y&&!w),Qe(x)),([,v])=>{sr(c,()=>{Ke(h,!0)}),$f(4,()=>{sr(i,()=>{Ke(f,!0)}),Ke(u,v)})}),{initialItemFinalLocationReached:h,initialTopMostItemIndex:x,scrolledToInitialItem:f}},Rt(br,yn,si,Sa),{singleton:!0});function gy(t,a){return Math.abs(t-a)<1.01}const ti="up",Gs="down",Wk="none",qk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Yk=0,oi=ut(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),f=ge(!0),x=it(),h=it(),v=ge(4),y=ge(Yk),b=pn(he(ff(he(Ie(c),Wa(1),xr(!0)),he(Ie(c),Wa(1),xr(!1),wg(100))),Tt()),!1),S=pn(he(ff(he(s,xr(!0)),he(s,xr(!1),wg(200))),Tt()),!1);Le(he(qt(Ie(c),Ie(y)),we(([T,A])=>T<=A),Tt()),f),Le(he(f,Ur(50)),h);const w=$n(he(qt(i,Ie(u),Ie(a),Ie(t),Ie(v)),gr((T,[{scrollHeight:A,scrollTop:B},z,P,C,O])=>{const L=B+z-A>-O,_={scrollHeight:A,scrollTop:B,viewportHeight:z};if(L){let W,q;return B>T.state.scrollTop?(W="SCROLLED_DOWN",q=T.state.scrollTop-B):(W="SIZE_DECREASED",q=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:q,state:_}}let H;return _.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":z<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:_}},qk),Tt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=pn(he(i,gr((T,{scrollHeight:A,scrollTop:B,viewportHeight:z})=>{if(!gy(T.scrollHeight,A)){const P=A-(B+z)<1;return T.scrollTop!==B&&P?{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}),$e(T=>T.changed),we(T=>T.jump)),0);Le(he(w,we(T=>T.atBottom)),d),Le(he(d,Ur(50)),x);const k=ge(Gs);Le(he(i,we(({scrollTop:T})=>T),Tt(),gr((T,A)=>zt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?ti:Gs,prevScrollTop:A},{direction:Gs,prevScrollTop:0}),we(T=>T.direction)),k),Le(he(i,Ur(50),xr(Wk)),k);const N=ge(0);return Le(he(b,$e(T=>!T),xr(0)),N),Le(he(c,Ur(100),Qe(b),$e(([T,A])=>A),gr(([T,A],[B])=>[A,B],[0,0]),we(([T,A])=>A-T)),N),{atBottomState:w,atBottomStateChange:x,atBottomThreshold:v,atTopStateChange:h,atTopThreshold:y,isAtBottom:d,isAtTop:f,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:k,scrollVelocity:N}},Rt(yn)),ni="top",ri="bottom",Tg="none";function Rg(t,a,s){return typeof t=="number"?s===ti&&a===ni||s===Gs&&a===ri?t:0:s===ti?a===ni?t.main:t.reverse:a===ri?t.main:t.reverse}function Ag(t,a){return typeof t=="number"?t:t[a]??0}const Hf=ut(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=it(),d=ge(0),f=ge(0),x=ge(0),h=pn(he(qt(Ie(i),Ie(c),Ie(s),Ie(u,Js),Ie(x),Ie(d),Ie(a),Ie(t),Ie(f)),we(([v,y,b,[S,w],E,k,N,T,A])=>{const B=v-T,z=k+N,P=Math.max(b-B,0);let C=Tg;const O=Ag(A,ni),L=Ag(A,ri);return S-=T,S+=b+N,w+=b+N,w-=T,S>v+z-O&&(C=ti),w<v-P+y+L&&(C=Gs),C!==Tg?[Math.max(B-b-Rg(E,ni,C)-O,0),B-P-N+y+Rg(E,ri,C)+L]:null}),$e(v=>v!==null),Tt(Js)),[0,0]);return{increaseViewportBy:f,listBoundary:u,overscan:x,topListHeight:d,visibleRange:h}},Rt(yn),{singleton:!0});function Kk(t,a,s){if(ic(a)){const i=py(t,a);return[{index:or(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const _d={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Po(t,a,s,i,c,u){const{lastIndex:d,lastOffset:f,lastSize:x}=c;let h=0,v=0;if(t.length>0){h=t[0].offset;const E=t[t.length-1];v=E.offset+E.size}const y=s-d,b=f+y*x+(y-1)*i,S=h,w=b-v;return{bottom:v,firstItemIndex:u,items:Lg(t,c,u),offsetBottom:w,offsetTop:h,top:S,topItems:Lg(a,c,u),topListHeight:a.reduce((E,k)=>k.size+E,0),totalCount:s}}function vy(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const v of s.groupIndices){if(v-d>=t)break;d++}const f=t+d,x=Uf(a,f),h=Array.from({length:f}).map((v,y)=>({data:u[y+x],index:y+x,offset:0,size:0}));return Po(h,[],f,c,s,i)}function Lg(t,a,s){if(t.length===0)return[];if(!ic(a))return t.map(h=>({...h,index:h.index+s,originalIndex:h.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Bl(a.groupOffsetTree,i,c);let f,x=0;for(const h of t){(!f||f.end<h.index)&&(f=d.shift(),x=a.groupIndices.indexOf(f.start));let v;h.index===f.start?v={index:x,type:"group"}:v={groupIndex:x,index:h.index-(x+1)+s},u.push({...v,data:h.data,offset:h.offset,originalIndex:h.index,size:h.size})}return u}function Mg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Xa=ut(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:f,visibleRange:x},{initialTopMostItemIndex:h,scrolledToInitialItem:v},{topListHeight:y},b,{didMount:S},{recalcInProgress:w}])=>{const E=ge([]),k=ge(0),N=it(),T=ge(0);Le(u.topItemsIndexes,E);const A=pn(he(qt(S,w,Ie(x,Js),Ie(c),Ie(i),Ie(h),v,Ie(E),Ie(a),Ie(s),Ie(T),t),$e(([C,O,,L,,,,,,,,_])=>{const H=_!==void 0&&_.length!==L;return C&&!O&&!H}),we(([,,[C,O],L,_,H,W,q,ee,$,D,I])=>{var me,je;const F=_,{offsetTree:J,sizeTree:de}=F,M=zt(k);if(L===0)return{..._d,totalCount:L};if(C===0&&O===0)return M===0?{..._d,totalCount:L}:vy(M,H,_,ee,$,I||[]);if(yt(de))return M>0?null:Po(Kk(Uf(H,L),F,I),[],L,$,F,ee);const U=[];if(q.length>0){const Ne=q[0],Me=q[q.length-1];let Fe=0;for(const Ue of Bl(de,Ne,Me)){const De=Ue.value,Ge=Math.max(Ue.start,Ne),ft=Math.min(Ue.end,Me);for(let oe=Ge;oe<=ft;oe++)U.push({data:I==null?void 0:I[oe],index:oe,offset:Fe,size:De}),Fe+=De}}if(!W)return Po([],U,L,$,F,ee);const K=q.length>0?q[q.length-1]+1:0,Q=Bk(J,C,O,K);if(Q.length===0)return null;const ce=L-1,Z=sc([],Ne=>{for(const Me of Q){const Fe=Me.value;let Ue=Fe.offset,De=Me.start;const Ge=Fe.size;if(Fe.offset<C){De+=Math.floor((C-Fe.offset+$)/(Ge+$));const oe=De-Me.start;Ue+=oe*Ge+oe*$}De<K&&(Ue+=(K-De)*Ge,De=K);const ft=Math.min(Me.end,ce);for(let oe=De;oe<=ft&&!(Ue>=O);oe++)Ne.push({data:I==null?void 0:I[oe],index:oe,offset:Ue,size:Ge}),Ue+=Ge+$}}),ie=Mg(D,ni),X=Mg(D,ri);if(Z.length>0&&(ie>0||X>0)){const Ne=Z[0],Me=Z[Z.length-1];if(ie>0&&Ne.index>K){const Fe=Math.min(ie,Ne.index-K),Ue=[];let De=Ne.offset;for(let Ge=Ne.index-1;Ge>=Ne.index-Fe;Ge--){const ft=((me=Bl(de,Ge,Ge)[0])==null?void 0:me.value)??Ne.size;De-=ft+$,Ue.unshift({data:I==null?void 0:I[Ge],index:Ge,offset:De,size:ft})}Z.unshift(...Ue)}if(X>0&&Me.index<ce){const Fe=Math.min(X,ce-Me.index);let Ue=Me.offset+Me.size+$;for(let De=Me.index+1;De<=Me.index+Fe;De++){const Ge=((je=Bl(de,De,De)[0])==null?void 0:je.value)??Me.size;Z.push({data:I==null?void 0:I[De],index:De,offset:Ue,size:Ge}),Ue+=Ge+$}}}return Po(Z,U,L,$,F,ee)}),$e(C=>C!==null),Tt()),_d);Le(he(t,$e(Df),we(C=>C==null?void 0:C.length)),c),Le(he(A,we(C=>C.topListHeight)),y),Le(y,f),Le(he(A,we(C=>[C.top,C.bottom])),d),Le(he(A,we(C=>C.items)),N);const B=$n(he(A,$e(({items:C})=>C.length>0),Qe(c,t),$e(([{items:C},O])=>C[C.length-1].originalIndex===O-1),we(([,C,O])=>[C-1,O]),Tt(Js),we(([C])=>C))),z=$n(he(A,Ur(200),$e(({items:C,topItems:O})=>C.length>0&&C[0].originalIndex===O.length),we(({items:C})=>C[0].index),Tt())),P=$n(he(A,$e(({items:C})=>C.length>0),we(({items:C})=>{let O=0,L=C.length-1;for(;C[O].type==="group"&&O<L;)O++;for(;C[L].type==="group"&&L>O;)L--;return{endIndex:C[L].index,startIndex:C[O].index}}),Tt(dy)));return{endReached:B,initialItemCount:k,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:P,startReached:z,topItemsIndexes:E,...b}},Rt(br,hy,Hf,ii,si,oi,Sa,Bf),{singleton:!0}),yy=ut(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=it(),d=pn(he(qt(s,t,i,a,c),we(([f,x,h,v,y])=>f+x+h+v+y.offsetBottom+y.bottom)),0);return Le(Ie(d),u),{totalListHeight:d,totalListHeightChanged:u}},Rt(yn,Xa),{singleton:!0}),Xk=ut(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),i=pn(he(qt(s,t,a),$e(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),Ur(0),Tt()),0);return{alignToBottom:s,paddingTopAddition:i}},Rt(yn,yy),{singleton:!0}),by=ut(()=>({context:ge(null)})),Qk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,jy=ut(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:f,viewportHeight:x},{scrollToIndex:h}])=>{const v=it();return Le(he(v,Qe(a,x,s,u,c,i,f),Qe(t),we(([[y,b,S,w,E,k,N,T],A])=>{const{calculateViewLocation:B=Qk,done:z,...P}=y,C=my(y,b,w-1),O=ei(C,b.offsetTree,A)+E+k,L=O+or(b.sizeTree,C)[1],_=T+k,H=T+S-N,W=B({itemBottom:L,itemTop:O,locationParams:P,viewportBottom:H,viewportTop:_});return W!==null?z&&sr(he(d,$e(q=>!q),Wa(zt(d)?1:2)),z):z==null||z(),W}),$e(y=>y!==null)),h),{scrollIntoView:v}},Rt(br,yn,si,Xa,ja),{singleton:!0});function zg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const Zk=(t,a)=>typeof t=="function"?zg(t(a)):a&&zg(t),Jk=ut(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:f},{didMount:x,propsReady:h},{log:v},{scrollingInProgress:y},{context:b},{scrollIntoView:S}])=>{const w=ge(!1),E=it();let k=null;function N(z){Ke(d,{align:"end",behavior:z,index:"LAST"})}pt(he(qt(he(Ie(a),Wa(1)),x),Qe(Ie(w),u,f,y),we(([[z,P],C,O,L,_])=>{let H=P&&L,W="auto";return H&&(W=Zk(C,O||_),H=H&&W!==!1),{followOutputBehavior:W,shouldFollow:H,totalCount:z}}),$e(({shouldFollow:z})=>z)),({followOutputBehavior:z,totalCount:P})=>{k!==null&&(k(),k=null),zt(s)!==void 0?requestAnimationFrame(()=>{zt(v)("following output to ",{totalCount:P},Qt.DEBUG),N(z)}):k=sr(t,()=>{zt(v)("following output to ",{totalCount:P},Qt.DEBUG),N(z),k=null})});function T(z){const P=sr(c,C=>{z&&!C.atBottom&&C.notAtBottomBecause==="SIZE_INCREASED"&&k===null&&(zt(v)("scrolling to bottom due to increased size",{},Qt.DEBUG),N("auto"))});setTimeout(P,100)}pt(he(qt(Ie(w),a,h),$e(([z,,P])=>z!==!1&&P),gr(({value:z},[,P])=>({refreshed:z===P,value:P}),{refreshed:!1,value:0}),$e(({refreshed:z})=>z),Qe(w,a)),([,z])=>{zt(f)&&T(z!==!1)}),pt(E,()=>{T(zt(w)!==!1)}),pt(qt(Ie(w),c),([z,P])=>{z!==!1&&!P.atBottom&&P.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ge(null),B=it();return Le(ff(he(Ie(i),we(z=>(z==null?void 0:z.length)??0)),he(Ie(a))),B),pt(he(qt(he(B,Wa(1)),x),Qe(Ie(A),f,y,b),we(([[z,P],C,O,L,_])=>P&&O&&(C==null?void 0:C({context:_,totalCount:z,scrollingInProgress:L}))),$e(z=>!!z),Ur(0)),z=>{k!==null&&(k(),k=null),zt(s)!==void 0?requestAnimationFrame(()=>{zt(v)("scrolling into view",{}),Ke(S,z)}):k=sr(t,()=>{zt(v)("scrolling into view",{}),Ke(S,z),k=null})}),{autoscrollToBottom:E,followOutput:w,scrollIntoViewOnChange:A}},Rt(br,oi,si,ii,Sa,ja,yn,by,jy)),ew=ut(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:f}])=>(Le(he(f,Qe(u),$e(([,x])=>x!==0),Qe(c,i,a,s,t),we(([[,x],h,v,y,b,S=[]])=>vy(x,h,v,y,b,S))),d),{}),Rt(br,ii,Xa,Sa),{singleton:!0}),tw=ut(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ge(0);return pt(he(t,Qe(i),$e(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{sr(he(s,Wa(1),$e(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Ke(a,c)})})}),{initialScrollTop:i}},Rt(Sa,yn,Xa),{singleton:!0}),Sy=ut(([{scrollVelocity:t}])=>{const a=ge(!1),s=it(),i=ge(!1);return Le(he(t,Qe(i,a,s),$e(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,f])=>{const{enter:x,exit:h}=u;if(d){if(h(c,f))return!1}else if(x(c,f))return!0;return d}),Tt()),a),pt(he(qt(a,t,s),Qe(i)),([[c,u,d],f])=>{c&&f!==!1&&f!==void 0&&f.change&&f.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},Rt(oi),{singleton:!0}),Pf=ut(([{scrollContainerState:t,scrollTo:a}])=>{const s=it(),i=it(),c=it(),u=ge(!1),d=ge(void 0);return Le(he(qt(s,i),we(([{scrollTop:f,viewportHeight:x},{offsetTop:h,listHeight:v}])=>({scrollHeight:v,scrollTop:Math.max(0,f-h),viewportHeight:x}))),t),Le(he(a,Qe(i),we(([f,{offsetTop:x}])=>({...f,top:f.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Rt(yn)),nw=ut(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:f,windowViewportRect:x}])=>{const h=it(),v=ge(void 0),y=ge(null),b=ge(null);return Le(f,y),Le(x,b),pt(he(h,Qe(a,i,d,y,b,s)),([S,w,E,k,N,T,A])=>{const B=$k(w.sizeTree);k&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Le(he(v,$e(Df),we(rw)),c),Le(he(u,Qe(v),$e(([,S])=>S!==void 0),Tt(),we(([,S])=>S.ranges)),t),{getState:h,restoreStateFrom:v}},Rt(br,yn,ii,Sa,Pf));function rw(t){return{align:"start",index:0,offset:t.scrollTop}}const aw=ut(([{topItemsIndexes:t}])=>{const a=ge(0);return Le(he(a,$e(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Rt(Xa));function ky(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const lw=ky(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),sw=ut(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:f},{listState:x},{beforeUnshiftWith:h,gap:v,shiftWithOffset:y,sizes:b},{log:S},{recalcInProgress:w}])=>{const E=$n(he(x,Qe(d),gr(([,N,T,A],[{bottom:B,items:z,offsetBottom:P,totalCount:C},O])=>{const L=B+P;let _=0;return T===C&&N.length>0&&z.length>0&&(z[0].originalIndex===0&&N[0].originalIndex===0||(_=L-A,_!==0&&(_+=O))),[_,z,C,L]},[0,[],0,0]),$e(([N])=>N!==0),Qe(i,f,s,c,S,w),$e(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===ti),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Qt.DEBUG),N))));function k(N){N>0?(Ke(a,{behavior:"auto",top:-N}),Ke(t,0)):(Ke(t,0),Ke(a,{behavior:"auto",top:-N}))}return pt(he(E,Qe(t,u)),([N,T,A])=>{A&&lw()?Ke(t,T-N):k(-N)}),pt(he(qt(pn(u,!1),t,w),$e(([N,T,A])=>!N&&!A&&T!==0),we(([N,T])=>T),Ur(1)),k),Le(he(y,we(N=>({top:-N}))),a),pt(he(h,Qe(b,v),we(([N,{groupIndices:T,lastSize:A,sizeTree:B},z])=>{function P(H){return H*(A+z)}if(T.length===0)return P(N);let C=0;const O=Zs(B,0);let L=0,_=0;for(;L<N;){L++,C+=O;let H=T.length===_+1?1/0:T[_+1]-T[_]-1;L+H>N&&(C-=O,H=N-L+1),L+=H,C+=P(H),_++}return C})),N=>{Ke(t,N),requestAnimationFrame(()=>{Ke(a,{top:N}),requestAnimationFrame(()=>{Ke(t,0),Ke(w,!1)})})}),{deviation:t}},Rt(yn,oi,Xa,br,ja,Bf)),iw=ut(([t,a,s,i,c,u,d,f,x,h,v])=>({...t,...a,...s,...i,...c,...u,...d,...f,...x,...h,...v}),Rt(Hf,ew,Sa,Sy,yy,tw,Xk,Pf,jy,ja,by)),wy=ut(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:f,itemSize:x,sizeRanges:h,sizes:v,statefulTotalCount:y,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:w,initialTopMostItemIndex:E,scrolledToInitialItem:k},N,T,A,B,{scrollToIndex:z},P,{topItemCount:C},{groupCounts:O},L])=>{const{listState:_,minOverscanItemCount:H,topItemsIndexes:W,rangeChanged:q,...ee}=B;return Le(q,L.scrollSeekRangeChanged),Le(he(L.windowViewportRect,we($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:f,initialItemFinalLocationReached:w,initialTopMostItemIndex:E,scrolledToInitialItem:k,sizeRanges:h,topItemCount:C,topItemsIndexes:W,totalCount:b,...A,groupIndices:d,itemSize:x,listState:_,minOverscanItemCount:H,scrollToIndex:z,statefulTotalCount:y,trackItemSizes:S,rangeChanged:q,...ee,...L,...N,sizes:v,...T}},Rt(br,ii,yn,nw,Jk,Xa,si,sw,aw,hy,iw));function ow(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const No=typeof document<"u"?Ae.useLayoutEffect:Ae.useEffect;function Cy(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),f=Ae.createContext({});function x(k,N){k.propsReady!==void 0&&Ke(k.propsReady,!1);for(const T of i){const A=k[a.required[T]];Ke(A,N[T])}for(const T of c)if(T in N){const A=k[a.optional[T]];Ke(A,N[T])}k.propsReady!==void 0&&Ke(k.propsReady,!0)}function h(k){return u.reduce((N,T)=>(N[T]=A=>{const B=k[a.methods[T]];Ke(B,A)},N),{})}function v(k){return d.reduce((N,T)=>(N[T]=wk(k[a.events[T]]),N),{})}const y=Ae.forwardRef(function(k,N){const{children:T,...A}=k,[B]=Ae.useState(()=>sc(Ek(t),C=>{x(C,A)})),[z]=Ae.useState(kg(v,B));No(()=>{for(const C of d)C in A&&pt(z[C],A[C]);return()=>{Object.values(z).map(_f)}},[A,z,B]),No(()=>{x(B,A)}),Ae.useImperativeHandle(N,Sg(h(B)));const P=s;return r.jsx(f.Provider,{value:B,children:s!==void 0?r.jsx(P,{...ow([...i,...c,...d],A),children:T}):T})}),b=k=>{const N=Ae.useContext(f);return Ae.useCallback(T=>{Ke(N[k],T)},[N,k])},S=k=>{const N=Ae.useContext(f)[k],T=Ae.useCallback(A=>pt(N,A),[N]);return Ae.useSyncExternalStore(T,()=>zt(N),()=>zt(N))},w=k=>{const N=Ae.useContext(f)[k],[T,A]=Ae.useState(kg(zt,N));return No(()=>pt(N,B=>{B!==T&&A(Sg(B))}),[N,T]),T},E=parseInt(Ae.version)>=18?S:w;return{Component:y,useEmitter:(k,N)=>{const T=Ae.useContext(f)[k];No(()=>pt(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const Ey=Ae.createContext(void 0),Ny=Ae.createContext(void 0),Od="-webkit-sticky",Dg="sticky",Vf=ky(()=>{if(typeof document>"u")return Dg;const t=document.createElement("div");return t.style.position=Od,t.style.position===Od?Od:Dg}),Ty=typeof document<"u"?Ae.useLayoutEffect:Ae.useEffect;function Bd(t){return"self"in t}function cw(t){return"body"in t}function Ry(t,a,s,i=Gl,c,u){const d=Ae.useRef(null),f=Ae.useRef(null),x=Ae.useRef(null),h=Ae.useCallback(b=>{let S,w,E;const k=b.target;if(cw(k)||Bd(k)){const T=Bd(k)?k:k.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,w=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?k.scrollLeft:k.scrollTop,S=u===!0?k.scrollWidth:k.scrollHeight,w=u===!0?k.offsetWidth:k.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:w})};b.suppressFlushSync===!0?N():bS.flushSync(N),f.current!==null&&(E===f.current||E<=0||E===S-w)&&(f.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Ae.useEffect(()=>{const b=c||d.current;return i(c||d.current),h({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",h,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",h)}},[d,h,s,i,c]);function v(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const w=b.behavior==="smooth";let E,k,N;Bd(S)?(k=Math.max(va(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):(k=S[u===!0?"scrollWidth":"scrollHeight"],E=va(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=k-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),gy(E,k)||b.top===N){t({scrollHeight:k,scrollTop:N,viewportHeight:E}),w&&a(!0);return}w?(f.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,f.current=null,a(!0)},1e3)):f.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function y(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:y,scrollerRef:d,scrollToCallback:v}}function Ff(t){return t}const uw=ut(()=>{const t=ge(f=>`Item ${f}`),a=ge(f=>`Group ${f}`),s=ge({}),i=ge(Ff),c=ge("div"),u=ge(Gl),d=(f,x=null)=>pn(he(s,we(h=>h[f]),Tt()),x);return{components:s,computeItemKey:i,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),dw=ut(([t,a])=>({...t,...a}),Rt(wy,uw)),fw=({height:t})=>r.jsx("div",{style:{height:t}}),pw={overflowAnchor:"none",position:Vf(),zIndex:1},Ay={overflowAnchor:"none"},mw={...Ay,display:"inline-block",height:"100%"},_g=Ae.memo(function({showTopList:t=!1}){const a=Ve("listState"),s=er("sizeRanges"),i=Ve("useWindowScroll"),c=Ve("customScrollParent"),u=er("windowScrollContainerState"),d=er("scrollContainerState"),f=c||i?u:d,x=Ve("itemContent"),h=Ve("context"),v=Ve("groupContent"),y=Ve("trackItemSizes"),b=Ve("itemSize"),S=Ve("log"),w=er("gap"),E=Ve("horizontalDirection"),{callbackRef:k}=Rk(s,b,y,t?Gl:f,S,w,c,E,Ve("skipAnimationFrameInResizeObserver")),[N,T]=Ae.useState(0);Gf("deviation",ee=>{N!==ee&&T(ee)});const A=Ve("EmptyPlaceholder"),B=Ve("ScrollSeekPlaceholder")??fw,z=Ve("ListComponent"),P=Ve("ItemComponent"),C=Ve("GroupComponent"),O=Ve("computeItemKey"),L=Ve("isSeeking"),_=Ve("groupIndices").length>0,H=Ve("alignToBottom"),W=Ve("initialItemFinalLocationReached"),q=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},...W?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...fn(A,h)}):r.jsx(z,{...fn(z,h),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:k,style:q,children:(t?a.topItems:a.items).map(ee=>{const $=ee.originalIndex,D=O($+a.firstItemIndex,ee.data,h);return L?m.createElement(B,{...fn(B,h),height:ee.size,index:ee.index,key:D,type:ee.type||"item",...ee.type==="group"?{}:{groupIndex:ee.groupIndex}}):ee.type==="group"?m.createElement(C,{...fn(C,h),"data-index":$,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:pw},v(ee.index,h)):m.createElement(P,{...fn(P,h),...vw(P,ee.data),"data-index":$,"data-item-group-index":ee.groupIndex,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:E?mw:Ay},_?x(ee.index,ee.groupIndex,ee.data,h):x(ee.index,ee.data,h))})})}),hw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},xw={outline:"none",overflowX:"auto",position:"relative"},oc=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),gw={position:Vf(),top:0,width:"100%",zIndex:1};function fn(t,a){if(typeof t!="string")return{context:a}}function vw(t,a){return{item:typeof t=="string"?void 0:a}}const yw=Ae.memo(function(){const t=Ve("HeaderComponent"),a=er("headerHeight"),s=Ve("HeaderFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ve("skipAnimationFrameInResizeObserver")),c=Ve("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),bw=Ae.memo(function(){const t=Ve("FooterComponent"),a=er("footerHeight"),s=Ve("HeaderFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ve("skipAnimationFrameInResizeObserver")),c=Ve("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null});function Ly({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ae.memo(function({children:i,style:c,context:u,...d}){const f=s("scrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),v=a("scrollerRef"),y=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:w}=Ry(f,h,x,v,void 0,y);return t("scrollTo",w),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...y?xw:hw,...c},tabIndex:0,...d,...fn(x,u),children:i})})}function My({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ae.memo(function({children:i,style:c,context:u,...d}){const f=s("windowScrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),v=a("totalListHeight"),y=a("deviation"),b=a("customScrollParent"),S=Ae.useRef(null),w=a("scrollerRef"),{scrollByCallback:E,scrollerRef:k,scrollToCallback:N}=Ry(f,h,x,w,b);return Ty(()=>{var T;return k.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{k.current=null}},[k,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...v!==0?{height:v+y}:void 0},...d,...fn(x,u),children:i})})}const jw=({children:t})=>{const a=Ae.useContext(Ey),s=er("viewportHeight"),i=er("fixedItemHeight"),c=Ve("alignToBottom"),u=Ve("horizontalDirection"),d=Ae.useMemo(()=>ry(s,x=>va(x,u?"width":"height")),[s,u]),f=Ka(d,!0,Ve("skipAnimationFrameInResizeObserver"));return Ae.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:f,style:oc(c),children:t})},Sw=({children:t})=>{const a=Ae.useContext(Ey),s=er("windowViewportRect"),i=er("fixedItemHeight"),c=Ve("customScrollParent"),u=ly(s,c,Ve("skipAnimationFrameInResizeObserver")),d=Ve("alignToBottom");return Ae.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:oc(d),children:t})},kw=({children:t})=>{const a=Ve("TopItemListComponent")??"div",s=Ve("headerHeight"),i={...gw,marginTop:`${s}px`},c=Ve("context");return r.jsx(a,{style:i,...fn(a,c),children:t})},ww=Ae.memo(function(t){const a=Ve("useWindowScroll"),s=Ve("topItemsIndexes").length>0,i=Ve("customScrollParent"),c=Ve("context");return r.jsxs(i||a?Nw:Ew,{...t,context:c,children:[s&&r.jsx(kw,{children:r.jsx(_g,{showTopList:!0})}),r.jsxs(i||a?Sw:jw,{children:[r.jsx(yw,{}),r.jsx(_g,{}),r.jsx(bw,{})]})]})}),{Component:Cw,useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}=Cy(dw,{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"}},ww),Ew=Ly({useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}),Nw=My({useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}),Tw=Cw,Rw=ut(()=>{const t=ge(h=>r.jsxs("td",{children:["Item $",h]})),a=ge(null),s=ge(h=>r.jsxs("td",{colSpan:1e3,children:["Group ",h]})),i=ge(null),c=ge(null),u=ge({}),d=ge(Ff),f=ge(Gl),x=(h,v=null)=>pn(he(u,we(y=>y[h]),Tt()),v);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});Rt(wy,Rw);Vf();const Og={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Aw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Bg,floor:qo,max:Ws,min:Id,round:Ig}=Math;function $g(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Lw(t){return{...Aw,items:t}}function To(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Mw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const zw=ut(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:f,scrollTo:x,scrollTop:h,smoothScrollTargetReached:v,viewportHeight:y},b,S,{didMount:w,propsReady:E},{customScrollParent:k,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},z])=>{const P=ge(0),C=ge(0),O=ge(Og),L=ge({height:0,width:0}),_=ge({height:0,width:0}),H=it(),W=it(),q=ge(0),ee=ge(null),$=ge({column:0,row:0}),D=it(),I=it(),F=ge(!1),J=ge(0),de=ge(!0),M=ge(!1),U=ge(!1);pt(he(w,Qe(J),$e(([X,me])=>me!==0)),()=>{Ke(de,!1)}),pt(he(qt(w,de,_,L,J,M),$e(([X,me,je,Ne,,Me])=>X&&!me&&je.height!==0&&Ne.height!==0&&!Me)),([,,,,X])=>{Ke(M,!0),$f(1,()=>{Ke(H,X)}),sr(he(h),()=>{Ke(a,[0,0]),Ke(de,!0)})}),Le(he(I,$e(X=>X!=null&&X.scrollTop>0),xr(0)),C),pt(he(w,Qe(I),$e(([,X])=>X!=null)),([,X])=>{X&&(Ke(L,X.viewport),Ke(_,X.item),Ke($,X.gap),X.scrollTop>0&&(Ke(F,!0),sr(he(h,Wa(1)),me=>{Ke(F,!1)}),Ke(x,{top:X.scrollTop})))}),Le(he(L,we(({height:X})=>X)),y),Le(he(qt(Ie(L,To),Ie(_,To),Ie($,(X,me)=>X!==void 0&&X.column===me.column&&X.row===me.row),Ie(h)),we(([X,me,je,Ne])=>({gap:je,item:me,scrollTop:Ne,viewport:X}))),D),Le(he(qt(Ie(P),i,Ie($,Mw),Ie(_,To),Ie(L,To),Ie(ee),Ie(C),Ie(F),Ie(de),Ie(J)),$e(([,,,,,,,X])=>!X),we(([X,[me,je],Ne,Me,Fe,Ue,De,,Ge,ft])=>{const{column:oe,row:ve}=Ne,{height:ye,width:be}=Me,{width:Ee}=Fe;if(De===0&&(X===0||Ee===0))return Og;if(be===0){const Xe=Uf(ft,X),kt=Xe+Math.max(De-1,0);return Lw($g(Xe,kt,Ue))}const qe=zy(Ee,be,oe);let He,jt;Ge?me===0&&je===0&&De>0?(He=0,jt=De-1):(He=qe*qo((me+ve)/(ye+ve)),jt=qe*Bg((je+ve)/(ye+ve))-1,jt=Id(X-1,Ws(jt,qe-1)),He=Id(jt,Ws(0,He))):(He=0,jt=-1);const Dt=$g(He,jt,Ue),{bottom:St,top:At}=Ug(Fe,Ne,Me,Dt),xe=Bg(X/qe),Ze=xe*ye+(xe-1)*ve-St;return{bottom:St,itemHeight:ye,items:Dt,itemWidth:be,offsetBottom:Ze,offsetTop:At,top:At}})),O),Le(he(ee,$e(X=>X!==null),we(X=>X.length)),P),Le(he(qt(L,_,O,$),$e(([X,me,{items:je}])=>je.length>0&&me.height!==0&&X.height!==0),we(([X,me,{items:je},Ne])=>{const{bottom:Me,top:Fe}=Ug(X,Ne,me,je);return[Fe,Me]}),Tt(Js)),a);const K=ge(!1);Le(he(h,Qe(K),we(([X,me])=>me||X!==0)),K);const Q=$n(he(qt(O,P),$e(([{items:X}])=>X.length>0),Qe(K),$e(([[X,me],je])=>{const Ne=X.items[X.items.length-1].index===me-1;return(je||X.bottom>0&&X.itemHeight>0&&X.offsetBottom===0&&X.items.length===me)&&Ne}),we(([[,X]])=>X-1),Tt())),ce=$n(he(Ie(O),$e(({items:X})=>X.length>0&&X[0].index===0),xr(0),Tt())),Z=$n(he(Ie(O),Qe(F),$e(([{items:X},me])=>X.length>0&&!me),we(([{items:X}])=>({endIndex:X[X.length-1].index,startIndex:X[0].index})),Tt(dy),Ur(0)));Le(Z,S.scrollSeekRangeChanged),Le(he(H,Qe(L,_,P,$),we(([X,me,je,Ne,Me])=>{const Fe=xy(X),{align:Ue,behavior:De,offset:Ge}=Fe;let ft=Fe.index;ft==="LAST"&&(ft=Ne-1),ft=Ws(0,ft,Id(Ne-1,ft));let oe=gf(me,Me,je,ft);return Ue==="end"?oe=Ig(oe-me.height+je.height):Ue==="center"&&(oe=Ig(oe-me.height/2+je.height/2)),Ge!==void 0&&Ge!==0&&(oe+=Ge),{behavior:De,top:oe}})),x);const ie=pn(he(O,we(X=>X.offsetBottom+X.bottom)),0);return Le(he(B,we(X=>({height:X.visibleHeight,width:X.visibleWidth}))),L),{customScrollParent:k,data:ee,deviation:q,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:C,itemDimensions:_,overscan:s,restoreStateFrom:I,scrollBy:d,scrollContainerState:f,scrollHeight:W,scrollTo:x,scrollToIndex:H,scrollTop:h,smoothScrollTargetReached:v,totalCount:P,useWindowScroll:N,viewportDimensions:L,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:U,initialTopMostItemIndex:J,totalListHeight:ie,...b,endReached:Q,propsReady:E,rangeChanged:Z,startReached:ce,stateChanged:D,stateRestoreInProgress:F,...z}},Rt(Hf,yn,oi,Sy,Sa,Pf,ja));function zy(t,a,s){return Ws(1,qo((t+s)/(qo(a)+s)))}function Ug(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=gf(t,a,s,i[0].index);return{bottom:gf(t,a,s,i[i.length-1].index)+c,top:u}}function gf(t,a,s,i){const c=zy(t.width,s.width,a.column),u=qo(i/c),d=u*s.height+Ws(0,u-1)*a.row;return d>0?d+a.row:d}const Dw=ut(()=>{const t=ge(y=>`Item ${y}`),a=ge({}),s=ge(null),i=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Ff),d=ge("div"),f=ge(Gl),x=(y,b=null)=>pn(he(a,we(S=>S[y]),Tt()),b),h=ge(!1),v=ge(!1);return Le(Ie(v),h),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:h,reportReadyState:v,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),_w=ut(([t,a])=>({...t,...a}),Rt(zw,Dw)),Ow=Ae.memo(function(){const t=Mt("gridState"),a=Mt("listClassName"),s=Mt("itemClassName"),i=Mt("itemContent"),c=Mt("computeItemKey"),u=Mt("isSeeking"),d=tr("scrollHeight"),f=Mt("ItemComponent"),x=Mt("ListComponent"),h=Mt("ScrollSeekPlaceholder"),v=Mt("context"),y=tr("itemDimensions"),b=tr("gap"),S=Mt("log"),w=Mt("stateRestoreInProgress"),E=tr("reportReadyState"),k=Ka(Ae.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:z}=A.getBoundingClientRect();y({height:B,width:z})}b({column:Hg("column-gap",getComputedStyle(N).columnGap,S),row:Hg("row-gap",getComputedStyle(N).rowGap,S)})},[d,y,b,S]),!0,!1);return Ty(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),w?null:r.jsx(x,{className:a,ref:k,...fn(x,v),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,v);return u?r.jsx(h,{...fn(h,v),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(f,{...fn(f,v),className:s,"data-index":N.index,key:T},i(N.index,N.data,v))})})}),Bw=Ae.memo(function(){const t=Mt("HeaderComponent"),a=tr("headerHeight"),s=Mt("headerFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=Mt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),Iw=Ae.memo(function(){const t=Mt("FooterComponent"),a=tr("footerHeight"),s=Mt("headerFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=Mt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),$w=({children:t})=>{const a=Ae.useContext(Ny),s=tr("itemDimensions"),i=tr("viewportDimensions"),c=Ka(Ae.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Ae.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:oc(!1),children:t})},Uw=({children:t})=>{const a=Ae.useContext(Ny),s=tr("windowViewportRect"),i=tr("itemDimensions"),c=Mt("customScrollParent"),u=ly(s,c,!1);return Ae.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:oc(!1),children:t})},Hw=Ae.memo(function({...t}){const a=Mt("useWindowScroll"),s=Mt("customScrollParent"),i=s||a?Vw:Pw,c=s||a?Uw:$w,u=Mt("context");return r.jsx(i,{...t,...fn(i,u),children:r.jsxs(c,{children:[r.jsx(Bw,{}),r.jsx(Ow,{}),r.jsx(Iw,{})]})})}),{useEmitter:Dy,useEmitterValue:Mt,usePublisher:tr}=Cy(_w,{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"}},Hw),Pw=Ly({useEmitter:Dy,useEmitterValue:Mt,usePublisher:tr}),Vw=My({useEmitter:Dy,useEmitterValue:Mt,usePublisher:tr});function Hg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Qt.WARN),a==="normal"?0:parseInt(a??"0",10)}const Fw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},_y={source:"Own",installed:"Installed"};function Gw(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 Ww(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Pg({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=Fw[t],[d,f]=m.useState(()=>Gw(u)),x=m.useCallback(()=>{f(b=>{const S=!b;return Ww(u,S),S})},[u]),h=_y[t],v=`sidebar-section-${t}-header`,y=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:v,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":y,onClick:x,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(Yw,{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:h}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),i!=null&&i>0&&r.jsx(qw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:y,role:"group","aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function qw({origin:t,updateCount:a}){const[s,i]=m.useState(!1),c=_y[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>i(!0),onBlur:()=>i(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Yw({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 Wf(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 Kw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),f=!!i&&t.trim()!==""&&!i.test(t);return m.useEffect(()=>{function x(h){var b;if(h.key!=="/")return;const v=h.target;if(!v)return;const y=v.tagName;y==="INPUT"||y==="TEXTAREA"||v.isContentEditable||(h.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":f?!0:void 0,"aria-describedby":f?d:void 0,value:t,placeholder:s,onChange:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),f&&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 Xw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function Qw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function Zw({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(Wv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Jw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ci(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",f=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!f.startsWith("v")?`v${f}`:f,h=i==="sm"?10:12,v=i==="sm"?1:2,y=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=Jw(c,f,u),w=t.title??S,E={display:"inline-flex",alignItems:"center",padding:`${v}px ${y}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:h,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(E.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":f,"data-version-source":c,title:w,style:E,children:x})}function eC({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(d,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(ci,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(Xw,{target:t.symlinkTarget??null}),r.jsx(Qw,{skill:t}),r.jsx(Zw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const qs=m.memo(eC);function tC({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){var v;const d=[...a].sort((y,b)=>y.skill.localeCompare(b.skill)),f=(v=a[0])==null?void 0:v.pluginDisplay,x=t.replace(/^\./,"").toLowerCase(),h=!!f&&f.toLowerCase()!==x;return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",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,")"]}),h&&r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary, var(--text-secondary))",opacity:.75,fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:f,children:f})]}),r.jsx("div",{role:"list",children:d.map(y=>{const b=!!s&&s.plugin===y.plugin&&s.skill===y.skill;return r.jsx("div",{role:"listitem",children:r.jsx(qs,{skill:y,isSelected:b,onSelect:()=>i(y),onContextMenu:c,dirty:u==null?void 0:u.has(`${y.plugin}/${y.skill}`)})},`${y.plugin}/${y.skill}`)})})]})}function nC(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 $d({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const f=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,h]=m.useState(()=>nC(i,s)),v=d?!1:x,y=m.useCallback(()=>{h(w=>{const E=!w;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(E))}catch{}return E})},[i]),b=v?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":f,role:"group","aria-label":`${f} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!v,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:f}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!v&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(w=>r.jsx("div",{"data-vskill-plugin-skill":w.pluginNamespace??w.skill,children:c(w)},`${w.pluginNamespace??w.skill}`))})]})}function Vo({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:f}){const x=m.useRef(null),h=m.useRef(null),v=m.useRef(null);if(m.useEffect(()=>{if(t)return v.current=document.activeElement??null,requestAnimationFrame(()=>{var w;(w=h.current)==null||w.focus()}),()=>{var w,E;(E=(w=v.current)==null?void 0:w.focus)==null||E.call(w),v.current=null}},[t]),m.useEffect(()=>{if(!t)return;function w(E){if(E.key==="Escape"){E.preventDefault(),f();return}if(E.key==="Tab"&&x.current){const k=x.current.querySelectorAll("button:not([disabled])");if(k.length===0)return;const N=k[0],T=k[k.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[t,f]),!t)return null;const y="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:w=>{w.target===w.currentTarget&&f()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":y,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:y,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:h,type:"button","data-testid":"confirm-dialog-cancel",onClick:f,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:i})]})]})})}function rC(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Ud(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function aC({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=m.useState(!1),[u,d]=m.useState(null),[f,x]=m.useState(null),[h,v]=m.useState(!1),y=m.useRef(null);m.useEffect(()=>{if(!i)return;function w(E){y.current&&!y.current.contains(E.target)&&c(!1)}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]);async function b(w){d(w),x(null);try{const E=await fetch(`/api/plugins/${encodeURIComponent(t)}/${w}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),k=await E.json().catch(()=>({}));if(!E.ok||!k.ok){const N=k.error??`${w} failed (${E.status})`;x(N),w==="uninstall"&&Ud(`Failed to uninstall ${t}: ${N}`,"error");return}if(w==="uninstall"){const N=k.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Ud(N,"success")}In("skills"),ty(),s==null||s(),c(!1)}catch(E){const k=E instanceof Error?E.message:String(E);x(k),w==="uninstall"&&Ud(`Failed to uninstall ${t}: ${k}`,"error")}finally{d(null)}}function S(){v(!0)}return r.jsxs("div",{ref:y,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:w=>{w.stopPropagation(),c(E=>!E)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:w=>{w.currentTarget.style.color="var(--text-primary)",w.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:w=>{w.currentTarget.style.color="var(--text-tertiary)",w.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Hd,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Hd,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Hd,{onClick:S,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),f&&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:f})]}),r.jsx(Vo,{open:h,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{v(!1),c(!1)},onConfirm:()=>{v(!1),b("uninstall")}})]})}function Hd({onClick:t,disabled:a,busy:s,label:i,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}const lC=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function sC({anchorSkillDir:t,candidateLabel:a,initialName:s,initialDescription:i,onConverted:c,onCancel:u}){const[d,f]=m.useState(s),[x,h]=m.useState(i??""),[v,y]=m.useState(!1),[b,S]=m.useState(null),[w,E]=m.useState(null),k=lC.test(d),N=v||!k,T=m.useCallback(async A=>{if(A.preventDefault(),!N){y(!0),S(null),E(null);try{const B=await ke.convertToPlugin({anchorSkillDir:t,pluginName:d.trim(),description:x.trim()});c({pluginDir:B.pluginDir,manifestPath:B.manifestPath,validation:B.validation})}catch(B){if(B instanceof Ga){S(B.message);const z=B.details;z&&typeof z.stderr=="string"&&E(z.stderr)}else S(B instanceof Error?B.message:String(B));y(!1)}}},[N,t,d,x,c]);return r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"vskill-convert-dialog-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:A=>{A.target===A.currentTarget&&!v&&u()},children:r.jsxs("form",{onSubmit:T,style:{background:"var(--bg-primary, #fff)",color:"var(--text-primary, #111)",borderRadius:8,padding:20,width:"min(540px, 92vw)",boxShadow:"0 12px 48px rgba(0,0,0,0.25)",fontFamily:"var(--font-sans)"},children:[r.jsxs("h2",{id:"vskill-convert-dialog-title",style:{margin:0,fontSize:16,fontWeight:600},children:["Convert ",r.jsxs("span",{style:{fontFamily:"var(--font-mono)"},children:[a,"/"]})," to a plugin"]}),r.jsxs("p",{style:{marginTop:8,marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:["Writes ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:".claude-plugin/plugin.json"})," into this folder and validates it via ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:"claude plugin validate"}),". The skills already on disk will appear nested under the new plugin."]}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginBottom:4},children:"Plugin name"}),r.jsx("input",{type:"text",value:d,onChange:A=>f(A.target.value),disabled:v,autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontSize:13,fontFamily:"var(--font-mono)",boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),!k&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #c00)",marginTop:4},children:"Must be kebab-case (lowercase letters, digits, hyphens; 2–64 chars)."}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginTop:12,marginBottom:4},children:"Description"}),r.jsx("input",{type:"text",value:x,onChange:A=>h(A.target.value),disabled:v,style:{width:"100%",padding:"6px 8px",fontSize:13,boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),b&&r.jsxs("div",{role:"alert",style:{marginTop:12,padding:8,fontSize:12,background:"var(--color-error-bg, #fee)",color:"var(--color-error, #c00)",borderRadius:4},children:[r.jsx("div",{style:{fontWeight:500},children:b}),w&&r.jsx("pre",{style:{marginTop:6,padding:6,fontSize:11,fontFamily:"var(--font-mono)",whiteSpace:"pre-wrap",background:"rgba(0,0,0,0.04)",borderRadius:3,maxHeight:160,overflow:"auto"},children:w})]}),r.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{type:"button",onClick:u,disabled:v,style:{padding:"6px 12px",fontSize:13,background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,cursor:v?"not-allowed":"pointer"},children:"Cancel"}),r.jsx("button",{type:"submit",disabled:N,style:{padding:"6px 12px",fontSize:13,background:"var(--color-accent, #2b6cb0)",color:"white",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",opacity:N?.5:1},children:v?"Converting…":"Convert"})]})]})})}function Vg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const f=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=i==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",h=typeof u=="function",v={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:x,borderLeft:`3px solid ${f}`,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:h?"pointer":"default",border:"none",textAlign:"left"},y=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[h&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:f,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:y}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(iC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:f})})]});return h?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:v,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:v,children:b})}function iC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function oC(){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 cC(t){const a=t.key.split("+").map(f=>f.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const f of a.slice(0,-1)){const x=f.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?i=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function uC(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 dC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function vf(t,a={}){const{enabled:s=!0,target:i}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(cC),m.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function f(x){const h=x,v=uC(h.target);for(const y of c.current){if(!dC(h,y))continue;const b=y.meta||y.ctrl||y.alt;if(!(v&&!y.allowInInputs&&!b)){y.handler(h);return}}}return d.addEventListener("keydown",f),()=>{d.removeEventListener("keydown",f)}},[s,i])}function Oy(){const{data:t,loading:a,error:s,revalidate:i}=qa("project-github-status",()=>ke.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function fC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function pC({projectRoot:t}){const{status:a,loading:s}=Oy();if(s||!a||a.status==="github"||fC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const mC=200;function hC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function xC(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const d of t){const f=d.scopeV2??(d.scope==="installed"?"available-project":d.scope==="global"?"available-personal":"authoring-project");f==="available-project"?s.availableProject.push(d):f==="available-personal"?s.availablePersonal.push(d):f==="available-plugin"?s.availablePlugin.push(d):f==="authoring-plugin"?s.authoringPlugin.push(d):s.authoringProject.push(d)}function i(d){const f=d.filter(v=>Wf(v,a)),x={};for(const v of f){const y=v.pluginName??v.plugin;(x[y]||(x[y]=[])).push(v)}const h=Object.entries(x).sort((v,y)=>v[0].localeCompare(y[0]));return{total:d.length,filtered:f.length,byPlugin:h}}const c=i(s.authoringProject),u=c.byPlugin.filter(([d,f])=>f.length>=2&&d.trim().length>=2).map(([d,f])=>({groupKey:d,skills:f,anchorSkillDir:f[0].dir}));return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:c,authoringPlugin:i(s.authoringPlugin),authoringCandidatePlugins:u}}function gC(t,a){const s=[],i=[],c=[];for(const d of t){const f=hC(d);f==="global"?c.push(d):f==="installed"?i.push(d):s.push(d)}function u(d){var v;const f=d.filter(y=>Wf(y,a)),x={};for(const y of f)(x[v=y.plugin]||(x[v]=[])).push(y);const h=Object.entries(x).sort((y,b)=>y[0].localeCompare(b[0]));return{total:d.length,filtered:f.length,byPlugin:h}}return{own:u(s),installed:u(i),global:u(c)}}function vC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var h;const d=u.filter(v=>Wf(v,a)),f={};for(const v of d)(f[h=v.plugin]||(f[h]=[])).push(v);const x=Object.entries(f).sort((v,y)=>v[0].localeCompare(y[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function yC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:f,activeAgentId:x,outdatedByScope:h,topSlot:v,revealSkillId:y,onRevealComplete:b,dirtySkillIds:S,onSkillsChanged:w}){const[E,k]=m.useState(null),N=!!x||t.some(ie=>ie.scope!==void 0&&ie.scope!==null),T=x??"claude-cli",[A,B]=m.useState(""),z=m.useDeferredValue(A),P=m.useMemo(()=>gC(t,z),[t,z]),C=m.useMemo(()=>xC(t,z),[t,z]),O=T==="claude-code",{plugins:L}=vk(),_=O?{plugins:L??[]}:void 0,H=m.useMemo(()=>{const ie=new Map;for(const X of(_==null?void 0:_.plugins)??[]){const me=ie.get(X.name);ie.set(X.name,!!me||!!X.enabled)}return ie},[_==null?void 0:_.plugins]),[W,q]=m.useState(()=>yf(`vskill-sidebar-${T}-group-available-collapsed`)),[ee,$]=m.useState(()=>yf(`vskill-sidebar-${T}-group-authoring-collapsed`)),D=m.useCallback(ie=>{q(ie);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-available-collapsed`,String(ie))}catch{}},[T]),I=m.useCallback(ie=>{$(ie);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-authoring-collapsed`,String(ie))}catch{}},[T]),{own:F,installed:J}=m.useMemo(()=>vC(t,z),[t,z]),M=P.own.filtered+P.installed.filtered+P.global.filtered>=mC,U=m.useMemo(()=>{const ie=X=>{const me=[];for(const[,je]of X){const Ne=[...je].sort((Me,Fe)=>Me.skill.localeCompare(Fe.skill));me.push(...Ne)}return me};return N?[...ie(P.own.byPlugin),...ie(P.installed.byPlugin),...ie(P.global.byPlugin)]:[...ie(F.byPlugin),...ie(J.byPlugin)]},[N,P.own.byPlugin,P.installed.byPlugin,P.global.byPlugin,F.byPlugin,J.byPlugin]),K=m.useMemo(()=>a?U.findIndex(ie=>ie.plugin===a.plugin&&ie.skill===a.skill):-1,[U,a]),Q=m.useCallback(ie=>{if(U.length===0)return;const X=K<0?ie>0?0:U.length-1:Math.min(Math.max(K+ie,0),U.length-1);s(U[X])},[U,K,s]),ce=m.useMemo(()=>{if(!y)return null;const[ie,X]=y.split("/");if(!ie||!X)return null;const me=t.find(Me=>Me.plugin===ie&&Me.skill===X);if(!me)return{plugin:ie,skill:X,bucket:null,pluginName:null};const je=me.source==="plugin"?"plugin":"project",Ne=je==="plugin"?me.pluginName??ie:null;return{plugin:ie,skill:X,bucket:je,pluginName:Ne}},[y,t]),Z=m.useRef(null);return m.useEffect(()=>{if(!y){Z.current=null;return}if(Z.current===y)return;const ie=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(y):y.replace(/["\\]/g,"\\$&"),X=document.querySelector(`[data-skill-id="${ie}"]`);X&&(Z.current=y,X.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[y,b,t]),vf([{key:"j",handler:()=>Q(1)},{key:"k",handler:()=>Q(-1)},{key:"Enter",handler:()=>{K>=0&&s(U[K])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[v,r.jsx(Kw,{value:A,onChange:B}),i&&r.jsx(EC,{}),!i&&c&&r.jsx(NC,{error:c,onRetry:u}),!i&&!c&&N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Vg,{name:le.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:W,onToggle:D,count:C.availableProject.total+C.availablePersonal.total+C.availablePlugin.total}),!W&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:le.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${T}-available-project-collapsed`,count:C.availableProject.total,filteredCount:A?C.availableProject.filtered:null,updateCount:(h==null?void 0:h.installed)??(f==null?void 0:f.installed),headerRightSlot:O?r.jsx(pC,{projectRoot:T}):null,children:C.availableProject.filtered===0?r.jsx(Gg,{queryActive:!!A,agentId:T}):r.jsx($s,{items:C.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})}),r.jsx(Is,{label:le.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${T}-available-personal-collapsed`,count:C.availablePersonal.total,filteredCount:A?C.availablePersonal.filtered:null,updateCount:h==null?void 0:h.global,children:C.availablePersonal.filtered===0?r.jsx(jC,{queryActive:!!A,agentId:T}):r.jsx($s,{items:C.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})}),O&&r.jsxs(Is,{label:le.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-available-plugin-collapsed`,count:C.availablePlugin.total,filteredCount:A?C.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…"]}),C.availablePlugin.filtered===0?r.jsx(SC,{queryActive:!!A,hasInstalled:C.availablePlugin.total>0}):C.availablePlugin.byPlugin.map(([ie,X])=>r.jsx($d,{pluginName:ie,skills:X,persistKey:`vskill-plugin-available-${ie}-collapsed`,headerActionSlot:O?r.jsx(aC,{pluginName:ie,enabled:H.get(ie)??!0}):void 0,renderSkill:me=>r.jsx(qs,{skill:me,isSelected:(a==null?void 0:a.plugin)===me.plugin&&(a==null?void 0:a.skill)===me.skill,onSelect:()=>s(me),onContextMenu:d,dirty:S==null?void 0:S.has(`${me.plugin}/${me.skill}`)})},`available-${ie}`))]})]}),r.jsx(CC,{}),r.jsx(Vg,{name:le.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:ce?!1:ee,onToggle:I,count:C.authoringProject.total+C.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"}}))}}}),(!ee||ce)&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:le.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${T}-authoring-project-collapsed`,count:C.authoringProject.total,filteredCount:A?C.authoringProject.filtered:null,updateCount:(h==null?void 0:h.own)??(f==null?void 0:f.source),forceOpen:(ce==null?void 0:ce.bucket)==="project",children:C.authoringProject.filtered===0?r.jsx(Fg,{queryActive:!!A}):r.jsxs(r.Fragment,{children:[C.authoringCandidatePlugins.map(ie=>r.jsx($d,{pluginName:ie.groupKey,skills:ie.skills,persistKey:`vskill-candidate-plugin-${ie.groupKey}-collapsed`,headerActionSlot:r.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),k({candidateLabel:ie.groupKey,initialName:ie.groupKey,anchorSkillDir:ie.anchorSkillDir})},title:"Write .claude-plugin/plugin.json into this folder so Claude Code recognizes it as a plugin",style:{fontSize:10,fontWeight:500,padding:"2px 8px",borderRadius:10,border:"1px solid var(--border-subtle, rgba(128,128,128,0.3))",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Not a plugin yet · Convert →"}),renderSkill:X=>r.jsx(qs,{skill:X,isSelected:(a==null?void 0:a.plugin)===X.plugin&&(a==null?void 0:a.skill)===X.skill,onSelect:()=>s(X),onContextMenu:d,dirty:S==null?void 0:S.has(`${X.plugin}/${X.skill}`)})},`candidate-${ie.groupKey}`)),r.jsx($s,{items:C.authoringProject.byPlugin.filter(([ie])=>!C.authoringCandidatePlugins.some(X=>X.groupKey===ie)),selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})]})}),O&&r.jsx(Is,{label:le.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-authoring-plugin-collapsed`,count:C.authoringPlugin.total,filteredCount:A?C.authoringPlugin.filtered:null,forceOpen:(ce==null?void 0:ce.bucket)==="plugin",children:C.authoringPlugin.filtered===0?r.jsx(kC,{queryActive:!!A,hasSources:C.authoringPlugin.total>0,candidates:C.authoringCandidatePlugins,onPromote:ie=>k({candidateLabel:ie.groupKey,initialName:ie.groupKey,anchorSkillDir:ie.anchorSkillDir})}):C.authoringPlugin.byPlugin.map(([ie,X])=>r.jsx($d,{pluginName:ie,skills:X,persistKey:`vskill-plugin-authoring-${ie}-collapsed`,forceOpen:(ce==null?void 0:ce.bucket)==="plugin"&&ce.pluginName===ie,renderSkill:me=>r.jsx(qs,{skill:me,isSelected:(a==null?void 0:a.plugin)===me.plugin&&(a==null?void 0:a.skill)===me.skill,onSelect:()=>s(me),onContextMenu:d,dirty:S==null?void 0:S.has(`${me.plugin}/${me.skill}`)})},`authoring-${ie}`))})]})]}),!i&&!c&&!N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Pg,{origin:"source",count:F.total,filteredCount:A?F.filtered:null,updateCount:f==null?void 0:f.source,children:F.filtered===0?r.jsx(Fg,{queryActive:!!A}):r.jsx($s,{items:F.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})}),r.jsx(wC,{}),r.jsx(Pg,{origin:"installed",count:J.total,filteredCount:A?J.filtered:null,updateCount:f==null?void 0:f.installed,children:J.filtered===0?r.jsx(Gg,{queryActive:!!A}):r.jsx($s,{items:J.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})})]}),E&&r.jsx(sC,{anchorSkillDir:E.anchorSkillDir,candidateLabel:E.candidateLabel,initialName:E.initialName,onCancel:()=>k(null),onConverted:ie=>{k(null),w==null||w(),ie.validation==="skipped"&&window.alert("Plugin manifest written, but schema validation was skipped because the 'claude' CLI is not on PATH. Install Claude Code to enable plugin schema validation.")}})]})}function yf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Is({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:f}){const[x,h]=m.useState(()=>yf(a)),v=d?!1:x,y=m.useCallback(()=>{h(S=>{const w=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(w))}catch{}return w})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!v,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:v?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),f]}),!v&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function bC(t){const a=[];for(const[s,i]of t){const c=[...i].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function $s({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=bC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Tw,{overscan:4,totalCount:d.length,itemContent:f=>{const x=d[f];if(!x)return null;if(x.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const h=x.skill,v=!!a&&a.plugin===h.plugin&&a.skill===h.skill;return r.jsx(qs,{skill:h,isSelected:v,onSelect:()=>s(h),onContextMenu:i,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,f])=>r.jsx(tC,{plugin:d,skills:f,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Fg({queryActive:t}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx($l,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Gg({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install <skill>"})," to add one."]})})}function jC({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install --global <skill>"})," to add one."]})})}function SC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx($l,{children:"Browse marketplaces…"})," above to add one."]})})}function kC({queryActive:t,hasSources:a,candidates:s,onPromote:i}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsxs(r.Fragment,{children:[r.jsx(yr,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx($l,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",r.jsx($l,{children:"vskill plugin new"})," from the terminal."]})}),s&&s.length>0&&r.jsxs("div",{style:{padding:"0 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[r.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:["Candidate folders (",s.length,")"]}),s.map(c=>r.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(c),title:`Promote ${c.groupKey}/ to a Claude Code plugin`,style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,padding:"6px 8px",fontSize:12,background:"transparent",border:"1px dashed var(--border-subtle, rgba(128,128,128,0.35))",borderRadius:4,color:"var(--text-primary)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)"},children:[r.jsxs("span",{children:[c.groupKey,"/ ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",c.skills.length," skills)"]})]}),r.jsx("span",{style:{fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)"},children:"Promote →"})]},`promote-${c.groupKey}`))]})]})}function yr({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 $l({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 wC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function CC(){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 EC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(oC,{},t))})}function NC({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:TC(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 TC(t){const a=t.split(`
|
|
65
|
+
}`})]})}const F2="/assets/skill-studio-logo-CRyKgIrg.png";function mg(){typeof window>"u"||(window.location.hash="#/")}function G2({onHome:t}){const[a,s]=m.useState(!1),[i,c]=m.useState(!1),u=f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.button!==0||(f.preventDefault(),mg(),t==null||t())},d=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),mg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:i?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("img",{src:F2,alt:"","aria-hidden":"true",width:28,height:28,style:{display:"block",objectFit:"contain",flexShrink:0}}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const hg=m.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function W2({toast:t,onDismiss:a}){const[s,i]=m.useState(!0),c=m.useRef(null);m.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function q2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(hg,{politeness:"polite",message:s}),r.jsx(hg,{politeness:"assertive",message:i}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(W2,{toast:c,onDismiss:a})},c.id))})]})}const Qv=m.createContext(null);function rc(){const t=m.useContext(Qv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function Y2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=m.useState([]),[u,d]=m.useState(""),[f,x]=m.useState(""),h=m.useRef(new Map),v=m.useCallback(k=>{const N=h.current.get(k);N&&(clearTimeout(N),h.current.delete(k)),c(T=>T.filter(A=>A.id!==k))},[]),y=m.useCallback((k,N)=>{if(N<=0)return;const T=setTimeout(()=>{v(k)},N);h.current.set(k,T)},[v]),b=m.useCallback(k=>{const N=k.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:k.message,severity:k.severity??"info",durationMs:k.durationMs??s,action:k.action};return c(A=>[...A,T]),T.severity==="error"?x(T.message):d(T.message),y(N,T.durationMs),N},[s,y]),S=m.useCallback(()=>{for(const k of h.current.values())clearTimeout(k);h.current.clear(),c([])},[]);m.useEffect(()=>{function k(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),B=A[A.length-1],z=h.current.get(B.id);return z&&(clearTimeout(z),h.current.delete(B.id)),T.filter(P=>P.id!==B.id)})}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[a]),m.useEffect(()=>()=>{for(const k of h.current.values())clearTimeout(k);h.current.clear()},[]);const w=i.slice(0,a),E=m.useMemo(()=>({toast:b,dismiss:v,clear:S}),[b,v,S]);return r.jsxs(Qv.Provider,{value:E,children:[t,r.jsx(q2,{toasts:w,onDismiss:v,liveMessage:u,liveAssertiveMessage:f})]})}function K2(){const{data:t,loading:a}=qa("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const X2=m.lazy(()=>Vl(()=>import("./UpdateDropdown-DcRoBdFQ.js"),__vite__mapDeps([0,1])));function Q2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:f,activeAgent:x}=cr(),{toast:h}=rc(),{data:v}=K2(),y=(v==null?void 0:v.degraded)===!0,b=m.useMemo(()=>{if(!f||f.size===0)return;const P=new Map;for(const[C,O]of f)O.diffSummary&&P.set(C,O.diffSummary);return P.size>0?P:void 0},[f]),[S,w]=m.useState(!1),E=m.useRef(null),k=m.useCallback(()=>w(!1),[]),N=y?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),A=t===0?"No updates available":`${t} updates available, open summary`,B=y?`${A} — platform crawler degraded`:A,z=y?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:E,type:"button","data-testid":"update-bell","aria-label":B,"aria-haspopup":"dialog","aria-expanded":S,title:z,onClick:()=>w(P=>!P),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||y?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:T})]}),S&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(X2,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:P=>{const C=P.localSkill??P.name.split("/").pop()??"",O=P.localPlugin??"";if(u)u(O,C);else{const _=P.name.split("/"),H=_.length>=2?_[_.length-2]:_[0];c({plugin:H,skill:C,origin:"installed"})}if(!(d??[]).some(_=>_.skill===C&&(O===""||_.plugin===O))){const _=P.installLocations??[];if(_.length>0){const H=x?_.filter(q=>q.agent===x):[],W=x?_.filter(q=>q.agent!==x):_;if(H.length>0&&W.length>0){const q=W.length>=2?`Also installed under ${W.length} other locations.`:`Also installed under ${W[0].agentLabel}.`;h({severity:"info",message:q})}else{const q=_[0].agentLabel;h({severity:"info",message:`Skill installed under ${q} — switch to ${q} to view details.`})}}}k()},onViewAll:()=>{window.location.hash="#/updates",k()},onClose:k,anchorRef:E})})]})}function xg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function Z2(t){return t.source==="project"?le.scopeLabels.sourceProject:t.source==="personal"?le.scopeLabels.sourcePersonal:t.source==="plugin"?le.scopeLabels.sourcePlugin:t.origin==="installed"?le.scopeLabels.sourcePersonal:le.scopeLabels.sourceProject}function J2(t){return t.source==="project"?"var(--status-installed)":t.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)"}function ek({projectName:t,selected:a,onHome:s,projectPickerSlot:i,onRequestCreateSkill:c,findSkillsSlot:u}){const d=a?Z2(a):null,f=a?J2(a):"var(--text-secondary)";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(G2,{onHome:s}),i?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:i}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&d&&r.jsxs(r.Fragment,{children:[r.jsx(gg,{segment:"origin",onClick:()=>xg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:f},children:d}),r.jsx(vg,{}),r.jsx(gg,{segment:"plugin",onClick:()=>xg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(vg,{}),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:12,flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u,c&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:c,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]})]}),r.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"var(--border-default)"}}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(P2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(Q2,{})})]})]})]})}function gg({segment:t,onClick:a,style:s,children:i}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:i})}function vg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const ac="vskill-theme";function Zv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function tk(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function nk(t){try{const a=t.getItem(ac);return Zv(a)}catch{return"auto"}}function rk(t,a){try{t.setItem(ac,a)}catch{}}function ak(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function lk(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Jv=m.createContext(null);function sk({storage:t,matchMedia:a,target:s,children:i}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[f,x]=m.useState(()=>c?nk(c):"auto"),[h,v]=m.useState(()=>lk(u)),y=m.useMemo(()=>tk(f,h),[f,h]);m.useEffect(()=>{d&&ak(d,f,y)},[d,f,y]),m.useEffect(()=>{if(!u)return;const w=u("(prefers-color-scheme: dark)"),E=N=>v(N.matches);if(typeof w.addEventListener=="function")return w.addEventListener("change",E),()=>w.removeEventListener("change",E);const k=w;return k.addListener(E),()=>k.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const w=E=>{E.key===ac&&x(Zv(E.newValue))};return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[]),m.useEffect(()=>{if(!u||!d)return;let w;try{w=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(w.matches);const k=T=>E(T.matches);if(typeof w.addEventListener=="function")return w.addEventListener("change",k),()=>w.removeEventListener("change",k);const N=w;return N.addListener(k),()=>N.removeListener(k)},[u,d]);const b=m.useCallback(w=>{x(w),c&&rk(c,w)},[c]),S=m.useMemo(()=>({mode:f,resolvedTheme:y,setTheme:b}),[f,y,b]);return r.jsx(Jv.Provider,{value:S,children:i})}function ey(){const t=m.useContext(Jv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const yg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function ik(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of yg){const c=a.get(i);c&&s.push(c)}for(const i of t)yg.includes(i.id)||s.push(i);return s}function ok(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 i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function ck({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=ik(t),c=ok(640),[u,d]=m.useState(!1),f=m.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=i.filter(h=>h.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":le.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:le.statusBar.providerSummary(x,i.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:i.map(h=>r.jsx(bg,{p:h,onClick:f},h.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(x=>r.jsx(bg,{p:x,onClick:f,compact:!0},x.id))})}function bg({p:t,onClick:a,compact:s}){const i=t.available?le.statusBar.unlocked(t.label):t.kind==="cli-install"?le.statusBar.lockedCli(t.label):le.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(uf,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function uk(){try{return typeof localStorage>"u"?null:localStorage.getItem(ac)}catch{return null}}function dk({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:f,resolvedTheme:x,setTheme:h}=ey(),y=uk()==="auto",b=fk(f,x,y),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(jg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(pk,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(jg,{}),r.jsx(ck,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>h(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${f} — 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(mk,{mode:f}),r.jsx("span",{style:{textTransform:"capitalize"},children:f})]})]})}function fk(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function pk({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function jg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function mk({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 df=new Set;function ty(){for(const t of df)t()}const hk=5,xk=1e3,gk=6e4;function vk(){const[t,a]=m.useState(void 0),[s,i]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),f=m.useRef(null),x=m.useRef(null),h=m.useRef(!0),v=m.useRef(0),[y,b]=m.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},w=m.useCallback(()=>{f.current&&(f.current.abort(),f.current=null)},[]),E=m.useCallback(async()=>{if(!h.current||document.visibilityState==="hidden")return;w();const N=new AbortController;f.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!h.current)return;const A=await T.json();if(!h.current)return;d.current=0,a(A.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{h.current&&b(B=>B+1)},gk)}catch(T){if(!h.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>hk){i(!0);return}const A=xk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{h.current&&b(B=>B+1)},A)}},[w]);m.useEffect(()=>(h.current=!0,()=>{h.current=!1,S(),w()}),[w]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[y,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),w()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[w]);const k=m.useCallback(()=>{d.current=0,i(!1),S(),v.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(df.add(k),()=>{df.delete(k)}),[k]),{plugins:t,paused:s,loading:c,retry:k}}const lc=0,ba=1,Fl=2,ny=4;function Sg(t){return()=>t}function yk(t){t()}function ry(t,a){return s=>t(a(s))}function kg(t,a){return()=>t(a)}function bk(t,a){return s=>t(a,s)}function Df(t){return t!==void 0}function jk(...t){return()=>{t.map(yk)}}function Gl(){}function sc(t,a){return a(t),t}function Sk(t,a){return a(t)}function Rt(...t){return t}function pt(t,a){return t(ba,a)}function Ke(t,a){t(lc,a)}function _f(t){t(Fl)}function zt(t){return t(ny)}function Le(t,a){return pt(t,bk(a,lc))}function sr(t,a){const s=t(ba,i=>{s(),a(i)});return s}function wg(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function ay(t,a){return t===a}function Tt(t=ay){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function $e(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>ry(a,t)}function xr(t){return a=>()=>{a(t)}}function he(t,...a){const s=kk(...a);return((i,c)=>{switch(i){case Fl:_f(t);return;case ba:return pt(t,s(c))}})}function gr(t,a){return s=>i=>{s(a=t(a,i))}}function Wa(t){return a=>s=>{t>0?t--:a(s)}}function Ur(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function Qe(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;pt(u,x=>{const h=s;s|=f,a[d]=x,h!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const f=()=>{u([d].concat(a))};s===c?f():i=f}}function kk(...t){return a=>t.reduceRight(Sk,a)}function wk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ba:return u?s===u?void 0:(i(),s=u,a=pt(t,u),a):(i(),Gl);case Fl:i(),s=null;return}}}function ge(t){let a=t;const s=it();return((i,c)=>{switch(i){case lc:a=c;break;case ba:{c(a);break}case ny:return a}return s(i,c)})}function pn(t,a){return sc(ge(a),s=>Le(t,s))}function it(){const t=[];return((a,s)=>{switch(a){case lc:t.slice().forEach(i=>{i(s)});return;case Fl:t.splice(0,t.length);return;case ba:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function $n(t){return sc(it(),a=>Le(t,a))}function ut(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:Ck(),singleton:s}}const Ck=()=>Symbol();function Ek(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const f=i(c.map(x=>s(x)));return d&&a.set(u,f),f};return s(t)}function qt(...t){const a=it(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;pt(u,x=>{s[d]=x,i|=f,i===c&&Ke(a,s)})}),function(u,d){switch(u){case Fl:{_f(a);return}case ba:return i===c&&d(s),pt(a,d)}}}function Ie(t,a=ay){return he(t,Tt(a))}function ff(...t){return function(a,s){switch(a){case Fl:return;case ba:return jk(...t.map(i=>pt(i,s)))}}}const Qt={DEBUG:0,INFO:1,WARN:2,ERROR:3},Nk={[Qt.DEBUG]:"debug",[Qt.ERROR]:"error",[Qt.INFO]:"log",[Qt.WARN]:"warn"},Tk=()=>typeof globalThis>"u"?window:globalThis,ja=ut(()=>{const t=ge(Qt.ERROR);return{log:ge((a,s,i=Qt.INFO)=>{const c=Tk().VIRTUOSO_LOG_LEVEL??zt(t);i>=c&&console[Nk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ka(t,a,s){return Of(t,a,s).callbackRef}function Of(t,a,s){const i=Ae.useRef(null);let c=d=>{};const u=Ae.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const f=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?f():requestAnimationFrame(f)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function Rk(t,a,s,i,c,u,d,f,x){const h=Ae.useCallback(v=>{const y=Ak(v.children,a,f?"offsetWidth":"offsetHeight",c);let b=v.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let w;S&&(w=b.ownerDocument.defaultView);const E=d?f?d.scrollLeft:d.scrollTop:S?f?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:f?b.scrollLeft:b.scrollTop,k=d?f?d.scrollWidth:d.scrollHeight:S?f?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:f?b.scrollWidth:b.scrollHeight,N=d?f?d.offsetWidth:d.offsetHeight:S?f?w.innerWidth:w.innerHeight:f?b.offsetWidth:b.offsetHeight;i({scrollHeight:k,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(f?Cg("column-gap",getComputedStyle(v).columnGap,c):Cg("row-gap",getComputedStyle(v).rowGap,c)),y!==null&&t(y)},[t,a,c,u,d,i,f]);return Of(h,s,x)}function Ak(t,a,s,i){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const f=t.item(d);if(f.dataset.index===void 0)continue;const x=parseInt(f.dataset.index),h=parseFloat(f.dataset.knownSize),v=a(f,s);if(v===0&&i("Zero-sized element, this should not happen",{child:f},Qt.ERROR),v===h)continue;const y=u[u.length-1];u.length===0||y.size!==v||y.endIndex!==x-1?u.push({endIndex:x,size:v,startIndex:x}):u[u.length-1].endIndex++}return u}function Cg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Qt.WARN),a==="normal"?0:parseInt(a??"0",10)}function ly(t,a,s){const i=Ae.useRef(null),c=Ae.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const h=x.getBoundingClientRect(),v=h.width;let y,b;if(a){const S=a.getBoundingClientRect(),w=h.top-S.top;b=S.height-Math.max(0,w),y=w+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,h.top),y=h.top+S.scrollY}i.current={listHeight:h.height,offsetTop:y,visibleHeight:b,visibleWidth:v},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Of(c,!0,s),f=Ae.useCallback(()=>{c(d.current)},[c,d]);return Ae.useEffect(()=>{var h;if(a){a.addEventListener("scroll",f);const v=new ResizeObserver(()=>{requestAnimationFrame(f)});return v.observe(a),()=>{a.removeEventListener("scroll",f),v.unobserve(a)}}const x=(h=d.current)==null?void 0:h.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",f),x==null||x.addEventListener("resize",f),()=>{x==null||x.removeEventListener("scroll",f),x==null||x.removeEventListener("resize",f)}},[f,a,d]),u}const yn=ut(()=>{const t=it(),a=it(),s=ge(0),i=it(),c=ge(0),u=it(),d=it(),f=ge(0),x=ge(0),h=ge(0),v=ge(0),y=it(),b=it(),S=ge(!1),w=ge(!1),E=ge(!1);return Le(he(t,we(({scrollTop:k})=>k)),a),Le(he(t,we(({scrollHeight:k})=>k)),d),Le(a,c),{deviation:s,fixedFooterHeight:h,fixedHeaderHeight:x,footerHeight:v,headerHeight:f,horizontalDirection:w,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:y,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Qs={lvl:0};function sy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:f,value:x}=a(t[d]);u.push({end:f-1,start:i,value:c}),i=f,c=x}return u.push({end:1/0,start:i,value:c}),u}function yt(t){return t===Qs}function Zs(t,a){if(!yt(t))return a===t.k?t.v:a<t.k?Zs(t.l,a):Zs(t.r,a)}function or(t,a,s="k"){if(yt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=or(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return or(t.l,a,s)}function Bn(t,a,s){return yt(t)?cy(a,s,1):a===t.k?Xt(t,{k:a,v:s}):a<t.k?Eg(Xt(t,{l:Bn(t.l,a,s)})):Eg(Xt(t,{r:Bn(t.r,a,s)}))}function Ol(){return Qs}function Bl(t,a,s){if(yt(t))return[];const i=or(t,a)[0];return Lk(mf(t,i,s))}function pf(t,a){if(yt(t))return Qs;const{k:s,l:i,r:c}=t;if(a===s){if(yt(i))return c;if(yt(c))return i;const[u,d]=oy(i);return Ho(Xt(t,{k:u,l:iy(i),v:d}))}return a<s?Ho(Xt(t,{l:pf(i,a)})):Ho(Xt(t,{r:pf(c,a)}))}function Fa(t){return yt(t)?[]:[...Fa(t.l),{k:t.k,v:t.v},...Fa(t.r)]}function mf(t,a,s){if(yt(t))return[];const{k:i,l:c,r:u,v:d}=t;let f=[];return i>a&&(f=f.concat(mf(c,a,s))),i>=a&&i<=s&&f.push({k:i,v:d}),i<=s&&(f=f.concat(mf(u,a,s))),f}function Ho(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(Dd(a))return uy(Xt(t,{lvl:s-1}));if(!yt(a)&&!yt(a.r))return Xt(a.r,{l:Xt(a,{r:a.r.l}),lvl:s,r:Xt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Dd(t))return hf(Xt(t,{lvl:s-1}));if(!yt(i)&&!yt(i.l)){const c=i.l,u=Dd(c)?i.lvl-1:i.lvl;return Xt(c,{l:Xt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:hf(Xt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Xt(t,a){return cy(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 iy(t){return yt(t.r)?t.l:Ho(Xt(t,{r:iy(t.r)}))}function Dd(t){return yt(t)||t.lvl>t.r.lvl}function oy(t){return yt(t.r)?[t.k,t.v]:oy(t.r)}function cy(t,a,s,i=Qs,c=Qs){return{k:t,l:i,lvl:s,r:c,v:a}}function Eg(t){return hf(uy(t))}function uy(t){const{l:a}=t;return!yt(a)&&a.lvl===t.lvl?Xt(a,{r:Xt(t,{l:a.r})}):t}function hf(t){const{lvl:a,r:s}=t;return!yt(s)&&!yt(s.r)&&s.lvl===a&&s.r.lvl===a?Xt(s,{l:Xt(t,{r:s.l}),lvl:a+1}):t}function Lk(t){return sy(t,({k:a,v:s})=>({index:a,value:s}))}function dy(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Js(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Bf=ut(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function fy(t,a,s){return t[Wo(t,a,s)]}function Wo(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],f=s(d,a);if(f===0)return u;if(f===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Mk(t,a,s,i){const c=Wo(t,a,i),u=Wo(t,s,i,c);return t.slice(c,u+1)}function va(t,a){return Math.round(t.getBoundingClientRect()[a])}function ic(t){return!yt(t.groupOffsetTree)}function If({index:t},a){return a===t?0:a<t?-1:1}function zk(){return{groupIndices:[],groupOffsetTree:Ol(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ol()}}function Dk(t,a){let s=yt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),yt(t)){t=Bn(t,0,u);continue}const f=Bl(t,d-1,c+1);if(f.some(Hk(i)))continue;let x=!1,h=!1;for(const{end:v,start:y,value:b}of f)x?(c>=y||u===b)&&(t=pf(t,y)):(h=b!==u,x=!0),v>c&&c>=y&&b!==u&&(t=Bn(t,c+1,b));h&&(t=Bn(t,d,u))}return[t,s]}function _k(t){return typeof t.groupIndex<"u"}function Ok({offset:t},a){return a===t?0:a<t?-1:1}function ei(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=fy(a,t,If),d=t-i,f=u*d+(d-1)*s+c;return f>0?f+s:f}function py(t,a){if(!ic(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function my(t,a,s){if(_k(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=py(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function Bk(t,a,s,i=0){return i>0&&(a=Math.max(a,fy(t,i,If).offset)),sy(Mk(t,a,s,Ok),Uk)}function Ik(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Qt.DEBUG);const u=t.sizeTree;let d=u,f=0;if(s.length>0&&yt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((w,E)=>Bn(Bn(w,E,b),E+1,S),d)}else[d,f]=Dk(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:h,lastSize:v,offsetTree:y}=xf(t.offsetTree,f,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>Bn(b,S,ei(S,y,c)),Ol()),lastIndex:x,lastOffset:h,lastSize:v,offsetTree:y,sizeTree:d}}function $k(t){return Fa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Ng(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function xf(t,a,s,i){let c=t,u=0,d=0,f=0,x=0;if(a!==0){x=Wo(c,a-1,If),f=c[x].offset;const h=or(s,a-1);u=h[0],d=h[1],c.length&&c[x].size===or(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:h,value:v}of Bl(s,a,1/0)){const y=h-u,b=y*d+f+y*i;c.push({index:h,offset:b,size:v}),u=h,f=b,d=v}return{lastIndex:u,lastOffset:f,lastSize:d,offsetTree:c}}function Uk(t){return{index:t.index,value:t}}function Hk(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Pk={offsetHeight:"height",offsetWidth:"width"},br=ut(([{log:t},{recalcInProgress:a}])=>{const s=it(),i=it(),c=pn(i,0),u=it(),d=it(),f=ge(0),x=ge([]),h=ge(void 0),v=ge(void 0),y=ge(void 0),b=ge(void 0),S=ge((C,O)=>va(C,Pk[O])),w=ge(void 0),E=ge(0),k=zk(),N=pn(he(s,Qe(x,t,E),gr(Ik,k),Tt()),k),T=pn(he(x,Tt(),gr((C,O)=>({current:O,prev:C.current}),{current:[],prev:[]}),we(({prev:C})=>C)),[]);Le(he(x,$e(C=>C.length>0),Qe(N,E),we(([C,O,L])=>{const _=C.reduce((H,W,q)=>Bn(H,W,ei(W,O.offsetTree,L)||q),Ol());return{...O,groupIndices:C,groupOffsetTree:_}})),N),Le(he(i,Qe(N),$e(([C,{lastIndex:O}])=>C<O),we(([C,{lastIndex:O,lastSize:L}])=>[{endIndex:O,size:L,startIndex:C}])),s),Le(h,v);const A=pn(he(h,we(C=>C===void 0)),!0);Le(he(v,$e(C=>C!==void 0&&yt(zt(N).sizeTree)),we(C=>{const O=zt(y),L=zt(x).length>0;return O!==void 0&&O!==0?L?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:C,startIndex:1}]:[]:[{endIndex:0,size:C,startIndex:0}]})),s),Le(he(b,$e(C=>C!==void 0&&C.length>0&&yt(zt(N).sizeTree)),we(C=>{const O=[];let L=C[0],_=0;for(let H=1;H<C.length;H++){const W=C[H];W!==L&&(O.push({endIndex:H-1,size:L,startIndex:_}),L=W,_=H)}return O.push({endIndex:C.length-1,size:L,startIndex:_}),O})),s),Le(he(x,Qe(y,v),$e(([,C,O])=>C!==void 0&&O!==void 0),we(([C,O,L])=>{const _=[];for(let H=0;H<C.length;H++){const W=C[H],q=C[H+1];_.push({startIndex:W,endIndex:W,size:O}),q!==void 0&&_.push({startIndex:W+1,endIndex:q-1,size:L})}return _})),s);const B=$n(he(s,Qe(N),gr(({sizes:C},[O,L])=>({changed:L!==C,sizes:L}),{changed:!1,sizes:k}),we(C=>C.changed)));pt(he(f,gr((C,O)=>({diff:C.prev-O,prev:O}),{diff:0,prev:0}),we(C=>C.diff)),C=>{const{groupIndices:O}=zt(N);if(C>0)Ke(a,!0),Ke(u,C+Ng(C,O));else if(C<0){const L=zt(T);L.length>0&&(C-=Ng(-C,L)),Ke(d,C)}}),pt(he(f,Qe(t)),([C,O])=>{C<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:f},Qt.ERROR)});const z=$n(u);Le(he(u,Qe(N),we(([C,O])=>{const L=O.groupIndices.length>0,_=[],H=O.lastSize;if(L){const W=Zs(O.sizeTree,0);let q=0,ee=0;for(;q<C;){const D=O.groupIndices[ee],I=O.groupIndices.length===ee+1?1/0:O.groupIndices[ee+1]-D-1;_.push({endIndex:D,size:W,startIndex:D}),_.push({endIndex:D+1+I-1,size:H,startIndex:D+1}),ee++,q+=I+1}const $=Fa(O.sizeTree);return q!==C&&$.shift(),$.reduce((D,{k:I,v:F})=>{let J=D.ranges;return D.prevSize!==0&&(J=[...D.ranges,{endIndex:I+C-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:I+C,prevSize:F,ranges:J}},{prevIndex:C,prevSize:0,ranges:_}).ranges}return Fa(O.sizeTree).reduce((W,{k:q,v:ee})=>({prevIndex:q+C,prevSize:ee,ranges:[...W.ranges,{endIndex:q+C-1,size:W.prevSize,startIndex:W.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const P=$n(he(d,Qe(N,E),we(([C,{offsetTree:O},L])=>{const _=-C;return ei(_,O,L)})));return Le(he(d,Qe(N,E),we(([C,O,L])=>{if(O.groupIndices.length>0){if(yt(O.sizeTree))return O;let H=Ol();const W=zt(T);let q=0,ee=0,$=0;for(;q<-C;){$=W[ee];const D=W[ee+1]-$-1;ee++,q+=D+1}if(H=Fa(O.sizeTree).reduce((D,{k:I,v:F})=>Bn(D,Math.max(0,I+C),F),H),q!==-C){const D=Zs(O.sizeTree,$);H=Bn(H,0,D);const I=or(O.sizeTree,-C+1)[1];H=Bn(H,1,I)}return{...O,sizeTree:H,...xf(O.offsetTree,0,H,L)}}const _=Fa(O.sizeTree).reduce((H,{k:W,v:q})=>Bn(H,Math.max(0,W+C),q),Ol());return{...O,sizeTree:_,...xf(O.offsetTree,0,_,L)}})),N),{beforeUnshiftWith:z,data:w,defaultItemSize:v,firstItemIndex:f,fixedItemSize:h,fixedGroupSize:y,gap:E,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:P,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:A,unshiftWith:u}},Rt(ja,Bf),{singleton:!0});function Vk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const hy=ut(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=it(),d=it(),f=$n(he(u,we(Vk)));return Le(he(f,we(x=>x.totalCount)),s),Le(he(f,we(x=>x.groupIndices)),t),Le(he(qt(c,a,i),$e(([x,h])=>ic(h)),we(([x,h,v])=>or(h.groupOffsetTree,Math.max(x-v,0),"v")[0]),Tt(),we(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},Rt(br,yn)),Sa=ut(([{log:t}])=>{const a=ge(!1),s=$n(he(a,$e(i=>i),Tt()));return pt(a,i=>{i&&zt(t)("props updated",{},Qt.DEBUG)}),{didMount:s,propsReady:a}},Rt(ja),{singleton:!0}),Fk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function xy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!Fk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const si=ut(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:f,scrollingInProgress:x,scrollTo:h,smoothScrollTargetReached:v,viewportHeight:y},{log:b}])=>{const S=it(),w=it(),E=ge(0);let k=null,N=null,T=null;function A(){k!==null&&(k(),k=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Ke(x,!1)}return Le(he(S,Qe(s,y,i,E,f,d,b),Qe(t,u,c),we(([[B,z,P,C,O,L,_,H],W,q,ee])=>{const $=xy(B),{align:D,behavior:I,offset:F}=$,J=C-1,de=my($,z,J);let M=ei(de,z.offsetTree,W)+L;D==="end"?(M+=q+or(z.sizeTree,de)[1]-P+ee,de===J&&(M+=_)):D==="center"?M+=(q+or(z.sizeTree,de)[1]-P+ee)/2:M-=O,F!==void 0&&F!==0&&(M+=F);const U=K=>{A(),K?(H("retrying to scroll to",{location:B},Qt.DEBUG),Ke(S,B)):(Ke(w,!0),H("list did not change, scroll successful",{},Qt.DEBUG))};if(A(),I==="smooth"){let K=!1;T=pt(a,Q=>{K=K||Q}),k=sr(v,()=>{U(K)})}else k=sr(he(a,Gk(150)),U);return N=setTimeout(()=>{A()},1200),Ke(x,!0),H("scrolling from index to",{behavior:I,index:de,top:M},Qt.DEBUG),{behavior:I,top:M}})),h),{scrollTargetReached:w,scrollToIndex:S,topListHeight:E}},Rt(br,yn,ja),{singleton:!0});function Gk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function $f(t,a){t===0?a():requestAnimationFrame(()=>{$f(t-1,a)})}function Uf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const ii=ut(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const f=ge(!0),x=ge(0),h=ge(!0);return Le(he(d,Qe(x),$e(([v,y])=>y!==0),xr(!1)),f),Le(he(d,Qe(x),$e(([v,y])=>y!==0),xr(!1)),h),pt(he(qt(a,d),Qe(f,s,t,h),$e(([[,v],y,{sizeTree:b},S,w])=>v&&(!yt(b)||Df(S))&&!y&&!w),Qe(x)),([,v])=>{sr(c,()=>{Ke(h,!0)}),$f(4,()=>{sr(i,()=>{Ke(f,!0)}),Ke(u,v)})}),{initialItemFinalLocationReached:h,initialTopMostItemIndex:x,scrolledToInitialItem:f}},Rt(br,yn,si,Sa),{singleton:!0});function gy(t,a){return Math.abs(t-a)<1.01}const ti="up",Gs="down",Wk="none",qk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Yk=0,oi=ut(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),f=ge(!0),x=it(),h=it(),v=ge(4),y=ge(Yk),b=pn(he(ff(he(Ie(c),Wa(1),xr(!0)),he(Ie(c),Wa(1),xr(!1),wg(100))),Tt()),!1),S=pn(he(ff(he(s,xr(!0)),he(s,xr(!1),wg(200))),Tt()),!1);Le(he(qt(Ie(c),Ie(y)),we(([T,A])=>T<=A),Tt()),f),Le(he(f,Ur(50)),h);const w=$n(he(qt(i,Ie(u),Ie(a),Ie(t),Ie(v)),gr((T,[{scrollHeight:A,scrollTop:B},z,P,C,O])=>{const L=B+z-A>-O,_={scrollHeight:A,scrollTop:B,viewportHeight:z};if(L){let W,q;return B>T.state.scrollTop?(W="SCROLLED_DOWN",q=T.state.scrollTop-B):(W="SIZE_DECREASED",q=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:q,state:_}}let H;return _.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":z<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:_}},qk),Tt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=pn(he(i,gr((T,{scrollHeight:A,scrollTop:B,viewportHeight:z})=>{if(!gy(T.scrollHeight,A)){const P=A-(B+z)<1;return T.scrollTop!==B&&P?{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}),$e(T=>T.changed),we(T=>T.jump)),0);Le(he(w,we(T=>T.atBottom)),d),Le(he(d,Ur(50)),x);const k=ge(Gs);Le(he(i,we(({scrollTop:T})=>T),Tt(),gr((T,A)=>zt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?ti:Gs,prevScrollTop:A},{direction:Gs,prevScrollTop:0}),we(T=>T.direction)),k),Le(he(i,Ur(50),xr(Wk)),k);const N=ge(0);return Le(he(b,$e(T=>!T),xr(0)),N),Le(he(c,Ur(100),Qe(b),$e(([T,A])=>A),gr(([T,A],[B])=>[A,B],[0,0]),we(([T,A])=>A-T)),N),{atBottomState:w,atBottomStateChange:x,atBottomThreshold:v,atTopStateChange:h,atTopThreshold:y,isAtBottom:d,isAtTop:f,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:k,scrollVelocity:N}},Rt(yn)),ni="top",ri="bottom",Tg="none";function Rg(t,a,s){return typeof t=="number"?s===ti&&a===ni||s===Gs&&a===ri?t:0:s===ti?a===ni?t.main:t.reverse:a===ri?t.main:t.reverse}function Ag(t,a){return typeof t=="number"?t:t[a]??0}const Hf=ut(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=it(),d=ge(0),f=ge(0),x=ge(0),h=pn(he(qt(Ie(i),Ie(c),Ie(s),Ie(u,Js),Ie(x),Ie(d),Ie(a),Ie(t),Ie(f)),we(([v,y,b,[S,w],E,k,N,T,A])=>{const B=v-T,z=k+N,P=Math.max(b-B,0);let C=Tg;const O=Ag(A,ni),L=Ag(A,ri);return S-=T,S+=b+N,w+=b+N,w-=T,S>v+z-O&&(C=ti),w<v-P+y+L&&(C=Gs),C!==Tg?[Math.max(B-b-Rg(E,ni,C)-O,0),B-P-N+y+Rg(E,ri,C)+L]:null}),$e(v=>v!==null),Tt(Js)),[0,0]);return{increaseViewportBy:f,listBoundary:u,overscan:x,topListHeight:d,visibleRange:h}},Rt(yn),{singleton:!0});function Kk(t,a,s){if(ic(a)){const i=py(t,a);return[{index:or(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const _d={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Po(t,a,s,i,c,u){const{lastIndex:d,lastOffset:f,lastSize:x}=c;let h=0,v=0;if(t.length>0){h=t[0].offset;const E=t[t.length-1];v=E.offset+E.size}const y=s-d,b=f+y*x+(y-1)*i,S=h,w=b-v;return{bottom:v,firstItemIndex:u,items:Lg(t,c,u),offsetBottom:w,offsetTop:h,top:S,topItems:Lg(a,c,u),topListHeight:a.reduce((E,k)=>k.size+E,0),totalCount:s}}function vy(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const v of s.groupIndices){if(v-d>=t)break;d++}const f=t+d,x=Uf(a,f),h=Array.from({length:f}).map((v,y)=>({data:u[y+x],index:y+x,offset:0,size:0}));return Po(h,[],f,c,s,i)}function Lg(t,a,s){if(t.length===0)return[];if(!ic(a))return t.map(h=>({...h,index:h.index+s,originalIndex:h.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Bl(a.groupOffsetTree,i,c);let f,x=0;for(const h of t){(!f||f.end<h.index)&&(f=d.shift(),x=a.groupIndices.indexOf(f.start));let v;h.index===f.start?v={index:x,type:"group"}:v={groupIndex:x,index:h.index-(x+1)+s},u.push({...v,data:h.data,offset:h.offset,originalIndex:h.index,size:h.size})}return u}function Mg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Xa=ut(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:f,visibleRange:x},{initialTopMostItemIndex:h,scrolledToInitialItem:v},{topListHeight:y},b,{didMount:S},{recalcInProgress:w}])=>{const E=ge([]),k=ge(0),N=it(),T=ge(0);Le(u.topItemsIndexes,E);const A=pn(he(qt(S,w,Ie(x,Js),Ie(c),Ie(i),Ie(h),v,Ie(E),Ie(a),Ie(s),Ie(T),t),$e(([C,O,,L,,,,,,,,_])=>{const H=_!==void 0&&_.length!==L;return C&&!O&&!H}),we(([,,[C,O],L,_,H,W,q,ee,$,D,I])=>{var me,je;const F=_,{offsetTree:J,sizeTree:de}=F,M=zt(k);if(L===0)return{..._d,totalCount:L};if(C===0&&O===0)return M===0?{..._d,totalCount:L}:vy(M,H,_,ee,$,I||[]);if(yt(de))return M>0?null:Po(Kk(Uf(H,L),F,I),[],L,$,F,ee);const U=[];if(q.length>0){const Ne=q[0],Me=q[q.length-1];let Fe=0;for(const Ue of Bl(de,Ne,Me)){const De=Ue.value,Ge=Math.max(Ue.start,Ne),ft=Math.min(Ue.end,Me);for(let oe=Ge;oe<=ft;oe++)U.push({data:I==null?void 0:I[oe],index:oe,offset:Fe,size:De}),Fe+=De}}if(!W)return Po([],U,L,$,F,ee);const K=q.length>0?q[q.length-1]+1:0,Q=Bk(J,C,O,K);if(Q.length===0)return null;const ce=L-1,Z=sc([],Ne=>{for(const Me of Q){const Fe=Me.value;let Ue=Fe.offset,De=Me.start;const Ge=Fe.size;if(Fe.offset<C){De+=Math.floor((C-Fe.offset+$)/(Ge+$));const oe=De-Me.start;Ue+=oe*Ge+oe*$}De<K&&(Ue+=(K-De)*Ge,De=K);const ft=Math.min(Me.end,ce);for(let oe=De;oe<=ft&&!(Ue>=O);oe++)Ne.push({data:I==null?void 0:I[oe],index:oe,offset:Ue,size:Ge}),Ue+=Ge+$}}),ie=Mg(D,ni),X=Mg(D,ri);if(Z.length>0&&(ie>0||X>0)){const Ne=Z[0],Me=Z[Z.length-1];if(ie>0&&Ne.index>K){const Fe=Math.min(ie,Ne.index-K),Ue=[];let De=Ne.offset;for(let Ge=Ne.index-1;Ge>=Ne.index-Fe;Ge--){const ft=((me=Bl(de,Ge,Ge)[0])==null?void 0:me.value)??Ne.size;De-=ft+$,Ue.unshift({data:I==null?void 0:I[Ge],index:Ge,offset:De,size:ft})}Z.unshift(...Ue)}if(X>0&&Me.index<ce){const Fe=Math.min(X,ce-Me.index);let Ue=Me.offset+Me.size+$;for(let De=Me.index+1;De<=Me.index+Fe;De++){const Ge=((je=Bl(de,De,De)[0])==null?void 0:je.value)??Me.size;Z.push({data:I==null?void 0:I[De],index:De,offset:Ue,size:Ge}),Ue+=Ge+$}}}return Po(Z,U,L,$,F,ee)}),$e(C=>C!==null),Tt()),_d);Le(he(t,$e(Df),we(C=>C==null?void 0:C.length)),c),Le(he(A,we(C=>C.topListHeight)),y),Le(y,f),Le(he(A,we(C=>[C.top,C.bottom])),d),Le(he(A,we(C=>C.items)),N);const B=$n(he(A,$e(({items:C})=>C.length>0),Qe(c,t),$e(([{items:C},O])=>C[C.length-1].originalIndex===O-1),we(([,C,O])=>[C-1,O]),Tt(Js),we(([C])=>C))),z=$n(he(A,Ur(200),$e(({items:C,topItems:O})=>C.length>0&&C[0].originalIndex===O.length),we(({items:C})=>C[0].index),Tt())),P=$n(he(A,$e(({items:C})=>C.length>0),we(({items:C})=>{let O=0,L=C.length-1;for(;C[O].type==="group"&&O<L;)O++;for(;C[L].type==="group"&&L>O;)L--;return{endIndex:C[L].index,startIndex:C[O].index}}),Tt(dy)));return{endReached:B,initialItemCount:k,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:P,startReached:z,topItemsIndexes:E,...b}},Rt(br,hy,Hf,ii,si,oi,Sa,Bf),{singleton:!0}),yy=ut(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=it(),d=pn(he(qt(s,t,i,a,c),we(([f,x,h,v,y])=>f+x+h+v+y.offsetBottom+y.bottom)),0);return Le(Ie(d),u),{totalListHeight:d,totalListHeightChanged:u}},Rt(yn,Xa),{singleton:!0}),Xk=ut(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),i=pn(he(qt(s,t,a),$e(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),Ur(0),Tt()),0);return{alignToBottom:s,paddingTopAddition:i}},Rt(yn,yy),{singleton:!0}),by=ut(()=>({context:ge(null)})),Qk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,jy=ut(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:f,viewportHeight:x},{scrollToIndex:h}])=>{const v=it();return Le(he(v,Qe(a,x,s,u,c,i,f),Qe(t),we(([[y,b,S,w,E,k,N,T],A])=>{const{calculateViewLocation:B=Qk,done:z,...P}=y,C=my(y,b,w-1),O=ei(C,b.offsetTree,A)+E+k,L=O+or(b.sizeTree,C)[1],_=T+k,H=T+S-N,W=B({itemBottom:L,itemTop:O,locationParams:P,viewportBottom:H,viewportTop:_});return W!==null?z&&sr(he(d,$e(q=>!q),Wa(zt(d)?1:2)),z):z==null||z(),W}),$e(y=>y!==null)),h),{scrollIntoView:v}},Rt(br,yn,si,Xa,ja),{singleton:!0});function zg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const Zk=(t,a)=>typeof t=="function"?zg(t(a)):a&&zg(t),Jk=ut(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:f},{didMount:x,propsReady:h},{log:v},{scrollingInProgress:y},{context:b},{scrollIntoView:S}])=>{const w=ge(!1),E=it();let k=null;function N(z){Ke(d,{align:"end",behavior:z,index:"LAST"})}pt(he(qt(he(Ie(a),Wa(1)),x),Qe(Ie(w),u,f,y),we(([[z,P],C,O,L,_])=>{let H=P&&L,W="auto";return H&&(W=Zk(C,O||_),H=H&&W!==!1),{followOutputBehavior:W,shouldFollow:H,totalCount:z}}),$e(({shouldFollow:z})=>z)),({followOutputBehavior:z,totalCount:P})=>{k!==null&&(k(),k=null),zt(s)!==void 0?requestAnimationFrame(()=>{zt(v)("following output to ",{totalCount:P},Qt.DEBUG),N(z)}):k=sr(t,()=>{zt(v)("following output to ",{totalCount:P},Qt.DEBUG),N(z),k=null})});function T(z){const P=sr(c,C=>{z&&!C.atBottom&&C.notAtBottomBecause==="SIZE_INCREASED"&&k===null&&(zt(v)("scrolling to bottom due to increased size",{},Qt.DEBUG),N("auto"))});setTimeout(P,100)}pt(he(qt(Ie(w),a,h),$e(([z,,P])=>z!==!1&&P),gr(({value:z},[,P])=>({refreshed:z===P,value:P}),{refreshed:!1,value:0}),$e(({refreshed:z})=>z),Qe(w,a)),([,z])=>{zt(f)&&T(z!==!1)}),pt(E,()=>{T(zt(w)!==!1)}),pt(qt(Ie(w),c),([z,P])=>{z!==!1&&!P.atBottom&&P.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ge(null),B=it();return Le(ff(he(Ie(i),we(z=>(z==null?void 0:z.length)??0)),he(Ie(a))),B),pt(he(qt(he(B,Wa(1)),x),Qe(Ie(A),f,y,b),we(([[z,P],C,O,L,_])=>P&&O&&(C==null?void 0:C({context:_,totalCount:z,scrollingInProgress:L}))),$e(z=>!!z),Ur(0)),z=>{k!==null&&(k(),k=null),zt(s)!==void 0?requestAnimationFrame(()=>{zt(v)("scrolling into view",{}),Ke(S,z)}):k=sr(t,()=>{zt(v)("scrolling into view",{}),Ke(S,z),k=null})}),{autoscrollToBottom:E,followOutput:w,scrollIntoViewOnChange:A}},Rt(br,oi,si,ii,Sa,ja,yn,by,jy)),ew=ut(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:f}])=>(Le(he(f,Qe(u),$e(([,x])=>x!==0),Qe(c,i,a,s,t),we(([[,x],h,v,y,b,S=[]])=>vy(x,h,v,y,b,S))),d),{}),Rt(br,ii,Xa,Sa),{singleton:!0}),tw=ut(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ge(0);return pt(he(t,Qe(i),$e(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{sr(he(s,Wa(1),$e(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Ke(a,c)})})}),{initialScrollTop:i}},Rt(Sa,yn,Xa),{singleton:!0}),Sy=ut(([{scrollVelocity:t}])=>{const a=ge(!1),s=it(),i=ge(!1);return Le(he(t,Qe(i,a,s),$e(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,f])=>{const{enter:x,exit:h}=u;if(d){if(h(c,f))return!1}else if(x(c,f))return!0;return d}),Tt()),a),pt(he(qt(a,t,s),Qe(i)),([[c,u,d],f])=>{c&&f!==!1&&f!==void 0&&f.change&&f.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},Rt(oi),{singleton:!0}),Pf=ut(([{scrollContainerState:t,scrollTo:a}])=>{const s=it(),i=it(),c=it(),u=ge(!1),d=ge(void 0);return Le(he(qt(s,i),we(([{scrollTop:f,viewportHeight:x},{offsetTop:h,listHeight:v}])=>({scrollHeight:v,scrollTop:Math.max(0,f-h),viewportHeight:x}))),t),Le(he(a,Qe(i),we(([f,{offsetTop:x}])=>({...f,top:f.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Rt(yn)),nw=ut(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:f,windowViewportRect:x}])=>{const h=it(),v=ge(void 0),y=ge(null),b=ge(null);return Le(f,y),Le(x,b),pt(he(h,Qe(a,i,d,y,b,s)),([S,w,E,k,N,T,A])=>{const B=$k(w.sizeTree);k&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Le(he(v,$e(Df),we(rw)),c),Le(he(u,Qe(v),$e(([,S])=>S!==void 0),Tt(),we(([,S])=>S.ranges)),t),{getState:h,restoreStateFrom:v}},Rt(br,yn,ii,Sa,Pf));function rw(t){return{align:"start",index:0,offset:t.scrollTop}}const aw=ut(([{topItemsIndexes:t}])=>{const a=ge(0);return Le(he(a,$e(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Rt(Xa));function ky(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const lw=ky(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),sw=ut(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:f},{listState:x},{beforeUnshiftWith:h,gap:v,shiftWithOffset:y,sizes:b},{log:S},{recalcInProgress:w}])=>{const E=$n(he(x,Qe(d),gr(([,N,T,A],[{bottom:B,items:z,offsetBottom:P,totalCount:C},O])=>{const L=B+P;let _=0;return T===C&&N.length>0&&z.length>0&&(z[0].originalIndex===0&&N[0].originalIndex===0||(_=L-A,_!==0&&(_+=O))),[_,z,C,L]},[0,[],0,0]),$e(([N])=>N!==0),Qe(i,f,s,c,S,w),$e(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===ti),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Qt.DEBUG),N))));function k(N){N>0?(Ke(a,{behavior:"auto",top:-N}),Ke(t,0)):(Ke(t,0),Ke(a,{behavior:"auto",top:-N}))}return pt(he(E,Qe(t,u)),([N,T,A])=>{A&&lw()?Ke(t,T-N):k(-N)}),pt(he(qt(pn(u,!1),t,w),$e(([N,T,A])=>!N&&!A&&T!==0),we(([N,T])=>T),Ur(1)),k),Le(he(y,we(N=>({top:-N}))),a),pt(he(h,Qe(b,v),we(([N,{groupIndices:T,lastSize:A,sizeTree:B},z])=>{function P(H){return H*(A+z)}if(T.length===0)return P(N);let C=0;const O=Zs(B,0);let L=0,_=0;for(;L<N;){L++,C+=O;let H=T.length===_+1?1/0:T[_+1]-T[_]-1;L+H>N&&(C-=O,H=N-L+1),L+=H,C+=P(H),_++}return C})),N=>{Ke(t,N),requestAnimationFrame(()=>{Ke(a,{top:N}),requestAnimationFrame(()=>{Ke(t,0),Ke(w,!1)})})}),{deviation:t}},Rt(yn,oi,Xa,br,ja,Bf)),iw=ut(([t,a,s,i,c,u,d,f,x,h,v])=>({...t,...a,...s,...i,...c,...u,...d,...f,...x,...h,...v}),Rt(Hf,ew,Sa,Sy,yy,tw,Xk,Pf,jy,ja,by)),wy=ut(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:f,itemSize:x,sizeRanges:h,sizes:v,statefulTotalCount:y,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:w,initialTopMostItemIndex:E,scrolledToInitialItem:k},N,T,A,B,{scrollToIndex:z},P,{topItemCount:C},{groupCounts:O},L])=>{const{listState:_,minOverscanItemCount:H,topItemsIndexes:W,rangeChanged:q,...ee}=B;return Le(q,L.scrollSeekRangeChanged),Le(he(L.windowViewportRect,we($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:f,initialItemFinalLocationReached:w,initialTopMostItemIndex:E,scrolledToInitialItem:k,sizeRanges:h,topItemCount:C,topItemsIndexes:W,totalCount:b,...A,groupIndices:d,itemSize:x,listState:_,minOverscanItemCount:H,scrollToIndex:z,statefulTotalCount:y,trackItemSizes:S,rangeChanged:q,...ee,...L,...N,sizes:v,...T}},Rt(br,ii,yn,nw,Jk,Xa,si,sw,aw,hy,iw));function ow(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const No=typeof document<"u"?Ae.useLayoutEffect:Ae.useEffect;function Cy(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),f=Ae.createContext({});function x(k,N){k.propsReady!==void 0&&Ke(k.propsReady,!1);for(const T of i){const A=k[a.required[T]];Ke(A,N[T])}for(const T of c)if(T in N){const A=k[a.optional[T]];Ke(A,N[T])}k.propsReady!==void 0&&Ke(k.propsReady,!0)}function h(k){return u.reduce((N,T)=>(N[T]=A=>{const B=k[a.methods[T]];Ke(B,A)},N),{})}function v(k){return d.reduce((N,T)=>(N[T]=wk(k[a.events[T]]),N),{})}const y=Ae.forwardRef(function(k,N){const{children:T,...A}=k,[B]=Ae.useState(()=>sc(Ek(t),C=>{x(C,A)})),[z]=Ae.useState(kg(v,B));No(()=>{for(const C of d)C in A&&pt(z[C],A[C]);return()=>{Object.values(z).map(_f)}},[A,z,B]),No(()=>{x(B,A)}),Ae.useImperativeHandle(N,Sg(h(B)));const P=s;return r.jsx(f.Provider,{value:B,children:s!==void 0?r.jsx(P,{...ow([...i,...c,...d],A),children:T}):T})}),b=k=>{const N=Ae.useContext(f);return Ae.useCallback(T=>{Ke(N[k],T)},[N,k])},S=k=>{const N=Ae.useContext(f)[k],T=Ae.useCallback(A=>pt(N,A),[N]);return Ae.useSyncExternalStore(T,()=>zt(N),()=>zt(N))},w=k=>{const N=Ae.useContext(f)[k],[T,A]=Ae.useState(kg(zt,N));return No(()=>pt(N,B=>{B!==T&&A(Sg(B))}),[N,T]),T},E=parseInt(Ae.version)>=18?S:w;return{Component:y,useEmitter:(k,N)=>{const T=Ae.useContext(f)[k];No(()=>pt(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const Ey=Ae.createContext(void 0),Ny=Ae.createContext(void 0),Od="-webkit-sticky",Dg="sticky",Vf=ky(()=>{if(typeof document>"u")return Dg;const t=document.createElement("div");return t.style.position=Od,t.style.position===Od?Od:Dg}),Ty=typeof document<"u"?Ae.useLayoutEffect:Ae.useEffect;function Bd(t){return"self"in t}function cw(t){return"body"in t}function Ry(t,a,s,i=Gl,c,u){const d=Ae.useRef(null),f=Ae.useRef(null),x=Ae.useRef(null),h=Ae.useCallback(b=>{let S,w,E;const k=b.target;if(cw(k)||Bd(k)){const T=Bd(k)?k:k.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,w=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?k.scrollLeft:k.scrollTop,S=u===!0?k.scrollWidth:k.scrollHeight,w=u===!0?k.offsetWidth:k.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:w})};b.suppressFlushSync===!0?N():bS.flushSync(N),f.current!==null&&(E===f.current||E<=0||E===S-w)&&(f.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Ae.useEffect(()=>{const b=c||d.current;return i(c||d.current),h({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",h,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",h)}},[d,h,s,i,c]);function v(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const w=b.behavior==="smooth";let E,k,N;Bd(S)?(k=Math.max(va(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):(k=S[u===!0?"scrollWidth":"scrollHeight"],E=va(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=k-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),gy(E,k)||b.top===N){t({scrollHeight:k,scrollTop:N,viewportHeight:E}),w&&a(!0);return}w?(f.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,f.current=null,a(!0)},1e3)):f.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function y(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:y,scrollerRef:d,scrollToCallback:v}}function Ff(t){return t}const uw=ut(()=>{const t=ge(f=>`Item ${f}`),a=ge(f=>`Group ${f}`),s=ge({}),i=ge(Ff),c=ge("div"),u=ge(Gl),d=(f,x=null)=>pn(he(s,we(h=>h[f]),Tt()),x);return{components:s,computeItemKey:i,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),dw=ut(([t,a])=>({...t,...a}),Rt(wy,uw)),fw=({height:t})=>r.jsx("div",{style:{height:t}}),pw={overflowAnchor:"none",position:Vf(),zIndex:1},Ay={overflowAnchor:"none"},mw={...Ay,display:"inline-block",height:"100%"},_g=Ae.memo(function({showTopList:t=!1}){const a=Ve("listState"),s=er("sizeRanges"),i=Ve("useWindowScroll"),c=Ve("customScrollParent"),u=er("windowScrollContainerState"),d=er("scrollContainerState"),f=c||i?u:d,x=Ve("itemContent"),h=Ve("context"),v=Ve("groupContent"),y=Ve("trackItemSizes"),b=Ve("itemSize"),S=Ve("log"),w=er("gap"),E=Ve("horizontalDirection"),{callbackRef:k}=Rk(s,b,y,t?Gl:f,S,w,c,E,Ve("skipAnimationFrameInResizeObserver")),[N,T]=Ae.useState(0);Gf("deviation",ee=>{N!==ee&&T(ee)});const A=Ve("EmptyPlaceholder"),B=Ve("ScrollSeekPlaceholder")??fw,z=Ve("ListComponent"),P=Ve("ItemComponent"),C=Ve("GroupComponent"),O=Ve("computeItemKey"),L=Ve("isSeeking"),_=Ve("groupIndices").length>0,H=Ve("alignToBottom"),W=Ve("initialItemFinalLocationReached"),q=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},...W?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...fn(A,h)}):r.jsx(z,{...fn(z,h),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:k,style:q,children:(t?a.topItems:a.items).map(ee=>{const $=ee.originalIndex,D=O($+a.firstItemIndex,ee.data,h);return L?m.createElement(B,{...fn(B,h),height:ee.size,index:ee.index,key:D,type:ee.type||"item",...ee.type==="group"?{}:{groupIndex:ee.groupIndex}}):ee.type==="group"?m.createElement(C,{...fn(C,h),"data-index":$,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:pw},v(ee.index,h)):m.createElement(P,{...fn(P,h),...vw(P,ee.data),"data-index":$,"data-item-group-index":ee.groupIndex,"data-item-index":ee.index,"data-known-size":ee.size,key:D,style:E?mw:Ay},_?x(ee.index,ee.groupIndex,ee.data,h):x(ee.index,ee.data,h))})})}),hw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},xw={outline:"none",overflowX:"auto",position:"relative"},oc=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),gw={position:Vf(),top:0,width:"100%",zIndex:1};function fn(t,a){if(typeof t!="string")return{context:a}}function vw(t,a){return{item:typeof t=="string"?void 0:a}}const yw=Ae.memo(function(){const t=Ve("HeaderComponent"),a=er("headerHeight"),s=Ve("HeaderFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ve("skipAnimationFrameInResizeObserver")),c=Ve("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),bw=Ae.memo(function(){const t=Ve("FooterComponent"),a=er("footerHeight"),s=Ve("HeaderFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ve("skipAnimationFrameInResizeObserver")),c=Ve("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null});function Ly({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ae.memo(function({children:i,style:c,context:u,...d}){const f=s("scrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),v=a("scrollerRef"),y=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:w}=Ry(f,h,x,v,void 0,y);return t("scrollTo",w),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...y?xw:hw,...c},tabIndex:0,...d,...fn(x,u),children:i})})}function My({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ae.memo(function({children:i,style:c,context:u,...d}){const f=s("windowScrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),v=a("totalListHeight"),y=a("deviation"),b=a("customScrollParent"),S=Ae.useRef(null),w=a("scrollerRef"),{scrollByCallback:E,scrollerRef:k,scrollToCallback:N}=Ry(f,h,x,w,b);return Ty(()=>{var T;return k.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{k.current=null}},[k,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...v!==0?{height:v+y}:void 0},...d,...fn(x,u),children:i})})}const jw=({children:t})=>{const a=Ae.useContext(Ey),s=er("viewportHeight"),i=er("fixedItemHeight"),c=Ve("alignToBottom"),u=Ve("horizontalDirection"),d=Ae.useMemo(()=>ry(s,x=>va(x,u?"width":"height")),[s,u]),f=Ka(d,!0,Ve("skipAnimationFrameInResizeObserver"));return Ae.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:f,style:oc(c),children:t})},Sw=({children:t})=>{const a=Ae.useContext(Ey),s=er("windowViewportRect"),i=er("fixedItemHeight"),c=Ve("customScrollParent"),u=ly(s,c,Ve("skipAnimationFrameInResizeObserver")),d=Ve("alignToBottom");return Ae.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:oc(d),children:t})},kw=({children:t})=>{const a=Ve("TopItemListComponent")??"div",s=Ve("headerHeight"),i={...gw,marginTop:`${s}px`},c=Ve("context");return r.jsx(a,{style:i,...fn(a,c),children:t})},ww=Ae.memo(function(t){const a=Ve("useWindowScroll"),s=Ve("topItemsIndexes").length>0,i=Ve("customScrollParent"),c=Ve("context");return r.jsxs(i||a?Nw:Ew,{...t,context:c,children:[s&&r.jsx(kw,{children:r.jsx(_g,{showTopList:!0})}),r.jsxs(i||a?Sw:jw,{children:[r.jsx(yw,{}),r.jsx(_g,{}),r.jsx(bw,{})]})]})}),{Component:Cw,useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}=Cy(dw,{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"}},ww),Ew=Ly({useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}),Nw=My({useEmitter:Gf,useEmitterValue:Ve,usePublisher:er}),Tw=Cw,Rw=ut(()=>{const t=ge(h=>r.jsxs("td",{children:["Item $",h]})),a=ge(null),s=ge(h=>r.jsxs("td",{colSpan:1e3,children:["Group ",h]})),i=ge(null),c=ge(null),u=ge({}),d=ge(Ff),f=ge(Gl),x=(h,v=null)=>pn(he(u,we(y=>y[h]),Tt()),v);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});Rt(wy,Rw);Vf();const Og={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Aw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Bg,floor:qo,max:Ws,min:Id,round:Ig}=Math;function $g(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Lw(t){return{...Aw,items:t}}function To(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Mw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const zw=ut(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:f,scrollTo:x,scrollTop:h,smoothScrollTargetReached:v,viewportHeight:y},b,S,{didMount:w,propsReady:E},{customScrollParent:k,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},z])=>{const P=ge(0),C=ge(0),O=ge(Og),L=ge({height:0,width:0}),_=ge({height:0,width:0}),H=it(),W=it(),q=ge(0),ee=ge(null),$=ge({column:0,row:0}),D=it(),I=it(),F=ge(!1),J=ge(0),de=ge(!0),M=ge(!1),U=ge(!1);pt(he(w,Qe(J),$e(([X,me])=>me!==0)),()=>{Ke(de,!1)}),pt(he(qt(w,de,_,L,J,M),$e(([X,me,je,Ne,,Me])=>X&&!me&&je.height!==0&&Ne.height!==0&&!Me)),([,,,,X])=>{Ke(M,!0),$f(1,()=>{Ke(H,X)}),sr(he(h),()=>{Ke(a,[0,0]),Ke(de,!0)})}),Le(he(I,$e(X=>X!=null&&X.scrollTop>0),xr(0)),C),pt(he(w,Qe(I),$e(([,X])=>X!=null)),([,X])=>{X&&(Ke(L,X.viewport),Ke(_,X.item),Ke($,X.gap),X.scrollTop>0&&(Ke(F,!0),sr(he(h,Wa(1)),me=>{Ke(F,!1)}),Ke(x,{top:X.scrollTop})))}),Le(he(L,we(({height:X})=>X)),y),Le(he(qt(Ie(L,To),Ie(_,To),Ie($,(X,me)=>X!==void 0&&X.column===me.column&&X.row===me.row),Ie(h)),we(([X,me,je,Ne])=>({gap:je,item:me,scrollTop:Ne,viewport:X}))),D),Le(he(qt(Ie(P),i,Ie($,Mw),Ie(_,To),Ie(L,To),Ie(ee),Ie(C),Ie(F),Ie(de),Ie(J)),$e(([,,,,,,,X])=>!X),we(([X,[me,je],Ne,Me,Fe,Ue,De,,Ge,ft])=>{const{column:oe,row:ve}=Ne,{height:ye,width:be}=Me,{width:Ee}=Fe;if(De===0&&(X===0||Ee===0))return Og;if(be===0){const Xe=Uf(ft,X),kt=Xe+Math.max(De-1,0);return Lw($g(Xe,kt,Ue))}const qe=zy(Ee,be,oe);let He,jt;Ge?me===0&&je===0&&De>0?(He=0,jt=De-1):(He=qe*qo((me+ve)/(ye+ve)),jt=qe*Bg((je+ve)/(ye+ve))-1,jt=Id(X-1,Ws(jt,qe-1)),He=Id(jt,Ws(0,He))):(He=0,jt=-1);const Dt=$g(He,jt,Ue),{bottom:St,top:At}=Ug(Fe,Ne,Me,Dt),xe=Bg(X/qe),Ze=xe*ye+(xe-1)*ve-St;return{bottom:St,itemHeight:ye,items:Dt,itemWidth:be,offsetBottom:Ze,offsetTop:At,top:At}})),O),Le(he(ee,$e(X=>X!==null),we(X=>X.length)),P),Le(he(qt(L,_,O,$),$e(([X,me,{items:je}])=>je.length>0&&me.height!==0&&X.height!==0),we(([X,me,{items:je},Ne])=>{const{bottom:Me,top:Fe}=Ug(X,Ne,me,je);return[Fe,Me]}),Tt(Js)),a);const K=ge(!1);Le(he(h,Qe(K),we(([X,me])=>me||X!==0)),K);const Q=$n(he(qt(O,P),$e(([{items:X}])=>X.length>0),Qe(K),$e(([[X,me],je])=>{const Ne=X.items[X.items.length-1].index===me-1;return(je||X.bottom>0&&X.itemHeight>0&&X.offsetBottom===0&&X.items.length===me)&&Ne}),we(([[,X]])=>X-1),Tt())),ce=$n(he(Ie(O),$e(({items:X})=>X.length>0&&X[0].index===0),xr(0),Tt())),Z=$n(he(Ie(O),Qe(F),$e(([{items:X},me])=>X.length>0&&!me),we(([{items:X}])=>({endIndex:X[X.length-1].index,startIndex:X[0].index})),Tt(dy),Ur(0)));Le(Z,S.scrollSeekRangeChanged),Le(he(H,Qe(L,_,P,$),we(([X,me,je,Ne,Me])=>{const Fe=xy(X),{align:Ue,behavior:De,offset:Ge}=Fe;let ft=Fe.index;ft==="LAST"&&(ft=Ne-1),ft=Ws(0,ft,Id(Ne-1,ft));let oe=gf(me,Me,je,ft);return Ue==="end"?oe=Ig(oe-me.height+je.height):Ue==="center"&&(oe=Ig(oe-me.height/2+je.height/2)),Ge!==void 0&&Ge!==0&&(oe+=Ge),{behavior:De,top:oe}})),x);const ie=pn(he(O,we(X=>X.offsetBottom+X.bottom)),0);return Le(he(B,we(X=>({height:X.visibleHeight,width:X.visibleWidth}))),L),{customScrollParent:k,data:ee,deviation:q,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:C,itemDimensions:_,overscan:s,restoreStateFrom:I,scrollBy:d,scrollContainerState:f,scrollHeight:W,scrollTo:x,scrollToIndex:H,scrollTop:h,smoothScrollTargetReached:v,totalCount:P,useWindowScroll:N,viewportDimensions:L,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:U,initialTopMostItemIndex:J,totalListHeight:ie,...b,endReached:Q,propsReady:E,rangeChanged:Z,startReached:ce,stateChanged:D,stateRestoreInProgress:F,...z}},Rt(Hf,yn,oi,Sy,Sa,Pf,ja));function zy(t,a,s){return Ws(1,qo((t+s)/(qo(a)+s)))}function Ug(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=gf(t,a,s,i[0].index);return{bottom:gf(t,a,s,i[i.length-1].index)+c,top:u}}function gf(t,a,s,i){const c=zy(t.width,s.width,a.column),u=qo(i/c),d=u*s.height+Ws(0,u-1)*a.row;return d>0?d+a.row:d}const Dw=ut(()=>{const t=ge(y=>`Item ${y}`),a=ge({}),s=ge(null),i=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Ff),d=ge("div"),f=ge(Gl),x=(y,b=null)=>pn(he(a,we(S=>S[y]),Tt()),b),h=ge(!1),v=ge(!1);return Le(Ie(v),h),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:h,reportReadyState:v,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),_w=ut(([t,a])=>({...t,...a}),Rt(zw,Dw)),Ow=Ae.memo(function(){const t=Mt("gridState"),a=Mt("listClassName"),s=Mt("itemClassName"),i=Mt("itemContent"),c=Mt("computeItemKey"),u=Mt("isSeeking"),d=tr("scrollHeight"),f=Mt("ItemComponent"),x=Mt("ListComponent"),h=Mt("ScrollSeekPlaceholder"),v=Mt("context"),y=tr("itemDimensions"),b=tr("gap"),S=Mt("log"),w=Mt("stateRestoreInProgress"),E=tr("reportReadyState"),k=Ka(Ae.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:z}=A.getBoundingClientRect();y({height:B,width:z})}b({column:Hg("column-gap",getComputedStyle(N).columnGap,S),row:Hg("row-gap",getComputedStyle(N).rowGap,S)})},[d,y,b,S]),!0,!1);return Ty(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),w?null:r.jsx(x,{className:a,ref:k,...fn(x,v),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,v);return u?r.jsx(h,{...fn(h,v),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(f,{...fn(f,v),className:s,"data-index":N.index,key:T},i(N.index,N.data,v))})})}),Bw=Ae.memo(function(){const t=Mt("HeaderComponent"),a=tr("headerHeight"),s=Mt("headerFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=Mt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),Iw=Ae.memo(function(){const t=Mt("FooterComponent"),a=tr("footerHeight"),s=Mt("headerFooterTag"),i=Ka(Ae.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=Mt("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),$w=({children:t})=>{const a=Ae.useContext(Ny),s=tr("itemDimensions"),i=tr("viewportDimensions"),c=Ka(Ae.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Ae.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:oc(!1),children:t})},Uw=({children:t})=>{const a=Ae.useContext(Ny),s=tr("windowViewportRect"),i=tr("itemDimensions"),c=Mt("customScrollParent"),u=ly(s,c,!1);return Ae.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:oc(!1),children:t})},Hw=Ae.memo(function({...t}){const a=Mt("useWindowScroll"),s=Mt("customScrollParent"),i=s||a?Vw:Pw,c=s||a?Uw:$w,u=Mt("context");return r.jsx(i,{...t,...fn(i,u),children:r.jsxs(c,{children:[r.jsx(Bw,{}),r.jsx(Ow,{}),r.jsx(Iw,{})]})})}),{useEmitter:Dy,useEmitterValue:Mt,usePublisher:tr}=Cy(_w,{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"}},Hw),Pw=Ly({useEmitter:Dy,useEmitterValue:Mt,usePublisher:tr}),Vw=My({useEmitter:Dy,useEmitterValue:Mt,usePublisher:tr});function Hg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Qt.WARN),a==="normal"?0:parseInt(a??"0",10)}const Fw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},_y={source:"Own",installed:"Installed"};function Gw(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 Ww(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Pg({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=Fw[t],[d,f]=m.useState(()=>Gw(u)),x=m.useCallback(()=>{f(b=>{const S=!b;return Ww(u,S),S})},[u]),h=_y[t],v=`sidebar-section-${t}-header`,y=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:v,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":y,onClick:x,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(Yw,{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:h}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),i!=null&&i>0&&r.jsx(qw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:y,role:"group","aria-labelledby":v,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function qw({origin:t,updateCount:a}){const[s,i]=m.useState(!1),c=_y[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>i(!0),onBlur:()=>i(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Yw({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 Wf(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 Kw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),f=!!i&&t.trim()!==""&&!i.test(t);return m.useEffect(()=>{function x(h){var b;if(h.key!=="/")return;const v=h.target;if(!v)return;const y=v.tagName;y==="INPUT"||y==="TEXTAREA"||v.isContentEditable||(h.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":f?!0:void 0,"aria-describedby":f?d:void 0,value:t,placeholder:s,onChange:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),f&&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 Xw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function Qw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function Zw({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(Wv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Jw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ci(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",f=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!f.startsWith("v")?`v${f}`:f,h=i==="sm"?10:12,v=i==="sm"?1:2,y=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=Jw(c,f,u),w=t.title??S,E={display:"inline-flex",alignItems:"center",padding:`${v}px ${y}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:h,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(E.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":f,"data-version-source":c,title:w,style:E,children:x})}function eC({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(d,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(ci,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(Xw,{target:t.symlinkTarget??null}),r.jsx(Qw,{skill:t}),r.jsx(Zw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const qs=m.memo(eC);function tC({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){var v;const d=[...a].sort((y,b)=>y.skill.localeCompare(b.skill)),f=(v=a[0])==null?void 0:v.pluginDisplay,x=t.replace(/^\./,"").toLowerCase(),h=!!f&&f.toLowerCase()!==x;return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",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,")"]}),h&&r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary, var(--text-secondary))",opacity:.75,fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:f,children:f})]}),r.jsx("div",{role:"list",children:d.map(y=>{const b=!!s&&s.plugin===y.plugin&&s.skill===y.skill;return r.jsx("div",{role:"listitem",children:r.jsx(qs,{skill:y,isSelected:b,onSelect:()=>i(y),onContextMenu:c,dirty:u==null?void 0:u.has(`${y.plugin}/${y.skill}`)})},`${y.plugin}/${y.skill}`)})})]})}function nC(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 $d({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const f=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,h]=m.useState(()=>nC(i,s)),v=d?!1:x,y=m.useCallback(()=>{h(w=>{const E=!w;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(E))}catch{}return E})},[i]),b=v?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":f,role:"group","aria-label":`${f} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!v,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:f}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!v&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(w=>r.jsx("div",{"data-vskill-plugin-skill":w.pluginNamespace??w.skill,children:c(w)},`${w.pluginNamespace??w.skill}`))})]})}function Vo({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:f}){const x=m.useRef(null),h=m.useRef(null),v=m.useRef(null);if(m.useEffect(()=>{if(t)return v.current=document.activeElement??null,requestAnimationFrame(()=>{var w;(w=h.current)==null||w.focus()}),()=>{var w,E;(E=(w=v.current)==null?void 0:w.focus)==null||E.call(w),v.current=null}},[t]),m.useEffect(()=>{if(!t)return;function w(E){if(E.key==="Escape"){E.preventDefault(),f();return}if(E.key==="Tab"&&x.current){const k=x.current.querySelectorAll("button:not([disabled])");if(k.length===0)return;const N=k[0],T=k[k.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[t,f]),!t)return null;const y="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:w=>{w.target===w.currentTarget&&f()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":y,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:y,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:h,type:"button","data-testid":"confirm-dialog-cancel",onClick:f,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:i})]})]})})}function rC(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Ud(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function aC({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=m.useState(!1),[u,d]=m.useState(null),[f,x]=m.useState(null),[h,v]=m.useState(!1),y=m.useRef(null);m.useEffect(()=>{if(!i)return;function w(E){y.current&&!y.current.contains(E.target)&&c(!1)}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]);async function b(w){d(w),x(null);try{const E=await fetch(`/api/plugins/${encodeURIComponent(t)}/${w}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),k=await E.json().catch(()=>({}));if(!E.ok||!k.ok){const N=k.error??`${w} failed (${E.status})`;x(N),w==="uninstall"&&Ud(`Failed to uninstall ${t}: ${N}`,"error");return}if(w==="uninstall"){const N=k.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Ud(N,"success")}In("skills"),ty(),s==null||s(),c(!1)}catch(E){const k=E instanceof Error?E.message:String(E);x(k),w==="uninstall"&&Ud(`Failed to uninstall ${t}: ${k}`,"error")}finally{d(null)}}function S(){v(!0)}return r.jsxs("div",{ref:y,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:w=>{w.stopPropagation(),c(E=>!E)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:w=>{w.currentTarget.style.color="var(--text-primary)",w.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:w=>{w.currentTarget.style.color="var(--text-tertiary)",w.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Hd,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Hd,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Hd,{onClick:S,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),f&&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:f})]}),r.jsx(Vo,{open:h,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{v(!1),c(!1)},onConfirm:()=>{v(!1),b("uninstall")}})]})}function Hd({onClick:t,disabled:a,busy:s,label:i,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}const lC=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function sC({anchorSkillDir:t,candidateLabel:a,initialName:s,initialDescription:i,onConverted:c,onCancel:u}){const[d,f]=m.useState(s),[x,h]=m.useState(i??""),[v,y]=m.useState(!1),[b,S]=m.useState(null),[w,E]=m.useState(null),k=lC.test(d),N=v||!k,T=m.useCallback(async A=>{if(A.preventDefault(),!N){y(!0),S(null),E(null);try{const B=await ke.convertToPlugin({anchorSkillDir:t,pluginName:d.trim(),description:x.trim()});c({pluginDir:B.pluginDir,manifestPath:B.manifestPath,validation:B.validation})}catch(B){if(B instanceof Ga){S(B.message);const z=B.details;z&&typeof z.stderr=="string"&&E(z.stderr)}else S(B instanceof Error?B.message:String(B));y(!1)}}},[N,t,d,x,c]);return r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"vskill-convert-dialog-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:A=>{A.target===A.currentTarget&&!v&&u()},children:r.jsxs("form",{onSubmit:T,style:{background:"var(--bg-primary, #fff)",color:"var(--text-primary, #111)",borderRadius:8,padding:20,width:"min(540px, 92vw)",boxShadow:"0 12px 48px rgba(0,0,0,0.25)",fontFamily:"var(--font-sans)"},children:[r.jsxs("h2",{id:"vskill-convert-dialog-title",style:{margin:0,fontSize:16,fontWeight:600},children:["Convert ",r.jsxs("span",{style:{fontFamily:"var(--font-mono)"},children:[a,"/"]})," to a plugin"]}),r.jsxs("p",{style:{marginTop:8,marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:["Writes ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:".claude-plugin/plugin.json"})," into this folder and validates it via ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:"claude plugin validate"}),". The skills already on disk will appear nested under the new plugin."]}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginBottom:4},children:"Plugin name"}),r.jsx("input",{type:"text",value:d,onChange:A=>f(A.target.value),disabled:v,autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontSize:13,fontFamily:"var(--font-mono)",boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),!k&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #c00)",marginTop:4},children:"Must be kebab-case (lowercase letters, digits, hyphens; 2–64 chars)."}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginTop:12,marginBottom:4},children:"Description"}),r.jsx("input",{type:"text",value:x,onChange:A=>h(A.target.value),disabled:v,style:{width:"100%",padding:"6px 8px",fontSize:13,boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),b&&r.jsxs("div",{role:"alert",style:{marginTop:12,padding:8,fontSize:12,background:"var(--color-error-bg, #fee)",color:"var(--color-error, #c00)",borderRadius:4},children:[r.jsx("div",{style:{fontWeight:500},children:b}),w&&r.jsx("pre",{style:{marginTop:6,padding:6,fontSize:11,fontFamily:"var(--font-mono)",whiteSpace:"pre-wrap",background:"rgba(0,0,0,0.04)",borderRadius:3,maxHeight:160,overflow:"auto"},children:w})]}),r.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{type:"button",onClick:u,disabled:v,style:{padding:"6px 12px",fontSize:13,background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,cursor:v?"not-allowed":"pointer"},children:"Cancel"}),r.jsx("button",{type:"submit",disabled:N,style:{padding:"6px 12px",fontSize:13,background:"var(--color-accent, #2b6cb0)",color:"white",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",opacity:N?.5:1},children:v?"Converting…":"Convert"})]})]})})}function Vg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const f=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=i==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",h=typeof u=="function",v={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:x,borderLeft:`3px solid ${f}`,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:h?"pointer":"default",border:"none",textAlign:"left"},y=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[h&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:f,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:y}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(iC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:f})})]});return h?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:v,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:v,children:b})}function iC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function oC(){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 cC(t){const a=t.key.split("+").map(f=>f.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const f of a.slice(0,-1)){const x=f.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?i=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function uC(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 dC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function vf(t,a={}){const{enabled:s=!0,target:i}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(cC),m.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function f(x){const h=x,v=uC(h.target);for(const y of c.current){if(!dC(h,y))continue;const b=y.meta||y.ctrl||y.alt;if(!(v&&!y.allowInInputs&&!b)){y.handler(h);return}}}return d.addEventListener("keydown",f),()=>{d.removeEventListener("keydown",f)}},[s,i])}function Oy(){const{data:t,loading:a,error:s,revalidate:i}=qa("project-github-status",()=>ke.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function fC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function pC({projectRoot:t}){const{status:a,loading:s}=Oy();if(s||!a||a.status==="github"||fC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const mC=200;function hC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function xC(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const d of t){const f=d.scopeV2??(d.scope==="installed"?"available-project":d.scope==="global"?"available-personal":"authoring-project");f==="available-project"?s.availableProject.push(d):f==="available-personal"?s.availablePersonal.push(d):f==="available-plugin"?s.availablePlugin.push(d):f==="authoring-plugin"?s.authoringPlugin.push(d):s.authoringProject.push(d)}function i(d){const f=d.filter(v=>Wf(v,a)),x={};for(const v of f){const y=v.pluginName??v.plugin;(x[y]||(x[y]=[])).push(v)}const h=Object.entries(x).sort((v,y)=>v[0].localeCompare(y[0]));return{total:d.length,filtered:f.length,byPlugin:h}}const c=i(s.authoringProject),u=c.byPlugin.filter(([d,f])=>f.length>=2&&d.trim().length>=2).map(([d,f])=>({groupKey:d,skills:f,anchorSkillDir:f[0].dir}));return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:c,authoringPlugin:i(s.authoringPlugin),authoringCandidatePlugins:u}}function gC(t,a){const s=[],i=[],c=[];for(const d of t){const f=hC(d);f==="global"?c.push(d):f==="installed"?i.push(d):s.push(d)}function u(d){var v;const f=d.filter(y=>Wf(y,a)),x={};for(const y of f)(x[v=y.plugin]||(x[v]=[])).push(y);const h=Object.entries(x).sort((y,b)=>y[0].localeCompare(b[0]));return{total:d.length,filtered:f.length,byPlugin:h}}return{own:u(s),installed:u(i),global:u(c)}}function vC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var h;const d=u.filter(v=>Wf(v,a)),f={};for(const v of d)(f[h=v.plugin]||(f[h]=[])).push(v);const x=Object.entries(f).sort((v,y)=>v[0].localeCompare(y[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function yC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:f,activeAgentId:x,outdatedByScope:h,topSlot:v,revealSkillId:y,onRevealComplete:b,dirtySkillIds:S,onSkillsChanged:w}){const[E,k]=m.useState(null),N=!!x||t.some(ie=>ie.scope!==void 0&&ie.scope!==null),T=x??"claude-cli",[A,B]=m.useState(""),z=m.useDeferredValue(A),P=m.useMemo(()=>gC(t,z),[t,z]),C=m.useMemo(()=>xC(t,z),[t,z]),O=T==="claude-code",{plugins:L}=vk(),_=O?{plugins:L??[]}:void 0,H=m.useMemo(()=>{const ie=new Map;for(const X of(_==null?void 0:_.plugins)??[]){const me=ie.get(X.name);ie.set(X.name,!!me||!!X.enabled)}return ie},[_==null?void 0:_.plugins]),[W,q]=m.useState(()=>yf(`vskill-sidebar-${T}-group-available-collapsed`)),[ee,$]=m.useState(()=>yf(`vskill-sidebar-${T}-group-authoring-collapsed`)),D=m.useCallback(ie=>{q(ie);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-available-collapsed`,String(ie))}catch{}},[T]),I=m.useCallback(ie=>{$(ie);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-authoring-collapsed`,String(ie))}catch{}},[T]),{own:F,installed:J}=m.useMemo(()=>vC(t,z),[t,z]),M=P.own.filtered+P.installed.filtered+P.global.filtered>=mC,U=m.useMemo(()=>{const ie=X=>{const me=[];for(const[,je]of X){const Ne=[...je].sort((Me,Fe)=>Me.skill.localeCompare(Fe.skill));me.push(...Ne)}return me};return N?[...ie(P.own.byPlugin),...ie(P.installed.byPlugin),...ie(P.global.byPlugin)]:[...ie(F.byPlugin),...ie(J.byPlugin)]},[N,P.own.byPlugin,P.installed.byPlugin,P.global.byPlugin,F.byPlugin,J.byPlugin]),K=m.useMemo(()=>a?U.findIndex(ie=>ie.plugin===a.plugin&&ie.skill===a.skill):-1,[U,a]),Q=m.useCallback(ie=>{if(U.length===0)return;const X=K<0?ie>0?0:U.length-1:Math.min(Math.max(K+ie,0),U.length-1);s(U[X])},[U,K,s]),ce=m.useMemo(()=>{if(!y)return null;const[ie,X]=y.split("/");if(!ie||!X)return null;const me=t.find(Me=>Me.plugin===ie&&Me.skill===X);if(!me)return{plugin:ie,skill:X,bucket:null,pluginName:null};const je=me.source==="plugin"?"plugin":"project",Ne=je==="plugin"?me.pluginName??ie:null;return{plugin:ie,skill:X,bucket:je,pluginName:Ne}},[y,t]),Z=m.useRef(null);return m.useEffect(()=>{if(!y){Z.current=null;return}if(Z.current===y)return;const ie=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(y):y.replace(/["\\]/g,"\\$&"),X=document.querySelector(`[data-skill-id="${ie}"]`);X&&(Z.current=y,X.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[y,b,t]),vf([{key:"j",handler:()=>Q(1)},{key:"k",handler:()=>Q(-1)},{key:"Enter",handler:()=>{K>=0&&s(U[K])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[v,r.jsx(Kw,{value:A,onChange:B}),i&&r.jsx(EC,{}),!i&&c&&r.jsx(NC,{error:c,onRetry:u}),!i&&!c&&N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Vg,{name:le.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:W,onToggle:D,count:C.availableProject.total+C.availablePersonal.total+C.availablePlugin.total}),!W&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:le.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${T}-available-project-collapsed`,count:C.availableProject.total,filteredCount:A?C.availableProject.filtered:null,updateCount:(h==null?void 0:h.installed)??(f==null?void 0:f.installed),headerRightSlot:O?r.jsx(pC,{projectRoot:T}):null,children:C.availableProject.filtered===0?r.jsx(Gg,{queryActive:!!A,agentId:T}):r.jsx($s,{items:C.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})}),r.jsx(Is,{label:le.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${T}-available-personal-collapsed`,count:C.availablePersonal.total,filteredCount:A?C.availablePersonal.filtered:null,updateCount:h==null?void 0:h.global,children:C.availablePersonal.filtered===0?r.jsx(jC,{queryActive:!!A,agentId:T}):r.jsx($s,{items:C.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})}),O&&r.jsxs(Is,{label:le.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-available-plugin-collapsed`,count:C.availablePlugin.total,filteredCount:A?C.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…"]}),C.availablePlugin.filtered===0?r.jsx(SC,{queryActive:!!A,hasInstalled:C.availablePlugin.total>0}):C.availablePlugin.byPlugin.map(([ie,X])=>r.jsx($d,{pluginName:ie,skills:X,persistKey:`vskill-plugin-available-${ie}-collapsed`,headerActionSlot:O?r.jsx(aC,{pluginName:ie,enabled:H.get(ie)??!0}):void 0,renderSkill:me=>r.jsx(qs,{skill:me,isSelected:(a==null?void 0:a.plugin)===me.plugin&&(a==null?void 0:a.skill)===me.skill,onSelect:()=>s(me),onContextMenu:d,dirty:S==null?void 0:S.has(`${me.plugin}/${me.skill}`)})},`available-${ie}`))]})]}),r.jsx(CC,{}),r.jsx(Vg,{name:le.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:ce?!1:ee,onToggle:I,count:C.authoringProject.total+C.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"}}))}}}),(!ee||ce)&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:le.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${T}-authoring-project-collapsed`,count:C.authoringProject.total,filteredCount:A?C.authoringProject.filtered:null,updateCount:(h==null?void 0:h.own)??(f==null?void 0:f.source),forceOpen:(ce==null?void 0:ce.bucket)==="project",children:C.authoringProject.filtered===0?r.jsx(Fg,{queryActive:!!A}):r.jsxs(r.Fragment,{children:[C.authoringCandidatePlugins.map(ie=>r.jsx($d,{pluginName:ie.groupKey,skills:ie.skills,persistKey:`vskill-candidate-plugin-${ie.groupKey}-collapsed`,headerActionSlot:r.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),k({candidateLabel:ie.groupKey,initialName:ie.groupKey,anchorSkillDir:ie.anchorSkillDir})},title:"Write .claude-plugin/plugin.json into this folder so Claude Code recognizes it as a plugin",style:{fontSize:10,fontWeight:500,padding:"2px 8px",borderRadius:10,border:"1px solid var(--border-subtle, rgba(128,128,128,0.3))",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Not a plugin yet · Convert →"}),renderSkill:X=>r.jsx(qs,{skill:X,isSelected:(a==null?void 0:a.plugin)===X.plugin&&(a==null?void 0:a.skill)===X.skill,onSelect:()=>s(X),onContextMenu:d,dirty:S==null?void 0:S.has(`${X.plugin}/${X.skill}`)})},`candidate-${ie.groupKey}`)),r.jsx($s,{items:C.authoringProject.byPlugin.filter(([ie])=>!C.authoringCandidatePlugins.some(X=>X.groupKey===ie)),selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})]})}),O&&r.jsx(Is,{label:le.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-authoring-plugin-collapsed`,count:C.authoringPlugin.total,filteredCount:A?C.authoringPlugin.filtered:null,forceOpen:(ce==null?void 0:ce.bucket)==="plugin",children:C.authoringPlugin.filtered===0?r.jsx(kC,{queryActive:!!A,hasSources:C.authoringPlugin.total>0,candidates:C.authoringCandidatePlugins,onPromote:ie=>k({candidateLabel:ie.groupKey,initialName:ie.groupKey,anchorSkillDir:ie.anchorSkillDir})}):C.authoringPlugin.byPlugin.map(([ie,X])=>r.jsx($d,{pluginName:ie,skills:X,persistKey:`vskill-plugin-authoring-${ie}-collapsed`,forceOpen:(ce==null?void 0:ce.bucket)==="plugin"&&ce.pluginName===ie,renderSkill:me=>r.jsx(qs,{skill:me,isSelected:(a==null?void 0:a.plugin)===me.plugin&&(a==null?void 0:a.skill)===me.skill,onSelect:()=>s(me),onContextMenu:d,dirty:S==null?void 0:S.has(`${me.plugin}/${me.skill}`)})},`authoring-${ie}`))})]})]}),!i&&!c&&!N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Pg,{origin:"source",count:F.total,filteredCount:A?F.filtered:null,updateCount:f==null?void 0:f.source,children:F.filtered===0?r.jsx(Fg,{queryActive:!!A}):r.jsx($s,{items:F.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})}),r.jsx(wC,{}),r.jsx(Pg,{origin:"installed",count:J.total,filteredCount:A?J.filtered:null,updateCount:f==null?void 0:f.installed,children:J.filtered===0?r.jsx(Gg,{queryActive:!!A}):r.jsx($s,{items:J.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:M,dirtySkillIds:S})})]}),E&&r.jsx(sC,{anchorSkillDir:E.anchorSkillDir,candidateLabel:E.candidateLabel,initialName:E.initialName,onCancel:()=>k(null),onConverted:ie=>{k(null),w==null||w(),ie.validation==="skipped"&&window.alert("Plugin manifest written, but schema validation was skipped because the 'claude' CLI is not on PATH. Install Claude Code to enable plugin schema validation.")}})]})}function yf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Is({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:f}){const[x,h]=m.useState(()=>yf(a)),v=d?!1:x,y=m.useCallback(()=>{h(S=>{const w=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(w))}catch{}return w})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!v,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:v?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),f]}),!v&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function bC(t){const a=[];for(const[s,i]of t){const c=[...i].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function $s({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=bC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Tw,{overscan:4,totalCount:d.length,itemContent:f=>{const x=d[f];if(!x)return null;if(x.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const h=x.skill,v=!!a&&a.plugin===h.plugin&&a.skill===h.skill;return r.jsx(qs,{skill:h,isSelected:v,onSelect:()=>s(h),onContextMenu:i,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,f])=>r.jsx(tC,{plugin:d,skills:f,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Fg({queryActive:t}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx($l,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Gg({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install <skill>"})," to add one."]})})}function jC({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install --global <skill>"})," to add one."]})})}function SC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx($l,{children:"Browse marketplaces…"})," above to add one."]})})}function kC({queryActive:t,hasSources:a,candidates:s,onPromote:i}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsxs(r.Fragment,{children:[r.jsx(yr,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx($l,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",r.jsx($l,{children:"vskill plugin new"})," from the terminal."]})}),s&&s.length>0&&r.jsxs("div",{style:{padding:"0 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[r.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:["Candidate folders (",s.length,")"]}),s.map(c=>r.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(c),title:`Promote ${c.groupKey}/ to a Claude Code plugin`,style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,padding:"6px 8px",fontSize:12,background:"transparent",border:"1px dashed var(--border-subtle, rgba(128,128,128,0.35))",borderRadius:4,color:"var(--text-primary)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)"},children:[r.jsxs("span",{children:[c.groupKey,"/ ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",c.skills.length," skills)"]})]}),r.jsx("span",{style:{fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)"},children:"Promote →"})]},`promote-${c.groupKey}`))]})]})}function yr({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 $l({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 wC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function CC(){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 EC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(oC,{},t))})}function NC({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:TC(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 TC(t){const a=t.split(`
|
|
66
66
|
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const By=240,Iy=480,$y="vskill-sidebar-width",Ys=320;function qf(t){return Number.isFinite(t)?Math.round(Math.max(By,Math.min(Iy,t))):Ys}function RC(){try{const t=localStorage.getItem($y);if(!t)return Ys;const a=Number(t);return Number.isFinite(a)?qf(a):Ys}catch{return Ys}}function AC(t){try{localStorage.setItem($y,String(qf(t)))}catch{}}function LC({initialWidth:t,onChange:a}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),i=m.useRef(t);return m.useEffect(()=>{i.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const f=d.clientX-s.current.startX,x=qf(s.current.startWidth+f);i.current=x,a(x)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,AC(i.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":By,"aria-valuemax":Iy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=i.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}const MC=/^[ MADRCU?!]{1,2} +/;function zC(t){return t.replace(MC,"")}function DC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function _C(t,a,s){const i=new Set;if(a.length===0||t.length===0)return i;const c=a.map(u=>zC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const f=DC(s,d);if(f===null)continue;const x=`${u.plugin}/${u.skill}`;if(f===""){c.length>0&&i.add(x);continue}const h=f+"/";for(const v of c)if(v===f||v.startsWith(h)){i.add(x);break}}return i}const OC=5e3;function BC(t,a,s=OC){const[i,c]=m.useState([]),u=m.useRef(t);return u.current=t,m.useEffect(()=>{if(!a){c([]);return}let d=!1,f=null;const x=async()=>{try{const v=await ke.gitStatus();d||c(v.paths??[])}catch{d||c([])}d||(f=setTimeout(x,s))};x();const h=()=>{x()};return typeof window<"u"&&window.addEventListener("studio:content-saved",h),()=>{d=!0,f&&clearTimeout(f),typeof window<"u"&&window.removeEventListener("studio:content-saved",h)}},[a,s]),a?_C(u.current,i,a):new Set}function IC({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 Uy(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 Hy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);try{const s=new WeakSet;return JSON.stringify(t,(i,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Pd(){const[t,a]=m.useState([]),[s,i]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState(null),x=m.useRef(null),h=m.useCallback(async(y,b)=>{a([]),i(!0),u(!1),f(null);const S=new AbortController;x.current=S;try{const w=Hy(b),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:w,signal:S.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,z;try{z=await E.json(),z&&typeof z=="object"&&"error"in z&&typeof z.error=="string"&&(B=z.error)}catch{}throw Uy(E.status,z),new Error(B)}const k=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:z}=await k.read();if(B)break;T+=N.decode(z,{stream:!0});const P=T.split(`
|
|
67
67
|
`);T=P.pop()||"";for(const C of P)if(C.startsWith("event: "))A=C.slice(7).trim();else if(C.startsWith("data: ")){try{const O=JSON.parse(C.slice(6)),L={event:A,data:O};A==="done"?(u(!0),a(_=>[..._,L])):a(_=>[..._,L])}catch{}A=""}}}catch(w){w.name!=="AbortError"&&f(w.message)}finally{i(!1),x.current=null}},[]),v=m.useCallback(()=>{var y;(y=x.current)==null||y.abort()},[]);return{events:t,running:s,done:c,error:d,start:h,stop:v}}function $C(t){const a=m.useRef(t);a.current=t;const[s,i]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(h,v,y)=>{var S;(S=c.current.get(h))==null||S.abort();const b=new AbortController;c.current.set(h,b),i(w=>{const E=new Set(w);return E.add(h),E});try{const w=Hy(y),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:w,signal:b.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,z;try{z=await E.json(),z&&typeof z=="object"&&"error"in z&&typeof z.error=="string"&&(B=z.error)}catch{}throw Uy(E.status,z),new Error(B)}const k=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:z}=await k.read();if(B)break;T+=N.decode(z,{stream:!0});const P=T.split(`
|
|
68
68
|
`);T=P.pop()||"";for(const C of P)if(C.startsWith("event: "))A=C.slice(7).trim();else if(C.startsWith("data: ")){try{const O=JSON.parse(C.slice(6)),L={event:A,data:O};a.current.onEvent(h,L)}catch{}A=""}}a.current.onDone(h)}catch(w){w.name!=="AbortError"&&a.current.onError(h,w.message)}finally{i(w=>{const E=new Set(w);return E.delete(h),E}),c.current.delete(h)}},[]),d=m.useCallback(h=>{var v;(v=c.current.get(h))==null||v.abort()},[]),f=m.useCallback(()=>{for(const h of c.current.values())h.abort()},[]),x=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:f,isAnyCaseRunning:x}}const UC={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationPromptsSource:null,activationPromptsCanonical:"",savingTestCases:!1,savingTestCasesError:null,savingTestCasesSuccess:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function HC(t,a){var s,i;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(f=>({assertion_id:f.id,text:f.text,pass:f.pass,reasoning:f.reasoning}))});const u=((i=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:i.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":{const c=a.prompts===t.activationPromptsCanonical;return{...t,activationPrompts:a.prompts,activationPromptsSource:c?t.activationPromptsSource:t.activationPromptsSource===null||t.activationPromptsSource==="skill-md"||t.activationPromptsSource==="ai-generated"?"user-typed":t.activationPromptsSource}}case"SET_PROMPTS_SOURCE":return{...t,activationPromptsSource:a.source,activationPromptsCanonical:a.canonical??t.activationPromptsCanonical};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:a.error};case"SAVE_TEST_CASES_START":return{...t,savingTestCases:!0,savingTestCasesError:null,savingTestCasesSuccess:null};case"SAVE_TEST_CASES_SUCCESS":return{...t,savingTestCases:!1,savingTestCasesSuccess:`Saved ${a.count} test case${a.count===1?"":"s"} to SKILL.md`,activationPromptsSource:"skill-md",activationPromptsCanonical:t.activationPrompts};case"SAVE_TEST_CASES_ERROR":return{...t,savingTestCases:!1,savingTestCasesError:a.error};case"CLEAR_SAVE_TEST_CASES_FEEDBACK":return{...t,savingTestCasesSuccess:null,savingTestCasesError:null};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function PC(t,a){if(!t)return{canEdit:!1,canRun:!1};const s=t.origin==="source",i=a.exists&&a.cases.length>0;return{canEdit:s,canRun:i}}function VC(t){if(t==="unit"||t==="integration")return t}function FC(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.event==="assertion_result"){const i={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===i.assertion_id)||t.assertions.push(i)}a.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const Py=m.createContext(null);function bn(){const t=m.useContext(Py);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function GC({plugin:t,skill:a,origin:s,children:i}){var ft;const c=s==="installed",{config:u}=Ya(),[d,f]=m.useReducer(HC,{...UC,plugin:t,skill:a}),x=PC({origin:s},{exists:d.evals!=null,cases:((ft=d.evals)==null?void 0:ft.evals)??[]}),h=x.canEdit,v=x.canRun,y=m.useRef(new Set),b=m.useRef(new Set),S=m.useRef(new Map),w=m.useCallback((oe,ve)=>{let ye=S.current.get(oe);ye||(ye={assertions:[]},S.current.set(oe,ye)),FC(ye,ve),f({type:"UPDATE_INLINE_RESULT",evalId:oe,result:{...ye,assertions:[...ye.assertions]}})},[]),E=m.useCallback(oe=>{if(b.current.has(oe))return;b.current.add(oe);const ve=S.current.get(oe)??{assertions:[]};f({type:"CASE_RUN_COMPLETE",caseId:oe,result:{...ve,assertions:[...ve.assertions]}}),y.current.has(oe)&&(y.current.delete(oe),y.current.size===0&&ke.getLatestBenchmark(t,a).then(ye=>f({type:"BULK_RUN_COMPLETE",benchmark:ye})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),k=m.useCallback((oe,ve)=>{b.current.has(oe)||(b.current.add(oe),f({type:"CASE_RUN_ERROR",caseId:oe,error:ve}),y.current.has(oe)&&(y.current.delete(oe),y.current.size===0&&ke.getLatestBenchmark(t,a).then(ye=>f({type:"BULK_RUN_COMPLETE",benchmark:ye})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:N,stopCase:T,stopAll:A}=$C({onEvent:w,onDone:E,onError:k});m.useEffect(()=>()=>{A()},[A]);const B=m.useCallback(async()=>{try{const oe=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!oe.ok){if(oe.status===404){f({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const ve=await oe.json();f({type:"ACTIVATION_HISTORY_LOADED",runs:ve.runs||[]})}catch{}},[t,a]);m.useEffect(()=>{let oe=!1;async function ve(){try{const[ye,be,Ee]=await Promise.allSettled([ke.getSkillDetail(t,a),ke.getEvals(t,a),ke.getLatestBenchmark(t,a)]);if(oe)return;let qe=null,He=null;if(be.status==="fulfilled")qe=be.value;else{const jt=be.reason;He=(jt==null?void 0:jt.message)??"Failed to load test cases"}f({type:"INIT_DATA",skillContent:ye.status==="fulfilled"?ye.value.skillContent:"",evals:qe,evalsError:He,benchmark:Ee.status==="fulfilled"?Ee.value:null})}catch(ye){oe||f({type:"SET_ERROR",error:ye.message})}}return ve(),B(),()=>{oe=!0}},[t,a,B]);const z=m.useCallback(async oe=>{if(c)return;const ve=oe??d.skillContent;try{await ke.applyImprovement(t,a,ve),oe!==void 0&&oe!==d.skillContent&&f({type:"SET_CONTENT",content:oe}),f({type:"CONTENT_SAVED"})}catch(ye){f({type:"SET_ERROR",error:ye.message})}},[c,t,a,d.skillContent]),P=m.useCallback(async oe=>{if(!c)try{const ve=await ke.saveEvals(t,a,oe);f({type:"SET_EVALS",evals:ve})}catch(ve){f({type:"SET_ERROR",error:ve.message})}},[c,t,a]),C=m.useCallback((oe,ve="benchmark")=>{const ye=d.caseRunStates.get(oe);if((ye==null?void 0:ye.status)==="running")return;S.current.delete(oe),b.current.delete(oe),f({type:"CASE_RUN_START",caseId:oe,mode:ve});const be=ve==="comparison"?{eval_ids:[oe]}:ve==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(be.provider=u.provider),u!=null&&u.model&&(be.model=u.model),ve==="comparison"){const Ee=`/api/skills/${t}/${a}/compare`;N(oe,Ee,be)}else{const Ee=`/api/skills/${t}/${a}/benchmark/case/${oe}`;N(oe,Ee,Object.keys(be).length>0?be:void 0)}},[t,a,d.caseRunStates,N,u]),O=m.useCallback((oe="benchmark")=>{var be;const ve=((be=d.evals)==null?void 0:be.evals)??[];if(ve.length===0)return;const ye=ve.map(Ee=>Ee.id);for(const Ee of ye)S.current.delete(Ee),b.current.delete(Ee);f({type:"BULK_RUN_START",caseIds:ye,mode:oe}),y.current=new Set(ye);for(const Ee of ye){const qe=oe==="comparison"?{eval_ids:[Ee]}:oe==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(qe.provider=u.provider),u!=null&&u.model&&(qe.model=u.model),oe==="comparison")N(Ee,`/api/skills/${t}/${a}/compare`,qe);else{const He=`/api/skills/${t}/${a}/benchmark/case/${Ee}`;N(Ee,He,Object.keys(qe).length>0?qe:void 0)}}},[t,a,d.evals,N,u]),L=m.useCallback(oe=>{T(oe),f({type:"CASE_RUN_CANCEL",caseId:oe}),y.current.delete(oe),b.current.add(oe)},[T]),_=m.useCallback(()=>{A(),f({type:"CANCEL_ALL"}),y.current.clear()},[A]),H=m.useCallback(async(oe,ve)=>{f({type:"OPEN_IMPROVE",evalId:oe})},[]),W=m.useCallback(async(oe,ve)=>{try{await ke.applyImprovement(t,a,ve),f({type:"SET_CONTENT",content:ve}),f({type:"CONTENT_SAVED"}),f({type:"CLOSE_IMPROVE"}),C(oe,"benchmark")}catch(ye){f({type:"SET_ERROR",error:ye.message})}},[t,a,C]),q=Pd(),ee=m.useRef(null),$=m.useRef(0);m.useEffect(()=>{const oe=q.events;for(let ve=$.current;ve<oe.length;ve++){const ye=oe[ve],be=ye.data;if(ye.event==="progress"&&f({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:be.phase,message:be.message}}),ye.event==="done"){const Ee=be.improved,qe=be.reasoning,He=be.evalChanges??[];f({type:"AI_EDIT_RESULT",improved:Ee,reasoning:qe,evalChanges:He})}if(ye.event==="error"){const Ee=be;f({type:"AI_EDIT_ERROR",message:Ee.description||"Unknown error",classified:Ee})}}$.current=oe.length},[q.events]),m.useEffect(()=>{q.error&&f({type:"AI_EDIT_ERROR",message:q.error})},[q.error]),m.useEffect(()=>()=>{q.stop()},[q.stop]);const D=m.useCallback(async(oe,ve,ye)=>{c||($.current=0,f({type:"AI_EDIT_LOADING"}),ee.current=q.stop,q.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:oe,content:d.skillContent,evals:d.evals??{skill_name:a,evals:[]},provider:ve,model:ye}))},[c,t,a,d.skillContent,d.evals,q]),I=m.useCallback(()=>{q.stop(),f({type:"AI_EDIT_ERROR",message:"Cancelled"})},[q]),F=m.useCallback(async()=>{const oe=d.aiEditResult;if(oe!=null&&oe.improved)try{if(await ke.applyImprovement(t,a,oe.improved),f({type:"SET_CONTENT",content:oe.improved}),f({type:"CONTENT_SAVED"}),d.aiEditEvalChanges.length>0&&Array.from(d.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:ye}=await Vl(async()=>{const{mergeEvalChanges:qe}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:qe}},[]),be=d.evals??{skill_name:a,evals:[]},Ee=ye(be,d.aiEditEvalChanges,d.aiEditEvalSelections);try{const qe=await ke.saveEvals(t,a,Ee);f({type:"SET_EVALS",evals:qe})}catch(qe){f({type:"SET_EVALS_RETRY",evalsFile:Ee}),f({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${qe.message}. You can retry from the AI Edit panel.`});return}}f({type:"CLOSE_AI_EDIT"})}catch(ve){f({type:"SET_ERROR",error:ve.message})}},[t,a,d.aiEditResult,d.evals,d.aiEditEvalChanges,d.aiEditEvalSelections]),J=m.useCallback(()=>{f({type:"CLOSE_AI_EDIT"})},[]),de=m.useCallback(oe=>{f({type:"TOGGLE_EVAL_CHANGE",index:oe})},[]),M=m.useCallback(()=>{f({type:"SELECT_ALL_EVAL_CHANGES"})},[]),U=m.useCallback(()=>{f({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),K=m.useCallback(async()=>{const oe=d.aiEditEvalsRetry;if(oe)try{const ve=await ke.saveEvals(t,a,oe);f({type:"SET_EVALS",evals:ve}),f({type:"SET_ERROR",error:null}),f({type:"CLOSE_AI_EDIT"})}catch(ve){f({type:"SET_ERROR",error:`Retry failed: ${ve.message}`})}},[t,a,d.aiEditEvalsRetry]),Q=m.useCallback(async()=>{try{const oe=await ke.getSkillDetail(t,a);f({type:"SET_CONTENT",content:oe.skillContent}),f({type:"CONTENT_SAVED"})}catch{}},[t,a]),ce=Pd(),Z=m.useRef(0);m.useEffect(()=>{const oe=ce.events;for(let ve=Z.current;ve<oe.length;ve++){const ye=oe[ve],be=ye.data;if(ye.event==="progress"&&f({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:be.phase,message:be.message}}),ye.event==="done"){const Ee=be;ke.saveEvals(t,a,Ee).then(qe=>f({type:"GENERATE_EVALS_DONE",evals:qe})).catch(qe=>f({type:"SET_ERROR",error:qe.message}))}ye.event==="error"&&f({type:"GENERATE_EVALS_ERROR",classified:be})}Z.current=oe.length},[ce.events,t,a]),m.useEffect(()=>{ce.error&&f({type:"SET_ERROR",error:ce.error})},[ce.error]),m.useEffect(()=>()=>{ce.stop()},[ce.stop]);const ie=m.useCallback(async oe=>{if(c)return;Z.current=0,f({type:"GENERATE_EVALS_START"});const ve={};u!=null&&u.provider&&(ve.provider=u.provider),u!=null&&u.model&&(ve.model=u.model);const ye=VC(oe==null?void 0:oe.testType);ye&&(ve.testType=ye),ce.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(ve).length>0?ve:void 0)},[c,t,a,ce,u]),X=Pd(),me=m.useRef(0);m.useEffect(()=>()=>{X.stop()},[X.stop]),m.useEffect(()=>{const oe=X.events;for(let ve=me.current;ve<oe.length;ve++){const ye=oe[ve];if(ye.event==="classifying"){const be=ye.data;f({type:"ACTIVATION_CLASSIFYING",index:be.index,total:be.total})}if(ye.event==="prompt_result"&&f({type:"ACTIVATION_RESULT",result:ye.data}),ye.event==="done"){je.current&&(clearTimeout(je.current),je.current=null);const be=ye.data;if(be.error)f({type:"ACTIVATION_ERROR",error:be.error});else{f({type:"ACTIVATION_DONE",summary:be});const Ee={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(u==null?void 0:u.model)||"unknown",provider:(u==null?void 0:u.provider)||"unknown",promptCount:be.total,summary:{precision:be.precision,recall:be.recall,reliability:be.reliability,tp:be.tp,tn:be.tn,fp:be.fp,fn:be.fn}};f({type:"ACTIVATION_HISTORY_LOADED",runs:[Ee,...d.activationHistory??[]]})}}}me.current=oe.length},[X.events,u,d.activationHistory]),m.useEffect(()=>{X.error&&(je.current&&(clearTimeout(je.current),je.current=null),f({type:"ACTIVATION_ERROR",error:X.error}))},[X.error]);const je=m.useRef(null),Ne=m.useCallback(()=>{je.current&&(clearTimeout(je.current),je.current=null),X.stop(),f({type:"ACTIVATION_CANCEL",totalPrompts:0})},[X]),Me=m.useCallback(oe=>{const ye=oe.trim().split(`
|
|
@@ -119,4 +119,4 @@ You are an expert at...
|
|
|
119
119
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
120
120
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
121
121
|
}`})]}),document.body)}function rR({agent:t,focused:a,active:s,onClick:i}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:i,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount,"·",t.pluginCount??0]})]})}function aR({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 lR({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 sR({agent:t,activeAgentId:a,onSwitch:s}){const i=t.id===a,c=t.isRemoteOnly===!0,u=i||c,d=i?"Active":c?"Remote-only":le.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":oR(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Do,{label:le.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Do,{label:le.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Do,{label:le.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),r.jsx(Do,{label:le.scopePicker.statsLastSync,value:t.lastSync?iR(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 Do({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 vv(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function iR(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const i=Math.round(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const c=Math.round(i/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function oR(t){switch(t){case"ok":return le.scopePicker.statsHealthOk;case"stale":return le.scopePicker.statsHealthStale;case"missing":return le.scopePicker.statsHealthMissing}}function cR(t){const a=new Map;for(const s of t.sharedFolders??[])for(const i of s.consumers)a.set(i,s);return t.agents.map(s=>{const i=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,pluginCount:s.pluginSkillCount??0,lastSync:s.lastSync,health:s.health,sharedFolderGroup:i?i.consumers:void 0,sharedFolderPath:i?i.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function uR({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:i}){const[c,u]=m.useState(!1),[d,f]=m.useState(null),x=m.useRef(null),h=m.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),v=m.useMemo(()=>h?h.health==="ok"?"var(--color-ok, #22c55e)":h.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[h]),y=m.useCallback(()=>{var S;u(!1),(S=x.current)==null||S.focus()},[]),b=m.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:x,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:v,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(h==null?void 0:h.displayName)??"Select agent"}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(h==null?void 0:h.installedCount)??0," · ",(h==null?void 0:h.globalCount)??0," · ",(h==null?void 0:h.pluginCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(nR,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:f,onSwitch:b,onOpenSetup:S=>{i(S),y()},onClose:y})]})}const bb="vskill-ccode-banner-dismissed",dR=new Set(["claude-cli","claude-code"]);function fR(){try{return sessionStorage.getItem(bb)==="true"}catch{return!1}}function pR(){try{sessionStorage.setItem(bb,"true")}catch{}}function mR({activeAgentId:t}){const[a,s]=m.useState(()=>fR()),i=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{pR(),s(!0)},[]);return!t||!dR.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:[le.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:i,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:le.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 hR(){const[t,a]=m.useState(null),[s,i]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const f=await ke.getAgents();a(f),i("ready"),u(null)}catch(f){i("error"),u(f.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const f=()=>void d();return window.addEventListener("studio:agent-changed",f),()=>window.removeEventListener("studio:agent-changed",f)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const _o="workspace",xR=["skills","agents"];async function gR(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function vR(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 yR(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 bR(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 nf(){for(const t of xR)In(t)}function jR(){const{data:t,loading:a,error:s,revalidate:i}=qa(_o,gR),c=t,u=c==null?void 0:c.projects.find(h=>h.id===c.activeProjectId),d=m.useCallback(async h=>{await vR(h),In(_o),nf()},[]),f=m.useCallback(async h=>{await yR(h),In(_o),nf()},[]),x=m.useCallback(async h=>{await bR(h),In(_o),nf()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:f,removeProject:x,revalidate:i}}function SR({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=m.useState(!1),[f,x]=m.useState(!1),[h,v]=m.useState(""),[y,b]=m.useState(null),[S,w]=m.useState(null),[E,k]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),B=(t==null?void 0:t.projects)??[],z=B.find(L=>L.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function L(_){A.current&&!A.current.contains(_.target)&&(d(!1),x(!1),b(null))}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[u]);async function P(){b(null);const L=h.trim();if(!L){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!L.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(L)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:L}),v(""),x(!1)}catch(_){const H=_ instanceof Error?_.message:String(_);/does not exist/i.test(H)?b(`Path not found on disk: ${L}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function C(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const L=await window.showDirectoryPicker();v(L.name),x(!0)}catch{}else x(!0)}function O(L){if(L.length<=50)return L;const _=L.split("/");return _.length<=4?L:`${_.slice(0,3).join("/")}/…/${_.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(L=>!L),"aria-expanded":u,"aria-haspopup":"menu",title:(z==null?void 0:z.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(z==null?void 0:z.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z?z.name:"No project"}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&r.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[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(L=>{const _=c?c(L.path):!1,H=L.id===(t==null?void 0:t.activeProjectId),W=S===L.id;return r.jsxs("li",{role:"menuitem","data-stale":_?"true":"false",onMouseEnter:()=>w(L.id),onMouseLeave:()=>w(q=>q===L.id?null:q),onClick:()=>{if(!_){if(H){d(!1);return}k(L)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:_?"not-allowed":"pointer",background:W&&!_?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:_?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:L.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:L.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:L.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(L.path)}),_&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${L.name}`,onClick:q=>{q.stopPropagation(),i(L.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:W?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:q=>{q.currentTarget.style.color="var(--color-error, #b91c1c)",q.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:q=>{q.currentTarget.style.color="var(--text-tertiary)",q.currentTarget.style.backgroundColor="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},L.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:f?8:6},children:[!f&&r.jsxs("button",{type:"button",onClick:()=>void C(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:L=>{L.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:L=>{L.currentTarget.style.backgroundColor="transparent"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),f&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:h,onChange:L=>v(L.target.value),onKeyDown:L=>{L.key==="Enter"&&P(),L.key==="Escape"&&(x(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{x(!1),b(null),v("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>void P(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),y&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:y})]})]})]}),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:()=>k(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:L=>L.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",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:()=>k(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 kR(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(i=>{const c=`${i.name} ${i.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function wR({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=m.useState(""),[d,f]=m.useState(0),x=m.useMemo(()=>kR(a,c),[a,c]);m.useEffect(()=>{t||(u(""),f(0))},[t]),m.useEffect(()=>{d>=x.length&&f(0)},[x.length,d]);const h=v=>{if(v.key==="Escape"){v.preventDefault(),i();return}if(v.key==="ArrowDown"){v.preventDefault(),f(y=>Math.min(y+1,Math.max(x.length-1,0)));return}if(v.key==="ArrowUp"){v.preventDefault(),f(y=>Math.max(y-1,0));return}if(v.key==="Enter"){v.preventDefault();const y=x[d];y&&(s(y.id),i())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:i}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:v=>u(v.target.value),onKeyDown:h,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[x.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),x.map((v,y)=>r.jsxs("li",{role:"option","aria-selected":y===d,"data-highlighted":y===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",y===d?"bg-muted":""].join(" "),onMouseEnter:()=>f(y),onClick:()=>{s(v.id),i()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:v.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:v.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:v.path})]})]},v.id))]})]})]}):null}const yv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function CR({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,f]=m.useState("destination"),[x,h]=m.useState(s),[v,y]=m.useState(""),[b,S]=m.useState(""),[w,E]=m.useState(""),[k,N]=m.useState([]),[T,A]=m.useState(!1),[B,z]=m.useState(null);if(m.useEffect(()=>{t&&(f("destination"),h(s),y(""),S(""),E(""),z(null))},[t,s]),m.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(D=>D.json()).then(D=>{$&&N(D.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),m.useEffect(()=>{if(!t)return;function $(D){D.key==="Escape"&&(D.preventDefault(),a())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,a]),!t)return null;const P=k.length>0,C=i&&P,O=i,L=yv.test(v),_=x==="existing-plugin"?b.length>0:yv.test(b),H=!T&&L&&(x==="standalone"||_),W=ER(c,x,b,v);async function q(){z(null),A(!0);try{const I=new URLSearchParams;I.set("mode",x),I.set("skillName",v),b&&I.set("pluginName",b);const F=await fetch(`/api/authoring/skill-exists?${I.toString()}`),J=await F.json();if(!F.ok){z(J.error??`Check failed: ${F.status}`);return}if(J.exists){z(`Skill '${v}' already exists${J.path?` at ${J.path}`:""}`);return}}catch(I){z(I instanceof Error?I.message:String(I));return}finally{A(!1)}const $=new URLSearchParams;$.set("mode",x),$.set("skillName",v),w.trim()&&$.set("description",w.trim()),b&&$.set("pluginName",b);const D=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=D),a()}async function ee(){z(null),A(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,skillName:v,description:w.trim()||void 0,pluginName:x==="standalone"?void 0:b})}),D=await $.json();if(!$.ok||!D.ok){z(D.error??`Create failed: ${$.status}`);return}In("skills"),u==null||u({mode:x,skillName:v,pluginName:D.pluginName??null,skillMdPath:D.skillMdPath}),a()}catch($){z($ instanceof Error?$.message:String($))}finally{A(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(rf,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:x==="standalone",onClick:()=>h("standalone")}),r.jsx(rf,{title:"Add to existing plugin",subtitle:C?`${k.length} plugin source${k.length===1?"":"s"} in this project`:i?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!C,selected:x==="existing-plugin",onClick:()=>C&&h("existing-plugin")}),r.jsx(rf,{title:"Plugin (multi-skill)",subtitle:O?"Bundle related skills under one Claude Code plugin":"Claude Code only",description:"Creates <folder>/.claude-plugin/plugin.json and <folder>/skills/<first>/SKILL.md.",icon:"📦",disabled:!O,selected:x==="new-plugin",onClick:()=>O&&h("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[x==="new-plugin"&&r.jsx(Oo,{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:Bo(!b||_)})}),x==="existing-plugin"&&r.jsx(Oo,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...Bo(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),k.map($=>r.jsx("option",{value:$.name,children:$.name},$.path))]})}),r.jsx(Oo,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:v,onChange:$=>y($.target.value.trim()),placeholder:"my-new-skill",autoFocus:x!=="new-plugin",style:Bo(!v||L)})}),r.jsx(Oo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:w,onChange:$=>E($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...Bo(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),W&&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:"}),W.map(($,D)=>r.jsx("div",{children:$},D))]}),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:af,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>f("details"),style:bv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>f("destination"),style:af,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void q(),disabled:!H,style:{...af,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 ee(),disabled:!H,style:{...bv,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 rf({title:t,subtitle:a,description:s,icon:i,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:i}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function Oo({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 Bo(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 bv={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"},af={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 ER(t,a,s,i){const c=i||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function jb(t){return t.trim().toLowerCase()}function NR(t,a){const s=jb(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function TR(t,a){const s=jb(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function RR({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=m.useState(null),[f,x]=m.useState([]),[h,v]=m.useState(null),[y,b]=m.useState(null),[S,w]=m.useState(!1),[E,k]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState("");m.useEffect(()=>{h?T(""):B("")},[h]);const z=m.useMemo(()=>NR(f,N),[f,N]),P=m.useMemo(()=>TR((y==null?void 0:y.plugins)??[],A),[y,A]);return m.useEffect(()=>{t&&(w(!0),k(null),fetch("/api/plugins/marketplaces").then(C=>C.json()).then(C=>{if(C.error)throw new Error(C.error);x(C.marketplaces??[])}).catch(C=>k(C instanceof Error?C.message:String(C))).finally(()=>w(!1)))},[t]),m.useEffect(()=>{if(!h){b(null);return}w(!0),k(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(h)}`).then(C=>C.json()).then(C=>{if(C.error)throw new Error(C.error);b(C)}).catch(C=>k(C instanceof Error?C.message:String(C))).finally(()=>w(!1))},[h]),m.useEffect(()=>{if(!t)return;function C(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[h&&r.jsx("button",{type:"button",onClick:()=>v(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:h?(y==null?void 0:y.name)??h:"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}),!h&&!S&&f.length===0&&!E&&r.jsx(AR,{}),!h&&f.length>0&&r.jsx(jv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!h&&f.length>0&&z.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!h&&z.map(C=>r.jsxs("button",{type:"button",onClick:()=>v(C.name),style:MR,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:C.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.source})]},C.name)),h&&y&&r.jsxs(r.Fragment,{children:[y.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:y.description}),y.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),y.plugins.length>0&&r.jsx(jv,{value:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),y.plugins.length>0&&P.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),P.map(C=>{const O=c.has(C.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[C.name,C.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:C.version}),C.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:C.category})]}),C.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:C.description})]}),O&&i?r.jsx("button",{type:"button",disabled:u===C.name,onClick:async()=>{d(C.name);try{await i(C.name)}finally{d(null)}},"aria-label":`Uninstall ${C.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===C.name?"wait":"pointer",opacity:u===C.name?.6:1,fontFamily:"inherit"},children:u===C.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(C.name,h),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"})]})},C.name)})]})]}),!h&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(LR,{onAdded:()=>{In("marketplaces"),fetch("/api/plugins/marketplaces").then(C=>C.json()).then(C=>x(C.marketplaces??[]))}})})]})]}):null}function jv({value:t,onChange:a,placeholder:s,ariaLabel:i,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":i,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function AR(){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 LR({onAdded:t}){const[a,s]=m.useState(""),[i,c]=m.useState(!1),[u,d]=m.useState(null);async function f(){const x=a.trim();if(x){c(!0),d(null);try{const h=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x})}),v=await h.json().catch(()=>({}));if(!h.ok||!v.ok){d(v.error??`Add failed (${h.status})`);return}s(""),t()}catch(h){d(h instanceof Error?h.message:String(h))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&f()},placeholder:"anthropics/claude-plugins-official",disabled:i,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void f(),disabled:i||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:i||!a.trim()?"not-allowed":"pointer",opacity:i||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:i?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const MR={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},lf=12;function zR({job:t,onDone:a}){const[s,i]=m.useState([]),[c,u]=m.useState("running"),[d,f]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;i([]),u("running"),f(!1);const y=new AbortController;let b=[],S="running";return(async()=>{try{const w=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:y.signal});if(!w.ok||!w.body){u("failed"),a({ok:!1,code:w.status,lines:[`HTTP ${w.status}`]});return}const E=w.body.getReader(),k=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=k.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const z of B){const P=z.match(/^data:\s*(.*)$/m);if(P)try{const C=JSON.parse(P[1]);C.type==="stdout"&&C.line?(b=[...b,C.line].slice(-lf),i(b)):C.type==="stderr"&&C.line?(b=[...b,`⚠ ${C.line}`].slice(-lf),i(b)):C.type==="done"?(S=C.ok?"ok":"failed",u(S),ty(),In("skills"),a({ok:C.ok??!1,code:C.code??null,lines:b})):C.type==="error"&&C.error&&(b=[...b,`✘ ${C.error}`].slice(-lf),i(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(w){if(w.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,w instanceof Error?w.message:String(w)]})}})(),()=>y.abort()},[t==null?void 0:t.ref]),!t)return null;const x=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",h=c==="ok"?"✔":c==="failed"?"✘":"…",v=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${x}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>f(y=>!y),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:x,width:16,textAlign:"center"},children:c==="running"?r.jsx(DR,{}):h}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[v,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-primary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
|
|
122
|
-
`)})]})}function DR(){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 _R=3e3,OR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Sv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function BR(){const{toast:t}=rc(),a=m.useRef(new Map),s=m.useCallback(i=>{if(!Sv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<_R)return;a.current.set(i.provider,c);const d=OR[i.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:i.provider}}))}}})},[t]);return m.useEffect(()=>{function i(c){const u=c.detail;!u||!Sv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const Sb="vskill.studio.prefs";function kb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function wb(){const t=kb();if(!t)return{};try{const a=t.getItem(Sb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function IR(t,a){const s=kb();if(s)try{const c={...wb(),[t]:a};s.setItem(Sb,JSON.stringify(c))}catch{}}function $R(t,a){const i=wb()[t];return i===void 0?a:i}const kv={open:!1,x:0,y:0,skill:null};function UR(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function Ha(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function HR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function PR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{Ha(le.toasts.permissionDenied,"error");return}Ha(le.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ha(le.actions.editPlaceholder,"info");return;case"run-benchmark":Ha(le.toasts.benchmarkQueued,"info");return;case"duplicate":Ha(le.toasts.skillDuplicated,"info");return;case"update":Ha(le.toasts.skillUpdated,"info");return;case"uninstall":Ha(le.actions.editPlaceholder,"info");return;case"delete":HR(a);return;default:return}}function VR(t){return t.startsWith("#/create")}function FR(t){return t.startsWith("#/updates")}function Cb(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function GR(){return Cb(VR)}function WR(){return Cb(FR)}function qR(){var i,c;if(typeof navigator>"u")return"⌘⇧K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function YR(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function KR(){const[t,a]=m.useState("⌘⇧K");m.useEffect(()=>{a(qR())},[]);const s=YR();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const XR=m.lazy(()=>Vl(()=>import("./FindSkillsPalette-MfuQzMDW.js"),__vite__mapDeps([2,1])).then(t=>({default:t.FindSkillsPalette}))),QR=m.lazy(()=>Vl(()=>import("./SkillDetailPanel-DBrDY92e.js"),__vite__mapDeps([3,4,1])).then(t=>({default:t.SkillDetailPanel}))),ZR=m.lazy(()=>Vl(()=>import("./CreateSkillPage-BEBnDBmh.js"),__vite__mapDeps([5,1])).then(t=>({default:t.CreateSkillPage}))),JR=m.lazy(()=>Vl(()=>Promise.resolve().then(()=>QN),void 0).then(t=>({default:t.UpdatesPanel})));function e4(){return r.jsx(KS,{children:r.jsx(WS,{children:r.jsxs(Y2,{children:[r.jsx(t4,{}),r.jsx(HT,{})]})})})}function t4(){var jr,rn;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=cr(),{config:f}=Ya(),{resolvedTheme:x,setTheme:h}=ey(),{toast:v}=rc(),[y,b]=m.useState(()=>RC()),[S]=m.useState(!0),[w,E]=m.useState(!1),[k,N]=m.useState(!1),[T,A]=m.useState(()=>typeof window>"u"?"overview":Ef(window.location.search).tab),[B,z]=m.useState(()=>{if(typeof window>"u")return"";const ae=Ef(window.location.search);return ae.mode?ae.mode:ae.view?ae.view:vb(ae.tab,window.location.search)}),P=m.useCallback(ae=>{A(Se=>(Se!==ae&&z(Ks(ae)),ae))},[]);m.useEffect(()=>{if(typeof window>"u")return;const ae=()=>{const Se=new URLSearchParams(window.location.search),Te=Se.get("tab"),$t=Se.get("panel"),Ct=Zo(Te)??Zo($t);if(!Ct)return;const Jt=new URLSearchParams(window.location.search);Jt.delete("panel"),Jt.delete("sub"),Ct.tab==="overview"?Jt.delete("tab"):Jt.set("tab",Ct.tab),Jt.delete("mode"),Jt.delete("view"),Ct.mode&&Jt.set("mode",Ct.mode),Ct.view&&Jt.set("view",Ct.view);const Vr=Jt.toString(),dr=`${window.location.pathname}${Vr?"?"+Vr:""}${window.location.hash}`,nt=`${window.location.pathname}${window.location.search}${window.location.hash}`;dr!==nt&&window.history.replaceState(null,"",dr),A(Ct.tab),Ct.mode?z(Ct.mode):Ct.view?z(Ct.view):z(Ks(Ct.tab))};return ae(),window.addEventListener("popstate",ae),()=>window.removeEventListener("popstate",ae)},[]),m.useEffect(()=>{if(typeof window>"u")return;const ae=new URLSearchParams(window.location.search);ae.delete("panel"),ae.delete("sub"),T==="overview"?ae.delete("tab"):ae.set("tab",T),ae.delete("mode"),ae.delete("view"),!(B===Ks(T))&&B&&(T==="run"?ae.set("mode",B):T==="history"&&ae.set("view",B));const Te=ae.toString(),$t=`${window.location.pathname}${Te?"?"+Te:""}${window.location.hash}`,Ct=`${window.location.pathname}${window.location.search}${window.location.hash}`;$t!==Ct&&window.history.replaceState(null,"",$t)},[T,B]);const[C,O]=m.useState(kv),L=m.useCallback((ae,Se)=>{O(UR(ae,Se))},[]),_=hR(),[H,W]=m.useState(()=>$R("activeAgent",null)),q=m.useCallback(ae=>{W(ae),IR("activeAgent",ae),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ae}}))},[]);m.useEffect(()=>{var ae;!H&&((ae=_.response)!=null&&ae.suggested)&&q(_.response.suggested)},[H,(jr=_.response)==null?void 0:jr.suggested,q]);const ee=m.useMemo(()=>_.response?cR(_.response):[],[_.response]),{workspace:$,switchProject:D,addProject:I,removeProject:F,activeProject:J}=jR(),[de,M]=m.useState(!1),[U,K]=m.useState(!1),[Q,ce]=m.useState("standalone"),Z=m.useCallback((ae="standalone")=>{ce(ae),K(!0)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Z((Te==null?void 0:Te.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ae),()=>window.removeEventListener("studio:request-create-skill",ae)},[Z]);const[ie,X]=m.useState(!1),[me,je]=m.useState(null),[Ne,Me]=m.useState(null);m.useEffect(()=>{function ae(){X(!0)}return window.addEventListener("studio:open-marketplace",ae),()=>window.removeEventListener("studio:open-marketplace",ae)},[]);const Fe=m.useMemo(()=>{const ae=new Set;for(const Se of t.skills)Se.source==="plugin"&&Se.pluginName&&ae.add(Se.pluginName);return ae},[t.skills]);vf([{key:"p",meta:!0,handler:ae=>{var Te;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Te=ae==null?void 0:ae.preventDefault)==null||Te.call(ae),M($t=>!$t))}}],{enabled:!0});const Ue=eR(),De=Ue.open;m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.provider&&De(Te.provider)}return window.addEventListener("studio:open-setup-drawer",ae),()=>window.removeEventListener("studio:open-setup-drawer",ae)},[De]);const Ge=m.useCallback(()=>{O(kv)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.message&&v({message:Te.message,severity:Te.severity??"info"})}return window.addEventListener("studio:toast",ae),()=>window.removeEventListener("studio:toast",ae)},[v]),BR();const[ft,oe]=m.useState(!1),[ve,ye]=m.useState(void 0);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;ye(Te==null?void 0:Te.provider),oe(!0)}return window.addEventListener("studio:open-settings",ae),()=>window.removeEventListener("studio:open-settings",ae)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${y}px`)},[y]),m.useEffect(()=>{function ae(){i()}return window.addEventListener("studio:content-saved",ae),()=>window.removeEventListener("studio:content-saved",ae)},[i]);const[be,Ee]=m.useState(null),[qe,He]=m.useState(()=>new Set),jt=m.useRef(!1),Dt=m.useMemo(()=>rC(),[]),St=m.useCallback(ae=>`${ae.plugin}/${ae.skill}`,[]),At=m.useCallback(ae=>{He(Se=>{const Te=new Set(Se);return Te.add(St(ae)),Te})},[St]),xe=m.useCallback(ae=>{He(Se=>{const Te=new Set(Se);return Te.delete(St(ae)),Te})},[St]),Ze=gv({delayMs:1e4,onCommit:ae=>{i(),xe(ae)},onFailure:(ae,Se)=>{xe(ae),v({message:`Couldn't delete ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:le.actions.retry,onInvoke:()=>{At(ae),Ze.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.skill&&Ee(Te.skill)}return window.addEventListener("studio:request-delete",ae),()=>window.removeEventListener("studio:request-delete",ae)},[]);const[Xe,kt]=m.useState(null),_t=gv({delayMs:250,apiCall:(ae,Se)=>api.uninstallSkill(ae,Se),onCommit:ae=>{i(),xe(ae)},onFailure:(ae,Se)=>{xe(ae),v({message:`Couldn't uninstall ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:le.actions.retry,onInvoke:()=>{At(ae),_t.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.skill&&kt(Te.skill)}return window.addEventListener("studio:request-uninstall",ae),()=>window.removeEventListener("studio:request-uninstall",ae)},[]);const lt=m.useCallback(()=>{const ae=Xe;if(kt(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};At(Se),_t.enqueueDelete(Se),v({message:`Uninstalled ${ae.skill}. Sent to your ${Dt}.`,severity:"info",durationMs:4e3})},[Xe,At,_t,v,Dt]),jn=m.useCallback(()=>{kt(null)},[]),Yt=m.useCallback(()=>{const ae=be;if(Ee(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};At(Se),Ze.enqueueDelete(Se);const Te=jt.current?"":`Sent to your ${Dt}. Open Trash to restore. `;jt.current=!0,v({message:`${Te}Deleted ${ae.skill}`,severity:"info",durationMs:1e4,action:{label:le.actions.undo,onInvoke:()=>{Ze.cancelDelete(St(Se)),xe(Se)}}})},[be,At,xe,Ze,v,Dt,St]),mn=m.useCallback(()=>{Ee(null)},[]),un=m.useMemo(()=>t.skills.filter(ae=>!qe.has(St(ae))),[t.skills,qe,St]),ur=BC(un,(J==null?void 0:J.path)??null),Tn=m.useMemo(()=>t.selectedSkill?t.skills.find(ae=>ae.plugin===t.selectedSkill.plugin&&ae.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Hn=m.useCallback(ae=>{a({plugin:ae.plugin,skill:ae.skill,origin:ae.origin,source:ae.source})},[a]),Rn=m.useMemo(()=>{if(!t.selectedSkill)return"";const ae=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ae})`},[t.selectedSkill]),[wt,Be]=m.useState(null);vf([{key:"cmd+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>E(ae=>!ae)},{key:"cmd+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"cmd+b",handler:()=>N(ae=>!ae)},{key:"ctrl+b",handler:()=>N(ae=>!ae)},{key:"e",handler:()=>v({message:le.actions.editPlaceholder,severity:"info"})}]);const Je=GR(),hn=WR()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(JR,{})}):Je?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(ZR,{})}):r.jsx(zT,{selectedSkillInfo:Tn,activeDetailTab:T,onDetailTabChange:P,activeDetailSub:B,onDetailSubChange:z,allSkills:t.skills,onSelectSkill:Hn});return r.jsxs(r.Fragment,{children:[r.jsx(XS,{sidebarWidth:y,sidebarHidden:k||t.isMobile&&t.mobileView==="detail",banner:r.jsx(IC,{connected:S}),liveMessage:Rn,topRail:r.jsx(ek,{projectName:(f==null?void 0:f.projectName)??null,selected:t.selectedSkill,onHome:s,onRequestCreateSkill:()=>Z("standalone"),projectPickerSlot:$&&$.projects.length>0?r.jsx(SR,{workspace:$,onSwitch:D,onAdd:I,onRemove:F}):void 0,findSkillsSlot:r.jsx(KR,{})}),sidebar:r.jsx(yC,{skills:un,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Hn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:L,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:ur,onSkillsChanged:i,topSlot:_.status==="ready"&&ee.length>0?r.jsxs(r.Fragment,{children:[r.jsx(uR,{agents:ee,activeAgentId:H,onActiveAgentChange:q,onOpenSetup:ae=>Ue.open(ae)}),r.jsx(mR,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(LC,{initialWidth:y??Ys,onChange:b}),main:hn,statusBar:r.jsx(dk,{projectPath:(f==null?void 0:f.root)??null,modelName:(f==null?void 0:f.model)??null,health:f!=null&&f.error?"degraded":"ok",providers:(rn=f==null?void 0:f.providers)==null?void 0:rn.map(ae=>{const Se=ae.id;return{id:Se,label:ae.label,available:ae.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(VT,{open:w,onClose:()=>E(!1)}),r.jsx(YT,{open:Ue.isOpen,providerKey:Ue.providerKey,onClose:Ue.close}),r.jsx(GT,{state:C,onClose:Ge,onAction:(ae,Se)=>PR(ae,Se)}),r.jsx(m.Suspense,{fallback:null,children:r.jsx(XR,{onSelect:ae=>{const Se=ae.name.split("/");Se.length===3&&Be({owner:Se[0],repo:Se[1],slug:Se[2],displayName:ae.displayName??ae.name})}})}),wt&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(QR,{selectedSkill:wt,onClose:()=>Be(null)})}),r.jsx(wR,{open:de,projects:($==null?void 0:$.projects)??[],onSwitch:ae=>{D(ae)},onClose:()=>M(!1)}),r.jsx(CR,{open:U,onClose:()=>K(!1),initialMode:Q,isClaudeCode:H==="claude-code",projectRoot:(J==null?void 0:J.path)??(f==null?void 0:f.projectName)??"",onCreated:ae=>{i(),setTimeout(()=>{u(ae.pluginName??"",ae.skillName)},500)}}),r.jsx(RR,{open:ie,onClose:()=>X(!1),installedNames:Fe,onInstall:(ae,Se)=>{je({plugin:ae,marketplace:Se,ref:`${ae}@${Se}`}),X(!1)},onUninstall:async ae=>{if(await new Promise(Te=>{Me({plugin:ae,resolve:Te})}))try{const Te=await fetch(`/api/plugins/${encodeURIComponent(ae)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),$t=await Te.json().catch(()=>({}));if(!Te.ok||!$t.ok){v({message:$t.error??`Uninstall failed (${Te.status})`,severity:"error"});return}const Ct=$t.fallback==="orphan-cache-removed"?`Removed orphaned ${ae}.`:`Uninstalled ${ae}.`;v({message:Ct,severity:"success"}),i()}catch(Te){v({message:Te instanceof Error?Te.message:String(Te),severity:"error"})}}}),r.jsx(Xv,{open:ft,onClose:()=>oe(!1),initialProvider:ve,onToast:ae=>v({message:ae,severity:"info"})}),r.jsx(zR,{job:me,onDone:ae=>{ae.ok&&(i(),setTimeout(()=>je(null),3e3))}}),r.jsx(Vo,{open:be!==null,title:be?`Delete "${be.skill}"?`:"",body:`It will be sent to your ${Dt}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:mn}),r.jsx(Vo,{open:Xe!==null,title:Xe?`Uninstall "${Xe.skill}"?`:"",body:`It will be sent to your ${Dt} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:lt,onCancel:jn}),r.jsx(Vo,{open:Ne!==null,title:Ne?`Uninstall ${Ne.plugin}?`:"",body:Ne?`This removes the ${Ne.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ne==null||Ne.resolve(!0),Me(null)},onCancel:()=>{Ne==null||Ne.resolve(!1),Me(null)}})]})}const wv="vskill.migrations.scope-rename.v1",n4={own:"authoring-project",installed:"available-project",global:"available-personal"},r4=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function a4(t){if(t.getItem(wv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(r4);if(!c)continue;const[,u,d]=c,f=n4[d];if(!f)continue;const x=t.getItem(i);x!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${f}-collapsed`,value:x})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(wv,"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{a4(window.localStorage)}catch{}V0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(uS,{children:r.jsx(sk,{children:r.jsx(e4,{})})})}));export{dc as E,Vv as L,ui as P,Ae as R,qN as S,s4 as T,Vl as _,cr as a,wb as b,FN as c,cc as d,rc as e,ke as f,$R as g,cb as h,r as j,m as r,Qo as t,Ya as u,IR as w};
|
|
122
|
+
`)})]})}function DR(){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 _R=3e3,OR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Sv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function BR(){const{toast:t}=rc(),a=m.useRef(new Map),s=m.useCallback(i=>{if(!Sv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<_R)return;a.current.set(i.provider,c);const d=OR[i.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:i.provider}}))}}})},[t]);return m.useEffect(()=>{function i(c){const u=c.detail;!u||!Sv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const Sb="vskill.studio.prefs";function kb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function wb(){const t=kb();if(!t)return{};try{const a=t.getItem(Sb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function IR(t,a){const s=kb();if(s)try{const c={...wb(),[t]:a};s.setItem(Sb,JSON.stringify(c))}catch{}}function $R(t,a){const i=wb()[t];return i===void 0?a:i}const kv={open:!1,x:0,y:0,skill:null};function UR(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function Ha(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function HR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function PR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{Ha(le.toasts.permissionDenied,"error");return}Ha(le.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ha(le.actions.editPlaceholder,"info");return;case"run-benchmark":Ha(le.toasts.benchmarkQueued,"info");return;case"duplicate":Ha(le.toasts.skillDuplicated,"info");return;case"update":Ha(le.toasts.skillUpdated,"info");return;case"uninstall":Ha(le.actions.editPlaceholder,"info");return;case"delete":HR(a);return;default:return}}function VR(t){return t.startsWith("#/create")}function FR(t){return t.startsWith("#/updates")}function Cb(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function GR(){return Cb(VR)}function WR(){return Cb(FR)}function qR(){var i,c;if(typeof navigator>"u")return"⌘⇧K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function YR(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function KR(){const[t,a]=m.useState("⌘⇧K");m.useEffect(()=>{a(qR())},[]);const s=YR();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const XR=m.lazy(()=>Vl(()=>import("./FindSkillsPalette-XKomH8zI.js"),__vite__mapDeps([2,1])).then(t=>({default:t.FindSkillsPalette}))),QR=m.lazy(()=>Vl(()=>import("./SkillDetailPanel-BEqkY3lG.js"),__vite__mapDeps([3,4,1])).then(t=>({default:t.SkillDetailPanel}))),ZR=m.lazy(()=>Vl(()=>import("./CreateSkillPage--g_NEIiD.js"),__vite__mapDeps([5,1])).then(t=>({default:t.CreateSkillPage}))),JR=m.lazy(()=>Vl(()=>Promise.resolve().then(()=>QN),void 0).then(t=>({default:t.UpdatesPanel})));function e4(){return r.jsx(KS,{children:r.jsx(WS,{children:r.jsxs(Y2,{children:[r.jsx(t4,{}),r.jsx(HT,{})]})})})}function t4(){var jr,rn;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=cr(),{config:f}=Ya(),{resolvedTheme:x,setTheme:h}=ey(),{toast:v}=rc(),[y,b]=m.useState(()=>RC()),[S]=m.useState(!0),[w,E]=m.useState(!1),[k,N]=m.useState(!1),[T,A]=m.useState(()=>typeof window>"u"?"overview":Ef(window.location.search).tab),[B,z]=m.useState(()=>{if(typeof window>"u")return"";const ae=Ef(window.location.search);return ae.mode?ae.mode:ae.view?ae.view:vb(ae.tab,window.location.search)}),P=m.useCallback(ae=>{A(Se=>(Se!==ae&&z(Ks(ae)),ae))},[]);m.useEffect(()=>{if(typeof window>"u")return;const ae=()=>{const Se=new URLSearchParams(window.location.search),Te=Se.get("tab"),$t=Se.get("panel"),Ct=Zo(Te)??Zo($t);if(!Ct)return;const Jt=new URLSearchParams(window.location.search);Jt.delete("panel"),Jt.delete("sub"),Ct.tab==="overview"?Jt.delete("tab"):Jt.set("tab",Ct.tab),Jt.delete("mode"),Jt.delete("view"),Ct.mode&&Jt.set("mode",Ct.mode),Ct.view&&Jt.set("view",Ct.view);const Vr=Jt.toString(),dr=`${window.location.pathname}${Vr?"?"+Vr:""}${window.location.hash}`,nt=`${window.location.pathname}${window.location.search}${window.location.hash}`;dr!==nt&&window.history.replaceState(null,"",dr),A(Ct.tab),Ct.mode?z(Ct.mode):Ct.view?z(Ct.view):z(Ks(Ct.tab))};return ae(),window.addEventListener("popstate",ae),()=>window.removeEventListener("popstate",ae)},[]),m.useEffect(()=>{if(typeof window>"u")return;const ae=new URLSearchParams(window.location.search);ae.delete("panel"),ae.delete("sub"),T==="overview"?ae.delete("tab"):ae.set("tab",T),ae.delete("mode"),ae.delete("view"),!(B===Ks(T))&&B&&(T==="run"?ae.set("mode",B):T==="history"&&ae.set("view",B));const Te=ae.toString(),$t=`${window.location.pathname}${Te?"?"+Te:""}${window.location.hash}`,Ct=`${window.location.pathname}${window.location.search}${window.location.hash}`;$t!==Ct&&window.history.replaceState(null,"",$t)},[T,B]);const[C,O]=m.useState(kv),L=m.useCallback((ae,Se)=>{O(UR(ae,Se))},[]),_=hR(),[H,W]=m.useState(()=>$R("activeAgent",null)),q=m.useCallback(ae=>{W(ae),IR("activeAgent",ae),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ae}}))},[]);m.useEffect(()=>{var ae;!H&&((ae=_.response)!=null&&ae.suggested)&&q(_.response.suggested)},[H,(jr=_.response)==null?void 0:jr.suggested,q]);const ee=m.useMemo(()=>_.response?cR(_.response):[],[_.response]),{workspace:$,switchProject:D,addProject:I,removeProject:F,activeProject:J}=jR(),[de,M]=m.useState(!1),[U,K]=m.useState(!1),[Q,ce]=m.useState("standalone"),Z=m.useCallback((ae="standalone")=>{ce(ae),K(!0)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Z((Te==null?void 0:Te.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ae),()=>window.removeEventListener("studio:request-create-skill",ae)},[Z]);const[ie,X]=m.useState(!1),[me,je]=m.useState(null),[Ne,Me]=m.useState(null);m.useEffect(()=>{function ae(){X(!0)}return window.addEventListener("studio:open-marketplace",ae),()=>window.removeEventListener("studio:open-marketplace",ae)},[]);const Fe=m.useMemo(()=>{const ae=new Set;for(const Se of t.skills)Se.source==="plugin"&&Se.pluginName&&ae.add(Se.pluginName);return ae},[t.skills]);vf([{key:"p",meta:!0,handler:ae=>{var Te;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Te=ae==null?void 0:ae.preventDefault)==null||Te.call(ae),M($t=>!$t))}}],{enabled:!0});const Ue=eR(),De=Ue.open;m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.provider&&De(Te.provider)}return window.addEventListener("studio:open-setup-drawer",ae),()=>window.removeEventListener("studio:open-setup-drawer",ae)},[De]);const Ge=m.useCallback(()=>{O(kv)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.message&&v({message:Te.message,severity:Te.severity??"info"})}return window.addEventListener("studio:toast",ae),()=>window.removeEventListener("studio:toast",ae)},[v]),BR();const[ft,oe]=m.useState(!1),[ve,ye]=m.useState(void 0);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;ye(Te==null?void 0:Te.provider),oe(!0)}return window.addEventListener("studio:open-settings",ae),()=>window.removeEventListener("studio:open-settings",ae)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${y}px`)},[y]),m.useEffect(()=>{function ae(){i()}return window.addEventListener("studio:content-saved",ae),()=>window.removeEventListener("studio:content-saved",ae)},[i]);const[be,Ee]=m.useState(null),[qe,He]=m.useState(()=>new Set),jt=m.useRef(!1),Dt=m.useMemo(()=>rC(),[]),St=m.useCallback(ae=>`${ae.plugin}/${ae.skill}`,[]),At=m.useCallback(ae=>{He(Se=>{const Te=new Set(Se);return Te.add(St(ae)),Te})},[St]),xe=m.useCallback(ae=>{He(Se=>{const Te=new Set(Se);return Te.delete(St(ae)),Te})},[St]),Ze=gv({delayMs:1e4,onCommit:ae=>{i(),xe(ae)},onFailure:(ae,Se)=>{xe(ae),v({message:`Couldn't delete ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:le.actions.retry,onInvoke:()=>{At(ae),Ze.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.skill&&Ee(Te.skill)}return window.addEventListener("studio:request-delete",ae),()=>window.removeEventListener("studio:request-delete",ae)},[]);const[Xe,kt]=m.useState(null),_t=gv({delayMs:250,apiCall:(ae,Se)=>api.uninstallSkill(ae,Se),onCommit:ae=>{i(),xe(ae)},onFailure:(ae,Se)=>{xe(ae),v({message:`Couldn't uninstall ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:le.actions.retry,onInvoke:()=>{At(ae),_t.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Te=Se.detail;Te!=null&&Te.skill&&kt(Te.skill)}return window.addEventListener("studio:request-uninstall",ae),()=>window.removeEventListener("studio:request-uninstall",ae)},[]);const lt=m.useCallback(()=>{const ae=Xe;if(kt(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};At(Se),_t.enqueueDelete(Se),v({message:`Uninstalled ${ae.skill}. Sent to your ${Dt}.`,severity:"info",durationMs:4e3})},[Xe,At,_t,v,Dt]),jn=m.useCallback(()=>{kt(null)},[]),Yt=m.useCallback(()=>{const ae=be;if(Ee(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};At(Se),Ze.enqueueDelete(Se);const Te=jt.current?"":`Sent to your ${Dt}. Open Trash to restore. `;jt.current=!0,v({message:`${Te}Deleted ${ae.skill}`,severity:"info",durationMs:1e4,action:{label:le.actions.undo,onInvoke:()=>{Ze.cancelDelete(St(Se)),xe(Se)}}})},[be,At,xe,Ze,v,Dt,St]),mn=m.useCallback(()=>{Ee(null)},[]),un=m.useMemo(()=>t.skills.filter(ae=>!qe.has(St(ae))),[t.skills,qe,St]),ur=BC(un,(J==null?void 0:J.path)??null),Tn=m.useMemo(()=>t.selectedSkill?t.skills.find(ae=>ae.plugin===t.selectedSkill.plugin&&ae.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Hn=m.useCallback(ae=>{a({plugin:ae.plugin,skill:ae.skill,origin:ae.origin,source:ae.source})},[a]),Rn=m.useMemo(()=>{if(!t.selectedSkill)return"";const ae=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ae})`},[t.selectedSkill]),[wt,Be]=m.useState(null);vf([{key:"cmd+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>E(ae=>!ae)},{key:"cmd+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"cmd+b",handler:()=>N(ae=>!ae)},{key:"ctrl+b",handler:()=>N(ae=>!ae)},{key:"e",handler:()=>v({message:le.actions.editPlaceholder,severity:"info"})}]);const Je=GR(),hn=WR()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(JR,{})}):Je?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(ZR,{})}):r.jsx(zT,{selectedSkillInfo:Tn,activeDetailTab:T,onDetailTabChange:P,activeDetailSub:B,onDetailSubChange:z,allSkills:t.skills,onSelectSkill:Hn});return r.jsxs(r.Fragment,{children:[r.jsx(XS,{sidebarWidth:y,sidebarHidden:k||t.isMobile&&t.mobileView==="detail",banner:r.jsx(IC,{connected:S}),liveMessage:Rn,topRail:r.jsx(ek,{projectName:(f==null?void 0:f.projectName)??null,selected:t.selectedSkill,onHome:s,onRequestCreateSkill:()=>Z("standalone"),projectPickerSlot:$&&$.projects.length>0?r.jsx(SR,{workspace:$,onSwitch:D,onAdd:I,onRemove:F}):void 0,findSkillsSlot:r.jsx(KR,{})}),sidebar:r.jsx(yC,{skills:un,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Hn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:L,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:ur,onSkillsChanged:i,topSlot:_.status==="ready"&&ee.length>0?r.jsxs(r.Fragment,{children:[r.jsx(uR,{agents:ee,activeAgentId:H,onActiveAgentChange:q,onOpenSetup:ae=>Ue.open(ae)}),r.jsx(mR,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(LC,{initialWidth:y??Ys,onChange:b}),main:hn,statusBar:r.jsx(dk,{projectPath:(f==null?void 0:f.root)??null,modelName:(f==null?void 0:f.model)??null,health:f!=null&&f.error?"degraded":"ok",providers:(rn=f==null?void 0:f.providers)==null?void 0:rn.map(ae=>{const Se=ae.id;return{id:Se,label:ae.label,available:ae.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(VT,{open:w,onClose:()=>E(!1)}),r.jsx(YT,{open:Ue.isOpen,providerKey:Ue.providerKey,onClose:Ue.close}),r.jsx(GT,{state:C,onClose:Ge,onAction:(ae,Se)=>PR(ae,Se)}),r.jsx(m.Suspense,{fallback:null,children:r.jsx(XR,{onSelect:ae=>{const Se=ae.name.split("/");Se.length===3&&Be({owner:Se[0],repo:Se[1],slug:Se[2],displayName:ae.displayName??ae.name})}})}),wt&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(QR,{selectedSkill:wt,onClose:()=>Be(null)})}),r.jsx(wR,{open:de,projects:($==null?void 0:$.projects)??[],onSwitch:ae=>{D(ae)},onClose:()=>M(!1)}),r.jsx(CR,{open:U,onClose:()=>K(!1),initialMode:Q,isClaudeCode:H==="claude-code",projectRoot:(J==null?void 0:J.path)??(f==null?void 0:f.projectName)??"",onCreated:ae=>{i(),setTimeout(()=>{u(ae.pluginName??"",ae.skillName)},500)}}),r.jsx(RR,{open:ie,onClose:()=>X(!1),installedNames:Fe,onInstall:(ae,Se)=>{je({plugin:ae,marketplace:Se,ref:`${ae}@${Se}`}),X(!1)},onUninstall:async ae=>{if(await new Promise(Te=>{Me({plugin:ae,resolve:Te})}))try{const Te=await fetch(`/api/plugins/${encodeURIComponent(ae)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),$t=await Te.json().catch(()=>({}));if(!Te.ok||!$t.ok){v({message:$t.error??`Uninstall failed (${Te.status})`,severity:"error"});return}const Ct=$t.fallback==="orphan-cache-removed"?`Removed orphaned ${ae}.`:`Uninstalled ${ae}.`;v({message:Ct,severity:"success"}),i()}catch(Te){v({message:Te instanceof Error?Te.message:String(Te),severity:"error"})}}}),r.jsx(Xv,{open:ft,onClose:()=>oe(!1),initialProvider:ve,onToast:ae=>v({message:ae,severity:"info"})}),r.jsx(zR,{job:me,onDone:ae=>{ae.ok&&(i(),setTimeout(()=>je(null),3e3))}}),r.jsx(Vo,{open:be!==null,title:be?`Delete "${be.skill}"?`:"",body:`It will be sent to your ${Dt}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:mn}),r.jsx(Vo,{open:Xe!==null,title:Xe?`Uninstall "${Xe.skill}"?`:"",body:`It will be sent to your ${Dt} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:lt,onCancel:jn}),r.jsx(Vo,{open:Ne!==null,title:Ne?`Uninstall ${Ne.plugin}?`:"",body:Ne?`This removes the ${Ne.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ne==null||Ne.resolve(!0),Me(null)},onCancel:()=>{Ne==null||Ne.resolve(!1),Me(null)}})]})}const wv="vskill.migrations.scope-rename.v1",n4={own:"authoring-project",installed:"available-project",global:"available-personal"},r4=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function a4(t){if(t.getItem(wv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(r4);if(!c)continue;const[,u,d]=c,f=n4[d];if(!f)continue;const x=t.getItem(i);x!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${f}-collapsed`,value:x})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(wv,"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{a4(window.localStorage)}catch{}V0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(uS,{children:r.jsx(sk,{children:r.jsx(e4,{})})})}));export{dc as E,Vv as L,ui as P,Ae as R,qN as S,s4 as T,Vl as _,cr as a,wb as b,FN as c,cc as d,rc as e,ke as f,$R as g,cb as h,r as j,m as r,Qo as t,Ya as u,IR as w};
|