vskill 1.2.10 → 1.2.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/commands/submit.d.ts +2 -0
- package/dist/commands/submit.js +4 -0
- package/dist/commands/submit.js.map +1 -1
- package/dist/eval-server/install-engine-routes.d.ts +12 -7
- package/dist/eval-server/install-engine-routes.js +2 -39
- package/dist/eval-server/install-engine-routes.js.map +1 -1
- package/dist/eval-server/install-jobs.js +31 -19
- package/dist/eval-server/install-jobs.js.map +1 -1
- package/dist/eval-server/install-skill-routes.js +7 -6
- package/dist/eval-server/install-skill-routes.js.map +1 -1
- package/dist/eval-server/install-state-routes.d.ts +2 -2
- package/dist/eval-server/install-state-routes.js +22 -9
- package/dist/eval-server/install-state-routes.js.map +1 -1
- package/dist/eval-server/remove-skill-routes.js +226 -156
- package/dist/eval-server/remove-skill-routes.js.map +1 -1
- package/dist/eval-server/skill-authoring-engine.d.ts +10 -0
- package/dist/eval-server/skill-authoring-engine.js +58 -0
- package/dist/eval-server/skill-authoring-engine.js.map +1 -0
- package/dist/eval-server/skill-authoring-path.d.ts +15 -0
- package/dist/eval-server/skill-authoring-path.js +38 -0
- package/dist/eval-server/skill-authoring-path.js.map +1 -0
- package/dist/eval-server/skill-authoring-route.d.ts +3 -0
- package/dist/eval-server/skill-authoring-route.js +37 -0
- package/dist/eval-server/skill-authoring-route.js.map +1 -0
- package/dist/eval-server/skill-create-routes.d.ts +74 -2
- package/dist/eval-server/skill-create-routes.js +59 -160
- package/dist/eval-server/skill-create-routes.js.map +1 -1
- package/dist/eval-server/skill-generate-route.d.ts +2 -0
- package/dist/eval-server/skill-generate-route.js +130 -0
- package/dist/eval-server/skill-generate-route.js.map +1 -0
- package/dist/eval-server/skill-install-paths.d.ts +39 -0
- package/dist/eval-server/skill-install-paths.js +167 -0
- package/dist/eval-server/skill-install-paths.js.map +1 -0
- package/dist/eval-server/skill-md-emitter.js +4 -2
- package/dist/eval-server/skill-md-emitter.js.map +1 -1
- package/dist/eval-server/supported-agents-routes.d.ts +8 -2
- package/dist/eval-server/supported-agents-routes.js +10 -2
- package/dist/eval-server/supported-agents-routes.js.map +1 -1
- package/dist/eval-ui/assets/{AdvancedTab-6VlfqCuD.js → AdvancedTab-DX3v5Q7O.js} +1 -1
- package/dist/eval-ui/assets/CreateSkillPage-CwreCn22.js +151 -0
- package/dist/eval-ui/assets/{FindSkillsPalette-M6Ot4Qeq.js → FindSkillsPalette-B5-3ZLEo.js} +2 -2
- package/dist/eval-ui/assets/{GeneralTab-BpFlJ2ue.js → GeneralTab-BfFbcbuP.js} +1 -1
- package/dist/eval-ui/assets/{PrivacyTab-UfO7QLy_.js → PrivacyTab-Bq2N7Iam.js} +1 -1
- package/dist/eval-ui/assets/{SearchPaletteCore-CufFV6OR.js → SearchPaletteCore-Bgld3QTz.js} +1 -1
- package/dist/eval-ui/assets/SkillDetailPanel-B5LYvcry.js +1 -0
- package/dist/eval-ui/assets/{UpdateDropdown-CVM2xW6V.js → UpdateDropdown-VRCYPtXG.js} +1 -1
- package/dist/eval-ui/assets/{UpdatesTab-C38-n7V3.js → UpdatesTab-w6h18GPp.js} +1 -1
- package/dist/eval-ui/assets/core-DgHXlyD_.js +1 -0
- package/dist/eval-ui/assets/{event-QtOCMXAv.js → event-CABB5pUM.js} +1 -1
- package/dist/eval-ui/assets/{fonts-i7Lkz2zN.css → fonts-BZeyWEAn.css} +1 -1
- package/dist/eval-ui/assets/{index-DlQYQHDO.js → index-Bje294df.js} +1 -1
- package/dist/eval-ui/assets/{index-DDNzcrhv.js → index-D0lWXViJ.js} +1 -1
- package/dist/eval-ui/assets/{index-CUEYzTVL.js → index-DCV9_0X4.js} +1 -1
- package/dist/eval-ui/assets/main-DIkxEshL.js +86 -0
- package/dist/eval-ui/assets/{preferences-BN-jNWS0.js → preferences-VTBvoXmM.js} +2 -2
- package/dist/eval-ui/assets/source-serif-4-cyrillic-ext-wght-normal-DHTKMUil.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-cyrillic-wght-normal-B1g8a0vD.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-greek-wght-normal-BpXpdlRW.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-ext-wght-normal-BVZ5su8S.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-wght-normal-DMe4EKeb.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-vietnamese-wght-normal-BsaNuasd.woff2 +0 -0
- package/dist/eval-ui/assets/{useDesktopBridge-Cm4zPght.js → useDesktopBridge-C8dT34x9.js} +2 -2
- package/dist/eval-ui/index.html +3 -3
- package/dist/eval-ui/lifecycle.html +2 -2
- package/dist/eval-ui/preferences.html +3 -3
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/shared/authoring-engine-commands.d.ts +14 -0
- package/dist/shared/authoring-engine-commands.js +10 -0
- package/dist/shared/authoring-engine-commands.js.map +1 -0
- package/dist/shared/skill-authoring-document.d.ts +28 -0
- package/dist/shared/skill-authoring-document.js +187 -0
- package/dist/shared/skill-authoring-document.js.map +1 -0
- package/dist/studio/routes/index.js +1 -1
- package/dist/studio/routes/index.js.map +1 -1
- package/dist/utils/semver.d.ts +1 -0
- package/dist/utils/semver.js +18 -0
- package/dist/utils/semver.js.map +1 -1
- package/dist/utils/skill-builder-detection.js +4 -9
- package/dist/utils/skill-builder-detection.js.map +1 -1
- package/package.json +5 -4
- package/dist/eval-ui/assets/CreateSkillPage-e3YH0sBH.js +0 -13
- package/dist/eval-ui/assets/SkillDetailPanel-B7f3UPBT.js +0 -1
- package/dist/eval-ui/assets/core-DZjBCfjp.js +0 -1
- package/dist/eval-ui/assets/main-C30fpcFP.js +0 -86
- package/dist/eval-ui/assets/source-serif-4-cyrillic-ext-wght-normal-cHuGMAiY.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-cyrillic-wght-normal-DwHjdM4S.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-greek-wght-normal-ece1310W.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-ext-wght-normal-CxNHBx-q.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-wght-normal-D9elroTD.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-vietnamese-wght-normal-D-yuW59g.woff2 +0 -0
- /package/dist/eval-ui/assets/{lifecycle-n00yue6r.js → lifecycle-DC0khFSd.js} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bje294df.js","assets/core-DgHXlyD_.js","assets/UpdateDropdown-VRCYPtXG.js","assets/globals-DmzftdEG.js","assets/globals-BWCNQsMa.css","assets/useDesktopBridge-C8dT34x9.js","assets/fonts-BZeyWEAn.css","assets/index-D0lWXViJ.js","assets/FindSkillsPalette-B5-3ZLEo.js","assets/SkillDetailPanel-B5LYvcry.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-CwreCn22.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as c,a as ap,g as ip,j as t,R as me,c as lp}from"./globals-DmzftdEG.js";import{h as cp,o as hn,_ as ar,u as jn,n as Ga,l as Pn}from"./useDesktopBridge-C8dT34x9.js";/* empty css *//**
|
|
3
|
+
* react-router v7.18.4
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Remix Software Inc.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
* @license MIT
|
|
11
|
+
*/var da=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Zl=/^[\\/]{2}/;function dp(e,r){return r+e.replace(/\\/g,"/")}var Ka="popstate";function qa(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function up(e={}){function r(o,a){let{pathname:i="/",search:l="",hash:d=""}=Or(o.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),zo("",{pathname:i,search:l,hash:d},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(o,a){let i=o.document.querySelector("base"),l="";if(i&&i.getAttribute("href")){let d=o.location.href,u=d.indexOf("#");l=u===-1?d:d.slice(0,u)}return l+"#"+(typeof a=="string"?a:Dr(a))}function s(o,a){Ft(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(a)})`)}return fp(r,n,s,e)}function ot(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Ft(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function pp(){return Math.random().toString(36).substring(2,10)}function Ya(e,r){return{usr:e.state,key:e.key,idx:r,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function zo(e,r,n=null,s,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof r=="string"?Or(r):r,state:n,key:r&&r.key||s||pp(),mask:o}}function Dr({pathname:e="/",search:r="",hash:n=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Or(e){let r={};if(e){let n=e.indexOf("#");n>=0&&(r.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(r.search=e.substring(s),e=e.substring(0,s)),e&&(r.pathname=e)}return r}function fp(e,r,n,s={}){let{window:o=document.defaultView,v5Compat:a=!1}=s,i=o.history,l="POP",d=null,u=p();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function p(){return(i.state||{idx:null}).idx}function f(){l="POP";let x=p(),b=x==null?null:x-u;u=x,d&&d({action:l,location:v.location,delta:b})}function h(x,b){l="PUSH";let y=qa(x)?x:zo(v.location,x,b);n&&n(y,x),u=p()+1;let j=Ya(y,u),S=v.createHref(y.mask||y);try{i.pushState(j,"",S)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;o.location.assign(S)}a&&d&&d({action:l,location:v.location,delta:1})}function m(x,b){l="REPLACE";let y=qa(x)?x:zo(v.location,x,b);n&&n(y,x),u=p();let j=Ya(y,u),S=v.createHref(y.mask||y);i.replaceState(j,"",S),a&&d&&d({action:l,location:v.location,delta:0})}function g(x){return hp(o,x)}let v={get action(){return l},get location(){return e(o,i)},listen(x){if(d)throw new Error("A history only accepts one active listener");return o.addEventListener(Ka,f),d=x,()=>{o.removeEventListener(Ka,f),d=null}},createHref(x){return r(o,x)},createURL:g,encodeLocation(x){let b=g(x);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:h,replace:m,go(x){return i.go(x)}};return v}function hp(e,r,n=!1){let s="http://localhost";e&&(s=e.location.origin!=="null"?e.location.origin:e.location.href),ot(s,"No window.location.(origin|href) available to create URL");let o=typeof r=="string"?r:Dr(r);return o=o.replace(/ $/,"%20"),!n&&Zl.test(o)&&(o=s+o),new URL(o,s)}function ec(e,r,n="/"){return mp(e,r,n,!1)}function mp(e,r,n,s,o){let a=typeof r=="string"?Or(r):r,i=Qt(a.pathname||"/",n);if(i==null)return null;let l=xp(e),d=null,u=Np(i);for(let p=0;d==null&&p<l.length;++p)d=Ep(l[p],u,s);return d}function xp(e){let r=tc(e);return gp(r),r}function tc(e,r=[],n=[],s="",o=!1){let a=(i,l,d=o,u)=>{let p={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(s)&&d)return;ot(p.relativePath.startsWith(s),`Absolute route path "${p.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(s.length)}let f=$t([s,p.relativePath]),h=n.concat(p);i.children&&i.children.length>0&&(ot(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),tc(i.children,r,h,f,d)),!(i.path==null&&!i.index)&&r.push({path:f,score:Sp(f,i.index),routesMeta:h.map((m,g)=>{let[v,x]=sc(m.relativePath,m.caseSensitive,g===h.length-1);return{...m,matcher:v,compiledParams:x}})})};return e.forEach((i,l)=>{var d;if(i.path===""||!((d=i.path)!=null&&d.includes("?")))a(i,l);else for(let u of rc(i.path))a(i,l,!0,u)}),r}function rc(e){let r=e.split("/");if(r.length===0)return[];let[n,...s]=r,o=n.endsWith("?"),a=n.replace(/\?$/,"");if(s.length===0)return o?[a,""]:[a];let i=rc(s.join("/")),l=[];return l.push(...i.map(d=>d===""?a:[a,d].join("/"))),o&&l.push(...i),l.map(d=>e.startsWith("/")&&d===""?"/":d)}function gp(e){e.sort((r,n)=>r.score!==n.score?n.score-r.score:Cp(r.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var vp=/^:[\w-]+$/,yp=3,bp=2,kp=1,jp=10,wp=-2,Ja=e=>e==="*";function Sp(e,r){let n=e.split("/"),s=n.length;return n.some(Ja)&&(s+=wp),r&&(s+=bp),n.filter(o=>!Ja(o)).reduce((o,a)=>o+(vp.test(a)?yp:a===""?kp:jp),s)}function Cp(e,r){return e.length===r.length&&e.slice(0,-1).every((s,o)=>s===r[o])?e[e.length-1]-r[r.length-1]:0}function Ep(e,r,n=!1){let{routesMeta:s}=e,o={},a="/",i=[];for(let l=0;l<s.length;++l){let d=s[l],u=l===s.length-1,p=a==="/"?r:r.slice(a.length)||"/",f={path:d.relativePath,caseSensitive:d.caseSensitive,end:u},h=d.matcher&&d.compiledParams?nc(f,p,d.matcher,d.compiledParams):ss(f,p),m=d.route;if(!h&&u&&n&&!s[s.length-1].route.index&&(h=ss({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},p)),!h)return null;Object.assign(o,h.params),i.push({params:o,pathname:$t([a,h.pathname]),pathnameBase:Ip($t([a,h.pathnameBase])),route:m}),h.pathnameBase!=="/"&&(a=$t([a,h.pathnameBase]))}return i}function ss(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,s]=sc(e.path,e.caseSensitive,e.end);return nc(e,r,n,s)}function nc(e,r,n,s){let o=r.match(n);if(!o)return null;let a=o[0],i=zr(a,1),l=o.slice(1);return{params:s.reduce((u,{paramName:p,isOptional:f},h)=>{if(p==="*"){let g=l[h]||"";i=zr(a.slice(0,a.length-g.length),1)}const m=l[h];return f&&!m?u[p]=void 0:u[p]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:i,pattern:e}}function sc(e,r=!1,n=!0){Ft(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let s=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,d,u,p)=>{if(s.push({paramName:l,isOptional:d!=null}),d){let f=p.charAt(u+i.length);return f&&f!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(s.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,r?void 0:"i"),s]}function Np(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Ft(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),e}}function Qt(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let n=r.endsWith("/")?r.length-1:r.length,s=e.charAt(n);return s&&s!=="/"?null:e.slice(n)||"/"}function Rp(e,r="/"){let{pathname:n,search:s="",hash:o=""}=typeof e=="string"?Or(e):e,a;return n?(n=ac(n),n.startsWith("/")||n.startsWith("\\")?a=Qa(n.substring(1),"/"):a=Qa(n,r)):a=r,{pathname:a,search:Lp(s),hash:Ap(o)}}function Qa(e,r){let n=zr(r).split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Ps(e,r,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Tp(e){return e.filter((r,n)=>n===0||r.route.path&&r.route.path.length>0)}function oc(e){let r=Tp(e);return r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase)}function ua(e,r,n,s=!1){let o;typeof e=="string"?o=Or(e):(o={...e},ot(!o.pathname||!o.pathname.includes("?"),Ps("?","pathname","search",o)),ot(!o.pathname||!o.pathname.includes("#"),Ps("#","pathname","hash",o)),ot(!o.search||!o.search.includes("#"),Ps("#","search","hash",o)));let a=e===""||o.pathname==="",i=a?"/":o.pathname,l;if(i==null)l=n;else{let f=r.length-1;if(!s&&i.startsWith("..")){let h=i.split("/");for(;h[0]==="..";)h.shift(),f-=1;o.pathname=h.join("/")}l=f>=0?r[f]:"/"}let d=Rp(o,l),u=i&&i!=="/"&&i.endsWith("/"),p=(a||i===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}var ac=e=>e.replace(/[\\/]{2,}/g,"/"),$t=e=>ac(e.join("/"));function zr(e,r=0){let n=e.length;for(;n>r&&e.charCodeAt(n-1)===47;)n--;return n===e.length?e:e.slice(0,n)}var Ip=e=>zr(e).replace(/^\/*/,"/"),Lp=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ap=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Pp=class{constructor(e,r,n,s=!1){this.status=e,this.statusText=r||"",this.internal=s,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function $p(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Mp(e){let r=e.map(n=>n.route.path).filter(Boolean);return $t(r)||"/"}var ic=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function lc(e,r){let n=e;if(typeof n!="string"||!da.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,o=!1;if(ic)try{let a=new URL(window.location.href),i=Zl.test(n)?new URL(dp(n,a.protocol)):new URL(n),l=Qt(i.pathname,r);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:o=!0}catch{Ft(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Xa=new URL("http://localhost");function cc(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),Xa)}catch{return Xa}}function $s(e,r){return e.origin===r.origin&&(e.origin!=="null"||e.protocol===r.protocol&&e.host===r.host)}function Fp(e,r){if(e.startsWith("//"))return!0;let n=r.protocol.toLowerCase();return e.toLowerCase().startsWith(n)?r.host===""||e.slice(n.length).startsWith("//"):!1}function dc(e,r,n,s){let o=null;try{o=e==null?null:new URL(e,n)}catch{}let a=new URL(r,n),i=o!=null&&!$s(o,n),l=!$s(a,n);if(s==="reject"){if(i||l)throw new Error("External navigation is not allowed")}else if(l&&(o==null||!Fp(e,o)||!$s(o,a)))throw new Error("External navigation is not allowed")}var uc=["POST","PUT","PATCH","DELETE"];new Set(uc);var Dp=["GET",...uc];new Set(Dp);var zp=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Bp(e){try{return zp.includes(new URL(e).protocol)}catch{return!1}}var Wr=c.createContext(null);Wr.displayName="DataRouter";var fs=c.createContext(null);fs.displayName="DataRouterState";var pc=c.createContext(!1);function _p(){return c.useContext(pc)}var fc=c.createContext({isTransitioning:!1});fc.displayName="ViewTransition";var Op=c.createContext(new Map);Op.displayName="Fetchers";var Wp=c.createContext(null);Wp.displayName="Await";var At=c.createContext(null);At.displayName="Navigation";var hs=c.createContext(null);hs.displayName="Location";var Xt=c.createContext({outlet:null,matches:[],isDataRoute:!1});Xt.displayName="Route";var pa=c.createContext(null);pa.displayName="RouteError";var hc="REACT_ROUTER_ERROR",Up="REDIRECT",Hp="ROUTE_ERROR_RESPONSE";function Vp(e){if(e.startsWith(`${hc}:${Up}:{`))try{let r=JSON.parse(e.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function Gp(e){if(e.startsWith(`${hc}:${Hp}:{`))try{let r=JSON.parse(e.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new Pp(r.status,r.statusText,r.data)}catch{}}function Kp(e,{relative:r}={}){ot(wn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:s}=c.useContext(At),{hash:o,pathname:a,search:i}=Sn(e,{relative:r}),l=a;return n!=="/"&&(l=a==="/"?n:$t([n,a])),s.createHref({pathname:l,search:i,hash:o})}function wn(){return c.useContext(hs)!=null}function Zt(){return ot(wn(),"useLocation() may be used only in the context of a <Router> component."),c.useContext(hs).location}var mc="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function xc(e){c.useContext(At).static||c.useLayoutEffect(e)}function qp(){let{isDataRoute:e}=c.useContext(Xt);return e?lf():Yp()}function Yp(){ot(wn(),"useNavigate() may be used only in the context of a <Router> component.");let e=c.useContext(Wr),{basename:r,navigator:n}=c.useContext(At),{matches:s}=c.useContext(Xt),{pathname:o}=Zt(),a=JSON.stringify(oc(s)),i=c.useRef(!1);return xc(()=>{i.current=!0}),c.useCallback((d,u={})=>{if(Ft(i.current,mc),!i.current)return;if(typeof d=="number"){n.go(d);return}let p=ua(d,JSON.parse(a),o,u.relative==="path");e==null&&r!=="/"&&(p.pathname=p.pathname==="/"?r:$t([r,p.pathname])),dc(typeof d=="string"?d:Dr(d),n.createHref(p),cc(n),"reject"),(u.replace?n.replace:n.push)(p,u.state,u)},[r,n,a,o,e])}c.createContext(null);function Sn(e,{relative:r}={}){let{matches:n}=c.useContext(Xt),{pathname:s}=Zt(),o=JSON.stringify(oc(n));return c.useMemo(()=>ua(e,JSON.parse(o),s,r==="path"),[e,o,s,r])}function Jp(e,r,n){ot(wn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=c.useContext(At),{matches:o}=c.useContext(Xt),a=o[o.length-1],i=a?a.params:{},l=a?a.pathname:"/",d=a?a.pathnameBase:"/",u=a&&a.route;{let x=u&&u.path||"";vc(l,!u||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${x}">) 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.
|
|
12
|
+
|
|
13
|
+
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let p=Zt(),f;f=p;let h=f.pathname||"/",m=h;if(d!=="/"){let x=d.replace(/^\//,"").split("/");m="/"+h.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(x=>Object.assign(x,{route:n.manifest[x.route.id]||x.route})):ec(e,{pathname:m});return Ft(u||g!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Ft(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.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.`),tf(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:$t([d,s.encodeLocation?s.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?d:$t([d,s.encodeLocation?s.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),o,n)}function Qp(){let e=af(),r=$p(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:s},a={padding:"2px 4px",backgroundColor:s},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=c.createElement(c.Fragment,null,c.createElement("p",null,"💿 Hey developer 👋"),c.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",c.createElement("code",{style:a},"ErrorBoundary")," or"," ",c.createElement("code",{style:a},"errorElement")," prop on your route.")),c.createElement(c.Fragment,null,c.createElement("h2",null,"Unexpected Application Error!"),c.createElement("h3",{style:{fontStyle:"italic"}},r),n?c.createElement("pre",{style:o},n):null,i)}var Xp=c.createElement(Qp,null),gc=class extends c.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Gp(e.digest);n&&(e=n)}let r=e!==void 0?c.createElement(Xt.Provider,{value:this.props.routeContext},c.createElement(pa.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?c.createElement(Zp,{error:e},r):r}};gc.contextType=pc;var Ms=new WeakMap;function Zp({children:e,error:r}){let{basename:n,navigator:s}=c.useContext(At);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let o=Vp(r.digest);if(o){let a=Ms.get(r);if(a)throw a;let i=lc(o.location,n),l=i.absoluteURL||i.to;if(dc(o.location,l,cc(s),"allow-explicit"),Bp(l))throw new Error("Invalid redirect location");if(ic&&!Ms.get(r))if(i.isExternal||o.reloadDocument)window.location.href=l;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:o.replace}));throw Ms.set(r,d),d}return c.createElement("meta",{httpEquiv:"refresh",content:`0;url=${l}`})}}return e}function ef({routeContext:e,match:r,children:n}){let s=c.useContext(Wr);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),c.createElement(Xt.Provider,{value:e},n)}function tf(e,r=[],n){let s=n==null?void 0:n.state;if(e==null){if(!s)return null;if(s.errors)e=s.matches;else if(r.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let o=e,a=s==null?void 0:s.errors;if(a!=null){let p=o.findIndex(f=>f.route.id&&(a==null?void 0:a[f.route.id])!==void 0);ot(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),o=o.slice(0,Math.min(o.length,p+1))}let i=!1,l=-1;if(n&&s){i=s.renderFallback;for(let p=0;p<o.length;p++){let f=o[p];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=p),f.route.id){let{loaderData:h,errors:m}=s,g=f.route.loader&&!h.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||g){n.isStatic&&(i=!0),l>=0?o=o.slice(0,l+1):o=[o[0]];break}}}}let d=n==null?void 0:n.onError,u=s&&d?(p,f)=>{var h,m;d(p,{location:s.location,params:((m=(h=s.matches)==null?void 0:h[0])==null?void 0:m.params)??{},pattern:Mp(s.matches),errorInfo:f})}:void 0;return o.reduceRight((p,f,h)=>{let m,g=!1,v=null,x=null;s&&(m=a&&f.route.id?a[f.route.id]:void 0,v=f.route.errorElement||Xp,i&&(l<0&&h===0?(vc("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):l===h&&(g=!0,x=f.route.hydrateFallbackElement||null)));let b=r.concat(o.slice(0,h+1)),y=()=>{let j;return m?j=v:g?j=x:f.route.Component?j=c.createElement(f.route.Component,null):f.route.element?j=f.route.element:j=p,c.createElement(ef,{match:f,routeContext:{outlet:p,matches:b,isDataRoute:s!=null},children:j})};return s&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?c.createElement(gc,{location:s.location,revalidation:s.revalidation,component:v,error:m,children:y(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):y()},null)}function fa(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rf(e){let r=c.useContext(Wr);return ot(r,fa(e)),r}function nf(e){let r=c.useContext(fs);return ot(r,fa(e)),r}function sf(e){let r=c.useContext(Xt);return ot(r,fa(e)),r}function ha(e){let r=sf(e),n=r.matches[r.matches.length-1];return ot(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function of(){return ha("useRouteId")}function af(){var s;let e=c.useContext(pa),r=nf("useRouteError"),n=ha("useRouteError");return e!==void 0?e:(s=r.errors)==null?void 0:s[n]}function lf(){let{router:e}=rf("useNavigate"),r=ha("useNavigate"),n=c.useRef(!1);return xc(()=>{n.current=!0}),c.useCallback(async(o,a={})=>{Ft(n.current,mc),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:r,...a}))},[e,r])}var Za={};function vc(e,r,n){!r&&!Za[e]&&(Za[e]=!0,Ft(!1,n))}c.memo(cf);function cf({routes:e,manifest:r,future:n,state:s,isStatic:o,onError:a}){return Jp(e,void 0,{manifest:r,state:s,isStatic:o,onError:a})}function df({basename:e="/",children:r=null,location:n,navigationType:s="POP",navigator:o,static:a=!1,useTransitions:i}){ot(!wn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),d=c.useMemo(()=>({basename:l,navigator:o,static:a,useTransitions:i,future:{}}),[l,o,a,i]);typeof n=="string"&&(n=Or(n));let{pathname:u="/",search:p="",hash:f="",state:h=null,key:m="default",mask:g}=n,v=c.useMemo(()=>{let x=Qt(u,l);return x==null?null:{location:{pathname:x,search:p,hash:f,state:h,key:m,mask:g},navigationType:s}},[l,u,p,f,h,m,s,g]);return Ft(v!=null,`<Router basename="${l}"> is not able to match the URL "${u}${p}${f}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:c.createElement(At.Provider,{value:d},c.createElement(hs.Provider,{children:r,value:v}))}var Yn="get",Jn="application/x-www-form-urlencoded";function ms(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function uf(e){return ms(e)&&e.tagName.toLowerCase()==="button"}function pf(e){return ms(e)&&e.tagName.toLowerCase()==="form"}function ff(e){return ms(e)&&e.tagName.toLowerCase()==="input"}function hf(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function mf(e,r){return e.button===0&&(!r||r==="_self")&&!hf(e)}var $n=null;function xf(){if($n===null)try{new FormData(document.createElement("form"),0),$n=!1}catch{$n=!0}return $n}var gf=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fs(e){return e!=null&&!gf.has(e)?(Ft(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Jn}"`),null):e}function vf(e,r){let n,s,o,a,i;if(pf(e)){let l=e.getAttribute("action");s=l?Qt(l,r):null,n=e.getAttribute("method")||Yn,o=Fs(e.getAttribute("enctype"))||Jn,a=new FormData(e)}else if(uf(e)||ff(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||l.getAttribute("action");if(s=d?Qt(d,r):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Yn,o=Fs(e.getAttribute("formenctype"))||Fs(l.getAttribute("enctype"))||Jn,a=new FormData(l,e),!xf()){let{name:u,type:p,value:f}=e;if(p==="image"){let h=u?`${u}.`:"";a.append(`${h}x`,"0"),a.append(`${h}y`,"0")}else u&&a.append(u,f)}}else{if(ms(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Yn,s=null,o=Jn,i=e}return a&&o==="text/plain"&&(i=a,a=void 0),{action:s,method:n.toLowerCase(),encType:o,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ma(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function yc(e,r,n,s){let o=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${s}`:o.pathname=`${o.pathname}.${s}`:o.pathname==="/"?o.pathname=`_root.${s}`:r&&Qt(o.pathname,r)==="/"?o.pathname=`${zr(r)}/_root.${s}`:o.pathname=`${zr(o.pathname)}.${s}`,o}async function yf(e,r){if(e.id in r)return r[e.id];try{let n=await import(e.module);return r[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function bf(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function kf(e,r,n){let s=await Promise.all(e.map(async o=>{let a=r.routes[o.route.id];if(a){let i=await yf(a,n);return i.links?i.links():[]}return[]}));return Cf(s.flat(1).filter(bf).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function ei(e,r,n,s,o,a){let i=(d,u)=>n[u]?d.route.id!==n[u].route.id:!0,l=(d,u)=>{var p;return n[u].pathname!==d.pathname||((p=n[u].route.path)==null?void 0:p.endsWith("*"))&&n[u].params["*"]!==d.params["*"]};return a==="assets"?r.filter((d,u)=>i(d,u)||l(d,u)):a==="data"?r.filter((d,u)=>{var f;let p=s.routes[d.route.id];if(!p||!p.hasLoader)return!1;if(i(d,u)||l(d,u))return!0;if(d.route.shouldRevalidate){let h=d.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:((f=n[0])==null?void 0:f.params)||{},nextUrl:new URL(e,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function jf(e,r,{includeHydrateFallback:n}={}){return wf(e.map(s=>{let o=r.routes[s.route.id];if(!o)return[];let a=[o.module];return o.clientActionModule&&(a=a.concat(o.clientActionModule)),o.clientLoaderModule&&(a=a.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(a=a.concat(o.hydrateFallbackModule)),o.imports&&(a=a.concat(o.imports)),a}).flat(1))}function wf(e){return[...new Set(e)]}function Sf(e){let r={},n=Object.keys(e).sort();for(let s of n)r[s]=e[s];return r}function Cf(e,r){let n=new Set;return new Set(r),e.reduce((s,o)=>{let a=JSON.stringify(Sf(o));return n.has(a)||(n.add(a),s.push({key:a,link:o})),s},[])}function xa(){let e=c.useContext(Wr);return ma(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Ef(){let e=c.useContext(fs);return ma(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ga=c.createContext(void 0);ga.displayName="FrameworkContext";function xs(){let e=c.useContext(ga);return ma(e,"You must render this element inside a <HydratedRouter> element"),e}function Nf(e,r){let n=c.useContext(ga),[s,o]=c.useState(!1),[a,i]=c.useState(!1),{onFocus:l,onBlur:d,onMouseEnter:u,onMouseLeave:p,onTouchStart:f}=r,h=c.useRef(null);c.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let v=b=>{b.forEach(y=>{i(y.isIntersecting)})},x=new IntersectionObserver(v,{threshold:.5});return h.current&&x.observe(h.current),()=>{x.disconnect()}}},[e]),c.useEffect(()=>{if(s){let v=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(v)}}},[s]);let m=()=>{o(!0)},g=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,h,{}]:[a,h,{onFocus:Yr(l,m),onBlur:Yr(d,g),onMouseEnter:Yr(u,m),onMouseLeave:Yr(p,g),onTouchStart:Yr(f,m)}]:[!1,h,{}]}function Yr(e,r){return n=>{e&&e(n),n.defaultPrevented||r(n)}}function Rf({page:e,...r}){let n=_p(),{nonce:s}=xs(),{router:o}=xa(),a=c.useMemo(()=>ec(o.routes,e,o.basename),[o.routes,e,o.basename]);return a?(r.nonce==null&&s&&(r={...r,nonce:s}),n?c.createElement(If,{page:e,matches:a,...r}):c.createElement(Lf,{page:e,matches:a,...r})):null}function Tf(e){let{manifest:r,routeModules:n}=xs(),[s,o]=c.useState([]);return c.useEffect(()=>{let a=!1;return kf(e,r,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,r,n]),s}function If({page:e,matches:r,...n}){let s=Zt(),{future:o}=xs(),{basename:a}=xa(),i=c.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let l=yc(e,a,o.v8_trailingSlashAwareDataRequests,"rsc"),d=!1,u=[];for(let p of r)typeof p.route.shouldRevalidate=="function"?d=!0:u.push(p.route.id);return d&&u.length>0&&l.searchParams.set("_routes",u.join(",")),[l.pathname+l.search]},[a,o.v8_trailingSlashAwareDataRequests,e,s,r]);return c.createElement(c.Fragment,null,i.map(l=>c.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function Lf({page:e,matches:r,...n}){let s=Zt(),{future:o,manifest:a,routeModules:i}=xs(),{basename:l}=xa(),{loaderData:d,matches:u}=Ef(),p=c.useMemo(()=>ei(e,r,u,a,s,"data"),[e,r,u,a,s]),f=c.useMemo(()=>ei(e,r,u,a,s,"assets"),[e,r,u,a,s]),h=c.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let v=new Set,x=!1;if(r.forEach(y=>{var S;let j=a.routes[y.route.id];!j||!j.hasLoader||(!p.some(k=>k.route.id===y.route.id)&&y.route.id in d&&((S=i[y.route.id])!=null&&S.shouldRevalidate)||j.hasClientLoader?x=!0:v.add(y.route.id))}),v.size===0)return[];let b=yc(e,l,o.v8_trailingSlashAwareDataRequests,"data");return x&&v.size>0&&b.searchParams.set("_routes",r.filter(y=>v.has(y.route.id)).map(y=>y.route.id).join(",")),[b.pathname+b.search]},[l,o.v8_trailingSlashAwareDataRequests,d,s,a,p,r,e,i]),m=c.useMemo(()=>jf(f,a),[f,a]),g=Tf(f);return c.createElement(c.Fragment,null,h.map(v=>c.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),m.map(v=>c.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),g.map(({key:v,link:x})=>c.createElement("link",{key:v,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function Af(...e){return r=>{e.forEach(n=>{typeof n=="function"?n(r):n!=null&&(n.current=r)})}}var Pf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Pf&&(window.__reactRouterVersion="7.18.4")}catch{}function $f({basename:e,children:r,useTransitions:n,window:s}){let o=c.useRef();o.current==null&&(o.current=up({window:s,v5Compat:!0}));let a=o.current,[i,l]=c.useState({action:a.action,location:a.location}),d=c.useCallback(u=>{n===!1?l(u):c.startTransition(()=>l(u))},[n]);return c.useLayoutEffect(()=>a.listen(d),[a,d]),c.createElement(df,{basename:e,children:r,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var bc=c.forwardRef(function({onClick:r,discover:n="render",prefetch:s="none",relative:o,reloadDocument:a,replace:i,mask:l,state:d,target:u,to:p,preventScrollReset:f,viewTransition:h,defaultShouldRevalidate:m,...g},v){let{basename:x,navigator:b,useTransitions:y}=c.useContext(At),j=typeof p=="string"&&da.test(p),S=lc(p,x);p=S.to;let k=Kp(p,{relative:o}),R=Zt(),w=null;if(l){let C=ua(l,[],R.mask?R.mask.pathname:"/",!0);x!=="/"&&(C.pathname=C.pathname==="/"?x:$t([x,C.pathname])),w=b.createHref(C)}let[E,N,T]=Nf(s,g),I=zf(p,{replace:i,mask:l,state:d,target:u,preventScrollReset:f,relative:o,viewTransition:h,defaultShouldRevalidate:m,useTransitions:y});function A(C){r&&r(C),C.defaultPrevented||I(C)}let $=!(S.isExternal||a),W=c.createElement("a",{...g,...T,href:($?w:void 0)||S.absoluteURL||k,onClick:$?A:r,ref:Af(v,N),target:u,"data-discover":!j&&n==="render"?"true":void 0});return E&&!j?c.createElement(c.Fragment,null,W,c.createElement(Rf,{page:k})):W});bc.displayName="Link";var Mf=c.forwardRef(function({"aria-current":r="page",caseSensitive:n=!1,className:s="",end:o=!1,style:a,to:i,viewTransition:l,children:d,...u},p){let f=Sn(i,{relative:u.relative}),h=Zt(),m=c.useContext(fs),{navigator:g,basename:v}=c.useContext(At),x=m!=null&&Uf(f)&&l===!0,b=g.encodeLocation?g.encodeLocation(f).pathname:f.pathname,y=h.pathname,j=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(y=y.toLowerCase(),j=j?j.toLowerCase():null,b=b.toLowerCase()),j&&v&&(j=Qt(j,v)||j);const S=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let k=y===b||!o&&y.startsWith(b)&&y.charAt(S)==="/",R=j!=null&&(j===b||!o&&j.startsWith(b)&&j.charAt(b.length)==="/"),w={isActive:k,isPending:R,isTransitioning:x},E=k?r:void 0,N;typeof s=="function"?N=s(w):N=[s,k?"active":null,R?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let T=typeof a=="function"?a(w):a;return c.createElement(bc,{...u,"aria-current":E,className:N,ref:p,style:T,to:i,viewTransition:l},typeof d=="function"?d(w):d)});Mf.displayName="NavLink";var Ff=c.forwardRef(({discover:e="render",fetcherKey:r,navigate:n,reloadDocument:s,replace:o,state:a,method:i=Yn,action:l,onSubmit:d,relative:u,preventScrollReset:p,viewTransition:f,defaultShouldRevalidate:h,...m},g)=>{let{useTransitions:v}=c.useContext(At),x=Of(),b=Wf(l,{relative:u}),y=i.toLowerCase()==="get"?"get":"post",j=typeof l=="string"&&da.test(l),S=k=>{if(d&&d(k),k.defaultPrevented)return;k.preventDefault();let R=k.nativeEvent.submitter,w=(R==null?void 0:R.getAttribute("formmethod"))||i,E=()=>x(R||k.currentTarget,{fetcherKey:r,method:w,navigate:n,replace:o,state:a,relative:u,preventScrollReset:p,viewTransition:f,defaultShouldRevalidate:h});v&&n!==!1?c.startTransition(()=>E()):E()};return c.createElement("form",{ref:g,method:y,action:b,onSubmit:s?d:S,...m,"data-discover":!j&&e==="render"?"true":void 0})});Ff.displayName="Form";function Df(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kc(e){let r=c.useContext(Wr);return ot(r,Df(e)),r}function zf(e,{target:r,replace:n,mask:s,state:o,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:d,useTransitions:u}={}){let p=qp(),f=Zt(),h=Sn(e,{relative:i});return c.useCallback(m=>{if(mf(m,r)){m.preventDefault();let g=n!==void 0?n:Dr(f)===Dr(h),v=()=>p(e,{replace:g,mask:s,state:o,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:d});u?c.startTransition(()=>v()):v()}},[f,p,h,n,s,o,r,e,a,i,l,d,u])}var Bf=0,_f=()=>`__${String(++Bf)}__`;function Of(){let{router:e}=kc("useSubmit"),{basename:r}=c.useContext(At),n=of(),s=e.fetch,o=e.navigate;return c.useCallback(async(a,i={})=>{let{action:l,method:d,encType:u,formData:p,body:f}=vf(a,r);if(i.navigate===!1){let h=i.fetcherKey||_f();await s(h,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,formMethod:i.method||d,formEncType:i.encType||u,flushSync:i.flushSync})}else await o(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,formMethod:i.method||d,formEncType:i.encType||u,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[s,o,r,n])}function Wf(e,{relative:r}={}){let{basename:n}=c.useContext(At),s=c.useContext(Xt);ot(s,"useFormAction must be used inside a RouteContext");let[o]=s.matches.slice(-1),a={...Sn(e||".",{relative:r})},i=Zt();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),d=l.getAll("index");if(d.some(p=>p==="")){l.delete("index"),d.filter(f=>f).forEach(f=>l.append("index",f));let p=l.toString();a.search=p?`?${p}`:""}}return(!e||e===".")&&o.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:$t([n,a.pathname])),Dr(a)}function Uf(e,{relative:r}={}){let n=c.useContext(fc);ot(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=kc("useViewTransitionState"),o=Sn(e,{relative:r});if(!n.isTransitioning)return!1;let a=Qt(n.currentLocation.pathname,s)||n.currentLocation.pathname,i=Qt(n.nextLocation.pathname,s)||n.nextLocation.pathname;return ss(o.pathname,i)!=null||ss(o.pathname,a)!=null}var Ur=ap();const Hf=ip(Ur),Vf=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Mn(e){if(typeof e!="string")return null;const r=e.trim();return r===""||!Vf.test(r)||r==="0.0.0"?null:r}function jc(e){if(e.preferInstalled){const o=Mn(e.installedCurrentVersion);if(o)return{version:o,versionSource:"registry"}}const r=Mn(e.frontmatterVersion);if(r)return{version:r,versionSource:"frontmatter"};const n=Mn(e.registryCurrentVersion);if(n)return{version:n,versionSource:"registry"};const s=Mn(e.pluginVersion);return s?{version:s,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const pr="";async function ti(e,r){const n=await fetch(e,r);return n.status>=502&&n.status<=504?(await new Promise(s=>setTimeout(s,250)),fetch(e,r)):n}const ri=100;function ni(e,r){if(e.length===0||r<=0)return[];const n=[];for(let s=0;s<e.length;s+=r)n.push(e.slice(s,s+r));return n}function Gf(e){return{async getSkillVersions(r,n){const s=await e(`/api/skills/${r}/${n}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(r,n){return e(`/api/skills/${r}/${n}/versions`)},getVersionDiff(r,n,s,o){return e(`/api/skills/${r}/${n}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(r){const n=`${pr}/api/skills/batch-update`,s=new EventSource(n);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:r})}),s},startSkillUpdate(r,n){const s=`${pr}/api/skills/${r}/${n}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(r,n,s){let o,a;if(s&&typeof s.aborted=="boolean")o=s;else if(s&&typeof s=="object"){const f=s;o=f.signal,a=f.agentId}const i=a?`?agent=${encodeURIComponent(a)}`:"",l=`${pr}/api/skills/${r}/${n}/update${i}`,d=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},signal:o});let u,p="";if(d.body){const f=d.body.getReader(),h=new TextDecoder;let m=!1,g="";for(;!m;){const x=await f.read();if(m=x.done,x.value){const b=h.decode(x.value,{stream:!m});g+=b,p.length<200&&(p+=b)}}const v=g.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(v)try{u=JSON.parse(v[1]).version}catch{}p=p.slice(0,200)}else{const f=await d.text();p=f.slice(0,200);const h=f.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(h)try{u=JSON.parse(h[1]).version}catch{}}return{ok:d.ok,status:d.status,body:p,version:u}},async rescanSkill(r,n){const s=`${r}/${n}`,o=await fetch(`${pr}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const r=await fetch(`${pr}/api/skills/updates`);return r.ok?await r.json():[]}catch{return[]}},async checkSkillUpdates(r){if(r.length===0)return[];const n=[...r].sort(),s=ni(n,ri),o=async i=>{try{const l=await ti(`${pr}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:i.map(u=>({name:u,currentVersion:"0.0.0"}))})});if(!l.ok)return[];const d=await l.json().catch(()=>null);return Array.isArray(d)?d:d&&typeof d=="object"&&Array.isArray(d.results)?d.results.map(u=>({skillId:typeof u.skillId=="string"?u.skillId:typeof u.name=="string"?u.name:"",version:typeof u.version=="string"?u.version:typeof u.latest=="string"?u.latest:"",eventId:typeof u.eventId=="string"?u.eventId:"",publishedAt:typeof u.publishedAt=="string"?u.publishedAt:"",diffSummary:typeof u.diffSummary=="string"?u.diffSummary:void 0,trackedForUpdates:typeof u.trackedForUpdates=="boolean"?u.trackedForUpdates:void 0,updateAvailable:typeof u.updateAvailable=="boolean"?u.updateAvailable:void 0,installed:typeof u.installed=="string"&&u.installed!=="0.0.0"?u.installed:void 0,latest:typeof u.latest=="string"?u.latest:void 0,name:typeof u.name=="string"?u.name:void 0})):[]}catch{return[]}};return(await Promise.all(s.map(o))).flat()},async resolveInstalledSkillIds(r){if(r.length===0)return[];const n=ni(r,ri),s=async i=>{try{const l=await ti(`${pr}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:i.map(p=>({name:p.name,currentVersion:p.currentVersion??"0.0.0"}))})});if(!l.ok)return{ok:!1,map:new Map};const d=await l.json().catch(()=>null),u=Array.isArray(d)?d:Array.isArray(d==null?void 0:d.results)?d.results:[];return{ok:!0,map:new Map(u.filter(p=>typeof p.name=="string"&&p.name.length>0).map(p=>[p.name,p]))}}catch{return{ok:!1,map:new Map}}},o=await Promise.all(n.map(s));if(o.length>0&&o.every(i=>!i.ok))throw new Error("resolveInstalledSkillIds: all chunks failed");const a=new Map;for(const i of o)for(const[l,d]of i.map)a.set(l,d);return r.map(i=>{const l=a.get(i.name);return{plugin:i.plugin,skill:i.skill,uuid:typeof(l==null?void 0:l.id)=="string"&&l.id.length>0?l.id:void 0,slug:typeof(l==null?void 0:l.slug)=="string"&&l.slug.length>0?l.slug:void 0}})}}}function Kf(e,r){if(!e||!r)return!1;const n=/^(\d+)\.(\d+)\.(\d+)/,s=e.match(n),o=r.match(n);if(!s||!o)return!1;const[,a,i,l]=s.map(Number),[,d,u,p]=o.map(Number);return a!==d?a>d:i!==u?i>u:l>=p}function qf(e,r){if(!r.length)return e;const n=new Map,s=new Map;for(const o of r){const a=o.name.split("/"),i=a.pop()||o.name;if(s.set(i,o),a.length>=1){const l=a[a.length-1];n.set(`${l}/${i}`,o)}}return e.map(o=>{if(o.origin!=="installed")return o;let a;if(o.pluginName?a=n.get(`${o.pluginName}/${o.skill}`):a=s.get(o.skill),!a)return o;const i=a.updateAvailable&&!Kf(o.version,a.latest),l=a.installed&&a.installed!=="0.0.0"?a.installed:null,d={...o,updateAvailable:i,currentVersion:l??o.currentVersion,latestVersion:a.latest??void 0};typeof a.trackedForUpdates=="boolean"&&(d.trackedForUpdates=a.trackedForUpdates);const u=jc({frontmatterVersion:d.version??null,registryCurrentVersion:d.currentVersion??null,pluginVersion:d.pluginVersion??null,installedCurrentVersion:d.currentVersion??null,preferInstalled:!0});return d.resolvedVersion=u.version,d.versionSource=u.versionSource,d})}const Yf=new Set(["private_repository","unsupported_repository"]),Jf=new Set(["private_publishing_unavailable","draft_persistence_unavailable"]);class Qn extends Error{constructor(r,n,s){super(n),this.name="SubmissionRefusedError",this.code=r,this.status=s}}function wc(e){return e instanceof Qn||e instanceof Error&&e.name==="SubmissionRefusedError"&&typeof e.code=="string"}function Qf(e){var o,a;const r=e,n=typeof((o=r==null?void 0:r.details)==null?void 0:o.error)=="string"?r.details.error:"",s=typeof((a=r==null?void 0:r.details)==null?void 0:a.message)=="string"?r.details.message:"";throw(r==null?void 0:r.status)===400&&n==="missing_tenant"?new Qn(n,s||"Select a publishing account or connect the GitHub App first.",400):(r==null?void 0:r.status)===422&&Yf.has(n)?new Qn(n,s||"Nothing was submitted to verified-skill.com.",422):(r==null?void 0:r.status)===503&&Jf.has(n)?new Qn(n,s||"Hosted private publishing is not open yet.",503):e}const Xf={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},si={own:"authoring-project",installed:"available-project",global:"available-personal"},Bo=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function Zf(e){if(typeof e=="string"){if(Bo.has(e))return e;if(Object.prototype.hasOwnProperty.call(si,e))return si[e]}return"authoring-project"}function eh(e){return e.startsWith("available-")?"available":"authoring"}function th(e){const r=e.indexOf("-");return e.slice(r+1)}const Lr="";function Fn(e,r){try{let n=!1;const s=Xf;if(s&&(s.VITE_VSKILL_DEBUG_SSE==="1"||s.VITE_VSKILL_DEBUG_SSE==="true")&&(n=!0),!n&&typeof window<"u"&&typeof window.location<"u"&&new URLSearchParams(window.location.search).get("debugSse")==="1"&&(n=!0),!n)return;console.warn(`[vskill api] ${e}`,r)}catch{}}class Jt extends Error{constructor(r,n,s){super(r),this.name="ApiError",this.status=n,this.details=s}}async function ve(e,r){const n=await fetch(`${Lr}${e}`,r);if(!n.ok){const s=await n.json().catch(()=>({error:n.statusText})),o=s&&typeof s=="object"?s:void 0;throw new Jt((s==null?void 0:s.error)||`HTTP ${n.status}`,n.status,o)}return n.json()}function Ze(e){return typeof e=="string"&&e.length>0?e:null}function rh(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Ar(e){if(!Array.isArray(e))return null;const r=e.filter(n=>typeof n=="string"&&n.length>0);return r.length>0?r:null}function nh(e){if(!e||typeof e!="object")return null;const r=e,n=Ze(r.python)??void 0,s=Ar(r.pip)??void 0,o=Ze(r.node)??void 0;return!n&&!s&&!o?null:{python:n,pip:s,node:o}}function sh(e){if(!e||typeof e!="object")return null;const r=e,n=r.runner;return n!=="vitest"&&n!=="pytest"&&n!=="none"?null:{runner:n,file:Ze(r.file)??void 0,requires:Ar(r.requires)??void 0}}function oh(e){const r=e??{};let n;r.origin==="source"||r.origin==="installed"?n=r.origin:(n="source",console.warn(`[api.getSkills] skill ${String(r.plugin)}/${String(r.skill)} has invalid origin=${JSON.stringify(r.origin)}; defaulting to 'source'`));let s;r.scope==="own"||r.scope==="installed"||r.scope==="global"?s=r.scope:s=n==="installed"?"installed":"own";let o;r.installMethod==="authored"||r.installMethod==="copied"||r.installMethod==="symlinked"?o=r.installMethod:o=s==="own"?"authored":"copied";const a=typeof r.scopeV2=="string"&&Bo.has(r.scopeV2)?r.scopeV2:Zf(r.scope),i=eh(a),l=th(a),d=typeof r.precedenceRank=="number"?r.precedenceRank:void 0;let u;r.shadowedBy===null?u=null:typeof r.shadowedBy=="string"&&Bo.has(r.shadowedBy)?u=r.shadowedBy:u=void 0;const p={plugin:typeof r.plugin=="string"?r.plugin:"",skill:typeof r.skill=="string"?r.skill:"",dir:typeof r.dir=="string"?r.dir:"",hasEvals:!!r.hasEvals,hasBenchmark:!!r.hasBenchmark,evalCount:typeof r.evalCount=="number"?r.evalCount:0,assertionCount:typeof r.assertionCount=="number"?r.assertionCount:0,benchmarkStatus:r.benchmarkStatus==="pass"||r.benchmarkStatus==="fail"||r.benchmarkStatus==="pending"||r.benchmarkStatus==="stale"||r.benchmarkStatus==="missing"?r.benchmarkStatus:"missing",lastBenchmark:typeof r.lastBenchmark=="string"?r.lastBenchmark:null,origin:n,...r.sourcePrivate===!0?{sourcePrivate:!0}:{},scope:s,isSymlink:typeof r.isSymlink=="boolean"?r.isSymlink:!1,symlinkTarget:Ze(r.symlinkTarget),installMethod:o,sourcePath:Ze(r.sourcePath),scopeV2:a,group:i,source:l,pluginName:Ze(r.pluginName),pluginNamespace:Ze(r.pluginNamespace),pluginMarketplace:Ze(r.pluginMarketplace),pluginManifestPath:Ze(r.pluginManifestPath),pluginVersion:Ze(r.pluginVersion),...typeof r.pluginDisplay=="string"&&r.pluginDisplay?{pluginDisplay:r.pluginDisplay}:{},precedenceRank:d,shadowedBy:u,description:Ze(r.description),version:Ze(r.version),category:Ze(r.category),author:Ze(r.author),license:Ze(r.license),homepage:Ze(r.homepage),repoUrl:Ze(r.repoUrl),skillPath:Ze(r.skillPath),tags:Ar(r.tags),deps:Ar(r.deps),mcpDeps:Ar(r.mcpDeps),entryPoint:Ze(r.entryPoint),lastModified:Ze(r.lastModified),sizeBytes:rh(r.sizeBytes),sourceAgent:Ze(r.sourceAgent),secrets:Ar(r.secrets),runtime:nh(r.runtime),integrationTests:sh(r.integrationTests)};if(r.provenance&&typeof r.provenance=="object"){const h=r.provenance;(h.promotedFrom==="installed"||h.promotedFrom==="global")&&typeof h.sourcePath=="string"&&typeof h.promotedAt=="number"?p.provenance={promotedFrom:h.promotedFrom,sourcePath:h.sourcePath,promotedAt:h.promotedAt,sourceSkillVersion:typeof h.sourceSkillVersion=="string"?h.sourceSkillVersion:void 0}:p.provenance=null}else r.provenance===null&&(p.provenance=null);typeof r.updateAvailable=="boolean"&&(p.updateAvailable=r.updateAvailable),typeof r.currentVersion=="string"&&(p.currentVersion=r.currentVersion),typeof r.latestVersion=="string"&&(p.latestVersion=r.latestVersion),typeof r.pinnedVersion=="string"&&(p.pinnedVersion=r.pinnedVersion);const f=jc({frontmatterVersion:p.version??null,registryCurrentVersion:p.currentVersion??null,pluginVersion:p.pluginVersion??null,installedCurrentVersion:p.currentVersion??null,preferInstalled:p.origin==="installed"});return p.resolvedVersion=f.version,p.versionSource=f.versionSource,p}const ce={getConfig(){return ve("/api/config")},setConfig(e,r){return ve("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:r})})},revealInEditor(e,r,n){return ve("/api/skills/reveal-in-editor",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{plugin:e,skill:r,file:n}:{plugin:e,skill:r})})},async getSkills(e){const r=new URLSearchParams;e!=null&&e.scope&&r.set("scope",e.scope),e!=null&&e.agent&&r.set("agent",e.agent);const n=r.toString(),s=await ve(`/api/skills${n?"?"+n:""}`);return Array.isArray(s)?s.map(oh):[]},getSkillInstallState(e){return ve(`/api/studio/install-state?skill=${encodeURIComponent(e)}`)},async convertToPlugin(e){return ve("/api/authoring/convert-to-plugin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getAgents(){return ve("/api/agents")},getSkillAuthoringContext(e,r){return ve(`/api/skills/${encodeURIComponent(e)}/${encodeURIComponent(r)}/authoring`)},getSkillDetail(e,r){return ve(`/api/skills/${e}/${r}`)},async getEvals(e,r){const n=await ve(`/api/skills/${e}/${r}/evals`);if(n&&typeof n=="object"&&"exists"in n){if(n.exists===!1)return{skill_name:r,evals:[]};const{exists:s,...o}=n;return o}return n},getEvalsEnvelope(e,r){return ve(`/api/skills/${e}/${r}/evals`)},getActivationHistoryEnvelope(e,r){return ve(`/api/skills/${e}/${r}/activation-history`)},saveEvals(e,r,n){return ve(`/api/skills/${e}/${r}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},generateEvals(e,r){return ve(`/api/skills/${e}/${r}/generate-evals`,{method:"POST"})},async getLatestBenchmark(e,r){const n=await fetch(`${Lr}/api/skills/${e}/${r}/benchmark/latest`);if(!n.ok){const s=await n.json().catch(()=>({error:n.statusText}));throw new Jt(s.error||`HTTP ${n.status}`,n.status)}return n.json()},getHistory(e,r,n){const s=new URLSearchParams;n!=null&&n.model&&s.set("model",n.model),n!=null&&n.type&&s.set("type",n.type),n!=null&&n.from&&s.set("from",n.from),n!=null&&n.to&&s.set("to",n.to);const o=s.toString();return ve(`/api/skills/${e}/${r}/history${o?"?"+o:""}`)},getHistoryEntry(e,r,n){return ve(`/api/skills/${e}/${r}/history/${encodeURIComponent(n)}`)},compareRuns(e,r,n,s){return ve(`/api/skills/${e}/${r}/history-compare?a=${encodeURIComponent(n)}&b=${encodeURIComponent(s)}`)},getCaseHistory(e,r,n,s){const o=new URLSearchParams;s&&o.set("model",s);const a=o.toString();return ve(`/api/skills/${e}/${r}/history/case/${n}${a?"?"+a:""}`)},deleteHistoryEntry(e,r,n){return ve(`/api/skills/${e}/${r}/history/${encodeURIComponent(n)}`,{method:"DELETE"})},deleteSkill(e,r){return ve(`/api/skills/${e}/${r}`,{method:"DELETE"})},uninstallSkill(e,r){return ve(`/api/skills/${e}/${r}/uninstall`,{method:"POST"})},improveSkill(e,r,n){return ve(`/api/skills/${e}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},instructEdit(e,r,n){return ve(`/api/skills/${e}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...n})})},applyImprovement(e,r,n){return ve(`/api/skills/${e}/${r}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})})},getStats(e,r){return ve(`/api/skills/${e}/${r}/stats`)},getDependencies(e,r){return ve(`/api/skills/${e}/${r}/dependencies`)},getProjectLayout(){return ve("/api/project-layout")},getProjectGitHubStatus(){return ve("/api/project/github-status")},createSkill(e){return ve("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},detectEngines(){return ve("/api/studio/detect-engines")},saveDraft(e){return ve("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getSkillCreatorStatus(){return ve("/api/skill-creator-status")},generateSkill(e){return ve("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getSkillFiles(e,r){return ve(`/api/skills/${e}/${r}/files`)},getSkillFile(e,r,n){return ve(`/api/skills/${e}/${r}/file?path=${encodeURIComponent(n)}`)},saveSkillFile(e,r,n,s){return ve(`/api/skills/${e}/${r}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:s})})},getLeaderboard(e,r){return ve(`/api/skills/${e}/${r}/leaderboard`)},getLeaderboardEntry(e,r,n){return ve(`/api/skills/${e}/${r}/leaderboard/${encodeURIComponent(n)}`)},startSweep(e,r,n){const s=`${Lr}/api/skills/${e}/${r}/sweep`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(n)}),o},getCredentials(e,r){return ve(`/api/credentials/${e}/${r}`)},setCredential(e,r,n,s){return ve(`/api/credentials/${e}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,value:s})})},getParams(e,r){return ve(`/api/credentials/${e}/${r}/params`)},getParamsRevealed(e,r,n){const s=n?`reveal=true&key=${encodeURIComponent(n)}`:"reveal=true";return ve(`/api/credentials/${e}/${r}/params?${s}`)},searchModels(){return ve("/api/openrouter/models")},...Gf(ve),async lookupSkillsByName(e){if(!Array.isArray(e)||e.length===0)return[];const r=e.slice(0,50);try{const n=await fetch(`${Lr}/api/v1/skills/lookup-by-name`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entries:r})});if(!n.ok)return Fn("lookup-by-name-error",{status:n.status}),[];const s=await n.json().catch(a=>(Fn("lookup-by-name-parse-error",{message:a instanceof Error?a.message:String(a)}),null)),o=s&&typeof s=="object"&&"results"in s?s.results:null;return Array.isArray(o)?o.filter(a=>a!==null&&typeof a=="object").map(a=>({name:typeof a.name=="string"?a.name:"",author:typeof a.author=="string"?a.author:"",uuid:typeof a.uuid=="string"&&a.uuid.length>0?a.uuid:void 0,slug:typeof a.slug=="string"&&a.slug.length>0?a.slug:void 0})).filter(a=>a.name.length>0):(s!==null&&Fn("lookup-by-name-no-results-array",{}),[])}catch(n){return Fn("lookup-by-name-fetch-error",{message:n instanceof Error?n.message:String(n)}),[]}},promoteSkill(e,r,n){const s=n!=null&&n.overwrite?"?overwrite=true":"";return Ds(`/api/skills/${e}/${r}/promote${s}`,n==null?void 0:n.onEvent,n==null?void 0:n.signal)},testInstallSkill(e,r,n){const s=new URLSearchParams;(n==null?void 0:n.dest)==="global"&&s.set("dest","global"),n!=null&&n.overwrite&&s.set("overwrite","true");const o=s.toString();return Ds(`/api/skills/${e}/${r}/test-install${o?"?"+o:""}`,n==null?void 0:n.onEvent,n==null?void 0:n.signal)},revertSkill(e,r,n){return Ds(`/api/skills/${e}/${r}/revert`,n==null?void 0:n.onEvent,n==null?void 0:n.signal)},listStudioOps(e){const r=new URLSearchParams;(e==null?void 0:e.before)!=null&&r.set("before",String(e.before)),(e==null?void 0:e.limit)!=null&&r.set("limit",String(e.limit));const n=r.toString();return ve(`/api/studio/ops${n?"?"+n:""}`)},deleteStudioOp(e){return ve(`/api/studio/ops/${encodeURIComponent(e)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Lr}/api/studio/ops/stream`)},gitRemote(){return ve("/api/git/remote")},gitDiff(){return ve("/api/git/diff",{method:"POST"})},gitStatus(){return ve("/api/git/status")},gitCommitMessage(e){return ve("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})},gitPublish(e){return ve("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})},async submitToQueue(e){const r=await ve("/api/v1/submissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(Qf);return r.alreadyVerified===!0?{kind:"alreadyVerified",skillId:typeof r.skillId=="string"?r.skillId:void 0,skillName:typeof r.skillName=="string"?r.skillName:void 0}:r.blocked===!0?{kind:"blocked",submissionId:String(r.submissionId??r.id??"")}:r.requeued===!0?{kind:"requeued",id:String(r.id??""),state:String(r.state??"RECEIVED")}:r.duplicate===!0?{kind:"duplicate",id:String(r.id??""),state:String(r.state??"")}:{kind:"created",id:String(r.id??""),skillName:String(r.skillName??e.skillName),skillPath:String(r.skillPath??e.skillPath??""),state:String(r.state??"RECEIVED"),createdAt:String(r.createdAt??new Date().toISOString())}},getMyQueue(){return ve("/api/v1/submissions?mine=1")},getSubmission(e){return ve(`/api/v1/submissions/${encodeURIComponent(e)}`)},getPositions(e){const r=e&&e.length>0?`?ids=${encodeURIComponent(e.join(","))}`:"";return ve(`/api/v1/submissions/positions${r}`)},async getAccountTenants(){return ve("/api/v1/account/tenants")},async getActiveTenant(){return ve("/__internal/active-tenant")},async setActiveTenant(e){return ve("/__internal/active-tenant",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentTenant:e})})}};async function Ds(e,r,n){const s=await fetch(`${Lr}${e}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:n});if(!s.ok||!s.body){let p=`HTTP ${s.status}`,f;try{const m=await s.json();m.error&&(p=m.error),typeof m.code=="string"&&(f=m.code)}catch{}const h=new Jt(p,s.status);throw f&&(h.code=f),h}const o=s.body.getReader(),a=new TextDecoder;let i="",l="",d=null,u=null;for(;;){const{done:p,value:f}=await o.read();if(p)break;i+=a.decode(f,{stream:!0});const h=i.split(`
|
|
14
|
+
`);i=h.pop()??"";for(const m of h)if(m.startsWith("event: "))l=m.slice(7).trim();else if(m.startsWith("data: ")){let g={};try{g=JSON.parse(m.slice(6))}catch{l="";continue}if(l==="started"||l==="copied"||l==="deleted"||l==="indexed"||l==="done"||l==="error"){const v={type:l,...g};r==null||r(v),v.type==="done"&&(d=v),v.type==="error"&&(u=v)}l=""}}if(u){const p=new Jt(u.message,500);throw p.code=u.code,p}if(!d)throw new Jt("Transfer stream ended without 'done' event",500);return d}const Xn=new Map,hr=new Map,sn=new Map;function He(e){Xn.delete(e),hr.delete(e);const r=sn.get(e);if(r)for(const n of r)n()}function It(e,r,n={}){const{ttl:s=3e4,enabled:o=!0}=n,[,a]=c.useState(0),[i,l]=c.useState(void 0),[d,u]=c.useState(0),p=c.useRef(!0),f=c.useRef(e);f.current=e;const h=()=>{l(void 0),He(e),u(v=>v+1)};c.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),c.useEffect(()=>{if(!o)return;const v=()=>{p.current&&u(x=>x+1)};return sn.has(e)||sn.set(e,new Set),sn.get(e).add(v),()=>{var x;(x=sn.get(e))==null||x.delete(v)}},[e,o]),c.useEffect(()=>{if(!o)return;const v=Xn.get(e);if(!(!v||Date.now()-v.fetchedAt>s))return;if(hr.has(e)){const j=hr.get(e),S=()=>{p.current&&f.current===e&&a(k=>k+1)};j.subscribers.push(S);return}const b={promise:Promise.resolve(),subscribers:[]},y=r().then(j=>{Xn.set(e,{data:j,fetchedAt:Date.now()}),hr.delete(e),p.current&&f.current===e&&(l(void 0),a(S=>S+1));for(const S of b.subscribers)S()},j=>{hr.delete(e);const S=j instanceof Error?j:new Error(String(j));p.current&&f.current===e&&(l(S),a(k=>k+1));for(const k of b.subscribers)k()});b.promise=y,hr.set(e,b)},[e,r,s,o,d]);const m=Xn.get(e),g=o&&!m&&!i&&hr.has(e);return{data:m==null?void 0:m.data,loading:g,error:i,revalidate:h}}function ah(e){const[r,n]=c.useState(()=>typeof window>"u"?!1:window.matchMedia(e).matches);return c.useEffect(()=>{const s=window.matchMedia(e);n(s.matches);const o=a=>n(a.matches);return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[e]),r}async function ih(e,r){try{if(!await cp())return;const{q:n,...s}=r;await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s),keepalive:!0})}catch{}}const lh=500,_o="vskill.updates.seenLastId";function ch(){if(typeof window>"u")return null;try{return window.localStorage.getItem(_o)}catch{return null}}function zs(e){if(!(typeof window>"u"))try{e==null?window.localStorage.removeItem(_o):window.localStorage.setItem(_o,e)}catch{}}function dh(){let e=new Map;const r=new Set,n=new Set,s=[];let o=ch();o&&(n.add(o),s.push(o));function a(){e=new Map(e);for(const l of Array.from(r))l()}function i(l){if(!n.has(l)){if(n.add(l),s.push(l),s.length>lh){const d=s.shift();d&&n.delete(d)}o=l,zs(l)}}return{getSnapshot(){return e},subscribe(l){return r.add(l),()=>{r.delete(l)}},ingest(l){return n.has(l.eventId)?"duplicate":(i(l.eventId),e.set(l.skillId,{skillId:l.skillId,version:l.version,diffSummary:l.diffSummary,eventId:l.eventId,publishedAt:l.publishedAt,receivedAt:Date.now()}),a(),"stored")},dismiss(l){e.has(l)&&(e.delete(l),a())},clearSeen(){n.clear(),s.length=0,o=null,zs(null)},mergeBulk(l){if(l.length!==0){for(const d of l)e.set(d.skillId,d);a()}},getSeenLastId(){return o},reset(){e=new Map,n.clear(),s.length=0,o=null,zs(null),a()}}}const tr=dh(),Sc="vskill:toast-queue",uh=10,ph=1800*1e3;function gs(){return typeof window<"u"&&typeof window.localStorage<"u"}function Cc(){if(!gs())return[];try{const e=window.localStorage.getItem(Sc);if(!e)return[];const r=JSON.parse(e);return Array.isArray(r)?r.filter(n=>n&&typeof n=="object"&&typeof n.eventId=="string"&&typeof n.skillId=="string"&&typeof n.version=="string"&&typeof n.enqueuedAt=="number"&&typeof n.message=="string"):[]}catch{return[]}}function Ec(e){if(gs())try{window.localStorage.setItem(Sc,JSON.stringify(e))}catch{}}function fh(e){if(!gs())return"enqueued";const r=Cc();if(r.some(o=>o.eventId===e.eventId))return"deduped";let n=!1;const s=[...r,e];for(;s.length>uh;)s.shift(),n=!0;return Ec(s),n?"evicted":"enqueued"}function hh(){if(!gs())return[];const e=Cc();if(e.length===0)return[];Ec([]);const r=Date.now()-ph;return e.filter(n=>n.enqueuedAt>=r)}const mh="X-Studio-Token";let gr=null,Jr=null,oi=!1,Dn=null;function xh(){var e;return typeof window>"u"?!1:!!((e=window.__TAURI_INTERNALS__)!=null&&e.invoke)}function va(){if(typeof document>"u")return null;const e=document.getElementById("__vskill_studio_token__");if(!e||!e.textContent)return null;try{const r=JSON.parse(e.textContent);if(typeof r.token=="string"&&r.token.length>0)return r.token}catch{}return null}async function gh(){var n;if(typeof window>"u")return null;const r=(n=window.__TAURI_INTERNALS__)==null?void 0:n.invoke;if(!r)return null;try{const s=await r("get_studio_token");return typeof s=="string"&&s.length>0?s:null}catch{return null}}async function vh(){if(gr)return gr;const e=va();return e?(gr=e,e):Jr||(Jr=gh().then(r=>(r&&(gr=r),Jr=null,r)),Jr)}function yh(e){if(typeof window>"u")return!1;if(e.startsWith("/api/"))return!0;try{const r=window.location.origin;if(e.startsWith(`${r}/api/`))return!0}catch{}return!1}function bh(){oi||typeof globalThis.fetch!="function"||!(va()!==null)&&!xh()||(oi=!0,Dn=globalThis.fetch.bind(globalThis),globalThis.fetch=async(r,n)=>{let s;if(typeof r=="string"?s=r:r instanceof URL?s=r.toString():s=r.url,!yh(s))return Dn(r,n);const o=await vh();if(!o)return Dn(r,n);const a={...n??{}},i=new Headers(a.headers??{});return i.set(mh,o),a.headers=i,Dn(r,a)})}function kh(){if(gr)return gr;const e=va();return e?(gr=e,e):null}const vs=new Set(["PUBLISHED","AUTO_APPROVED","VENDOR_APPROVED"]),ya=new Set(["REJECTED","TIER1_FAILED","BLOCKED"]),Oo=new Set;function Nc(e,r){return`${e}::${r}`}function Rc(e,r){const n=Nc(e,r);return Oo.has(n)?!1:(Oo.add(n),!0)}function jh(e,r){Oo.add(Nc(e,r))}function wh(e){return`https://verified-skill.com/submit/${encodeURIComponent(e)}`}function Sh(e,r,n){const s=r||"Your skill";return vs.has(n)?{outcome:"approved",title:"Skill approved",body:`${s} is now published on verified-skill.com`}:ya.has(n)?{outcome:"rejected",title:"Skill rejected",body:`${s} ${n==="BLOCKED"?"was blocked":"was rejected"}. Tap to see why.`,clickUrl:wh(e)}:null}function Ch(){return typeof window<"u"&&"__TAURI_INTERNALS__"in window}async function Eh(){try{return await ar(()=>import("./index-Bje294df.js"),__vite__mapDeps([0,1]))}catch{return null}}async function Nh(e){try{let r=await e.isPermissionGranted();return r||(r=await e.requestPermission()==="granted"),r}catch{return!1}}async function Tc(e,r,n){const s=Sh(e,r,n);if(!s||!Ch())return!1;const o=await Eh();if(!o||!await Nh(o))return!1;if(s.outcome==="rejected"&&s.clickUrl&&typeof o.onAction=="function")try{const i=s.clickUrl;let l=null;l=await o.onAction(()=>{hn(i);try{l==null||l()}catch{}})}catch{}try{return o.sendNotification({title:s.title,body:s.body}),!0}catch{return!1}}function ai(e){return typeof e=="string"&&e.length>0}function Rh(e){if(typeof e!="string")return null;const r=e.trim();return r.length>0?`usr_${r}`:null}function Th(e){const r=[];for(const n of e){const s=ai(n.uuid),o=ai(n.slug);if(!s&&!o)continue;const a={};s&&(a.uuid=n.uuid),o&&(a.slug=n.slug),r.push(a)}return r}const Ih=3e5,Lh=500,Ah=15e3,Ph=6e4,$h=6e4,Mh="/api/v1/skills/stream",Fh=250,Dh=500,zh="/api/v1/studio/telemetry/sse",ii="vskill.studio.sse.sessionId";function Ic(){var e;try{const r=(e=import.meta)==null?void 0:e.env;if(r&&typeof r=="object")return r}catch{}return{}}function Bh(){if(typeof window>"u")return!1;const e=Ic();if(e.VITE_VSKILL_DEBUG_SSE==="1"||e.VITE_VSKILL_DEBUG_SSE==="true")return!0;try{if(new URLSearchParams(window.location.search).get("debugSse")==="1")return!0}catch{}return!1}function _h(){if(typeof window>"u")return!0;const e=Ic();if(e.VITE_VSKILL_DISABLE_TELEMETRY==="1"||e.VITE_VSKILL_DISABLE_TELEMETRY==="true")return!0;try{if(new URLSearchParams(window.location.search).get("disableTelemetry")==="1")return!0}catch{}return!1}function jt(e,r){if(Bh())try{const n=new Date().toISOString();r?console.debug(`[sse] ${n} ${e}`,r):console.debug(`[sse] ${n} ${e}`)}catch{}}function li(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")try{return crypto.randomUUID()}catch{}const e=[];for(let r=0;r<16;r++)e.push(Math.floor(Math.random()*256).toString(16).padStart(2,"0"));return e[6]=(parseInt(e[6],16)&15|64).toString(16).padStart(2,"0"),e[8]=(parseInt(e[8],16)&63|128).toString(16).padStart(2,"0"),e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10,16).join("")}function Oh(){if(typeof window>"u")return"";try{const e=window.sessionStorage.getItem(ii);if(e)return e;const r=li();return window.sessionStorage.setItem(ii,r),r}catch{return li()}}function Bs(e){const r=new Map;for(const s of e)r.set(s.name,s);const n=new Map;for(const s of e){const o=s.name.split("/").pop()||s.name;o!==s.name&&n.set(o,(n.get(o)??0)+1)}for(const s of e){const o=s.name.split("/").pop()||s.name;o!==s.name&&((n.get(o)??0)>1||r.has(o)||r.set(o,s))}return r}function _s(e){let r=0;for(const n of e)n.updateAvailable&&r++;return r}const ci="sk_published_";function di(e,r){const n=e.split(/[.+-]/).slice(0,3).map(o=>Number.parseInt(o,10)||0),s=r.split(/[.+-]/).slice(0,3).map(o=>Number.parseInt(o,10)||0);for(let o=0;o<3;o++)if((n[o]??0)!==(s[o]??0))return(n[o]??0)>(s[o]??0);return!1}function Wh(e,r){const n=r.skillSlug;if(!n||!n.startsWith(ci))return e;const s=n.slice(ci.length);let o=!1;const a=e.map(i=>i.name!==s||i.pinned||!di(r.version,i.installed)||i.updateAvailable&&i.latest&&!di(r.version,i.latest)?i:(o=!0,{...i,latest:r.version,updateAvailable:!0}));return o?a:e}function Uh(e){if(!e||typeof e!="object")return!1;const r=e;return r.type==="skill.updated"&&typeof r.eventId=="string"&&typeof r.skillId=="string"&&typeof r.version=="string"}function Hh(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.submissionId=="string"&&r.submissionId.length>0&&typeof r.state=="string"&&r.state.length>0}function Vh(e){const r=(e==null?void 0:e.intervalMs)??Ih,n=(e==null?void 0:e.debounceMs)??Lh,s=(e==null?void 0:e.timeoutMs)??Ah,o=(e==null?void 0:e.staleAfterMs)??Ph,a=(e==null?void 0:e.disconnectFallbackMs)??$h,i=(e==null?void 0:e.streamUrlBase)??Mh,l=(e==null?void 0:e.replayIntervalMs)??Fh,d=Rh(e==null?void 0:e.userId),u=c.useMemo(()=>{const U=(e==null?void 0:e.skillIds)??[];if(U.length===0&&!d)return"";const K=d?1:0,X=[...new Set(U)].filter(G=>G!==d).sort().slice(0,Dh-K),ie=d?[...X,d]:X;return ie.length===0?"":ie.sort().join(",")},[e==null?void 0:e.skillIds,d]),p=c.useMemo(()=>{const U=(e==null?void 0:e.trackingSkillIds)??(e==null?void 0:e.skillIds)??[];return U.length===0?"":[...U].sort().join(",")},[e==null?void 0:e.trackingSkillIds,e==null?void 0:e.skillIds]),[f,h]=c.useState([]),[m,g]=c.useState(()=>new Map),[v,x]=c.useState(0),[b,y]=c.useState(!1),[j,S]=c.useState(null),[k,R]=c.useState(null),w=c.useRef(null),E=c.useRef(null),N=c.useRef(null),T=c.useRef(null),I=c.useRef(!0),A=c.useRef(new Set),[$,W]=c.useState(()=>u?"connecting":"fallback"),C=c.useRef($);C.current=$;const P=c.useRef(new Set),L=c.useRef(null),F=c.useSyncExternalStore(U=>tr.subscribe(U),()=>tr.getSnapshot(),()=>tr.getSnapshot()),H=F.size,re=c.useCallback(U=>{if(_h()||P.current.has(U))return;P.current.add(U);const K=Oh(),X=Date.now(),ie={event:U,sessionId:K,sourceTier:"platform-proxy",timestamp:X};U!=="connected"&&L.current!=null&&(ie.durationSinceOpenMs=X-L.current),ih(zh,ie)},[]),V=c.useCallback(async()=>{y(!0);const U=new AbortController,K=setTimeout(()=>U.abort(),s);try{const X=await Promise.race([ce.getSkillUpdates(),new Promise((ie,G)=>{U.signal.addEventListener("abort",()=>{G(new Error("TIMEOUT"))})})]);if(X==="TIMEOUT")throw new Error("TIMEOUT");if(!I.current)return;h(X),g(Bs(X)),x(_s(X)),E.current=Date.now(),S(E.current),R(null)}catch(X){if(!I.current)return;R(X instanceof Error?X:new Error(String(X)))}finally{clearTimeout(K),I.current&&y(!1)}},[s]),O=c.useCallback(()=>{if(w.current)return w.current;const U=V().finally(()=>{w.current=null});return w.current=U,U},[V]),se=c.useCallback(()=>{N.current==null&&(N.current=setInterval(()=>{O()},r))},[r,O]),ge=c.useCallback(()=>{N.current!=null&&(clearInterval(N.current),N.current=null)},[]),ye=c.useCallback(()=>{if(typeof window>"u")return;const U=hh();U.length!==0&&(jt("queue-drain",{count:U.length}),U.forEach((K,X)=>{let ie;ie=setTimeout(()=>{if(A.current.delete(ie),!I.current)return;const te=tr.getSnapshot().get(K.skillId);if(te&&te.eventId!==K.eventId){jt("queue-replay-skip-superseded",{queuedEventId:K.eventId,currentEventId:te.eventId});return}try{window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:K.message,severity:K.severity,skillId:K.skillId,version:K.version,eventId:K.eventId}})),jt("queue-replay",{eventId:K.eventId})}catch{}},X*l),A.current.add(ie)}))},[l]),z=c.useCallback(()=>{for(const U of A.current)clearTimeout(U);A.current.clear()},[]);c.useEffect(()=>{I.current=!0,(E.current==null||Date.now()-E.current>o)&&O(),(typeof document>"u"||document.visibilityState!=="hidden")&&se();const X=()=>{if(T.current&&(clearTimeout(T.current),T.current=null),document.visibilityState==="hidden"){ge();return}ye(),T.current=setTimeout(()=>{T.current=null,(E.current==null||Date.now()-E.current>o)&&O(),se()},n)};return typeof document<"u"&&document.addEventListener("visibilitychange",X),()=>{I.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",X),T.current&&clearTimeout(T.current),z(),ge()}},[]);const ne=c.useCallback(async U=>{if(U.length!==0)try{const K=await ce.checkSkillUpdates(U);if(!I.current||K.length===0)return;const X=Date.now(),ie=K.filter(te=>te.skillId&&te.eventId&&te.version).map(te=>({skillId:te.skillId,version:te.version,eventId:te.eventId,publishedAt:te.publishedAt,diffSummary:te.diffSummary,receivedAt:X}));ie.length>0&&tr.mergeBulk(ie);const G=K.filter(te=>typeof te.trackedForUpdates=="boolean"||typeof te.updateAvailable=="boolean").map(te=>({name:te.name??te.skillId,installed:te.installed??"",latest:te.latest??null,updateAvailable:te.updateAvailable??!1,trackedForUpdates:typeof te.trackedForUpdates=="boolean"?te.trackedForUpdates:void 0}));G.length>0&&h(te=>{const de=new Map;for(const B of te)de.set(B.name,B);let fe=0;for(const B of G){const Y=B.name,J=de.get(Y);if(J){const ee={...J};J.trackedForUpdates===void 0&&B.trackedForUpdates!==void 0&&(ee.trackedForUpdates=B.trackedForUpdates),de.set(Y,ee)}else de.set(Y,{name:B.name,installed:B.installed??"",latest:B.latest??null,updateAvailable:B.updateAvailable??!1,trackedForUpdates:B.trackedForUpdates}),fe+=1}if(fe===0&&de.size===te.length)return te;const ke=[...de.values()];return g(Bs(ke)),x(_s(ke)),ke})}catch{}},[]);c.useEffect(()=>{const U=u||p;if(!U){W("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){W("fallback");return}W("connecting");const K=U.split(",");let X=`${i}?skills=${encodeURIComponent(U)}`;const ie=kh();ie&&(X+=`&studioToken=${encodeURIComponent(ie)}`);let G=null,te=null,de=null;const fe=()=>{te==null&&(te=setTimeout(()=>{te=null,I.current&&C.current!=="connected"&&(W("fallback"),jt("fallback-flipped",{reason:"watchdog-timeout"}),re("fallback"))},a),jt("fallback-armed",{fallbackMs:a}))},ke=()=>{te!=null&&(clearTimeout(te),te=null)};fe();const B=1e3,Y=()=>{I.current&&de==null&&(de=setTimeout(()=>{if(de=null,!!I.current&&!(G&&G.readyState!==EventSource.CLOSED)){if(G)try{G.close()}catch{}jt("reconnect-scheduled",{backoffMs:B}),re("reconnect-scheduled"),be()}},B))},J=Te=>{if(!I.current)return;let Q;try{Q=JSON.parse(Te.data)}catch{return}if(!Uh(Q))return;const Se=tr.ingest(Q);if(jt("message",{eventId:Q.eventId,skillId:Q.skillId,outcome:Se}),Se==="duplicate")return;h(Ae=>{const Pe=Wh(Ae,Q);return Pe===Ae?Ae:(g(Bs(Pe)),x(_s(Pe)),Pe)});const he=typeof document>"u"||document.visibilityState!=="hidden",Ce=`${Q.skillId} updated to ${Q.version}`;if(he)try{window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Ce,severity:"info",skillId:Q.skillId,version:Q.version,eventId:Q.eventId}}))}catch{}else{const Ae={message:Ce,severity:"info",skillId:Q.skillId,version:Q.version,eventId:Q.eventId,enqueuedAt:Date.now()},Pe=fh(Ae);jt("queue-enqueue",{eventId:Q.eventId,outcome:Pe})}},ee=()=>{I.current&&(jt("gone",{skillsCount:K.length}),re("gone-frame-received"),tr.clearSeen(),ne(K))},ue=Te=>{if(!I.current)return;let Q;try{Q=JSON.parse(Te.data)}catch{return}if(Hh(Q)){if(!Rc(Q.submissionId,Q.state)){jt("submission-decision-duplicate",{submissionId:Q.submissionId,state:Q.state});return}jt("submission-decision",{submissionId:Q.submissionId,state:Q.state}),Tc(Q.submissionId,Q.skillName??"",Q.state),vs.has(Q.state)&&O()}},be=()=>{I.current&&(G=new EventSource(X),jt("open-attempt",{url:X}),G.onopen=()=>{I.current&&(ke(),W("connected"),L.current=Date.now(),jt("open",{url:X}),re("connected"))},G.onerror=()=>{I.current&&(jt("error",{readyState:G==null?void 0:G.readyState}),fe(),G&&G.readyState===EventSource.CLOSED&&Y())},G.onmessage=J,G.addEventListener("skill.updated",J),G.addEventListener("gone",ee),G.addEventListener("submission_decision",ue))};return be(),()=>{if(ke(),de!=null&&(clearTimeout(de),de=null),G){try{G.removeEventListener("gone",ee)}catch{}try{G.removeEventListener("submission_decision",ue)}catch{}try{G.close()}catch{}}z()}},[u,p,i,a,ne,re,z]),c.useEffect(()=>{if(!p)return;const U=p.split(",");ne(U)},[p,ne]);const M=c.useCallback(U=>{tr.dismiss(U)},[]);return{updates:f,updatesMap:m,updateCount:v,isRefreshing:b,lastFetchAt:j,error:k,refresh:O,updatesById:F,pushUpdateCount:H,status:$,dismiss:M}}async function Gh(){return Lc("account_get_platform_url"),{platformBaseUrl:"",authMode:"cookie",getAuthHeader:async()=>null}}async function Kh(){const e=await Lc("account_get_user_summary");return e&&typeof e=="object"?e:{signedIn:!1,login:null,avatarUrl:null,tier:"free"}}async function Lc(e){var s;if(typeof window>"u")return null;const n=(s=window.__TAURI_INTERNALS__)==null?void 0:s.invoke;if(!n)return null;try{return await n(e)}catch(o){return console.warn(`[AccountTauriBridge] ${e} failed:`,o),null}}function Ac(){var e;return typeof window>"u"?!1:!!((e=window.__TAURI_INTERNALS__)!=null&&e.invoke)}const qh={signedIn:!1,login:null,avatarUrl:null,tier:"free"};function Pc(){const[e,r]=c.useState(qh);return c.useEffect(()=>{let n=!1;const s=()=>{Kh().then(o=>{n||r(o)})};return s(),typeof window>"u"?()=>{n=!0}:(window.addEventListener("studio:account-summary-refresh",s),()=>{n=!0,window.removeEventListener("studio:account-summary-refresh",s)})},[]),e}const Yh={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function Jh(e,r){switch(r.type){case"SELECT_SKILL":return{...e,selectedSkill:r.skill,mode:"browse",mobileView:e.isMobile?"detail":e.mobileView};case"CLEAR_SELECTION":return{...e,selectedSkill:null};case"SET_MODE":return{...e,mode:r.mode,selectedSkill:r.mode==="create"?null:e.selectedSkill};case"SET_SEARCH":return{...e,searchQuery:r.query};case"SET_SKILLS":return{...e,skills:r.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...e,skillsError:r.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...e,skillsLoading:r.loading};case"SET_MOBILE":return{...e,isMobile:r.isMobile};case"SET_MOBILE_VIEW":return{...e,mobileView:r.view};case"DISMISS_UPDATE_NOTIFICATION":return{...e,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...e,selectedSkill:r.skill,revealSkillId:`${r.skill.plugin}/${r.skill.skill}`,mode:"browse",mobileView:e.isMobile?"detail":e.mobileView};case"CLEAR_REVEAL":return{...e,revealSkillId:null};default:return e}}const $c=c.createContext(null),Mc=$c;function Pt(){const e=c.useContext(Mc);if(!e)throw new Error("useStudio must be used within StudioProvider");return e}function Qh({children:e}){const[r,n]=c.useReducer(Jh,Yh),s=ah("(max-width: 767px)");c.useEffect(()=>{n({type:"SET_MOBILE",isMobile:s})},[s]);const[o,a]=c.useState(()=>{try{const z=window.localStorage.getItem("vskill.studio.prefs");if(!z)return null;const ne=JSON.parse(z);return typeof ne.activeAgent=="string"?ne.activeAgent:null}catch{return null}}),[i,l]=c.useState(o!==null);c.useEffect(()=>{function z(ne){if(!(ne instanceof CustomEvent))return;const M=ne.detail;M!=null&&M.agentId&&(a(M.agentId),l(!0))}return window.addEventListener("studio:agent-changed",z),()=>window.removeEventListener("studio:agent-changed",z)},[]),c.useEffect(()=>{if(i)return;let z=!1;return ce.getAgents().then(ne=>{if(z)return;const M=(ne==null?void 0:ne.suggested)??"claude-code";a(U=>U??M),l(!0)}).catch(()=>{z||(a(ne=>ne??"claude-code"),l(!0))}),()=>{z=!0}},[i]);const d=c.useCallback(()=>{if(!i||!o)return Promise.resolve();n({type:"SET_SKILLS_LOADING",loading:!0});const z={agent:o};return ce.getSkills(z).then(ne=>{n({type:"SET_SKILLS",skills:ne});const M=window.location.hash,U=M.match(/^#\/skills\/(project|personal|plugin)\/([^/]+)\/([^/?]+)/);if(U){const[,X,ie,G]=U,te=X,de=ne.find(ke=>ke.plugin===ie&&ke.skill===G&&ke.source===te);if(de){n({type:"SELECT_SKILL",skill:{plugin:ie,skill:G,origin:de.origin,source:de.source}});return}const fe=ne.find(ke=>ke.plugin===ie&&ke.skill===G);fe&&n({type:"SELECT_SKILL",skill:{plugin:ie,skill:G,origin:fe.origin,source:fe.source}});return}const K=M.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(K){const[,X,ie]=K,G=ne.find(te=>te.plugin===X&&te.skill===ie);G&&n({type:"SELECT_SKILL",skill:{plugin:X,skill:ie,origin:G.origin,source:G.source}})}}).catch(ne=>n({type:"SET_SKILLS_ERROR",error:ne.message}))},[o,i]);c.useEffect(()=>{d()},[d]),c.useEffect(()=>{function z(){d()}return window.addEventListener("studio:project-changed",z),()=>window.removeEventListener("studio:project-changed",z)},[d]);const u=c.useCallback(z=>{n({type:"SELECT_SKILL",skill:z}),window.location.hash=z.source?`/skills/${z.source}/${z.plugin}/${z.skill}`:`/skills/${z.plugin}/${z.skill}`},[]),p=c.useRef(r.skills);c.useEffect(()=>{p.current=r.skills},[r.skills]);const f=c.useCallback((z,ne)=>{const M=p.current,U=z?M.find(G=>G.plugin===z&&G.skill===ne):M.find(G=>G.skill===ne&&G.source!=="plugin");if(!z&&!U){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${ne}" not yet in state — skipping reveal`);return}const K=(U==null?void 0:U.plugin)??z,X=(U==null?void 0:U.origin)??"source",ie=U==null?void 0:U.source;n({type:"REVEAL_SKILL",skill:{plugin:K,skill:ne,origin:X,source:ie}}),window.location.hash=ie?`/skills/${ie}/${K}/${ne}`:`/skills/${K}/${ne}`},[]),h=c.useCallback(()=>{n({type:"CLEAR_REVEAL"})},[]),m=c.useCallback(()=>{n({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),g=c.useCallback(z=>{n({type:"SET_MODE",mode:z})},[]),v=c.useCallback(z=>{n({type:"SET_SEARCH",query:z})},[]),x=c.useCallback(z=>{n({type:"SET_MOBILE_VIEW",view:z})},[]),b=c.useCallback(()=>{n({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),y=c.useRef(new Map),j=c.useRef(""),S=c.useRef(!1),[k,R]=c.useState(""),w=c.useRef(""),E=c.useRef(""),[N,T]=c.useState(""),I=c.useMemo(()=>r.skills.filter(z=>!z.sourcePrivate).map(z=>`${z.plugin}/${z.skill}`),[r.skills]),A=c.useMemo(()=>{const z=k?k.split(",").filter(Boolean):[],ne=N?N.split(",").filter(Boolean):[];return z.length===0&&ne.length===0?[]:[...new Set([...z,...ne])]},[k,N]),$=Pc(),W=$.signedIn?$.userId:void 0,C=Vh({skillIds:A,trackingSkillIds:I,userId:W}),P=c.useMemo(()=>A.length,[A]),L=c.useRef("");c.useEffect(()=>{const z=r.skills.filter(G=>G.origin==="installed"&&!G.sourcePrivate);if(z.length===0){R(""),L.current="";return}const ne=new Set(z.map(G=>`${G.plugin}/${G.skill}`)),M=new Map;for(const G of C.updates){const te=G.name.split("/").pop()||G.name;ne.has(G.name)&&M.has(te)||M.set(te,G)}const U=z.map(G=>{const te=M.get(G.skill),de=G.currentVersion??(te==null?void 0:te.installed)??G.version??G.pluginVersion??"1.0.0";return{plugin:G.plugin,skill:G.skill,name:(te==null?void 0:te.name)??G.skill,currentVersion:de}}),K=U.map(G=>`${G.plugin}/${G.skill}@${G.currentVersion}#${G.name}`).sort().join("|");if(K===L.current)return;L.current=K;let X=!1,ie=!1;return ce.resolveInstalledSkillIds(U).then(G=>{if(ie=!0,X)return;const fe=[...Th(G).flatMap(ke=>[ke.uuid,ke.slug].filter(Boolean))].sort().join(",");fe!==j.current&&(j.current=fe,y.current=new Map(G.map(ke=>[`${ke.plugin}/${ke.skill}`,{uuid:ke.uuid,slug:ke.slug}])),R(fe))}).catch(G=>{if(ie=!0,X||(L.current=""),!S.current){S.current=!0;const te=G instanceof Error?G.message:String(G);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{X=!0,ie||(L.current="")}},[r.skills,C.updates]),c.useEffect(()=>{const z=r.skills.filter(K=>K.origin==="source"&&!K.sourcePrivate&&typeof K.author=="string"&&K.author.length>0);if(z.length===0){w.current!==""&&(w.current="",T("")),E.current="";return}const ne=z.map(K=>({name:K.skill,author:K.author})),M=ne.map(K=>`${K.name.toLowerCase()}|${K.author}`).sort().join(`
|
|
15
|
+
`);if(M===E.current)return;E.current=M;let U=!1;return ce.lookupSkillsByName(ne).then(K=>{if(U)return;const X=K.flatMap(G=>[G.uuid,G.slug]).filter(G=>typeof G=="string"&&G.length>0),ie=[...new Set(X)].sort().join(",");ie!==w.current&&(w.current=ie,T(ie))}).catch(()=>{U||(E.current="")}),()=>{U=!0}},[r.skills]);const F=c.useMemo(()=>{const z=r.skills.map(ne=>{if(!ne.updateAvailable&&ne.latestVersion===void 0&&ne.trackedForUpdates===void 0)return ne;const M={...ne};return delete M.updateAvailable,delete M.currentVersion,delete M.latestVersion,delete M.trackedForUpdates,M});return qf(z,C.updates)},[r.skills,C.updates]),H=c.useMemo(()=>{const z={source:0,installed:0};for(const ne of F)ne.updateAvailable&&(z[ne.origin]+=1);return z},[F]),re=c.useMemo(()=>({...r,skills:F}),[r,F]),V=C.updateCount,O=C.refresh,se=C.isRefreshing,ge=c.useCallback((z,ne)=>{O(),d(),He(`versions/${z}/${ne}`),C.dismiss(`${z}/${ne}`)},[O,d,C]),ye=c.useMemo(()=>({state:re,selectSkill:u,clearSelection:m,setMode:g,setSearch:v,setMobileView:x,refreshSkills:d,updateCount:V,dismissUpdateNotification:b,updates:C.updates,outdatedByOrigin:H,isRefreshingUpdates:se,refreshUpdates:O,revealSkill:f,clearReveal:h,updatesById:C.updatesById,pushUpdateCount:C.pushUpdateCount,updateStreamStatus:C.status,dismissPushUpdate:C.dismiss,activeAgent:o,onSkillUpdated:ge,trackedSkillCount:P}),[re,u,m,g,v,x,d,V,b,C.updates,H,se,O,f,h,C.updatesById,C.pushUpdateCount,C.status,C.dismiss,o,ge,P]);return t.jsx(Mc.Provider,{value:ye,children:e})}const Xh={config:null,loading:!0};function Zh(e,r){switch(r.type){case"SET_CONFIG":return{config:r.config,loading:!1};case"SET_LOADING":return{...e,loading:!0};default:return e}}const Fc=c.createContext(null);function kr(){const e=c.useContext(Fc);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}function em({children:e}){const[r,n]=c.useReducer(Zh,Xh),s=c.useCallback(()=>{ce.getConfig().then(i=>n({type:"SET_CONFIG",config:i})).catch(()=>{})},[]);c.useEffect(()=>{s()},[s]);const o=c.useCallback(async(i,l)=>{const d=await ce.setConfig(i,l);return n({type:"SET_CONFIG",config:d}),d},[]),a=c.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:o,refreshConfig:s}),[r,o,s]);return t.jsx(Fc.Provider,{value:a,children:e})}function tm({topRail:e,sidebar:r,main:n,statusBar:s,resizeHandle:o,banner:a,liveMessage:i,sidebarWidth:l=320,sidebarHidden:d=!1}){const u={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${l}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)"},p={display:"grid",gridTemplateColumns:d?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return t.jsxs("div",{className:"studio-shell",style:u,children:[a,t.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:e}),t.jsxs("div",{style:p,children:[!d&&t.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:o?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:r}),!d&&o,t.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:n})]}),t.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:s}),t.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:i??""})]})}const rm={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:(e,r)=>`${e} of ${r}`},nm={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"},sm={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:e=>`Couldn't load SKILL.md for ${e}.`,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:e=>`Viewing ${e} (Own)`,announceViewingInstalled:e=>`Viewing ${e} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},om={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",cloneToAuthoring:"Clone to authoring…",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},am={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"},im={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"},lm={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",cloneStarted:"Cloning to authoring…",cloneSucceeded:"Cloned to authoring.",cloneFailed:"Clone failed. Check eval-server logs.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",openingInEditor:"Opening in editor…",noEditor:"No editor found. Set $VISUAL or $EDITOR, or install code/cursor.",openFailed:"Could not open in editor.",skillNotFound:"Skill not found on disk.",uninstallNotImplemented:"Uninstall is not yet available from this menu.",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."},cm={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},dm={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},um={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},pm={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:e=>`No models match "${e}"`,clearSearch:"Clear",currentlyActive:"Currently active"},fm={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)."}},hm={subscriptionBilling:"· subscription",free:"· free"},mm={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:e=>`Keys stored at ${e} · 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:e=>`Remove ${e} API key?`,keyStoredAt:e=>`Key stored locally — updated ${e}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:e=>`This doesn't look like a typical ${e} key. Save anyway?`,keySaved:e=>`${e} API key saved (local only, never synced)`,keyRemoved:e=>`${e} API key removed`},xm={providersLabel:"Providers",providerSummary:(e,r)=>`${e}/${r} providers`,locked:e=>`${e} — locked. Click to add a key.`,lockedCli:e=>`${e} — locked. Click for install instructions.`,unlocked:e=>`${e} — unlocked.`},gm={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:e=>`Set up ${e}`,sharedFolderBanner:e=>`Shared folder — consumed by ${e}`},vm={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:e=>`No skills installed for ${e} in this project — run vskill install.`,emptyGlobal:e=>`No global skills for ${e} — run vskill install --global.`},ym={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"},bm={title:e=>`Set up ${e}`,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."},km={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},jm={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"}},_={sidebar:rm,shell:nm,detail:sm,actions:om,palette:am,shortcuts:im,toasts:lm,connection:cm,forms:dm,errors:um,picker:pm,providers:fm,models:hm,settings:mm,statusBar:xm,scopePicker:gm,scopeSection:vm,claudeCodeLabel:ym,setupDrawer:bm,setupProviders:jm,scopeLabels:km},ui=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],wm={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},Sm={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},Cm={"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"},Em={"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 Nm(e,r){var l,d;const n=wm[e.id]??null,s=Sm[e.id]??null,o=n?!!((l=r==null?void 0:r.wrapperFolders)!=null&&l[n]):!1,a=s?!!((d=r==null?void 0:r.binaries)!=null&&d[s]):!0,i=e.models.map(u=>({id:u.id,displayName:u.label,billingMode:Em[e.id]??"per-token",...u.pricing?{pricing:u.pricing}:{},...u.resolvedId?{resolvedId:u.resolvedId}:{}}));return{id:e.id,displayName:Rm(e.id,e.label),wrapperFolder:n,wrapperFolderPresent:o,binaryAvailable:a,endpointReachable:e.id==="ollama"||e.id==="lm-studio"?e.available:null,available:e.available,ctaType:e.available?null:Cm[e.id]??null,models:i,resolvedModel:e.resolvedModel??null}}function Rm(e,r){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"}[e]??r}function Tm(e){const r=new Map(e.map(s=>[s.id,s])),n=[];for(const s of ui){const o=r.get(s);o&&n.push(o)}for(const s of e)ui.includes(s.id)||n.push(s);return n}function Dc(e){const[r,n]=c.useState(null),[s,o]=c.useState("loading"),[a,i]=c.useState(null),[l,d]=c.useState(null),u=c.useRef(null),p=c.useRef(0),f=c.useRef(e==null?void 0:e.onStaleCatalog),h=c.useRef(e==null?void 0:e.onSetActiveError);c.useEffect(()=>{f.current=e==null?void 0:e.onStaleCatalog,h.current=e==null?void 0:e.onSetActiveError},[e==null?void 0:e.onStaleCatalog,e==null?void 0:e.onSetActiveError]);const m=c.useCallback(async()=>{try{const y=await fetch("/api/config");if(!y.ok)throw new Error(`/api/config returned ${y.status}`);const j=await y.json(),S=Tm((j.providers||[]).map(k=>Nm(k,j.detection)));n({agents:S,activeAgent:j.provider??null,activeModel:j.model??null}),o("ready"),i(null)}catch(y){o("error"),i(y.message)}},[]);c.useEffect(()=>{m()},[m]);const g=c.useCallback(async()=>{var j;const y=Date.now();if(!(y-p.current<5*6e4))try{const S=await fetch("/api/openrouter/models");if(!S.ok){S.status!==400&&d(`OpenRouter catalog fetch failed (${S.status})`);return}const k=await S.json();p.current=y,d(null),n(E=>{if(!E)return E;const N=E.agents.map(T=>{if(T.id!=="openrouter")return T;const A=(Array.isArray(k.models)?k.models:[]).filter(W=>W.id||W.name).map(W=>{const C=W.id||W.name;return{id:C,displayName:W.name??C,contextWindow:W.contextWindow,pricing:W.pricing,billingMode:"per-token"}});return{...T,models:A,catalogAgeMs:k.ageSec?k.ageSec*1e3:0,cacheStale:!!k.stale}});return{...E,agents:N}});const R=k.ageSec??0;(k.stale===!0||R>600)&&((j=f.current)==null||j.call(f,"openrouter",R*1e3))}catch(S){d(`OpenRouter catalog unreachable: ${S.message}`)}},[]),v=c.useCallback(y=>{u.current=y,y==="openrouter"&&g()},[g]),x=c.useCallback(()=>{p.current=0,m()},[m]),b=c.useCallback(async(y,j)=>{var R,w;let S;try{S=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:y,model:j})})}catch(E){(R=h.current)==null||R.call(h,`Network error while setting ${y}: ${E.message}`);return}if(S.ok){n(E=>E&&{...E,activeAgent:y,activeModel:j});return}let k=`Failed to set ${y} (${S.status})`;try{const E=await S.json();E&&typeof E.error=="string"&&(k=E.error)}catch{}(w=h.current)==null||w.call(h,k)},[]);return{status:s,catalog:r,error:a,openRouterError:l,focusAgent:v,refresh:x,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:b}}function Os({variant:e,label:r,onActivate:n,installUrl:s,tooltip:o}){function a(l){if(l.stopPropagation(),e==="cli-install"&&s){window.open(s,"_blank","noopener,noreferrer");return}n()}function i(l){(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a(l))}return t.jsx("button",{type:"button","data-testid":`locked-cta-${e}`,onClick:a,onKeyDown:i,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":r,...o?{title:o}:{},children:r})}function Wo({unlocked:e=!1,size:r=10}){return e?t.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),t.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):t.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),t.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const Im=new Set(["claude-cli","claude-code"]);function pi(e){return Im.has(e)}const fi=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function Lm({agents:e,activeAgentId:r,focusedAgentId:n,onFocus:s,onSelect:o,onOpenSettings:a}){const i=e.filter(d=>fi.has(d.id)),l=e.filter(d=>!fi.has(d.id));return t.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:[i.map(d=>t.jsx(hi,{agent:d,isActive:d.id===r,isFocused:d.id===n,onFocus:s,onSelect:o,onOpenSettings:a},d.id)),l.length>0&&t.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),l.map(d=>t.jsx(hi,{agent:d,isActive:d.id===r,isFocused:d.id===n,onFocus:s,onSelect:o,onOpenSettings:a},d.id))]})}function hi({agent:e,isActive:r,isFocused:n,onFocus:s,onSelect:o,onOpenSettings:a}){const{providers:i}=_,l={"claude-cli":i.claudeCli.caption,anthropic:i.anthropic.caption,openrouter:i.openrouter.caption},d={"claude-cli":{label:i.claudeCli.installCta,url:i.claudeCli.installUrl},cursor:{label:i.cursor.installCta},"codex-cli":{label:i.codexCli.installCta},"gemini-cli":{label:i.geminiCli.installCta},copilot:{label:i.copilot.installCta},zed:{label:i.zed.installCta}},u=pi(e.id),p={minHeight:36,height:u?"auto":36,padding:u?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:n?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:r?500:400,color:"var(--text-primary)"};return r&&(p.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),t.jsxs("div",{role:"option","aria-selected":r,"data-testid":`agent-row-${e.id}`,"data-focused":n||void 0,tabIndex:n?0:-1,onMouseEnter:()=>s(e.id),onFocus:()=>s(e.id),onClick:()=>o(e.id),style:p,children:[e.wrapperFolder&&t.jsx("span",{"data-testid":`wrapper-dot-${e.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:e.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:e.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!e.wrapperFolder&&t.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),t.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.displayName}),pi(e.id)&&t.jsx("span",{"data-testid":"claude-code-billing-label",title:_.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:_.claudeCodeLabel.compactLabel})]}),t.jsx("span",{"aria-label":e.available?"available":"locked",style:{color:e.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:e.available?t.jsx(Wo,{unlocked:!0,size:10}):t.jsx(Wo,{size:10})}),r&&t.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${e.id}`,children:_.picker.currentlyActive}),!e.available&&e.ctaType==="api-key"&&t.jsx(Os,{variant:"api-key",label:e.id==="anthropic"?i.anthropic.addKeyCta:i.openrouter.addKeyCta,onActivate:()=>a(e.id)}),!e.available&&e.ctaType==="cli-install"&&d[e.id]&&t.jsx(Os,{variant:"cli-install",label:d[e.id].label,installUrl:d[e.id].url,onActivate:()=>{}}),!e.available&&e.ctaType==="start-service"&&t.jsx(Os,{variant:"start-service",label:e.id==="ollama"?i.ollama.startServiceCta:i.lmStudio.startServiceCta,onActivate:()=>a(e.id)}),l[e.id]&&t.jsx("span",{className:"sr-only","data-testid":`caption-${e.id}`,children:l[e.id]})]})}function Am(e,r,n,s){const i=e>=80,l=c.useRef(null),[d,u]=c.useState(0),p=c.useCallback(m=>{u(m.currentTarget.scrollTop)},[]),{visibleStart:f,visibleEnd:h}=c.useMemo(()=>{if(!i)return{visibleStart:0,visibleEnd:e};const m=Math.max(0,Math.floor(d/r)-4),g=Math.ceil(n/r)+8,v=Math.min(e,m+g);return{visibleStart:m,visibleEnd:v}},[i,d,r,n,e,4]);return{visibleStart:f,visibleEnd:h,totalHeight:e*r,offsetTop:f*r,virtualised:i,containerProps:{onScroll:p,ref:l,style:{overflowY:"auto",maxHeight:n,willChange:i?"transform":void 0}}}}const zc=44,Pm=352,$m=60,mi=480;function Mm(e){var a,i;const r=e.contextWindow?e.contextWindow>=1e6?`${Math.round(e.contextWindow/1e6)}M`:e.contextWindow>=1e3?`${Math.round(e.contextWindow/1e3)}k`:String(e.contextWindow):null;if(e.billingMode==="subscription")return r?`${r} ctx ${_.models.subscriptionBilling}`:_.models.subscriptionBilling.trim();if(e.billingMode==="free")return r?`local · ${r} ctx · free`:"local · free";const n=((a=e.pricing)==null?void 0:a.prompt)??0,s=((i=e.pricing)==null?void 0:i.completion)??0,o=`$${n.toFixed(2)} / $${s.toFixed(2)} per 1M tokens`;return r?`${r} ctx · ${o}`:o}function Ws(e){return e.displayName??e.id??""}function Fm(e,r){if(!r)return e;const n=r.toLowerCase();return e.filter(o=>Ws(o).toLowerCase().includes(n)).sort((o,a)=>{const i=Ws(o),l=Ws(a),d=i.toLowerCase().indexOf(n),u=l.toLowerCase().indexOf(n);return d!==u?d-u:i.length-l.length})}function Dm({agent:e,activeModelId:r,focusedIndex:n=-1,onSelect:s,onOpenSettings:o}){const[a,i]=c.useState(""),[l,d]=c.useState(""),u=c.useRef(null);c.useEffect(()=>{const h=setTimeout(()=>d(a),$m);return()=>clearTimeout(h)},[a]),c.useEffect(()=>{e.id==="openrouter"&&e.available&&u.current&&u.current.focus()},[e.id,e.available]);const p=c.useMemo(()=>Fm(e.models,l),[e.models,l]),f=Am(p.length,zc,Pm);return e.id==="openrouter"&&!e.available?t.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:mi,padding:20,display:"flex",flexDirection:"column",gap:12},children:[t.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:_.providers.openrouter.emptyCardBody}),t.jsx("button",{type:"button",onClick:()=>o("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:_.providers.openrouter.addKeyCta})]}):t.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:mi,display:"flex",flexDirection:"column"},children:[e.id==="openrouter"&&t.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:t.jsx("input",{ref:u,type:"text",placeholder:_.picker.searchPlaceholder,value:a,onChange:h=>i(h.target.value),"data-testid":"model-search-input","aria-label":_.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"}})}),p.length===0&&l?t.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[t.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:_.picker.noMatches(l)}),t.jsx("button",{type:"button",onClick:()=>i(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:_.picker.clearSearch})]}):p.length===0?t.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:_.picker.noModelsYet}):t.jsx("div",{...f.containerProps,children:t.jsx("div",{style:{height:f.virtualised?f.totalHeight:"auto",position:"relative"},children:t.jsx("div",{style:{transform:f.virtualised?`translateY(${f.offsetTop}px)`:void 0},children:p.slice(f.visibleStart,f.visibleEnd).map((h,m)=>{const g=f.visibleStart+m;return t.jsx(Bm,{model:h,isActive:h.id===r,isFocused:n===g,onSelect:()=>s(h.id),resolvedModel:e.id==="claude-cli"?e.resolvedModel??null:null},h.id)})})})})]})}function zm(e,r,n){return r&&r.toLowerCase().includes(e.toLowerCase())?r:n??null}function Bm({model:e,isActive:r,isFocused:n,onSelect:s,resolvedModel:o}){const a=Mm(e),i=zm(e.id,o,e.resolvedId),l=i!==null,d=r?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":n?"var(--surface-muted, var(--surface-3))":"transparent",u=r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return t.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":`model-row-${e.id}`,"data-focused":n||void 0,onClick:s,title:e.id,style:{width:"100%",minHeight:zc,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:d,borderLeft:u,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[t.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:e.displayName}),t.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:a}),l&&t.jsxs("span",{"data-testid":`model-row-${e.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",i]})]})}const xi={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function _m(){const[e,r]=c.useState(null),[n,s]=c.useState(!0),[o,a]=c.useState(null),i=c.useCallback(async()=>{s(!0);try{const u=await fetch("/api/settings/keys");if(!u.ok)throw new Error(`GET /api/settings/keys returned ${u.status}`);const p=await u.json();r({...xi,...p}),a(null)}catch(u){a(u.message),r(xi)}finally{s(!1)}},[]);c.useEffect(()=>{i()},[i]);const l=c.useCallback(async(u,p)=>{const f=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u,key:p})});if(!f.ok){const m=await f.json().catch(()=>({error:f.statusText}));throw new Error(m.error||`POST /api/settings/keys returned ${f.status}`)}const h=await f.json();return await i(),h},[i]),d=c.useCallback(async u=>{const p=await fetch(`/api/settings/keys/${u}`,{method:"DELETE"});if(!p.ok)throw new Error(`DELETE /api/settings/keys/${u} returned ${p.status}`);await i()},[i]);return{state:e,loading:n,error:o,save:l,remove:d,refresh:i}}function Om({onMigrated:e,fetchImpl:r}){const[n,s]=c.useState({kind:"loading"}),o=r??globalThis.fetch,a=c.useCallback(async()=>{var u;try{const p=await o("/api/settings/migration-status");if(!p.ok){s({kind:"hidden"});return}const f=await p.json();f.pending&&(((u=f.darwinKeys)==null?void 0:u.length)??0)>0?s({kind:"visible",darwinKeys:f.darwinKeys??[]}):s({kind:"hidden"})}catch{s({kind:"hidden"})}},[o]);c.useEffect(()=>{a()},[a]);const i=c.useCallback(async()=>{s({kind:"working"});try{const u=await o("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!u.ok){s({kind:"error",message:`Migration failed (${u.status})`});return}const p=await u.json().catch(()=>({migrated:[]}));e==null||e(p.migrated??[]),await a()}catch(u){s({kind:"error",message:u.message})}},[o,a,e]),l=c.useCallback(async()=>{s({kind:"hidden"});try{await o("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[o]);if(n.kind==="loading"||n.kind==="hidden")return null;if(n.kind==="error")return t.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:[t.jsx("span",{style:{flex:1},children:n.message}),t.jsx("button",{type:"button",onClick:()=>void a(),"data-testid":"migration-retry",style:Us,children:"Retry"})]});const d=n.kind==="working";return t.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:[t.jsxs("div",{style:{flex:1},children:[t.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),t.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."})]}),t.jsx("button",{type:"button",onClick:()=>void i(),disabled:d,"data-testid":"migration-migrate",style:{...Us,background:"var(--accent, var(--color-accent))",color:"white",opacity:d?.6:1},children:d?"Importing…":"Migrate"}),t.jsx("button",{type:"button",onClick:()=>void l(),"data-testid":"migration-dismiss",style:{...Us,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Us={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Wm=[{id:"anthropic",name:_.providers.anthropic.name,keyIssuanceUrl:_.providers.anthropic.keyIssuanceUrl,prefix:_.providers.anthropic.keyPrefix,placeholder:`Paste ${_.providers.anthropic.name} key`},{id:"openai",name:_.providers.openai.name,keyIssuanceUrl:_.providers.openai.keyIssuanceUrl,prefix:_.providers.openai.keyPrefix,placeholder:_.providers.openai.pastePlaceholder},{id:"openrouter",name:_.providers.openrouter.name,keyIssuanceUrl:_.providers.openrouter.keyIssuanceUrl,prefix:_.providers.openrouter.keyPrefix,placeholder:`Paste ${_.providers.openrouter.name} key`}];function Um(e){const r=Date.now()-new Date(e).getTime();return r<6e4?"just now":r<36e5?`${Math.round(r/6e4)}m ago`:r<864e5?`${Math.round(r/36e5)}h ago`:new Date(e).toLocaleString()}function Bc({open:e,onClose:r,initialProvider:n,onToast:s}){const{state:o,save:a,remove:i,refresh:l}=_m(),d=c.useRef(null),u=c.useRef(null),[p,f]=c.useState(null);c.useEffect(()=>{if(!e)return;let m=!1;return(async()=>{try{const g=await fetch("/api/settings/storage-path");if(!g.ok)throw new Error(`GET /api/settings/storage-path returned ${g.status}`);const v=await g.json();m||f(v.path??null)}catch{m||f(null)}})(),()=>{m=!0}},[e]),c.useEffect(()=>{if(!e)return;const m=document.activeElement,g=setTimeout(()=>{var b;const v=n?`input[data-provider="${n}"]`:"input[data-provider]",x=(b=d.current)==null?void 0:b.querySelector(v);x==null||x.focus()},0);return()=>{var v;clearTimeout(g),(v=m==null?void 0:m.focus)==null||v.call(m)}},[e,n]),c.useEffect(()=>{if(!e)return;const m=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),r();return}if(g.key==="Tab"&&d.current){g.stopPropagation();const v=d.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(v.length===0)return;const x=v[0],b=v[v.length-1];g.shiftKey&&document.activeElement===x?(g.preventDefault(),b.focus()):!g.shiftKey&&document.activeElement===b&&(g.preventDefault(),x.focus())}};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[e,r]);const h=c.useCallback(async()=>{var m,g;if(p)try{await((g=(m=navigator.clipboard)==null?void 0:m.writeText)==null?void 0:g.call(m,p)),s==null||s(_.settings.pathCopied)}catch{}},[s,p]);return e?t.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:10080},onClick:m=>{m.target===m.currentTarget&&r()},children:t.jsxs("div",{ref:d,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:m=>m.stopPropagation(),children:[t.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:_.settings.title}),t.jsx(Om,{onMigrated:()=>{l()}}),t.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:_.settings.banner}),t.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[t.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:_.settings.sectionApiKeys}),Wm.map(m=>t.jsx(Hm,{providerId:m.id,providerName:m.name,keyIssuanceUrl:m.keyIssuanceUrl,prefix:m.prefix,placeholder:m.placeholder,metadata:o==null?void 0:o[m.id],onSave:async g=>{const v=await a(m.id,g);return s==null||s(_.settings.keySaved(m.name)),v},onRemove:async()=>{await i(m.id),s==null||s(_.settings.keyRemoved(m.name))},inputRef:m.id===(n??"anthropic")?u:void 0},m.id))]}),t.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:[t.jsx("span",{style:{flex:1},children:p?_.settings.storagePath(p):_.settings.storagePathFallback}),t.jsx("button",{type:"button",onClick:h,disabled:!p,"data-testid":"settings-copy-path",style:{...mr,opacity:p?1:.5,cursor:p?"pointer":"not-allowed"},children:_.settings.copyPath})]}),t.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{type:"button",onClick:r,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 Hm({providerId:e,providerName:r,keyIssuanceUrl:n,prefix:s,placeholder:o,metadata:a,onSave:i,onRemove:l,inputRef:d}){const[u,p]=c.useState(""),[f,h]=c.useState(!1),[m,g]=c.useState(!1),[v,x]=c.useState(!1),[b,y]=c.useState(null),j=u.trim(),S=j.length===0,k=j.length>0&&!j.startsWith(s),R=c.useCallback(async()=>{if(S)return;g(!0);const N=j;p("");try{const T=await i(N);T.warning?y(T.warning):y(null)}finally{g(!1)}},[S,i,j]),w=c.useCallback(async()=>{var N;try{if(!((N=navigator.clipboard)!=null&&N.readText))return;const T=await navigator.clipboard.readText();p(T)}catch{}},[]),E=c.useCallback(async()=>{x(!1),await l()},[l]);return t.jsxs("div",{"data-testid":`provider-row-${e}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("strong",{style:{fontSize:13},children:r}),t.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{ref:d,type:f?"text":"password",value:u,onChange:N=>{p(N.target.value),y(null)},"data-provider":e,placeholder:o,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"}}),t.jsx("button",{type:"button",onClick:()=>h(!f),style:mr,children:f?_.settings.hide:_.settings.show}),t.jsx("button",{type:"button",onClick:w,style:mr,children:_.settings.paste})]}),k&&t.jsx("div",{role:"status","data-testid":`prefix-warn-${e}`,style:gi,children:_.settings.prefixWarn(r)}),b&&t.jsx("div",{role:"status",style:gi,children:b}),t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[t.jsx("button",{type:"button",onClick:R,disabled:S||m,"data-testid":`save-${e}`,style:{...mr,background:S?"var(--surface-2)":"var(--accent, var(--color-accent))",color:S?"var(--text-muted)":"white",cursor:S?"not-allowed":"pointer"},children:_.settings.save}),(a==null?void 0:a.stored)&&t.jsx(t.Fragment,{children:v?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:12},children:_.settings.removeConfirm(r)}),t.jsx("button",{type:"button",onClick:E,"data-testid":`remove-confirm-${e}`,style:{...mr,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),t.jsx("button",{type:"button",onClick:()=>x(!1),style:mr,children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>x(!0),"data-testid":`remove-${e}`,style:{...mr,color:"var(--text-muted)"},children:_.settings.remove})}),t.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${e}`,children:a!=null&&a.stored&&a.updatedAt?_.settings.keyStoredAt(Um(a.updatedAt)):_.settings.noKey})]})]})}const mr={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},gi={fontSize:11,color:"var(--warning, var(--text-muted))"};function Vm(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Gm({onToast:e}){const{status:r,catalog:n,focusAgent:s,setActive:o}=Dc({onStaleCatalog:(T,I)=>{const A=Math.round(I/6e4);e==null||e(`Using cached ${T} catalog (${A} min old)`)},onSetActiveError:T=>e==null?void 0:e(T)}),[a,i]=c.useState(!1),[l,d]=c.useState(!1),[u,p]=c.useState(),[f,h]=c.useState(null),[m,g]=c.useState("agents"),[v,x]=c.useState(0),b=c.useRef(null);c.useRef(null),c.useEffect(()=>{var T;n&&!f&&h(n.activeAgent??((T=n.agents[0])==null?void 0:T.id)??null)},[n,f]);const y=(n==null?void 0:n.agents)??[],j=c.useMemo(()=>y.find(T=>T.id===f)??y[0],[y,f]);c.useEffect(()=>{x(0)},[f]);const S=c.useCallback(()=>{var T;i(!0),g("agents"),h((n==null?void 0:n.activeAgent)??((T=y[0])==null?void 0:T.id)??null),x(0)},[n,y]),k=c.useCallback(()=>{var T;i(!1),(T=b.current)==null||T.focus()},[]);c.useEffect(()=>{const T=()=>i(I=>!I);return window.addEventListener("openAgentModelPicker",T),()=>{window.removeEventListener("openAgentModelPicker",T)}},[]),c.useEffect(()=>{if(!a)return;const T=A=>{if(A.key==="Escape"){A.preventDefault(),k();return}if(A.key==="ArrowDown"){A.preventDefault(),I(1);return}if(A.key==="ArrowUp"){A.preventDefault(),I(-1);return}if(A.key==="ArrowRight"&&m==="agents"){A.preventDefault(),g("models"),x($=>{const W=((j==null?void 0:j.models.length)??1)-1;return Math.max(0,Math.min($,Math.max(0,W)))});return}if(A.key==="ArrowLeft"&&m==="models"){A.preventDefault(),g("agents");return}if(A.key==="Enter"){if(A.preventDefault(),m==="agents"&&j)g("models"),x(0);else if(m==="models"&&j){const $=Math.max(0,Math.min(j.models.length-1,v)),W=j.models[$];W&&(o(j.id,W.id),k())}return}};function I(A){if(m==="agents"){const $=y.findIndex(C=>C.id===f),W=y[Math.max(0,Math.min(y.length-1,$+A))];W&&(h(W.id),s(W.id));return}if(m==="models"&&j){const $=j.models.length;if($===0)return;x(W=>{const C=W+A;return Math.max(0,Math.min($-1,C))})}}return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[a,m,y,f,j,v,k,s,o]);const R=c.useCallback(T=>{p(T==="anthropic"||T==="openrouter"?T:void 0),d(!0),i(!1)},[]),w=y.find(T=>T.id===(n==null?void 0:n.activeAgent)),E=w==null?void 0:w.models.find(T=>T.id===(n==null?void 0:n.activeModel)),N=c.useMemo(()=>{if(r!=="ready"||!n)return"Loading…";const T=(w==null?void 0:w.displayName)??"Agent",I=(E==null?void 0:E.displayName)??n.activeModel??"Model";return`${T} · ${I}`},[r,n,w,E]);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:b,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>a?k():S(),"aria-haspopup":"listbox","aria-expanded":a,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:[t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),t.jsx("span",{children:N})]}),a&&typeof document<"u"&&Ur.createPortal(t.jsxs(Km,{reducedMotion:Vm(),onClickOutside:k,children:[t.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[t.jsx(Lm,{agents:y,activeAgentId:(n==null?void 0:n.activeAgent)??null,focusedAgentId:f,onFocus:T=>{h(T),s(T)},onSelect:T=>{h(T),s(T),g("models")},onOpenSettings:R}),j&&t.jsx(Dm,{agent:j,activeModelId:(n==null?void 0:n.activeModel)??null,focusedIndex:m==="models"?v:-1,onSelect:T=>{o(j.id,T),k()},onOpenSettings:R})]}),t.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:[t.jsx("button",{type:"button",onClick:()=>R(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:_.picker.settingsButton}),t.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:_.picker.footerHint})]})]}),document.body),t.jsx(Bc,{open:l,onClose:()=>d(!1),initialProvider:u,onToast:e})]})}function Km({children:e,reducedMotion:r,onClickOutside:n}){const s=c.useRef(null);return c.useEffect(()=>{const o=a=>{s.current&&!s.current.contains(a.target)&&n()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[n]),t.jsxs("div",{ref:s,"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:r?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[e,t.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
16
|
+
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
17
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
18
|
+
}`})]})}const Hs="#F25F1C";function vi(){typeof window>"u"||(window.location.hash="#/")}function qm({onHome:e}){const[r,n]=c.useState(!1),[s,o]=c.useState(!1),a=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.button!==0||(l.preventDefault(),vi(),e==null||e())},i=l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),vi(),e==null||e())};return t.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:a,onKeyDown:i,onFocus:()=>n(!0),onBlur:()=>n(!1),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:8,flexShrink:0,padding:"4px 8px",margin:"-4px -8px",borderRadius:8,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:s?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[t.jsxs("svg",{width:22,height:22,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",style:{display:"block",flexShrink:0,overflow:"visible"},children:[t.jsx("path",{d:"M12 3.25c-3.59 0-6.5 2.91-6.5 6.5v3.18c0 .67-.21 1.32-.6 1.86l-1.27 1.78c-.49.69 0 1.65.84 1.65h15.06c.84 0 1.33-.96.84-1.65l-1.27-1.78c-.39-.54-.6-1.19-.6-1.86V9.75c0-3.59-2.91-6.5-6.5-6.5z",fill:Hs}),t.jsx("path",{d:"M9.75 19.4h4.5a2.25 2.25 0 11-4.5 0z",fill:Hs}),t.jsx("circle",{cx:"18.5",cy:"5.5",r:"2.75",fill:Hs,stroke:"var(--surface-base, #ffffff)",strokeWidth:"1"})]}),t.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1,color:"var(--text-primary)"},children:"Skill Studio"})]})}const yi=c.memo(function({message:r,politeness:n="polite",role:s}){const o=s??(n==="assertive"?"alert":"status");return t.jsx("div",{"aria-live":n,"aria-atomic":"true",role:o,"data-testid":"aria-live","data-politeness":n,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:r})});function Ym({toast:e,onDismiss:r}){const[n,s]=c.useState(!0),o=c.useRef(null);c.useEffect(()=>(o.current=requestAnimationFrame(()=>{o.current=requestAnimationFrame(()=>s(!1))}),()=>{o.current!=null&&cancelAnimationFrame(o.current)}),[]);const a={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return t.jsxs("div",{role:e.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":e.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 ${a[e.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:n?"translateY(8px)":"translateY(0)",opacity:n?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[t.jsx("span",{style:{flex:1,minWidth:0},children:e.message}),e.action&&t.jsx("button",{type:"button",onClick:()=>{e.action.onInvoke(),r(e.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:e.action.label}),t.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>r(e.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function Jm({toasts:e,onDismiss:r,liveMessage:n,liveAssertiveMessage:s}){return t.jsxs(t.Fragment,{children:[t.jsx(yi,{politeness:"polite",message:n}),t.jsx(yi,{politeness:"assertive",message:s}),e.length>0&&t.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:2e4,pointerEvents:"none"},children:e.map(o=>t.jsx("div",{style:{pointerEvents:"auto"},children:t.jsx(Ym,{toast:o,onDismiss:r})},o.id))})]})}const _c=c.createContext(null);function ys(){const e=c.useContext(_c);if(!e)throw new Error("useToast must be used inside <ToastProvider>.");return e}function Qm({children:e,maxVisible:r=4,defaultDurationMs:n=4e3}){const[s,o]=c.useState([]),[a,i]=c.useState(""),[l,d]=c.useState(""),u=c.useRef(new Map),p=c.useCallback(x=>{const b=u.current.get(x);b&&(clearTimeout(b),u.current.delete(x)),o(y=>y.filter(j=>j.id!==x))},[]),f=c.useCallback((x,b)=>{if(b<=0)return;const y=setTimeout(()=>{p(x)},b);u.current.set(x,y)},[p]),h=c.useCallback(x=>{const b=x.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,y={id:b,message:x.message,severity:x.severity??"info",durationMs:x.durationMs??n,action:x.action};return o(j=>[...j,y]),y.severity==="error"?d(y.message):i(y.message),f(b,y.durationMs),b},[n,f]),m=c.useCallback(()=>{for(const x of u.current.values())clearTimeout(x);u.current.clear(),o([])},[]);c.useEffect(()=>{function x(b){b.key==="Escape"&&o(y=>{if(y.length===0)return y;const j=y.slice(0,r),S=j[j.length-1],k=u.current.get(S.id);return k&&(clearTimeout(k),u.current.delete(S.id)),y.filter(R=>R.id!==S.id)})}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[r]),c.useEffect(()=>()=>{for(const x of u.current.values())clearTimeout(x);u.current.clear()},[]);const g=s.slice(0,r),v=c.useMemo(()=>({toast:h,dismiss:p,clear:m}),[h,p,m]);return t.jsxs(_c.Provider,{value:v,children:[e,t.jsx(Jm,{toasts:g,onDismiss:p,liveMessage:a,liveAssertiveMessage:l})]})}function Xm(){const{data:e,loading:r}=It("platform-health",async()=>{const n=await fetch("/api/platform/health");return n.ok?await n.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:e,loading:r}}const Zm=c.lazy(()=>ar(()=>import("./UpdateDropdown-VRCYPtXG.js"),__vite__mapDeps([2,3,4,5,6])));function ex(e){switch(e){case"connected":return"connected";case"fallback":return"reconnecting";case"connecting":default:return"connecting"}}function tx(e){switch(e){case"connected":return"var(--status-success-text)";case"fallback":return"var(--color-own)";case"connecting":default:return"var(--text-secondary)"}}function rx(){const{updateCount:e,updates:r,isRefreshingUpdates:n,refreshUpdates:s,selectSkill:o,revealSkill:a,skills:i,updatesById:l,activeAgent:d,updateStreamStatus:u,trackedSkillCount:p}=Pt(),{toast:f}=ys(),{data:h}=Xm(),m=(h==null?void 0:h.degraded)===!0,g=c.useId(),v=u??"connecting",x=typeof p=="number"?p:null,b=x===null?!0:x>0,y=c.useMemo(()=>{if(!l||l.size===0)return;const A=new Map;for(const[$,W]of l)W.diffSummary&&A.set($,W.diffSummary);return A.size>0?A:void 0},[l]),[j,S]=c.useState(!1),k=c.useRef(null),R=c.useCallback(()=>S(!1),[]),w=m?"var(--color-own)":e>0?"var(--text-primary)":"var(--text-secondary)",E=e>9?"9+":String(e),N=e===0?"No updates available":`${e} updates available, open summary`,T=m?`${N} — platform crawler degraded`:N,I=m?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return t.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[t.jsxs("button",{ref:k,type:"button","data-testid":"update-bell","aria-label":T,"aria-haspopup":"dialog","aria-expanded":j,"aria-describedby":g,title:I,onClick:()=>S(A=>!A),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:w,cursor:"pointer"},children:[t.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:e>0||m?1:.75,color:w},children:[t.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"}),t.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),t.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),e>0&&t.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:E}),b&&t.jsx("span",{"data-testid":"update-bell-status-pip","aria-hidden":"true",style:{position:"absolute",bottom:-1,right:-1,width:6,height:6,borderRadius:999,background:tx(v),border:"1px solid var(--color-paper)",display:"inline-block",lineHeight:0}})]}),t.jsx("span",{id:g,"data-testid":"update-bell-status-text",style:{position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},children:`Live updates: ${ex(v)}`}),j&&t.jsx(c.Suspense,{fallback:t.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:t.jsx(Zm,{updates:r,isRefreshing:n,diffSummariesById:y,onRefresh:()=>s(),onSelectSkill:A=>{const $=A.localSkill??A.name.split("/").pop()??"",W=A.localPlugin??"";if(a)a(W,$);else{const P=A.name.split("/"),L=P.length>=2?P[P.length-2]:P[0];o({plugin:L,skill:$,origin:"installed"})}if(!(i??[]).some(P=>P.skill===$&&(W===""||P.plugin===W))){const P=A.installLocations??[];if(P.length>0){const L=d?P.filter(H=>H.agent===d):[],F=d?P.filter(H=>H.agent!==d):P;if(L.length>0&&F.length>0){const H=F.length>=2?`Also installed under ${F.length} other locations.`:`Also installed under ${F[0].agentLabel}.`;f({severity:"info",message:H})}else{const H=P[0].agentLabel;f({severity:"info",message:`Skill installed under ${H} — switch to ${H} to view details.`})}}}R()},onViewAll:()=>{window.location.hash="#/updates",R()},onClose:R,anchorRef:k})})]})}function bi(e){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:e}))}function nx(e){return e.source==="project"?_.scopeLabels.sourceProject:e.source==="personal"?_.scopeLabels.sourcePersonal:e.source==="plugin"?_.scopeLabels.sourcePlugin:e.origin==="installed"?_.scopeLabels.sourcePersonal:_.scopeLabels.sourceProject}function sx(e){return e.source==="project"?"var(--status-installed)":e.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)"}function ox({projectName:e,selected:r,onHome:n,projectPickerSlot:s,onRequestCreateSkill:o,findSkillsSlot:a,userDropdownSlot:i,appUpdateSlot:l}){const d=r?nx(r):null,u=r?sx(r):"var(--text-secondary)";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[t.jsx(qm,{onHome:n}),s?t.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:s}):e&&t.jsx("span",{title:e,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),l&&t.jsx("span",{"data-slot":"app-update",style:{display:"inline-flex",flexShrink:0},children:l})]}),t.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&d&&t.jsxs(t.Fragment,{children:[t.jsx(ki,{segment:"origin",onClick:()=>bi({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:u},children:d}),t.jsx(ji,{}),t.jsx(ki,{segment:"plugin",onClick:()=>bi({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),t.jsx(ji,{}),t.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),t.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:12,flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a,o&&t.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:o,"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:[t.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:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]})]}),t.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"var(--border-default)"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:t.jsx(Gm,{})}),t.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:t.jsx(rx,{})}),i&&t.jsx("span",{"data-slot":"user-dropdown",style:{display:"inline-flex"},children:i})]})]})]})}function ki({segment:e,onClick:r,style:n,children:s}){return t.jsx("button",{type:"button","data-breadcrumb-segment":e,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...n},onMouseEnter:o=>{o.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:o=>{const a=(n==null?void 0:n.color)??"var(--text-secondary)";o.currentTarget.style.color=a},children:s})}function ji(){return t.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const bs="vskill-theme";function Oc(e){return e==="light"||e==="dark"||e==="auto"?e:"auto"}function ax(e,r){return e==="light"||e==="dark"?e:r?"dark":"light"}function ix(e){try{const r=e.getItem(bs);return Oc(r)}catch{return"auto"}}function lx(e,r){try{e.setItem(bs,r)}catch{}}function cx(e,r,n){e.dataset.theme=n,e.dataset.themeMode=r}function dx(e){if(!e)return!1;try{return e("(prefers-color-scheme: dark)").matches}catch{return!1}}const Wc=c.createContext(null);function ux({storage:e,matchMedia:r,target:n,children:s}){const o=e??(typeof window<"u"?window.localStorage:void 0),a=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),i=n??(typeof document<"u"?document.documentElement:void 0),[l,d]=c.useState(()=>o?ix(o):"auto"),[u,p]=c.useState(()=>dx(a)),f=c.useMemo(()=>ax(l,u),[l,u]);c.useEffect(()=>{i&&cx(i,l,f)},[i,l,f]),c.useEffect(()=>{if(!a)return;const g=a("(prefers-color-scheme: dark)"),v=b=>p(b.matches);if(typeof g.addEventListener=="function")return g.addEventListener("change",v),()=>g.removeEventListener("change",v);const x=g;return x.addListener(v),()=>x.removeListener(v)},[a]),c.useEffect(()=>{if(typeof window>"u")return;const g=v=>{v.key===bs&&d(Oc(v.newValue))};return window.addEventListener("storage",g),()=>window.removeEventListener("storage",g)},[]),c.useEffect(()=>{if(!a||!i)return;let g;try{g=a("(prefers-contrast: more)")}catch{return}const v=y=>{y?i.dataset.contrast="more":i.dataset.contrast==="more"&&delete i.dataset.contrast};v(g.matches);const x=y=>v(y.matches);if(typeof g.addEventListener=="function")return g.addEventListener("change",x),()=>g.removeEventListener("change",x);const b=g;return b.addListener(x),()=>b.removeListener(x)},[a,i]);const h=c.useCallback(g=>{d(g),o&&lx(o,g)},[o]),m=c.useMemo(()=>({mode:l,resolvedTheme:f,setTheme:h}),[l,f,h]);return t.jsx(Wc.Provider,{value:m,children:s})}function Uc(){const e=c.useContext(Wc);if(!e)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return e}const wi=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function px(e){const r=new Map(e.map(s=>[s.id,s])),n=[];for(const s of wi){const o=r.get(s);o&&n.push(o)}for(const s of e)wi.includes(s.id)||n.push(s);return n}function fx(e){const[r,n]=c.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${e}px)`).matches);return c.useEffect(()=>{var a;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(`(max-width: ${e}px)`),o=()=>n(s.matches);return(a=s.addEventListener)==null||a.call(s,"change",o),()=>{var i;return(i=s.removeEventListener)==null?void 0:i.call(s,"change",o)}},[e]),r}function hx({providers:e,onOpenSettings:r,onOpenInstallHelp:n}){const s=px(e),o=fx(640),[a,i]=c.useState(!1),l=c.useCallback(d=>{d.available||d.kind==="api-key"?r==null||r(d.id):n==null||n(d.id)},[r,n]);if(o){const d=s.filter(u=>u.available).length;return t.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[t.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>i(!a),"aria-label":_.statusBar.providerSummary(d,s.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:_.statusBar.providerSummary(d,s.length)}),a&&t.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:s.map(u=>t.jsx(Si,{p:u,onClick:l},u.id))})]})}return t.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:s.map(d=>t.jsx(Si,{p:d,onClick:l,compact:!0},d.id))})}function Si({p:e,onClick:r,compact:n}){const s=e.available?_.statusBar.unlocked(e.label):e.kind==="cli-install"?_.statusBar.lockedCli(e.label):_.statusBar.locked(e.label);return t.jsxs("button",{type:"button","data-testid":`provider-glyph-${e.id}`,"data-available":e.available,"aria-label":s,title:s,onClick:()=>r(e),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:e.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:n?"2px":"4px 6px",fontSize:11},children:[t.jsx(Wo,{unlocked:e.available,size:10}),!n&&t.jsx("span",{children:e.label})]})}function mx(){try{return typeof localStorage>"u"?null:localStorage.getItem(bs)}catch{return null}}function xx({projectPath:e,modelName:r,health:n="ok",onPathClick:s,providers:o,onOpenProviderSettings:a,onOpenProviderInstallHelp:i}){const{mode:l,resolvedTheme:d,setTheme:u}=Uc(),f=mx()==="auto",h=gx(l,d,f),m=n==="down"||n==="degraded"?"var(--status-own)":"var(--status-installed)";return t.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:[t.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),t.jsx(Ci,{}),t.jsxs("span",{"aria-label":`Health: ${n}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[t.jsx(vx,{color:m}),t.jsx("span",{style:{textTransform:"capitalize"},children:n})]}),o&&o.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ci,{}),t.jsx(hx,{providers:o,onOpenSettings:a,onOpenInstallHelp:i})]}),t.jsx("div",{style:{flex:1}}),t.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>u(h),"aria-label":`Switch to ${h} theme`,title:`Theme: ${l} — click for ${h}`,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:[t.jsx(yx,{mode:l}),t.jsx("span",{style:{textTransform:"capitalize"},children:l})]})]})}function gx(e,r,n){return e==="light"?"dark":e==="dark"?"auto":n?"light":r==="light"?"dark":"light"}function vx({color:e}){return t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:e,display:"inline-block",flexShrink:0}})}function Ci(){return t.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function yx({mode:e}){return e==="dark"?t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):e==="light"?t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"4"}),t.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"})]}):t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Uo=new Set;function Hc(){for(const e of Uo)e()}const bx=5,kx=1e3,jx=6e4;function wx(){const[e,r]=c.useState(void 0),[n,s]=c.useState(!1),[o,a]=c.useState(!0),i=c.useRef(0),l=c.useRef(null),d=c.useRef(null),u=c.useRef(!0),p=c.useRef(0),[f,h]=c.useState(0),m=()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},g=c.useCallback(()=>{l.current&&(l.current.abort(),l.current=null)},[]),v=c.useCallback(async()=>{if(!u.current||document.visibilityState==="hidden")return;g();const b=new AbortController;l.current=b;try{const y=await fetch("/api/plugins",{signal:b.signal});if(!u.current)return;const j=await y.json();if(!u.current)return;i.current=0,r(j.plugins??[]),a(!1),s(!1),d.current=setTimeout(()=>{u.current&&h(S=>S+1)},jx)}catch(y){if(!u.current||y instanceof DOMException&&y.name==="AbortError")return;if(i.current+=1,a(!1),i.current>bx){s(!0);return}const j=kx*Math.pow(2,i.current-1);d.current=setTimeout(()=>{u.current&&h(S=>S+1)},j)}},[g]);c.useEffect(()=>(u.current=!0,()=>{u.current=!1,m(),g()}),[g]),c.useEffect(()=>{document.visibilityState!=="hidden"&&(m(),v())},[f,v]),c.useEffect(()=>{const b=()=>{document.visibilityState==="hidden"?(m(),g()):(i.current=0,s(!1),h(y=>y+1))};return document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b)}},[g]);const x=c.useCallback(()=>{i.current=0,s(!1),m(),p.current+=1,h(b=>b+1)},[]);return c.useEffect(()=>(Uo.add(x),()=>{Uo.delete(x)}),[x]),{plugins:e,paused:n,loading:o,retry:x}}const ks=0,ir=1,Hr=2,Vc=4;function Ei(e){return()=>e}function Sx(e){e()}function Gc(e,r){return n=>e(r(n))}function Ni(e,r){return()=>e(r)}function Cx(e,r){return n=>e(r,n)}function ba(e){return e!==void 0}function Ex(...e){return()=>{e.map(Sx)}}function Vr(){}function js(e,r){return r(e),e}function Nx(e,r){return r(e)}function Ke(...e){return e}function Be(e,r){return e(ir,r)}function Re(e,r){e(ks,r)}function ka(e){e(Hr)}function qe(e){return e(Vc)}function xe(e,r){return Be(e,Cx(r,ks))}function Mt(e,r){const n=e(ir,s=>{n(),r(s)});return n}function Ri(e){let r,n;return s=>o=>{r=o,n&&clearTimeout(n),n=setTimeout(()=>{s(r)},e)}}function Kc(e,r){return e===r}function Ge(e=Kc){let r;return n=>s=>{e(r,s)||(r=s,n(s))}}function we(e){return r=>n=>{e(n)&&r(n)}}function pe(e){return r=>Gc(r,e)}function Wt(e){return r=>()=>{r(e)}}function Z(e,...r){const n=Rx(...r);return((s,o)=>{switch(s){case Hr:ka(e);return;case ir:return Be(e,n(o))}})}function Ht(e,r){return n=>s=>{n(r=e(r,s))}}function br(e){return r=>n=>{e>0?e--:r(n)}}function Yt(e){let r=null,n;return s=>o=>{r=o,!n&&(n=setTimeout(()=>{n=void 0,s(r)},e))}}function Le(...e){const r=Array.from({length:e.length});let n=0,s=null;const o=2**e.length-1;return e.forEach((a,i)=>{const l=2**i;Be(a,d=>{const u=n;n|=l,r[i]=d,u!==o&&n===o&&s&&(s(),s=null)})}),a=>i=>{const l=()=>{a([i].concat(r))};n===o?l():s=l}}function Rx(...e){return r=>e.reduceRight(Nx,r)}function Tx(e){let r,n;const s=()=>r==null?void 0:r();return function(o,a){switch(o){case ir:return a?n===a?void 0:(s(),n=a,r=Be(e,a),r):(s(),Vr);case Hr:s(),n=null;return}}}function le(e){let r=e;const n=Me();return((s,o)=>{switch(s){case ks:r=o;break;case ir:{o(r);break}case Vc:return r}return n(s,o)})}function dt(e,r){return js(le(r),n=>xe(e,n))}function Me(){const e=[];return((r,n)=>{switch(r){case ks:e.slice().forEach(s=>{s(n)});return;case Hr:e.splice(0);return;case ir:return e.push(n),()=>{const s=e.indexOf(n);s>-1&&e.splice(s,1)}}})}function Rt(e){return js(Me(),r=>xe(e,r))}const Ix={singleton:!0};function ze(e,r=[],n=Ix){const{singleton:s}=n;return{constructor:e,dependencies:r,id:Lx(),singleton:s}}const Lx=()=>Symbol("id");function Ax(e){const r=new Map,n=({constructor:s,dependencies:o,id:a,singleton:i})=>{if(i&&r.has(a))return r.get(a);const l=s(o.map(d=>n(d)));return i&&r.set(a,l),l};return n(e)}function et(...e){const r=Me(),n=Array.from({length:e.length});let s=0;const o=2**e.length-1;return e.forEach((a,i)=>{const l=2**i;Be(a,d=>{n[i]=d,s|=l,s===o&&Re(r,n)})}),function(a,i){switch(a){case Hr:{ka(r);return}case ir:return s===o&&i(n),Be(r,i)}}}function je(e,r=Kc){return Z(e,Ge(r))}function Ho(...e){return function(r,n){switch(r){case Hr:return;case ir:return Ex(...e.map(s=>Be(s,n)))}}}const st={DEBUG:0,INFO:1,WARN:2,ERROR:3},Px={[st.DEBUG]:"debug",[st.ERROR]:"error",[st.INFO]:"log",[st.WARN]:"warn"},$x=()=>typeof globalThis>"u"?window:globalThis,lr=ze(()=>{const e=le(st.ERROR);return{log:le((r,n,s=st.INFO)=>{const o=$x().VIRTUOSO_LOG_LEVEL??qe(e);s>=o&&console[Px[s]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,n)}),logLevel:e}},[],{singleton:!0});function Mx(e){return"self"in e?e.document.documentElement:e}function qc(e){const r=Mx(e);return r.ownerDocument.defaultView.getComputedStyle(r).direction==="rtl"}function vr(e,r){return qc(e)?-r:r}function Ti(e,r){return qc(e)?-r:r}function jr(e,r,n){return ja(e,r,n).callbackRef}function ja(e,r,n){const s=me.useRef(null);let o=i=>{};const a=me.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const d=i[0].target;d.offsetParent!==null&&e(d)};n?l():requestAnimationFrame(l)}):null,[e,n]);return o=i=>{i&&r?(a==null||a.observe(i),s.current=i):(s.current&&(a==null||a.unobserve(s.current)),s.current=null)},{callbackRef:o,ref:s}}function Fx(e,r,n,s,o,a,i,l,d){const u=me.useCallback(p=>{var y;const f=Dx(p.children,r,l?"offsetWidth":"offsetHeight",o);let h=p.parentElement;for(;h.dataset.virtuosoScroller===void 0;)h=h.parentElement;const m=((y=h.lastElementChild)==null?void 0:y.dataset.viewportType)==="window";let g;m&&(g=h.ownerDocument.defaultView);const v=i?l?i.scrollWidth:i.scrollHeight:m?l?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight:l?h.scrollWidth:h.scrollHeight,x=i?l?i.offsetWidth:i.offsetHeight:m?l?g.innerWidth:g.innerHeight:l?h.offsetWidth:h.offsetHeight,b=i?l?vr(i,i.scrollLeft):i.scrollTop:m?l?vr(g,g.scrollX||g.document.documentElement.scrollLeft):g.scrollY||g.document.documentElement.scrollTop:l?vr(h,h.scrollLeft):h.scrollTop;s({scrollHeight:v,scrollTop:Math.max(b,0),viewportHeight:x}),a==null||a(l?Ii("column-gap",getComputedStyle(p).columnGap,o):Ii("row-gap",getComputedStyle(p).rowGap,o)),f!==null&&e(f)},[e,r,o,a,i,s,l]);return ja(u,n,d)}function Dx(e,r,n,s){const o=e.length;if(o===0)return null;const a=[];for(let i=0;i<o;i++){const l=e.item(i);if(l.dataset.index===void 0)continue;const d=parseInt(l.dataset.index,10),u=parseFloat(l.dataset.knownSize),p=r(l,n);if(p===0&&s("Zero-sized element, this should not happen",{child:l},st.ERROR),p===u)continue;const f=a[a.length-1];a.length===0||f.size!==p||f.endIndex!==d-1?a.push({endIndex:d,size:p,startIndex:d}):a[a.length-1].endIndex++}return a}function Ii(e,r,n){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,r,st.WARN),r==="normal"?0:parseInt(r??"0",10)}const wa=typeof document>"u"?me.useEffect:me.useLayoutEffect;function Yc(e,r,n){const s=me.useRef(null),o=me.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const u=d.getBoundingClientRect(),p=u.width;let f,h;if(r){const m=r.getBoundingClientRect(),g=u.top-m.top;h=m.height-Math.max(0,g),f=g+r.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}s.current={listHeight:u.height,offsetTop:f,visibleHeight:h,visibleWidth:p},e(s.current)},[e,r]),{callbackRef:a,ref:i}=ja(o,!0,n),l=me.useCallback(()=>{o(i.current)},[o,i]);return me.useEffect(()=>{var u;if(r){r.addEventListener("scroll",l);const p=new ResizeObserver(()=>{requestAnimationFrame(l)});return p.observe(r),()=>{r.removeEventListener("scroll",l),p.unobserve(r)}}const d=(u=i.current)==null?void 0:u.ownerDocument.defaultView;return d==null||d.addEventListener("scroll",l),d==null||d.addEventListener("resize",l),()=>{d==null||d.removeEventListener("scroll",l),d==null||d.removeEventListener("resize",l)}},[l,r,i]),a}const mt=ze(()=>{const e=Me(),r=Me(),n=le(0),s=Me(),o=Me(),a=le(0),i=Me(),l=Me(),d=le(0),u=le(0),p=le(0),f=le(0),h=Me(),m=Me(),g=le(!1),v=le(!1),x=le(!1);return xe(Z(e,pe(({scrollTop:b})=>b)),r),xe(Z(e,pe(({scrollHeight:b})=>b)),l),xe(r,a),{deviation:n,deviationCommitted:s,fixedFooterHeight:p,fixedHeaderHeight:u,footerHeight:f,headerHeight:d,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:l,scrollingInProgress:g,scrollTo:h,scrollTop:r,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:o,statefulScrollTop:a,viewportHeight:i}},[],{singleton:!0}),mn={lvl:0};function Jc(e,r){const n=e.length;if(n===0)return[];let{index:s,value:o}=r(e[0]);const a=[];for(let i=1;i<n;i++){const{index:l,value:d}=r(e[i]);a.push({end:l-1,start:s,value:o}),s=l,o=d}return a.push({end:1/0,start:s,value:o}),a}function Oe(e){return e===mn}function xn(e,r){if(!Oe(e))return r===e.k?e.v:r<e.k?xn(e.l,r):xn(e.r,r)}function Dt(e,r,n="k"){if(Oe(e))return[-1/0,void 0];if(Number(e[n])===r)return[e.k,e.v];if(Number(e[n])<r){const s=Dt(e.r,r,n);return s[0]===-1/0?[e.k,e.v]:s}return Dt(e.l,r,n)}function Et(e,r,n){return Oe(e)?Zc(r,n,1):r===e.k?rt(e,{k:r,v:n}):r<e.k?Li(rt(e,{l:Et(e.l,r,n)})):Li(rt(e,{r:Et(e.r,r,n)}))}function $r(){return mn}function Mr(e,r,n){if(Oe(e))return[];const s=Dt(e,r)[0];return zx(Go(e,s,n))}function Vo(e,r){if(Oe(e))return mn;const{k:n,l:s,r:o}=e;if(r===n){if(Oe(s))return o;if(Oe(o))return s;const[a,i]=Xc(s);return Zn(rt(e,{k:a,l:Qc(s),v:i}))}return r<n?Zn(rt(e,{l:Vo(s,r)})):Zn(rt(e,{r:Vo(o,r)}))}function yr(e){return Oe(e)?[]:[...yr(e.l),{k:e.k,v:e.v},...yr(e.r)]}function Go(e,r,n){if(Oe(e))return[];const{k:s,l:o,r:a,v:i}=e;let l=[];return s>r&&(l=l.concat(Go(o,r,n))),s>=r&&s<=n&&l.push({k:s,v:i}),s<=n&&(l=l.concat(Go(a,r,n))),l}function Zn(e){const{l:r,lvl:n,r:s}=e;if(s.lvl>=n-1&&r.lvl>=n-1)return e;if(n>s.lvl+1){if(Vs(r))return ed(rt(e,{lvl:n-1}));if(!Oe(r)&&!Oe(r.r))return rt(r.r,{l:rt(r,{r:r.r.l}),lvl:n,r:rt(e,{l:r.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}if(Vs(e))return Ko(rt(e,{lvl:n-1}));if(!Oe(s)&&!Oe(s.l)){const o=s.l,a=Vs(o)?s.lvl-1:s.lvl;return rt(o,{l:rt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ko(rt(s,{l:o.r,lvl:a}))})}throw new Error("Unexpected empty nodes")}function rt(e,r){return Zc(r.k===void 0?e.k:r.k,r.v===void 0?e.v:r.v,r.lvl===void 0?e.lvl:r.lvl,r.l===void 0?e.l:r.l,r.r===void 0?e.r:r.r)}function Qc(e){return Oe(e.r)?e.l:Zn(rt(e,{r:Qc(e.r)}))}function Vs(e){return Oe(e)||e.lvl>e.r.lvl}function Xc(e){return Oe(e.r)?[e.k,e.v]:Xc(e.r)}function Zc(e,r,n,s=mn,o=mn){return{k:e,l:s,lvl:n,r:o,v:r}}function Li(e){return Ko(ed(e))}function ed(e){const{l:r}=e;return!Oe(r)&&r.lvl===e.lvl?rt(r,{r:rt(e,{l:r.r})}):e}function Ko(e){const{lvl:r,r:n}=e;return!Oe(n)&&!Oe(n.r)&&n.lvl===r&&n.r.lvl===r?rt(n,{l:rt(e,{r:n.l}),lvl:r+1}):e}function zx(e){return Jc(e,({k:r,v:n})=>({index:r,value:n}))}function td(e,r){return!!(e&&e.startIndex===r.startIndex&&e.endIndex===r.endIndex)}function gn(e,r){return!!(e&&e[0]===r[0]&&e[1]===r[1])}const Sa=ze(()=>({recalcInProgress:le(!1)}),[],{singleton:!0});function rd(e,r,n){return e[os(e,r,n)]}function os(e,r,n,s=0){let o=e.length-1;for(;s<=o;){const a=Math.floor((s+o)/2),i=e[a],l=n(i,r);if(l===0)return a;if(l===-1){if(o-s<2)return a-1;o=a-1}else{if(o===s)return a;s=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${r}`)}function Bx(e,r,n,s){const o=os(e,r,s),a=os(e,n,s,o);return e.slice(o,a+1)}function or(e,r){return Math.round(e.getBoundingClientRect()[r])}function ws(e){return!Oe(e.groupOffsetTree)}function Ca({index:e},r){return r===e?0:r<e?-1:1}function _x(){return{groupIndices:[],groupOffsetTree:$r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:$r()}}function Ox(e,r){let n=Oe(e)?0:1/0;for(const s of r){const{endIndex:o,size:a,startIndex:i}=s;if(n=Math.min(n,i),Oe(e)){e=Et(e,0,a);continue}const l=Mr(e,i-1,o+1);if(l.some(qx(s)))continue;let d=!1,u=!1;for(const{end:p,start:f,value:h}of l)d?(o>=f||a===h)&&(e=Vo(e,f)):(u=h!==a,d=!0),p>o&&o>=f&&h!==a&&(e=Et(e,o+1,h));u&&(e=Et(e,i,a))}return[e,n]}function Wx(e){return e.groupIndex!==void 0}function Ux({offset:e},r){return r===e?0:r<e?-1:1}function vn(e,r,n){if(r.length===0)return 0;const{index:s,offset:o,size:a}=rd(r,e,Ca),i=e-s,l=a*i+(i-1)*n+o;return l>0?l+n:l}function nd(e,r){if(!ws(r))return e;let n=0;for(;r.groupIndices[n]<=e+n;)n++;return e+n}function sd(e,r,n){if(Wx(e))return r.groupIndices[e.groupIndex]+1;const s=e.index==="LAST"?n:e.index;let o=nd(s,r);return o=Math.max(0,Math.min(n,o)),o}function Hx(e,r,n,s=0){return s>0&&(r=Math.max(r,rd(e,s,Ca).offset)),Jc(Bx(e,r,n,Ux),Kx)}function Vx(e,[r,n,s,o]){r.length>0&&s("received item sizes",r,st.DEBUG);const a=e.sizeTree;let i=a,l=0;if(n.length>0&&Oe(a)&&r.length===2){const h=r[0].size,m=r[1].size;i=n.reduce((g,v)=>Et(Et(g,v,h),v+1,m),i)}else[i,l]=Ox(i,r);if(i===a)return e;const{lastIndex:d,lastOffset:u,lastSize:p,offsetTree:f}=qo(e.offsetTree,l,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>Et(h,m,vn(m,f,o)),$r()),lastIndex:d,lastOffset:u,lastSize:p,offsetTree:f,sizeTree:i}}function Gx(e){return yr(e).map(({k:r,v:n},s,o)=>{const a=o[s+1];return{endIndex:a===void 0?1/0:a.k-1,size:n,startIndex:r}})}function Ai(e,r){let n=0,s=0;for(;n<e;)n+=r[s+1]-r[s]-1,s++;return s-(n===e?0:1)}function qo(e,r,n,s){let o=e,a=0,i=0,l=0,d=0;if(r===0)o=[];else{d=os(o,r-1,Ca),l=o[d].offset;const u=Dt(n,r-1);a=u[0],i=u[1],o.length&&o[d].size===Dt(n,r)[1]&&(d-=1),o=o.slice(0,d+1)}for(const{start:u,value:p}of Mr(n,r,1/0)){const f=u-a,h=f*i+l+f*s;o.push({index:u,offset:h,size:p}),a=u,l=h,i=p}return{lastIndex:a,lastOffset:l,lastSize:i,offsetTree:o}}function Kx(e){return{index:e.index,value:e}}function qx(e){const{endIndex:r,size:n,startIndex:s}=e;return o=>o.start===s&&(o.end===r||o.end===1/0)&&o.value===n}const Yx={offsetHeight:"height",offsetWidth:"width"},Gt=ze(([{log:e},{recalcInProgress:r}])=>{const n=Me(),s=Me(),o=dt(s,0),a=Me(),i=Me(),l=le(0),d=le([]),u=le(void 0),p=le(void 0),f=le(void 0),h=le(void 0),m=le((w,E)=>or(w,Yx[E])),g=le(void 0),v=le(0),x=_x(),b=dt(Z(n,Le(d,e,v),Ht(Vx,x),Ge()),x),y=dt(Z(d,Ge(),Ht((w,E)=>({current:E,prev:w.current}),{current:[],prev:[]}),pe(({prev:w})=>w)),[]);xe(Z(d,we(w=>w.length>0),Le(b,v),pe(([w,E,N])=>{const T=w.reduce((I,A,$)=>Et(I,A,vn(A,E.offsetTree,N)||$),$r());return{...E,groupIndices:w,groupOffsetTree:T}})),b),xe(Z(s,Le(b),we(([w,{lastIndex:E}])=>w<E),pe(([w,{lastIndex:E,lastSize:N}])=>[{endIndex:E,size:N,startIndex:w}])),n),xe(u,p);const j=dt(Z(u,pe(w=>w===void 0)),!0);xe(Z(p,we(w=>w!==void 0&&Oe(qe(b).sizeTree)),pe(w=>{const E=qe(f),N=qe(d).length>0;return E!==void 0&&E!==0?N?[{endIndex:0,size:E,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),n),xe(Z(h,we(w=>w!==void 0&&w.length>0&&Oe(qe(b).sizeTree)),pe(w=>{const E=[];let N=w[0],T=0;for(let I=1;I<w.length;I++){const A=w[I];A!==N&&(E.push({endIndex:I-1,size:N,startIndex:T}),N=A,T=I)}return E.push({endIndex:w.length-1,size:N,startIndex:T}),E})),n),xe(Z(d,Le(f,p),we(([,w,E])=>w!==void 0&&E!==void 0),pe(([w,E,N])=>{const T=[];for(let I=0;I<w.length;I++){const A=w[I],$=w[I+1];T.push({startIndex:A,endIndex:A,size:E}),$!==void 0&&T.push({startIndex:A+1,endIndex:$-1,size:N})}return T})),n);const S=Rt(Z(n,Le(b),Ht(({sizes:w},[E,N])=>({changed:N!==w,sizes:N}),{changed:!1,sizes:x}),pe(w=>w.changed)));Be(Z(l,Ht((w,E)=>({diff:w.prev-E,prev:E}),{diff:0,prev:0}),pe(w=>w.diff)),w=>{const{groupIndices:E}=qe(b);if(w>0)Re(r,!0),Re(a,w+Ai(w,E));else if(w<0){const N=qe(y);N.length>0&&(w-=Ai(-w,N)),Re(i,w)}}),Be(Z(l,Le(e)),([w,E])=>{w<0&&E("`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:l},st.ERROR)});const k=Rt(a);xe(Z(a,Le(b),pe(([w,E])=>{const N=E.groupIndices.length>0,T=[],I=E.lastSize;if(N){const A=xn(E.sizeTree,0);let $=0,W=0;for(;$<w;){const P=E.groupIndices[W],L=E.groupIndices.length===W+1?1/0:E.groupIndices[W+1]-P-1;T.push({endIndex:P,size:A,startIndex:P}),T.push({endIndex:P+1+L-1,size:I,startIndex:P+1}),W++,$+=L+1}const C=yr(E.sizeTree);return $!==w&&C.shift(),C.reduce((P,{k:L,v:F})=>{let H=P.ranges;return P.prevSize!==0&&(H=[...P.ranges,{endIndex:L+w-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:L+w,prevSize:F,ranges:H}},{prevIndex:w,prevSize:0,ranges:T}).ranges}return yr(E.sizeTree).reduce((A,{k:$,v:W})=>({prevIndex:$+w,prevSize:W,ranges:[...A.ranges,{endIndex:$+w-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:I,ranges:[]}).ranges})),n);const R=Rt(Z(i,Le(b,v),pe(([w,{offsetTree:E},N])=>{const T=-w;return vn(T,E,N)})));return xe(Z(i,Le(b,v),pe(([w,E,N])=>{if(E.groupIndices.length>0){if(Oe(E.sizeTree))return E;let I=$r();const A=qe(y);let $=0,W=0,C=0;for(;$<-w;){C=A[W];const P=A[W+1]-C-1;W++,$+=P+1}if(I=yr(E.sizeTree).reduce((P,{k:L,v:F})=>Et(P,Math.max(0,L+w),F),I),$!==-w){const P=xn(E.sizeTree,C);I=Et(I,0,P);const L=Dt(E.sizeTree,-w+1)[1];I=Et(I,1,L)}return{...E,sizeTree:I,...qo(E.offsetTree,0,I,N)}}const T=yr(E.sizeTree).reduce((I,{k:A,v:$})=>Et(I,Math.max(0,A+w),$),$r());return{...E,sizeTree:T,...qo(E.offsetTree,0,T,N)}})),b),{beforeUnshiftWith:k,data:g,defaultItemSize:p,firstItemIndex:l,fixedItemSize:u,fixedGroupSize:f,gap:v,groupIndices:d,heightEstimates:h,itemSize:m,listRefresh:S,shiftWith:i,shiftWithOffset:R,sizeRanges:n,sizes:b,statefulTotalCount:o,totalCount:s,trackItemSizes:j,unshiftWith:a}},Ke(lr,Sa),{singleton:!0});function Jx(e){return e.reduce((r,n)=>(r.groupIndices.push(r.totalCount),r.totalCount+=n+1,r),{groupIndices:[],totalCount:0})}const od=ze(([{groupIndices:e,sizes:r,totalCount:n},{headerHeight:s,scrollTop:o}])=>{const a=Me(),i=Me(),l=Rt(Z(a,pe(Jx)));return xe(Z(l,pe(d=>d.totalCount)),n),xe(Z(l,pe(d=>d.groupIndices)),e),xe(Z(et(o,r,s),we(([d,u])=>ws(u)),pe(([d,u,p])=>Dt(u.groupOffsetTree,Math.max(d-p,0),"v")[0]),Ge(),pe(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},Ke(Gt,mt)),cr=ze(([{log:e}])=>{const r=le(!1),n=Rt(Z(r,we(s=>s),Ge()));return Be(r,s=>{s&&qe(e)("props updated",{},st.DEBUG)}),{didMount:n,propsReady:r}},Ke(lr),{singleton:!0}),Qx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ad(e){const r=typeof e=="number"?{index:e}:{...e};return r.align||(r.align="start"),(!r.behavior||!Qx)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Cn=ze(([{gap:e,listRefresh:r,sizes:n,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:a,footerHeight:i,headerHeight:l,scrollingInProgress:d,scrollTo:u,smoothScrollTargetReached:p,viewportHeight:f},{log:h}])=>{const m=Me(),g=Me(),v=le(0);let x=null,b=null,y=null;function j(){x!==null&&(x(),x=null),y!==null&&(y(),y=null),b&&(clearTimeout(b),b=null),Re(d,!1)}return xe(Z(m,Le(n,f,s,v,l,i,h),Le(e,a,o),pe(([[S,k,R,w,E,N,T,I],A,$,W])=>{const C=ad(S),{align:P,behavior:L,offset:F}=C,H=w-1,re=sd(C,k,H);let V=vn(re,k.offsetTree,A)+N;P==="end"?(V+=$+Dt(k.sizeTree,re)[1]-R+W,re===H&&(V+=T)):P==="center"?V+=($+Dt(k.sizeTree,re)[1]-R+W)/2:V-=E,F!==void 0&&F!==0&&(V+=F);const O=se=>{j(),se?(I("retrying to scroll to",{location:S},st.DEBUG),Re(m,S)):(Re(g,!0),I("list did not change, scroll successful",{},st.DEBUG))};if(j(),L==="smooth"){let se=!1;y=Be(r,ge=>{se=se||ge}),x=Mt(p,()=>{O(se)})}else x=Mt(Z(r,Xx(150)),O);return b=setTimeout(()=>{j()},1200),Re(d,!0),I("scrolling from index to",{behavior:L,index:re,top:V},st.DEBUG),{behavior:L,top:V}})),u),{scrollTargetReached:g,scrollToIndex:m,topListHeight:v}},Ke(Gt,mt,lr),{singleton:!0});function Xx(e){return r=>{const n=setTimeout(()=>{r(!1)},e);return s=>{s&&(r(!0),clearTimeout(n))}}}function Ea(e,r){e===0?r():requestAnimationFrame(()=>{Ea(e-1,r)})}function Na(e,r){if(e===void 0)return 0;const n=r-1,s=typeof e=="number"?e:e.index==="LAST"?n:e.index;return Math.max(0,Math.min(s,n))}function Yo(e){return e===void 0?!0:typeof e=="number"?e===0:e.index===0&&(e.align===void 0||e.align==="start")&&(e.offset===void 0||e.offset===0)}const En=ze(([{defaultItemSize:e,listRefresh:r,sizes:n},{scrollTop:s},{scrollTargetReached:o,scrollToIndex:a},{didMount:i}])=>{const l=le(!0),d=le(0),u=le(!0);return xe(Z(i,Le(d),we(([p,f])=>!Yo(f)),Wt(!1)),l),xe(Z(i,Le(d),we(([p,f])=>!Yo(f)),Wt(!1)),u),Be(Z(et(r,i),Le(l,n,e,u),we(([[,p],f,{sizeTree:h},m,g])=>p&&(!Oe(h)||ba(m))&&!f&&!g),Le(d)),([,p])=>{if(p===void 0){Re(l,!0),Re(u,!0);return}Mt(o,()=>{Re(u,!0)}),Ea(4,()=>{Mt(s,()=>{Re(l,!0)}),Re(a,p)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:d,scrolledToInitialItem:l}},Ke(Gt,mt,Cn,cr),{singleton:!0});function id(e,r){return Math.abs(e-r)<1.01}const yn="up",cn="down",Zx="none",eg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},tg=0,Nn=ze(([{footerHeight:e,headerHeight:r,scrollBy:n,scrollContainerState:s,scrollTop:o,viewportHeight:a}])=>{const i=le(!1),l=le(!0),d=Me(),u=Me(),p=le(4),f=le(tg),h=dt(Z(Ho(Z(je(o),br(1),Wt(!0)),Z(je(o),br(1),Wt(!1),Ri(100))),Ge()),!1),m=dt(Z(Ho(Z(n,Wt(!0)),Z(n,Wt(!1),Ri(200))),Ge()),!1);xe(Z(et(je(o),je(f)),pe(([y,j])=>y<=j),Ge()),l),xe(Z(l,Yt(50)),u);const g=Rt(Z(et(s,je(a),je(r),je(e),je(p)),Ht((y,[{scrollHeight:j,scrollTop:S},k,R,w,E])=>{const N=S+k-j>-E,T={scrollHeight:j,scrollTop:S,viewportHeight:k};if(N){let A,$;return S>y.state.scrollTop?(A="SCROLLED_DOWN",$=y.state.scrollTop-S):(A="SIZE_DECREASED",$=y.state.scrollTop-S||y.scrollTopDelta),{atBottom:!0,atBottomBecause:A,scrollTopDelta:$,state:T}}let I;return T.scrollHeight>y.state.scrollHeight?I="SIZE_INCREASED":k<y.state.viewportHeight?I="VIEWPORT_HEIGHT_DECREASING":S<y.state.scrollTop?I="SCROLLING_UPWARDS":I="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:I,state:T}},eg),Ge((y,j)=>y!==void 0&&y.atBottom===j.atBottom))),v=dt(Z(s,Ht((y,{scrollHeight:j,scrollTop:S,viewportHeight:k})=>{if(!id(y.scrollHeight,j)){const R=j-(S+k)<1;return y.scrollTop!==S&&R?{changed:!0,jump:y.scrollTop-S,scrollHeight:j,scrollTop:S}:{changed:!0,jump:0,scrollHeight:j,scrollTop:S}}return{changed:!1,jump:0,scrollHeight:j,scrollTop:S}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),we(y=>y.changed),pe(y=>y.jump)),0);xe(Z(g,pe(y=>y.atBottom)),i),xe(Z(i,Yt(50)),d);const x=le(cn);xe(Z(s,pe(({scrollTop:y})=>y),Ge(),Ht((y,j)=>qe(m)?{direction:y.direction,prevScrollTop:j}:{direction:j<y.prevScrollTop?yn:cn,prevScrollTop:j},{direction:cn,prevScrollTop:0}),pe(y=>y.direction)),x),xe(Z(s,Yt(50),Wt(Zx)),x);const b=le(0);return xe(Z(h,we(y=>!y),Wt(0)),b),xe(Z(o,Yt(100),Le(h),we(([y,j])=>j),Ht(([y,j],[S])=>[j,S],[0,0]),pe(([y,j])=>j-y)),b),{atBottomState:g,atBottomStateChange:d,atBottomThreshold:p,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:l,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:x,scrollVelocity:b}},Ke(mt)),bn="top",kn="bottom",Pi="none";function $i(e,r,n){return typeof e=="number"?n===yn&&r===bn||n===cn&&r===kn?e:0:n===yn?r===bn?e.main:e.reverse:r===kn?e.main:e.reverse}function Mi(e,r){return typeof e=="number"?e:e[r]??0}const Ra=ze(([{deviation:e,fixedHeaderHeight:r,headerHeight:n,scrollTop:s,viewportHeight:o}])=>{const a=Me(),i=le(0),l=le(0),d=le(0),u=dt(Z(et(je(s),je(o),je(n),je(a,gn),je(d),je(i),je(r),je(e),je(l)),pe(([p,f,h,[m,g],v,x,b,y,j])=>{const S=p-y,k=x+b,R=Math.max(h-S,0);let w=Pi;const E=Mi(j,bn),N=Mi(j,kn);return m-=y,m+=h+b,g+=h+b,g-=y,m>p+k-E&&(w=yn),g<p-R+f+N&&(w=cn),w!==Pi?[Math.max(S-h-$i(v,bn,w)-E,0),S-R-b+f+$i(v,kn,w)+N]:null}),we(p=>p!==null),Ge(gn)),[0,0]);return{increaseViewportBy:l,listBoundary:a,overscan:d,topListHeight:i,visibleRange:u}},Ke(mt),{singleton:!0});function rg(e,r,n){if(ws(r)){const s=nd(e,r);return[{index:Dt(r.groupOffsetTree,s)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:s,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Gs={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function es(e,r,n,s,o,a){const{lastIndex:i,lastOffset:l,lastSize:d}=o;let u=0,p=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];p=v.offset+v.size}const f=n-i,h=l+f*d+(f-1)*s,m=u,g=h-p;return{bottom:p,firstItemIndex:a,items:Fi(e,o,a),offsetBottom:g,offsetTop:u,top:m,topItems:Fi(r,o,a),topListHeight:r.reduce((v,x)=>x.size+v,0),totalCount:n}}function ld(e,r,n,s,o,a){let i=0;if(n.groupIndices.length>0)for(const m of n.groupIndices){if(m-i>=e)break;i++}const l=e+i,d=a!==void 0,u=(a==null?void 0:a.length)??0,p=Na(r,d?u:l),f=d?Math.max(0,Math.min(l,u-p)):l,h=Array.from({length:f}).map((m,g)=>({data:a==null?void 0:a[g+p],index:g+p,offset:0,size:0}));return es(h,[],f,o,n,s)}function Fi(e,r,n){if(e.length===0)return[];if(!ws(r))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const s=e[0].index,o=e[e.length-1].index,a=[],i=Mr(r.groupOffsetTree,s,o);let l,d=0;for(const u of e){(!l||l.end<u.index)&&(l=i.shift(),d=r.groupIndices.indexOf(l.start));let p;u.index===l.start?p={index:d,type:"group"}:p={groupIndex:d,index:u.index-(d+1)+n},a.push({...p,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return a}function Di(e,r){return e===void 0?0:typeof e=="number"?e:e[r]??0}const wr=ze(([{data:e,firstItemIndex:r,gap:n,sizes:s,totalCount:o},a,{listBoundary:i,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:u,scrolledToInitialItem:p},{topListHeight:f},h,{didMount:m},{recalcInProgress:g}])=>{const v=le([]),x=le(0),b=Me(),y=le(0);xe(a.topItemsIndexes,v);const j=dt(Z(et(m,g,je(d,gn),je(o),je(s),je(u),p,je(v),je(r),je(n),je(y),e,je(x)),we(([w,E,,N,,,,,,,,T])=>{const I=T!==void 0&&T.length!==N;return w&&!E&&!I}),pe(([,,[w,E],N,T,I,A,$,W,C,P,L,F])=>{var U,K;const H=T,{offsetTree:re,sizeTree:V}=H;if(N===0)return{...Gs,totalCount:N};if(w===0&&E===0)return F===0?{...Gs,totalCount:N}:ld(F,I,T,W,C,L);if(Oe(V))return F>0?null:es(rg(Na(I,N),H,L),[],N,C,H,W);const O=[];if($.length>0){const X=$[0],ie=$[$.length-1];let G=0;for(const te of Mr(V,X,ie)){const de=te.value,fe=Math.max(te.start,X),ke=Math.min(te.end,ie);for(let B=fe;B<=ke;B++)O.push({data:L==null?void 0:L[B],index:B,offset:G,size:de}),G+=de}}if(!A)return es([],O,N,C,H,W);const se=$.length>0?$[$.length-1]+1:0,ge=Hx(re,w,E,se);if(ge.length===0)return null;const ye=N-1,z=js([],X=>{for(const ie of ge){const G=ie.value;let te=G.offset,de=ie.start;const fe=G.size;if(G.offset<w){de+=Math.floor((w-G.offset+C)/(fe+C));const B=de-ie.start;te+=B*fe+B*C}de<se&&(te+=(se-de)*fe,de=se);const ke=Math.min(ie.end,ye);for(let B=de;B<=ke&&!(te>=E);B++)X.push({data:L==null?void 0:L[B],index:B,offset:te,size:fe}),te+=fe+C}}),ne=Di(P,bn),M=Di(P,kn);if(z.length>0&&(ne>0||M>0)){const X=z[0],ie=z[z.length-1];if(ne>0&&X.index>se){const G=Math.min(ne,X.index-se),te=[];let de=X.offset;for(let fe=X.index-1;fe>=X.index-G;fe--){const ke=((U=Mr(V,fe,fe)[0])==null?void 0:U.value)??X.size;de-=ke+C,te.unshift({data:L==null?void 0:L[fe],index:fe,offset:de,size:ke})}z.unshift(...te)}if(M>0&&ie.index<ye){const G=Math.min(M,ye-ie.index);let te=ie.offset+ie.size+C;for(let de=ie.index+1;de<=ie.index+G;de++){const fe=((K=Mr(V,de,de)[0])==null?void 0:K.value)??ie.size;z.push({data:L==null?void 0:L[de],index:de,offset:te,size:fe}),te+=fe+C}}}return es(z,O,N,C,H,W)}),we(w=>w!==null),Ge()),Gs);xe(Z(e,we(ba),pe(w=>w==null?void 0:w.length)),o),xe(Z(j,pe(w=>w.topListHeight)),f),xe(f,l),xe(Z(j,pe(w=>[w.top,w.bottom])),i),xe(Z(j,pe(w=>w.items)),b);const S=Rt(Z(j,we(({items:w})=>w.length>0),Le(o,e),we(([{items:w},E])=>w[w.length-1].originalIndex===E-1),pe(([,w,E])=>[w-1,E]),Ge(gn),pe(([w])=>w))),k=Rt(Z(j,Yt(200),we(({items:w,topItems:E})=>w.length>0&&w[0].originalIndex===E.length),pe(({items:w})=>w[0].index),Ge())),R=Rt(Z(j,we(({items:w})=>w.length>0),pe(({items:w})=>{let E=0,N=w.length-1;for(;w[E].type==="group"&&E<N;)E++;for(;w[N].type==="group"&&N>E;)N--;return{endIndex:w[N].index,startIndex:w[E].index}}),Ge(td)));return{endReached:S,initialItemCount:x,itemsRendered:b,listState:j,minOverscanItemCount:y,rangeChanged:R,startReached:k,topItemsIndexes:v,...h}},Ke(Gt,od,Ra,En,Cn,Nn,cr,Sa),{singleton:!0}),cd=ze(([{fixedFooterHeight:e,fixedHeaderHeight:r,footerHeight:n,headerHeight:s},{listState:o}])=>{const a=Me(),i=dt(Z(et(n,e,s,r,o),pe(([l,d,u,p,f])=>l+d+u+p+f.offsetBottom+f.bottom)),0);return xe(je(i),a),{totalListHeight:i,totalListHeightChanged:a}},Ke(mt,wr),{singleton:!0}),ng=ze(([{viewportHeight:e},{totalListHeight:r}])=>{const n=le(!1),s=dt(Z(et(n,e,r),we(([o])=>o),pe(([,o,a])=>Math.max(0,o-a)),Yt(0),Ge()),0);return{alignToBottom:n,paddingTopAddition:s}},Ke(mt,cd),{singleton:!0}),dd=ze(()=>({context:le(null)})),sg=({itemBottom:e,itemTop:r,locationParams:{align:n,behavior:s,...o},viewportBottom:a,viewportTop:i})=>r<i?{...o,align:n??"start",...s===void 0?{}:{behavior:s}}:e>a?{...o,align:n??"end",...s===void 0?{}:{behavior:s}}:null,ud=ze(([{gap:e,sizes:r,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:o,headerHeight:a,scrollingInProgress:i,scrollTop:l,viewportHeight:d},{scrollToIndex:u}])=>{const p=Me();return xe(Z(p,Le(r,d,n,a,o,s,l),Le(e),pe(([[f,h,m,g,v,x,b,y],j])=>{const{calculateViewLocation:S=sg,done:k,...R}=f,w=sd(f,h,g-1),E=vn(w,h.offsetTree,j)+v+x,N=E+Dt(h.sizeTree,w)[1],T=y+x,I=y+m-b,A=S({itemBottom:N,itemTop:E,locationParams:R,viewportBottom:I,viewportTop:T});return A===null?k==null||k():k&&Mt(Z(i,we($=>!$),br(qe(i)?1:2)),k),A}),we(f=>f!==null)),u),{scrollIntoView:p}},Ke(Gt,mt,Cn,wr,lr),{singleton:!0});function zi(e){return e===!1?!1:e==="smooth"?"smooth":"auto"}const og=(e,r)=>typeof e=="function"?zi(e(r)):r&&zi(e),ag=ze(([{listRefresh:e,totalCount:r,fixedItemSize:n,data:s},{atBottomState:o,isAtBottom:a},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:d,propsReady:u},{log:p},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const g=le(!1),v=Me();let x=null;function b(k){Re(i,{align:"end",behavior:k,index:"LAST"})}Be(Z(et(Z(je(r),br(1)),d),Le(je(g),a,l,f),pe(([[k,R],w,E,N,T])=>{let I=R&&N,A="auto";return I&&(A=og(w,E||T),I=I&&A!==!1),{followOutputBehavior:A,shouldFollow:I,totalCount:k}}),we(({shouldFollow:k})=>k)),({followOutputBehavior:k,totalCount:R})=>{x!==null&&(x(),x=null),qe(n)===void 0?x=Mt(e,()=>{qe(p)("following output to ",{totalCount:R},st.DEBUG),b(k),x=null}):requestAnimationFrame(()=>{qe(p)("following output to ",{totalCount:R},st.DEBUG),b(k)})});function y(k){const R=Mt(o,w=>{k&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&x===null&&(qe(p)("scrolling to bottom due to increased size",{},st.DEBUG),b("auto"))});setTimeout(R,100)}Be(Z(et(je(g),r,u),we(([k,,R])=>k!==!1&&R),Ht(({value:k},[,R])=>({refreshed:k===R,value:R}),{refreshed:!1,value:0}),we(({refreshed:k})=>k),Le(g,r)),([,k])=>{qe(l)&&y(k!==!1)}),Be(v,()=>{y(qe(g)!==!1)}),Be(et(je(g),o),([k,R])=>{k!==!1&&!R.atBottom&&R.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&b("auto")});const j=le(null),S=Me();return xe(Ho(Z(je(s),pe(k=>(k==null?void 0:k.length)??0)),Z(je(r))),S),Be(Z(et(Z(S,br(1)),d),Le(je(j),l,f,h),pe(([[k,R],w,E,N,T])=>R&&E&&(w==null?void 0:w({context:T,totalCount:k,scrollingInProgress:N}))),we(k=>!!k),Yt(0)),k=>{x!==null&&(x(),x=null),qe(n)===void 0?x=Mt(e,()=>{qe(p)("scrolling into view",{}),Re(m,k),x=null}):requestAnimationFrame(()=>{qe(p)("scrolling into view",{}),Re(m,k)})}),{autoscrollToBottom:v,followOutput:g,scrollIntoViewOnChange:j}},Ke(Gt,Nn,Cn,En,cr,lr,mt,dd,ud)),ig=ze(([{data:e,firstItemIndex:r,gap:n,sizes:s},{initialTopMostItemIndex:o},{initialItemCount:a,listState:i},{didMount:l}])=>(xe(Z(l,Le(a),we(([,d])=>d!==0),Le(o,s,r,n,e),pe(([[,d],u,p,f,h,m])=>ld(d,u,p,f,h,m))),i),{}),Ke(Gt,En,wr,cr),{singleton:!0}),lg=ze(([{didMount:e},{scrollTo:r},{listState:n}])=>{const s=le(0);return Be(Z(e,Le(s),we(([,o])=>o!==0),pe(([,o])=>({top:o}))),o=>{Mt(Z(n,br(1),we(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Re(r,o)})})}),{initialScrollTop:s}},Ke(cr,mt,wr),{singleton:!0}),pd=ze(([{scrollVelocity:e}])=>{const r=le(!1),n=Me(),s=le(!1);return xe(Z(e,Le(s,r,n),we(([o,a])=>a!==!1&&a!==void 0),pe(([o,a,i,l])=>{const{enter:d,exit:u}=a;if(i){if(u(o,l))return!1}else if(d(o,l))return!0;return i}),Ge()),r),Be(Z(et(r,e,n),Le(s)),([[o,a,i],l])=>{o&&l!==!1&&l!==void 0&&l.change&&l.change(a,i)}),{isSeeking:r,scrollSeekConfiguration:s,scrollSeekRangeChanged:n,scrollVelocity:e}},Ke(Nn),{singleton:!0}),Ta=ze(([{scrollContainerState:e,scrollTo:r}])=>{const n=Me(),s=Me(),o=Me(),a=le(!1),i=le(void 0);return xe(Z(et(n,s),pe(([{scrollTop:l,viewportHeight:d},{offsetTop:u,listHeight:p}])=>({scrollHeight:p,scrollTop:Math.max(0,l-u),viewportHeight:d}))),e),xe(Z(r,Le(s),pe(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),o),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:s}},Ke(mt)),cg=ze(([{sizeRanges:e,sizes:r},{headerHeight:n,scrollTop:s},{initialTopMostItemIndex:o},{didMount:a},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:d}])=>{const u=Me(),p=le(void 0),f=le(null),h=le(null);return xe(l,f),xe(d,h),Be(Z(u,Le(r,s,i,f,h,n)),([m,g,v,x,b,y,j])=>{const S=Gx(g.sizeTree);x&&b!==null&&y!==null&&(v=b.scrollTop-y.offsetTop),v-=j,m({ranges:S,scrollTop:v})}),xe(Z(p,we(ba),pe(dg)),o),xe(Z(a,Le(p),we(([,m])=>m!==void 0),Ge(),pe(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:p}},Ke(Gt,mt,En,cr,Ta));function dg(e){return{align:"start",index:0,offset:e.scrollTop}}const ug=ze(([{topItemsIndexes:e}])=>{const r=le(0);return xe(Z(r,we(n=>n>=0),pe(n=>Array.from({length:n}).map((s,o)=>o))),e),{topItemCount:r}},Ke(wr));function fd(e){let r=!1,n;return(()=>(r||(r=!0,n=e()),n))}const pg=fd(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),fg=ze(([{deviation:e,deviationCommitted:r,scrollBy:n,scrollingInProgress:s,scrollTop:o},{isAtBottom:a,isScrolling:i,lastJumpDueToItemResize:l,scrollDirection:d},{listState:u},{beforeUnshiftWith:p,gap:f,shiftWithOffset:h,sizes:m},{log:g},{recalcInProgress:v}])=>{const x=Rt(Z(u,Le(l),Ht(([,S,k,R],[{bottom:w,items:E,offsetBottom:N,totalCount:T},I])=>{const A=w+N;let $=0;return k===T&&S.length>0&&E.length>0&&(E[0].originalIndex===0&&S[0].originalIndex===0||($=A-R,$!==0&&($+=I))),[$,E,T,A]},[0,[],0,0]),we(([S])=>S!==0),Le(o,d,s,a,g,v),we(([,S,k,R,,,w])=>!w&&!R&&S!==0&&k===yn),pe(([[S],,,,,k])=>(k("Upward scrolling compensation",{amount:S},st.DEBUG),S))));function b(S){S>0?(Re(n,{behavior:"auto",top:-S}),Re(e,0)):(Re(e,0),Re(n,{behavior:"auto",top:-S}))}Be(Z(x,Le(e,i)),([S,k,R])=>{R&&pg()?Re(e,k-S):b(-S)}),Be(Z(et(dt(i,!1),e,v),we(([S,k,R])=>!S&&!R&&k!==0),pe(([S,k])=>k),Yt(1)),b),xe(Z(h,pe(S=>({top:-S}))),n);let y=null;function j(){if(y===null)return;const{offset:S}=y;y=null,Re(n,{top:S}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})}return Be(r,S=>{y===null||!y.acknowledgeable||S===y.offset&&j()}),Be(Z(p,Le(m,f),pe(([S,{groupIndices:k,lastSize:R,sizeTree:w},E])=>{function N(W){return W*(R+E)}if(k.length===0)return N(S);let T=0;const I=xn(w,0);let A=0,$=0;for(;A<S;){A++,T+=I;let W=k.length===$+1?1/0:k[$+1]-k[$]-1;A+W>S&&(T-=I,W=S-A+1),A+=W,T+=N(W),$++}return T})),S=>{y={acknowledgeable:qe(e)!==S,offset:S},Re(e,S),requestAnimationFrame(j)}),{deviation:e}},Ke(mt,Nn,wr,Gt,lr,Sa)),hg=ze(([e,r,n,s,o,a,i,l,d,u,p])=>({...e,...r,...n,...s,...o,...a,...i,...l,...d,...u,...p}),Ke(Ra,ig,cr,pd,cd,lg,ng,Ta,ud,lr,dd)),hd=ze(([{data:e,defaultItemSize:r,firstItemIndex:n,fixedItemSize:s,fixedGroupSize:o,gap:a,groupIndices:i,heightEstimates:l,itemSize:d,sizeRanges:u,sizes:p,statefulTotalCount:f,totalCount:h,trackItemSizes:m},{initialItemFinalLocationReached:g,initialTopMostItemIndex:v,scrolledToInitialItem:x},b,y,j,S,{scrollToIndex:k},R,{topItemCount:w},{groupCounts:E},N])=>{const{listState:T,minOverscanItemCount:I,topItemsIndexes:A,rangeChanged:$,...W}=S;return xe($,N.scrollSeekRangeChanged),xe(Z(et(N.windowViewportRect,b.headerHeight,b.fixedHeaderHeight),pe(([C,P,L])=>Math.max(P+L+1,C.visibleHeight))),b.viewportHeight),{data:e,defaultItemHeight:r,firstItemIndex:n,fixedItemHeight:s,fixedGroupHeight:o,gap:a,groupCounts:E,heightEstimates:l,initialItemFinalLocationReached:g,initialTopMostItemIndex:v,scrolledToInitialItem:x,sizeRanges:u,topItemCount:w,topItemsIndexes:A,totalCount:h,...j,groupIndices:i,itemSize:d,listState:T,minOverscanItemCount:I,scrollToIndex:k,statefulTotalCount:f,trackItemSizes:m,rangeChanged:$,...W,...N,...b,sizes:p,...y}},Ke(Gt,En,mt,cg,ag,wr,Cn,fg,ug,od,hg));function mg(e,r){const n={},s={};let o=0;const a=e.length;for(;o<a;)s[e[o]]=1,o+=1;for(const i in r)Object.hasOwn(s,i)||(n[i]=r[i]);return n}const zn=typeof document>"u"?me.useEffect:me.useLayoutEffect;function md(e,r,n){const s=Object.keys(r.required||{}),o=Object.keys(r.optional||{}),a=Object.keys(r.methods||{}),i=Object.keys(r.events||{}),l=me.createContext({});function d(x,b){x.propsReady!==void 0&&Re(x.propsReady,!1);for(const y of s){const j=x[r.required[y]];Re(j,b[y])}for(const y of o)if(y in b){const j=x[r.optional[y]];Re(j,b[y])}x.propsReady!==void 0&&Re(x.propsReady,!0)}function u(x){return a.reduce((b,y)=>(b[y]=j=>{const S=x[r.methods[y]];Re(S,j)},b),{})}function p(x){return i.reduce((b,y)=>(b[y]=Tx(x[r.events[y]]),b),{})}const f=me.forwardRef(function(x,b){const{children:y,...j}=x,[S]=me.useState(()=>js(Ax(e),w=>{d(w,j)})),[k]=me.useState(Ni(p,S));zn(()=>{for(const w of i)w in j&&Be(k[w],j[w]);return()=>{Object.values(k).map(ka)}},[j,k,S]),zn(()=>{d(S,j)}),me.useImperativeHandle(b,Ei(u(S)));const R=n;return t.jsx(l.Provider,{value:S,children:n===void 0?y:t.jsx(R,{...mg([...s,...o,...i],j),children:y})})}),h=x=>{const b=me.useContext(l);return me.useCallback(y=>{Re(b[x],y)},[b,x])},m=x=>{const b=me.useContext(l)[x],y=me.useCallback(j=>Be(b,j),[b]);return me.useSyncExternalStore(y,()=>qe(b),()=>qe(b))},g=x=>{const b=me.useContext(l)[x],[y,j]=me.useState(Ni(qe,b));return zn(()=>Be(b,S=>{S!==y&&j(Ei(S))}),[b,y]),y},v=parseInt(me.version,10)>=18?m:g;return{Component:f,useEmitter:(x,b)=>{const y=me.useContext(l)[x];zn(()=>Be(y,b),[b,y])},useEmitterValue:v,usePublisher:h}}const xd=me.createContext(void 0),gd=me.createContext(void 0),Ks="-webkit-sticky",Bi="sticky",Ia=fd(()=>{if(typeof document>"u")return Bi;const e=document.createElement("div");return e.style.position=Ks,e.style.position===Ks?Ks:Bi});function qs(e){return"self"in e}function xg(e){return"body"in e}function vd(e,r,n,s=Vr,o,a){const i=me.useRef(null),l=me.useRef(null),d=me.useRef(null),u=me.useCallback(f=>{let h,m,g;const v=f.target;if(xg(v)||qs(v)){const b=qs(v)?v:v.defaultView;g=a===!0?vr(b,b.scrollX):b.scrollY,h=a===!0?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,m=a===!0?b.innerWidth:b.innerHeight}else g=a===!0?vr(v,v.scrollLeft):v.scrollTop,h=a===!0?v.scrollWidth:v.scrollHeight,m=a===!0?v.offsetWidth:v.offsetHeight;const x=()=>{e({scrollHeight:h,scrollTop:Math.max(g,0),viewportHeight:m})};f.suppressFlushSync===!0?x():Hf.flushSync(x),l.current!==null&&(g===l.current||g<=0||g===h-m)&&(l.current=null,r(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,r,a]);me.useEffect(()=>{const f=o??i.current;return s(o??i.current),u({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",u,{passive:!0}),()=>{s(null),f.removeEventListener("scroll",u)}},[i,u,n,s,o]);function p(f){const h=i.current;if(!h||(a===!0?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const m=f.behavior==="smooth";let g,v,x;qs(h)?(v=Math.max(or(h.document.documentElement,a===!0?"width":"height"),a===!0?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),g=a===!0?h.innerWidth:h.innerHeight,x=a===!0?vr(h,h.scrollX):h.scrollY):(v=h[a===!0?"scrollWidth":"scrollHeight"],g=or(h,a===!0?"width":"height"),x=a===!0?vr(h,h.scrollLeft):h.scrollTop);const b=v-g;if(f.top===void 0){h.scrollTo(f);return}const y=Math.ceil(Math.max(Math.min(b,f.top),0));if(f.top=y,id(g,v)||y===x){e({scrollHeight:v,scrollTop:x,viewportHeight:g}),m&&r(!0);return}m?(l.current=y,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,r(!0)},1e3)):l.current=null,a===!0&&(f={...f.behavior===void 0?{}:{behavior:f.behavior},left:Ti(h,y)}),h.scrollTo(f)}return{scrollByCallback:me.useCallback(f=>{a===!0&&(f={...f.behavior===void 0?{}:{behavior:f.behavior},...f.top===void 0?{}:{left:Ti(i.current,f.top)}}),i.current.scrollBy(f)},[a]),scrollerRef:i,scrollToCallback:p}}function La(e){return e}const gg=ze(()=>{const e=le(l=>`Item ${l}`),r=le(l=>`Group ${l}`),n=le({}),s=le(La),o=le("div"),a=le(Vr),i=(l,d=null)=>dt(Z(n,pe(u=>u[l]),Ge()),d);return{components:n,computeItemKey:s,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:r,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),vg=ze(([e,r])=>({...e,...r}),Ke(hd,gg)),yg=({height:e})=>t.jsx("div",{style:{height:e}}),bg={overflowAnchor:"none",position:Ia(),zIndex:1},yd={overflowAnchor:"none"},kg={...yd,display:"inline-block",height:"100%"},_i=me.memo(function({showTopList:e=!1}){const r=Ee("listState"),n=Nt("sizeRanges"),s=Ee("useWindowScroll"),o=Ee("customScrollParent"),a=Nt("windowScrollContainerState"),i=Nt("scrollContainerState"),l=o||s?a:i,d=Ee("itemContent"),u=Ee("context"),p=Ee("groupContent"),f=Ee("trackItemSizes"),h=Ee("itemSize"),m=Ee("log"),g=Nt("gap"),v=Ee("horizontalDirection"),{callbackRef:x}=Fx(n,h,f,e?Vr:l,m,g,o,v,Ee("skipAnimationFrameInResizeObserver")),[b,y]=me.useState(0);Pa("deviation",C=>{b!==C&&y(C)});const j=Nt("deviationCommitted");wa(()=>{j(b)},[b,j]);const S=Ee("EmptyPlaceholder"),k=Ee("ScrollSeekPlaceholder")??yg,R=Ee("ListComponent"),w=Ee("ItemComponent"),E=Ee("GroupComponent"),N=Ee("computeItemKey"),T=Ee("isSeeking"),I=Ee("groupIndices").length>0,A=Ee("alignToBottom"),$=Ee("initialItemFinalLocationReached"),W=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginInlineStart:b===0?A?"auto":0:b,paddingInlineEnd:r.offsetBottom,paddingInlineStart:r.offsetTop,whiteSpace:"nowrap"}:{marginTop:b===0?A?"auto":0:b,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&r.totalCount===0&&S!==null&&S!==void 0?t.jsx(S,{...ct(S,u)}):t.jsx(R,{...ct(R,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:W,children:(e?r.topItems:r.items).map(C=>{const P=C.originalIndex,L=N(P+r.firstItemIndex,C.data,u);return T?c.createElement(k,{...ct(k,u),height:C.size,index:C.index,key:L,type:C.type||"item",...C.type==="group"?{}:{groupIndex:C.groupIndex}}):C.type==="group"?c.createElement(E,{...ct(E,u),"data-index":P,"data-item-index":C.index,"data-known-size":C.size,key:L,style:bg},p(C.index,u)):c.createElement(w,{...ct(w,u),...Cg(w,C.data),"data-index":P,"data-item-group-index":C.groupIndex,"data-item-index":C.index,"data-known-size":C.size,key:L,style:v?kg:yd},I?d(C.index,C.groupIndex,C.data,u):d(C.index,C.data,u))})})}),jg={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},wg={outline:"none",overflowX:"auto",position:"relative"},Aa=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:void 0}),bd=(e,r,n=0)=>({...Aa(e),position:r?"relative":"absolute",top:r?-n:0}),Sg={position:Ia(),top:0,width:"100%",zIndex:1};function ct(e,r){if(typeof e!="string")return{context:r}}function Cg(e,r){return{item:typeof e=="string"?void 0:r}}const Eg=me.memo(function(){const e=Ee("HeaderComponent"),r=Nt("headerHeight"),n=Ee("HeaderFooterTag"),s=jr(me.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Ng=me.memo(function(){const e=Ee("FooterComponent"),r=Nt("footerHeight"),n=Ee("HeaderFooterTag"),s=jr(me.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null});function kd({useEmitter:e,useEmitterValue:r,usePublisher:n}){return me.memo(function({children:s,style:o,context:a,...i}){const l=n("scrollContainerState"),d=r("ScrollerComponent"),u=n("smoothScrollTargetReached"),p=r("scrollerRef"),f=r("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:g}=vd(l,u,d,p,void 0,f);return e("scrollTo",g),e("scrollBy",h),t.jsx(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?wg:jg,...o},tabIndex:0,...i,...ct(d,a),children:s})})}function jd({useEmitter:e,useEmitterValue:r,usePublisher:n}){return me.memo(function({children:s,style:o,context:a,...i}){const l=n("windowScrollContainerState"),d=r("ScrollerComponent"),u=n("smoothScrollTargetReached"),p=r("totalListHeight"),f=r("deviation"),h=r("customScrollParent"),m=me.useRef(null),g=r("scrollerRef"),{scrollByCallback:v,scrollerRef:x,scrollToCallback:b}=vd(l,u,d,g,h);return wa(()=>{var y;return x.current=h??((y=m.current)==null?void 0:y.ownerDocument.defaultView),()=>{x.current=null}},[x,h]),e("windowScrollTo",b),e("scrollBy",v),t.jsx(d,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...p===0?void 0:{height:p+f}},...i,...ct(d,a),children:s})})}const Rg=({children:e})=>{const r=me.useContext(xd),n=Nt("viewportHeight"),s=Nt("fixedItemHeight"),o=Ee("alignToBottom"),a=Ee("horizontalDirection"),i=me.useMemo(()=>Gc(n,d=>or(d,a?"width":"height")),[n,a]),l=jr(i,!0,Ee("skipAnimationFrameInResizeObserver"));return me.useEffect(()=>{r&&(n(r.viewportHeight),s(r.itemHeight))},[r,n,s]),t.jsx("div",{"data-viewport-type":"element",ref:l,style:Aa(o),children:e})},Tg=({children:e})=>{const r=me.useContext(xd),n=Nt("windowViewportRect"),s=Nt("fixedItemHeight"),o=Ee("customScrollParent"),a=Ee("useWindowScroll"),i=Ee("topListHeight"),l=Yc(n,o,Ee("skipAnimationFrameInResizeObserver")),d=Ee("alignToBottom");return me.useEffect(()=>{r&&(s(r.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,n,s]),t.jsx("div",{"data-viewport-type":"window",ref:l,style:bd(d,a,i),children:e})},Ig=({children:e})=>{const r=Ee("TopItemListComponent")??"div",n=Ee("headerHeight"),s={...Sg,marginTop:`${n}px`},o=Ee("context");return t.jsx(r,{style:s,...ct(r,o),children:e})},Lg=me.memo(function(e){const r=Ee("useWindowScroll"),n=Ee("topItemsIndexes").length>0,s=Ee("customScrollParent"),o=Ee("context");return t.jsxs(s||r?$g:Pg,{...e,context:o,children:[n&&t.jsx(Ig,{children:t.jsx(_i,{showTopList:!0})}),t.jsxs(s||r?Tg:Rg,{children:[t.jsx(Eg,{}),t.jsx(_i,{}),t.jsx(Ng,{})]})]})}),{Component:Ag,useEmitter:Pa,useEmitterValue:Ee,usePublisher:Nt}=md(vg,{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"}},Lg),Pg=kd({useEmitter:Pa,useEmitterValue:Ee,usePublisher:Nt}),$g=jd({useEmitter:Pa,useEmitterValue:Ee,usePublisher:Nt}),Mg=Ag,Fg=ze(()=>{const e=le(u=>t.jsxs("td",{children:["Item $",u]})),r=le(null),n=le(u=>t.jsxs("td",{colSpan:1e3,children:["Group ",u]})),s=le(null),o=le(null),a=le({}),i=le(La),l=le(Vr),d=(u,p=null)=>dt(Z(a,pe(f=>f[u]),Ge()),p);return{components:a,computeItemKey:i,context:r,EmptyPlaceholder:d("EmptyPlaceholder"),FillerRow:d("FillerRow"),fixedFooterContent:o,fixedHeaderContent:s,itemContent:e,groupContent:n,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TableBodyComponent:d("TableBody","tbody"),TableComponent:d("Table","table"),TableFooterComponent:d("TableFoot","tfoot"),TableHeadComponent:d("TableHead","thead"),TableRowComponent:d("TableRow","tr"),GroupComponent:d("Group","tr")}});Ke(hd,Fg);Ia();const Oi={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Dg={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Wi,floor:as,max:dn,min:Ys,round:Ui}=Math;function Hi(e,r,n){return Array.from({length:r-e+1}).map((s,o)=>({data:n===null?null:n[o+e],index:o+e}))}function zg(e){return{...Dg,items:e}}function Bn(e,r){return e!==void 0&&e.width===r.width&&e.height===r.height}function Bg(e,r){return e!==void 0&&e.column===r.column&&e.row===r.row}const _g=ze(([{increaseViewportBy:e,listBoundary:r,overscan:n,visibleRange:s},{footerHeight:o,headerHeight:a,scrollBy:i,scrollContainerState:l,scrollTo:d,scrollTop:u,smoothScrollTargetReached:p,viewportHeight:f},h,m,{didMount:g,propsReady:v},{customScrollParent:x,useWindowScroll:b,windowScrollContainerState:y,windowScrollTo:j,windowViewportRect:S},k])=>{const R=le(0),w=le(0),E=le(Oi),N=le({height:0,width:0}),T=le({height:0,width:0}),I=Me(),A=Me(),$=le(0),W=le(null),C=le({column:0,row:0}),P=Me(),L=Me(),F=le(!1),H=le(0),re=le(!0),V=le(!1),O=le(!1);Be(Z(g,Le(H),we(([M,U])=>!Yo(U))),()=>{Re(re,!1)}),Be(Z(et(g,re,T,N,H,V),we(([M,U,K,X,,ie])=>M&&!U&&K.height!==0&&X.height!==0&&!ie)),([,,,,M])=>{if(M===void 0){Re(re,!0);return}Re(V,!0),Ea(1,()=>{Re(I,M)}),Mt(Z(u),()=>{Re(r,[0,0]),Re(re,!0)})}),xe(Z(L,we(M=>M!=null&&M.scrollTop>0),Wt(0)),w),Be(Z(g,Le(L),we(([,M])=>M!=null)),([,M])=>{M&&(Re(N,M.viewport),Re(T,M.item),Re(C,M.gap),M.scrollTop>0&&(Re(F,!0),Mt(Z(u,br(1)),U=>{Re(F,!1)}),Re(d,{top:M.scrollTop})))}),xe(Z(N,pe(({height:M})=>M)),f),xe(Z(et(je(N,Bn),je(T,Bn),je(C,(M,U)=>M!==void 0&&M.column===U.column&&M.row===U.row),je(u)),pe(([M,U,K,X])=>({gap:K,item:U,scrollTop:X,viewport:M}))),P),xe(Z(et(je(R),s,je(C,Bg),je(T,Bn),je(N,Bn),je(W),je(w),je(F),je(re),je(H)),we(([,,,,,,,M])=>!M),pe(([M,[U,K],X,ie,G,te,de,,fe,ke])=>{const{column:B,row:Y}=X,{height:J,width:ee}=ie,{width:ue}=G;if(de===0&&(M===0||ue===0))return Oi;if(ee===0){const _e=Na(ke,M),wt=_e+Math.max(de-1,0);return zg(Hi(_e,wt,te))}const be=wd(ue,ee,B);let Te,Q;fe?U===0&&K===0&&de>0?(Te=0,Q=de-1):(Te=be*as((U+Y)/(J+Y)),Q=be*Wi((K+Y)/(J+Y))-1,Q=Ys(M-1,dn(Q,be-1)),Te=Ys(Q,dn(0,Te))):(Te=0,Q=-1);const Se=Hi(Te,Q,te),{bottom:he,top:Ce}=Vi(G,X,ie,Se),Ae=Wi(M/be),Pe=Ae*J+(Ae-1)*Y-he;return{bottom:he,itemHeight:J,items:Se,itemWidth:ee,offsetBottom:Pe,offsetTop:Ce,top:Ce}})),E),xe(Z(W,we(M=>M!==null),pe(M=>M.length)),R),xe(Z(et(N,T,E,C),we(([M,U,{items:K}])=>K.length>0&&U.height!==0&&M.height!==0),pe(([M,U,{items:K},X])=>{const{bottom:ie,top:G}=Vi(M,X,U,K);return[G,ie]}),Ge(gn)),r);const se=le(!1);xe(Z(u,Le(se),pe(([M,U])=>U||M!==0)),se);const ge=Rt(Z(et(E,R),we(([{items:M}])=>M.length>0),Le(se),we(([[M,U],K])=>{const X=M.items[M.items.length-1].index===U-1;return(K||M.bottom>0&&M.itemHeight>0&&M.offsetBottom===0&&M.items.length===U)&&X}),pe(([[,M]])=>M-1),Ge())),ye=Rt(Z(je(E),we(({items:M})=>M.length>0&&M[0].index===0),Wt(0),Ge())),z=Rt(Z(je(E),Le(F),we(([{items:M},U])=>M.length>0&&!U),pe(([{items:M}])=>({endIndex:M[M.length-1].index,startIndex:M[0].index})),Ge(td),Yt(0)));xe(z,m.scrollSeekRangeChanged),xe(Z(I,Le(N,T,R,C),pe(([M,U,K,X,ie])=>{const G=ad(M),{align:te,behavior:de,offset:fe}=G;let ke=G.index;ke==="LAST"&&(ke=X-1),ke=dn(0,ke,Ys(X-1,ke));let B=Jo(U,ie,K,ke);return te==="end"?B=Ui(B-U.height+K.height):te==="center"&&(B=Ui(B-U.height/2+K.height/2)),fe!==void 0&&fe!==0&&(B+=fe),{behavior:de,top:B}})),d);const ne=dt(Z(E,pe(M=>M.offsetBottom+M.bottom)),0);return xe(Z(S,pe(M=>({height:M.visibleHeight,width:M.visibleWidth}))),N),{customScrollParent:x,data:W,deviation:$,footerHeight:o,gap:C,headerHeight:a,increaseViewportBy:e,initialItemCount:w,itemDimensions:T,overscan:n,restoreStateFrom:L,scrollBy:i,scrollContainerState:l,scrollHeight:A,scrollTo:d,scrollToIndex:I,scrollTop:u,smoothScrollTargetReached:p,totalCount:R,useWindowScroll:b,viewportDimensions:N,windowScrollContainerState:y,windowScrollTo:j,windowViewportRect:S,...m,gridState:E,horizontalDirection:O,initialTopMostItemIndex:H,totalListHeight:ne,...h,endReached:ge,propsReady:v,rangeChanged:z,startReached:ye,stateChanged:P,stateRestoreInProgress:F,...k}},Ke(Ra,mt,Nn,pd,cr,Ta,lr));function wd(e,r,n){return dn(1,as((e+n)/(as(r)+n)))}function Vi(e,r,n,s){const{height:o}=n;if(o===void 0||s.length===0)return{bottom:0,top:0};const a=Jo(e,r,n,s[0].index);return{bottom:Jo(e,r,n,s[s.length-1].index)+o,top:a}}function Jo(e,r,n,s){const o=wd(e.width,n.width,r.column),a=as(s/o),i=a*n.height+dn(0,a-1)*r.row;return i>0?i+r.row:i}const Og=ze(()=>{const e=le(f=>`Item ${f}`),r=le({}),n=le(null),s=le("virtuoso-grid-item"),o=le("virtuoso-grid-list"),a=le(La),i=le("div"),l=le(Vr),d=(f,h=null)=>dt(Z(r,pe(m=>m[f]),Ge()),h),u=le(!1),p=le(!1);return xe(je(p),u),{components:r,computeItemKey:a,context:n,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:i,itemClassName:s,ItemComponent:d("Item","div"),itemContent:e,listClassName:o,ListComponent:d("List","div"),readyStateChanged:u,reportReadyState:p,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),Wg=ze(([e,r])=>({...e,...r}),Ke(_g,Og)),Ug=me.memo(function(){const e=Ve("gridState"),r=Ve("listClassName"),n=Ve("itemClassName"),s=Ve("itemContent"),o=Ve("computeItemKey"),a=Ve("isSeeking"),i=Lt("scrollHeight"),l=Ve("ItemComponent"),d=Ve("ListComponent"),u=Ve("ScrollSeekPlaceholder"),p=Ve("context"),f=Lt("itemDimensions"),h=Lt("gap"),m=Ve("log"),g=Ve("stateRestoreInProgress"),v=Lt("reportReadyState"),x=jr(me.useMemo(()=>b=>{const y=b.parentElement.parentElement.scrollHeight;i(y);const j=b.firstChild;if(j!==null){const{height:S,width:k}=j.getBoundingClientRect();f({height:S,width:k})}h({column:Gi("column-gap",getComputedStyle(b).columnGap,m),row:Gi("row-gap",getComputedStyle(b).rowGap,m)})},[i,f,h,m]),!0,!1);return wa(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),g?null:t.jsx(d,{className:r,ref:x,...ct(d,p),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(b=>{const y=o(b.index,b.data,p);return a?t.jsx(u,{...ct(u,p),height:e.itemHeight,index:b.index,width:e.itemWidth},y):c.createElement(l,{...ct(l,p),className:n,"data-index":b.index,key:y},s(b.index,b.data,p))})})}),Hg=me.memo(function(){const e=Ve("HeaderComponent"),r=Lt("headerHeight"),n=Ve("headerFooterTag"),s=jr(me.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,!1),o=Ve("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Vg=me.memo(function(){const e=Ve("FooterComponent"),r=Lt("footerHeight"),n=Ve("headerFooterTag"),s=jr(me.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,!1),o=Ve("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Gg=({children:e})=>{const r=me.useContext(gd),n=Lt("itemDimensions"),s=Lt("viewportDimensions"),o=jr(me.useMemo(()=>a=>{s(a.getBoundingClientRect())},[s]),!0,!1);return me.useEffect(()=>{r&&(s({height:r.viewportHeight,width:r.viewportWidth}),n({height:r.itemHeight,width:r.itemWidth}))},[r,s,n]),t.jsx("div",{ref:o,style:Aa(!1),children:e})},Kg=({children:e})=>{const r=me.useContext(gd),n=Lt("windowViewportRect"),s=Lt("itemDimensions"),o=Ve("customScrollParent"),a=Ve("useWindowScroll"),i=Yc(n,o,!1);return me.useEffect(()=>{r&&(s({height:r.itemHeight,width:r.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,n,s]),t.jsx("div",{ref:i,style:bd(!1,a),children:e})},qg=me.memo(function({...e}){const r=Ve("useWindowScroll"),n=Ve("customScrollParent"),s=n||r?Jg:Yg,o=n||r?Kg:Gg,a=Ve("context");return t.jsx(s,{...e,...ct(s,a),children:t.jsxs(o,{children:[t.jsx(Hg,{}),t.jsx(Ug,{}),t.jsx(Vg,{})]})})}),{useEmitter:Sd,useEmitterValue:Ve,usePublisher:Lt}=md(Wg,{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"}},qg),Yg=kd({useEmitter:Sd,useEmitterValue:Ve,usePublisher:Lt}),Jg=jd({useEmitter:Sd,useEmitterValue:Ve,usePublisher:Lt});function Gi(e,r,n){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,r,st.WARN),r==="normal"?0:parseInt(r??"0",10)}const Qg={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Cd={source:"Own",installed:"Installed"};function Xg(e){try{const r=localStorage.getItem(e);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(e);if(r!=null)return r==="true"}}catch{}return!1}function Zg(e,r){const n=r?"true":"false";try{localStorage.setItem(e,n)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(e,n)}catch{}}function Ki({origin:e,count:r,filteredCount:n,updateCount:s,children:o}){const a=Qg[e],[i,l]=c.useState(()=>Xg(a)),d=c.useCallback(()=>{l(h=>{const m=!h;return Zg(a,m),m})},[a]),u=Cd[e],p=`sidebar-section-${e}-header`,f=`sidebar-section-${e}-group`;return t.jsxs("section",{"aria-labelledby":p,style:{display:"flex",flexDirection:"column",minHeight:0},children:[t.jsxs("button",{id:p,type:"button","data-testid":"sidebar-section-header","aria-expanded":!i,"aria-controls":f,onClick:d,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:[t.jsx(tv,{collapsed:i}),t.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:u}),t.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:n!=null&&n!==r?`(${n} of ${r})`:`(${r})`}),s!=null&&s>0&&t.jsx(ev,{origin:e,updateCount:s})]}),!i&&t.jsx("div",{id:f,role:"group","aria-labelledby":p,style:{display:"flex",flexDirection:"column",minHeight:0},children:o})]})}function ev({origin:e,updateCount:r}){const[n,s]=c.useState(!1),o=Cd[e].toLowerCase(),a=`${r} updates available in ${o} section, view all`;return t.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":a,onClick:i=>{i.stopPropagation(),window.location.hash="#/updates"},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),i.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>s(!0),onBlur:()=>s(!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:n?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",t.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function tv({collapsed:e}){return t.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:e?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})}function $a(e,r){const n=r.trim().toLowerCase();return n?e.skill.toLowerCase().includes(n)||e.plugin.toLowerCase().includes(n)||e.dir.toLowerCase().includes(n):!0}function rv({value:e,onChange:r,placeholder:n="Filter skills…",validationPattern:s,validationMessage:o="Invalid filter expression"}){const a=c.useRef(null),i=c.useId(),l=!!s&&e.trim()!==""&&!s.test(e);return c.useEffect(()=>{function d(u){var h;if(u.key!=="/")return;const p=u.target;if(!p)return;const f=p.tagName;f==="INPUT"||f==="TEXTAREA"||p.isContentEditable||(u.preventDefault(),(h=a.current)==null||h.focus())}return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[]),t.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("path",{d:"M21 21l-4.35-4.35"})]}),t.jsx("input",{ref:a,type:"search","aria-label":"Filter skills","aria-invalid":l?!0:void 0,"aria-describedby":l?i:void 0,value:e,placeholder:n,onChange:d=>r(d.currentTarget.value),onKeyDown:d=>{d.key==="Escape"&&(r(""),d.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"}}),l&&t.jsx("span",{id:i,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:o}),t.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:e?"none":"inline-block"},children:"/"})]})}function nv({target:e}){const r=typeof e=="string"&&e.length>0,n=r?`symlinked → ${e}`:"symlinked — cycle detected or target unresolved",s=r?`symlinked from ${e}`:"symlinked, target unresolved";return t.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":s,title:n,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:t.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:[t.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"}),t.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 sv({skill:e}){if(!e.updateAvailable)return null;const r=e.currentVersion??"",n=e.latestVersion,s=n?`Update available: ${r} → ${n}`.trim():"Update available";return t.jsx("span",{"data-testid":"skill-row-update-glyph",title:s,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 19V5"}),t.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function ov({skillId:e,trackedForUpdates:r}){let n=null;try{n=c.useContext($c)}catch{n=null}const s=n==null?void 0:n.updatesById.get(e);if(s){const o=`Update available → ${s.version}${s.diffSummary?` — ${s.diffSummary}`:""}`;return t.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${s.version}`,title:o,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:t.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 av(e,r,n){if(!(!e||e==="frontmatter"))return e==="plugin"?`Inherited from ${n&&n.trim()!==""?n:"plugin"} plugin v${r}`:e==="registry"?"Inherited from registry":"No version declared"}function Rn(e){const{version:r,showPrefix:n=!0,size:s="md",source:o,pluginName:a}=e,i=typeof r=="string"?r.trim():"",l=i===""||i==="0.0.0"?"1.0.0":i,d=n&&!l.startsWith("v")?`v${l}`:l,u=s==="sm"?10:12,p=s==="sm"?1:2,f=s==="sm"?5:8,h=o==="registry"||o==="plugin",m=av(o,l,a),g=e.title??m,v={display:"inline-flex",alignItems:"center",padding:`${p}px ${f}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return h&&(v.fontStyle="italic"),t.jsx("span",{"data-testid":e["data-testid"]??"version-badge","data-version":l,"data-version-source":o,title:g,style:v,children:d})}const iv={small:{fontSize:"0.625rem",padX:"0.4rem",padY:"0.1rem",height:"18px",icon:10,showName:!1},inline:{fontSize:"0.6875rem",padX:"0.5rem",padY:"0.15rem",height:"22px",icon:12,showName:!0},large:{fontSize:"0.8125rem",padX:"0.65rem",padY:"0.25rem",height:"28px",icon:14,showName:!0}};function Ma({size:e}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[t.jsx("rect",{x:"2.75",y:"7",width:"10.5",height:"6.75",rx:"1.25",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("path",{d:"M5 7V5.25C5 3.59 6.34 2.25 8 2.25C9.66 2.25 11 3.59 11 5.25V7",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",fill:"none"}),t.jsx("circle",{cx:"8",cy:"10.25",r:"0.9",fill:"currentColor"})]})}function lv({tenantName:e,variant:r="inline"}){const n=iv[r],s={display:"inline-flex",alignItems:"center",gap:"0.3rem",padding:`${n.padY} ${n.padX}`,height:n.height,borderRadius:"4px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:n.fontSize,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",whiteSpace:"nowrap",lineHeight:1,color:"#92400E",backgroundColor:"#FFFBEB",border:"1px solid #FCD34D"};return t.jsxs("span",{role:"status","aria-label":`Private skill — visible to ${e} members only`,style:s,"data-private":"true",children:[t.jsx(Ma,{size:n.icon}),t.jsx("span",{children:"Private"}),n.showName&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,style:{opacity:.55,fontWeight:500},children:"·"}),t.jsx("span",{style:{fontWeight:500,textTransform:"none",letterSpacing:"0.01em"},children:e})]})]})}function cv({repoFullName:e,variant:r="row"}){const n=e?`From private repo: ${e}`:"From a private repo",s={display:"inline-flex",alignItems:"center",gap:r==="tag"?4:0,height:18,padding:r==="tag"?"0 6px":"0 3px",borderRadius:4,color:"var(--private-fg, #92400e)",backgroundColor:"var(--private-bg, rgba(245,158,11,0.12))",border:"1px solid var(--private-border-soft, rgba(245,158,11,0.35))",fontFamily:"var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)",fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",lineHeight:1,flexShrink:0};return t.jsxs("span",{role:"status","aria-label":n,title:n,"data-testid":"skill-row-private-chip","data-private":"true","data-variant":r,style:s,children:[t.jsx(Ma,{size:11}),r==="tag"?t.jsx("span",{children:"Private"}):null]})}function dv({skill:e,isSelected:r,onSelect:n,onContextMenu:s,dirty:o,repoVisibility:a,repoFullName:i}){const l=e.origin==="installed"?"var(--status-installed)":"var(--status-own)";return t.jsxs("button",{type:"button",onClick:n,onContextMenu:s?d=>{d.preventDefault(),s(d,e)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":e.origin,"data-skill-id":`${e.plugin}/${e.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"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:[t.jsx("span",{"aria-hidden":"true","aria-label":e.updateAvailable?"Update available":void 0,title:e.updateAvailable?`Update available${e.latestVersion?` → ${e.latestVersion}`:""}`:void 0,style:{width:e.updateAvailable?10:6,height:e.updateAvailable?10:6,borderRadius:"50%",background:l,display:"inline-block",flexShrink:0,boxShadow:e.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),t.jsx("span",{title:e.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.skill}),o&&t.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)"}}),t.jsx(Rn,{version:e.resolvedVersion??e.version??"1.0.0",source:e.versionSource??(e.version?"frontmatter":"default"),pluginName:e.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),a==="private"&&t.jsx(cv,{repoFullName:i??null}),e.isSymlink&&t.jsx(nv,{target:e.symlinkTarget??null}),t.jsx(sv,{skill:e}),t.jsx(ov,{skillId:`${e.plugin}/${e.skill}`,trackedForUpdates:e.trackedForUpdates??!0})]})}const un=c.memo(dv),Ed={platformBaseUrl:"",authMode:"cookie",getAuthHeader:async()=>null},Nd=c.createContext(Ed);function uv({value:e,children:r}){const n=c.useMemo(()=>({...Ed,...e??{}}),[e==null?void 0:e.platformBaseUrl,e==null?void 0:e.authMode,e==null?void 0:e.getAuthHeader,e==null?void 0:e.fetchImpl]);return t.jsx(Nd.Provider,{value:n,children:r})}function xt(){return c.useContext(Nd)}function pv(e,r){const n=e.platformBaseUrl.replace(/\/+$/,""),s=r.startsWith("/")?r:`/${r}`;return`${n}${s}`}const Gr=6e4,nt={profile:()=>"account:profile",repos:()=>"account:repos",tokens:()=>"account:tokens",skills:()=>"account:skills",notifications:()=>"account:notifications",exports:()=>"account:exports"};async function gt(e,r,n={}){const s=e.fetchImpl??globalThis.fetch.bind(globalThis),o=new Headers(n.headers??{});if(n.body&&!o.has("Content-Type")&&o.set("Content-Type","application/json"),e.authMode==="bearer"){const l=await e.getAuthHeader();l&&o.set("Authorization",l)}const a=e.authMode==="cookie"?"include":"omit",i=await s(pv(e,r),{...n,headers:o,credentials:a});if(!i.ok){let l="";try{l=await i.text()}catch{}const d=new Error(`Request to ${r} failed (${i.status}): ${l.slice(0,240)}`);throw d.status=i.status,d}if(i.status!==204)return await i.json()}function Tn(){const e=xt();return It(nt.profile(),()=>gt(e,"/api/v1/account/profile"),{ttl:Gr})}function Rd(){const e=xt();return c.useCallback(async r=>{const n=await gt(e,"/api/v1/account/profile",{method:"PATCH",body:JSON.stringify(r)});return He(nt.profile()),n},[e])}function Ss(){const e=xt();return It(nt.repos(),async()=>fv(await gt(e,"/api/v1/account/repos")),{ttl:Gr})}function Fa(e){return(e==null?void 0:e.repos)??[]}function fv(e){if(Array.isArray(e))return{repos:e,totalCount:e.length,publicCount:e.filter(n=>!n.isPrivate).length,privateCount:e.filter(n=>n.isPrivate).length};const r=Array.isArray(e==null?void 0:e.repos)?e.repos:[];return{repos:r,totalCount:(e==null?void 0:e.totalCount)??r.length,publicCount:(e==null?void 0:e.publicCount)??r.filter(n=>!n.isPrivate).length,privateCount:(e==null?void 0:e.privateCount)??r.filter(n=>n.isPrivate).length}}function Td(){const e=xt();return c.useCallback(async r=>{await gt(e,`/api/v1/account/repos/${r}/resync`,{method:"POST"}),He(nt.repos())},[e])}function Id(){const e=xt();return c.useCallback(async r=>{await gt(e,`/api/v1/account/repos/${r}`,{method:"DELETE"}),He(nt.repos())},[e])}function Ld(){const e=xt();return It(nt.tokens(),async()=>hv(await gt(e,"/api/v1/account/tokens")),{ttl:Gr})}function hv(e){return Array.isArray(e)?e:e.tokens??[]}function Ad(){const e=xt();return c.useCallback(async r=>{const n=await gt(e,"/api/v1/account/tokens",{method:"POST",body:JSON.stringify(r)});return He(nt.tokens()),n},[e])}function Pd(){const e=xt();return c.useCallback(async r=>{await gt(e,`/api/v1/account/tokens/${r}`,{method:"DELETE"}),He(nt.tokens())},[e])}function $d(){const e=xt();return It(nt.notifications(),()=>gt(e,"/api/v1/account/notifications"),{ttl:Gr})}function Md(){const e=xt();return c.useCallback(async r=>{const n=await gt(e,"/api/v1/account/notifications",{method:"PATCH",body:JSON.stringify(r)});return He(nt.notifications()),n},[e])}function mv(){const e=xt();return It(nt.skills(),()=>gt(e,"/api/v1/account/skills/summary"),{ttl:Gr})}function Fd(){const e=xt();return It(nt.exports(),async()=>(await gt(e,"/api/v1/account/export")).exports,{ttl:Gr})}function Dd(){const e=xt();return c.useCallback(async()=>{await gt(e,"/api/v1/account/sign-out-all",{method:"POST"}),He(nt.profile()),He(nt.repos()),He(nt.tokens()),He(nt.notifications()),He(nt.skills()),He(nt.exports())},[e])}function zd(){const e=xt();return c.useCallback(async()=>{const r=await gt(e,"/api/v1/account/export",{method:"POST"});return He(nt.exports()),r},[e])}function Bd(){const e=xt();return c.useCallback(async r=>{await gt(e,"/api/v1/account/delete",{method:"POST",body:JSON.stringify({confirmHandle:r})})},[e])}function xv(){return{profile:Tn(),repos:Ss(),tokens:Ld(),skills:mv(),notifications:$d(),exports:Fd(),updateProfile:Rd(),resyncRepo:Td(),disconnectRepo:Id(),createToken:Ad(),revokeToken:Pd(),updateNotificationPrefs:Md(),signOutAll:Dd(),requestExport:zd(),deleteAccount:Bd()}}const gv=/^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/?#]+?)(?:\.git)?\/?$/i,vv=/^git@github\.com:([^/]+)\/([^/?#]+?)(?:\.git)?$/i;function In(e){if(!e)return null;const r=e.trim(),n=gv.exec(r);if(n)return`${n[1].toLowerCase()}/${n[2].toLowerCase()}`;const s=vv.exec(r);return s?`${s[1].toLowerCase()}/${s[2].toLowerCase()}`:null}function _d(e){const r=new Map;for(const n of e)r.set(n.repoFullName.toLowerCase(),n);return r}function yv(e,r){const n=In(e);if(!n)return{visibility:"unknown",repo:null};const s=r.get(n);return s?{visibility:s.isPrivate?"private":"public",repo:s}:{visibility:"unknown",repo:null}}function bv(e){const{data:r}=Ss(),n=c.useMemo(()=>_d(Fa(r)),[r]);return yv(e,n)}function Od(){const{data:e,loading:r}=Ss(),n=Fa(e);return{lookup:c.useMemo(()=>_d(n),[n]),repos:n,loading:!!r,privateCount:(e==null?void 0:e.privateCount)??n.filter(o=>o.isPrivate).length,publicCount:(e==null?void 0:e.publicCount)??n.filter(o=>!o.isPrivate).length}}function Wd({plugin:e,skills:r,selectedKey:n,onSelect:s,onContextMenu:o,dirtySkillIds:a,repoVisibilityLookup:i}){var p;const l=[...r].sort((f,h)=>f.skill.localeCompare(h.skill)),d=(p=r[0])==null?void 0:p.pluginDisplay,u=!!d&&d.toLowerCase()!==e.toLowerCase();return t.jsxs("div",{role:"group","aria-label":`${e} (${r.length})`,children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 12px 4px 14px"},children:[t.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:e,children:e}),t.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]}),u&&t.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:d,children:d})]}),t.jsx("div",{role:"list",children:l.map(f=>{const h=!!n&&n.plugin===f.plugin&&n.skill===f.skill,m=i?In(f.repoUrl):null,g=m?i.get(m)??null:null,v=g?g.isPrivate?"private":"public":"unknown";return t.jsx("div",{role:"listitem",children:t.jsx(un,{skill:f,isSelected:h,onSelect:()=>s(f),onContextMenu:o,dirty:a==null?void 0:a.has(`${f.plugin}/${f.skill}`),repoVisibility:v,repoFullName:(g==null?void 0:g.repoFullName)??null})},`${f.plugin}/${f.skill}`)})})]})}function kv(e,r){if(!r)return!1;const n=In(e.repoUrl);if(!n)return!1;const s=r.get(n);return(s==null?void 0:s.isPrivate)===!0}function jv(e,r){const n=[],s=[];let o=0,a=0;for(const[i,l]of e){const d=[],u=[];for(const p of l)kv(p,r)?d.push(p):u.push(p);d.length>0&&(n.push([i,d]),o+=d.length),u.length>0&&(s.push([i,u]),a+=u.length)}return{privateItems:n,publicItems:s,privateCount:o,publicCount:a}}function wv(e){try{const r=localStorage.getItem(e);if(r!=null)return r==="true"}catch{}return!1}function Sv(e,r){try{localStorage.setItem(e,r?"true":"false")}catch{}}function Cv({items:e,agentId:r,sectionName:n,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:l,children:d}){const{privateItems:u,publicItems:p,privateCount:f,publicCount:h}=jv(e,s);if(f===0||h===0)return t.jsx(t.Fragment,{children:d});const m=`vskill-sidebar-${r}-section-${n}-private-collapsed`,g=`vskill-sidebar-${r}-section-${n}-public-collapsed`;return t.jsxs("div",{"data-testid":"section-privacy-subgroups",children:[t.jsx(qi,{testId:"sidebar-subgroup-private",storageKey:m,icon:"🔒",label:"Private repos",count:f,items:u,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:l}),t.jsx(qi,{testId:"sidebar-subgroup-public",storageKey:g,icon:"🌐",label:"Public repos",count:h,items:p,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:l})]})}function qi({testId:e,storageKey:r,icon:n,label:s,count:o,items:a,repoVisibilityLookup:i,selectedKey:l,onSelect:d,onContextMenu:u,dirtySkillIds:p}){const[f,h]=c.useState(()=>wv(r)),m=c.useCallback(()=>{h(v=>{const x=!v;return Sv(r,x),x})},[r]),g=`${e}-group`;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","data-testid":e,"aria-expanded":!f,"aria-controls":g,onClick:m,style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"6px 12px 4px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[t.jsx("span",{"aria-hidden":"true",style:{fontSize:11},children:n}),t.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-secondary)"},children:s}),t.jsxs("span",{style:{fontSize:10,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",o,")"]})]}),!f&&t.jsx("div",{id:g,role:"group",children:a.map(([v,x])=>t.jsx(Wd,{plugin:v,skills:x,selectedKey:l,onSelect:d,onContextMenu:u,dirtySkillIds:p,repoVisibilityLookup:i},v))})]})}function Ev(e,r){if(!e||typeof window>"u")return r;try{const n=window.localStorage.getItem(e);return n===null?r:n==="true"}catch{return r}}function Js({skills:e,pluginName:r,initialCollapsed:n=!1,persistKey:s,renderSkill:o,headerActionSlot:a,forceOpen:i=!1}){var m;const l=r??((m=e[0])==null?void 0:m.pluginName)??"unknown-plugin",[d,u]=c.useState(()=>Ev(s,n)),p=i?!1:d,f=c.useCallback(()=>{u(g=>{const v=!g;if(s&&typeof window<"u")try{window.localStorage.setItem(s,String(v))}catch{}return v})},[s]),h=p?"▸":"▾";return t.jsxs("div",{"data-vskill-plugin-tree":l,role:"group","aria-label":`${l} (${e.length})`,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[t.jsxs("button",{type:"button",onClick:f,"aria-expanded":!p,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:[t.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:h}),t.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:l}),t.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",e.length,")"]})]}),a&&t.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:a})]}),!p&&t.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:e.map(g=>t.jsx("div",{"data-vskill-plugin-skill":g.pluginNamespace??g.skill,children:o(g)},`${g.pluginNamespace??g.skill}`))})]})}function ts({open:e,title:r,body:n,confirmLabel:s="Confirm",cancelLabel:o="Cancel",variant:a="default",onConfirm:i,onCancel:l}){const d=c.useRef(null),u=c.useRef(null),p=c.useRef(null);if(c.useEffect(()=>{if(e)return p.current=document.activeElement??null,requestAnimationFrame(()=>{var g;(g=u.current)==null||g.focus()}),()=>{var g,v;(v=(g=p.current)==null?void 0:g.focus)==null||v.call(g),p.current=null}},[e]),c.useEffect(()=>{if(!e)return;function g(v){if(v.key==="Escape"){v.preventDefault(),l();return}if(v.key==="Tab"&&d.current){const x=d.current.querySelectorAll("button:not([disabled])");if(x.length===0)return;const b=x[0],y=x[x.length-1];v.shiftKey&&document.activeElement===b?(v.preventDefault(),y.focus()):!v.shiftKey&&document.activeElement===y&&(v.preventDefault(),b.focus())}}return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[e,l]),!e)return null;const f="confirm-dialog-title",h="confirm-dialog-body",m=a==="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 t.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:g=>{g.target===g.currentTarget&&l()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:t.jsxs("div",{ref:d,role:"alertdialog","aria-modal":"true","aria-labelledby":f,"aria-describedby":h,"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:[t.jsx("h2",{id:f,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:r}),t.jsx("p",{id:h,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:n}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[t.jsx("button",{ref:u,type:"button","data-testid":"confirm-dialog-cancel",onClick:l,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:o}),t.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:i,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...m},children:s})]})]})})}function Nv(e){const r=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return r.includes("mac")?"system Trash":r.includes("win")?"Recycle Bin":"Trash"}function Qs(e,r){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function Rv({pluginName:e,enabled:r,onAfterAction:n}){const[s,o]=c.useState(!1),[a,i]=c.useState(null),[l,d]=c.useState(null),[u,p]=c.useState(!1),f=c.useRef(null);c.useEffect(()=>{if(!s)return;function g(v){f.current&&!f.current.contains(v.target)&&o(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[s]);async function h(g){i(g),d(null);try{const v=await fetch(`/api/plugins/${encodeURIComponent(e)}/${g}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),x=await v.json().catch(()=>({}));if(!v.ok||!x.ok){const b=x.error??`${g} failed (${v.status})`;d(b),g==="uninstall"&&Qs(`Failed to uninstall ${e}: ${b}`,"error");return}if(g==="uninstall"){const b=x.fallback==="orphan-cache-removed"?`Removed orphaned ${e}`:`Uninstalled ${e}`;Qs(b,"success")}He("skills"),Hc(),n==null||n(),o(!1)}catch(v){const x=v instanceof Error?v.message:String(v);d(x),g==="uninstall"&&Qs(`Failed to uninstall ${e}: ${x}`,"error")}finally{i(null)}}function m(){p(!0)}return t.jsxs("div",{ref:f,style:{position:"relative",display:"inline-flex"},children:[t.jsx("button",{type:"button","aria-label":`Manage ${e}`,title:`Manage ${e}`,onClick:g=>{g.stopPropagation(),o(v=>!v)},"data-vskill-plugin-action-trigger":e,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:s?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:g=>{g.currentTarget.style.color="var(--text-primary)",g.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:g=>{g.currentTarget.style.color="var(--text-tertiary)",g.currentTarget.style.background=s?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),s&&t.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:[r?t.jsx(Xs,{onClick:()=>void h("disable"),disabled:a!==null,busy:a==="disable",label:"Disable",hint:"Keep installed, turn off"}):t.jsx(Xs,{onClick:()=>void h("enable"),disabled:a!==null,busy:a==="enable",label:"Enable",hint:"Activate plugin"}),t.jsx(Xs,{onClick:m,disabled:a!==null,busy:a==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),l&&t.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:l})]}),t.jsx(ts,{open:u,title:`Uninstall ${e}?`,body:`This removes the ${e} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{p(!1),o(!1)},onConfirm:()=>{p(!1),h("uninstall")}})]})}function Xs({onClick:e,disabled:r,busy:n,label:s,hint:o,danger:a}){return t.jsxs("button",{type:"button",onClick:i=>{i.stopPropagation(),e()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:a?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!n?.5:1,fontFamily:"inherit"},onMouseEnter:i=>{r||(i.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:i=>{i.currentTarget.style.background="transparent"},children:[t.jsx("div",{style:{fontSize:12,fontWeight:500},children:n?`${s}…`:s}),t.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:o})]})}const Tv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function Iv({anchorSkillDir:e,candidateLabel:r,initialName:n,initialDescription:s,onConverted:o,onCancel:a}){const[i,l]=c.useState(n),[d,u]=c.useState(s??""),[p,f]=c.useState(!1),[h,m]=c.useState(null),[g,v]=c.useState(null),x=Tv.test(i),b=p||!x,y=c.useCallback(async j=>{if(j.preventDefault(),!b){f(!0),m(null),v(null);try{const S=await ce.convertToPlugin({anchorSkillDir:e,pluginName:i.trim(),description:d.trim()});o({pluginDir:S.pluginDir,manifestPath:S.manifestPath,validation:S.validation})}catch(S){if(S instanceof Jt){m(S.message);const k=S.details;k&&typeof k.stderr=="string"&&v(k.stderr)}else m(S instanceof Error?S.message:String(S));f(!1)}}},[b,e,i,d,o]);return t.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:j=>{j.target===j.currentTarget&&!p&&a()},children:t.jsxs("form",{onSubmit:y,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:[t.jsxs("h2",{id:"vskill-convert-dialog-title",style:{margin:0,fontSize:16,fontWeight:600},children:["Convert ",t.jsxs("span",{style:{fontFamily:"var(--font-mono)"},children:[r,"/"]})," to a plugin"]}),t.jsxs("p",{style:{marginTop:8,marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:["Writes ",t.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:".claude-plugin/plugin.json"})," into this folder and validates it via ",t.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:"claude plugin validate"}),". The skills already on disk will appear nested under the new plugin."]}),t.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginBottom:4},children:"Plugin name"}),t.jsx("input",{type:"text",value:i,onChange:j=>l(j.target.value),disabled:p,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}}),!x&&t.jsx("div",{style:{fontSize:11,color:"var(--color-error, #c00)",marginTop:4},children:"Must be kebab-case (lowercase letters, digits, hyphens; 2–64 chars)."}),t.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginTop:12,marginBottom:4},children:"Description"}),t.jsx("input",{type:"text",value:d,onChange:j=>u(j.target.value),disabled:p,style:{width:"100%",padding:"6px 8px",fontSize:13,boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),h&&t.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:[t.jsx("div",{style:{fontWeight:500},children:h}),g&&t.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:g})]}),t.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"flex-end",gap:8},children:[t.jsx("button",{type:"button",onClick:a,disabled:p,style:{padding:"6px 12px",fontSize:13,background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,cursor:p?"not-allowed":"pointer"},children:"Cancel"}),t.jsx("button",{type:"submit",disabled:b,style:{padding:"6px 12px",fontSize:13,background:"var(--color-accent, #2b6cb0)",color:"white",border:"none",borderRadius:4,cursor:b?"not-allowed":"pointer",opacity:b?.5:1},children:p?"Converting…":"Convert"})]})]})})}function Yi({name:e,count:r,className:n,variant:s,collapsed:o,onToggle:a,action:i}){const l=s==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",d=s==="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))",u=typeof a=="function",p={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:d,borderLeft:`3px solid ${l}`,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:u?"pointer":"default",border:"none",textAlign:"left"},f=o?"▸":"▾",h=t.jsxs(t.Fragment,{children:[u&&t.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:l,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:f}),t.jsx("span",{className:"vskill-group-header-name",children:e}),t.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:["(",r,")"]}),i&&t.jsx("span",{style:{marginLeft:"auto"},children:t.jsx(Lv,{label:i.label,title:i.title,icon:i.icon,onClick:i.onClick,accent:l})})]});return u?t.jsx("button",{type:"button","data-vskill-group-header":e,className:["vskill-group-header select-none",n??""].join(" ").trim(),style:p,onClick:()=>a(!o),"aria-expanded":!o,children:h}):t.jsx("div",{"data-vskill-group-header":e,role:"heading","aria-level":3,className:["vskill-group-header select-none",n??""].join(" ").trim(),style:p,children:h})}function Lv({label:e,title:r,icon:n,onClick:s,accent:o}){return t.jsxs("button",{type:"button","aria-label":e,title:r??e,onClick:a=>{a.stopPropagation(),s()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${o}`,background:"transparent",color:o,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:a=>{a.currentTarget.style.background=`color-mix(in oklch, ${o} 15%, transparent)`},onMouseLeave:a=>{a.currentTarget.style.background="transparent"},children:[n,e]})}function Av(){return t.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[t.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),t.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function Pv(e){const r=e.key.split("+").map(l=>l.trim()).filter(Boolean);let n=!!e.meta,s=!!e.ctrl,o=!!e.shift,a=!!e.alt,i=e.key;if(r.length>1){for(const l of r.slice(0,-1)){const d=l.toLowerCase();d==="cmd"||d==="meta"||d==="⌘"?n=!0:d==="ctrl"||d==="control"?s=!0:d==="shift"?o=!0:(d==="alt"||d==="option")&&(a=!0)}i=r[r.length-1]}return{key:i.length===1?i.toLowerCase():i,meta:n,ctrl:s,shift:o,alt:a,allowInInputs:!!e.allowInInputs,handler:e.handler}}function $v(e){if(!e||!(e instanceof HTMLElement))return!1;const r=e.tagName;if(r==="INPUT"||r==="TEXTAREA"||e.isContentEditable)return!0;const n=e.getAttribute("contenteditable");return n!=null&&n!=="false"||e.getAttribute("role")==="textbox"}function Mv(e,r){const n=!!e.metaKey,s=!!e.ctrlKey,o=!!e.shiftKey,a=!!e.altKey;return n!==r.meta||s!==r.ctrl||o!==r.shift||a!==r.alt?!1:(e.key.length===1?e.key.toLowerCase():e.key)===r.key}function Qo(e,r={}){const{enabled:n=!0,target:s}=r,o=c.useRef([]),a=Array.isArray(e)?e:[e];o.current=a.map(Pv),c.useEffect(()=>{if(!n)return;const i=s??(typeof window<"u"?window:void 0);if(!i)return;function l(d){const u=d,p=$v(u.target);for(const f of o.current){if(!Mv(u,f))continue;const h=f.meta||f.ctrl||f.alt;if(!(p&&!f.allowInInputs&&!h)){f.handler(u);return}}}return i.addEventListener("keydown",l),()=>{i.removeEventListener("keydown",l)}},[n,s])}function Ud(){const{data:e,loading:r,error:n,revalidate:s}=It("project-github-status",()=>ce.getProjectGitHubStatus());return{status:e,loading:r,error:n,revalidate:s}}function Fv(e){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${e}`)==="true"}catch{return!1}}function Dv({projectRoot:e}){const{status:r,loading:n}=Ud();if(n||!r||r.status==="github"||Fv(e))return null;const s=r.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",o=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return t.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:s,onClick:o,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:t.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:[t.jsx("path",{d:"m2 2 20 20"}),t.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),t.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 zv=3e4;async function Bv(e){const r={name:null,branch:null,is_private:null,sync_state:{kind:"no_remote"}};if(typeof window>"u")return r;try{const n=await fetch(`/api/git/repo-info?folder=${encodeURIComponent(e)}`);return n.ok?await n.json():r}catch{return r}}const Hd=c.forwardRef(function({folder:r,fetchRepoInfo:n=Bv,pollIntervalMs:s=zv,tier:o,onConnectPrivateClick:a},i){const l=o==="pro"||o==="enterprise"?o:"free",[d,u]=c.useState(null),[p,f]=c.useState(!1),[h,m]=c.useState(null),g=c.useRef(n);g.current=n;const v=async()=>{if(!r){u(null);return}f(!0),m(null);try{const x=await g.current(r);u(x)}catch(x){m(x instanceof Error?x.message:String(x))}finally{f(!1)}};return c.useImperativeHandle(i,()=>({refresh:v}),[r]),c.useEffect(()=>{if(!r){u(null);return}let x=!1,b=null;const y=async()=>{if(!x&&!(typeof document<"u"&&document.visibilityState!=="visible"))try{const S=await g.current(r);x||u(S)}catch(S){x||m(S instanceof Error?S.message:String(S))}};y(),b=setInterval(y,s);const j=()=>{typeof document<"u"&&document.visibilityState==="visible"&&y()};return typeof document<"u"&&document.addEventListener("visibilitychange",j),()=>{x=!0,b!==null&&clearInterval(b),typeof document<"u"&&document.removeEventListener("visibilitychange",j)}},[r,s]),r?h?t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"error",style:Qr,children:t.jsxs("span",{style:{color:"var(--color-error, #c0392b)",fontSize:12},children:["Couldn't load repo info: ",h]})}):d?!d.name&&d.sync_state.kind==="no_remote"?t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"not-git",style:Qr,children:t.jsx("span",{style:{color:"var(--color-muted, #999)",fontSize:12},children:"No git remote"})}):t.jsxs("div",{"data-testid":"connected-repo-widget","data-state":"connected","data-tier":l,style:Qr,children:[t.jsx("span",{style:Hv,"data-testid":"repo-name",children:d.name??"Local-only"}),d.branch?t.jsxs("span",{style:Vv,"data-testid":"repo-branch",children:[t.jsx(_v,{})," ",d.branch]}):null,t.jsx(Uv,{state:d.sync_state}),t.jsx(Vd,{isPrivate:d.is_private,onConnectPrivateClick:a})]}):t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"loading","aria-busy":p||void 0,style:Qr,children:t.jsx("span",{style:{color:"var(--color-muted, #999)",fontSize:12},children:"Loading…"})}):t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"empty",style:Qr,children:t.jsx("span",{style:{color:"var(--color-muted, #999)",fontSize:12},children:"No project folder selected"})})});function Vd({isPrivate:e,onConnectPrivateClick:r}){return e!==!0?t.jsx(Wv,{isPrivate:e}):t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{style:Gv,role:"status",title:"Private GitHub repository","aria-label":"Private repository","data-testid":"visibility-pill","data-visibility":"private","data-private":"true",children:[t.jsx(Ma,{size:11}),t.jsx("span",{children:"Private"})]}),r?t.jsx("button",{type:"button",onClick:r,"data-testid":"repo-connect-private",title:"Install the verified-skill GitHub App to enable read/write access on this private repo.","aria-label":"Connect private repos via GitHub App",style:Kv,children:"Connect"}):null]})}function _v(){return t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,style:{verticalAlign:"middle",marginRight:4},children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function Ov(){return t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Wv({isPrivate:e}){return e===null?t.jsx("span",{style:{...xr,color:"var(--color-muted, #999)"},"data-testid":"visibility-pill","data-visibility":"unknown",children:"unknown"}):e?t.jsx(Vd,{isPrivate:!0}):t.jsxs("span",{style:{...xr,color:"var(--color-public, #2aa198)"},"data-testid":"visibility-pill","data-visibility":"public","aria-label":"Public repository",children:[t.jsx(Ov,{})," public"]})}function Uv({state:e}){return e.kind==="clean"?t.jsx("span",{style:{...xr,color:"var(--color-clean, #859900)"},"data-testid":"sync-state-pill","data-sync":"clean",children:"in sync"}):e.kind==="no_remote"?t.jsx("span",{style:{...xr,color:"var(--color-muted, #999)"},"data-testid":"sync-state-pill","data-sync":"no_remote",children:"no remote"}):e.kind==="dirty"?t.jsxs("span",{style:{...xr,color:"var(--color-warn, #cb4b16)"},"data-testid":"sync-state-pill","data-sync":"dirty",title:`${e.count} uncommitted ${e.count===1?"change":"changes"}`,children:[e.count," dirty"]}):e.kind==="ahead"?t.jsxs("span",{style:{...xr,color:"var(--color-ahead, #268bd2)"},"data-testid":"sync-state-pill","data-sync":"ahead",children:["+",e.count," ahead"]}):t.jsxs("span",{style:{...xr,color:"var(--color-behind, #6c71c4)"},"data-testid":"sync-state-pill","data-sync":"behind",children:["-",e.count," behind"]})}const Qr={display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap",fontSize:12,fontFamily:"var(--font-system, -apple-system, system-ui)"},Hv={fontWeight:500,color:"var(--color-text, #333)"},Vv={display:"inline-flex",alignItems:"center",gap:2,padding:"1px 6px",borderRadius:9999,background:"var(--color-pill-bg, rgba(0,0,0,0.05))",color:"var(--color-text-soft, #555)",fontSize:11},xr={display:"inline-flex",alignItems:"center",gap:3,padding:"1px 6px",borderRadius:9999,background:"var(--color-pill-bg, rgba(0,0,0,0.05))",fontSize:11,fontWeight:500},Gv={display:"inline-flex",alignItems:"center",gap:4,height:18,padding:"0 6px",borderRadius:4,color:"var(--private-fg, #92400e)",backgroundColor:"var(--private-bg, rgba(245,158,11,0.12))",border:"1px solid var(--private-border-soft, rgba(245,158,11,0.35))",fontFamily:"var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)",fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",lineHeight:1,flexShrink:0},Kv={marginLeft:4,padding:"0px 6px",borderRadius:9999,border:"1px solid currentColor",background:"transparent",color:"inherit",fontSize:10,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},qv=200;function Yv(e){return e.scope==="own"||e.scope==="installed"||e.scope==="global"?e.scope:e.origin==="installed"?"installed":"own"}function Jv(e,r){const n={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const i of e){const l=i.scopeV2??(i.scope==="installed"?"available-project":i.scope==="global"?"available-personal":"authoring-project");l==="available-project"?n.availableProject.push(i):l==="available-personal"?n.availablePersonal.push(i):l==="available-plugin"?n.availablePlugin.push(i):l==="authoring-plugin"?n.authoringPlugin.push(i):n.authoringProject.push(i)}function s(i){const l=i.filter(p=>$a(p,r)),d={};for(const p of l){const f=p.pluginName??p.plugin;(d[f]||(d[f]=[])).push(p)}const u=Object.entries(d).sort((p,f)=>p[0].localeCompare(f[0]));return{total:i.length,filtered:l.length,byPlugin:u}}const o=s(n.authoringProject),a=o.byPlugin.filter(([i,l])=>l.length>=2&&i.trim().length>=2).map(([i,l])=>({groupKey:i,skills:l,anchorSkillDir:l[0].dir}));return{availableProject:s(n.availableProject),availablePersonal:s(n.availablePersonal),availablePlugin:s(n.availablePlugin),authoringProject:o,authoringPlugin:s(n.authoringPlugin),authoringCandidatePlugins:a}}function Qv(e,r){const n=[],s=[],o=[];for(const i of e){const l=Yv(i);l==="global"?o.push(i):l==="installed"?s.push(i):n.push(i)}function a(i){var p;const l=i.filter(f=>$a(f,r)),d={};for(const f of l)(d[p=f.plugin]||(d[p]=[])).push(f);const u=Object.entries(d).sort((f,h)=>f[0].localeCompare(h[0]));return{total:i.length,filtered:l.length,byPlugin:u}}return{own:a(n),installed:a(s),global:a(o)}}function Xv(e,r){const n=[],s=[];for(const a of e)(a.origin==="installed"?s:n).push(a);function o(a){var u;const i=a.filter(p=>$a(p,r)),l={};for(const p of i)(l[u=p.plugin]||(l[u]=[])).push(p);const d=Object.entries(l).sort((p,f)=>p[0].localeCompare(f[0]));return{total:a.length,filtered:i.length,byPlugin:d}}return{own:o(n),installed:o(s)}}function Zv({skills:e,selectedKey:r,onSelect:n,isLoading:s,error:o,onRetry:a,onContextMenu:i,outdatedByOrigin:l,activeAgentId:d,outdatedByScope:u,topSlot:p,revealSkillId:f,onRevealComplete:h,dirtySkillIds:m,onSkillsChanged:g}){const[v,x]=c.useState(null),b=!!d||e.some(M=>M.scope!==void 0&&M.scope!==null),y=d??"claude-cli",[j,S]=c.useState(""),k=c.useDeferredValue(j),R=c.useMemo(()=>Qv(e,k),[e,k]),w=c.useMemo(()=>Jv(e,k),[e,k]),E=y==="claude-code",{plugins:N}=wx(),T=E?{plugins:N??[]}:void 0,I=c.useMemo(()=>{const M=new Map;for(const U of(T==null?void 0:T.plugins)??[]){const K=M.get(U.name);M.set(U.name,!!K||!!U.enabled)}return M},[T==null?void 0:T.plugins]),[A,$]=c.useState(()=>Xo(`vskill-sidebar-${y}-group-available-collapsed`)),[W,C]=c.useState(()=>Xo(`vskill-sidebar-${y}-group-authoring-collapsed`)),P=c.useCallback(M=>{$(M);try{window.localStorage.setItem(`vskill-sidebar-${y}-group-available-collapsed`,String(M))}catch{}},[y]),L=c.useCallback(M=>{C(M);try{window.localStorage.setItem(`vskill-sidebar-${y}-group-authoring-collapsed`,String(M))}catch{}},[y]),{own:F,installed:H}=c.useMemo(()=>Xv(e,k),[e,k]),V=R.own.filtered+R.installed.filtered+R.global.filtered>=qv,{lookup:O}=Od(),se=c.useMemo(()=>{const M=U=>{const K=[];for(const[,X]of U){const ie=[...X].sort((G,te)=>G.skill.localeCompare(te.skill));K.push(...ie)}return K};return b?[...M(R.own.byPlugin),...M(R.installed.byPlugin),...M(R.global.byPlugin)]:[...M(F.byPlugin),...M(H.byPlugin)]},[b,R.own.byPlugin,R.installed.byPlugin,R.global.byPlugin,F.byPlugin,H.byPlugin]),ge=c.useMemo(()=>r?se.findIndex(M=>M.plugin===r.plugin&&M.skill===r.skill):-1,[se,r]),ye=c.useCallback(M=>{if(se.length===0)return;const U=ge<0?M>0?0:se.length-1:Math.min(Math.max(ge+M,0),se.length-1);n(se[U])},[se,ge,n]),z=c.useMemo(()=>{if(!f)return null;const[M,U]=f.split("/");if(!M||!U)return null;const K=e.find(G=>G.plugin===M&&G.skill===U);if(!K)return{plugin:M,skill:U,bucket:null,pluginName:null};const X=K.source==="plugin"?"plugin":"project",ie=X==="plugin"?K.pluginName??M:null;return{plugin:M,skill:U,bucket:X,pluginName:ie}},[f,e]),ne=c.useRef(null);return c.useEffect(()=>{if(!f){ne.current=null;return}if(ne.current===f)return;const M=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/["\\]/g,"\\$&"),U=document.querySelector(`[data-skill-id="${M}"]`);U&&(ne.current=f,U.scrollIntoView({behavior:"smooth",block:"nearest"}),h==null||h())},[f,h,e]),Qo([{key:"j",handler:()=>ye(1)},{key:"k",handler:()=>ye(-1)},{key:"Enter",handler:()=>{ge>=0&&n(se[ge])}}],{enabled:!s&&!o}),t.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[p,t.jsx(rv,{value:j,onChange:S}),s&&t.jsx(ay,{}),!s&&o&&t.jsx(iy,{error:o,onRetry:a}),!s&&!o&&b&&t.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[t.jsx(Yi,{name:_.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:A,onToggle:P,count:w.availableProject.total+w.availablePersonal.total+w.availablePlugin.total}),!A&&t.jsxs(t.Fragment,{children:[t.jsx(Xr,{label:_.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${y}-available-project-collapsed`,count:w.availableProject.total,filteredCount:j?w.availableProject.filtered:null,updateCount:(u==null?void 0:u.installed)??(l==null?void 0:l.installed),headerRightSlot:E?t.jsx(cy,{projectRoot:y}):null,children:w.availableProject.filtered===0?t.jsx(Qi,{queryActive:!!j,agentId:y}):t.jsx(Zr,{items:w.availableProject.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:V,dirtySkillIds:m,repoVisibilityLookup:O,agentId:y,sectionName:"available-project"})}),t.jsx(Xr,{label:_.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${y}-available-personal-collapsed`,count:w.availablePersonal.total,filteredCount:j?w.availablePersonal.filtered:null,updateCount:u==null?void 0:u.global,children:w.availablePersonal.filtered===0?t.jsx(ty,{queryActive:!!j,agentId:y}):t.jsx(Zr,{items:w.availablePersonal.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:V,dirtySkillIds:m,repoVisibilityLookup:O,agentId:y,sectionName:"available-personal"})}),E&&t.jsxs(Xr,{label:_.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${y}-available-plugin-collapsed`,count:w.availablePlugin.total,filteredCount:j?w.availablePlugin.filtered:null,children:[t.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:[t.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),w.availablePlugin.filtered===0?t.jsx(ry,{queryActive:!!j,hasInstalled:w.availablePlugin.total>0}):w.availablePlugin.byPlugin.map(([M,U])=>t.jsx(Js,{pluginName:M,skills:U,persistKey:`vskill-plugin-available-${M}-collapsed`,headerActionSlot:E?t.jsx(Rv,{pluginName:M,enabled:I.get(M)??!0}):void 0,renderSkill:K=>t.jsx(un,{skill:K,isSelected:(r==null?void 0:r.plugin)===K.plugin&&(r==null?void 0:r.skill)===K.skill,onSelect:()=>n(K),onContextMenu:i,dirty:m==null?void 0:m.has(`${K.plugin}/${K.skill}`)})},`available-${M}`))]})]}),t.jsx(oy,{}),t.jsx(Yi,{name:_.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:z?!1:W,onToggle:L,count:w.authoringProject.total+w.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:t.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:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.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"}}))}}}),(!W||z)&&t.jsxs(t.Fragment,{children:[t.jsx(Xr,{label:_.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${y}-authoring-project-collapsed`,count:w.authoringProject.total,filteredCount:j?w.authoringProject.filtered:null,updateCount:(u==null?void 0:u.own)??(l==null?void 0:l.source),forceOpen:(z==null?void 0:z.bucket)==="project",children:w.authoringProject.filtered===0?t.jsx(Ji,{queryActive:!!j}):t.jsxs(t.Fragment,{children:[w.authoringCandidatePlugins.map(M=>t.jsx(Js,{pluginName:M.groupKey,skills:M.skills,persistKey:`vskill-candidate-plugin-${M.groupKey}-collapsed`,headerActionSlot:t.jsx("button",{type:"button",onClick:U=>{U.stopPropagation(),x({candidateLabel:M.groupKey,initialName:M.groupKey,anchorSkillDir:M.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:U=>t.jsx(un,{skill:U,isSelected:(r==null?void 0:r.plugin)===U.plugin&&(r==null?void 0:r.skill)===U.skill,onSelect:()=>n(U),onContextMenu:i,dirty:m==null?void 0:m.has(`${U.plugin}/${U.skill}`)})},`candidate-${M.groupKey}`)),t.jsx(Zr,{items:w.authoringProject.byPlugin.filter(([M])=>!w.authoringCandidatePlugins.some(U=>U.groupKey===M)),selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:V,dirtySkillIds:m,repoVisibilityLookup:O,agentId:y,sectionName:"authoring-project"})]})}),E&&t.jsx(Xr,{label:_.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${y}-authoring-plugin-collapsed`,count:w.authoringPlugin.total,filteredCount:j?w.authoringPlugin.filtered:null,forceOpen:(z==null?void 0:z.bucket)==="plugin",children:w.authoringPlugin.filtered===0?t.jsx(ny,{queryActive:!!j,hasSources:w.authoringPlugin.total>0,candidates:w.authoringCandidatePlugins,onPromote:M=>x({candidateLabel:M.groupKey,initialName:M.groupKey,anchorSkillDir:M.anchorSkillDir})}):w.authoringPlugin.byPlugin.map(([M,U])=>t.jsx(Js,{pluginName:M,skills:U,persistKey:`vskill-plugin-authoring-${M}-collapsed`,forceOpen:(z==null?void 0:z.bucket)==="plugin"&&z.pluginName===M,renderSkill:K=>t.jsx(un,{skill:K,isSelected:(r==null?void 0:r.plugin)===K.plugin&&(r==null?void 0:r.skill)===K.skill,onSelect:()=>n(K),onContextMenu:i,dirty:m==null?void 0:m.has(`${K.plugin}/${K.skill}`)})},`authoring-${M}`))})]})]}),!s&&!o&&!b&&t.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[t.jsx(Ki,{origin:"source",count:F.total,filteredCount:j?F.filtered:null,updateCount:l==null?void 0:l.source,children:F.filtered===0?t.jsx(Ji,{queryActive:!!j}):t.jsx(Zr,{items:F.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:V,dirtySkillIds:m,repoVisibilityLookup:O,agentId:y,sectionName:"own"})}),t.jsx(sy,{}),t.jsx(Ki,{origin:"installed",count:H.total,filteredCount:j?H.filtered:null,updateCount:l==null?void 0:l.installed,children:H.filtered===0?t.jsx(Qi,{queryActive:!!j}):t.jsx(Zr,{items:H.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:V,dirtySkillIds:m,repoVisibilityLookup:O,agentId:y,sectionName:"installed"})})]}),v&&t.jsx(Iv,{anchorSkillDir:v.anchorSkillDir,candidateLabel:v.candidateLabel,initialName:v.initialName,onCancel:()=>x(null),onConverted:M=>{x(null),g==null||g(),M.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 Xo(e){if(typeof window>"u")return!1;try{return window.localStorage.getItem(e)==="true"}catch{return!1}}function Xr({label:e,storageKey:r,count:n,filteredCount:s,updateCount:o,children:a,forceOpen:i=!1,headerRightSlot:l}){const[d,u]=c.useState(()=>Xo(r)),p=i?!1:d,f=c.useCallback(()=>{u(m=>{const g=!m;if(typeof window<"u")try{window.localStorage.setItem(r,String(g))}catch{}return g})},[r]),h=s!=null&&s!==n?`${s} of ${n}`:String(n);return t.jsxs("section",{"data-vskill-named-scope":e,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[t.jsxs("button",{type:"button",onClick:f,"aria-expanded":!p,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:[t.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),t.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:e}),t.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h,")"]}),o!=null&&o>0&&t.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[o," update",o!==1?"s":""]})]}),l]}),!p&&t.jsx("div",{style:{paddingLeft:18},children:a})]})}function ey(e){const r=[];for(const[n,s]of e){const o=[...s].sort((a,i)=>a.skill.localeCompare(i.skill));r.push({kind:"header",plugin:n,count:o.length});for(const a of o)r.push({kind:"row",skill:a})}return r}function Zr({items:e,selectedKey:r,onSelect:n,onContextMenu:s,useVirtual:o,dirtySkillIds:a,repoVisibilityLookup:i,agentId:l,sectionName:d}){if(o){const p=ey(e);return t.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:t.jsx(Mg,{overscan:4,totalCount:p.length,itemContent:f=>{const h=p[f];if(!h)return null;if(h.kind==="header")return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[t.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),t.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const m=h.skill,g=!!r&&r.plugin===m.plugin&&r.skill===m.skill,v=i?In(m.repoUrl):null,x=v?i.get(v)??null:null,b=x?x.isPrivate?"private":"public":"unknown";return t.jsx(un,{skill:m,isSelected:g,onSelect:()=>n(m),onContextMenu:s,dirty:a==null?void 0:a.has(`${m.plugin}/${m.skill}`),repoVisibility:b,repoFullName:(x==null?void 0:x.repoFullName)??null})}})})}const u=e.map(([p,f])=>t.jsx(Wd,{plugin:p,skills:f,selectedKey:r,onSelect:n,onContextMenu:s,dirtySkillIds:a,repoVisibilityLookup:i},p));return t.jsx("div",{"data-virtualized":"false",children:t.jsx(Cv,{items:e,agentId:l??"claude-cli",sectionName:d??"section",repoVisibilityLookup:i,selectedKey:r,onSelect:n,onContextMenu:s,dirtySkillIds:a,children:u})})}function Ji({queryActive:e}){return e?t.jsx(Vt,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Vt,{headline:"No skills yet.",body:t.jsxs(t.Fragment,{children:["Create one with ",t.jsx(Br,{children:"vskill new"})," or the"," ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Qi({queryActive:e,agentId:r}){return e?t.jsx(Vt,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Vt,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:t.jsxs(t.Fragment,{children:["Run ",t.jsx(Br,{children:"vskill install <skill>"})," to add one."]})})}function ty({queryActive:e,agentId:r}){return e?t.jsx(Vt,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Vt,{headline:`No global skills for ${r}.`,body:t.jsxs(t.Fragment,{children:["Run ",t.jsx(Br,{children:"vskill install --global <skill>"})," to add one."]})})}function ry({queryActive:e,hasInstalled:r}){return e&&r?t.jsx(Vt,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Vt,{headline:"No plugin skills installed yet.",body:t.jsxs(t.Fragment,{children:["Click ",t.jsx(Br,{children:"Browse marketplaces…"})," above to add one."]})})}function ny({queryActive:e,hasSources:r,candidates:n,onPromote:s}){return e&&r?t.jsx(Vt,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsxs(t.Fragment,{children:[t.jsx(Vt,{headline:"No plugin sources in this project.",body:t.jsxs(t.Fragment,{children:["Add ",t.jsx(Br,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",t.jsx(Br,{children:"vskill plugin new"})," from the terminal."]})}),n&&n.length>0&&t.jsxs("div",{style:{padding:"0 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:["Candidate folders (",n.length,")"]}),n.map(o=>t.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(o),title:`Promote ${o.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:[t.jsxs("span",{children:[o.groupKey,"/ ",t.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.skills.length," skills)"]})]}),t.jsx("span",{style:{fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)"},children:"Promote →"})]},`promote-${o.groupKey}`))]})]})}function Vt({headline:e,body:r}){return t.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[t.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:e}),t.jsx("div",{children:r})]})}function Br({children:e}){return t.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:e})}function sy(){return t.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function oy(){return t.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 ay(){return t.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(e=>t.jsx(Av,{},e))})}function iy({error:e,onRetry:r}){return t.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:[t.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),t.jsxs("details",{children:[t.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:ly(e)}),t.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:e})]}),r&&t.jsx("button",{type:"button",onClick:r,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 ly(e){const r=e.split(`
|
|
19
|
+
`)[0]??e;return r.length>80?r.slice(0,77)+"…":r}function cy({projectRoot:e}){const{signedIn:r,tier:n}=Pc();return r?t.jsx("span",{"data-testid":"sidebar-connected-repo-widget",onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-account-tab",{detail:{tab:"repos",initialPath:e}}))},style:{display:"inline-flex",cursor:"pointer"},children:t.jsx(Hd,{folder:e,tier:n})}):t.jsx(Dv,{projectRoot:e})}const Gd=240,Kd=480,qd="vskill-sidebar-width",pn=320;function Da(e){return Number.isFinite(e)?Math.round(Math.max(Gd,Math.min(Kd,e))):pn}function dy(){try{const e=localStorage.getItem(qd);if(!e)return pn;const r=Number(e);return Number.isFinite(r)?Da(r):pn}catch{return pn}}function uy(e){try{localStorage.setItem(qd,String(Da(e)))}catch{}}function py({initialWidth:e,onChange:r}){const n=c.useRef({startX:0,startWidth:e,pointerId:null}),s=c.useRef(e);return c.useEffect(()=>{s.current=e},[e]),c.useEffect(()=>{function o(i){if(n.current.pointerId==null||i.pointerId!==n.current.pointerId)return;const l=i.clientX-n.current.startX,d=Da(n.current.startWidth+l);s.current=d,r(d)}function a(i){n.current.pointerId==null||i.pointerId!==n.current.pointerId||(n.current.pointerId=null,uy(s.current))}return window.addEventListener("pointermove",o),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a)}},[r]),t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":Gd,"aria-valuemax":Kd,"aria-valuenow":e,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:o=>{const a=o.currentTarget;n.current.startX=o.clientX,n.current.startWidth=s.current,n.current.pointerId=o.pointerId;try{a.setPointerCapture(o.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}const fy=/^[ MADRCU?!]{1,2} +/;function hy(e){return e.replace(fy,"")}function my(e,r){const n=e.endsWith("/")?e:e+"/";return r===e?"":r.startsWith(n)?r.slice(n.length):null}function xy(e,r,n){const s=new Set;if(r.length===0||e.length===0)return s;const o=r.map(a=>hy(a).trim()).filter(a=>a.length>0);for(const a of e){const i=a.dir;if(!i)continue;const l=my(n,i);if(l===null)continue;const d=`${a.plugin}/${a.skill}`;if(l===""){o.length>0&&s.add(d);continue}const u=l+"/";for(const p of o)if(p===l||p.startsWith(u)){s.add(d);break}}return s}const gy=5e3;function vy(e,r,n=gy){const[s,o]=c.useState([]),a=c.useRef(e);return a.current=e,c.useEffect(()=>{if(!r){o([]);return}let i=!1,l=null;const d=async()=>{try{const p=await ce.gitStatus();i||o(p.paths??[])}catch{i||o([])}i||(l=setTimeout(d,n))};d();const u=()=>{d()};return typeof window<"u"&&window.addEventListener("studio:content-saved",u),()=>{i=!0,l&&clearTimeout(l),typeof window<"u"&&window.removeEventListener("studio:content-saved",u)}},[r,n]),r?xy(a.current,s,r):new Set}function yy({connected:e,hint:r,onRetry:n}){return e?null:t.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:[t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),t.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),r&&t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:r}),t.jsx("div",{style:{flex:1}}),n&&t.jsx("button",{type:"button",onClick:n,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 Yd(e,r){if(e!==401||typeof window>"u"||!r||typeof r!="object")return;const n=r;n.error==="invalid_api_key"&&(n.provider!=="anthropic"&&n.provider!=="openai"&&n.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:n.provider}})))}function Jd(e){if(e!==void 0)try{return JSON.stringify(e)}catch(r){console.error("Failed to serialize request body:",r);try{const n=new WeakSet;return JSON.stringify(e,(s,o)=>{if(typeof o=="object"&&o!==null){if(n.has(o))return"[Circular]";n.add(o)}return o})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Zs(){const[e,r]=c.useState([]),[n,s]=c.useState(!1),[o,a]=c.useState(!1),[i,l]=c.useState(null),d=c.useRef(null),u=c.useCallback(async(f,h)=>{r([]),s(!0),a(!1),l(null);const m=new AbortController;d.current=m;try{const g=Jd(h),v=await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:g,signal:m.signal});if(!v.ok||!v.body){let S=`HTTP ${v.status}`,k;try{k=await v.json(),k&&typeof k=="object"&&"error"in k&&typeof k.error=="string"&&(S=k.error)}catch{}throw Yd(v.status,k),new Error(S)}const x=v.body.getReader(),b=new TextDecoder;let y="",j="";for(;;){const{done:S,value:k}=await x.read();if(S)break;y+=b.decode(k,{stream:!0});const R=y.split(`
|
|
20
|
+
`);y=R.pop()||"";for(const w of R)if(w.startsWith("event: "))j=w.slice(7).trim();else if(w.startsWith("data: ")){try{const E=JSON.parse(w.slice(6)),N={event:j,data:E};j==="done"?(a(!0),r(T=>[...T,N])):r(T=>[...T,N])}catch{}j=""}}}catch(g){g.name!=="AbortError"&&l(g.message)}finally{s(!1),d.current=null}},[]),p=c.useCallback(()=>{var f;(f=d.current)==null||f.abort()},[]);return{events:e,running:n,done:o,error:i,start:u,stop:p}}function by(e){const r=c.useRef(e);r.current=e;const[n,s]=c.useState(new Set),o=c.useRef(new Map),a=c.useCallback(async(u,p,f)=>{var m;(m=o.current.get(u))==null||m.abort();const h=new AbortController;o.current.set(u,h),s(g=>{const v=new Set(g);return v.add(u),v});try{const g=Jd(f),v=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:g,signal:h.signal});if(!v.ok||!v.body){let S=`HTTP ${v.status}`,k;try{k=await v.json(),k&&typeof k=="object"&&"error"in k&&typeof k.error=="string"&&(S=k.error)}catch{}throw Yd(v.status,k),new Error(S)}const x=v.body.getReader(),b=new TextDecoder;let y="",j="";for(;;){const{done:S,value:k}=await x.read();if(S)break;y+=b.decode(k,{stream:!0});const R=y.split(`
|
|
21
|
+
`);y=R.pop()||"";for(const w of R)if(w.startsWith("event: "))j=w.slice(7).trim();else if(w.startsWith("data: ")){try{const E=JSON.parse(w.slice(6)),N={event:j,data:E};r.current.onEvent(u,N)}catch{}j=""}}r.current.onDone(u)}catch(g){g.name!=="AbortError"&&r.current.onError(u,g.message)}finally{s(g=>{const v=new Set(g);return v.delete(u),v}),o.current.delete(u)}},[]),i=c.useCallback(u=>{var p;(p=o.current.get(u))==null||p.abort()},[]),l=c.useCallback(()=>{for(const u of o.current.values())u.abort()},[]),d=n.size>0;return{runningSet:n,startCase:a,stopCase:i,stopAll:l,isAnyCaseRunning:d}}const ky={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 jy(e,r){var n,s;switch(r.type){case"SET_LOADING":return{...e,loading:r.loading};case"SET_ERROR":return{...e,error:r.error};case"INIT_DATA":{const o=new Map;if(r.benchmark)for(const i of r.benchmark.cases)o.set(i.eval_id,{status:i.status,passRate:i.pass_rate,errorMessage:i.error_message||void 0,durationMs:i.durationMs,tokens:i.tokens,output:i.output,assertions:i.assertions.map(l=>({assertion_id:l.id,text:l.text,pass:l.pass,reasoning:l.reasoning}))});const a=((s=(n=r.evals)==null?void 0:n.evals[0])==null?void 0:s.id)??null;return{...e,skillContent:r.skillContent,savedContent:r.skillContent,isDirty:!1,evals:r.evals,evalsError:r.evalsError??null,latestBenchmark:r.benchmark,inlineResults:o,selectedCaseId:a,loading:!1,error:null}}case"SET_PANEL":return{...e,activePanel:r.panel};case"SET_CONTENT":return{...e,skillContent:r.content,isDirty:r.content!==e.savedContent};case"CONTENT_SAVED":return{...e,savedContent:e.skillContent,isDirty:!1};case"SET_EVALS":return{...e,evals:r.evals};case"SELECT_CASE":return{...e,selectedCaseId:r.caseId};case"CASE_RUN_START":{const o=new Map(e.caseRunStates);return o.set(r.caseId,{status:"running",startedAt:Date.now(),mode:r.mode}),{...e,caseRunStates:o,runMode:r.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const o=new Map(e.caseRunStates),a=o.get(r.caseId);o.set(r.caseId,{status:"complete",mode:a==null?void 0:a.mode});const i=new Map(e.inlineResults);return i.set(r.caseId,r.result),{...e,caseRunStates:o,inlineResults:i}}case"CASE_RUN_ERROR":{const o=new Map(e.caseRunStates),a=o.get(r.caseId);o.set(r.caseId,{status:"error",mode:a==null?void 0:a.mode});const i=new Map(e.inlineResults);return i.set(r.caseId,{status:"error",errorMessage:r.error,assertions:[]}),{...e,caseRunStates:o,inlineResults:i}}case"CASE_RUN_CANCEL":{const o=new Map(e.caseRunStates),a=o.get(r.caseId);return o.set(r.caseId,{status:"cancelled",mode:a==null?void 0:a.mode}),{...e,caseRunStates:o}}case"BULK_RUN_START":{const o=new Map(e.caseRunStates);for(const a of r.caseIds)o.set(a,{status:"queued",mode:r.mode});return{...e,caseRunStates:o,bulkRunActive:!0,runMode:r.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...e,bulkRunActive:!1,latestBenchmark:r.benchmark??e.latestBenchmark,iterationCount:e.iterationCount+1};case"CANCEL_ALL":{const o=new Map(e.caseRunStates);for(const[a,i]of o)(i.status==="running"||i.status==="queued")&&o.set(a,{status:"cancelled"});return{...e,caseRunStates:o,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const o=new Map(e.inlineResults);return o.set(r.evalId,r.result),{...e,inlineResults:o}}case"OPEN_IMPROVE":return{...e,improveTarget:r.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...e,improveTarget:null};case"OPEN_AI_EDIT":return{...e,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...e,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...e,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...e,aiEditProgress:[...e.aiEditProgress,r.entry]};case"AI_EDIT_RESULT":{const o=r.evalChanges??[],a=new Map;for(let i=0;i<o.length;i++)a.set(i,!0);return{...e,aiEditLoading:!1,aiEditResult:{improved:r.improved,reasoning:r.reasoning,evalChanges:o},aiEditEvalChanges:o,aiEditEvalSelections:a}}case"AI_EDIT_ERROR":return{...e,aiEditLoading:!1,aiEditError:r.message,aiEditClassifiedError:r.classified??null};case"GENERATE_EVALS_START":return{...e,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...e,generateEvalsProgress:[...e.generateEvalsProgress,r.entry]};case"GENERATE_EVALS_DONE":return{...e,generateEvalsLoading:!1,evals:r.evals};case"GENERATE_EVALS_ERROR":return{...e,generateEvalsLoading:!1,generateEvalsError:r.classified};case"TOGGLE_EVAL_CHANGE":{const o=new Map(e.aiEditEvalSelections);return o.set(r.index,!o.get(r.index)),{...e,aiEditEvalSelections:o}}case"SELECT_ALL_EVAL_CHANGES":{const o=new Map(e.aiEditEvalSelections);for(const a of o.keys())o.set(a,!0);return{...e,aiEditEvalSelections:o}}case"DESELECT_ALL_EVAL_CHANGES":{const o=new Map(e.aiEditEvalSelections);for(const a of o.keys())o.set(a,!1);return{...e,aiEditEvalSelections:o}}case"SET_EVALS_RETRY":return{...e,aiEditEvalsRetry:r.evalsFile};case"SET_REGRESSIONS":return{...e,regressions:r.regressions};case"INCREMENT_ITERATION":return{...e,iterationCount:e.iterationCount+1};case"SET_ACTIVATION_PROMPTS":{const o=r.prompts===e.activationPromptsCanonical;return{...e,activationPrompts:r.prompts,activationPromptsSource:o?e.activationPromptsSource:e.activationPromptsSource===null||e.activationPromptsSource==="skill-md"||e.activationPromptsSource==="ai-generated"?"user-typed":e.activationPromptsSource}}case"SET_PROMPTS_SOURCE":return{...e,activationPromptsSource:r.source,activationPromptsCanonical:r.canonical??e.activationPromptsCanonical};case"ACTIVATION_START":return{...e,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...e,activationResults:[...e.activationResults,r.result]};case"ACTIVATION_DONE":return{...e,activationRunning:!1,activationSummary:r.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...e,activationClassifyingStatus:`Classifying prompt ${r.index}/${r.total}...`};case"ACTIVATION_ERROR":return{...e,activationRunning:!1,activationError:r.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...e,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...e,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...e,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...e,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...e,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...e,generatingPrompts:!1,generatingPromptsError:r.error};case"SAVE_TEST_CASES_START":return{...e,savingTestCases:!0,savingTestCasesError:null,savingTestCasesSuccess:null};case"SAVE_TEST_CASES_SUCCESS":return{...e,savingTestCases:!1,savingTestCasesSuccess:`Saved ${r.count} test case${r.count===1?"":"s"} to SKILL.md`,activationPromptsSource:"skill-md",activationPromptsCanonical:e.activationPrompts};case"SAVE_TEST_CASES_ERROR":return{...e,savingTestCases:!1,savingTestCasesError:r.error};case"CLEAR_SAVE_TEST_CASES_FEEDBACK":return{...e,savingTestCasesSuccess:null,savingTestCasesError:null};case"ACTIVATION_HISTORY_LOADED":return{...e,activationHistory:r.runs,activationHistoryLoading:!1};default:return e}}function wy(e,r){if(!e)return{canEdit:!1,canRun:!1};const n=e.origin==="source",s=r.exists&&r.cases.length>0;return{canEdit:n,canRun:s}}function Sy(e){if(e==="unit"||e==="integration")return e}function Cy(e,r){const n=r.data;if(r.event==="output_ready"&&(e.output=n.output,n.durationMs!=null&&(e.durationMs=n.durationMs),n.tokens!=null&&(e.tokens=n.tokens)),r.event==="outputs_ready"&&(e.output=n.skillOutput,n.skillDurationMs!=null&&(e.durationMs=n.skillDurationMs),n.skillTokens!=null&&(e.tokens=n.skillTokens)),r.event==="assertion_result"){const s={assertion_id:n.assertion_id,text:n.text,pass:n.pass,reasoning:n.reasoning};e.assertions.find(o=>o.assertion_id===s.assertion_id)||e.assertions.push(s)}r.event==="case_complete"&&(e.status=n.status,e.passRate=n.pass_rate,e.errorMessage=n.error_message||void 0,e.classifiedError=n.classified_error||void 0)}const Qd=c.createContext(null);function vt(){const e=c.useContext(Qd);if(!e)throw new Error("useWorkspace must be used within WorkspaceProvider");return e}function Ey({plugin:e,skill:r,origin:n,children:s}){var ke;const o=n==="installed",{config:a}=kr(),[i,l]=c.useReducer(jy,{...ky,plugin:e,skill:r}),d=wy({origin:n},{exists:i.evals!=null,cases:((ke=i.evals)==null?void 0:ke.evals)??[]}),u=d.canEdit,p=d.canRun,f=c.useRef(new Set),h=c.useRef(new Set),m=c.useRef(new Map),g=c.useCallback((B,Y)=>{let J=m.current.get(B);J||(J={assertions:[]},m.current.set(B,J)),Cy(J,Y),l({type:"UPDATE_INLINE_RESULT",evalId:B,result:{...J,assertions:[...J.assertions]}})},[]),v=c.useCallback(B=>{if(h.current.has(B))return;h.current.add(B);const Y=m.current.get(B)??{assertions:[]};l({type:"CASE_RUN_COMPLETE",caseId:B,result:{...Y,assertions:[...Y.assertions]}}),f.current.has(B)&&(f.current.delete(B),f.current.size===0&&ce.getLatestBenchmark(e,r).then(J=>l({type:"BULK_RUN_COMPLETE",benchmark:J})).catch(()=>l({type:"BULK_RUN_COMPLETE",benchmark:null})))},[e,r]),x=c.useCallback((B,Y)=>{h.current.has(B)||(h.current.add(B),l({type:"CASE_RUN_ERROR",caseId:B,error:Y}),f.current.has(B)&&(f.current.delete(B),f.current.size===0&&ce.getLatestBenchmark(e,r).then(J=>l({type:"BULK_RUN_COMPLETE",benchmark:J})).catch(()=>l({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[e,r]),{startCase:b,stopCase:y,stopAll:j}=by({onEvent:g,onDone:v,onError:x});c.useEffect(()=>()=>{j()},[j]);const S=c.useCallback(async()=>{try{const B=await fetch(`/api/skills/${e}/${r}/activation-history`);if(!B.ok){if(B.status===404){l({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const Y=await B.json();l({type:"ACTIVATION_HISTORY_LOADED",runs:Y.runs||[]})}catch{}},[e,r]);c.useEffect(()=>{let B=!1;async function Y(){try{const[J,ee,ue]=await Promise.allSettled([ce.getSkillDetail(e,r),ce.getEvals(e,r),ce.getLatestBenchmark(e,r)]);if(B)return;let be=null,Te=null;if(ee.status==="fulfilled")be=ee.value;else{const Q=ee.reason;Te=(Q==null?void 0:Q.message)??"Failed to load test cases"}l({type:"INIT_DATA",skillContent:J.status==="fulfilled"?J.value.skillContent:"",evals:be,evalsError:Te,benchmark:ue.status==="fulfilled"?ue.value:null})}catch(J){B||l({type:"SET_ERROR",error:J.message})}}return Y(),S(),()=>{B=!0}},[e,r,S]);const k=c.useCallback(async B=>{if(o)return;const Y=B??i.skillContent;try{await ce.applyImprovement(e,r,Y),B!==void 0&&B!==i.skillContent&&l({type:"SET_CONTENT",content:B}),l({type:"CONTENT_SAVED"})}catch(J){l({type:"SET_ERROR",error:J.message})}},[o,e,r,i.skillContent]),R=c.useCallback(async B=>{if(!o)try{const Y=await ce.saveEvals(e,r,B);l({type:"SET_EVALS",evals:Y})}catch(Y){l({type:"SET_ERROR",error:Y.message})}},[o,e,r]),w=c.useCallback((B,Y="benchmark")=>{const J=i.caseRunStates.get(B);if((J==null?void 0:J.status)==="running")return;m.current.delete(B),h.current.delete(B),l({type:"CASE_RUN_START",caseId:B,mode:Y});const ee=Y==="comparison"?{eval_ids:[B]}:Y==="baseline"?{mode:"baseline"}:{};if(a!=null&&a.provider&&(ee.provider=a.provider),a!=null&&a.model&&(ee.model=a.model),Y==="comparison"){const ue=`/api/skills/${e}/${r}/compare`;b(B,ue,ee)}else{const ue=`/api/skills/${e}/${r}/benchmark/case/${B}`;b(B,ue,Object.keys(ee).length>0?ee:void 0)}},[e,r,i.caseRunStates,b,a]),E=c.useCallback((B="benchmark")=>{var ee;const Y=((ee=i.evals)==null?void 0:ee.evals)??[];if(Y.length===0)return;const J=Y.map(ue=>ue.id);for(const ue of J)m.current.delete(ue),h.current.delete(ue);l({type:"BULK_RUN_START",caseIds:J,mode:B}),f.current=new Set(J);for(const ue of J){const be=B==="comparison"?{eval_ids:[ue]}:B==="baseline"?{mode:"baseline"}:{};if(a!=null&&a.provider&&(be.provider=a.provider),a!=null&&a.model&&(be.model=a.model),B==="comparison")b(ue,`/api/skills/${e}/${r}/compare`,be);else{const Te=`/api/skills/${e}/${r}/benchmark/case/${ue}`;b(ue,Te,Object.keys(be).length>0?be:void 0)}}},[e,r,i.evals,b,a]),N=c.useCallback(B=>{y(B),l({type:"CASE_RUN_CANCEL",caseId:B}),f.current.delete(B),h.current.add(B)},[y]),T=c.useCallback(()=>{j(),l({type:"CANCEL_ALL"}),f.current.clear()},[j]),I=c.useCallback(async(B,Y)=>{l({type:"OPEN_IMPROVE",evalId:B})},[]),A=c.useCallback(async(B,Y)=>{try{await ce.applyImprovement(e,r,Y),l({type:"SET_CONTENT",content:Y}),l({type:"CONTENT_SAVED"}),l({type:"CLOSE_IMPROVE"}),w(B,"benchmark")}catch(J){l({type:"SET_ERROR",error:J.message})}},[e,r,w]),$=Zs(),W=c.useRef(null),C=c.useRef(0);c.useEffect(()=>{const B=$.events;for(let Y=C.current;Y<B.length;Y++){const J=B[Y],ee=J.data;if(J.event==="progress"&&l({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:ee.phase,message:ee.message}}),J.event==="done"){const ue=ee.improved,be=ee.reasoning,Te=ee.evalChanges??[];l({type:"AI_EDIT_RESULT",improved:ue,reasoning:be,evalChanges:Te})}if(J.event==="error"){const ue=ee;l({type:"AI_EDIT_ERROR",message:ue.description||"Unknown error",classified:ue})}}C.current=B.length},[$.events]),c.useEffect(()=>{$.error&&l({type:"AI_EDIT_ERROR",message:$.error})},[$.error]),c.useEffect(()=>()=>{$.stop()},[$.stop]);const P=c.useCallback(async(B,Y,J)=>{o||(C.current=0,l({type:"AI_EDIT_LOADING"}),W.current=$.stop,$.start(`/api/skills/${e}/${r}/improve?sse`,{mode:"instruct",instruction:B,content:i.skillContent,evals:i.evals??{skill_name:r,evals:[]},provider:Y,model:J}))},[o,e,r,i.skillContent,i.evals,$]),L=c.useCallback(()=>{$.stop(),l({type:"AI_EDIT_ERROR",message:"Cancelled"})},[$]),F=c.useCallback(async()=>{const B=i.aiEditResult;if(B!=null&&B.improved)try{if(await ce.applyImprovement(e,r,B.improved),l({type:"SET_CONTENT",content:B.improved}),l({type:"CONTENT_SAVED"}),i.aiEditEvalChanges.length>0&&Array.from(i.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:J}=await ar(async()=>{const{mergeEvalChanges:be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:be}},[]),ee=i.evals??{skill_name:r,evals:[]},ue=J(ee,i.aiEditEvalChanges,i.aiEditEvalSelections);try{const be=await ce.saveEvals(e,r,ue);l({type:"SET_EVALS",evals:be})}catch(be){l({type:"SET_EVALS_RETRY",evalsFile:ue}),l({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${be.message}. You can retry from the AI Edit panel.`});return}}l({type:"CLOSE_AI_EDIT"})}catch(Y){l({type:"SET_ERROR",error:Y.message})}},[e,r,i.aiEditResult,i.evals,i.aiEditEvalChanges,i.aiEditEvalSelections]),H=c.useCallback(()=>{l({type:"CLOSE_AI_EDIT"})},[]),re=c.useCallback(B=>{l({type:"TOGGLE_EVAL_CHANGE",index:B})},[]),V=c.useCallback(()=>{l({type:"SELECT_ALL_EVAL_CHANGES"})},[]),O=c.useCallback(()=>{l({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),se=c.useCallback(async()=>{const B=i.aiEditEvalsRetry;if(B)try{const Y=await ce.saveEvals(e,r,B);l({type:"SET_EVALS",evals:Y}),l({type:"SET_ERROR",error:null}),l({type:"CLOSE_AI_EDIT"})}catch(Y){l({type:"SET_ERROR",error:`Retry failed: ${Y.message}`})}},[e,r,i.aiEditEvalsRetry]),ge=c.useCallback(async()=>{try{const B=await ce.getSkillDetail(e,r);l({type:"SET_CONTENT",content:B.skillContent}),l({type:"CONTENT_SAVED"})}catch{}},[e,r]),ye=Zs(),z=c.useRef(0);c.useEffect(()=>{const B=ye.events;for(let Y=z.current;Y<B.length;Y++){const J=B[Y],ee=J.data;if(J.event==="progress"&&l({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:ee.phase,message:ee.message}}),J.event==="done"){const ue=ee;ce.saveEvals(e,r,ue).then(be=>l({type:"GENERATE_EVALS_DONE",evals:be})).catch(be=>l({type:"SET_ERROR",error:be.message}))}J.event==="error"&&l({type:"GENERATE_EVALS_ERROR",classified:ee})}z.current=B.length},[ye.events,e,r]),c.useEffect(()=>{ye.error&&l({type:"SET_ERROR",error:ye.error})},[ye.error]),c.useEffect(()=>()=>{ye.stop()},[ye.stop]);const ne=c.useCallback(async B=>{if(o)return;z.current=0,l({type:"GENERATE_EVALS_START"});const Y={};a!=null&&a.provider&&(Y.provider=a.provider),a!=null&&a.model&&(Y.model=a.model);const J=Sy(B==null?void 0:B.testType);J&&(Y.testType=J),ye.start(`/api/skills/${e}/${r}/generate-evals?sse`,Object.keys(Y).length>0?Y:void 0)},[o,e,r,ye,a]),M=Zs(),U=c.useRef(0);c.useEffect(()=>()=>{M.stop()},[M.stop]),c.useEffect(()=>{const B=M.events;for(let Y=U.current;Y<B.length;Y++){const J=B[Y];if(J.event==="classifying"){const ee=J.data;l({type:"ACTIVATION_CLASSIFYING",index:ee.index,total:ee.total})}if(J.event==="prompt_result"&&l({type:"ACTIVATION_RESULT",result:J.data}),J.event==="done"){K.current&&(clearTimeout(K.current),K.current=null);const ee=J.data;if(ee.error)l({type:"ACTIVATION_ERROR",error:ee.error});else{l({type:"ACTIVATION_DONE",summary:ee});const ue={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(a==null?void 0:a.model)||"unknown",provider:(a==null?void 0:a.provider)||"unknown",promptCount:ee.total,summary:{precision:ee.precision,recall:ee.recall,reliability:ee.reliability,tp:ee.tp,tn:ee.tn,fp:ee.fp,fn:ee.fn}};l({type:"ACTIVATION_HISTORY_LOADED",runs:[ue,...i.activationHistory??[]]})}}}U.current=B.length},[M.events,a,i.activationHistory]),c.useEffect(()=>{M.error&&(K.current&&(clearTimeout(K.current),K.current=null),l({type:"ACTIVATION_ERROR",error:M.error}))},[M.error]);const K=c.useRef(null),X=c.useCallback(()=>{K.current&&(clearTimeout(K.current),K.current=null),M.stop(),l({type:"ACTIVATION_CANCEL",totalPrompts:0})},[M]),ie=c.useCallback(B=>{const J=B.trim().split(`
|
|
22
|
+
`).filter(Boolean).map(ue=>ue.startsWith("!")?{prompt:ue.slice(1).trim(),expected:"should_not_activate"}:ue.startsWith("+")?{prompt:ue.slice(1).trim(),expected:"should_activate"}:{prompt:ue.trim(),expected:"auto"});U.current=0,l({type:"ACTIVATION_START"}),l({type:"SET_ACTIVATION_PROMPTS",prompts:B});const ee={prompts:J};a!=null&&a.provider&&(ee.provider=a.provider),a!=null&&a.model&&(ee.model=a.model),M.start(`/api/skills/${e}/${r}/activation-test`,ee),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{M.stop(),l({type:"ACTIVATION_TIMEOUT"}),K.current=null},12e4)},[e,r,M,a]),G=c.useCallback(async(B=8)=>{l({type:"GENERATE_PROMPTS_START"});try{const Y={count:B};a!=null&&a.provider&&(Y.provider=a.provider),a!=null&&a.model&&(Y.model=a.model);const J=await fetch(`/api/skills/${e}/${r}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)});if(!J.ok){let he=`HTTP ${J.status}`;try{const Ce=await J.json();Ce.error&&(he=Ce.error)}catch{}throw new Error(he)}const ee=J.body.getReader(),ue=new TextDecoder;let be="",Te="",Q=[];for(;;){const{done:he,value:Ce}=await ee.read();if(he)break;be+=ue.decode(Ce,{stream:!0});const Ae=be.split(`
|
|
23
|
+
`);be=Ae.pop()||"";for(const Pe of Ae)if(Pe.startsWith("event: "))Te=Pe.slice(7).trim();else if(Pe.startsWith("data: ")){try{const _e=JSON.parse(Pe.slice(6));if(Te==="done"){if(_e.error)throw new Error(_e.error);Q=_e.prompts||[]}if(Te==="error")throw new Error(_e.message||_e.description||"Generation failed")}catch(_e){if(!(_e instanceof SyntaxError))throw _e}Te=""}}const Se=Q.map(he=>`${he.expected==="should_activate"?"+":"!"}${he.prompt}`).join(`
|
|
24
|
+
`);l({type:"SET_PROMPTS_SOURCE",source:"ai-generated",canonical:Se}),l({type:"SET_ACTIVATION_PROMPTS",prompts:Se}),l({type:"GENERATE_PROMPTS_DONE"})}catch(Y){l({type:"GENERATE_PROMPTS_ERROR",error:Y.message})}},[e,r,a]),te=c.useCallback(async()=>{try{const B=await fetch(`/api/skills/${e}/${r}/test-cases`);if(!B.ok)return;const Y=await B.json();if(!Y.prompts||Y.prompts.length===0)return;const J=Y.prompts.map(ee=>ee.expected==="should_activate"?`+${ee.prompt}`:ee.expected==="should_not_activate"?`!${ee.prompt}`:ee.prompt).join(`
|
|
25
|
+
`);l({type:"SET_PROMPTS_SOURCE",source:"skill-md",canonical:J}),l({type:"SET_ACTIVATION_PROMPTS",prompts:J})}catch{}},[e,r]),de=c.useCallback(async()=>{l({type:"SAVE_TEST_CASES_START"});try{const Y=i.activationPrompts.split(`
|
|
26
|
+
`).map(ue=>ue.trim()).filter(Boolean).map(ue=>ue.startsWith("!")?{prompt:ue.slice(1).trim(),expected:"should_not_activate"}:ue.startsWith("+")?{prompt:ue.slice(1).trim(),expected:"should_activate"}:{prompt:ue,expected:"auto"}),J=await fetch(`/api/skills/${e}/${r}/test-cases`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompts:Y})}),ee=await J.json().catch(()=>({}));if(!J.ok||!ee.ok)throw new Error(ee.error||`HTTP ${J.status}`);l({type:"SAVE_TEST_CASES_SUCCESS",count:ee.count??Y.length}),setTimeout(()=>l({type:"CLEAR_SAVE_TEST_CASES_FEEDBACK"}),3e3)}catch(B){l({type:"SAVE_TEST_CASES_ERROR",error:B.message})}},[e,r,i.activationPrompts]),fe=c.useMemo(()=>({state:i,dispatch:l,isReadOnly:o,canEdit:u,canRun:p,saveContent:k,saveEvals:R,runCase:w,runAll:E,cancelCase:N,cancelAll:T,improveForCase:I,applyImproveAndRerun:A,refreshSkillContent:ge,generateEvals:ne,runActivationTest:ie,cancelActivation:X,generateActivationPrompts:G,fetchActivationHistory:S,loadTestCasesFromSkillMd:te,saveTestCasesToSkillMd:de,submitAiEdit:P,cancelAiEdit:L,applyAiEdit:F,discardAiEdit:H,toggleEvalChange:re,selectAllEvalChanges:V,deselectAllEvalChanges:O,retryEvalsSave:se}),[i,o,u,p,k,R,w,E,N,T,I,A,ge,ne,ie,X,G,S,te,de,P,L,F,H,re,V,O,se]);return t.jsx(Qd.Provider,{value:fe,children:s})}function Xd(e){const r=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!r)return{metadata:{},body:e};const n=r[1],s=r[2].trim(),o={},a=n.split(`
|
|
27
|
+
`);let i="",l=!1;for(const d of a){const u=d.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(u&&i&&l){const h=u[1],m=u[2].trim();let g=o[i];if((typeof g!="object"||Array.isArray(g))&&(g={},o[i]=g),!m)g[h]=[];else{const v=m.match(/^\[(.+)\]$/);v?g[h]=v[1].split(",").map(x=>x.trim().replace(/^["']|["']$/g,"")).filter(Boolean):g[h]=m.replace(/^["']|["']$/g,"")}continue}const p=d.match(/^\s+-\s+(.+)$/);if(p&&i){l=!1;const h=o[i];Array.isArray(h)?h.push(p[1].trim().replace(/^["']|["']$/g,"")):o[i]=[p[1].trim().replace(/^["']|["']$/g,"")];continue}const f=d.match(/^([\w-]+):\s*(.*)$/);if(f){i=f[1];const h=f[2].trim();if(l=!1,!h){o[i]={},l=!0;continue}const m=h.match(/^\[(.+)\]$/);if(m){o[i]=m[1].split(",").map(g=>g.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}o[i]=h.replace(/^["']|["']$/g,"")}}return{metadata:o,body:s}}function Ln(e){if(!e)return"";try{let r=e.replace(/^---\n[\s\S]*?\n---\n?/,""),n=Ny(r);return n=n.replace(/```(\w*)\n([\s\S]*?)```/g,'<pre style="background:var(--surface-2);padding:0.75rem;border-radius:6px;overflow-x:auto;font-size:12px;line-height:1.5;margin:0.5rem 0;border:1px solid var(--border-subtle)"><code>$2</code></pre>'),n=n.replace(/^### (.+)$/gm,'<div style="font-weight:600;font-size:14px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),n=n.replace(/^## (.+)$/gm,'<div style="font-weight:700;font-size:15px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),n=n.replace(/^# (.+)$/gm,'<div style="font-weight:700;font-size:1rem;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer" style="color:var(--accent);text-decoration:underline">$1</a>'),n=n.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),n=n.replace(/\*([^*]+)\*/g,"<em>$1</em>"),n=n.replace(/`([^`]+)`/g,'<code style="background:var(--surface-3);padding:0.1rem 0.3rem;border-radius:3px;font-size:0.85em">$1</code>'),n=n.replace(/^- (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">• $1</div>'),n=n.replace(/^(\d+)\. (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">$1. $2</div>'),n=n.replace(/\n\n/g,'<div style="height:0.5rem"></div>'),n=n.replace(/\n/g,"<br/>"),n}catch{return`<pre style="white-space:pre-wrap;font-size:12px;line-height:1.5">${e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`}}function Ny(e){const r=e.split(`
|
|
28
|
+
`),n=[];let s=0;for(;s<r.length;)if(r[s].trim().startsWith("|")&&s+1<r.length&&r[s+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(r[s+1])){const o=Xi(r[s]);s+=2;const a=[];for(;s<r.length&&r[s].trim().startsWith("|");)a.push(Xi(r[s])),s++;const i='style="text-align:left;padding:0.4rem 0.6rem;font-weight:600;font-size:12px;color:var(--text-primary);border-bottom:1px solid var(--border-default)"',l='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let d='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';d+="<thead><tr>";for(const u of o)d+=`<th ${i}>${u}</th>`;d+="</tr></thead><tbody>";for(const u of a){d+="<tr>";for(const p of u)d+=`<td ${l}>${p}</td>`;d+="</tr>"}d+="</tbody></table>",n.push(d)}else n.push(r[s]),s++;return n.join(`
|
|
29
|
+
`)}function Xi(e){return e.split("|").map(r=>r.trim()).filter(r=>r.length>0)}function Cs(e,r){const n=e.split(`
|
|
30
|
+
`),s=r.split(`
|
|
31
|
+
`);if(n.length>1e3||s.length>1e3)return[...n.map(p=>({type:"unchanged",content:p}))];const o=n.length,a=s.length,i=Array.from({length:o+1},()=>new Array(a+1).fill(0));for(let p=1;p<=o;p++)for(let f=1;f<=a;f++)n[p-1]===s[f-1]?i[p][f]=i[p-1][f-1]+1:i[p][f]=Math.max(i[p-1][f],i[p][f-1]);const l=[];let d=o,u=a;for(;d>0||u>0;)d>0&&u>0&&n[d-1]===s[u-1]?(l.push({type:"unchanged",content:n[d-1]}),d--,u--):u>0&&(d===0||i[d][u-1]>=i[d-1][u])?(l.push({type:"added",content:s[u-1]}),u--):(l.push({type:"removed",content:n[d-1]}),d--);return l.reverse()}function Ry(e,r){if(r&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(e))return t.jsx("div",{className:"spinner",style:{width:10,height:10,flexShrink:0}});const s=new Set(["generating","comparing","preparing","generating_skill","generating_baseline","scoring","action_items"]);return t.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:s.has(e)?"var(--accent)":"var(--green)"}})}function An({entries:e,isRunning:r}){const[n,s]=c.useState(!1),o=c.useRef(null);return c.useEffect(()=>{o.current&&!n&&(o.current.scrollTop=o.current.scrollHeight)},[e,n]),e.length===0&&!r?null:t.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.jsxs("button",{onClick:()=>s(!n),className:"w-full flex items-center justify-between px-3 py-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:a=>{a.currentTarget.style.color="var(--text-primary)"},onMouseLeave:a=>{a.currentTarget.style.color="var(--text-tertiary)"},children:[t.jsxs("span",{className:"flex items-center gap-2",children:[r&&t.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",e.length,")"]}),t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{transform:n?"rotate(0)":"rotate(180deg)",transition:"transform 0.2s ease"},children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!n&&t.jsx("div",{ref:o,className:"px-3 pb-3 space-y-1 max-h-48 overflow-y-auto",children:e.map((a,i)=>{const l=i===e.length-1&&r,d=i===0?"0s":`+${((a.timestamp-e[0].timestamp)/1e3).toFixed(1)}s`;return t.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:l?1:.7},children:[Ry(a.phase,l),t.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:d}),t.jsx("span",{style:{color:l?"var(--text-primary)":"var(--text-secondary)"},children:a.message}),a.current!=null&&a.total!=null&&t.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",a.current,"/",a.total,"]"]})]},i)})})]})}const Zi={rate_limit:{icon:"⏱",color:"var(--amber, #f59e0b)"},context_window:{icon:"⚠",color:"var(--amber, #f59e0b)"},auth:{icon:"🔒",color:"var(--red, #ef4444)"},timeout:{icon:"⌛",color:"var(--amber, #f59e0b)"},model_not_found:{icon:"🔍",color:"var(--red, #ef4444)"},provider_unavailable:{icon:"⚡",color:"var(--red, #ef4444)"},parse_error:{icon:"❓",color:"var(--amber, #f59e0b)"},unknown:{icon:"❌",color:"var(--red, #ef4444)"}};function Es({error:e,onRetry:r,onDismiss:n}){const[s,o]=c.useState(null),a=c.useRef(null);c.useEffect(()=>(e.category==="rate_limit"&&e.retryAfterMs?o(Math.ceil(e.retryAfterMs/1e3)):o(null),()=>{a.current&&clearInterval(a.current)}),[e]),c.useEffect(()=>{if(!(s==null||s<=0))return a.current=setInterval(()=>{o(d=>d==null||d<=1?(a.current&&clearInterval(a.current),0):d-1)},1e3),()=>{a.current&&clearInterval(a.current)}},[s!=null&&s>0]);const i=Zi[e.category]||Zi.unknown,l=s!=null&&s>0;return t.jsxs("div",{className:"rounded-lg overflow-hidden animate-fade-in",style:{border:`1px solid color-mix(in srgb, ${i.color} 30%, transparent)`,background:`color-mix(in srgb, ${i.color} 6%, var(--surface-1))`},children:[t.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{style:{fontSize:14},children:i.icon}),t.jsx("span",{className:"text-[12px] font-semibold",style:{color:i.color},children:e.title})]}),n&&t.jsx("button",{onClick:n,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsxs("div",{className:"px-3.5 pb-3",children:[t.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:e.description}),t.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:e.hint}),(r||s!=null)&&t.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:r&&t.jsx("button",{onClick:r,disabled:l,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:l?.5:1},children:l?`Retry in ${s}s`:"Retry"})})]})]})}function Ty({plugin:e,skill:r,skillContent:n,onApplied:s}){const[o,a]=c.useState("closed"),{config:i}=kr(),[l,d]=c.useState("claude-cli"),[u,p]=c.useState("opus"),[f,h]=c.useState([]),[m,g]=c.useState(""),[v,x]=c.useState(""),[b,y]=c.useState(null),[j,S]=c.useState(null),[k,R]=c.useState([]),[w,E]=c.useState(!1),N=c.useRef(null);c.useEffect(()=>{if(!i)return;i.providers.find(L=>L.id==="claude-cli"&&L.available)&&(d("claude-cli"),p("opus"))},[i]),c.useEffect(()=>()=>{var P;(P=N.current)==null||P.abort()},[]);function T(){return i==null?void 0:i.providers.find(P=>P.id===l&&P.available)}const I=c.useCallback(()=>{var P;(P=N.current)==null||P.abort(),a("open")},[]);async function A(){a("loading"),y(null),S(null),R([]);const P=new AbortController;N.current=P;try{const L=await fetch(`/api/skills/${encodeURIComponent(e)}/${encodeURIComponent(r)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:l,model:u}),signal:P.signal});if(!L.ok||!L.body){let O=`HTTP ${L.status}`;try{const se=await L.json();se.error&&(O=se.error)}catch{}throw new Error(O)}const F=L.body.getReader(),H=new TextDecoder;let re="",V="";for(;;){const{done:O,value:se}=await F.read();if(O)break;re+=H.decode(se,{stream:!0});const ge=re.split(`
|
|
32
|
+
`);re=ge.pop()||"";for(const ye of ge)if(ye.startsWith("event: "))V=ye.slice(7).trim();else if(ye.startsWith("data: ")){try{const z=JSON.parse(ye.slice(6));V==="progress"?R(ne=>[...ne,{phase:z.phase,message:z.message,timestamp:Date.now()}]):V==="done"||V==="complete"?(g(z.improved),x(z.reasoning||""),h(Cs(z.original||n,z.improved)),a("diff_shown")):V==="error"&&(y(z.message||z.description||"Unknown error"),z.category&&S(z),a("open"))}catch{}V=""}}}catch(L){L.name!=="AbortError"&&(y(L.message),a("open"))}finally{N.current=null}}async function $(){E(!0);try{await ce.applyImprovement(e,r,m),s(m),a("closed")}catch(P){y(P.message)}finally{E(!1)}}function W(){a("closed"),h([]),g(""),x(""),y(null)}if(o==="closed")return t.jsxs("button",{onClick:()=>a("open"),className:"btn btn-secondary mb-5",disabled:!n,children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),t.jsx("path",{d:"M2 17l10 5 10-5"}),t.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const C=T();return t.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),t.jsx("path",{d:"M2 17l10 5 10-5"}),t.jsx("path",{d:"M2 12l10 5 10-5"})]})}),t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),t.jsx("button",{onClick:W,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:P=>{P.currentTarget.style.background="var(--surface-3)"},onMouseLeave:P=>{P.currentTarget.style.background="transparent"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsxs("div",{className:"px-5 py-4",children:[(o==="open"||o==="loading")&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),t.jsx("select",{className:"input-field text-[12px] py-1.5",value:l,onChange:P=>{d(P.target.value);const L=i==null?void 0:i.providers.find(F=>F.id===P.target.value);L!=null&&L.models[0]&&p(L.models[0].id)},disabled:o==="loading",children:i==null?void 0:i.providers.filter(P=>P.available).map(P=>t.jsx("option",{value:P.id,children:P.label},P.id))})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),t.jsx("select",{className:"input-field text-[12px] py-1.5",value:u,onChange:P=>p(P.target.value),disabled:o==="loading",children:C==null?void 0:C.models.map(P=>t.jsx("option",{value:P.id,children:P.label},P.id))})]}),o==="loading"?t.jsx("button",{onClick:I,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):t.jsx("button",{onClick:A,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),o==="loading"&&k.length>0&&t.jsx("div",{className:"mt-3",children:t.jsx(An,{entries:k,isRunning:!0})})]}),b&&t.jsx("div",{className:"mb-4",children:j?t.jsx(Es,{error:j,onRetry:A,onDismiss:()=>{y(null),S(null)}}):t.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),o==="diff_shown"&&t.jsxs(t.Fragment,{children:[v&&t.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[t.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),v]}),t.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:f.map((P,L)=>t.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:P.type==="added"?"rgba(34,197,94,0.1)":P.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:P.type==="added"?"var(--green)":P.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:P.type==="added"?"3px solid var(--green)":P.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[t.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:P.type==="added"?"+":P.type==="removed"?"-":" "}),P.content]},L))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:$,disabled:w,className:"btn btn-primary",children:w?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),t.jsx("button",{onClick:W,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const el={remove:{bg:"var(--red-muted)",color:"var(--red)",label:"REMOVE"},modify:{bg:"rgba(251,191,36,0.15)",color:"#fbbf24",label:"MODIFY"},add:{bg:"var(--green-muted)",color:"var(--green)",label:"ADD"}},Iy={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function Ly({change:e,index:r,selected:n,onToggle:s,originalEval:o}){var f;const[a,i]=c.useState(!1),l=el[e.action]??el.add,d=Iy[e.action]??"var(--border-subtle)",u=e.action==="remove"?(o==null?void 0:o.name)??`Eval #${e.evalId}`:((f=e.eval)==null?void 0:f.name)??"Unnamed",p=c.useCallback(()=>s(r),[s,r]);return t.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${d}`,opacity:n?1:.5},children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:p,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),t.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:l.bg,color:l.color,padding:"1px 6px"},children:l.label}),t.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:u}),t.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:e.reason}),t.jsx("button",{onClick:()=>i(!a),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:h=>{h.currentTarget.style.background="var(--surface-3)"},onMouseLeave:h=>{h.currentTarget.style.background="transparent"},children:t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(90deg)":"rotate(0)",transition:"transform 0.15s ease"},children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),a&&t.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[e.action==="add"&&e.eval&&t.jsx(Ay,{evalCase:e.eval}),e.action==="modify"&&e.eval&&o&&t.jsx(Py,{original:o,proposed:e.eval}),e.action==="remove"&&o&&t.jsx($y,{evalCase:o})]})]})}function Ay({evalCase:e}){var r;return t.jsxs("div",{className:"pt-2.5 space-y-2",children:[t.jsx(Zo,{label:"Prompt",value:e.prompt}),t.jsx(Zo,{label:"Expected",value:e.expected_output}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=e.assertions)==null?void 0:r.length)??0,")"]}),t.jsx("div",{className:"mt-1 space-y-1",children:(e.assertions??[]).map(n=>t.jsxs("div",{className:"text-[11px] flex items-start gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{style:{color:"var(--green)"},children:"+"})," ",n.text]},n.id))})]})]})}function Py({original:e,proposed:r}){const n=[];e.name!==r.name&&n.push({label:"Name",old:e.name,new:r.name}),e.prompt!==r.prompt&&n.push({label:"Prompt",old:e.prompt,new:r.prompt}),e.expected_output!==r.expected_output&&n.push({label:"Expected",old:e.expected_output,new:r.expected_output});const s=e.assertions??[],o=r.assertions??[],a=new Set(s.map(u=>u.text)),i=new Set(o.map(u=>u.text)),l=o.filter(u=>!a.has(u.text)),d=s.filter(u=>!i.has(u.text));return t.jsxs("div",{className:"pt-2.5 space-y-2",children:[n.map(u=>t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:u.label}),t.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[t.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",ea(u.old,120)]}),t.jsxs("div",{style:{color:"var(--green)"},children:["+ ",ea(u.new,120)]})]})]},u.label)),(l.length>0||d.length>0)&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),t.jsxs("div",{className:"mt-1 space-y-0.5",children:[d.map(u=>t.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",u.text]},u.id)),l.map(u=>t.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",u.text]},u.id))]})]}),n.length===0&&l.length===0&&d.length===0&&t.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function $y({evalCase:e}){var r;return t.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[t.jsx(Zo,{label:"Prompt",value:e.prompt}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=e.assertions)==null?void 0:r.length)??0,")"]}),t.jsx("div",{className:"mt-1 space-y-0.5",children:(e.assertions??[]).map(n=>t.jsx("div",{className:"text-[11px]",style:{color:"var(--red)",textDecoration:"line-through"},children:n.text},n.id))})]})]})}function Zo({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:e}),t.jsx("div",{className:"mt-0.5 text-[11px] p-2 rounded font-mono",style:{background:"var(--surface-1)",color:"var(--text-secondary)",whiteSpace:"pre-wrap"},children:ea(r,300)})]})}function ea(e,r){return e.length>r?e.slice(0,r)+"...":e}const tl={remove:0,modify:1,add:2};function My({changes:e,selections:r,currentEvals:n,onToggle:s,onSelectAll:o,onDeselectAll:a}){if(e.length===0)return null;const i=e.map((d,u)=>({change:d,originalIndex:u}));i.sort((d,u)=>(tl[d.change.action]??2)-(tl[u.change.action]??2));const l=Array.from(r.values()).filter(Boolean).length;return t.jsxs("div",{className:"mt-3 animate-fade-in",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),t.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",l,"/",e.length," selected)"]})]}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("button",{onClick:o,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:d=>{d.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:"Select All"}),t.jsx("button",{onClick:a,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),t.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:i.map(({change:d,originalIndex:u})=>t.jsx(Ly,{change:d,index:u,selected:r.get(u)??!1,onToggle:s,originalEval:d.evalId!=null?n.find(p=>p.id===d.evalId):void 0},u))})]})}function Fy(){var P;const{state:e,dispatch:r,submitAiEdit:n,applyAiEdit:s,discardAiEdit:o,cancelAiEdit:a,toggleEvalChange:i,selectAllEvalChanges:l,deselectAllEvalChanges:d,retryEvalsSave:u}=vt(),{aiEditLoading:p,aiEditResult:f,aiEditError:h,aiEditClassifiedError:m,aiEditProgress:g,aiEditEvalChanges:v,aiEditEvalSelections:x,aiEditEvalsRetry:b}=e,[y,j]=c.useState(""),{config:S}=kr(),[k,R]=c.useState("claude-cli"),[w,E]=c.useState("opus"),N=c.useRef(null);c.useEffect(()=>{var L;(L=N.current)==null||L.focus()},[]),c.useEffect(()=>{if(!S)return;S.providers.find(F=>F.id==="claude-cli"&&F.available)&&(R("claude-cli"),E("opus"))},[S]);const T=S==null?void 0:S.providers.find(L=>L.id===k&&L.available),I=c.useCallback(()=>{const L=y.trim();!L||p||n(L,k,w)},[y,p,n,k,w]),A=c.useCallback(L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),I()),L.key==="Escape"&&(L.preventDefault(),p?a():o())},[I,p,a,o]),$=c.useCallback(()=>{r({type:"CLOSE_AI_EDIT"}),r({type:"OPEN_AI_EDIT"})},[r]),W=f?Cs(e.skillContent,f.improved):[],C=((P=e.evals)==null?void 0:P.evals)??[];return t.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-2)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M15 4V2"}),t.jsx("path",{d:"M15 16v-2"}),t.jsx("path",{d:"M8 9h2"}),t.jsx("path",{d:"M20 9h2"}),t.jsx("path",{d:"M17.8 11.8L19 13"}),t.jsx("path",{d:"M15 9h.01"}),t.jsx("path",{d:"M17.8 6.2L19 5"}),t.jsx("path",{d:"M11 6.2L9.7 5"}),t.jsx("path",{d:"M3 21l9-9"})]})}),t.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),t.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),t.jsx("button",{onClick:o,className:"w-6 h-6 rounded-md flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:L=>{L.currentTarget.style.background="var(--surface-3)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsxs("div",{className:"px-4 py-3",children:[!f&&t.jsxs(t.Fragment,{children:[t.jsx("textarea",{ref:N,value:y,onChange:L=>j(L.target.value),onKeyDown:A,placeholder:"e.g., Add an error handling section...",disabled:p,rows:4,className:"w-full resize-y outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12.5,lineHeight:1.5,fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",minHeight:96,maxHeight:240}}),t.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[t.jsxs("div",{style:{minWidth:200},children:[t.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),t.jsx("select",{className:"input-field text-[11px] py-1",value:k,onChange:L=>{R(L.target.value);const F=S==null?void 0:S.providers.find(H=>H.id===L.target.value);F!=null&&F.models[0]&&E(F.models[0].id)},disabled:p,style:{width:"100%"},children:S==null?void 0:S.providers.filter(L=>L.available).map(L=>t.jsx("option",{value:L.id,children:L.label},L.id))})]}),t.jsxs("div",{style:{minWidth:200},children:[t.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),t.jsx("select",{className:"input-field text-[11px] py-1",value:w,onChange:L=>E(L.target.value),disabled:p,style:{width:"100%"},children:T==null?void 0:T.models.map(L=>t.jsx("option",{value:L.id,children:L.label},L.id))})]}),t.jsx("div",{className:"flex-1"}),p?t.jsx("button",{onClick:a,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):t.jsx("button",{onClick:I,disabled:!y.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),p&&g.length>0&&t.jsx("div",{className:"mt-2.5",children:t.jsx(An,{entries:g,isRunning:!0})})]}),h&&t.jsx("div",{className:"mt-3",children:m?t.jsx(Es,{error:m,onRetry:$,onDismiss:o}):t.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:h})}),f&&t.jsxs("div",{className:"animate-fade-in",children:[f.reasoning&&t.jsxs("div",{className:"mb-3 px-3 py-2.5 rounded-lg text-[11.5px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[t.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),f.reasoning]}),t.jsx("div",{className:"mb-1",children:t.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),t.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:W.map((L,F)=>t.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:L.type==="added"?"rgba(34,197,94,0.1)":L.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:L.type==="added"?"var(--green)":L.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:L.type==="added"?"3px solid var(--green)":L.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[t.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:L.type==="added"?"+":L.type==="removed"?"-":" "}),L.content]},F))}),t.jsx(My,{changes:v,selections:x,currentEvals:C,onToggle:i,onSelectAll:l,onDeselectAll:d}),b&&t.jsxs("div",{className:"mt-3 px-3 py-2.5 rounded-lg text-[12px] flex items-center justify-between",style:{background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.3)",color:"#fbbf24"},children:[t.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),t.jsx("button",{onClick:u,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),t.jsxs("div",{className:"flex gap-2 mt-3",children:[t.jsxs("button",{onClick:s,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),t.jsx("button",{onClick:o,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),t.jsx("button",{onClick:$,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function Dy(e,r){const[n,s]=c.useState([]),[o,a]=c.useState("SKILL.md"),[i,l]=c.useState(null),[d,u]=c.useState(!1),[p,f]=c.useState(null),[h,m]=c.useState(null),g=c.useCallback(async()=>{try{const b=await ce.getSkillFiles(e,r);s(b.files),m(null)}catch(b){s([]),m(b.message??"Unable to load skill files")}},[e,r]);c.useEffect(()=>{a("SKILL.md"),l(null),f(null),m(null),g()},[e,r,g]);const v=c.useCallback(async b=>{if(a(b),b==="SKILL.md"){l(null),f(null);return}u(!0),f(null);try{const y=await ce.getSkillFile(e,r,b);l(y)}catch(y){f(`Unable to open file: ${y.message}`),l(null)}finally{u(!1)}},[e,r]),x=c.useCallback(()=>{g()},[g]);return{files:n,activeFile:o,secondaryContent:i,loading:d,error:p,loadError:h,selectFile:v,refresh:x,isSkillMd:o==="SKILL.md"}}function zy(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function By(e){const r=[],n=new Map;for(const s of e){const o=s.path.split("/"),i={name:o[o.length-1],path:s.path,type:s.type,size:s.size,children:[]};n.set(s.path,i)}for(const s of e){const o=s.path.split("/");if(o.length===1){const a=n.get(s.path);a&&r.push(a)}else{const a=o.slice(0,-1).join("/"),i=n.get(a),l=n.get(s.path);i&&l&&i.children.push(l)}}return r}function Zd({expanded:e}){return t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:e?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})}function eu(){return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function _y(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Oy(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("polyline",{points:"1 20 1 14 7 14"}),t.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function tu({node:e,depth:r,activeFile:n,onSelect:s}){const[o,a]=c.useState(!0),i=e.path===n;return e.type==="dir"?t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>a(!o),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left"},children:[t.jsx(Zd,{expanded:o}),t.jsx(eu,{}),t.jsxs("span",{children:[e.name,"/"]})]}),o&&e.children.map(l=>t.jsx(tu,{node:l,depth:r+1,activeFile:n,onSelect:s},l.path))]}):t.jsxs("button",{onClick:()=>s(e.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:i?"var(--accent-muted)":"none",border:"none",cursor:"pointer",color:i?"var(--accent)":"var(--text-tertiary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left",borderRadius:3},children:[t.jsx("span",{style:{width:10}}),t.jsx(_y,{}),t.jsx("span",{style:{flex:1},children:e.name}),t.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:zy(e.size)})]})}function Wy({files:e,activeFile:r,onSelect:n,onRefresh:s,loadError:o}){const[a,i]=c.useState(!1),l=c.useMemo(()=>By(e),[e]);return t.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>i(!a),children:[t.jsx(Zd,{expanded:a}),t.jsx(eu,{}),t.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),t.jsx("button",{onClick:d=>{d.stopPropagation(),s()},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:"2px 4px",display:"flex",alignItems:"center",borderRadius:3},title:"Refresh file list",children:t.jsx(Oy,{})})]}),a&&t.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:o?t.jsx("div",{style:{fontSize:11,color:"var(--text-warning, var(--text-tertiary))",padding:"4px 8px"},title:o,children:"Skill files not accessible from this workspace"}):l.length===0?t.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):l.map(d=>t.jsx(tu,{node:d,depth:0,activeFile:r,onSelect:n},d.path))})]})}function _n(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Uy(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Hy(e){const r=e.toLowerCase();return r.endsWith(".json")?"json":r.endsWith(".md")?"md":"other"}function rl({content:e}){return t.jsx("textarea",{readOnly:!0,value:e,style:{flex:1,width:"100%",resize:"none",background:"var(--surface-1)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}})}function nl({content:e,fileType:r}){if(r==="json"){const n=Uy(e);return t.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n})}return r==="md"?t.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 20px",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:13,lineHeight:1.6},dangerouslySetInnerHTML:{__html:Ln(e)}}):t.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})}function sl(e){try{return JSON.stringify(JSON.parse(e),null,2).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"([^"\\]|\\.)*"\s*:/g,n=>`<span style="color:#6383ff">${n}</span>`).replace(/:\s*"([^"\\]|\\.)*"/g,n=>`<span style="color:#22c55e">${n.slice(0,2)}<span style="color:#22c55e">${n.slice(2)}</span></span>`).replace(/:\s*(-?\d+\.?\d*)/g,(n,s)=>`: <span style="color:#fb923c">${s}</span>`).replace(/:\s*(true|false|null)/g,(n,s)=>`: <span style="color:#a855f7">${s}</span>`)}catch{return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}}function Vy({file:e,loading:r,error:n,viewMode:s,plugin:o,skill:a,onSaved:i,onDirtyChange:l}){const[d,u]=c.useState(s),[p,f]=c.useState(!1),[h,m]=c.useState(""),[g,v]=c.useState(!1),[x,b]=c.useState(null),y=s!==d?s:d;c.useEffect(()=>{l==null||l(p)},[p,l]);const j=c.useCallback(()=>{(e==null?void 0:e.content)!=null&&(m(e.content),f(!0))},[e]),S=c.useCallback(()=>{f(!1)},[]),k=c.useCallback(async()=>{if(!(!o||!a||!e)){v(!0);try{await ce.saveSkillFile(o,a,e.path,h),b("Saved"),f(!1),i==null||i(),setTimeout(()=>b(null),2e3)}catch(E){b(`Save failed: ${E.message}`),setTimeout(()=>b(null),3e3)}finally{v(!1)}}},[o,a,e,h,i]);if(c.useEffect(()=>{if(!p)return;const E=N=>{(N.ctrlKey||N.metaKey)&&N.key==="s"&&(N.preventDefault(),k())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[p,k]),r)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:"Loading…"});if(n)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:t.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"16px 20px",maxWidth:400,textAlign:"center"},children:[t.jsx("div",{style:{fontSize:13,color:"var(--text-primary)",fontWeight:600,marginBottom:6},children:"Unable to open file"}),t.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:n})]})});if(!e)return null;if(e.binary)return t.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:["Binary file (",_n(e.size),") — cannot be displayed"]});const R=e.content??"",w=Hy(e.path);return t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[e.truncated&&t.jsxs("div",{style:{padding:"4px 12px",background:"var(--warning-muted, #fef3c7)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:"var(--warning-text, #92400e)"},children:["File truncated at ",_n(512*1024)," — ",_n(e.size)," total"]}),t.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(w==="md"||w==="json")&&["raw","split","preview"].map(E=>t.jsx("button",{onClick:()=>u(E),style:{padding:"2px 8px",fontSize:11,background:y===E?"var(--accent-muted)":"none",color:y===E?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:E},E)),t.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[_n(e.size),o&&a&&!e.binary&&!p&&t.jsx("button",{onClick:j,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),p&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:k,disabled:g,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:g?.6:1},children:g?"Saving...":"Save"}),t.jsx("button",{onClick:S,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),x&&t.jsx("div",{style:{padding:"4px 12px",background:x.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:x.startsWith("Save failed")?"var(--red)":"var(--green)"},children:x}),t.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:p?t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[t.jsx("textarea",{value:h,onChange:E=>m(E.target.value),style:{flex:1,width:"100%",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}}),t.jsxs("div",{style:{position:"sticky",bottom:0,display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[t.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),t.jsx("button",{onClick:k,disabled:g,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:g?.6:1},children:g?"Saving...":"Save"}),t.jsx("button",{onClick:S,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):y==="split"&&w!=="other"?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:t.jsx(rl,{content:R})}),t.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:w==="json"?t.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:sl(R)}}):t.jsx(nl,{content:R,fileType:w})})]}):y==="preview"&&w!=="other"?w==="json"?t.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:sl(R)}}):t.jsx(nl,{content:R,fileType:w}):t.jsx(rl,{content:R})})]})}const Gy=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/,Ky=/^https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/;function za(e){const r=e.trim();if(!r)throw new Error("normalizeRemoteUrl: empty input");let n=r.match(Gy);if(n)return`https://github.com/${n[1]}/${n[2]}`;if(n=r.match(Ky),n)return`https://github.com/${n[1]}/${n[2]}`;throw new Error(`normalizeRemoteUrl: unrecognized remote URL: ${e}`)}function qy(e){const r=za(e);return`https://verified-skill.com/submit?repo=${encodeURIComponent(r)}`}async function ol(e=!1,r=0){const n=await fetch(`/api/v1/billing/quota${e?"?fresh=1":""}`,{cache:"no-store"});if(!n.ok)throw Object.assign(new Error(`Could not read subscription status (${n.status}).`),{status:n.status});const s=await n.json();if(!["free","pro","enterprise"].includes(s.tier))throw new Error("Invalid subscription response");const o=new Date().toISOString();return{cache:{response:s,localAtSync:o,clockSkewMs:0},localSkillCount:r,isFresh:!0,daysRemaining:s.gracePeriodDaysRemaining??0}}const ru=c.createContext(null);function Yy(e){if(typeof window>"u")return()=>{};if(!window.__TAURI_INTERNALS__)return()=>{};const n=()=>{document.visibilityState==="visible"&&e()};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n)}}function Jy({children:e,projectRoots:r=[]}){const n=jn(),[s,o]=c.useState(null),[a,i]=c.useState(!1),[l,d]=c.useState(null),u=c.useRef(r);u.current=r;const p=c.useRef(n);p.current=n;const f=c.useCallback(async()=>{i(!0),d(null);try{const v=await ol();o(v)}catch(v){if(d(v instanceof Error?v.message:String(v)),v.status===401)o(null);else try{o(await p.current.quotaGet(u.current))}catch{}}finally{i(!1)}},[]),h=c.useCallback(async(v=!1)=>{i(!0),d(null);try{const x=await ol(v);o(x)}catch(x){if(d(x instanceof Error?x.message:String(x)),x.status===401){o(null);return}try{const b=await p.current.quotaGet(u.current);o(b)}catch{}}finally{i(!1)}},[]),m=c.useCallback(async()=>p.current.quotaCanCreateSkill(u.current),[]);c.useEffect(()=>{f();const v=Yy(()=>{f()}),x=setInterval(()=>{f()},6e4);return()=>{v(),clearInterval(x)}},[f]);const g=c.useMemo(()=>({snapshot:s,refreshing:a,error:l,forceSync:h,canCreateSkill:m}),[s,a,l,h,m]);return t.jsx(ru.Provider,{value:g,children:e})}function Ba(){const e=c.useContext(ru);if(!e)throw new Error("useQuota() called outside <QuotaProvider>");return e}function nu(){const{snapshot:e}=Ba();if(!e)return{tier:"free",isPro:!1,isFree:!0,isEnterprise:!1,skillCount:0,skillLimit:null,isUnlimited:!0,gracePeriodDaysRemaining:0,isFresh:!1,loaded:!1,localSkillCount:0};const r=e.cache;if(!r)return{tier:"free",isPro:!1,isFree:!0,isEnterprise:!1,skillCount:0,skillLimit:null,isUnlimited:!0,gracePeriodDaysRemaining:e.daysRemaining,isFresh:e.isFresh,loaded:!0,localSkillCount:e.localSkillCount};const n=r.response.tier,s=n==="pro"||n==="enterprise",o=r.response.skillLimit;return{tier:n,isPro:s,isFree:n==="free",isEnterprise:n==="enterprise",skillCount:r.response.skillCount,skillLimit:o,isUnlimited:o===null,gracePeriodDaysRemaining:e.daysRemaining,isFresh:e.isFresh,loaded:!0,localSkillCount:e.localSkillCount}}const _a="https://verified-skill.com/pricing",al="paywall-modal-title",eo="paywall-modal-body";function su({open:e,onClose:r,onProceed:n,skillName:s,context:o="connect"}){const a=jn(),{forceSync:i,snapshot:l}=Ba(),d=c.useRef(null),u=c.useRef(null),p=c.useRef(null);c.useEffect(()=>{if(!e)return;let h=!1;return(async()=>{try{await i(!0)}catch{}})(),()=>{h=!0}},[e,i]),c.useEffect(()=>{var m;if(!e)return;const h=(m=l==null?void 0:l.cache)==null?void 0:m.response.tier;(h==="pro"||h==="enterprise")&&(n==null||n(),r())},[e,l,n,r]),c.useEffect(()=>{if(!e)return;p.current=typeof document<"u"?document.activeElement:null;const h=setTimeout(()=>{var g;return(g=u.current)==null?void 0:g.focus()},0),m=g=>{if(g.key==="Escape"){g.preventDefault(),r();return}if(g.key!=="Tab")return;const v=d.current;if(!v)return;const x=Array.from(v.querySelectorAll('button:not([disabled]),[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])'));if(x.length===0)return;const b=x[0],y=x[x.length-1],j=typeof document<"u"?document.activeElement:null;g.shiftKey&&j===b?(g.preventDefault(),y.focus()):!g.shiftKey&&j===y&&(g.preventDefault(),b.focus())};return document.addEventListener("keydown",m),()=>{clearTimeout(h),document.removeEventListener("keydown",m),p.current instanceof HTMLElement&&p.current.focus()}},[e,r]);const f=c.useCallback(()=>{a.openExternalUrl(_a)},[a]);return e?t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":al,"aria-describedby":eo,"data-testid":"paywall-modal",style:Qy,children:[t.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),t.jsxs("div",{ref:d,style:Xy,children:[t.jsx("h2",{id:al,style:Zy,children:o==="publish"?"Publish private skills with Skill Studio Pro":"Connect private repositories with Skill Studio Pro"}),o==="publish"?t.jsx("p",{id:eo,style:il,children:"Pro lets you publish a skill privately, so only your org can see, search, or install it. Publishing publicly stays free."}):t.jsxs("p",{id:eo,style:il,children:["Pro adds private repo connections, priority support, and unlimited skills. Free users keep all current features for public repos.",s?t.jsxs(t.Fragment,{children:[" ",t.jsxs("span",{style:{color:"var(--color-muted, #888)"},children:["(",s," won’t connect until you upgrade.)"]})]}):null]}),t.jsxs("div",{style:eb,children:[t.jsx("button",{type:"button",onClick:r,"data-testid":"paywall-maybe-later",style:rb,children:"Maybe later"}),t.jsx("button",{ref:u,type:"button",onClick:f,"data-testid":"paywall-upgrade",style:tb,children:"Upgrade to Pro"})]})]})]}):null}const Qy={position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center"},Xy={position:"relative",width:"min(420px, 92vw)",background:"var(--color-bg, #ffffff)",color:"var(--color-text, #111111)",borderRadius:12,padding:"24px 24px 16px",boxShadow:"0 16px 48px rgba(0,0,0,0.25)",fontFamily:"var(--font-system, -apple-system, system-ui)"},Zy={margin:0,fontSize:18,fontWeight:600},il={marginTop:12,marginBottom:24,fontSize:14,lineHeight:1.5,color:"var(--color-text-soft, #444)"},eb={display:"flex",justifyContent:"flex-end",gap:12},ou={padding:"8px 16px",borderRadius:6,fontSize:13,fontWeight:500,cursor:"pointer",border:"1px solid transparent"},tb={...ou,background:"var(--color-accent, #cb4b16)",color:"#ffffff"},rb={...ou,background:"transparent",color:"var(--color-text, #111111)",borderColor:"var(--color-border, #cccccc)"},is=!0,nb=`${_a}#hosted-waitlist`,sb="https://verified-skill.com/settings/integrations",au="Select a publishing account. If none is available, connect the GitHub App to your account or organization first.";function ob({selection:e}){return t.jsxs("div",{"data-testid":"publish-tenant-picker",style:{marginBottom:16,fontSize:12,lineHeight:1.6},children:[t.jsx("label",{htmlFor:"publish-tenant",style:{display:"block",fontWeight:600},children:"Publishing account"}),e!=null&&e.loading?t.jsx("p",{role:"status",children:"Loading publishing accounts…"}):e!=null&&e.tenants.length?t.jsxs("select",{id:"publish-tenant","aria-label":"Publishing account",value:e.tenantId??"",onChange:r=>{e.select(r.target.value)},style:{width:"100%",padding:"8px 10px",color:"#E2E8F0",background:"#101319",border:"1px solid #465060",borderRadius:6,colorScheme:"dark"},children:[t.jsx("option",{value:"",disabled:!0,children:"Select an account…"}),e.tenants.map(r=>t.jsx("option",{value:r.tenantId,children:r.name},r.tenantId))]}):t.jsx("p",{children:au}),(e==null?void 0:e.error)&&t.jsx("p",{role:"alert",children:e.error}),t.jsxs("div",{style:{display:"flex",gap:14,marginTop:8},children:[t.jsx("button",{type:"button",className:"btn btn-ghost text-[11px]",style:{color:"#93C5FD"},onClick:()=>{hn(sb)},children:"Connect GitHub App ↗"}),e&&t.jsx("button",{type:"button",className:"btn btn-ghost text-[11px]",style:{color:"#CBD5E1"},disabled:e.loading,onClick:()=>{e.refresh()},children:"Refresh accounts"})]})]})}const ll=new Set(["PUBLISHED","REJECTED","TIER1_FAILED","TIER2_FAILED","BLOCKED","FAILED"]);function ab({id:e,initialState:r}){const[n,s]=c.useState(r),[o,a]=c.useState(null),[i,l]=c.useState(0);c.useEffect(()=>{let u=!0,p;const f=async()=>{try{const h=await ce.getSubmission(e);if(!u)return;const m=typeof h.state=="string"?h.state:"RECEIVED";s(m),a(typeof h.error=="string"?h.error:null),ll.has(m)||(p=setTimeout(()=>{f()},2e3))}catch{u&&a("Could not read private publishing status. Retry to check the result before submitting again.")}};return f(),()=>{u=!1,clearTimeout(p)}},[e,i]);const d=n==="PUBLISHED"?"Published privately.":ll.has(n)?"Private publication needs attention.":"Private security review in progress.";return t.jsxs("div",{role:"status","data-testid":"private-submission-status","data-state":n,style:{marginTop:12,lineHeight:1.6},children:[t.jsx("strong",{children:d})," ",t.jsx("span",{children:"Visible only to the selected publishing account."}),o&&t.jsx("p",{role:"alert",children:o}),o&&t.jsx("button",{type:"button",className:"btn btn-ghost text-[11px]",onClick:()=>l(u=>u+1),children:"Refresh status"})]})}function fr(e,r){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}const ta="https://verified-skill.com/submit";function cl(e){try{return qy(e)}catch{return ta}}function ib({remoteUrl:e,fileCount:r,provider:n,model:s,onClose:o,defaultMode:a="manual",skillName:i,skillPath:l,privacy:d,tenantId:u,tenantSelection:p}){const[f,h]=c.useState(a),[m,g]=c.useState(""),[v,x]=c.useState(!1),[b,y]=c.useState(!1),[j,S]=c.useState(d??"public"),[k,R]=c.useState(!1),{isFree:w}=nu(),E=is,N=j,T=N==="private"&&!E,I=N==="private"&&!i,A=N==="private"?u:void 0,$=N==="private"&&!!(!A||p!=null&&p.loading||p!=null&&p.error),[W,C]=c.useState(null),[P,L]=c.useState(null),[F,H]=c.useState(null),{catalog:re}=Dc(),V=c.useMemo(()=>{if(!(re!=null&&re.activeAgent)||!re.activeModel)return null;const B=re.agents.find(J=>J.id===re.activeAgent),Y=B==null?void 0:B.models.find(J=>J.id===re.activeModel);return{provider:re.activeAgent,model:re.activeModel,displayName:(Y==null?void 0:Y.displayName)??re.activeModel}},[re]),O=(V==null?void 0:V.provider)??n,se=(V==null?void 0:V.model)??s,ge=(V==null?void 0:V.displayName)??se,ye=c.useCallback(async()=>{x(!0),C(null);try{const B=await ce.gitCommitMessage({provider:O,model:se});g(B.message)}catch(B){const Y=B instanceof Error?B.message:String(B);C(Y)}finally{x(!1)}},[O,se]);c.useEffect(()=>{a==="ai"&&!m&&ye()},[]);const z=c.useCallback(()=>{h("ai"),L(null),m.trim()||ye()},[m,ye]),ne=c.useCallback(()=>{h("manual"),C(null)},[]),M=c.useCallback(async()=>{const B=m.trim();if(!(r>0&&!B||b)){if(I){L("Select a skill before publishing privately.");return}if($){L(au);return}y(!0),L(null),H(null);try{const Y=await ce.gitPublish(r>0?{commitMessage:B}:void 0);if(Y.conflict){const Te=Y.conflictedFiles??[],Q=Y.error??(Te.length>0?`Remote has changes that conflict with yours in: ${Te.join(", ")}. Pull and resolve manually, then publish again.`:"Remote has changes that conflict with yours. Pull and resolve manually, then publish again.");L(Q);const Se=Y.reason==="rebase_failed"?"Publish blocked: could not rebase onto the remote — pull manually and retry":"Publish blocked: remote conflict — resolve and retry";fr(Se,"error");return}const J=Y.remoteUrl??e,ee=(Y.commitSha??"").slice(0,7),ue=Y.branch??"",be=Y.reconciled?" (reconciled with remote)":"";if(i){let Te;try{Te=za(J)}catch{if(N==="private"){H({ok:!1,notSubmitted:"Private publishing requires a GitHub repository connected to the selected account."});return}H({ok:!1,websiteUrl:cl(J)}),fr(`Pushed ${ee} on ${ue}${be} — open the website to submit`,"info");return}let Q;try{Q=await ce.submitToQueue({repoUrl:Te,skillName:i,skillPath:l,source:"studio-submit",privacy:N,tenantId:A})}catch(he){if(N==="private"){const Pe=he instanceof Error?he.message:"Private submission could not be completed. Retry from Studio.";H({ok:!1,notSubmitted:Pe});return}if(wc(he)){H({ok:!1,notSubmitted:he.message}),fr(`Pushed ${ee} on ${ue}${be}. Not submitted to verified-skill.com.`,"info");return}const Ce=he==null?void 0:he.status;H({ok:!1,websiteUrl:typeof Ce=="number"&&Ce!==413?cl(J):ta}),fr(`Pushed ${ee} on ${ue}${be} — sign in or finish on the website to submit`,"info");return}const Se=N==="private"?"":`https://verified-skill.com/submit?repo=${encodeURIComponent(Te)}`;H({ok:!0,result:Q,submitUrl:Se,private:N==="private"}),fr(`Submitted ${i} — ${ee} on ${ue}`,"info")}else H({ok:!1,websiteUrl:ta}),fr(`Pushed ${ee} on ${ue}${be} — open the website to submit`,"info")}catch(Y){const J=Y instanceof Error?Y.message:String(Y),ee=J.length>200?J.slice(0,200)+"…":J;L(ee),fr(`Publish failed: ${ee}`,"error")}finally{y(!1)}}},[m,b,e,i,l,N,A,r,$,T,I]),U=c.useCallback(B=>{hn(B)},[]),K=(r===0||m.trim().length>0)&&!b&&!v&&!$&&!T&&!I,X="#E6EDF3",ie="#9CA3AF",G="rgba(255,255,255,0.12)",te="#0F1115",de={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:ie,fontFamily:"var(--font-mono, monospace)",marginBottom:6,display:"block"},fe={flex:1,height:32,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,fontFamily:"var(--font-mono, monospace)",background:"transparent",color:ie,border:"none",cursor:"pointer",transition:"background 120ms ease, color 120ms ease"},ke={...fe,background:"rgba(255,255,255,0.08)",color:X,fontWeight:600};return t.jsxs(t.Fragment,{children:[t.jsx("div",{"aria-hidden":"true",onClick:b?void 0:o,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",zIndex:999,animation:"publishDrawerBackdropIn 150ms ease-out"}}),t.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:24,pointerEvents:"none"},children:t.jsxs("div",{role:"dialog","aria-label":"Publish","aria-modal":"true",style:{pointerEvents:"auto",width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"80vh",overflowY:"auto",background:"#1A1D24",border:`1px solid ${G}`,borderRadius:10,padding:24,boxShadow:"0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05)",color:X,fontFamily:"var(--font-mono, monospace)",animation:"publishDrawerIn 180ms cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:4},children:[t.jsx("strong",{style:{fontSize:16,fontWeight:700,letterSpacing:"-0.01em",color:X,fontFamily:"var(--font-sans, var(--font-mono, sans-serif))"},children:"Publish skill"}),t.jsx("button",{type:"button","aria-label":"Dismiss",onClick:b?void 0:o,disabled:b,style:{background:"none",border:"none",color:ie,fontSize:22,lineHeight:1,cursor:b?"not-allowed":"pointer",padding:0,opacity:b?.4:1},children:"×"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:ie,fontVariantNumeric:"tabular-nums",marginBottom:18},children:[t.jsx("span",{"aria-hidden":"true",style:{color:"#F59E0B",fontFamily:"monospace"},children:"▮"}),t.jsxs("span",{children:[r," file",r===1?"":"s"," changed"]})]}),t.jsx("div",{style:{height:1,background:G,margin:"0 -24px 18px"}}),r>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:de,children:"Mode"}),t.jsxs("div",{role:"tablist","aria-label":"Commit message mode","data-testid":"publish-mode-toggle",style:{display:"flex",border:`1px solid ${G}`,borderRadius:6,overflow:"hidden",marginBottom:16,background:te},children:[t.jsx("button",{type:"button",role:"tab","aria-selected":f==="manual","data-testid":"publish-mode-manual",onClick:ne,disabled:b,style:f==="manual"?ke:fe,children:"Write yourself"}),t.jsx("div",{style:{width:1,background:G}}),t.jsx("button",{type:"button",role:"tab","aria-selected":f==="ai","data-testid":"publish-mode-ai",onClick:z,disabled:b,style:f==="ai"?ke:fe,children:v&&f==="ai"?"Generating…":"Generate with AI"})]})]}),t.jsx("span",{style:de,children:"Visibility"}),t.jsx(lb,{value:N,onChange:S,isFree:w,gateOpen:E,onUpgrade:()=>R(!0),onWaitlist:()=>U(nb),disabled:b,border:G,text:X,textMuted:ie,inputBg:te}),T,I&&t.jsx("p",{role:"alert",style:{marginTop:12},children:"Select a skill before publishing privately."}),N==="private"&&t.jsx(ob,{selection:p}),r>0&&t.jsxs(t.Fragment,{children:[t.jsx("label",{htmlFor:"commit-message",style:de,children:"Commit message"}),t.jsx("textarea",{id:"commit-message",value:m,onChange:B=>g(B.target.value),rows:5,disabled:v||b,placeholder:v?"Generating with AI…":f==="ai"?"Click Generate to draft a message":"Type your commit message…",style:{width:"100%",background:te,border:`1px solid ${G}`,borderRadius:6,padding:"10px 12px",fontFamily:"var(--font-mono, monospace)",fontSize:13,lineHeight:1.6,color:X,resize:"vertical",outline:"none"}}),f==="ai"&&ge&&t.jsxs("div",{"data-testid":"publish-ai-model",style:{marginTop:10,fontSize:11,color:ie,fontFamily:"var(--font-mono, monospace)"},children:["Using ",ge]}),f==="ai"&&t.jsx("button",{type:"button",onClick:ye,disabled:v||b,"data-testid":"publish-generate-button",style:{marginTop:10,padding:"8px 14px",background:v?"rgba(255,255,255,0.06)":"#2563EB",color:v?ie:"#FFFFFF",border:"1px solid "+(v?G:"#2563EB"),borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:600,cursor:v||b?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6},children:v?"Generating…":"Generate with AI"}),W&&f==="ai"&&t.jsxs("div",{role:"alert","data-testid":"publish-error-generate",style:{marginTop:10,padding:"8px 12px",border:"1px solid oklch(65% 0.14 25 / 0.35)",background:"oklch(65% 0.14 25 / 0.06)",borderRadius:4,fontSize:11,color:"oklch(70% 0.14 25)",fontFamily:"var(--font-mono, monospace)",lineHeight:1.5},children:[t.jsx("strong",{style:{fontWeight:600},children:"AI generation failed."})," ",W," ",t.jsx("button",{type:"button",onClick:ye,disabled:v,style:{background:"none",border:"none",color:"var(--color-accent)",cursor:v?"not-allowed":"pointer",fontFamily:"inherit",fontSize:"inherit",textDecoration:"underline",padding:0},children:"Retry"})]})]}),P&&t.jsxs("div",{role:"alert","data-testid":"publish-error-push",style:{marginTop:10,padding:"8px 12px",border:"1px solid oklch(65% 0.14 25 / 0.35)",background:"oklch(65% 0.14 25 / 0.06)",borderRadius:4,fontSize:11,color:"oklch(70% 0.14 25)",fontFamily:"var(--font-mono, monospace)",lineHeight:1.5},children:[t.jsx("strong",{style:{fontWeight:600},children:"Publish failed."})," ",P]}),F&&t.jsx(cb,{outcome:F,onOpenWebsite:U,border:G,textMuted:ie}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:18,gap:6},children:[t.jsx("div",{style:{minHeight:28},children:f==="ai"&&t.jsx("button",{type:"button","aria-label":"Regenerate",onClick:ye,disabled:v||b,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:v?"Generating…":"Regenerate"})}),t.jsx("div",{style:{display:"flex",gap:8},children:F?t.jsx("button",{type:"button","aria-label":"Done",onClick:o,"data-testid":"publish-done",style:{padding:"8px 16px",background:"#22C55E",color:"#0B0F12",border:"1px solid #22C55E",borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:700,cursor:"pointer"},children:"Done"}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","aria-label":"Cancel",onClick:o,disabled:b,style:{padding:"8px 14px",background:"transparent",color:X,border:`1px solid ${G}`,borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:500,cursor:b?"not-allowed":"pointer",opacity:b?.5:1},children:"Cancel"}),t.jsx("button",{type:"button","aria-label":r>0?"Commit & Push":"Push & Submit",onClick:M,disabled:!K,"data-testid":"publish-commit-push",style:{padding:"8px 16px",background:K?"#22C55E":"rgba(255,255,255,0.06)",color:K?"#0B0F12":ie,border:"1px solid "+(K?"#22C55E":G),borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:700,cursor:K?"pointer":"not-allowed"},children:b?"Publishing…":r>0?"Commit & Push":"Push & Submit"})]})})]})]})}),t.jsx("style",{children:`
|
|
33
|
+
@keyframes publishDrawerBackdropIn { from { opacity: 0 } to { opacity: 1 } }
|
|
34
|
+
@keyframes publishDrawerIn {
|
|
35
|
+
from { opacity: 0; transform: translateY(4px) }
|
|
36
|
+
to { opacity: 1; transform: translateY(0) }
|
|
37
|
+
}
|
|
38
|
+
@media (prefers-reduced-motion: reduce) {
|
|
39
|
+
[role="dialog"][aria-label="Publish"],
|
|
40
|
+
[role="dialog"][aria-label="Publish"] + * { animation: none !important }
|
|
41
|
+
}
|
|
42
|
+
`}),t.jsx(su,{open:k,onClose:()=>R(!1),onProceed:()=>S("private"),skillName:i,context:"publish"})]})}function lb({value:e,onChange:r,isFree:n,gateOpen:s,onUpgrade:o,onWaitlist:a,disabled:i,border:l,text:d,textMuted:u,inputBg:p}){const f=g=>({flex:1,minWidth:120,display:"flex",flexDirection:"column",gap:4,padding:"10px 12px",border:`1px solid ${g?"#22C55E":l}`,borderRadius:6,background:g?"rgba(34,197,94,0.08)":p,color:d,cursor:i?"not-allowed":"pointer",textAlign:"left",fontFamily:"var(--font-mono, monospace)"}),h={fontSize:12,fontWeight:600,color:d},m={fontSize:10.5,color:u,lineHeight:1.4};return t.jsxs("div",{role:"radiogroup","aria-label":"Visibility",style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:[t.jsxs("button",{type:"button",role:"radio","aria-checked":e==="public","data-testid":"publish-privacy-public",onClick:()=>!i&&r("public"),disabled:i,style:f(e==="public"),children:[t.jsx("span",{style:h,children:"Public"}),t.jsx("span",{style:m,children:"Visible to everyone on verified-skill.com."})]}),s?n?t.jsxs("button",{type:"button",role:"radio","aria-checked":e==="private","data-testid":"publish-privacy-locked",onClick:()=>!i&&o(),disabled:i,style:{...f(!1),opacity:.85},children:[t.jsx("span",{style:h,children:"🔒 Private"}),t.jsx("span",{style:{...m,color:"#F59E0B"},children:"Upgrade to publish privately"})]}):t.jsxs("button",{type:"button",role:"radio","aria-checked":e==="private","data-testid":"publish-privacy-private",onClick:()=>!i&&r("private"),disabled:i,style:f(e==="private"),children:[t.jsx("span",{style:h,children:"🔒 Private"}),t.jsx("span",{style:m,children:"Only your org can see, search, or install it."})]}):t.jsxs("div",{"aria-disabled":"true","data-testid":"publish-privacy-unavailable",style:{...f(!1),cursor:"default",opacity:.85},children:[t.jsx("span",{style:h,children:"🔒 Private"}),t.jsx("span",{style:m,children:"Hosted private publishing is not open yet."}),t.jsx("button",{type:"button","data-testid":"publish-privacy-waitlist",onClick:()=>!i&&a(),disabled:i,style:{...ra(),fontSize:10.5,alignSelf:"flex-start"},children:"Join the waitlist ↗"})]})]})}function cb({outcome:e,onOpenWebsite:r,border:n,textMuted:s}){if(!e.ok&&"notSubmitted"in e)return t.jsxs("div",{role:"status","data-testid":"publish-outcome","data-outcome":"not-submitted",style:to(n,"#F59E0B"),children:[t.jsx("strong",{style:{fontWeight:600,color:"#F59E0B"},children:"Pushed to GitHub."})," ",t.jsxs("span",{style:{color:s},children:["Nothing was submitted to verified-skill.com. ",e.notSubmitted]})]});if(!e.ok)return t.jsxs("div",{role:"status","data-testid":"publish-outcome","data-outcome":"website-fallback",style:to(n,"#F59E0B"),children:[t.jsx("strong",{style:{fontWeight:600,color:"#F59E0B"},children:"Pushed to GitHub."})," ",t.jsx("span",{style:{color:s},children:"Sign in to submit in-app, or finish on the website."})," ",t.jsx("button",{type:"button","data-testid":"publish-open-website",onClick:()=>r(e.websiteUrl),style:ra(),children:"Open on website ↗"})]});const{result:o,submitUrl:a}=e;if(e.private&&"id"in o)return t.jsx(ab,{id:o.id,initialState:o.state});let i="#22C55E",l="Submitted to the queue.",d="";switch(o.kind){case"created":i="#22C55E",l="Submitted to the queue.",d=`${o.skillName} is now ${o.state}. We’ll notify you when review completes.`;break;case"requeued":i="#22C55E",l="Re-queued for review.",d=`This skill was already submitted — it’s back in the queue (${o.state}).`;break;case"duplicate":i="#F59E0B",l="Already in the queue.",d=`This skill is already submitted (${o.state}). No new entry was created.`;break;case"alreadyVerified":i="#3B82F6",l="Already verified.",d=`${o.skillName??"This skill"} is already published — nothing to submit.`;break;case"blocked":i="#EF4444",l="Submission blocked.",d="This skill is on the blocklist and can’t be submitted. Tap to see why.";break}return t.jsxs("div",{role:"status","data-testid":"publish-outcome","data-outcome":o.kind,style:to(n,i),children:[t.jsx("strong",{style:{fontWeight:600,color:i},children:l})," ",t.jsx("span",{style:{color:s},children:d})," ",!e.private&&t.jsx("button",{type:"button","data-testid":"publish-open-website",onClick:()=>r(a),style:ra(),children:"Open on website ↗"})]})}function to(e,r){return{marginTop:10,padding:"8px 12px",border:`1px solid ${e}`,borderLeft:`3px solid ${r}`,background:"rgba(255,255,255,0.03)",borderRadius:4,fontSize:11,fontFamily:"var(--font-mono, monospace)",lineHeight:1.55}}function ra(){return{background:"none",border:"none",color:"var(--color-accent, #60A5FA)",cursor:"pointer",fontFamily:"inherit",fontSize:"inherit",textDecoration:"underline",padding:0}}function en(e,r){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}const dl="https://verified-skill.com/submit";function iu({remoteUrl:e,provider:r,model:n,skillName:s,skillPath:o,privacy:a,tenantId:i,tenantSelection:l}){const[d,u]=c.useState(!1),[p,f]=c.useState(!1),[h,m]=c.useState(0),g=c.useCallback(async()=>{if(!(d||p)){u(!0);try{let x=!1,b=0;try{const R=await ce.gitDiff();x=!!R.hasChanges,b=R.fileCount??0}catch{}if(x||a==="private"||is&&s){m(b),f(!0);return}const y=await ce.gitPublish(),j=y.remoteUrl??e,S=(y.commitSha??"").slice(0,7),k=y.branch??"";if(s){let R=null;try{R=za(j)}catch{R=null}if(R){let w;try{w=await ce.submitToQueue({repoUrl:R,skillName:s,skillPath:o,source:"studio-submit",privacy:a??"public",tenantId:is?i:void 0})}catch(E){if(!wc(E))throw E;en(`Pushed ${S} on ${k}. Not submitted to verified-skill.com: ${E.message}`,"info");return}en(db(w,s,S,k),"info")}else hn(dl),en(`Pushed ${S} on ${k} — open the website to submit`,"info")}else hn(dl),en(`Opening verified-skill.com — ${S} on ${k}`,"info")}catch(x){const b=x instanceof Error?x.message:String(x),y=b.length>200?b.slice(0,200)+"…":b;en(`Publish failed: ${y}`,"error")}finally{u(!1)}}},[d,p,e,s,o,a,i]),v=c.useCallback(()=>f(!1),[]);return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","aria-label":"Publish",onClick:g,disabled:d,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},title:"Commit, push, and submit to the review queue — in-app, no browser redirect",children:d?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Publishing…"]}):"Publish"}),p&&t.jsx(ib,{remoteUrl:e,fileCount:h,provider:r,model:n,skillName:s,skillPath:o,privacy:a,tenantId:i,tenantSelection:l,onClose:v})]})}function db(e,r,n,s){switch(e.kind){case"created":return`Submitted ${r} — ${n} on ${s}`;case"requeued":return`Re-queued ${r} for review — ${n}`;case"duplicate":return`${r} is already in the queue`;case"alreadyVerified":return`${r} is already verified`;case"blocked":return`${r} is blocked and can’t be submitted`}}const ro="studio:tenant-changed";function lu(){const[e,r]=c.useState([]),[n,s]=c.useState(),[o,a]=c.useState(is),[i,l]=c.useState(null),d=c.useCallback(async()=>{a(!0);try{const[p,f]=await Promise.all([ce.getAccountTenants(),ce.getActiveTenant().catch(()=>({currentTenant:null}))]),h=p.tenants.filter(g=>g.tenantId&&g.installationId),m=h.find(g=>g.slug===f.currentTenant)??(h.length===1?h[0]:void 0);r(h),s(m==null?void 0:m.tenantId),l(null)}catch{r([]),s(void 0),l("Could not load publishing accounts. Check your connection and retry.")}finally{a(!1)}},[]),u=c.useCallback(async p=>{const f=e.find(h=>h.tenantId===p);if(f){a(!0),l(null);try{if((await ce.setActiveTenant(f.slug)).currentTenant!==f.slug)throw new Error("Tenant selection was not saved");s(f.tenantId),window.dispatchEvent(new Event(ro))}catch{l("Could not select this publishing account. Retry before publishing.")}finally{a(!1)}}},[e]);return c.useEffect(()=>{d();const p=()=>{d()};return window.addEventListener("focus",p),window.addEventListener(ro,p),()=>{window.removeEventListener("focus",p),window.removeEventListener(ro,p)}},[d]),{tenantId:n,tenants:e,loading:o,error:i,select:u,refresh:d}}const ub={hasRemote:!1,remoteUrl:null,branch:null,loading:!0,error:null};function pb(){const[e,r]=c.useState(ub);return c.useEffect(()=>{let n=!1;return ce.gitRemote().then(s=>{n||r({hasRemote:!!s.hasRemote,remoteUrl:s.remoteUrl??null,branch:s.branch??null,loading:!1,error:null})}).catch(s=>{n||r({hasRemote:!1,remoteUrl:null,branch:null,loading:!1,error:s instanceof Error?s:new Error(String(s))})}),()=>{n=!0}},[]),e}const fb=/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function na(e){if(typeof e!="string")return null;const r=e.trim().match(fb);return r?{major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3])}:null}function on(e,r){const n=na(e);if(!n)throw new Error(`bumpVersion: not a valid semver: ${JSON.stringify(e)}`);switch(r){case"patch":return`${n.major}.${n.minor}.${n.patch+1}`;case"minor":return`${n.major}.${n.minor+1}.0`;case"major":return`${n.major+1}.0.0`}}function hb(e,r){const n=na(r);if(!n)return{valid:!1,reason:`Invalid semver: ${JSON.stringify(r)}`};if(e==null)return{valid:!0};const s=na(e);return s?s.major===n.major&&s.minor===n.minor&&s.patch===n.patch?{valid:!0}:n.major<s.major||n.major===s.major&&n.minor<s.minor||n.major===s.major&&n.minor===s.minor&&n.patch<s.patch?{valid:!1,reason:`Version cannot decrease (from ${e} → ${r}). Use the same or higher version.`}:n.major!==s.major?n.major!==s.major+1?{valid:!1,reason:`Major version can only increase by 1 at a time (got ${s.major} → ${n.major}).`}:n.minor!==0||n.patch!==0?{valid:!1,reason:`When bumping major, minor and patch must be reset to 0 (got ${r}; expected ${n.major}.0.0).`}:{valid:!0}:n.minor!==s.minor?n.minor!==s.minor+1?{valid:!1,reason:`Minor version can only increase by 1 at a time (got ${s.minor} → ${n.minor}).`}:n.patch!==0?{valid:!1,reason:`When bumping minor, patch must be reset to 0 (got ${r}; expected ${n.major}.${n.minor}.0).`}:{valid:!0}:n.patch!==s.patch+1?{valid:!1,reason:`Patch version can only increase by 1 at a time (got ${s.patch} → ${n.patch}).`}:{valid:!0}:{valid:!0}}const cu=/^(---[ \t]*\r?\n)([\s\S]*?)(\r?\n---[ \t]*(?=\r?\n|$))/;function du(e){const r=e.findIndex(u=>/^version[ \t]*:/.test(u)),n=e.findIndex(u=>/^metadata[ \t]*:[ \t]*(?:#.*)?$/.test(u));let s=n+1;for(;s<e.length&&(!e[s].trim()||/^\s|^#/.test(e[s]));)s++;const o=n<0?[]:e.slice(n+1,s),a=o.filter(u=>/^ +[^ #]/.test(u)).map(u=>u.length-u.trimStart().length),i=a.length?Math.min(...a):2,l=new RegExp(`^ {${i}}version[ \\t]*:`),d=o.findIndex(u=>l.test(u));return{root:r,metadata:n,nested:d<0?-1:n+1+d,indent:i}}function mb(e){const r=e.match(cu);if(!r)return[];const n=r[2].split(/\r?\n/),{root:s,nested:o}=du(n);return[s,o].filter(a=>a>=0).map(a=>{var d;const l=n[a].slice(n[a].indexOf(":")+1).trim().match(/^(?:"([^"]*)"|'([^']*)'|([^#]*))/);return((d=(l==null?void 0:l[1])??(l==null?void 0:l[2])??(l==null?void 0:l[3]))==null?void 0:d.trim())||void 0})}function xb(e){return mb(e).find(r=>r!==void 0)}function uu(e,r){const n=e.match(cu),s=JSON.stringify(r);if(!n)return`---
|
|
43
|
+
metadata:
|
|
44
|
+
version: ${s}
|
|
45
|
+
---
|
|
46
|
+
${e}`;const[,o,a,i]=n,l=o.includes(`\r
|
|
47
|
+
`)?`\r
|
|
48
|
+
`:`
|
|
49
|
+
`,d=a.split(/\r?\n/);if(d.some(g=>/^[ \t]*["'][^\r\n]*["'][ \t]*:/.test(g)))throw new Error("Cannot update version: quoted keys need a YAML-aware edit");const{root:u,metadata:p,nested:f,indent:h}=du(d),m=u>=0?u:f;if(m>=0){const g=d[m].slice(d[m].indexOf(":")+1).trim(),v=u>=0?0:h;if(/^[|>]/.test(g))throw new Error("Cannot update version: multiline version needs a YAML-aware edit");for(let x=m+1;x<d.length;x++)if(!(!d[x].trim()||/^[ \t]*#/.test(d[x]))){if(d[x].length-d[x].trimStart().length>v)throw new Error("Cannot update version: multiline version needs a YAML-aware edit");break}}if(u>=0)d[u]=`version: ${s}`;else if(f>=0)d[f]=`${" ".repeat(h)}version: ${s}`;else if(p>=0)d.splice(p+1,0,`${" ".repeat(h)}version: ${s}`);else{if(d.some(g=>/^metadata[ \t]*:/.test(g)))throw new Error("Cannot update version: metadata must use a block mapping");d.push("metadata:",` version: ${s}`)}return`${o}${d.join(l)}${i}${e.slice(n[0].length)}`}function ls(e){return xb(e)??null}function gb(e,r){const n=ls(r),s=ls(e);if(n!==null&&s!==null&&n===s)try{const o=on(n,"patch");return{contentToSave:uu(e,o),version:o,fromVersion:n}}catch{return{contentToSave:e,version:s,fromVersion:n}}return{contentToSave:e,version:s,fromVersion:n}}function Tr(e){return e.testType==="integration"?"integration":"unit"}function _r(e){return e>=.8?"var(--green)":e>=.5?"var(--yellow)":"var(--red)"}function pu(e){const r=new Date(e);return r.toLocaleDateString(void 0,{month:"short",day:"numeric"})+", "+r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function fu(e){return e==null?"--":e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}const vb=new Set(["benchmark","comparison","baseline"]);function ul(e,r,n,s){return e.map(({rate:o,idx:a,total:i})=>{const l=s+a/(i-1)*(r-s*2),d=s+(n-s*2)-o*(n-s*2);return`${l},${d}`})}function hu({entries:e}){const r=e.filter(f=>vb.has(f.type)).slice().reverse(),n=r.map((f,h,m)=>({rate:f.pass_rate,idx:h,total:m.length})).filter((f,h)=>{const m=r[h].type;return m==="benchmark"||m==="comparison"}),s=r.flatMap((f,h)=>f.type==="baseline"?[{rate:f.pass_rate,idx:h,total:r.length}]:f.type==="comparison"&&f.baselinePassRate!=null?[{rate:f.baselinePassRate,idx:h,total:r.length}]:[]);if(n.length<2&&s.length<2)return null;const o=80,a=24,i=2,l=n.length>=2?ul(n,o,a,i):[],d=s.length>=2?ul(s,o,a,i):[],u=l[l.length-1],p=d[d.length-1];return t.jsxs("svg",{width:o,height:a,style:{display:"block",flexShrink:0},children:[d.length>0&&t.jsx("polyline",{points:d.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),l.length>0&&t.jsx("polyline",{points:l.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),p&&t.jsx("circle",{cx:parseFloat(p.split(",")[0]),cy:parseFloat(p.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),u&&t.jsx("circle",{cx:parseFloat(u.split(",")[0]),cy:parseFloat(u.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function mu(e,r,n){const s=isNaN(r)?0:r,o=[],a=[],i=[];if((e==="PASS"||e==="EFFECTIVE")&&s>=.7){const u=o.length>0?` Met criteria: ${o.map(p=>p.criterion).join(", ")}.`:"";return{explanation:`${e} (score ${s.toFixed(2)}): evaluation met expectations.${u}`}}if(e==="FAIL"||e==="DEGRADING"){const u=a.length>0?` Failed criteria: ${a.map(f=>f.criterion).join(", ")}.`:"",p=[...a.map(f=>`Improve "${f.criterion}" (score: ${f.score.toFixed(2)})`),...i.map(f=>`Strengthen "${f.criterion}" (score: ${f.score.toFixed(2)})`)];return p.length===0&&p.push("Review prompt instructions and add more specific guidance"),{explanation:`${e} (score ${s.toFixed(2)}): evaluation did not meet expectations.${u}`,recommendations:p}}if(e==="INEFFECTIVE"){if(s<.2){const p=[...a.map(f=>`Rework "${f.criterion}" — currently at ${f.score.toFixed(2)}`),"Consider adding examples to your system prompt","Review the rubric criteria for achievability"];return{explanation:`${e} (score ${s.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:p}}const u=[...a.map(p=>`Rework "${p.criterion}" — currently at ${p.score.toFixed(2)}`),...i.map(p=>`Strengthen "${p.criterion}" (score: ${p.score.toFixed(2)})`)];return u.length===0&&u.push("Consider restructuring your prompt approach"),{explanation:`${e} (score ${s.toFixed(2)}): below expectations but showing some capability.`,recommendations:u}}if(e==="MARGINAL"){const u=[...i.map(p=>`Strengthen "${p.criterion}" (score: ${p.score.toFixed(2)})`),...a.map(p=>`Improve "${p.criterion}" (score: ${p.score.toFixed(2)})`)];return u.length===0&&u.push(o.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Review prompt instructions for areas of improvement"),{explanation:`${e} (score ${s.toFixed(2)}): moderate improvement detected.`,recommendations:u}}if(e==="EMERGING"){const u=[...a.map(p=>`Improve "${p.criterion}" (score: ${p.score.toFixed(2)})`),...i.map(p=>`Strengthen "${p.criterion}" (score: ${p.score.toFixed(2)})`)];return u.length===0&&u.push(o.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Add more specific guidance to your prompt instructions"),{explanation:`${e} (score ${s.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:u}}const l=o.length>0?` Passing: ${o.map(u=>u.criterion).join(", ")}.`:"",d=i.length>0?` Needs improvement: ${i.map(u=>u.criterion).join(", ")}.`:"";return{explanation:`${e} (score ${s.toFixed(2)}): mixed results.${l}${d}`}}const xu={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function yb(e){return Object.hasOwn(xu,e)}function bb(e){return yb(e)?xu[e]:e}function kb(){const{state:e}=vt(),{plugin:r,skill:n}=e,[s,o]=c.useState([]),[a,i]=c.useState([]),[l,d]=c.useState(!0),[u,p]=c.useState(null),[f,h]=c.useState(new Set),[m,g]=c.useState({}),[v,x]=c.useState(null),[b,y]=c.useState(""),[j,S]=c.useState(!1),[k,R]=c.useState(""),[w,E]=c.useState(""),N=c.useCallback(async()=>{d(!0),p(null);try{const[C,P]=await Promise.all([ce.getCredentials(r,n),ce.getParams(r,n)]);o(C.credentials),i(P.params)}catch(C){p(C instanceof Error?C.message:"Failed to load parameters"),o([]),i([])}finally{d(!1)}},[r,n]);c.useEffect(()=>{N()},[N]);const T=c.useCallback(async(C,P)=>{S(!0),p(null);try{await ce.setCredential(r,n,C,P),x(null),y(""),await N()}catch(L){p(L instanceof Error?L.message:`Failed to save ${C}`)}finally{S(!1)}},[r,n,N]),I=c.useCallback(async()=>{const C=k.trim().toUpperCase(),P=w.trim();if(!(!C||!P)){S(!0),p(null);try{await ce.setCredential(r,n,C,P),R(""),E(""),await N()}catch(L){p(L instanceof Error?L.message:`Failed to add ${C}`)}finally{S(!1)}}},[r,n,k,w,N]),A=c.useCallback(async C=>{if(f.has(C)){h(P=>{const L=new Set(P);return L.delete(C),L}),g(P=>{const L={...P};return delete L[C],L});return}try{const L=(await ce.getParamsRevealed(r,n,C)).params.find(F=>F.name===C);L!=null&&L.value&&(g(F=>({...F,[C]:L.value})),h(F=>new Set(F).add(C)))}catch{}},[r,n,f]),$=new Set(s.map(C=>C.name)),W=[...s.map(C=>{const P=a.find(L=>L.name===C.name);return{name:C.name,status:C.status,maskedValue:(P==null?void 0:P.maskedValue)??""}}),...a.filter(C=>!$.has(C.name)).map(C=>({name:C.name,status:C.status,maskedValue:C.maskedValue}))];return t.jsxs("div",{className:"py-2 px-3",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),u&&t.jsx("div",{className:"text-[10px] px-2 py-1.5 rounded mb-2",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},role:"alert",children:u}),l&&W.length===0&&t.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!l&&W.length===0&&!u&&t.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),W.map(C=>t.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:C.name}),t.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:C.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:C.status==="ready"?"var(--green)":"var(--red)"},children:C.status}),(C.maskedValue||C.status==="ready")&&t.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[f.has(C.name)?m[C.name]??C.maskedValue:C.maskedValue||"***",t.jsx("button",{onClick:()=>A(C.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${f.has(C.name)?"Hide":"Reveal"} value for ${C.name}`,children:f.has(C.name)?"hide":"show"})]}),v===C.name?t.jsxs("div",{className:"flex gap-1",children:[t.jsx("input",{value:b,onChange:P=>y(P.target.value),onKeyDown:P=>{P.key==="Enter"&&b.trim()&&T(C.name,b)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${C.name}`,autoFocus:!0}),t.jsx("button",{onClick:()=>T(C.name,b),disabled:j||!b.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),t.jsx("button",{onClick:()=>{x(null),y("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):t.jsx("button",{onClick:()=>{x(C.name),y("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},C.name)),t.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("input",{value:k,onChange:C=>R(C.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),t.jsx("input",{value:w,onChange:C=>E(C.target.value),onKeyDown:C=>{C.key==="Enter"&&k.trim()&&w.trim()&&I()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),t.jsx("button",{onClick:I,disabled:j||!k.trim()||!w.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:j?"not-allowed":"pointer"},children:"Add"})]})]})]})}function gu(e,r,n){const[s,o]=c.useState(null),[a,i]=c.useState(!1),l=c.useRef("");c.useEffect(()=>{const u=`${e}/${r}/${n}`;l.current!==u&&(l.current=u,i(!0),ce.getCaseHistory(e,r,n).then(p=>o(p)).catch(()=>o([])).finally(()=>i(!1)))},[e,r,n]);const d=c.useCallback(()=>{i(!0),l.current="",ce.getCaseHistory(e,r,n).then(u=>o(u)).catch(()=>o([])).finally(()=>i(!1))},[e,r,n]);return{entries:s,loading:a,refetch:d}}function jb(e,r,n){const s={flaky:!1,nonDiscriminating:!1,regression:!1};if(!n||n.length===0)return s;const a=n.slice(0,10).map(d=>d.assertions.find(u=>u.id===e)).filter(Boolean);if(a.length>=2){const u=a.filter(p=>p.pass).length/a.length;u>=.3&&u<=.7&&(s.flaky=!0)}const i=n.find(d=>d.type==="benchmark"),l=n.find(d=>d.type==="baseline");if(i&&l){const d=i.assertions.find(p=>p.id===e),u=l.assertions.find(p=>p.id===e);d!=null&&d.pass&&(u!=null&&u.pass)&&(s.nonDiscriminating=!0)}if(r&&!r.pass&&n.length>=1){const u=n[0].assertions.find(p=>p.id===e);u!=null&&u.pass&&(s.regression=!0)}return s}function vu({embedded:e=!1}={}){var V;const{state:r,dispatch:n,saveEvals:s,runCase:o,runAll:a,cancelCase:i,cancelAll:l,generateEvals:d,canEdit:u,canRun:p}=vt(),{evals:f,evalsError:h,selectedCaseId:m,inlineResults:g,caseRunStates:v,generateEvalsLoading:x,generateEvalsProgress:b,generateEvalsError:y}=r,j=c.useMemo(()=>{for(const O of v.values())if(O.status==="running"||O.status==="queued")return!0;return!1},[v]),[S,k]=c.useState(!1),[R,w]=c.useState("all"),E={skill_name:r.skill,evals:[]},N=f??E,T=N.evals,I=c.useMemo(()=>R==="all"?T:T.filter(O=>Tr(O)===R),[R,T]),A=I.find(O=>O.id===m)??null;c.useEffect(()=>{m!==null&&!I.find(O=>O.id===m)&&n({type:"SELECT_CASE",caseId:I.length>0?I[0].id:null})},[I,m,n]);const[$,W]=c.useState([]),C=c.useMemo(()=>T.some(O=>Tr(O)==="integration"),[T]);c.useEffect(()=>{C&&ce.getCredentials(r.plugin,r.skill).then(O=>W(O.credentials)).catch(()=>W([]))},[r.plugin,r.skill,C]);const P=c.useMemo(()=>new Set($.filter(O=>O.status==="missing").map(O=>O.name)),[$]),[L,F]=c.useState(!1),H=c.useCallback(O=>{F(!1),d(O?{testType:O}:void 0)},[d]);if(!f||T.length===0)return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:h?"var(--red-muted)":"var(--accent-muted)"},children:h?t.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):t.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),t.jsx("div",{className:"text-center",children:h?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),t.jsx("div",{className:"text-[11px] font-mono px-3 py-2 rounded mt-1 max-w-sm text-left break-words",style:{color:"var(--text-secondary)",background:"var(--surface-2)"},children:h}),t.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Fix the evals.json file and reload, or regenerate test cases with AI"})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),t.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),u&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>k(!0),className:"btn btn-primary text-[12px]",children:"Create Test Case"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("div",{className:"flex",children:[t.jsx("button",{onClick:()=>H("unit"),disabled:x,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:x?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),t.jsx("button",{onClick:()=>F(!L),disabled:x,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),L&&t.jsx("div",{className:"absolute right-0 mt-1 rounded-lg py-1 z-50",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",minWidth:180,boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:t.jsx("button",{onClick:()=>H("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2)"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),x&&b.length>0&&t.jsx("div",{className:"w-full max-w-md mt-3",children:t.jsx(An,{entries:b,isRunning:!0})}),y&&t.jsx("div",{className:"w-full max-w-md mt-3",children:t.jsx(Es,{error:y,onRetry:()=>H()})}),S&&t.jsx(pl,{evals:N,onSave:O=>{s(O),k(!1)},onCancel:()=>k(!1)})]});const re=!u&&!e&&f!=null&&t.jsxs("div",{role:"status","data-testid":"tests-readonly-banner",style:{padding:"10px 16px",background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:["Read-only — to author or modify tests, install this skill as source via"," ",t.jsx("code",{style:{background:"var(--surface-1)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"vskill plugin new"}),"."]});return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[re,t.jsxs("div",{className:"eval-cases-grid",children:[t.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[t.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:6,columnGap:8},children:[t.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",I.length,")"]}),t.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:!e&&(j?t.jsx("button",{onClick:l,className:"btn text-[10px] px-2 py-0.5",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:"Cancel All"}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>a("benchmark"),disabled:!p,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),u&&t.jsx("button",{onClick:()=>a("comparison"),disabled:!p,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]}))})]}),t.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(O=>t.jsx("button",{onClick:()=>w(O),style:{padding:"2px 8px",fontSize:10,fontWeight:R===O?600:400,background:R===O?"var(--accent-muted)":"transparent",color:R===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:O==="all"?`All (${T.length})`:O==="unit"?`Unit (${T.filter(se=>Tr(se)==="unit").length})`:`Integration (${T.filter(se=>Tr(se)==="integration").length})`},O))}),t.jsxs("div",{className:"py-1",children:[I.length===0&&T.length>0&&t.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",R==="all"?"":R+" ","tests yet"]}),I.map(O=>{var z;const se=g.get(O.id),ge=m===O.id,ye=Tr(O);return t.jsxs("button",{onClick:()=>n({type:"SELECT_CASE",caseId:O.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:ge?"var(--accent-muted)":"transparent",borderLeft:ge?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:ne=>{ge||(ne.currentTarget.style.background="var(--surface-2)")},onMouseLeave:ne=>{ge||(ne.currentTarget.style.background="transparent")},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5 min-w-0",children:[t.jsxs("span",{className:"text-[12px] font-medium flex items-center gap-1.5 min-w-0 flex-1",style:{color:ge?"var(--text-primary)":"var(--text-secondary)"},children:[t.jsxs("span",{className:"truncate min-w-0 flex-1",children:["#",O.id," ",O.name]}),t.jsx("span",{title:ye==="unit"?"Unit test":"Integration test","aria-label":ye==="unit"?"Unit test":"Integration test",style:{flexShrink:0,fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:ye==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:ye==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap",letterSpacing:"0.02em"},children:ye==="unit"?"U":"I"}),ye==="integration"&&((z=O.requiredCredentials)==null?void 0:z.some(ne=>P.has(ne)))&&t.jsx("span",{title:"Configure credentials to run",style:{flexShrink:0,display:"inline-flex"},children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),t.jsx(yu,{result:se})]}),t.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[O.assertions.length," assertion",O.assertions.length!==1?"s":"",(se==null?void 0:se.passRate)!=null&&t.jsx(Cb,{passRate:se.passRate})]})]},O.id)})]}),t.jsx("div",{className:"px-3 py-2",children:u&&t.jsx("button",{onClick:()=>k(!0),className:"w-full py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{border:"1px dashed var(--border-default)",color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--accent)",O.currentTarget.style.color="var(--accent)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--border-default)",O.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),t.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:t.jsx(kb,{})})]}),t.jsx("div",{className:"overflow-auto",children:A?t.jsx(wb,{evalCase:A,result:g.get(A.id),evals:f,caseStatus:((V=v.get(A.id))==null?void 0:V.status)??"idle",onSaveEvals:s,onRun:O=>o(O,"benchmark"),onCompare:O=>o(O,"comparison"),onCancel:O=>i(O),onImprove:O=>n({type:"OPEN_IMPROVE",evalId:O}),embedded:e}):t.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),S&&t.jsx(pl,{evals:N,onSave:O=>{s(O),k(!1)},onCancel:()=>k(!1)})]})]})}function wb({evalCase:e,result:r,evals:n,caseStatus:s,onSaveEvals:o,onRun:a,onCompare:i,onCancel:l,onImprove:d,embedded:u=!1}){const{state:p,canEdit:f,canRun:h}=vt(),{plugin:m,skill:g}=p,{entries:v,loading:x}=gu(m,g,e.id),[b,y]=c.useState(!1),[j,S]=c.useState(e.prompt),[k,R]=c.useState(!1),[w,E]=c.useState(e.expected_output);c.useState(()=>{S(e.prompt),E(e.expected_output)});const N=c.useCallback(V=>{o({...n,evals:n.evals.map(O=>O.id===V.id?V:O)})},[n,o]),T=c.useCallback(()=>{N({...e,prompt:j}),y(!1)},[e,j,N]),I=c.useCallback(()=>{N({...e,expected_output:w}),R(!1)},[e,w,N]),A=c.useCallback(()=>{N({...e,assertions:[...e.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[e,N]),$=c.useCallback((V,O)=>{N({...e,assertions:e.assertions.map(se=>se.id===V?{...se,text:O}:se)})},[e,N]),W=c.useCallback(V=>{N({...e,assertions:e.assertions.filter(O=>O.id!==V)})},[e,N]),C=c.useCallback(()=>{confirm("Delete this test case?")&&o({...n,evals:n.evals.filter(V=>V.id!==e.id)})},[n,e.id,o]),P=r&&r.assertions.length>0&&r.assertions.every(V=>V.pass),L=r&&r.assertions.some(V=>!V.pass),F=Tr(e),H=e.requiredCredentials??[],re=F==="integration"&&H.length>0;return t.jsxs("div",{className:"p-5 animate-fade-in",children:[t.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[t.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[t.jsxs("span",{className:"text-[16px] font-semibold",title:`#${e.id} ${e.name}`,style:{color:"var(--text-primary)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["#",e.id," ",e.name]}),f?t.jsx("button",{onClick:()=>{if((F==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:O,requirements:se,cleanup:ge,...ye}=e;N({...ye,testType:"unit"})}else N({...e,testType:"integration"})},title:`Click to switch to ${F==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:F==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:F==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:F==="unit"?"Unit":"Integration"}):t.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:F==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:F==="unit"?"var(--accent)":"var(--orange)"},children:F==="unit"?"Unit":"Integration"}),t.jsx(yu,{result:r})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[!u&&(s==="running"||s==="queued"?t.jsxs("button",{onClick:()=>l(e.id),className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>a(e.id),disabled:!h,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),f&&t.jsx("button",{onClick:()=>i(e.id),disabled:!h,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]})),L&&f&&s!=="running"&&s!=="queued"&&t.jsx("button",{onClick:()=>d(e.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),f&&s!=="running"&&s!=="queued"&&t.jsx("button",{onClick:C,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),!f&&F==="integration"&&t.jsxs("div",{"data-testid":"platform-integration-note",className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--accent-muted)",border:"1px solid var(--accent-muted)"},children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),t.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),t.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),t.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in Skill Studio"})]}),P&&t.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--green-muted)",border:"1px solid var(--green-muted)"},children:[t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[t.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),t.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),t.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),re&&t.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),t.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:H.map(V=>t.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:V},V))})]}),f&&F==="integration"&&t.jsx(Nb,{evalCase:e,onUpdate:N}),t.jsx(On,{title:"Prompt",children:b?t.jsxs("div",{children:[t.jsx("textarea",{value:j,onChange:V=>S(V.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("button",{onClick:T,className:"btn btn-primary text-[12px]",children:"Save"}),t.jsx("button",{onClick:()=>{S(e.prompt),y(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):t.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-secondary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:f?"pointer":"default"},onClick:()=>{f&&y(!0)},onMouseEnter:V=>{f&&(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:e.prompt||t.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:f?"Click to edit prompt...":"No prompt"})})}),t.jsx(On,{title:"Expected Output",children:k?t.jsxs("div",{children:[t.jsx("textarea",{value:w,onChange:V=>E(V.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("button",{onClick:I,className:"btn btn-primary text-[12px]",children:"Save"}),t.jsx("button",{onClick:()=>{E(e.expected_output),R(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):t.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:f?"pointer":"default"},onClick:()=>{f&&R(!0)},onMouseEnter:V=>{f&&(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:e.expected_output||t.jsx("span",{style:{fontStyle:"italic"},children:f?"Click to edit expected output...":"No expected output"})})}),t.jsx(On,{title:`Assertions (${e.assertions.length})`,action:f?t.jsx("button",{onClick:A,className:"btn btn-ghost text-[11px]",children:"+ Add"}):void 0,children:e.assertions.length===0?t.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):t.jsx("div",{className:"space-y-2",children:e.assertions.map(V=>{const O=r==null?void 0:r.assertions.find(ge=>ge.assertion_id===V.id),se=jb(V.id,O,v);return t.jsx(Sb,{assertion:V,result:O,badges:se,isReadOnly:!f,onUpdate:ge=>$(V.id,ge),onDelete:()=>W(V.id)},V.id)})})}),(r==null?void 0:r.output)&&t.jsx(Eb,{output:r.output,durationMs:r.durationMs,tokens:r.tokens}),r&&r.passRate!=null&&r.passRate<.2&&(()=>{const V=mu("INEFFECTIVE",r.passRate);return V.recommendations&&V.recommendations.length>0?t.jsx(On,{title:"Recommendations",children:t.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),t.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),t.jsx("ul",{className:"space-y-1.5 ml-1",children:V.recommendations.map((O,se)=>t.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),O]},se))})]})}):null})(),!u&&t.jsx(bu,{evalId:e.id,sharedEntries:v,sharedLoading:x})]},e.id)}function Sb({assertion:e,result:r,badges:n,isReadOnly:s,onUpdate:o,onDelete:a}){const[i,l]=c.useState(!1),[d,u]=c.useState(e.text),[p,f]=c.useState(!1),h=()=>{o(d),l(!1)};return t.jsx("div",{className:"rounded-lg px-3 py-2.5 transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:t.jsxs("div",{className:"flex items-start gap-2",children:[r?t.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):t.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,border:"1.5px dashed var(--text-tertiary)",background:"transparent"},title:"Not run yet"}),(n==null?void 0:n.regression)&&t.jsx("span",{className:"mt-0.5 flex-shrink-0",title:"Regression: was passing, now failing",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:18,color:"var(--red)",fontSize:14,fontWeight:700,lineHeight:1},children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:e.id}),(n==null?void 0:n.flaky)&&t.jsx("span",{title:"Flaky: 30-70% pass rate across recent runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--yellow-muted)",color:"var(--yellow)",whiteSpace:"nowrap"},children:"Flaky"}),(n==null?void 0:n.nonDiscriminating)&&t.jsx("span",{title:"Non-discriminating: passes on both skill and baseline runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--surface-3)",color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:"Non-Discrim."})]}),i?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:d,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&h(),m.key==="Escape"&&l(!1)},className:"input-field flex-1 text-[12px]",autoFocus:!0}),t.jsx("button",{onClick:h,className:"btn btn-primary text-[11px]",children:"Save"})]}):t.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:s?"default":"pointer"},onClick:()=>{s||(u(e.text),l(!0))},children:e.text}),(r==null?void 0:r.reasoning)&&t.jsx("button",{onClick:()=>f(!p),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:p?"Hide reasoning":"Show reasoning"}),p&&(r==null?void 0:r.reasoning)&&t.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:r.reasoning})]}),!s&&t.jsx("button",{onClick:a,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:m=>{m.currentTarget.style.color="var(--red)",m.currentTarget.style.opacity="1"},onMouseLeave:m=>{m.currentTarget.style.color="var(--text-tertiary)",m.currentTarget.style.opacity=""},children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function On({title:e,action:r,children:n}){return t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:e}),r]}),n]})}function yu({result:e}){const[r,n]=c.useState(!1),s={padding:"2px 8px",borderRadius:9999,flexShrink:0,minWidth:44,justifyContent:"center",position:"relative",cursor:"default"};if(!e||e.status==null)return t.jsx("span",{className:"pill text-[10px]",title:"Not run yet","aria-label":"Not run yet",style:{...s,background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const o=e.status==="pass",a=e.passRate??0,i=o?"PASS":"FAIL",l=mu(i,a),d=e.passRate!=null?`${Math.round(e.passRate*100)}%`:i;return t.jsxs("span",{className:"pill text-[10px]",style:{...s,background:o?"var(--green-muted)":"var(--red-muted)",color:o?"var(--green)":"var(--red)",fontWeight:600},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),"aria-label":`${i} ${d}`,"aria-describedby":r?"verdict-tooltip":void 0,children:[d,r&&t.jsx("div",{id:"verdict-tooltip",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,padding:"6px 10px",background:"var(--surface-4)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:11,color:"var(--text-secondary)",whiteSpace:"nowrap",zIndex:50,maxWidth:300,width:"max-content",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:l.explanation})]})}function Cb({passRate:e}){const r=Math.round(e*100);return t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("div",{className:"rounded-full overflow-hidden",style:{width:32,height:4,background:"var(--surface-4)"},children:t.jsx("div",{className:"h-full rounded-full",style:{width:`${r}%`,background:r>=80?"var(--green)":r>=50?"var(--yellow)":"var(--red)"}})})})}function Eb({output:e,durationMs:r,tokens:n}){const[s,o]=c.useState(!1);return t.jsxs("div",{className:"mb-5",children:[t.jsxs("button",{onClick:()=>o(!s),className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:s?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:t.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",r!=null&&t.jsxs("span",{style:{fontWeight:400},children:["(",(r/1e3).toFixed(1),"s)"]}),n!=null&&t.jsxs("span",{style:{fontWeight:400},children:["(",n," tokens)"]})]}),s&&t.jsx("pre",{className:"text-[12px] p-4 rounded-lg overflow-auto animate-fade-in",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:400,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}function no(e){return e==="baseline"?"right":e==="comparison"?"full":"left"}function so({entry:e}){return t.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:pu(e.timestamp)}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:e.model}),t.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:e.type==="benchmark"?"var(--accent-muted)":e.type==="comparison"?"var(--purple-muted)":"var(--orange-muted)",color:e.type==="benchmark"?"var(--accent)":e.type==="comparison"?"var(--purple)":"var(--orange)"},children:e.type}),t.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:_r(e.pass_rate)},children:[Math.round(e.pass_rate*100),"%"]})]}),t.jsxs("div",{className:"flex items-center gap-4 mb-1.5 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[e.durationMs!=null&&t.jsx("span",{children:fu(e.durationMs)}),e.tokens!=null&&t.jsxs("span",{children:[e.tokens>=1e3?`${(e.tokens/1e3).toFixed(1)}k`:e.tokens," tok"]})]}),e.type==="comparison"&&e.baselinePassRate!=null&&(()=>{const r=e.pass_rate-e.baselinePassRate,n=r>.001?"skill":r<-.001?"baseline":"tie",s=r>0?"+":"",o=n==="skill"?"var(--green)":n==="baseline"?"var(--red)":"var(--text-tertiary)";return t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:r>=0?"var(--green)":"var(--red)"},children:[s,(r*100).toFixed(1),"%"]}),t.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:o},children:n})]})})(),t.jsx("div",{className:"space-y-0.5",children:e.assertions.map(r=>t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:r.text})]},r.id))})]})}function bu({evalId:e,sharedEntries:r,sharedLoading:n}){const{state:s,dispatch:o}=vt(),{plugin:a,skill:i}=s,[l,d]=c.useState(!0),u=r??null,p=n??!1,f=c.useCallback(()=>{d(v=>!v)},[]),h=u?u.slice(0,10):[],m=h.some(v=>{const x=no(v.type);return x==="left"||x==="full"}),g=h.some(v=>{const x=no(v.type);return x==="right"||x==="full"});return t.jsxs("div",{className:"mb-5",children:[t.jsxs("button",{onClick:f,className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:l?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:t.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",u&&u.length>0&&t.jsxs("span",{style:{fontWeight:400},children:["(",u.length," run",u.length!==1?"s":"",")"]})]}),l&&t.jsx("div",{className:"animate-fade-in",children:p?t.jsxs("div",{className:"flex items-center gap-2 py-3",children:[t.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),t.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!u||u.length===0?t.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):t.jsxs("div",{children:[h.length>=2&&t.jsx("div",{className:"mb-2",children:t.jsx(hu,{entries:h})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!m&&t.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!g&&t.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),h.map((v,x)=>{const b=no(v.type);return b==="full"?t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(so,{entry:v})},x):b==="left"?t.jsxs(c.Fragment,{children:[t.jsx("div",{style:{gridColumn:"1"},children:t.jsx(so,{entry:v})}),t.jsx("div",{style:{gridColumn:"2"}})]},x):t.jsxs(c.Fragment,{children:[t.jsx("div",{style:{gridColumn:"1"}}),t.jsx("div",{style:{gridColumn:"2"},children:t.jsx(so,{entry:v})})]},x)})]}),t.jsx("button",{onClick:()=>o({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:v=>{v.currentTarget.style.textDecoration="underline"},onMouseLeave:v=>{v.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function pl({evals:e,onSave:r,onCancel:n}){const[s,o]=c.useState(""),[a,i]=c.useState(""),[l,d]=c.useState(""),[u,p]=c.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[f,h]=c.useState("unit"),[m,g]=c.useState(""),[v,x]=c.useState([]),[b,y]=c.useState(""),[j,S]=c.useState(""),k=Math.max(0,...e.evals.map(N=>N.id))+1,R=N=>{h(N),N==="unit"&&(x([]),g(""),y(""),S(""))},w=()=>{const N=m.trim().toUpperCase();N&&!v.includes(N)&&x([...v,N]),g("")},E=()=>{if(!s.trim()||!a.trim())return;const N={id:k,name:s.trim(),prompt:a.trim(),expected_output:l.trim(),files:[],assertions:u.filter(T=>T.text.trim()),...f==="integration"?{testType:"integration",...v.length>0?{requiredCredentials:v}:{},...b||j?{requirements:{...b?{platform:b}:{},...j?{chromeProfile:j}:{}}}:{}}:{}};r({...e,evals:[...e.evals,N]})};return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-overlay-in",style:{background:"rgba(0,0,0,0.6)"},children:t.jsxs("div",{className:"w-full max-w-lg rounded-xl p-6 animate-modal-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",maxHeight:"85vh",overflowY:"auto"},children:[t.jsx("div",{className:"text-[15px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"New Test Case"}),t.jsxs("div",{className:"mb-3",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1.5 block",style:{color:"var(--text-tertiary)"},children:"Type"}),t.jsx("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)",display:"inline-flex"},children:["unit","integration"].map(N=>t.jsx("button",{onClick:()=>R(N),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:f===N?N==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:f===N?N==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:N},N))})]}),t.jsxs("label",{className:"block mb-3",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),t.jsx("input",{value:s,onChange:N=>o(N.target.value),className:"input-field",placeholder:"e.g., auth-check",autoFocus:!0})]}),t.jsxs("label",{className:"block mb-3",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Prompt"}),t.jsx("textarea",{value:a,onChange:N=>i(N.target.value),className:"input-field",rows:3,placeholder:"User prompt to test..."})]}),t.jsxs("label",{className:"block mb-3",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Expected Output"}),t.jsx("textarea",{value:l,onChange:N=>d(N.target.value),className:"input-field",rows:2,placeholder:"Description of expected behavior..."})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Assertions"}),u.map((N,T)=>t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("input",{value:N.text,onChange:I=>p(u.map((A,$)=>$===T?{...A,text:I.target.value}:A)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),u.length>1&&t.jsx("button",{onClick:()=>p(u.filter((I,A)=>A!==T)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},N.id)),t.jsx("button",{onClick:()=>p([...u,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),f==="integration"&&t.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),t.jsxs("div",{className:"mb-3",children:[t.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:v.map(N=>t.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[N,t.jsx("button",{onClick:()=>x(v.filter(T=>T!==N)),style:{color:"var(--orange)",lineHeight:1},children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},N))}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("input",{value:m,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),w())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),t.jsx("button",{onClick:w,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),t.jsxs("label",{className:"block mb-3",children:[t.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),t.jsx("input",{value:b,onChange:N=>y(N.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),t.jsx("input",{value:j,onChange:N=>S(N.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:n,className:"btn btn-secondary text-[12px]",children:"Cancel"}),t.jsx("button",{onClick:E,disabled:!s.trim()||!a.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function Nb({evalCase:e,onUpdate:r}){var i,l;const[n,s]=c.useState(""),o=()=>{const d=n.trim().toUpperCase();d&&!(e.requiredCredentials??[]).includes(d)&&r({...e,requiredCredentials:[...e.requiredCredentials??[],d]}),s("")},a=d=>{const u=(e.requiredCredentials??[]).filter(p=>p!==d);r({...e,requiredCredentials:u.length>0?u:void 0})};return t.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),t.jsxs("div",{className:"mb-2.5",children:[t.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(e.requiredCredentials??[]).map(d=>t.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[d,t.jsx("button",{onClick:()=>a(d),style:{color:"var(--orange)",lineHeight:1},children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},d))}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("input",{value:n,onChange:d=>s(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),o())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),t.jsx("button",{onClick:o,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),t.jsxs("div",{className:"mb-2.5",children:[t.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),t.jsx("input",{value:((i=e.requirements)==null?void 0:i.platform)??"",onChange:d=>r({...e,requirements:{...e.requirements,platform:d.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),t.jsx("input",{value:((l=e.requirements)==null?void 0:l.chromeProfile)??"",onChange:d=>r({...e,requirements:{...e.requirements,chromeProfile:d.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function oo(e,r){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function Rb({size:e=15}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"16 18 22 12 16 6"}),t.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function Tb({size:e=15}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),t.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function Ib({size:e=15}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Lb({size:e=15}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M15 4V2"}),t.jsx("path",{d:"M15 16v-2"}),t.jsx("path",{d:"M8 9h2"}),t.jsx("path",{d:"M20 9h2"}),t.jsx("path",{d:"M17.8 11.8L19 13"}),t.jsx("path",{d:"M15 9h.01"}),t.jsx("path",{d:"M17.8 6.2L19 5"}),t.jsx("path",{d:"M11 6.2L9.7 5"}),t.jsx("path",{d:"M3 21l9-9"})]})}function ao({size:e=15}){return t.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"})})}function Ab(){var wt;const e=lu(),{state:r,dispatch:n,saveContent:s,isReadOnly:o}=vt(),{plugin:a,skill:i,skillContent:l,isDirty:d,improveTarget:u,aiEditOpen:p}=r,{state:f}=Pt(),h=((wt=f.skills.find(oe=>oe.plugin===a&&oe.skill===i))==null?void 0:wt.skillPath)??void 0,[m,g]=c.useState("split"),[v,x]=c.useState(!1),b=c.useRef(null),[y,j]=c.useState(!1),[S,k]=c.useState(""),[R,w]=c.useState(!1),[E,N]=c.useState(null),[T,I]=c.useState([]),[A,$]=c.useState([]),[W,C]=c.useState(null),P=c.useRef(null),{config:L}=kr(),F=pb(),{files:H,activeFile:re,secondaryContent:V,loading:O,error:se,loadError:ge,selectFile:ye,refresh:z,isSkillMd:ne}=Dy(a??"",i??""),[M,U]=c.useState(!1),K=c.useCallback(oe=>{M&&!window.confirm("You have unsaved changes. Discard?")||ye(oe)},[M,ye]);c.useEffect(()=>()=>{var oe;(oe=P.current)==null||oe.abort()},[]);const{metadata:X,body:ie}=Xd(l),G=X["allowed-tools"],te=Array.isArray(G)?G:typeof G=="string"?[G]:[],de=X.name,fe=X.description,ke=X.metadata,B=typeof ke=="object"&&!Array.isArray(ke)?ke:null,Y=X.version||(B==null?void 0:B.version),J=X.tags||(B==null?void 0:B.tags),ee=Array.isArray(J)?J:typeof J=="string"?J.split(",").map(oe=>oe.trim()).filter(Boolean):[],ue=new Set(["name","description","metadata","allowed-tools","version","tags"]),be=Object.entries(X).filter(([oe])=>!ue.has(oe)),Te=c.useCallback(async()=>{const{contentToSave:oe,version:$e,fromVersion:Fe}=gb(l,r.savedContent);if($e!==null){const Ye=hb(Fe,$e);if(!Ye.valid){oo(`Save blocked: ${Ye.reason??"invalid version transition"}`,"error");return}}x(!0),await s(oe),x(!1),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:content-saved",{detail:{plugin:a,skill:i,version:$e}}))},[s,l,r.savedContent,a,i]),Q=c.useCallback(oe=>{const $e=ls(l)??"1.0.0";let Fe;try{Fe=on($e,oe)}catch(tt){const Qe=tt instanceof Error?tt.message:String(tt);oo(`Bump failed: ${Qe}`,"error");return}const Ye=uu(l,Fe);n({type:"SET_CONTENT",content:Ye}),oo(`Bumped to v${Fe} (${oe}). Click Save to commit.`,"info")},[l,n]),Se=c.useCallback(oe=>{(oe.ctrlKey||oe.metaKey)&&oe.key==="s"&&(oe.preventDefault(),oe.stopPropagation(),d&&Te()),(oe.ctrlKey||oe.metaKey)&&oe.key==="i"&&(oe.preventDefault(),oe.stopPropagation(),n({type:p?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[d,Te,p,n]),he=c.useCallback(async()=>{var $e,Fe;if(!S.trim())return;($e=P.current)==null||$e.abort();const oe=new AbortController;P.current=oe,w(!0),C(null),$([]),N(null),I([]);try{const Ye=(L==null?void 0:L.provider)||"claude-cli",tt=(L==null?void 0:L.model)||"sonnet",Qe=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:S,provider:Ye,model:tt}),signal:oe.signal});if(!Qe.ok||!Qe.body){let yt=`HTTP ${Qe.status}`;try{const ut=await Qe.json();ut.error&&(yt=ut.error)}catch{}throw new Error(yt)}const zt=Qe.body.getReader(),St=new TextDecoder;let We="",Je="";for(;;){const{done:yt,value:ut}=await zt.read();if(yt)break;We+=St.decode(ut,{stream:!0});const Kt=We.split(`
|
|
50
|
+
`);We=Kt.pop()||"";for(const Bt of Kt)if(Bt.startsWith("event: "))Je=Bt.slice(7).trim();else if(Bt.startsWith("data: ")){try{const Ue=JSON.parse(Bt.slice(6));if(Je==="progress")$(bt=>[...bt,{phase:Ue.phase,message:Ue.message,timestamp:Date.now()}]);else if(Je==="done"||Je==="complete"){const bt=["---"];Ue.name&&bt.push(`name: ${Ue.name}`),Ue.description&&bt.push(`description: "${Ue.description.replace(/"/g,'\\"')}"`),Ue.model&&bt.push(`model: ${Ue.model}`),(Fe=Ue.allowedTools)!=null&&Fe.trim()&&bt.push(`allowed-tools: ${Ue.allowedTools.trim()}`),bt.push("---","",Ue.body||"");const _t=bt.join(`
|
|
51
|
+
`);N(_t),I(Cs(l,_t)),w(!1)}else Je==="error"&&(C(Ue.message||Ue.description||"Generation failed"),w(!1))}catch{}Je=""}}}catch(Ye){Ye.name!=="AbortError"&&C(Ye.message)}finally{w(!1),P.current=null}},[S,L,l]),Ce=c.useCallback(()=>{E&&n({type:"SET_CONTENT",content:E}),j(!1),N(null),I([]),k(""),$([])},[E,n]),Ae=c.useCallback(()=>{j(!1),N(null),I([]),k(""),$([]),C(null)},[]),Pe=c.useCallback(()=>{var oe;y?((oe=P.current)==null||oe.abort(),Ae()):(p&&n({type:"CLOSE_AI_EDIT"}),j(!0))},[y,p,n,Ae]),_e=[{mode:"raw",icon:t.jsx(Rb,{}),label:"Editor"},{mode:"split",icon:t.jsx(Tb,{}),label:"Split"},{mode:"preview",icon:t.jsx(Ib,{}),label:"Preview"}];return t.jsxs("div",{className:"flex flex-col",style:{height:"100%",overflow:"auto"},onKeyDown:Se,tabIndex:-1,children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[t.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:_e.map(({mode:oe,icon:$e,label:Fe})=>t.jsxs("button",{onClick:()=>g(oe),title:Fe,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:m===oe?"var(--surface-4)":"transparent",color:m===oe?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:m===oe?600:400,border:"none",cursor:"pointer"},children:[$e,t.jsx("span",{style:{letterSpacing:"0.01em"},children:Fe})]},oe))}),ne?o?t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>{p?n({type:"CLOSE_AI_EDIT"}):(y&&Ae(),n({type:"OPEN_AI_EDIT"}))},title:"Edit with AI (Ctrl+K)",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:p?600:400,border:"none",cursor:"pointer",color:p?"var(--purple)":"var(--text-tertiary)",background:p?"var(--purple-muted)":"transparent"},children:[t.jsx(Lb,{size:13}),t.jsx("span",{children:"AI Edit"})]}),t.jsxs("button",{onClick:Pe,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:y?600:400,border:"none",cursor:"pointer",color:y?"var(--purple)":"var(--text-tertiary)",background:y?"var(--purple-muted)":"transparent"},children:[t.jsx(ao,{size:13}),t.jsx("span",{children:"Regenerate"})]}),t.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),!o&&(()=>{const oe=ls(l)??"1.0.0";let $e=oe,Fe=oe,Ye=oe;try{$e=on(oe,"patch"),Fe=on(oe,"minor"),Ye=on(oe,"major")}catch{}const tt={padding:"4px 8px"};return t.jsxs("div",{style:{display:"inline-flex",gap:2,alignItems:"center"},"aria-label":"Version bump","data-testid":"version-bump-controls",children:[t.jsx("button",{type:"button",onClick:()=>Q("patch"),title:`Bump patch: ${oe} → ${$e}`,"aria-label":"Bump patch version",className:"btn btn-ghost text-[11px]",style:tt,children:"+patch"}),t.jsx("button",{type:"button",onClick:()=>Q("minor"),title:`Bump minor: ${oe} → ${Fe}`,"aria-label":"Bump minor version",className:"btn btn-ghost text-[11px]",style:tt,children:"+minor"}),t.jsx("button",{type:"button",onClick:()=>Q("major"),title:`Bump major: ${oe} → ${Ye}`,"aria-label":"Bump major version",className:"btn btn-ghost text-[11px]",style:tt,children:"+major"})]})})(),d&&t.jsx("button",{onClick:()=>n({type:"SET_CONTENT",content:r.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),t.jsx("button",{onClick:Te,disabled:!d||v,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:v?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"}),F.hasRemote&&F.remoteUrl&&t.jsx(iu,{remoteUrl:F.remoteUrl,provider:L==null?void 0:L.provider,model:L==null?void 0:L.model,skillName:i||void 0,skillPath:h,privacy:"public",tenantId:e.tenantId,tenantSelection:e})]}):null]}),a&&i&&t.jsx(Wy,{files:H,activeFile:re,onSelect:K,onRefresh:z,loadError:ge}),!ne&&t.jsx(Vy,{file:V,loading:O,error:se,viewMode:m,plugin:a??void 0,skill:i??void 0,onSaved:()=>{ye(re),z()},onDirtyChange:U}),ne&&t.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:m==="raw"||m==="preview"?"1fr":"1fr 1fr",minHeight:"60vh"},children:[m!=="preview"&&t.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:m==="split"?"1px solid var(--border-subtle)":"none"},children:t.jsx("textarea",{ref:b,"data-testid":"skill-editor-textarea",value:l,onChange:oe=>{!o&&!v&&!r.loading&&n({type:"SET_CONTENT",content:oe.target.value})},onKeyDown:Se,spellCheck:!1,readOnly:o||v||r.loading,className:"flex-1 w-full resize-none outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",fontSize:12.5,lineHeight:1.7,tabSize:2,border:"none",padding:"16px 20px",opacity:o?.7:1}})}),m!=="raw"&&t.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:t.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(de||Y||fe)&&t.jsxs("div",{style:{marginBottom:20},children:[t.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[de&&t.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:de}),Y&&t.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4,letterSpacing:"0.03em",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:["v",Y]})]}),fe&&t.jsx("p",{style:{fontSize:12.5,lineHeight:1.65,color:"var(--text-secondary)",margin:0,paddingLeft:12,borderLeft:"2px solid var(--accent)",maxWidth:600},children:fe})]}),ee.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:ee.map(oe=>t.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-tertiary)",background:"var(--surface-2)",padding:"3px 8px",borderRadius:4,letterSpacing:"0.02em"},children:oe},oe))}),te.length>0&&t.jsx("div",{style:{marginBottom:16},children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),te.map(oe=>t.jsx("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono, ui-monospace, monospace)",color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4},children:oe},oe))]})}),be.length>0&&t.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:be.map(([oe,$e],Fe)=>{const Ye=Array.isArray($e)?$e.join(", "):typeof $e=="object"?Object.entries($e).map(([tt,Qe])=>`${tt}: ${Array.isArray(Qe)?Qe.join(", "):Qe}`).join(" | "):$e;return t.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Fe>0?"1px solid var(--border-subtle)":"none"},children:[t.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:oe}),t.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Ye})]},oe)})}),(de||fe||ee.length>0||te.length>0||be.length>0)&&ie&&t.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ie&&t.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Ln(ie)}})]})})]}),ne&&p&&t.jsx(Fy,{}),ne&&y&&t.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:t.jsxs("div",{className:"px-4 py-3",children:[!E&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(ao,{size:14}),t.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),t.jsx("div",{className:"flex gap-2 mb-2",children:t.jsx("textarea",{value:S,onChange:oe=>k(oe.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:R,className:"flex-1 px-3 py-2 rounded-lg text-[12px] resize-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",outline:"none",opacity:R?.5:1},onKeyDown:oe=>{oe.key==="Enter"&&(oe.ctrlKey||oe.metaKey)&&S.trim()&&!R&&(oe.preventDefault(),he())}})}),t.jsxs("div",{className:"flex items-center gap-2",children:[R?t.jsx("button",{onClick:()=>{var oe;(oe=P.current)==null||oe.abort(),w(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):t.jsx("button",{onClick:he,disabled:!S.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),t.jsx("button",{onClick:Ae,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),R&&A.length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(An,{entries:A,isRunning:!0})}),W&&t.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[W,t.jsx("button",{onClick:he,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),E&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(ao,{size:14}),t.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),t.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:T.map((oe,$e)=>t.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:oe.type==="added"?"var(--green-muted)":oe.type==="removed"?"var(--red-muted)":"transparent",color:oe.type==="added"?"var(--green)":oe.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:oe.type==="added"?"3px solid var(--green)":oe.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[t.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:oe.type==="added"?"+":oe.type==="removed"?"-":" "}),oe.content]},$e))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:Ce,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),t.jsx("button",{onClick:Ae,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),ne&&u!==null&&a&&i&&t.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:t.jsx(Ty,{plugin:a,skill:i,skillContent:l,onApplied:oe=>{n({type:"SET_CONTENT",content:oe}),n({type:"CONTENT_SAVED"}),n({type:"CLOSE_IMPROVE"})}})}),ne&&t.jsx(Pb,{})]})}function Pb(){var d;const[e,r]=c.useState(()=>{var u;return typeof window>"u"?!1:((u=window.localStorage)==null?void 0:u.getItem("vskill:editor-eval-cases-open"))==="1"}),{state:n,canEdit:s}=vt(),o=((d=n.evals)==null?void 0:d.evals)??[],a=u=>{var f;const p=u.currentTarget.open;if(r(p),typeof window<"u")try{(f=window.localStorage)==null||f.setItem("vskill:editor-eval-cases-open",p?"1":"0")}catch{}},i=c.useCallback(u=>{var h;if((h=u.preventDefault)==null||h.call(u),typeof window>"u")return;const p=new URLSearchParams(window.location.search);p.set("tab","run"),p.set("mode","benchmark"),p.set("autorun","1");const f=`${window.location.pathname}?${p.toString()}${window.location.hash}`;window.history.replaceState(null,"",f),window.dispatchEvent(new PopStateEvent("popstate"))},[]),l=s&&o.length>0;return t.jsxs("details",{"data-testid":"editor-eval-cases-section",open:e,onToggle:a,style:{borderTop:"1px solid var(--border-subtle)",background:"var(--bg-canvas)"},children:[t.jsxs("summary",{style:{padding:"10px 16px",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--text-primary)",cursor:"pointer",userSelect:"none",background:"var(--surface-1)",borderBottom:e?"1px solid var(--border-subtle)":"none",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[t.jsx("span",{children:"Eval cases"}),l&&t.jsx("button",{type:"button","data-testid":"editor-eval-cases-run-all",onClick:i,title:"Run all → opens Run tab",className:"btn btn-primary text-[11px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run all"})]}),e&&t.jsx("div",{"data-testid":"editor-eval-cases-body",style:{height:520,overflow:"hidden"},children:t.jsx(vu,{embedded:!0})})]})}function $b(e){if(e==null||!Number.isFinite(e))return"—";if(e<1024)return`${e} B`;const r=e/1024;if(r<1024)return r>=10?`${Math.round(r)} KB`:`${r.toFixed(1).replace(/\.0$/,"")} KB`;const n=r/1024;return n>=10?`${Math.round(n)} MB`:`${n.toFixed(1).replace(/\.0$/,"")} MB`}const Mb={vskill:{label:"vskill",bg:"var(--accent-muted, #e0f2fe)",fg:"var(--accent, #0369a1)",border:"var(--accent, #0369a1)"},anthropic:{label:"Anthropic",bg:"var(--orange-muted, #fff1e0)",fg:"var(--orange, #c2410c)",border:"var(--orange, #c2410c)"},local:{label:"Local",bg:"var(--surface-3, #e5e5e5)",fg:"var(--text-tertiary, #666)",border:"var(--border-default, #ccc)"}};function sa({provider:e,size:r="sm"}){if(!e)return null;const n=Mb[e],s=r==="md"?11:9;return t.jsx("span",{"data-testid":`provider-chip-${e}`,"data-provider":e,style:{display:"inline-flex",alignItems:"center",padding:r==="md"?"2px 8px":"1.5px 6px",fontSize:s,fontWeight:500,fontFamily:"var(--font-sans)",background:n.bg,color:n.fg,border:`1px solid ${n.border}`,borderRadius:999,lineHeight:1.4,whiteSpace:"nowrap"},children:n.label})}function Fb({content:e,defaultExpanded:r=!0}){const[n,s]=c.useState(r),{metadata:o,body:a}=Xd(e);if(!e.trim())return null;const i=Object.keys(o).length>0,l=o["allowed-tools"],d=Array.isArray(l)?l:typeof l=="string"?[l]:[],u=Object.entries(o).filter(([p])=>p!=="allowed-tools");return t.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[t.jsxs("button",{onClick:()=>s(!n),className:"w-full flex items-center justify-between px-5 py-3.5 text-left transition-colors duration-150",style:{background:"var(--surface-2)"},onMouseEnter:p=>{p.currentTarget.style.background="var(--surface-3)"},onMouseLeave:p=>{p.currentTarget.style.background="var(--surface-2)"},children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{children:[t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),t.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",style:{transform:n?"rotate(180deg)":"rotate(0)",transition:"transform 0.2s ease"},children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),n&&t.jsxs("div",{className:"px-5 py-4 animate-fade-in",children:[i&&t.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:u.map(([p,f])=>{const h=Array.isArray(f)?f.join(", "):typeof f=="object"?Object.entries(f).map(([m,g])=>`${m}: ${Array.isArray(g)?g.join(", "):g}`).join(" | "):f;return t.jsxs("div",{className:"px-3 py-2.5 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--text-tertiary)"},children:p}),t.jsx("div",{className:"text-[12px]",style:{color:"var(--text-primary)"},children:h})]},p)})}),d.length>0&&t.jsxs("div",{className:"mb-4",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.map(p=>t.jsx("span",{className:"px-2 py-1 rounded-md text-[11px] font-mono",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:p},p))})]}),a&&t.jsx("div",{className:"text-[12px] leading-relaxed p-4 rounded-lg overflow-x-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Ln(a)}})]})]})}function Db(e){const r={name:"",path:"",type:"dir",size:0,children:[]};for(const s of e){if(s.type!=="file")continue;const o=s.path.split("/");let a=r;for(let i=0;i<o.length;i++){const l=o[i],d=i===o.length-1;let u=a.children.find(p=>p.name===l);u||(u={name:l,path:o.slice(0,i+1).join("/"),type:d?"file":"dir",size:d?s.size:0,children:[]},a.children.push(u)),a=u}}const n=s=>{s.children.sort((o,a)=>o.type!==a.type?o.type==="dir"?-1:1:o.name.localeCompare(a.name)),s.children.forEach(n)};return n(r),r}function zb(e){const r=e.lastIndexOf(".");return r>=0?e.slice(r+1).toLowerCase():""}function Bb(e){const r=zb(e);return e==="SKILL.md"?"📘":r==="md"?"📄":r==="ts"||r==="tsx"||r==="js"||r==="jsx"?"📜":r==="json"||r==="yaml"||r==="yml"||r==="toml"?"🔧":r==="sh"||r==="bash"?"🖥":r==="png"||r==="jpg"||r==="jpeg"||r==="gif"||r==="webp"||r==="svg"?"🖼":"📄"}function ku({node:e,depth:r,activePath:n,focusedPath:s,onSelect:o,expanded:a,onToggle:i}){if(e.type==="dir"){const u=a.has(e.path),p=e.path===s;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","data-testid":"source-tree-item","data-path":e.path,"data-type":"dir","data-focused":p?"true":"false",role:"treeitem","aria-expanded":u,onClick:()=>i(e.path),style:{width:"100%",textAlign:"left",background:p?"var(--surface-2)":"transparent",border:"none",padding:`4px 8px 4px ${r*12+8}px`,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,display:"inline-block"},children:u?"▾":"▸"}),t.jsx("span",{children:"📁"}),t.jsx("span",{children:e.name})]}),u&&t.jsx("div",{role:"group",children:e.children.map(f=>t.jsx(ku,{node:f,depth:r+1,activePath:n,focusedPath:s,onSelect:o,expanded:a,onToggle:i},f.path))})]})}const l=e.path===n,d=e.path===s;return t.jsxs("button",{type:"button","data-testid":"source-tree-item","data-path":e.path,"data-type":"file","data-active":l?"true":"false","data-focused":d?"true":"false",role:"treeitem","aria-selected":l,onClick:()=>o(e.path),style:{width:"100%",textAlign:"left",background:l?"var(--surface-3)":d?"var(--surface-2)":"transparent",border:"none",padding:`4px 8px 4px ${r*12+8}px`,color:l?"var(--text-primary)":"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,fontWeight:l?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,display:"inline-block"},children:" "}),t.jsx("span",{children:Bb(e.name)}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:e.name})]})}function _b({files:e,activePath:r,onSelect:n}){const s=c.useMemo(()=>Db(e),[e]),o=c.useMemo(()=>{const m=new Set;if(r&&r.includes("/")){const g=r.split("/");for(let v=1;v<g.length;v++)m.add(g.slice(0,v).join("/"))}return s.children.forEach(g=>{g.type==="dir"&&m.add(g.path)}),m},[s,r]),[a,i]=c.useState(o);c.useEffect(()=>{i(m=>{const g=new Set(m);let v=!1;return o.forEach(x=>{g.has(x)||(g.add(x),v=!0)}),v?g:m})},[o]);const l=m=>{i(g=>{const v=new Set(g);return v.has(m)?v.delete(m):v.add(m),v})},d=c.useMemo(()=>{const m=[],g=v=>{for(const x of v)m.push({path:x.path,type:x.type}),x.type==="dir"&&a.has(x.path)&&g(x.children)};return g(s.children),m},[s,a]),u=c.useRef(null),[p,f]=c.useState(()=>Math.max(0,d.findIndex(m=>m.path===r)));c.useEffect(()=>{const m=d.findIndex(g=>g.path===r);m>=0&&f(m)},[r,d]);const h=m=>{var g;if(d.length!==0)if(m.key==="ArrowDown")m.preventDefault(),f(v=>Math.min(d.length-1,v+1));else if(m.key==="ArrowUp")m.preventDefault(),f(v=>Math.max(0,v-1));else if(m.key==="Enter"){m.preventDefault();const v=d[p];if(!v)return;v.type==="dir"?l(v.path):n(v.path)}else m.key==="Escape"&&(m.preventDefault(),(g=u.current)==null||g.blur())};return s.children.length===0?t.jsx("div",{"data-testid":"source-tree-empty",style:{padding:16,fontSize:12,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)"},children:"No files found."}):t.jsx("div",{"data-testid":"source-file-tree",ref:u,tabIndex:0,onKeyDown:h,role:"tree","aria-label":"Skill files",style:{paddingTop:4,paddingBottom:4,outline:"none"},children:s.children.map(m=>{var g;return t.jsx(ku,{node:m,depth:0,activePath:r,focusedPath:(g=d[p])==null?void 0:g.path,onSelect:n,expanded:a,onToggle:l},m.path)})})}const Ob=new Set(["md","txt","json","yaml","yml","toml","ini","env","ts","tsx","js","jsx","mjs","cjs","py","rb","go","rs","java","c","cc","cpp","h","hpp","sh","bash","zsh","fish","html","css","scss","less","xml","csv","tsv","log","diff","patch","lock","gitignore","dockerfile"]),Wb=new Set(["png","jpg","jpeg","gif","webp","ico"]);function Ub(e){const r=e.lastIndexOf(".");return r>=0?e.slice(r+1).toLowerCase():""}function Hb(e){const r=Ub(e);return r==="md"?"markdown":Wb.has(r)?"image":Ob.has(r)?"text":"binary"}function Vb({content:e}){return t.jsx("div",{"data-testid":"source-md-viewer",children:t.jsx(Fb,{content:e})})}function Gb({content:e,path:r}){const n=e.split(`
|
|
52
|
+
`),s=n.length>5e3,o=s?n.slice(0,5e3).join(`
|
|
53
|
+
`):e;return t.jsxs("div",{"data-testid":"source-text-viewer",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:"70vh"},children:[t.jsxs("div",{style:{padding:"8px 12px",background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-tertiary)"},children:[r," · ",n.length," ",n.length===1?"line":"lines",s&&" (truncated for display)"]}),t.jsx("pre",{style:{margin:0,padding:12,fontFamily:"var(--font-mono, monospace)",fontSize:12,lineHeight:1.5,color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:o})]})}function Kb({plugin:e,skill:r,path:n}){const s=`/api/skills/${e}/${r}/file?path=${encodeURIComponent(n)}&raw=1`;return t.jsxs("div",{"data-testid":"source-image-viewer",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:16,display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[t.jsx("img",{src:s,alt:n,style:{maxWidth:"100%",maxHeight:"60vh",objectFit:"contain"}}),t.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)"},children:n})]})}function qb({path:e,size:r}){return t.jsxs("div",{"data-testid":"source-binary-placeholder",style:{background:"var(--surface-1)",border:"1px dashed var(--border-default)",borderRadius:8,padding:24,textAlign:"center",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:13},children:[t.jsxs("div",{style:{fontSize:14,fontWeight:500,marginBottom:6},children:["Binary file — ",$b(r)]}),t.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)"},children:e})]})}function Yb({plugin:e,skill:r,provider:n}){const[s,o]=c.useState([]),[a,i]=c.useState("SKILL.md"),[l,d]=c.useState(null),[u,p]=c.useState(!0),[f,h]=c.useState(null),[m,g]=c.useState(null),v=n??m;c.useEffect(()=>{if(n!==void 0)return;let b=!1;return ce.getSkillVersionsEnvelope(e,r).then(y=>{b||g(y.provider??null)}).catch(()=>{}),()=>{b=!0}},[e,r,n]),c.useEffect(()=>{let b=!1;return p(!0),h(null),ce.getSkillFiles(e,r).then(y=>{var k;if(b)return;o(y.files);const S=y.files.some(R=>R.path==="SKILL.md")?"SKILL.md":((k=y.files.find(R=>R.type==="file"))==null?void 0:k.path)??"";i(S),S||p(!1)}).catch(y=>{b||(h(y instanceof Error?y.message:String(y)),p(!1))}),()=>{b=!0}},[e,r]),c.useEffect(()=>{if(!a)return;let b=!1;return p(!0),h(null),ce.getSkillFile(e,r,a).then(y=>{b||(d(y),p(!1))}).catch(y=>{b||(h(y instanceof Error?y.message:String(y)),p(!1))}),()=>{b=!0}},[e,r,a]);const x=()=>{if(f)return t.jsxs("div",{"data-testid":"source-error",style:{padding:16,color:"var(--danger, #c00)",fontFamily:"var(--font-sans)",fontSize:13},children:["Failed to load: ",f]});if(u||!l)return t.jsx("div",{"data-testid":"source-loading",style:{padding:16,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)",fontSize:13},children:"Loading…"});const b=Hb(a);return b==="markdown"?t.jsx(Vb,{content:l.content??""}):b==="text"&&!l.binary?t.jsx(Gb,{content:l.content??"",path:a}):b==="image"?t.jsx(Kb,{plugin:e,skill:r,path:a}):t.jsx(qb,{path:a,size:l.size})};return t.jsxs("div",{"data-testid":"source-panel",style:{display:"flex",flexDirection:"column",height:"100%",minHeight:400,gap:12},children:[v&&t.jsxs("div",{"data-testid":"source-panel-header",style:{display:"flex",alignItems:"center",gap:8,paddingLeft:4},children:[t.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-sans)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Provider:"}),t.jsx(sa,{provider:v})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"260px 1fr",gap:16,flex:1,minHeight:0},children:[t.jsx("aside",{style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:"75vh"},children:t.jsx(_b,{files:s,activePath:a,onSelect:i})}),t.jsx("main",{style:{minWidth:0},children:x()})]})]})}function Tt(e,r){return r==="free"?"Free":r==="subscription"&&e==null?"Included":e==null?"N/A":e>=1?`$${e.toFixed(2)}`:e===0?"$0.00":e>=.001?`$${e.toFixed(4)}`:`$${e.toPrecision(3).replace(/0+$/,"").replace(/\.$/,"")}`}function ju(e,r){return e==null||r==null?"N/A":`${e.toLocaleString("en-US")} in / ${r.toLocaleString("en-US")} out`}function Jb({evalId:e}){const{state:r}=vt(),{entries:n,loading:s}=gu(r.plugin,r.skill,e),o=!!n&&n.length>0;return!s&&!o?null:t.jsx("div",{"data-testid":`run-case-history-${e}`,className:"mt-2 ml-3 pl-3",style:{borderLeft:"1px solid var(--border-subtle)"},children:t.jsx(bu,{evalId:e,sharedEntries:n,sharedLoading:s})})}function Qb(e){return e==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function Xb(e,r){let n="";if(r){const o=new Date(r);isNaN(o.getTime())||(n=o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}))}return[e,n].filter(Boolean).join(" · ")}function Zb(e,r,n){const s=n===1?"test case":"test cases";if(e===0)return`Your skill performs the same as the baseline across ${n} ${s}`;const o=Math.round(Math.abs(e)*r);if(o===0)return`Your skill performs the same as the baseline across ${n} ${s}`;const a=e>0?"more":"fewer";return`Your skill passes ${o} ${a} assertions across ${n} ${s}`}function fl(e,r){const n=s=>{const o=s/5*100;return isFinite(o)?Math.round(Math.min(100,Math.max(0,o))):0};return{skill:n(e),baseline:n(r)}}function e1(e){return e==="skill"?{text:"Skill wins",isSkill:!0}:e==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function t1(e,r){const n=e+r,s=n*10,o=n*25,a=i=>i>=60?`${Math.round(i/60)}m`:`${i}s`;return`${a(s)}–${a(o)}`}const r1={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function n1(e,r){if(!e)return null;const n=r1[e];if(n==null||n===0)return null;const s=n*r*.5,o=n*r*2;return`${Tt(s)}–${Tt(o)}`}function s1(){const{state:e,runCase:r,runAll:n,cancelCase:s,cancelAll:o,canEdit:a,canRun:i}=vt(),{evals:l,caseRunStates:d,bulkRunActive:u,latestBenchmark:p,inlineResults:f}=e,{config:h}=kr(),m=(l==null?void 0:l.evals)??[],g=c.useMemo(()=>{for(const E of d.values())if(E.status==="running"||E.status==="queued")return!0;return!1},[d]),v=m.filter(E=>{const N=d.get(E.id);return N&&(N.status==="complete"||N.status==="error"||N.status==="cancelled")}).length,x=m.filter(E=>{const N=d.get(E.id);return N&&(N.status==="running"||N.status==="queued")}).length,b=c.useRef(null),[y,j]=c.useState(0);c.useEffect(()=>{if(g&&!b.current&&(b.current=Date.now()),!g){b.current=null,j(0);return}const E=setInterval(()=>{b.current&&j(Math.round((Date.now()-b.current)/1e3))},1e3);return()=>clearInterval(E)},[g]);const S=m.reduce((E,N)=>E+N.assertions.length,0),k=m.length+S,R=c.useMemo(()=>t1(m.length,S),[m.length,S]),w=c.useMemo(()=>n1((h==null?void 0:h.provider)??null,k),[h==null?void 0:h.provider,k]);return t.jsxs("div",{className:"p-5",children:[!a&&l!=null&&t.jsxs("div",{role:"status","data-testid":"tests-readonly-banner",className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-4 text-[11px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsxs("span",{children:["Read-only — to author or modify tests, install this skill as source via"," ",t.jsx("code",{style:{background:"var(--surface-1)",padding:"1px 5px",borderRadius:3,fontFamily:"var(--font-mono)"},children:"vskill plugin new"}),"."]})]}),t.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),g&&t.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[x," running"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[g&&t.jsxs("button",{onClick:o,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),a&&t.jsx("button",{onClick:()=>n("comparison"),disabled:!i||g,className:"btn btn-primary text-[12px]",title:"Runs both your skill and the baseline, then compares results side by side",children:"Run A/B Test"}),t.jsx("button",{onClick:()=>n("benchmark"),disabled:!i||g,className:a?"btn btn-secondary text-[12px]":"btn btn-primary text-[12px]",title:a?"Runs benchmark using your skill only":"Run all author-shipped eval cases",children:a?"Test Skill":"Run All"}),a&&t.jsx("button",{onClick:()=>n("baseline"),disabled:!i||g,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!g&&m.length>0&&t.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.jsxs("span",{children:["Est. duration: ",R]}),w&&t.jsxs("span",{children:["Est. cost: ",w]}),!w&&(h==null?void 0:h.provider)&&(h.provider==="claude-cli"||h.provider==="codex-cli")&&t.jsx("span",{children:"Cost: Included"}),!w&&(h==null?void 0:h.provider)&&(h.provider==="ollama"||h.provider==="lm-studio"||h.provider==="gemini-cli")&&t.jsx("span",{children:"Cost: Free"})]})]}),g&&m.length>0&&t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",v,"/",m.length," cases"]}),t.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(v/m.length*100),"%"]})]}),t.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:t.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${v/m.length*100}%`,background:"var(--accent)"}})}),t.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[t.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",y>=60?`${Math.floor(y/60)}m ${y%60}s`:`${y}s`]}),t.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",R]})]})]}),t.jsx("div",{className:"space-y-3 stagger-children",children:m.map(E=>{const N=f.get(E.id),T=d.get(E.id),I=(T==null?void 0:T.status)??"idle",A=p==null?void 0:p.cases.find($=>$.eval_id===E.id);return t.jsxs(c.Fragment,{children:[t.jsx(a1,{name:E.name,evalId:E.id,result:N,caseCost:A==null?void 0:A.cost,caseBillingMode:A==null?void 0:A.billingMode,caseInputTokens:A==null?void 0:A.inputTokens,caseOutputTokens:A==null?void 0:A.outputTokens,caseStatus:I,runMode:(T==null?void 0:T.mode)??null,comparisonDetail:A==null?void 0:A.comparisonDetail,canEdit:a,onRun:$=>r($,"benchmark"),onBaseline:$=>r($,"baseline"),onCompare:$=>r($,"comparison"),onCancel:$=>s($)}),t.jsx(Jb,{evalId:E.id})]},E.id)})}),!g&&p&&p.cases.length>0&&t.jsxs("div",{className:"mt-5",children:[t.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:Qb(p.type)}),t.jsx("span",{className:"text-[20px] font-bold",style:{color:(p.overall_pass_rate??0)>=.8?"var(--green)":(p.overall_pass_rate??0)>=.5?"var(--yellow)":"var(--red)"},children:p.overall_pass_rate!=null?`${Math.round(p.overall_pass_rate*100)}%`:"--"})]}),p.totalDurationMs!=null&&t.jsxs("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:["Total: ",(p.totalDurationMs/1e3).toFixed(1),"s",p.model&&` | Model: ${p.model}`,p.totalInputTokens!=null&&p.totalOutputTokens!=null&&` | Tokens: ${ju(p.totalInputTokens,p.totalOutputTokens)}`,p.totalCost!=null&&` | Cost: ${Tt(p.totalCost)}`]}),a&&p.overall_pass_rate>=.9999&&!p.comparison&&t.jsx("button",{onClick:()=>n("comparison"),disabled:!i,className:"text-[13px] font-semibold mt-3 w-full rounded-lg transition-opacity duration-150",style:{padding:"10px 0",background:"var(--green)",color:"var(--color-paper)",border:"none",cursor:"pointer",opacity:m.length===0?.5:1},children:"Run Final A/B Comparison"})]}),p.comparison&&t.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const E=Xb(p.model,p.timestamp);return E?t.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:E}):t.jsx("div",{className:"mb-3"})})(),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsx(hl,{label:"Skill",value:p.comparison.skillPassRate,color:"var(--accent)"}),t.jsx(hl,{label:"Baseline",value:p.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),t.jsxs("div",{className:"mt-3 text-[12px] font-medium",style:{color:p.comparison.delta>0?"var(--green)":p.comparison.delta<0?"var(--red)":"var(--text-tertiary)"},children:["Delta: ",p.comparison.delta>0?"+":"",(p.comparison.delta*100).toFixed(1),"%",p.verdict&&` | ${bb(p.verdict)}`]}),(()=>{const E=p.cases.reduce((T,I)=>T+I.assertions.length,0),N=Zb(p.comparison.delta,E,p.cases.length);return t.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:N})})()]})]})]})}const o1={benchmark:{label:"Skill",bg:"var(--accent-muted)",color:"var(--accent)"},baseline:{label:"Baseline",bg:"var(--surface-3)",color:"var(--text-tertiary)"},comparison:{label:"Compare",bg:"var(--purple-muted)",color:"var(--purple)"}};function a1({name:e,evalId:r,result:n,caseCost:s,caseBillingMode:o,caseInputTokens:a,caseOutputTokens:i,caseStatus:l,runMode:d,comparisonDetail:u,canEdit:p=!1,onRun:f,onBaseline:h,onCompare:m,onCancel:g}){const[v,x]=c.useState(!1),b=l==="running"||l==="queued",y=l==="complete"||l==="error";return t.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:b?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:b?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[l==="running"&&t.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),l==="queued"&&t.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),t.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",r," ",e]}),d&&(b||y)&&(()=>{const j=o1[d];return j?t.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:j.bg,color:j.color,padding:"1px 6px"},children:j.label}):null})()]}),t.jsxs("div",{className:"flex items-center gap-2",children:[b?t.jsx("button",{onClick:()=>g(r),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):t.jsxs(t.Fragment,{children:[p&&t.jsx("button",{onClick:()=>m(r),className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),t.jsx("button",{onClick:()=>f(r),className:p?"btn btn-secondary text-[10px] px-2 py-1":"btn btn-primary text-[10px] px-2 py-1",children:p?"Skill":"Run"}),p&&t.jsx("button",{onClick:()=>h(r),className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),n&&n.status!=null&&t.jsx("span",{className:"pill text-[10px]",style:{background:n.status==="pass"?"var(--green-muted)":"var(--red-muted)",color:n.status==="pass"?"var(--green)":"var(--red)"},children:n.passRate!=null?`${Math.round(n.passRate*100)}%`:n.status}),a!=null&&i!=null&&t.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:ju(a,i)}),s!=null&&t.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Tt(s,o)}),l==="cancelled"&&t.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),n&&n.assertions.length>0&&t.jsxs("div",{className:"px-4 pb-3",children:[t.jsx("div",{className:"space-y-1",children:n.assertions.map(j=>t.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[t.jsx("span",{style:{color:j.pass?"var(--green)":"var(--red)"},children:j.pass?"PASS":"FAIL"}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:j.text})]},j.assertion_id))}),n.output&&t.jsx("button",{onClick:()=>x(!v),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:v?"Hide output":"Show output"}),v&&n.output&&t.jsx("pre",{className:"text-[11px] mt-2 p-3 rounded-lg overflow-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:200,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap"},children:n.output})]}),u&&t.jsx("div",{className:"px-4 pb-3",children:t.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:t.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const j=fl(u.skillContentScore,u.baselineContentScore),S=fl(u.skillStructureScore,u.baselineStructureScore),k=e1(u.winner);return t.jsxs(t.Fragment,{children:[t.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",j.skill,"% / Baseline ",j.baseline,"%"]}),t.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),t.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",S.skill,"% / Baseline ",S.baseline,"%"]}),t.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),t.jsx("span",{style:{color:k.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:k.text})]})})()})})}),n&&n.errorMessage&&t.jsx(i1,{errorMessage:n.errorMessage,classifiedError:n.classifiedError})]})}const io={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function i1({errorMessage:e,classifiedError:r}){const[n,s]=c.useState(!1),o=(r==null?void 0:r.title)??"Error",a=r==null?void 0:r.hint,i=r?io[r.category]??io.unknown:io.unknown;return t.jsx("div",{className:"px-4 pb-3",children:t.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx("span",{style:{fontSize:12},children:i}),t.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:o}),t.jsx("button",{onClick:()=>s(!n),className:"text-[10px] px-1.5 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},children:n?"Hide details":"Details"})]}),a&&t.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:a}),n&&t.jsx("pre",{className:"text-[10px] px-3 pb-2.5 overflow-auto",style:{color:"var(--text-tertiary)",maxHeight:120,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:e})]})})}function hl({label:e,value:r,color:n}){return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:e}),t.jsxs("span",{className:"text-[12px] font-semibold",style:{color:n},children:[Math.round(r*100),"%"]})]}),t.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:t.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${r*100}%`,background:n}})})]})}const ml={TP:{bg:"var(--green-muted)",text:"var(--green)"},TN:{bg:"var(--green-muted)",text:"var(--green)"},FP:{bg:"var(--red-muted)",text:"var(--red)"},FN:{bg:"var(--red-muted)",text:"var(--red)"},SCOPE_WARNING:{bg:"var(--yellow-muted)",text:"var(--yellow)"},DRIFT_WARNING:{bg:"var(--yellow-muted)",text:"var(--yellow)"}},l1={scope_warning:"Description claims broader scope than name+tags suggest. Either narrow the description or add explicit '+' prefix to confirm intended scope.",drift_warning:"Description omits intent that classifier inferred from name+tags. Description may need to mention this case explicitly."};function c1(){const{state:e,dispatch:r,runActivationTest:n,cancelActivation:s,generateActivationPrompts:o,loadTestCasesFromSkillMd:a,saveTestCasesToSkillMd:i}=vt(),{plugin:l,skill:d,activationPrompts:u,activationResults:p,activationSummary:f,activationRunning:h,activationError:m,activationStartedAt:g,activationClassifyingStatus:v,generatingPrompts:x,generatingPromptsError:b,activationPromptsSource:y,savingTestCases:j,savingTestCasesError:S,savingTestCasesSuccess:k,activationHistory:R}=e,{state:w}=Pt(),E=w.skills.find(z=>z.plugin===l&&z.skill===d),N=(E==null?void 0:E.resolvedVersion)??(E==null?void 0:E.version)??null,[T,I]=c.useState(u),[A,$]=c.useState(null),[W,C]=c.useState(!1);c.useEffect(()=>{u&&u!==T&&I(u)},[u]),c.useEffect(()=>{r({type:"SET_ACTIVATION_PROMPTS",prompts:T})},[T,r]),c.useEffect(()=>{fetch(`/api/skills/${l}/${d}/description`).then(z=>z.json()).then(z=>$(z.rawContent||z.description||null)).catch(()=>$(null))},[l,d]),c.useEffect(()=>{(!u||u.trim().length===0)&&a()},[l,d]);function P(){n(T)}function L(){o(8)}function F(){i()}const H=T.trim().split(`
|
|
54
|
+
`).filter(Boolean).length,re=z=>z.verdict==="scope_warning"||z.verdict==="drift_warning",V=p.filter(z=>(z.classification==="TP"||z.classification==="TN")&&!re(z)),O=p.filter(z=>(z.classification==="FP"||z.classification==="FN")&&!re(z));p.filter(re);const se=(A==null?void 0:A.replace(/^---[\s\S]*?---\s*/,"").trim())??null,ge=T.trim().length>0,ye=se?Ln(se):"";return t.jsxs("div",{className:"p-5 space-y-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),t.jsx("div",{className:"text-[12px] mt-0.5",style:{color:"var(--text-tertiary)"},children:"Test whether this skill's description activates for relevant prompts and stays silent for irrelevant ones."})]}),t.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[t.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),y==="skill-md"&&t.jsx("span",{className:"pill",style:{background:"var(--green-muted)",color:"var(--green)",fontSize:"9px",padding:"1px 5px"},title:"Loaded from the ## Test Cases block in SKILL.md. Save back any edits to persist them.",children:"from SKILL.md"}),y==="ai-generated"&&t.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},title:"AI-generated. Save as test cases to persist into SKILL.md.",children:"AI-generated"})]}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("button",{onClick:F,disabled:j||!ge||h,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:j?"var(--surface-3)":"var(--surface-2)",color:ge?"var(--green)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:ge?1:.5,cursor:ge?"pointer":"not-allowed"},title:ge?"Write the current prompts back to SKILL.md as a ## Test Cases block":"No prompts to save",onMouseEnter:z=>{ge&&!j&&(z.currentTarget.style.background="var(--surface-3)")},onMouseLeave:z=>{j||(z.currentTarget.style.background="var(--surface-2)")},children:j?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"spinner",style:{borderTopColor:"var(--green)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),t.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),t.jsx("polyline",{points:"7 3 7 8 15 8"})]}),"Save as test cases"]})}),t.jsx("button",{onClick:L,disabled:x||!se||h,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:x?"var(--surface-3)":"var(--surface-2)",color:se?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:se?1:.5,cursor:se?"pointer":"not-allowed"},title:se?void 0:"No skill description available",onMouseEnter:z=>{se&&!x&&(z.currentTarget.style.background="var(--surface-3)")},onMouseLeave:z=>{x||(z.currentTarget.style.background="var(--surface-2)")},children:x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 3v3m6.36.64l-2.12 2.12M21 12h-3m-.64 6.36l-2.12-2.12M12 21v-3m-4.24.64l2.12-2.12M3 12h3m.64-6.36l2.12 2.12"})}),ge?"Regenerate":"Generate"," Test Prompts"]})})]})]}),k&&t.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--green)",background:"var(--green-muted)"},"aria-live":"polite",children:k}),S&&t.jsxs("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},"aria-live":"polite",children:["Save failed: ",S]}),!se&&!h&&t.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},"aria-live":"polite",children:"Add a description to your skill's frontmatter to enable prompt generation."}),b&&t.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:b}),t.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:T,onChange:z=>I(z.target.value),placeholder:`How do I write a unit test?
|
|
55
|
+
What edge cases should I test?
|
|
56
|
+
+Deploy this to production
|
|
57
|
+
!What's the weather like today?
|
|
58
|
+
!Write me a poem about flowers`}),t.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[t.jsx("span",{children:"One prompt per line"}),t.jsx(Wn,{}),t.jsx("span",{children:"No prefix = auto-classify"}),t.jsx(Wn,{}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),t.jsx(Wn,{}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),t.jsx(Wn,{}),t.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[H," prompt",H!==1?"s":""]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:P,disabled:h||!T.trim(),className:"btn btn-primary",children:h?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):t.jsxs(t.Fragment,{children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("circle",{cx:"12",cy:"12",r:"6"}),t.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),h&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),t.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[v||`${p.length} / ${H} prompts tested`,g&&t.jsx(f1,{startedAt:g})]})]})]})]}),t.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[t.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),t.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:se?t.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:ye}}):t.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),m&&t.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:m}),h&&p.length===0&&t.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[t.jsx("div",{className:"spinner-lg mx-auto mb-4"}),t.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),p.length>0&&t.jsxs("div",{className:"space-y-5",children:[O.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),t.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",O.length,")"]}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),t.jsx("div",{className:"space-y-1.5 stagger-children",children:O.map((z,ne)=>t.jsx(xl,{result:z},`incorrect-${ne}`))})]}),V.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("polyline",{points:"16 10 11 15 8 12"})]}),t.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",V.length,")"]})]}),t.jsx("div",{className:"space-y-1.5 stagger-children",children:V.map((z,ne)=>t.jsx(xl,{result:z},`correct-${ne}`))})]})]}),f&&t.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),f.autoClassifiedCount!=null&&f.autoClassifiedCount>0&&t.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[f.autoClassifiedCount," of ",f.total," prompts auto-classified from skill name and tags"]}),t.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[t.jsx(lo,{label:"Precision",value:f.precision,description:"Of all activations, how many were correct?",detail:`${f.tp} true / ${f.tp+f.fp} total activations`}),t.jsx(lo,{label:"Recall",value:f.recall,description:"Of expected activations, how many fired?",detail:`${f.tp} activated / ${f.tp+f.fn} expected`}),t.jsx(lo,{label:"Reliability",value:f.reliability,description:"Overall correct classification rate",detail:`${f.tp+f.tn} correct / ${f.total} total`})]}),t.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[t.jsx(Un,{label:"True Positive",abbr:"TP",count:f.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),t.jsx(Un,{label:"False Positive",abbr:"FP",count:f.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),t.jsx(Un,{label:"False Negative",abbr:"FN",count:f.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),t.jsx(Un,{label:"True Negative",abbr:"TN",count:f.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]}),t.jsxs("div",{className:"mt-3 max-w-xs mx-auto text-center text-[11px]",style:{color:"var(--text-tertiary)"},title:"Auto-classified disagreements: not real failures, but worth reviewing. Hover a yellow row for details.",children:["Warnings:"," ",t.jsxs("span",{style:{color:(f.scopeWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[f.scopeWarnings??0," scope"]}),", ",t.jsxs("span",{style:{color:(f.driftWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[f.driftWarnings??0," drift"]})]})]})]}),t.jsx(d1,{history:R,expanded:W,onToggle:()=>C(!W),skillVersion:N})]})}function d1({history:e,expanded:r,onToggle:n,skillVersion:s}){return e===null?null:t.jsxs("div",{className:"glass-card overflow-hidden",children:[t.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:r?"1px solid var(--border-subtle)":"none"},onClick:n,children:[t.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",e.length>0&&t.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",e.length," run",e.length!==1?"s":"",")"]})]}),t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),r&&t.jsx("div",{className:"px-4 py-3",children:e.length===0?t.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):t.jsx("div",{className:"space-y-2",children:e.map(o=>t.jsx(u1,{run:o,skillVersion:s},o.id))})})]})}function u1({run:e,skillVersion:r}){const n=Math.round(e.summary.reliability*100),s=n>=80?"var(--green)":n>=60?"var(--yellow)":"var(--red)",o=n>=80?"Good":n>=60?"Needs Work":"Poor",a=s;return t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:p1(e.timestamp)}),t.jsx(Rn,{version:r??null,size:"sm","data-testid":"activation-row-version"}),t.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:e.model||e.provider}),t.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[e.promptCount," prompts"]})]})}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsxs("span",{className:"text-[12px] font-semibold",style:{color:s,fontVariantNumeric:"tabular-nums"},children:[n,"%"]}),t.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:a,background:`color-mix(in srgb, ${a} 10%, transparent)`},children:o})]})]})}function p1(e){const r=Date.now(),n=new Date(e).getTime(),s=Math.floor((r-n)/1e3);if(s<60)return"just now";const o=Math.floor(s/60);if(o<60)return`${o}m ago`;const a=Math.floor(o/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<7?`${i}d ago`:new Date(e).toLocaleDateString()}function Wn(){return t.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function xl({result:e}){const r=e.verdict==="scope_warning"||e.verdict==="drift_warning",n=r?e.verdict==="scope_warning"?"SCOPE_WARNING":"DRIFT_WARNING":e.classification,s=ml[n]||ml.FN,o=!r&&(e.classification==="TP"||e.classification==="TN"),a=e.verdict==="scope_warning"?"scope warn":e.verdict==="drift_warning"?"drift warn":null,i=e.verdict&&e.verdict!=="ok"?l1[e.verdict]:void 0;return t.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:s.bg,border:"1px solid transparent"},children:[t.jsx("div",{className:"flex-shrink-0 mt-0.5",children:t.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${s.text} 20%, transparent)`},children:o?t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:s.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):r?t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:s.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:s.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"flex items-center gap-2 mb-1",children:t.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:e.prompt})}),t.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[t.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:s.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},title:i,children:a??e.classification}),t.jsx("span",{style:{color:e.activate?"var(--green)":"var(--text-tertiary)"},children:e.activate?"Activated":"Silent"}),t.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",e.expected==="should_activate"?"activate":"stay silent"]}),t.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[e.confidence," confidence"]}),e.autoClassified&&t.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),e.reasoning&&t.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:e.reasoning})]})]})}function lo({label:e,value:r,description:n,detail:s}){const o=Math.round(r*100),a=o>=80?"var(--green)":o>=60?"var(--yellow)":"var(--red)";return t.jsxs("div",{className:"text-center",children:[t.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:a},children:[o,"%"]}),t.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:e}),t.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:n}),t.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:s})]})}function Un({abbr:e,count:r,bg:n,color:s,description:o}){return t.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:n},children:[t.jsx("div",{className:"text-[20px] font-bold",style:{color:s},children:r}),t.jsx("div",{className:"text-[11px] font-semibold",style:{color:s},children:e}),t.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:o})]})}function f1({startedAt:e}){const[r,n]=c.useState(0);return c.useEffect(()=>{const s=setInterval(()=>n(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(s)},[e]),t.jsxs("span",{className:"ml-2",children:["(",r,"s)"]})}function h1(e){return e==="benchmark"||e==="activation"||e==="ab"}function m1({mode:e}){var l;const{state:r,runAll:n}=vt(),s=c.useRef(!1),a=(((l=r.evals)==null?void 0:l.evals)??[]).length,i=r.evals!=null;return c.useEffect(()=>{if(e!=="benchmark"||typeof window>"u"||s.current)return;const d=new URLSearchParams(window.location.search);if(d.get("autorun")!=="1"||!i||a===0)return;s.current=!0,n("benchmark"),d.delete("autorun");const u=d.toString(),p=`${window.location.pathname}${u?"?"+u:""}${window.location.hash}`;window.history.replaceState(null,"",p)},[e,i,a,n]),e==="activation"?t.jsx(c1,{}):t.jsx(s1,{})}const co={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},gl={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},oa=600,aa=180,ft=40,uo=oa-ft*2,rr=aa-ft*2,x1=[25,50,75,100];function vl(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function g1(e){return e==null?"--":`${(e/1e3).toFixed(1)}s`}function v1({entries:e,onPointClick:r}){const[n,s]=c.useState(null),o=c.useMemo(()=>[...e].reverse(),[e]);if(o.length<2)return null;const a=o.length,i=o.map((u,p)=>{const f=ft+p/(a-1)*uo,h=u.passRate*100,m=ft+rr-h/100*rr;return{x:f,y:m,pct:h,entry:u}}),l=i.map(u=>`${u.x},${u.y}`).join(" "),d=Array.from(new Set(o.map(u=>u.type)));return t.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:a>=20?"auto":void 0},children:[t.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),t.jsx("div",{className:"flex items-center gap-5 mb-3",children:d.map(u=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:co[u]??"var(--text-tertiary)"}}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:gl[u]??u})]},u))}),t.jsxs("svg",{width:oa,height:aa,viewBox:`0 0 ${oa} ${aa}`,style:{display:"block",overflow:"visible"},children:[x1.map(u=>{const p=ft+rr-u/100*rr;return t.jsxs("g",{children:[t.jsx("line",{x1:ft,y1:p,x2:ft+uo,y2:p,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),t.jsxs("text",{x:ft-8,y:p+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[u,"%"]})]},u)}),t.jsx("line",{x1:ft,y1:ft+rr,x2:ft+uo,y2:ft+rr,stroke:"var(--border-subtle)",strokeWidth:1}),t.jsx("text",{x:ft-8,y:ft+rr+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),t.jsx("polyline",{points:l,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),i.map((u,p)=>t.jsx("circle",{cx:u.x,cy:u.y,r:5,fill:co[u.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:f=>{f.currentTarget.setAttribute("r","7"),s({x:u.x,y:u.y,entry:u.entry})},onMouseLeave:f=>{f.currentTarget.setAttribute("r","5"),s(null)},onClick:()=>r==null?void 0:r(u.entry)},p)),y1(a).map(u=>t.jsx("text",{x:i[u].x,y:ft+rr+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:vl(o[u].timestamp)},u))]}),n&&t.jsxs("div",{style:{position:"absolute",left:n.x,top:n.y-12,transform:"translate(-50%, -100%)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"8px 12px",pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"},children:[t.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:vl(n.entry.timestamp)}),t.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:n.entry.model}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:co[n.entry.type]??"var(--text-tertiary)",color:"#fff"},children:gl[n.entry.type]??n.entry.type}),t.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(n.entry.passRate*100),"%"]})]}),t.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[t.jsx("span",{children:g1(n.entry.totalDurationMs)}),t.jsx("span",{children:n.entry.totalTokens!=null?`${n.entry.totalTokens} tokens`:"--"})]})]})]})}function y1(e){if(e<=3)return Array.from({length:e},(s,o)=>o);if(e<=6)return[0,Math.floor(e/2),e-1];if(e<20)return[0,Math.floor(e/3),Math.floor(2*e/3),e-1];const r=Math.ceil(e/10),n=[0];for(let s=r;s<e-1;s+=r)n.push(s);return n.push(e-1),n}const an=new Map;let ht=null,rs=null,Hn=1e3,Ir=0;function wu(){if(ht)return;ht=new EventSource("/api/events");const e=r=>n=>{let s={};try{s=n.data?JSON.parse(n.data):{}}catch{}const o=an.get(r);if(o)for(const a of o)a(s)};ht.addEventListener("benchmark:complete",e("benchmark:complete")),ht.addEventListener("history:written",e("history:written")),ht.addEventListener("leaderboard:updated",e("leaderboard:updated")),ht.onerror=()=>{ht==null||ht.close(),ht=null,Ir>0&&(rs=setTimeout(()=>{Hn=Math.min(Hn*2,3e4),wu()},Hn))},ht.onopen=()=>{Hn=1e3}}function b1(){rs!=null&&(clearTimeout(rs),rs=null),ht==null||ht.close(),ht=null}function k1(e,r){return an.has(e)||an.set(e,new Set),an.get(e).add(r),Ir++,wu(),()=>{var n;(n=an.get(e))==null||n.delete(r),Ir--,Ir<=0&&(Ir=0,queueMicrotask(()=>{Ir<=0&&b1()}))}}function cs(e,r){const n=c.useRef(r);n.current=r,c.useEffect(()=>k1(e,o=>n.current(o)),[e])}function ds(e){return e>=.8?"var(--green)":e>=.5?"var(--yellow)":"var(--red)"}function j1(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function w1({rate:e,label:r}){const n=Math.round(e*100);return t.jsx("div",{className:"flex items-center gap-3",children:t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:r}),t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:ds(e)},children:[n,"%"]})]}),t.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:t.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${n}%`,background:ds(e)}})})]})})}function S1({points:e}){if(e.length<2)return null;const r=200,n=48,s=4,o=e.length,a=e.map((d,u)=>{const p=s+u/(o-1)*(r-s*2),f=s+(n-s*2)-d.passRate*(n-s*2);return{x:p,y:f}}),i=`M ${a[0].x},${n-s} `+a.map(d=>`L ${d.x},${d.y}`).join(" ")+` L ${a[a.length-1].x},${n-s} Z`,l=a.map((d,u)=>`${u===0?"M":"L"} ${d.x},${d.y}`).join(" ");return t.jsxs("svg",{width:r,height:n,style:{display:"block"},children:[t.jsx("path",{d:i,fill:"var(--accent-muted)"}),t.jsx("path",{d:l,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),t.jsx("circle",{cx:a[a.length-1].x,cy:a[a.length-1].y,r:3,fill:"var(--accent)"})]})}function C1({plugin:e,skill:r}){const n=`stats/${e}/${r}`,s=c.useCallback(()=>ce.getStats(e,r),[e,r]),{data:o,loading:a}=It(n,s),i=c.useCallback(()=>He(n),[n]);if(cs("benchmark:complete",i),cs("history:written",i),a)return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"skeleton h-24 rounded-xl"}),t.jsx("div",{className:"skeleton h-48 rounded-xl"}),t.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!o||o.totalRuns===0)return t.jsxs("div",{className:"text-center py-12",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[t.jsx("path",{d:"M18 20V10"}),t.jsx("path",{d:"M12 20V4"}),t.jsx("path",{d:"M6 20v-6"})]})}),t.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),t.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const l=o.trendPoints.length>0?o.trendPoints[o.trendPoints.length-1].passRate:0,d=o.trendPoints.length>0?o.trendPoints[0].passRate:0,u=l-d,p=o.assertionStats.slice(0,10);return t.jsxs("div",{className:"space-y-4 stagger-children",children:[t.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),t.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:o.totalRuns})]}),t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),t.jsxs("div",{className:"text-[24px] font-bold",style:{color:ds(l)},children:[Math.round(l*100),"%"]})]}),t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),t.jsxs("div",{className:"text-[24px] font-bold",style:{color:u>=0?"var(--green)":"var(--red)"},children:[u>=0?"+":"",Math.round(u*100),"%"]})]}),t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),t.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:o.modelStats.length})]}),o.totalCost!=null&&t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),t.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Tt(o.totalCost)})]}),o.costPerRun!=null&&t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),t.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Tt(o.costPerRun)})]})]}),o.trendPoints.length>=2&&t.jsxs("div",{className:"glass-card p-5",children:[t.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),t.jsx(S1,{points:o.trendPoints})]}),o.modelStats.length>0&&t.jsxs("div",{className:"glass-card p-5",children:[t.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),t.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),t.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),t.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),t.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),t.jsx("tbody",{children:o.modelStats.map(f=>t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:f.model}),t.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:f.runs}),t.jsx("td",{style:{padding:"8px",textAlign:"center"},children:t.jsxs("span",{className:"font-semibold",style:{color:ds(f.avgPassRate)},children:[Math.round(f.avgPassRate*100),"%"]})}),t.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:j1(f.avgDurationMs)}),t.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:f.avgCost!=null?Tt(f.avgCost):"N/A"})]},f.model))})]})]}),p.length>0&&t.jsxs("div",{className:"glass-card p-5",children:[t.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),t.jsx("div",{className:"space-y-3",children:p.map(f=>t.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:h=>{h.currentTarget.style.background="var(--surface-2)"},onMouseLeave:h=>{h.currentTarget.style.background="transparent"},onClick:()=>{},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",f.evalId]}),t.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:f.evalName}),t.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[f.totalRuns," runs"]})]}),t.jsx(w1,{rate:f.passRate,label:f.text})]},`${f.evalId}:${f.id}`))})]})]})}function E1({plugin:e,skill:r}){const[n,s]=c.useState(null),[o,a]=c.useState(null),[i,l]=c.useState({}),[d,u]=c.useState({});c.useEffect(()=>{ce.getEvals(e,r).then(s).catch(()=>s(null))},[e,r]);async function p(f){if(o===f){a(null);return}if(a(f),!i[f]){u(h=>({...h,[f]:!0}));try{const h=await ce.getCaseHistory(e,r,f);l(m=>({...m,[f]:h}))}catch{l(h=>({...h,[f]:[]}))}finally{u(h=>({...h,[f]:!1}))}}}return n?t.jsx("div",{className:"space-y-2 stagger-children",children:n.evals.map(f=>{const h=i[f.id]||[],m=o===f.id,g=d[f.id],v=h.length>0?h[0].pass_rate:null;return t.jsxs("div",{className:"glass-card overflow-hidden",children:[t.jsxs("button",{onClick:()=>p(f.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:m?"var(--surface-2)":"transparent"},onMouseEnter:x=>{m||(x.currentTarget.style.background="var(--surface-2)")},onMouseLeave:x=>{m||(x.currentTarget.style.background="transparent")},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:m?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:t.jsx("polyline",{points:"9 18 15 12 9 6"})}),t.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",f.id]}),t.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:f.name}),h.length>=2&&t.jsx(hu,{entries:h}),v!=null&&t.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:_r(v)},children:[Math.round(v*100),"%"]}),h.length>0&&t.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[h.length," runs"]})]}),m&&t.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:g?t.jsxs("div",{className:"p-4 flex items-center gap-2",children:[t.jsx("div",{className:"spinner",style:{width:14,height:14}}),t.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):h.length===0?t.jsx("div",{className:"p-4",children:t.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):t.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:h.map((x,b)=>t.jsxs("div",{className:"p-4",style:{background:b===0?"var(--surface-2)":"transparent"},children:[t.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[t.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:pu(x.timestamp)}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:x.model}),t.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:x.type==="benchmark"?"rgba(99,131,255,0.15)":x.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:x.type==="benchmark"?"#6383ff":x.type==="comparison"?"var(--purple)":"#fb923c"},children:x.type}),t.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:_r(x.pass_rate)},children:[Math.round(x.pass_rate*100),"%"]})]}),t.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[x.durationMs!=null&&t.jsx("span",{children:fu(x.durationMs)}),x.tokens!=null&&t.jsxs("span",{children:[x.tokens>=1e3?`${(x.tokens/1e3).toFixed(1)}k`:x.tokens," tok"]})]}),t.jsx("div",{className:"space-y-1",children:x.assertions.map(y=>t.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[t.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:y.pass?"var(--green)":"var(--red)"},children:t.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:y.pass?t.jsx("polyline",{points:"20 6 9 17 4 12"}):t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:y.text}),y.reasoning&&t.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:y.reasoning})]})]},y.id))})]},b))})})]},f.id)})}):t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function N1(){const{state:e,dispatch:r}=vt(),{plugin:n,skill:s}=e,{state:o}=Pt(),a=o.skills.find(F=>F.plugin===n&&F.skill===s),i=(a==null?void 0:a.resolvedVersion)??(a==null?void 0:a.version)??null,[l,d]=c.useState("timeline"),[u,p]=c.useState(""),[f,h]=c.useState(""),[m,g]=c.useState(!1),[v,x]=c.useState([]),[b,y]=c.useState(null),[j,S]=c.useState(!1),[k,R]=c.useState(null),[w,E]=c.useState(!1),N=`history/${n}/${s}?model=${u}&type=${f}`,T=c.useCallback(()=>ce.getHistory(n,s,{model:u||void 0,type:f||void 0}),[n,s,u,f]),{data:I,loading:A}=It(N,T),$=I??[];c.useEffect(()=>{!I||I.length<2||ce.compareRuns(n,s,I[0].timestamp,I[1].timestamp).then(F=>{const H=F.regressions.filter(re=>re.change==="regression");r({type:"SET_REGRESSIONS",regressions:H})}).catch(()=>{})},[I,n,s,r]);const W=c.useCallback(()=>He(N),[N]);cs("history:written",W);const C=c.useCallback(async F=>{if(m){x(H=>H.includes(F)?H.filter(re=>re!==F):H.length>=2?[H[1],F]:[...H,F]);return}E(!0);try{const H=await ce.getHistoryEntry(n,s,F);R(H)}catch{}finally{E(!1)}},[n,s,m]),P=c.useCallback(async()=>{if(v.length===2){S(!0);try{const F=await ce.compareRuns(n,s,v[0],v[1]);y(F)}catch{}finally{S(!1)}}},[n,s,v]),L=[...new Set($.map(F=>F.model))];return A?t.jsxs("div",{className:"p-5",children:[t.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),t.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"skeleton h-12 rounded-lg"}),t.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):t.jsxs("div",{className:"p-5",children:[t.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(F=>t.jsx("button",{onClick:()=>d(F),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:l===F?"var(--accent-muted)":"transparent",color:l===F?"var(--accent)":"var(--text-tertiary)"},children:F==="timeline"?"Timeline":F==="per-eval"?"Per Eval":"Statistics"},F))}),l==="timeline"&&t.jsxs("div",{children:[$.length>0&&t.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:t.jsx(v1,{entries:$,onPointClick:F=>C(F.timestamp)})}),t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsxs("select",{value:u,onChange:F=>p(F.target.value),className:"input-field text-[12px]",style:{width:150},children:[t.jsx("option",{value:"",children:"All Models"}),L.map(F=>t.jsx("option",{value:F,children:F},F))]}),t.jsxs("select",{value:f,onChange:F=>h(F.target.value),className:"input-field text-[12px]",style:{width:150},children:[t.jsx("option",{value:"",children:"All Types"}),t.jsx("option",{value:"benchmark",children:"Benchmark"}),t.jsx("option",{value:"comparison",children:"Comparison"}),t.jsx("option",{value:"baseline",children:"Baseline"}),t.jsx("option",{value:"model-compare",children:"Model Compare"}),t.jsx("option",{value:"improve",children:"AI Improve"}),t.jsx("option",{value:"instruct",children:"AI Edit"}),t.jsx("option",{value:"ai-generate",children:"AI Generate"}),t.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>{g(!m),x([]),y(null)},className:`btn text-[12px] ${m?"btn-primary":"btn-secondary"}`,children:m?"Exit Compare":"Compare Runs"}),m&&v.length===2&&t.jsx("button",{onClick:P,disabled:j,className:"btn btn-primary text-[12px]",children:j?"Comparing...":"Compare"})]}),t.jsx("div",{className:"space-y-2",children:$.length===0?t.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):$.map(F=>{const H=v.includes(F.timestamp);return t.jsx("button",{onClick:()=>C(F.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:H?"var(--accent-muted)":"var(--surface-1)",border:H?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:re=>{H||(re.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:re=>{H||(re.currentTarget.style.borderColor="var(--border-subtle)")},children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[m&&t.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:H?"var(--accent)":"var(--border-default)",background:H?"var(--accent)":"transparent"},children:H&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}),t.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(F.timestamp).toLocaleString()}),t.jsx("span",{className:"pill text-[9px]",style:{background:F.type==="comparison"?"var(--purple-muted)":F.type==="baseline"?"var(--surface-3)":F.type==="model-compare"?"var(--accent-muted)":F.type==="improve"||F.type==="instruct"?"var(--purple-muted)":F.type==="ai-generate"?"var(--green-muted)":F.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:F.type==="comparison"?"var(--purple)":F.type==="baseline"?"var(--text-tertiary)":F.type==="model-compare"?"var(--accent)":F.type==="improve"||F.type==="instruct"?"var(--purple)":F.type==="ai-generate"?"var(--green)":F.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:F.type==="model-compare"?"model compare":F.type==="improve"?"ai improve":F.type==="instruct"?"ai edit":F.type==="ai-generate"?"ai generate":F.type==="eval-generate"?"eval generate":F.type})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Rn,{version:i,size:"sm","data-testid":"history-row-version"}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:F.model}),F.totalCost!=null&&F.totalCost>0&&t.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Tt(F.totalCost)}),t.jsxs("span",{className:"text-[12px] font-semibold",style:{color:F.passRate>=.8?"var(--green)":F.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(F.passRate*100),"%"]})]})]})},F.timestamp)})}),b&&t.jsx(R1,{result:b}),k&&!m&&t.jsx(T1,{run:k,onClose:()=>R(null)})]}),l==="per-eval"&&t.jsx(E1,{plugin:n,skill:s}),l==="statistics"&&t.jsx(C1,{plugin:n,skill:s})]})}function R1({result:e}){const r=e.regressions.filter(s=>s.change==="regression"),n=e.regressions.filter(s=>s.change==="improvement");return t.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(e.runA.timestamp).toLocaleDateString()," vs ",new Date(e.runB.timestamp).toLocaleDateString()]}),(e.runA.totalCost!=null||e.runB.totalCost!=null)&&t.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[t.jsxs("span",{children:["Run A cost: ",Tt(e.runA.totalCost??null)]}),t.jsxs("span",{children:["Run B cost: ",Tt(e.runB.totalCost??null)]}),e.runA.totalCost!=null&&e.runB.totalCost!=null&&t.jsxs("span",{style:{color:e.runB.totalCost<=e.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Tt(e.runB.totalCost-e.runA.totalCost)]})]}),r.length>0&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",r.length,")"]}),r.map(s=>t.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",s.evalId," ",s.evalName,": ",t.jsx("span",{style:{color:"var(--red)"},children:s.assertionId})," (was passing, now failing)"]},`${s.evalId}-${s.assertionId}`))]}),n.length>0&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",n.length,")"]}),n.map(s=>t.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",s.evalId," ",s.evalName,": ",t.jsx("span",{style:{color:"var(--green)"},children:s.assertionId})," (was failing, now passing)"]},`${s.evalId}-${s.assertionId}`))]}),t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),t.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:t.jsxs("table",{className:"w-full text-[12px]",children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"var(--surface-2)"},children:[t.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),t.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),t.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),t.jsx("tbody",{children:e.caseDiffs.map(s=>t.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[t.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),t.jsx("td",{className:"text-right px-3 py-2",style:{color:s.passRateA!=null?s.passRateA>=.8?"var(--green)":s.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:s.passRateA!=null?`${Math.round(s.passRateA*100)}%`:s.statusA}),t.jsx("td",{className:"text-right px-3 py-2",style:{color:s.passRateB!=null?s.passRateB>=.8?"var(--green)":s.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:s.passRateB!=null?`${Math.round(s.passRateB*100)}%`:s.statusB})]},s.eval_id))})]})})]})}function T1({run:e,onClose:r}){return(e.type==="improve"||e.type==="instruct")&&e.improve?t.jsx(I1,{run:e,onClose:r}):t.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(e.timestamp).toLocaleString()]}),t.jsx("button",{onClick:r,className:"btn btn-ghost text-[11px]",children:"Close"})]}),t.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",e.model," | Cases: ",e.cases.length," | Pass Rate: ",e.overall_pass_rate!=null?`${Math.round(e.overall_pass_rate*100)}%`:"--",e.totalCost!=null&&e.totalCost>0&&` | Cost: ${Tt(e.totalCost)}`]}),t.jsx("div",{className:"space-y-2",children:e.cases.map(n=>t.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",n.eval_id," ",n.eval_name]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n.cost!=null&&n.cost>0&&t.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Tt(n.cost)}),t.jsx("span",{className:"text-[11px] font-semibold",style:{color:n.status==="pass"?"var(--green)":"var(--red)"},children:n.pass_rate!=null?`${Math.round(n.pass_rate*100)}%`:n.status})]})]})},n.eval_id))})]})}function I1({run:e,onClose:r}){var a;const n=c.useMemo(()=>e.improve?Cs(e.improve.original,e.improve.improved):[],[e.improve]),s=c.useMemo(()=>{const i=n.filter(d=>d.type==="added").length,l=n.filter(d=>d.type==="removed").length;return{added:i,removed:l}},[n]),o=c.useMemo(()=>{let i=0,l=0;return n.map(d=>d.type==="removed"?(i++,{...d,origNum:i,newNum:null}):d.type==="added"?(l++,{...d,origNum:null,newNum:l}):(i++,l++,{...d,origNum:i,newNum:l}))},[n]);return t.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),t.jsx("path",{d:"M2 17l10 5 10-5"}),t.jsx("path",{d:"M2 12l10 5 10-5"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),t.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(e.timestamp).toLocaleString()," · ",e.model]})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[t.jsxs("span",{style:{color:"var(--green)"},children:["+",s.added]}),t.jsxs("span",{style:{color:"var(--red)"},children:["-",s.removed]})]}),t.jsx("button",{onClick:r,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:i=>{i.currentTarget.style.background="var(--surface-3)"},onMouseLeave:i=>{i.currentTarget.style.background="transparent"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((a=e.improve)==null?void 0:a.reasoning)&&t.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),e.improve.reasoning]}),t.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:t.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:t.jsx("tbody",{children:o.map((i,l)=>t.jsxs("tr",{style:{background:i.type==="added"?"var(--green-muted)":i.type==="removed"?"var(--red-muted)":"transparent"},children:[t.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:i.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:i.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:i.origNum??""}),t.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:i.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:i.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:i.newNum??""}),t.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:i.type==="added"?"var(--green)":i.type==="removed"?"var(--red)":"transparent",borderRight:i.type==="added"?"2px solid var(--green)":i.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:i.type==="added"?"+":i.type==="removed"?"-":" "}),t.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:i.type==="added"?"var(--green)":i.type==="removed"?"var(--red)":"var(--text-secondary)"},children:i.content||""})]},l))})})})]})}function Su({data:e}){if(e.length<2)return t.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const r=e.slice(-10),n=80,s=24,o=2,a=n-o*2,i=s-o*2,l=r.length,d=Math.min(...r),p=Math.max(...r)-d||1,f=r.map((g,v)=>{const x=o+v/(l-1)*a,b=o+i-(g-d)/p*i;return`${x.toFixed(1)},${b.toFixed(1)}`}),h=r[r.length-1],m=_r(h);return t.jsxs("svg",{width:n,height:s,viewBox:`0 0 ${n} ${s}`,style:{display:"block"},children:[t.jsx("polyline",{points:f.join(" "),fill:"none",stroke:m,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[g,v]=f[f.length-1].split(",");return t.jsx("circle",{cx:g,cy:v,r:2.5,fill:m})})()]})}function L1(){return t.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Best Model"]})}function A1({pct:e}){const r=e>=10?"var(--green)":e>=0?"var(--yellow)":"var(--red)",n=e>=10?"var(--green-muted)":e>=0?"var(--yellow-muted)":"var(--red-muted)",s=e>=0?"+":"";return t.jsxs("span",{className:"pill",style:{background:n,color:r,fontSize:10,fontWeight:600},children:[s,e.toFixed(1),"%"]})}function P1({score:e,rating:r}){const n={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},s=n[r]??n.minimal,o=e>=0?"+":"";return t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),t.jsxs("span",{className:"pill",style:{background:s.bg,color:s.fg,fontSize:11,fontWeight:600},children:[o,e.toFixed(1),"% (",r.toUpperCase(),")"]})]})}function $1({warning:e}){return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-3",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow-muted)"},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:e})]})}function M1({active:e,onChange:r,hasBaseline:n}){return t.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[t.jsx("button",{onClick:()=>r("rankings"),className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:e==="rankings"?"var(--surface-3)":"transparent",color:e==="rankings"?"var(--text-primary)":"var(--text-tertiary)"},children:"Rankings"}),t.jsx("button",{onClick:()=>r("amplification"),disabled:!n,className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:e==="amplification"?"var(--surface-3)":"transparent",color:n&&e==="amplification"?"var(--text-primary)":"var(--text-tertiary)",opacity:n?1:.5,cursor:n?"pointer":"not-allowed"},title:n?"View skill amplification data":"Run sweep with --baseline to see amplification data",children:"Skill Amplification"})]})}function F1(e){var s,o,a;if(e.length===0)return[];const r=new Map;for(const i of e)for(const l of i.models){if(l.status==="error")continue;const d=`${l.provider}/${l.model}`;r.has(d)||r.set(d,{provider:l.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const u=r.get(d);u.passRates.push(l.passRate.mean),u.lastRubric=((s=l.rubricScore)==null?void 0:s.mean)??null,u.lastDuration=l.duration.mean,u.lastCost=((o=l.cost)==null?void 0:o.total)??null,u.lastCompositeScore=l.compositeScore,l.baselinePassRate!=null&&(u.lastBaselinePassRate=l.baselinePassRate.mean,u.lastSkillDelta=(a=l.skillDelta)==null?void 0:a.mean,u.lastAmplificationPct=l.amplificationPct,u.hasBaseline=!0)}const n=[];for(const[i,l]of r){const[d,...u]=i.split("/");n.push({rank:0,model:u.join("/"),provider:d,passRate:l.passRates[l.passRates.length-1],rubricScore:l.lastRubric,duration:l.lastDuration,cost:l.lastCost,sparklineData:l.passRates,isBest:!1,baselinePassRate:l.lastBaselinePassRate,skillDelta:l.lastSkillDelta,amplificationPct:l.lastAmplificationPct,compositeScore:l.lastCompositeScore,hasBaseline:l.hasBaseline})}return n.sort((i,l)=>{const d=i.compositeScore??i.passRate;return(l.compositeScore??l.passRate)-d}),n.forEach((i,l)=>{i.rank=l+1}),n.length>0&&(n[0].isBest=!0),n}const Cu=(e="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:e,whiteSpace:"nowrap"});function D1({entries:e}){return t.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[t.jsx("thead",{children:t.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(r=>t.jsx("th",{style:Cu(r==="#"?"center":"left"),children:r},r))})}),t.jsx("tbody",{children:e.map(r=>t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:n=>{n.currentTarget.style.background="var(--surface-2)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:[t.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:r.rank}),t.jsx("td",{style:{padding:"10px 12px"},children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:r.model}),t.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:r.provider}),r.isBest&&t.jsx(L1,{})]})}),t.jsx("td",{style:{padding:"10px 12px"},children:t.jsxs("span",{className:"pill",style:{background:r.passRate>=.7?"var(--green-muted)":r.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:_r(r.passRate),fontSize:11,fontWeight:600},children:[Math.round(r.passRate*100),"%"]})}),t.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.rubricScore!=null?r.rubricScore.toFixed(1):"--"}),t.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.duration<1e3?`${Math.round(r.duration)}ms`:`${(r.duration/1e3).toFixed(1)}s`}),t.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.cost!=null?`$${r.cost.toFixed(4)}`:"N/A"}),t.jsx("td",{style:{padding:"10px 12px"},children:t.jsx(Su,{data:r.sparklineData})})]},`${r.provider}/${r.model}`))})]})})}function z1({entries:e}){const r=[...e].filter(n=>n.hasBaseline).sort((n,s)=>(s.amplificationPct??0)-(n.amplificationPct??0));return r.length===0?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-center",children:t.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",t.jsx("code",{children:"--baseline"})," flag."]})})}):t.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[t.jsx("thead",{children:t.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(n=>t.jsx("th",{style:Cu(n==="#"?"center":"left"),children:n},n))})}),t.jsx("tbody",{children:r.map((n,s)=>t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:o=>{o.currentTarget.style.background="var(--surface-2)"},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:[t.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:s+1}),t.jsx("td",{style:{padding:"10px 12px"},children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:n.model}),t.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:n.provider})]})}),t.jsx("td",{style:{padding:"10px 12px"},children:t.jsxs("span",{className:"pill",style:{background:n.passRate>=.7?"var(--green-muted)":n.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:_r(n.passRate),fontSize:11,fontWeight:600},children:[Math.round(n.passRate*100),"%"]})}),t.jsx("td",{style:{padding:"10px 12px"},children:n.baselinePassRate!=null?t.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(n.baselinePassRate*100),"%"]}):"--"}),t.jsx("td",{style:{padding:"10px 12px"},children:n.skillDelta!=null?t.jsxs("span",{className:"text-[11px] font-medium",style:{color:n.skillDelta>=0?"var(--green)":"var(--red)"},children:[n.skillDelta>=0?"+":"",(n.skillDelta*100).toFixed(1),"pp"]}):"--"}),t.jsx("td",{style:{padding:"10px 12px"},children:n.amplificationPct!=null&&isFinite(n.amplificationPct)?t.jsx(A1,{pct:n.amplificationPct}):"--"}),t.jsx("td",{style:{padding:"10px 12px"},children:t.jsx(Su,{data:n.sparklineData})})]},`${n.provider}/${n.model}`))})]})})}function B1(){const{state:e}=vt(),{plugin:r,skill:n}=e,[s,o]=c.useState("rankings"),a=`leaderboard/${r}/${n}`,i=c.useCallback(()=>ce.getLeaderboard(r,n),[r,n]),{data:l,loading:d,error:u}=It(a,i),p=(l==null?void 0:l.entries)??[],f=(u==null?void 0:u.message)??null;c.useEffect(()=>{o("rankings")},[r,n]);const h=c.useCallback(()=>He(a),[a]);cs("leaderboard:updated",h);const m=c.useMemo(()=>F1(p),[p]),g=m.some(b=>b.hasBaseline),v=p[0],x=v==null?void 0:v.judgeBiasWarning;return d?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx("div",{className:"spinner spinner-lg"})}):f?t.jsx("div",{className:"flex items-center justify-center h-full px-8",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Failed to load leaderboard"}),t.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:f})]})}):m.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:t.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 20V10"}),t.jsx("path",{d:"M12 20V4"}),t.jsx("path",{d:"M6 20v-6"})]})}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),t.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),t.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),t.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",t.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):t.jsxs("div",{className:"p-5 animate-fade-in",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),t.jsx(M1,{active:s,onChange:o,hasBaseline:g})]}),t.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[p.length," sweep",p.length!==1?"s":""," · ",m.length," model",m.length!==1?"s":""]})]}),x&&t.jsx($1,{warning:x}),s==="rankings"?t.jsx(D1,{entries:m}):t.jsx(z1,{entries:m}),s==="amplification"&&(v==null?void 0:v.skillQualityScore)!=null&&(v==null?void 0:v.skillQualityRating)&&t.jsx(P1,{score:v.skillQualityScore,rating:v.skillQualityRating})]})}function _1(e){if(!e)return[];const r=e.split(`
|
|
59
|
+
`),n=[];for(const s of r)if(!(s.startsWith("--- ")||s.startsWith("+++ "))){if(s.startsWith("@@")){n.push({type:"header",content:s});continue}if(s.startsWith("+")){n.push({type:"add",content:s.slice(1)});continue}if(s.startsWith("-")){n.push({type:"remove",content:s.slice(1)});continue}(s.startsWith(" ")||s===""&&n.length>0)&&n.push({type:"context",content:s.startsWith(" ")?s.slice(1):""})}return n}function Oa({contentDiff:e,fromLabel:r,toLabel:n,diffSummary:s,maxHeight:o=480,collapsible:a=!1,renderContext:i="inline",onRetry:l}){const[d,u]=c.useState(a),[p,f]=c.useState("unified"),h=c.useRef(null),m=c.useRef(null),g=c.useMemo(()=>_1(e),[e]),v=c.useMemo(()=>{const k=g.filter(w=>w.type==="add").length,R=g.filter(w=>w.type==="remove").length;return{added:k,removed:R}},[g]),x=c.useMemo(()=>{let k=0,R=0;return g.filter(w=>w.type!=="header").map(w=>w.type==="remove"?(k++,{...w,origNum:k,newNum:null}):w.type==="add"?(R++,{...w,origNum:null,newNum:R}):(k++,R++,{...w,origNum:k,newNum:R}))},[g]),b=c.useMemo(()=>{const k=[],R=[];for(const w of x)if(w.type==="remove")k.push(w);else if(w.type==="add")R.push(w);else{for(;k.length<R.length;)k.push({type:"context",content:"",origNum:null,newNum:null});for(;R.length<k.length;)R.push({type:"context",content:"",origNum:null,newNum:null});k.push(w),R.push(w)}for(;k.length<R.length;)k.push({type:"context",content:"",origNum:null,newNum:null});for(;R.length<k.length;)R.push({type:"context",content:"",origNum:null,newNum:null});return{left:k,right:R}},[x]),y=c.useCallback(k=>{const R=k==="left"?h.current:m.current,w=k==="left"?m.current:h.current;R&&w&&(w.scrollTop=R.scrollTop)},[]);if(!e||g.length===0)return t.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),l&&t.jsx("button",{onClick:l,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const j=i==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",S=t.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[r," → ",n]}),t.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[t.jsxs("span",{style:{color:"var(--green)"},children:["+",v.added]}),t.jsxs("span",{style:{color:"var(--red)"},children:["-",v.removed]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>f(p==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:p==="unified"?"Side-by-side":"Unified"}),a&&t.jsx("button",{onClick:()=>u(!d),className:"btn btn-ghost text-[11px]",children:d?"Expand":"Collapse"})]})]}),s&&t.jsx("div",{className:"mx-4 mt-3 px-4 py-2 rounded-lg text-[12px]",style:{background:"var(--accent-muted)",color:"var(--text-secondary)"},children:s}),!d&&(p==="unified"?t.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:o,overflowY:"auto"},children:t.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:t.jsx("tbody",{children:x.map((k,R)=>t.jsxs("tr",{style:{background:k.type==="add"?"rgba(34,197,94,0.08)":k.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[t.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:k.type==="remove"?"rgba(239,68,68,0.5)":"var(--text-tertiary)",opacity:k.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:k.origNum??""}),t.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:k.type==="add"?"rgba(34,197,94,0.5)":"var(--text-tertiary)",opacity:k.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:k.newNum??""}),t.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:k.type==="add"?"var(--green)":k.type==="remove"?"var(--red)":"transparent",borderRight:k.type==="add"?"2px solid var(--green)":k.type==="remove"?"2px solid var(--red)":"2px solid transparent"},children:k.type==="add"?"+":k.type==="remove"?"-":" "}),t.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:k.type==="add"?"var(--green)":k.type==="remove"?"var(--red)":"var(--text-secondary)"},children:k.content||""})]},R))})})}):t.jsxs("div",{className:"mx-4 my-4 grid grid-cols-2 gap-0 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:[t.jsx("div",{ref:h,style:{maxHeight:o,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>y("left"),children:t.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:t.jsx("tbody",{children:b.left.map((k,R)=>t.jsxs("tr",{style:{background:k.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[t.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:k.origNum??""}),t.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:k.type==="remove"?"var(--red)":"var(--text-secondary)"},children:k.content||""})]},R))})})}),t.jsx("div",{ref:m,style:{maxHeight:o,overflowY:"auto"},onScroll:()=>y("right"),children:t.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:t.jsx("tbody",{children:b.right.map((k,R)=>t.jsxs("tr",{style:{background:k.type==="add"?"rgba(34,197,94,0.08)":"transparent"},children:[t.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:k.newNum??""}),t.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:k.type==="add"?"var(--green)":"var(--text-secondary)"},children:k.content||""})]},R))})})})]}))]});return i==="modal"?t.jsx("div",{className:j,children:t.jsx("div",{style:{width:"80%",maxWidth:900},children:S})}):S}const po="https://verified-skill.com/submit",O1=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function W1(e){if(!e)return po;const r=e.trim();return!r||!O1.test(r)?po:`${po}?repo=${encodeURIComponent(r)}`}const U1={sm:{icon:12,fontSize:"0.625rem",gap:"0.25rem",px:"0.375rem",py:"0.125rem",height:"18px",radius:"3px"},md:{icon:14,fontSize:"0.6875rem",gap:"0.3rem",px:"0.5rem",py:"0.15rem",height:"22px",radius:"4px"},lg:{icon:16,fontSize:"0.75rem",gap:"0.375rem",px:"0.625rem",py:"0.2rem",height:"26px",radius:"4px"}};function H1({size:e}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M10 1L3 4.5V9.5C3 13.64 5.99 17.52 10 18.5C14.01 17.52 17 13.64 17 9.5V4.5L10 1Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),t.jsx("path",{d:"M7.5 10.5L9.5 12.5L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function V1({size:e}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M10 1L11.9 4.1L15.5 3.5L14.2 7L17 9.5L14.2 12L15.5 15.5L11.9 14.9L10 18L8.1 14.9L4.5 15.5L5.8 12L3 9.5L5.8 7L4.5 3.5L8.1 4.1L10 1Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.1",strokeLinejoin:"round"}),t.jsx("path",{d:"M10 6.5L10.9 8.6L13.1 8.8L11.4 10.3L11.9 12.5L10 11.3L8.1 12.5L8.6 10.3L6.9 8.8L9.1 8.6L10 6.5Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.4",strokeLinejoin:"round"})]})}const yl={VERIFIED:{color:"var(--tier-verified)",bg:"var(--tier-verified-bg)",border:"var(--tier-verified-border)"},CERTIFIED:{color:"var(--tier-certified)",bg:"var(--tier-certified-bg)",border:"var(--tier-certified-border)"},TAINTED:{color:"var(--tier-tainted)",bg:"var(--tier-tainted-bg)",border:"var(--tier-tainted-border)"}},G1={VERIFIED:"Security-Scanned",CERTIFIED:"Trusted Publisher",TAINTED:"Tainted"};function Eu(e){return G1[e]??e}function K1({size:e}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M10 2L1.5 17.5H18.5L10 2Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),t.jsx("path",{d:"M10 8V12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("circle",{cx:"10",cy:"14.5",r:"1",fill:"currentColor"})]})}function q1({tier:e,size:r}){return e==="TAINTED"?t.jsx(K1,{size:r}):e==="CERTIFIED"?t.jsx(V1,{size:r}):t.jsx(H1,{size:r})}function TS({tier:e,size:r="md",isTainted:n}){const s=U1[r],o=n?"TAINTED":e,a=yl[o]??yl.VERIFIED;return t.jsxs("span",{"data-testid":"tier-badge","data-tier":o,style:{display:"inline-flex",alignItems:"center",gap:s.gap,padding:`${s.py} ${s.px}`,height:s.height,borderRadius:s.radius,fontFamily:"var(--font-geist-mono)",fontSize:s.fontSize,fontWeight:600,letterSpacing:"0.03em",whiteSpace:"nowrap",color:a.color,backgroundColor:a.bg,border:`1px solid ${a.border}`,lineHeight:1},children:[t.jsx(q1,{tier:o,size:s.icon}),Eu(o)]})}const bl={CERTIFIED:{bg:"var(--yellow-muted)",text:"var(--yellow)"},VERIFIED:{bg:"var(--accent-muted)",text:"var(--accent)"},COMMUNITY:{bg:"var(--surface-3)",text:"var(--text-tertiary)"}};function Y1(e,r){return e?e.length>r?e.slice(0,r)+"…":e:""}function J1(e){if(!e)return"";const r=e.trim();if(!r)return"";const n=r.toLowerCase();return n==="0 files"||n==="no files"||n==="no file changes"?"Metadata-only release — no file changes":r}function Q1(){const{state:e}=vt(),{plugin:r,skill:n}=e,s=Pt(),{onSkillUpdated:o,updateCount:a}=s,i=c.useMemo(()=>s.state.skills.find(H=>H.plugin===r&&H.skill===n)??null,[s.state.skills,r,n]),l=`versions-envelope/${r}/${n}`,d=c.useCallback(()=>ce.getSkillVersionsEnvelope(r,n),[r,n]),{data:u,loading:p}=It(l,d),f=(u==null?void 0:u.versions)??[],h=(u==null?void 0:u.provider)??"local",m=(u==null?void 0:u.source)==="none",[g,v]=c.useState(null),[x,b]=c.useState(null),[y,j]=c.useState(null),[S,k]=c.useState(!1),[R,w]=c.useState("idle"),[E,N]=c.useState(null),T=c.useRef(null),I=c.useRef(null),A=c.useMemo(()=>(f==null?void 0:f.find(H=>H.isInstalled))??null,[f]),$=c.useMemo(()=>(f==null?void 0:f[0])??null,[f]),W=A&&$&&A.version!==$.version,C=c.useCallback(H=>{g?!x&&H!==g?b(H):(v(H),b(null),j(null)):(v(H),j(null))},[g,x]),P=c.useCallback(async(H,re)=>{k(!0);try{const V=await ce.getVersionDiff(r,n,H,re);j(V)}catch{j(null)}finally{k(!1)}},[r,n]);c.useEffect(()=>{if(g&&x){const H=f||[],re=H.findIndex(ge=>ge.version===g),V=H.findIndex(ge=>ge.version===x),[O,se]=re>V?[g,x]:[x,g];P(O,se)}},[g,x,f,P]);const L=c.useCallback(()=>{!A||!$||(v(A.version),b($.version))},[A,$]),F=c.useCallback(async()=>{w("updating"),N(null);const H=new AbortController;T.current=H;try{const re=await ce.postSkillUpdate(r,n,H.signal);if(re.ok)w("done"),o(r,n);else{const V=`Update failed (HTTP ${re.status}): ${re.body||"no response body"}`;w("error"),N(V)}}catch(re){if(re instanceof DOMException&&re.name==="AbortError")return;const V=re instanceof Error?re.message:"Network error";w("error"),N(V)}finally{T.current===H&&(T.current=null)}},[r,n,o]);if(c.useEffect(()=>()=>{var H;(H=T.current)==null||H.abort(),T.current=null},[]),p)return t.jsxs("div",{className:"p-5",children:[t.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"skeleton h-14 rounded-lg"}),t.jsx("div",{className:"skeleton h-14 rounded-lg"}),t.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!f||f.length===0){if((i==null?void 0:i.origin)==="source"){const re=W1((i==null?void 0:i.homepage)??null);return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[t.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),t.jsx("div",{className:"text-[13px] text-center mb-5 max-w-md",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:"This skill is local-only — the version history shown here is sourced from verified-skill.com. Submit your skill to start tracking versions and share it with others."}),t.jsx("a",{href:re,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary text-[12px]","data-testid":"versions-empty-state-cta",children:"Submit on verified-skill.com"})]})}return i!=null&&i.version?t.jsxs("div",{className:"p-5",children:[t.jsx("div",{className:"text-[14px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Version History"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),t.jsxs("div",{"data-testid":"version-row-local",className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg",style:{background:"transparent",border:"1px solid transparent"},children:[t.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:10,height:10,background:"var(--accent)",border:"2px solid var(--accent)"}}),t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:i.version}),t.jsx(sa,{provider:h}),t.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]})}),t.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},"data-testid":"versions-no-upstream-message",children:m?"No upstream registry — this skill ships without origin metadata, so update tracking is unavailable.":"Local-only — this skill is not registered on verified-skill.com, so no upstream history is available."})]})]})]}):t.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:t.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),t.jsxs("div",{className:"flex items-center gap-2",children:[W&&t.jsx("button",{onClick:L,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),W&&R!=="done"&&(R==="error"?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:E||"Update failed"}),t.jsx("button",{onClick:F,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):t.jsx("button",{onClick:F,disabled:R!=="idle",className:"btn btn-primary text-[11px]",children:R==="idle"?`Update to ${$==null?void 0:$.version}`:R==="updating"?"Starting update...":R==="scanning"?"Scanning...":"Installing..."})),a>1&&t.jsxs("button",{onClick:()=>{window.location.hash="#/updates"},className:"text-[11px] hover:underline",style:{color:"var(--text-tertiary)",background:"transparent",border:"none",cursor:"pointer"},children:["Manage all updates (",a,")"]})]})]}),g&&!x&&t.jsxs("div",{className:"text-[11px] mb-3 px-3 py-2 rounded-lg",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:["Click another version to compare with ",g]}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),t.jsx("div",{className:"space-y-1",children:f.map(H=>{const re=bl[H.certTier]||bl.COMMUNITY,V=H.version===g||H.version===x,O=H.isInstalled;return t.jsxs("button",{onClick:()=>C(H.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:V?"var(--accent-muted)":"transparent",border:V?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:se=>{V||(se.currentTarget.style.background="var(--surface-1)")},onMouseLeave:se=>{V||(se.currentTarget.style.background="transparent")},children:[t.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:O?10:8,height:O?10:8,background:O?"var(--accent)":"var(--surface-3)",border:O?"2px solid var(--accent)":"2px solid var(--border-default)"}}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:H.version}),t.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:re.bg,color:re.text},children:Eu(H.certTier)}),t.jsx(sa,{provider:h}),O&&t.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(H.createdAt).toLocaleDateString()})]}),(()=>{const se=J1(H.diffSummary);return se?t.jsx("div",{"data-testid":"version-row-diff-summary",className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:Y1(se,80)}):null})()]},H.version)})}),t.jsx("div",{ref:I,style:{height:1}})]}),S&&t.jsx("div",{className:"mt-4",children:t.jsx("div",{className:"skeleton h-48 rounded-xl"})}),y&&!S&&t.jsx("div",{className:"mt-4",children:t.jsx(Oa,{contentDiff:y.contentDiff,fromLabel:y.from,toLabel:y.to,diffSummary:y.diffSummary,renderContext:"inline",onRetry:()=>g&&x&&P(y.from,y.to)})})]})}function X1(e){return e==="timeline"||e==="models"||e==="versions"}function Z1({view:e}){return e==="models"?t.jsx(B1,{}):e==="versions"?t.jsx(Q1,{}):t.jsx(N1,{})}const ns="(?:0|[1-9]\\d*)",Nu="[0-9A-Za-z-]",kl=`(?:${ns}|\\d*[A-Za-z-]${Nu}*)`,jl=`${Nu}+`,e0=`(?:-${kl}(?:\\.${kl})*)`,t0=`(?:\\+${jl}(?:\\.${jl})*)`,r0=new RegExp(`^${ns}\\.${ns}\\.${ns}${e0}?${t0}?$`);function us(e){return typeof e!="string"?!1:r0.test(e.trim())}function n0(){const[e,r]=c.useState(null),[n,s]=c.useState("vskill"),o=c.useRef(!1),a=c.useRef(!1),i=c.useCallback(u=>{o.current=!0,s(u)},[]),l=c.useCallback(async()=>{let u;try{u=await ce.detectEngines()}catch{u={vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null}}r(u),!a.current&&!o.current&&s(u.vskillSkillBuilder?"vskill":u.anthropicSkillCreator?"anthropic-skill-creator":"none"),a.current=!0},[]);c.useEffect(()=>{l()},[l]);const d=n==="none"||!!(n==="vskill"?e!=null&&e.vskillSkillBuilder:e!=null&&e.anthropicSkillCreator);return{engineDetection:e,engine:n,setEngine:i,refreshEngineDetection:l,engineAvailable:d}}function s0(e){const r={prompt:e.prompt,provider:e.provider,model:e.model,...e.engine?{engine:e.engine}:{}};return e.targetAgents&&e.targetAgents.length>0&&(r.targetAgents=e.targetAgents),r}function o0(e){var o;const r=e.userName.trim().length>0,n=e.userPlugin.trim().length>0||e.userNewPlugin.trim().length>0,s=e.forceLayout===3;return{applyName:r?null:e.aiName??null,applySuggestedPlugin:!s&&!n&&!!((o=e.aiSuggestedPlugin)!=null&&o.plugin),suggestedPluginValue:s||n?null:e.aiSuggestedPlugin??null}}function Pr(e,r=!0){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,"-");return r&&(n=n.replace(/^-+|-+$/g,"")),n}function a0(e,r,n,s){const a=`.../${e.split("/").slice(-2).join("/")}`;switch(r){case 1:return`${a}/${n}/skills/${s}/SKILL.md`;case 2:return`${a}/plugins/${n}/skills/${s}/SKILL.md`;case 3:return`${a}/skills/${s}/SKILL.md`}}function i0({onCreated:e,resolveAiConfigOverride:r,forceLayout:n,flushPendingForSkillName:s,updateTarget:o}){const[a,i]=c.useState("ai"),[l,d]=c.useState(null),[u,p]=c.useState(!0),{config:f}=kr(),[h,m]=c.useState(""),[g,v]=c.useState(n??3),[x,b]=c.useState(""),[y,j]=c.useState(""),[S,k]=c.useState(""),[R,w]=c.useState(""),[E,N]=c.useState(""),T=c.useRef({model:!1,allowedTools:!1}),I=c.useCallback(Ie=>{T.current.model=!0,w(Ie)},[]),A=c.useCallback(Ie=>{T.current.allowedTools=!0,N(Ie)},[]),[$,W]=c.useState(""),[C,P]=c.useState("write"),[L,F]=c.useState([]),[H,re]=c.useState(!1),[V,O]=c.useState(null),[se,ge]=c.useState(null),{engineDetection:ye,engine:z,setEngine:ne,refreshEngineDetection:M,engineAvailable:U}=n0(),K=c.useCallback(Ie=>{ne(Ie),Ie==="none"&&i("manual")},[ne]),[X,ie]=c.useState("1.0.0"),[G,te]=c.useState(!0),de=G&&us(X),fe=c.useRef(void 0),[ke,B]=c.useState(!!o),[Y,J]=c.useState(),ee=c.useRef(null);c.useEffect(()=>{z==="none"&&i("manual")},[z]),c.useEffect(()=>{if(!o||!l||ee.current)return;let Ie=!1;return i("manual"),ce.getSkillAuthoringContext(o.plugin,o.skill).then(Ne=>{Ie||(ee.current=Ne,m(Ne.name),k(Ne.description),W(Ne.body),w(Ne.model||""),N(Ne.allowedTools||""),v(Ne.layout),b(Ne.plugin),ie(Ne.version),K(Ne.engine),fe.current=Ne.nativeSkillMd,J(Ne.versionsHref),B(!1))}).catch(Ne=>{Ie||(O(Ne.message),B(!1))}),()=>{Ie=!0}},[o==null?void 0:o.plugin,o==null?void 0:o.skill,l,K]);const[ue,be]=c.useState(""),[Te,Q]=c.useState(!1),[Se,he]=c.useState(!1),[Ce,Ae]=c.useState(null),[Pe,_e]=c.useState(null),[wt,oe]=c.useState([]),$e=c.useRef(null),Fe=c.useRef(null),Ye=c.useRef(null),tt=c.useRef(null),Qe=c.useRef(null),[zt,St]=c.useState(!1),[We,Je]=c.useState(!1),yt=c.useRef(h),ut=c.useRef(x),Kt=c.useRef(y);c.useEffect(()=>{yt.current=h},[h]),c.useEffect(()=>{ut.current=x},[x]),c.useEffect(()=>{Kt.current=y},[y]),c.useEffect(()=>{ce.getProjectLayout().then(Ie=>{if(d(Ie),n)return;v(Ie.suggestedLayout);const Ne=Ie.detectedLayouts.find(Ct=>Ct.layout===Ie.suggestedLayout);Ne!=null&&Ne.existingPlugins.length&&b(Ne.existingPlugins[0])}).catch(()=>{}).finally(()=>p(!1))},[n]),c.useEffect(()=>{var Ie;a==="ai"&&((Ie=$e.current)==null||Ie.focus())},[a]),c.useEffect(()=>()=>{var Ie;(Ie=Fe.current)==null||Ie.abort()},[]);const Bt=c.useMemo(()=>{var Ie;return l?((Ie=l.detectedLayouts.find(Ne=>Ne.layout===g))==null?void 0:Ie.existingPlugins)||[]:[]},[l,g]),Ue=x==="__new__"?y:x,bt=l?a0(l.root,g,Ue||"{plugin}",h||"{skill}"):"",_t=c.useMemo(()=>l?l.detectedLayouts.filter(Ie=>Ie.layout!==4):[],[l]),Ot=c.useMemo(()=>{if(!l)return null;const Ie=l.detectedLayouts.find(kt=>kt.layout===2&&kt.existingPlugins.length>0),Ne=l.detectedLayouts.find(kt=>kt.layout===1&&kt.existingPlugins.length>0),Ct=Ie||Ne;return Ct?{layout:Ct.layout,plugins:Ct.existingPlugins}:null},[l]),Cr=c.useCallback(()=>{if(r)return r();if(!f)return{provider:"claude-cli",model:"sonnet"};const Ie=f.provider||"claude-cli",Ne=f.model||"sonnet";return{provider:Ie,model:Ne}},[f,r]),Ns=c.useCallback(()=>{var Ie;(Ie=Fe.current)==null||Ie.abort(),Q(!1)},[]),Rs=c.useCallback(()=>{Ae(null),_e(null)},[]),Ts=c.useCallback(async()=>{var kt,it;if(Ae(null),_e(null),oe([]),Ye.current=null,tt.current=null,z==="none"){Ae("No engine selected — author the skill in Manual mode");return}if(!U){Ae("Install the selected engine before generating");return}if(!de){Ae("Version is not valid semver");return}if(!ue.trim()){Ae("Describe what your skill should do");return}Q(!0);const Ie=new AbortController;Fe.current=Ie;const{provider:Ne,model:Ct}=Cr();try{const pt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s0({prompt:ue.trim(),provider:Ne,model:Ct,targetAgents:z==="anthropic-skill-creator"?["claude-code"]:L,engine:z})),signal:Ie.signal});if(!pt.ok||!pt.body){let dr=`HTTP ${pt.status}`;try{const ur=await pt.json();ur.error&&(dr=ur.error)}catch{}throw new Error(dr)}const Er=pt.body.getReader(),Ls=new TextDecoder;let qr="",qt="";for(;;){const{done:dr,value:ur}=await Er.read();if(dr)break;qr+=Ls.decode(ur,{stream:!0});const D=qr.split(`
|
|
60
|
+
`);qr=D.pop()||"";for(const ae of D)if(ae.startsWith("event: "))qt=ae.slice(7).trim();else if(ae.startsWith("data: ")){try{const q=JSON.parse(ae.slice(6));if(qt==="progress")oe(Xe=>[...Xe,{phase:q.phase,message:q.message,timestamp:Date.now()}]);else if(qt==="provenance")tt.current={resolvedModelId:typeof q.resolvedModelId=="string"?q.resolvedModelId:null,snapshotDate:typeof q.snapshotDate=="string"?q.snapshotDate:null};else if(qt==="done"||qt==="complete"){const Xe={prompt:ue.trim(),provider:Cr().provider,model:Cr().model,resolvedModelId:((kt=tt.current)==null?void 0:kt.resolvedModelId)??null,snapshotDate:((it=tt.current)==null?void 0:it.snapshotDate)??null,reasoning:q.reasoning||""},De=o0({userName:yt.current,userPlugin:ut.current,userNewPlugin:Kt.current,aiName:q.name,aiSuggestedPlugin:q.suggestedPlugin&&q.suggestedPlugin.plugin?{plugin:q.suggestedPlugin.plugin,layout:q.suggestedPlugin.layout}:null,forceLayout:n});if(De.applyName!==null&&m(De.applyName),k(q.description),I(q.model||""),A(q.allowedTools||""),W(q.body),fe.current=q.nativeSkillMd,he(!0),Ye.current=Xe,i("manual"),n===3)v(3),b(""),j("");else if(De.applySuggestedPlugin&&De.suggestedPluginValue){const lt=De.suggestedPluginValue;if(((l==null?void 0:l.detectedLayouts.flatMap(er=>er.existingPlugins))??[]).includes(lt.plugin))if(b(lt.plugin),lt.layout&&(lt.layout===1||lt.layout===2))v(lt.layout);else{const er=l==null?void 0:l.detectedLayouts.find(op=>op.existingPlugins.includes(lt.plugin));er&&(er.layout===1||er.layout===2)&&v(er.layout)}else b("__new__"),j(lt.plugin)}else!De.applySuggestedPlugin&&ut.current.trim().length===0&&Kt.current.trim().length===0&&g===3&&Ot&&Je(!0);const at={name:q.name,plugin:Ue||"",layout:g,description:q.description,model:q.model||void 0,allowedTools:q.allowedTools||void 0,body:q.body,aiMeta:Xe,engine:z,version:X,nativeSkillMd:q.nativeSkillMd};o||ce.saveDraft(at).then(lt=>{St(!0),lt!=null&<.dir&&(Qe.current=lt.dir)}).catch(()=>{})}else qt==="error"&&(Ae(q.message||q.description||"Unknown error"),q.category&&_e(q))}catch{}qt=""}}}catch(pt){pt.name!=="AbortError"&&Ae(pt.message)}finally{Q(!1),Fe.current=null}},[ue,Cr,g,Ot,Ue,l,L,n,z,U,X,de,o]),Is=c.useCallback(async()=>{var Ie,Ne,Ct,kt;if(O(null),ge(null),!h.trim()){O("Skill name is required");return}if(!S.trim()){O("Description is required");return}if(g!==3&&!Ue.trim()){O("Plugin name is required");return}if(o&&!ee.current){O("Load the existing skill before updating");return}if(!U){O("Install the selected engine before submitting");return}if(!de||!us(X)){O("Version is not valid semver");return}re(!0);try{if(s)try{await s(Pr(h))}catch(pt){O(`Could not finalize previous delete of ${Pr(h)}: ${pt.message}. Cancel the pending delete and try again.`),re(!1);return}const it=await ce.createSkill({name:((Ie=ee.current)==null?void 0:Ie.name)??Pr(h),plugin:((Ne=ee.current)==null?void 0:Ne.plugin)??Ue??"",layout:((Ct=ee.current)==null?void 0:Ct.layout)??g,mode:o?"update":"create",description:S,model:!o||T.current.model?R:void 0,allowedTools:!o||T.current.allowedTools?E:void 0,body:$,aiMeta:z==="none"?void 0:Ye.current||void 0,nativeSkillMd:o||z==="anthropic-skill-creator"?fe.current:void 0,targetAgents:z==="anthropic-skill-creator"?["claude-code"]:L,draftDir:Qe.current||void 0,version:X.trim()||void 0,engine:z});Qe.current=null,e(it.plugin,it.skill)}catch(it){if(it instanceof Jt&&it.status===409&&((kt=it.details)==null?void 0:kt.code)==="skill-already-exists"){const pt=typeof it.details.plugin=="string"?it.details.plugin:"",Er=typeof it.details.skill=="string"?it.details.skill:Pr(h);ge("Skill already existed — opened it."),Qe.current=null,e(pt,Er)}else O(it.message)}finally{re(!1)}},[h,S,g,Ue,R,E,$,X,de,z,U,L,e,s,o]),Kr=c.useCallback(()=>{Ot&&(v(Ot.layout),b(Ot.plugins[0]),Je(!1))},[Ot]);return{authoringMode:o?"update":"create",updateLoading:ke,versionsHref:Y,mode:a,setMode:i,layout:l,layoutLoading:u,selectedLayout:g,setSelectedLayout:v,creatableLayouts:_t,availablePlugins:Bt,pathPreview:bt,plugin:x,setPlugin:b,newPlugin:y,setNewPlugin:j,effectivePlugin:Ue,name:h,setName:m,description:S,setDescription:k,model:R,setModel:I,allowedTools:E,setAllowedTools:A,nativeFieldEdits:{model:!o||T.current.model?R:void 0,allowedTools:!o||T.current.allowedTools?E:void 0},body:$,setBody:W,nativeSkillMd:fe.current,bodyViewMode:C,setBodyViewMode:P,aiPrompt:ue,setAiPrompt:be,generating:Te,aiGenerated:Se,aiError:Ce,aiClassifiedError:Pe,aiProgress:wt,promptRef:$e,handleGenerate:Ts,handleCancelGenerate:Ns,clearAiError:Rs,targetAgents:L,setTargetAgents:F,draftSaved:zt,showPluginRecommendation:We,setShowPluginRecommendation:Je,pluginLayoutInfo:Ot,applyPluginRecommendation:Kr,creating:H,error:V,info:se,handleCreate:Is,engineDetection:ye,refreshEngineDetection:M,engineAvailable:U,engine:z,setEngine:K,version:X,setVersion:ie,versionValid:de,setVersionValid:te,standaloneLocked:n===3}}const l0={flushBySkillName:async()=>{}},Ru=c.createContext(l0);function c0(){return c.useContext(Ru)}function Tu(){return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function d0(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Iu({node:e,depth:r=0}){var n;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${r*16}px`,color:e.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[e.type==="dir"?t.jsx(Tu,{}):t.jsx(d0,{}),t.jsxs("span",{children:[e.name,e.type==="dir"?"/":""]})]}),(n=e.children)==null?void 0:n.map(s=>t.jsx(Iu,{node:s,depth:r+1},s.name))]})}function u0(e,r,n){const s=[];r&&s.push({name:"evals.json",type:"file"}),s.push({name:"history",type:"dir"});const o=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:s}];return n&&o.push({name:"draft.json",type:"file"}),{name:e||"{skill}",type:"dir",children:o}}function p0({skillName:e,hasEvals:r,isDraft:n}){const s=u0(e,r,n);return t.jsxs("div",{className:"glass-card p-4",children:[t.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[t.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:t.jsx(Tu,{})}),"Skill Structure"]}),t.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:t.jsx(Iu,{node:s})})]})}const nr={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function fo({size:e=14,color:r="currentColor"}){return t.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 3l1.912 5.813a2 2 0 001.275 1.275L21 12l-5.813 1.912a2 2 0 00-1.275 1.275L12 21l-1.912-5.813a2 2 0 00-1.275-1.275L3 12l5.813-1.912a2 2 0 001.275-1.275L12 3z"})})}function f0({onCreated:e,onCancel:r}){const{flushBySkillName:n}=c0(),s=i0({onCreated:e,flushPendingForSkillName:n});return t.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[t.jsxs("div",{className:"mb-5",children:[t.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),t.jsx("div",{className:"flex items-center justify-between mt-2",children:t.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[t.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(fo,{size:12}),"AI-Assisted"]})}),t.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),t.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&t.jsxs("div",{className:"space-y-4 animate-fade-in",children:[t.jsxs("div",{className:"glass-card p-4",children:[t.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[t.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:t.jsx(fo,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),t.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
|
|
61
|
+
|
|
62
|
+
Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...nr,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),t.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&t.jsx(An,{entries:s.aiProgress,isRunning:!0}),s.aiError&&t.jsx("div",{children:s.aiClassifiedError?t.jsx(Es,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):t.jsxs("div",{children:[t.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.aiError}),t.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),t.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?t.jsx("button",{onClick:s.handleCancelGenerate,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:"var(--surface-3)",color:"var(--text-secondary)",border:"none",cursor:"pointer"},children:"Cancel Generation"}):t.jsxs("button",{onClick:s.handleGenerate,disabled:!s.aiPrompt.trim(),className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:s.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:s.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:s.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[t.jsx(fo,{size:14}),"Generate"]}),t.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&t.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",t.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&t.jsxs("div",{className:"space-y-4 animate-fade-in",children:[t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&t.jsxs("div",{className:"mb-3",children:[t.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),t.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>t.jsx("button",{onClick:()=>{s.setSelectedLayout(o.layout),s.setPlugin(o.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===o.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===o.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===o.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:o.label},o.layout))})]}),s.selectedLayout!==3&&t.jsxs("div",{className:"mb-3",children:[t.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),t.jsxs("select",{value:s.plugin,onChange:o=>{s.setPlugin(o.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:nr,children:[s.availablePlugins.map(o=>t.jsx("option",{value:o,children:o},o)),t.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&t.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(Pr(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:nr})]}),t.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&t.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),t.jsxs("span",{children:["Plugins detected (",t.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[t.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),t.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),t.jsxs("div",{className:"glass-card p-4",children:[t.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),t.jsxs("div",{className:"mb-3",children:[t.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",t.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),t.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(Pr(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:nr})]}),t.jsxs("div",{className:"mb-3",children:[t.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",t.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),t.jsx("textarea",{value:s.description,onChange:o=>s.setDescription(o.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...nr,minHeight:"72px"}})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),t.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:nr,children:[t.jsx("option",{value:"",children:"Any"}),t.jsx("option",{value:"opus",children:"Opus"}),t.jsx("option",{value:"sonnet",children:"Sonnet"}),t.jsx("option",{value:"haiku",children:"Haiku"})]})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),t.jsx("input",{type:"text",value:s.allowedTools,onChange:o=>s.setAllowedTools(o.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:nr})]})]})]}),t.jsxs("div",{className:"glass-card p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{children:[t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),t.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),t.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>t.jsxs("button",{onClick:()=>s.setBodyViewMode(o),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===o?"var(--surface-4)":"transparent",color:s.bodyViewMode===o?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===o?600:400,border:"none",cursor:"pointer"},children:[o==="write"?t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"16 18 22 12 16 6"}),t.jsx("polyline",{points:"8 6 2 12 8 18"})]}):t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),t.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?t.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
|
|
63
|
+
|
|
64
|
+
You are an expert at...
|
|
65
|
+
`,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...nr,minHeight:"150px"}}):s.body.trim()?t.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Ln(s.body)}}):t.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:t.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),t.jsx(p0,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&t.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),t.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function wl(){return t.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),t.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),t.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function ln({variant:e,message:r,onRetry:n}){const{setMode:s,setSearch:o}=Pt(),[a,i]=c.useState(!1);return e==="no-selection"?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[t.jsx("div",{className:"mb-5",children:a?t.jsx(wl,{}):t.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>i(!0),style:{objectFit:"contain"}})}),t.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),t.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):e==="no-skills"?t.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[t.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:t.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),t.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),t.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",t.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),t.jsxs("button",{onClick:()=>s("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:l=>{l.currentTarget.style.opacity="0.9"},onMouseLeave:l=>{l.currentTarget.style.opacity="1"},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):e==="no-project-skills"?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in","data-testid":"empty-state-no-project-skills",children:[t.jsx("div",{className:"mb-5",children:a?t.jsx(wl,{}):t.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>i(!0),style:{objectFit:"contain"}})}),t.jsx("p",{className:"text-[15px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No skills installed for this project yet."}),t.jsx("p",{className:"text-[12px] mb-5",style:{color:"var(--text-tertiary)",maxWidth:360,textAlign:"center"},children:"Browse the marketplace to install one, or author a new skill from scratch."}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{type:"button","data-testid":"empty-state-browse-marketplaces",onClick:()=>{window.dispatchEvent(new CustomEvent("studio:open-marketplace"))},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},"aria-label":"Browse marketplaces",children:[t.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:[t.jsx("circle",{cx:"9",cy:"21",r:"1"}),t.jsx("circle",{cx:"20",cy:"21",r:"1"}),t.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]}),"Browse marketplaces"]}),t.jsxs("button",{type:"button","data-testid":"empty-state-create-skill",onClick:()=>s("create"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-primary)",border:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer"},"aria-label":"Create new skill",children:[t.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:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create new skill"]})]})]}):e==="error"?t.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:t.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[t.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:r||"Failed to load skill data"}),n&&t.jsx("button",{onClick:n,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):t.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[t.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),t.jsx("button",{onClick:()=>o(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function h0(e,r){const[n,s]=e.split(".").map(Number),[o,a]=r.split(".").map(Number);return o>n?"major":a>s?"minor":"patch"}const m0={major:{bg:"var(--red-muted)",text:"var(--red)"},minor:{bg:"var(--yellow-muted)",text:"var(--yellow)"},patch:{bg:"var(--green-muted)",text:"var(--green)"}};function Lu(){const[e,r]=c.useState([]),[n,s]=c.useState(!0),[o,a]=c.useState(new Set),[i,l]=c.useState(new Map),[d,u]=c.useState(!1),[p,f]=c.useState(new Set),[h,m]=c.useState(new Map),[g,v]=c.useState(null),[x,b]=c.useState(null),[y,j]=c.useState(!1),S=c.useCallback(async()=>{s(!0);try{const I=await ce.getSkillUpdates();r(I.filter(A=>A.updateAvailable))}catch{r([])}finally{s(!1)}},[]);c.useEffect(()=>{S()},[S]);const k=c.useMemo(()=>e.filter(I=>!I.pinned),[e]),R=c.useCallback(I=>{a(A=>{const $=new Set(A);return $.has(I)?$.delete(I):$.add(I),$})},[]),w=c.useCallback(()=>{o.size===k.length?a(new Set):a(new Set(k.map(I=>I.name)))},[o,k]),E=c.useCallback(()=>{const I=[...o];if(!I.length)return;u(!0),l(new Map(I.map($=>[$,{skill:$,status:"pending"}])));const A=ce.startBatchUpdate(I);A.addEventListener("progress",$=>{try{const W=JSON.parse($.data);l(C=>new Map(C).set(W.skill,W))}catch{}}),A.addEventListener("done",$=>{A.close(),u(!1);try{const W=JSON.parse($.data);v(`Updated ${W.updated??0} skills, ${W.failed??0} failed`),setTimeout(()=>v(null),5e3)}catch{}S()}),A.addEventListener("error",()=>{A.close(),u(!1),v("Batch update failed"),setTimeout(()=>v(null),5e3)})},[o,S]),N=c.useCallback(async I=>{const A=I.name.split("/"),$=A.length>=3?A[A.length-2]:A[0],W=A[A.length-1];f(C=>new Set(C).add(I.name)),m(C=>{const P=new Map(C);return P.delete(I.name),P});try{const C=await ce.postSkillUpdate($,W);if(C.ok)S();else{const P=`Update failed (HTTP ${C.status}): ${C.body}`;m(L=>new Map(L).set(I.name,P)),v(`Couldn't update ${W} — HTTP ${C.status}`),setTimeout(()=>v(null),5e3)}}catch(C){const P=C instanceof Error?C.message:"Network error";m(L=>new Map(L).set(I.name,P)),v(`Couldn't update ${W} — ${P}`),setTimeout(()=>v(null),5e3)}finally{f(C=>{const P=new Set(C);return P.delete(I.name),P})}},[S]),T=c.useCallback(async I=>{if(!I.latest)return;const A=I.name.split("/"),$=A.length>=3?A[A.length-2]:A[0],W=A[A.length-1];j(!0);try{const C=await ce.getVersionDiff($,W,I.installed,I.latest);b({skill:I,diff:C})}catch{b(null)}finally{j(!1)}},[]);return n?t.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[t.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"skeleton h-16 rounded-lg"}),t.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):e.length===0?t.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[t.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[t.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),t.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),t.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),t.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),t.jsx("button",{onClick:S,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):t.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[g&&t.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:g}),t.jsxs("div",{className:"flex items-center justify-between mb-5",children:[t.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",k.length,")"]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:S,className:"btn btn-ghost text-[12px]",disabled:d,children:"Refresh"}),t.jsx("button",{onClick:E,disabled:o.size===0||d,className:"btn btn-primary text-[12px]",children:d?"Updating...":`Update Selected (${o.size})`})]})]}),t.jsx("div",{className:"flex items-center gap-2 mb-3",children:t.jsxs("button",{onClick:w,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[t.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:o.size===k.length&&k.length>0?"var(--accent)":"var(--border-default)",background:o.size===k.length&&k.length>0?"var(--accent)":"transparent"},children:o.size===k.length&&k.length>0&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),t.jsx("div",{className:"space-y-2",children:e.map(I=>{const A=I.name.split("/").pop()||I.name,$=I.latest?h0(I.installed,I.latest):"patch",W=m0[$],C=!!I.pinned,P=p.has(I.name),L=i.get(I.name),F=o.has(I.name);return t.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:C?.7:1},children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>!C&&R(I.name),disabled:C,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:C?"not-allowed":"pointer"},children:t.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:F?"var(--accent)":"var(--border-default)",background:F?"var(--accent)":"transparent",opacity:C?.4:1},children:F&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:A}),C&&t.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),t.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:W.bg,color:W.text},children:$})]}),t.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[I.installed," → ",I.latest||"?",C&&` (pinned at ${I.pinnedVersion||I.installed})`]})]}),L&&t.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:L.status==="done"?"var(--green-muted)":L.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:L.status==="done"?"var(--green)":L.status==="error"?"var(--red)":"var(--yellow)"},children:[L.status,L.error&&`: ${L.error}`]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[t.jsx("button",{onClick:()=>T(I),className:"btn btn-ghost text-[11px]",disabled:y,children:"View Changes"}),t.jsx("button",{onClick:()=>N(I),disabled:C||P||d,title:C?"Pinned — unpin from CLI to update":"",className:`btn ${C?"btn-ghost":"btn-primary"} text-[11px]`,children:P?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(L==null?void 0:L.status)==="done"?t.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},I.name)})}),x&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>b(null),children:t.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:I=>I.stopPropagation(),children:[t.jsx("div",{className:"mb-2 flex justify-end",children:t.jsx("button",{onClick:()=>b(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),t.jsx(Oa,{contentDiff:x.diff.contentDiff,fromLabel:x.diff.from,toLabel:x.diff.to,diffSummary:x.diff.diffSummary,renderContext:"inline"})]})})]})}const x0=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:Lu},Symbol.toStringTag,{value:"Module"}));function g0(e){return e==null?"var(--text-tertiary)":e>=.7?"var(--green)":e>=.4?"var(--yellow)":"var(--red)"}function v0(e){return e==null?"var(--surface-3)":e>=.7?"var(--green-muted)":e>=.4?"var(--yellow-muted)":"var(--red-muted)"}function y0(e){if(!e||typeof e!="string")return null;const r=e.trim();if(!r)return null;if(!r.includes("://")){const[n]=r.split("/");return n&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(n)?n:null}try{const n=new URL(r),s=n.hostname.toLowerCase();if(s!=="github.com"&&s!=="www.github.com"&&s!=="raw.githubusercontent.com")return null;const a=n.pathname.split("/").filter(Boolean)[0];return!a||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(a)?null:a}catch{return null}}function Au(e){const{author:r,repoUrl:n}=e,s=y0(n??null),o=r&&r.trim()!==""?r:s??"—",[a,i]=c.useState(!1),l=c.useCallback(async()=>{var d;try{await((d=navigator.clipboard)==null?void 0:d.writeText(o)),i(!0),setTimeout(()=>i(!1),1500)}catch{}},[o]);return s?t.jsx("a",{"data-testid":e["data-testid"]??"author-link",href:`https://github.com/${s}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:o}):!r||r.trim()===""?t.jsx("span",{"data-testid":e["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):t.jsxs("button",{type:"button","data-testid":e["data-testid"]??"author-copy",title:`Copy "${o}"`,onClick:l,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[o,t.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:a?"✓":"⧉"})]})}function Pu(e){let r=e.split("#")[0].split("?")[0].replace(/\/+$/,"");return r=r.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),r}function b0(e,r){const n=Pu(e),s=(r??"").replace(/^\/+/,"").replace(/\/+$/,"");return s?`${n}/blob/HEAD/${s}`:`${n}/blob/HEAD/`}function Sl(e){if(!e)return"source";const r=e.replace(/\/+$/,""),n=r.lastIndexOf("/");return n===-1?r:r.slice(n+1)}function $u(e){const{repoUrl:r,skillPath:n,absolutePath:s}=e,[o,a]=c.useState(!1),i=typeof r=="string"&&r.trim()!==""&&/^https?:\/\//.test(r.trim()),l=n?Sl(n):s?Sl(s):"source",d=c.useCallback(async()=>{var f;const p=s??n??"";if(p)try{await((f=navigator.clipboard)==null?void 0:f.writeText(p)),a(!0),setTimeout(()=>a(!1),1500)}catch{}},[s,n]);if(i){const p=b0(r,n);return t.jsxs("a",{"data-testid":e["data-testid"]??"source-file-link",href:p,target:"_blank",rel:"noopener noreferrer",title:p,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[t.jsx("span",{children:l}),t.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!s&&!n)return t.jsx("span",{"data-testid":e["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const u=s??n??"";return t.jsxs("button",{type:"button","data-testid":e["data-testid"]??"source-file-copy",title:`Copy ${u}`,onClick:d,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.jsx("span",{children:l}),t.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:o?"✓":"⧉"})]})}const k0=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/,j0=/^[A-Za-z0-9._-]+$/;function w0(e){if(!e||typeof e!="string")return null;const r=e.trim();if(!r)return null;let n;try{n=Pu(r)}catch{return null}let s;try{s=new URL(n)}catch{return null}const o=s.hostname.toLowerCase();if(o!=="github.com"&&o!=="www.github.com")return null;const a=s.pathname.split("/").filter(Boolean);if(a.length!==2)return null;const i=a[0],l=a[1].replace(/\.git$/i,"");return!k0.test(i)||!l||!j0.test(l)?null:{owner:i,repo:l}}function S0(e){return!e||typeof e!="string"?null:e.trim().split("/").map(n=>n.trim()).filter(Boolean).at(-1)??null}function C0(e,r){const n=S0(r);return n?`https://verified-skill.com/skills/${[e.owner,e.repo,n].map(encodeURIComponent).join("/")}`:null}function E0(e){const r=w0(e.repoUrl??null);if(!r)return null;const n=C0(r,e.skillName)??`https://github.com/${r.owner}/${r.repo}`;return t.jsxs("a",{"data-testid":e["data-testid"]??"repo-link",href:n,target:"_blank",rel:"noopener noreferrer",title:n,style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:[r.owner,"/",r.repo]})}function Cl(e,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function Mu(e){return e.skill?R0({skill:e.skill,repoVisibility:e.repoVisibility,tenantName:e.tenantName}):I0({state:e.state,isReadOnly:e.isReadOnly,onDelete:e.onDelete})}function N0(e,r=48){if(e.length<=r)return e;const n=e.slice(0,12),s=e.slice(e.length-(r-12-1));return`${n}…${s}`}function R0({skill:e,repoVisibility:r,tenantName:n}){const[s,o]=c.useState(!1),a=r==="private",i=(e.sourcePath??e.dir)||"—",l=c.useCallback(async()=>{var p;try{await((p=navigator.clipboard)==null?void 0:p.writeText(i)),o(!0),setTimeout(()=>o(!1),1500),Cl(_.toasts.pathCopied,"info")}catch{Cl(_.toasts.permissionDenied,"error")}},[i]),d=e.source==="project"?"Project":e.source==="personal"?"Personal":e.source==="plugin"?"Plugins":e.origin==="installed"?"Personal":"Skills",u=e.source==="project"?"var(--status-installed)":e.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)";return t.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[t.jsx("span",{"data-testid":"detail-header-plugin",children:e.plugin}),t.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[t.jsx("span",{"data-origin-dot":e.origin,"aria-label":`Origin: ${d}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),d]}),a&&t.jsx("span",{style:{marginLeft:"auto"},children:t.jsx(lv,{tenantName:n??"your org",variant:"inline"})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[t.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:e.skill}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{"data-testid":"detail-header-version",children:t.jsx(Rn,{version:e.resolvedVersion??e.version??null,source:e.versionSource,pluginName:e.pluginName??null})}),e.pluginName&&e.pluginVersion&&t.jsxs("span",{"data-testid":"detail-header-plugin-chip",title:`This skill ships in plugin ${e.pluginName} v${e.pluginVersion}. The plugin version is independent of this skill's own version track.`,style:{display:"inline-flex",alignItems:"baseline",gap:4,fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-tertiary)",padding:"2px 6px",borderRadius:4,background:"var(--surface-1, transparent)",border:"1px solid var(--border-subtle, transparent)",whiteSpace:"nowrap"},children:[t.jsx("span",{children:"from"}),t.jsx("span",{style:{color:"var(--text-secondary)"},children:e.pluginName}),t.jsx("span",{"aria-hidden":"true",children:"@"}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",color:"var(--text-secondary)"},children:e.pluginVersion})]}),e.origin==="source"&&t.jsx("button",{type:"button","data-testid":"detail-header-delete","aria-label":"Delete skill",title:"Delete skill",onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:e}}))},className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:4,borderRadius:4},onMouseEnter:p=>{p.currentTarget.style.color="var(--red)"},onMouseLeave:p=>{p.currentTarget.style.color="var(--text-tertiary)"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),t.jsx("path",{d:"M10 11v6"}),t.jsx("path",{d:"M14 11v6"}),t.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]}),t.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[t.jsx(Au,{author:e.author??null,repoUrl:e.repoUrl??e.homepage??null}),t.jsx(E0,{repoUrl:e.repoUrl??null,skillName:e.skill}),t.jsx($u,{repoUrl:e.repoUrl??null,skillPath:e.skillPath??null,absolutePath:e.dir})]}),t.jsx(T0,{skill:e}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:i,"aria-label":`Copy path ${i} to clipboard`,onClick:l,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:N0(i)}),t.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:l,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),s?"Copied":"Copy"]})]})]})}function T0({skill:e}){const r=e.installMethod,n=e.symlinkTarget;if(!r)return null;let s="";switch(r){case"symlinked":s=n?`Symlinked from ${n}`:"Symlinked (target unresolved)";break;case"copied":s="Copied (independent)";break;case"authored":s="Authored";break;default:return null}return t.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[t.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),t.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:s})]})}function I0({state:e,isReadOnly:r,onDelete:n}){const{plugin:s,skill:o,evals:a,latestBenchmark:i,isDirty:l,caseRunStates:d,regressions:u,iterationCount:p}=e,f=Array.from(d.values()).some(b=>b.status==="running"||b.status==="queued"),h=i==null?void 0:i.overall_pass_rate,m=(a==null?void 0:a.evals.reduce((b,y)=>b+y.assertions.length,0))??0,g=(a==null?void 0:a.evals.length)??0,v=g0(h),x=v0(h);return t.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[t.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[t.jsx("span",{style:{color:"var(--text-tertiary)"},children:s}),t.jsx(L0,{}),t.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:o}),r&&t.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),l&&t.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),f&&t.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[t.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[!r&&n&&t.jsx("button",{disabled:f,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:s,skill:o,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:f?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:f?.4:1,borderRadius:4},onMouseEnter:b=>{f||(b.currentTarget.style.color="var(--red)")},onMouseLeave:b=>{b.currentTarget.style.color="var(--text-tertiary)"},children:t.jsx(A0,{})}),u.length>0&&t.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),u.length," regression",u.length>1?"s":""]}),p>0&&t.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",p]}),t.jsx("span",{className:"pill",style:{background:x,color:v},children:h!=null?`${Math.round(h*100)}%`:"--"}),t.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[g," case",g!==1?"s":""," / ",m," assert",m!==1?"s":""]})]})]})}function L0(){return t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})}function A0(){return t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),t.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),t.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function sr(e){const{title:r,label:n,value:s,subtitle:o,description:a,linkLabel:i,children:l,onClick:d}=e,u=r??n??"",p=typeof d=="function",f=h=>{p&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),d==null||d())};return t.jsxs("div",{className:p?"metric-card metric-card-link":"metric-card","data-testid":e["data-testid"],role:p?"button":void 0,tabIndex:p?0:void 0,onClick:p?()=>d==null?void 0:d():void 0,onKeyDown:p?f:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:p?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[u?t.jsx("div",{"data-testid":e["data-testid"]?`${e["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:u}):null,t.jsx("div",{"data-testid":e["data-testid"]?`${e["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(s)}),o?t.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:o}):null,a?t.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:a}):null,l?t.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:l}):null,i?t.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:i}):null]})}const P0="Benchmarks are the aggregated score of this skill's evals (evals.yaml) run against its tests (tests/). Each test case produces a verdict; the benchmark is the mean pass rate.";function $0(e){const{onNavigate:r}=e,[n,s]=c.useState(e.open??!1),o=c.useCallback(()=>s(!1),[]);c.useEffect(()=>{if(!n)return;const i=l=>{l.key==="Escape"&&o()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n,o]);const a=c.useCallback(i=>{r==null||r(i),s(!1)},[r]);return t.jsxs("span",{"data-testid":e["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[t.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!n,onClick:()=>s(i=>!i),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),n&&t.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[t.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:P0}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>a("tests"),style:ho,children:"Tests →"}),t.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>a("run"),style:ho,children:"Run →"}),t.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:o,style:{...ho,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const ho={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function M0(e){return`gh repo create ${e.trim()||"<repo-name>"} --public --source=. --remote=origin --push`}const F0="Add a GitHub remote: `gh repo create --public --source=.` (replace existing origin if needed).";function D0({value:e}){const[r,n]=c.useState(!1),s=c.useCallback(async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},[e]);return t.jsx("button",{type:"button","data-testid":"publish-status-copy","aria-label":"Copy GitHub setup command",onClick:s,style:{fontSize:11,padding:"3px 8px",borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",background:"var(--surface-2)",color:"var(--text-primary)",cursor:"pointer"},children:r?"Copied":"Copy"})}function El({tone:e,label:r}){const n=e==="ok"?"color-mix(in srgb, var(--color-ok, #22c55e) 18%, transparent)":"color-mix(in srgb, var(--color-own, #f59e0b) 18%, transparent)",s=e==="ok"?"var(--color-ok, #22c55e)":"var(--color-own, #f59e0b)";return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:999,fontSize:11,fontWeight:500,color:s,background:n},children:r})}function z0(e={}){const{status:r,loading:n}=Ud(),s=lu();if(n||!r)return null;if(r.status==="github")return t.jsxs("div",{"data-testid":"publish-status-row","data-status":"github",style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[t.jsx(El,{tone:"ok",label:"Publish-ready"}),t.jsxs("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:["GitHub origin: ",r.githubOrigin]}),t.jsx("div",{style:{marginLeft:"auto"},children:t.jsx(iu,{remoteUrl:r.githubOrigin??"",provider:e.provider,model:e.model,skillName:e.skillName,skillPath:e.skillPath,privacy:"public",tenantId:s.tenantId,tenantSelection:s})})]});const o=r.status==="no-git"?M0(e.projectBasename??""):F0;return t.jsxs("div",{"data-testid":"publish-status-row","data-status":r.status,style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx(El,{tone:"warn",label:r.status==="no-git"?"No GitHub repo yet":"Origin is not GitHub"}),t.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Connect GitHub to publish your skills."})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("code",{"data-testid":"publish-status-command",style:{flex:1,minWidth:0,padding:"6px 10px",borderRadius:4,background:"var(--surface-2)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:o}),t.jsx(D0,{value:o})]})]})}function B0({plugin:e,skill:r}){const[n,s]=c.useState([]),[o,a]=c.useState([]),[i,l]=c.useState(!0),[d,u]=c.useState(null);c.useEffect(()=>{ce.getDependencies(e,r).then(f=>{s(f.mcpDependencies),a(f.skillDependencies)}).catch(()=>{}).finally(()=>l(!1))},[e,r]);async function p(f,h){try{await navigator.clipboard.writeText(h),u(f),setTimeout(()=>u(null),2e3)}catch{}}return i?null:n.length===0&&o.length===0?t.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):t.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.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"}),t.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"})]})}),t.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),t.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:n.length+o.length})]}),t.jsxs("div",{className:"px-5 py-4",children:[n.length>0&&t.jsxs("div",{className:"space-y-3 mb-4",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),n.map(f=>t.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:f.server}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:f.transport})]}),t.jsx("button",{onClick:()=>p(f.server,f.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:d===f.server?"var(--green)":"var(--accent)"},children:d===f.server?t.jsxs(t.Fragment,{children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):t.jsxs(t.Fragment,{children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),t.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:f.url}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.matchedTools.map(h=>t.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:h},h))})]},f.server))]}),o.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),t.jsx("div",{className:"space-y-1.5",children:o.map(f=>t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),t.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:f.name}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:f.source==="frontmatter"?"frontmatter":"referenced"})]},f.name))})]})]})]})}const _0="https://verified-skill.com/docs/parameters-and-secrets",O0="Stored as KEY=value in this skill's local .env.local (gitignored). Resolved from process.env first, then .env.local.";function Nl({onToggleAdd:e,addFormOpen:r}){return t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wider flex items-center gap-1.5",style:{color:"var(--text-tertiary)"},children:["Parameters & Secrets",t.jsx("span",{"aria-label":"About Parameters & Secrets",title:O0,style:{cursor:"help",fontSize:11,color:"var(--text-tertiary)",opacity:.7,display:"inline-block",lineHeight:1},children:"ⓘ"})]}),t.jsx("button",{onClick:e,"aria-pressed":r,className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]})}function W0(){return t.jsxs("div",{className:"px-4 py-5 rounded-xl flex flex-col gap-2",style:{background:"var(--surface-2)"},children:[t.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-secondary)"},children:"No parameters yet"}),t.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:["Values are stored as ",t.jsx("code",{style:{fontSize:11},children:"KEY=value"})," in this skill's local"," ",t.jsx("code",{style:{fontSize:11},children:".env.local"})," (auto-added to"," ",t.jsx("code",{style:{fontSize:11},children:".gitignore"}),"). They appear here when declared as"," ",t.jsx("code",{style:{fontSize:11},children:"requiredCredentials"})," in"," ",t.jsx("code",{style:{fontSize:11},children:"evals.json"}),", or when you add custom ones below."]}),t.jsx("a",{href:_0,target:"_blank",rel:"noopener noreferrer",className:"text-[11px]",style:{color:"var(--accent)",textDecoration:"none"},children:"Learn more →"})]})}function U0({plugin:e,skill:r}){const[n,s]=c.useState([]),[o,a]=c.useState(!0),[i,l]=c.useState(null),[d,u]=c.useState(""),[p,f]=c.useState(!1),[h,m]=c.useState(null),[g,v]=c.useState(""),[x,b]=c.useState(""),[y,j]=c.useState(!1),[S,k]=c.useState(new Set),R=c.useCallback(async()=>{a(!0);try{const[T,I]=await Promise.all([ce.getCredentials(e,r).catch(()=>({credentials:[]})),ce.getParams(e,r).catch(()=>({params:[]}))]),A=new Map(I.params.map(C=>[C.name,C])),$=new Set,W=[];for(const C of T.credentials){$.add(C.name);const P=A.get(C.name);W.push({name:C.name,status:C.status==="ready"||C.status==="resolved"?"ready":"missing",source:C.source,maskedValue:P==null?void 0:P.maskedValue})}for(const C of I.params)$.has(C.name)||W.push({name:C.name,status:C.status,maskedValue:C.maskedValue});s(W)}finally{a(!1)}},[e,r]);c.useEffect(()=>{R()},[R]);const w=c.useCallback(async T=>{if(S.has(T)){k(I=>{const A=new Set(I);return A.delete(T),A}),s(I=>I.map(A=>A.name===T?{...A,revealedValue:void 0}:A));return}try{const A=(await ce.getParamsRevealed(e,r,T)).params.find($=>$.name===T);A&&(s($=>$.map(W=>W.name===T?{...W,revealedValue:A.value}:W)),k($=>new Set($).add(T)))}catch{}},[e,r,S]),E=async(T,I)=>{if(!(!T.trim()||!I.trim())){f(!0),m(null);try{await ce.setCredential(e,r,T,I),l(null),u(""),k(new Set),R()}catch(A){m(A.message)}finally{f(!1)}}},N=async()=>{if(!(!g.trim()||!x.trim())){f(!0),m(null);try{await ce.setCredential(e,r,g.trim().toUpperCase(),x),v(""),b(""),j(!1),R()}catch(T){m(T.message)}finally{f(!1)}}};return o?t.jsxs("div",{className:"mt-6",children:[t.jsx(Nl,{onToggleAdd:()=>{},addFormOpen:!1}),t.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):t.jsxs("div",{className:"mt-6",children:[t.jsx(Nl,{onToggleAdd:()=>j(!y),addFormOpen:y}),h&&t.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:h}),n.length===0&&!y?t.jsx(W0,{}):t.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:n.map(T=>t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[t.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:T.name}),T.maskedValue&&t.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:S.has(T.name)&&T.revealedValue!=null?T.revealedValue:T.maskedValue}),T.maskedValue&&t.jsx("button",{onClick:()=>w(T.name),className:"btn btn-ghost px-1",title:S.has(T.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:S.has(T.name)?t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),t.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),t.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:T.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:T.status==="ready"?"var(--green)":"var(--orange)"},children:T.status==="ready"?"ready":"missing"}),T.source&&t.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:T.source}),i===T.name?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{value:d,onChange:I=>u(I.target.value),onKeyDown:I=>{I.key==="Enter"&&E(T.name,d)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),t.jsx("button",{onClick:()=>E(T.name,d),disabled:p||!d.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:p?"...":"Save"}),t.jsx("button",{onClick:()=>{l(null),u("")},className:"btn btn-ghost text-[10px] px-1",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):t.jsx("button",{onClick:()=>{l(T.name),u("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},T.name))}),y&&t.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx("input",{value:g,onChange:T=>v(T.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),t.jsx("input",{value:x,onChange:T=>b(T.target.value),onKeyDown:T=>{T.key==="Enter"&&N()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),t.jsxs("div",{className:"flex justify-end gap-1.5",children:[t.jsx("button",{onClick:()=>{j(!1),v(""),b("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),t.jsx("button",{onClick:N,disabled:p||!g.trim()||!x.trim(),className:"btn btn-primary text-[10px]",children:p?"Saving...":"Save"})]})]})]})}function Rl({children:e}){return t.jsx("h3",{style:{fontFamily:"var(--font-sans)",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:"var(--text-tertiary)",margin:"0 0 8px"},children:e})}function H0({plugin:e,skill:r}){return t.jsxs("aside",{"data-testid":"skill-overview-rightrail",style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("section",{"data-testid":"overview-rightrail-setup",children:[t.jsx(Rl,{children:"Setup"}),t.jsx(B0,{plugin:e,skill:r})]}),t.jsxs("section",{"data-testid":"overview-rightrail-credentials",children:[t.jsx(Rl,{children:"Credentials"}),t.jsx(U0,{plugin:e,skill:r})]})]})}function V0(e){if(e==null||!Number.isFinite(e))return"—";if(e<1024)return`${e} B`;const r=e/1024;if(r<1024)return r>=10?`${Math.round(r)} KB`:`${r.toFixed(1).replace(/\.0$/,"")} KB`;const n=r/1024;return n>=10?`${Math.round(n)} MB`:`${n.toFixed(1).replace(/\.0$/,"")} MB`}function tn(e){if(!e)return"—";const r=new Date(e);if(Number.isNaN(r.getTime()))return e;const n=Date.now()-r.getTime(),s=Math.floor(n/1e3);if(s<60)return"just now";const o=Math.floor(s/60);if(o<60)return`${o} min ago`;const a=Math.floor(o/60);if(a<24)return`${a} hr ago`;const i=Math.floor(a/24);if(i<30)return`${i} day${i===1?"":"s"} ago`;const l=Math.floor(i/30);if(l<12)return`${l} month${l===1?"":"s"} ago`;const d=Math.floor(l/12);return`${d} year${d===1?"":"s"} ago`}function G0(e){switch(e.benchmarkStatus){case"pass":case"fail":case"stale":return e.benchmarkStatus==="pass"?"100%":e.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function K0(e){const r=e.installMethod;if(!r)return null;const n=r==="authored"?"Authored":r==="copied"?"Copied":"Symlinked";return t.jsx("span",{"data-testid":"overview-install-method",style:{display:"inline-flex",alignItems:"center",padding:"1px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:10,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:.4},children:n})}function q0(e,r){const n=e.evalCount??0;return!e.hasEvals||n<=0?null:t.jsxs("button",{type:"button","data-testid":"overview-tests-chip",onClick:r?()=>r("run"):void 0,title:`Open Run tab — ${n} test case${n===1?"":"s"}`,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",border:"1px solid var(--border-default, var(--border))",borderRadius:9999,fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)",background:"transparent",cursor:r?"pointer":"default"},children:[n," ",n===1?"test":"tests"]})}function Y0(e){var f,h;const{skill:r,onNavigate:n,activationsCount:s=0,lastRunIso:o=null,repoUrl:a,skillPathInRepo:i}=e,l=a??(J0(r.homepage)?r.homepage??null:null),d=((f=r.mcpDeps)==null?void 0:f.length)??0,u=((h=r.deps)==null?void 0:h.length)??0,p=t.jsxs("div",{"data-testid":"skill-overview-main",style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:r.skill}),t.jsx(Rn,{version:r.resolvedVersion??r.version??null,source:r.versionSource,pluginName:r.pluginName??null}),r.origin==="source"&&!r.pluginMarketplace&&t.jsx("a",{"data-testid":"authoring-update-link",href:`#/create?${new URLSearchParams({mode:"update",skillName:r.skill,pluginName:r.plugin})}`,children:"Edit version and skill"}),K0(r),q0(r,n)]}),t.jsxs("div",{"data-testid":"skill-overview-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[t.jsx(Au,{author:r.author??null,repoUrl:l}),r.category?t.jsxs("span",{children:["· ",r.category]}):null,t.jsx($u,{repoUrl:l,skillPath:i??null,absolutePath:r.dir}),r.lastModified?t.jsxs("span",{title:r.lastModified,children:["· Updated ",tn(r.lastModified)]}):null]})]}),r.origin!=="installed"&&!r.pluginMarketplace&&r.installMethod!=="copied"&&r.installMethod!=="symlinked"&&t.jsx(z0,{skillName:r.skill,skillPath:r.skillPath??void 0}),t.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[t.jsx(sr,{title:"Benchmark",value:G0(r),subtitle:r.lastBenchmark?tn(r.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:n?()=>n("run"):void 0,children:t.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:t.jsx($0,{onNavigate:n})})}),t.jsx(sr,{title:"Tests",value:r.evalCount??0,subtitle:`${r.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:n?()=>n("tests"):void 0}),t.jsx(sr,{title:"Activations",value:s,subtitle:o?`Last: ${tn(o)}`:"Never","data-testid":"metric-activations",onClick:n?()=>n("activation"):void 0}),t.jsx(sr,{title:"Last run",value:tn(o??r.lastBenchmark??null),"data-testid":"metric-last-run",onClick:n?()=>n("history"):void 0}),t.jsx(sr,{title:"MCP deps",value:d,subtitle:d>0&&r.mcpDeps?r.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:n?()=>n("deps"):void 0}),t.jsx(sr,{title:"Skill deps",value:u,subtitle:u>0&&r.deps?r.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:n?()=>n("deps"):void 0}),t.jsx(sr,{title:"Size",value:V0(r.sizeBytes),"data-testid":"metric-size"}),t.jsx(sr,{title:"Last modified",value:tn(r.lastModified),subtitle:r.lastModified??void 0,"data-testid":"metric-last-modified"})]})]});return t.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 280px",gap:16,padding:16,alignItems:"start"},children:[p,t.jsx(H0,{plugin:r.plugin,skill:r.skill})]})}function J0(e){return e?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(e):!1}function Q0({skill:e}){const{onSkillUpdated:r}=Pt(),{toast:n}=ys(),[s,o]=c.useState("idle"),[a,i]=c.useState(null),[l,d]=c.useState(!1),[u,p]=c.useState(null),[f,h]=c.useState(!1),m=c.useRef(null),g=c.useCallback(async()=>{if(!e||s==="updating")return;const y=new AbortController;m.current=y,o("updating"),i(null);try{const j=await ce.postSkillUpdate(e.plugin,e.skill,y.signal);if(j.ok)o("done"),r(e.plugin,e.skill),n({message:`Updated ${e.skill}.`,severity:"success",durationMs:4e3});else{const S=`Update failed (HTTP ${j.status}): ${j.body}`;o("idle"),i(S),n({message:`Couldn't update ${e.skill} — HTTP ${j.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{g()}}})}}catch(j){if(j instanceof DOMException&&j.name==="AbortError")return;const S=j instanceof Error?j.message:"Network error";o("idle"),i(S),n({message:`Couldn't update ${e.skill} — ${S}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{g()}}})}finally{m.current===y&&(m.current=null)}},[e,s,r,n]);if(c.useEffect(()=>{if(!l||u!=null||!e||!e.latestVersion)return;let y=!1;return h(!0),ce.getVersionDiff(e.plugin,e.skill,e.currentVersion??"",e.latestVersion).then(j=>{y||p(j)}).catch(()=>{y||p(null)}).finally(()=>{y||h(!1)}),()=>{y=!0}},[l,u,e==null?void 0:e.plugin,e==null?void 0:e.skill,e==null?void 0:e.latestVersion,e==null?void 0:e.currentVersion,e]),c.useEffect(()=>()=>{var y;(y=m.current)==null||y.abort()},[]),!e||e.updateAvailable!==!0)return null;const v=e.latestVersion,x=s==="updating"?"Updating…":v?`Update to ${v}`:"Update",b=s==="updating";return t.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{g()},disabled:b,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:b?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:x}),t.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>d(y=>!y),disabled:b||!v,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:l?"Hide changelog":"Preview changelog"})]}),s==="updating"&&t.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),a&&s!=="updating"&&t.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:a}),l&&v&&t.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[f&&t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!f&&u&&t.jsx(Oa,{contentDiff:u.contentDiff,fromLabel:u.from,toLabel:u.to,diffSummary:u.diffSummary??void 0,renderContext:"inline"}),!f&&!u&&t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const X0=3e4;function Z0({plugin:e,skill:r,trackedForUpdates:n=!0,discoveryBackedOff:s=!1}){const o=Pt(),[a,i]=c.useState(!1),[l,d]=c.useState(!1),[,u]=c.useState(0),p=c.useRef(null),f=c.useRef(null),h=`${e}/${r}`,m=o.updatesById.get(h);if(c.useEffect(()=>{if(!a)return;const v=setInterval(()=>u(x=>(x+1)%1e6),250);return()=>clearInterval(v)},[a]),c.useEffect(()=>{if(!a||!m)return;const v=f.current??0;m.receivedAt<v||(p.current&&(clearTimeout(p.current),p.current=null),i(!1),d(!1),f.current=null)},[a,m]),c.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]),n===!1||s)return null;const g=async()=>{if(!a){d(!1),i(!0),f.current=Date.now(),p.current=setTimeout(()=>{i(!1),d(!0),p.current=null,f.current=null},X0);try{await ce.rescanSkill(e,r),p.current&&(clearTimeout(p.current),p.current=null);const v=o.updatesById.get(h),x=f.current??0,b=!!v&&v.receivedAt>=x;i(!1),b||d(!0),f.current=null}catch{p.current&&(clearTimeout(p.current),p.current=null),i(!1),f.current=null}}};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[t.jsx("button",{type:"button","data-testid":"check-now-button",onClick:g,disabled:a,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:a?"not-allowed":"pointer"},children:"Check now"}),a&&t.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),l&&t.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}function ek(e,r){var n;typeof process<"u"&&((n=process==null?void 0:process.env)==null?void 0:n.NODE_ENV)==="production"||console.warn(`[SubTabBar] sub-tab "${r}" clicked under "${e}" but no onChange handler was wired. Pass an onChange prop or this click is a no-op.`)}function tk({tabs:e,active:r,onChange:n,parentTabId:s}){const[o,a]=c.useState(null),i=l=>{n?n(l):ek(s,l)};return t.jsx("div",{role:"tablist","aria-label":`${s} sub-sections`,"data-testid":`detail-subtab-bar-${s}`,style:{display:"flex",alignItems:"stretch",gap:2,borderBottom:"1px solid var(--border-subtle, var(--border-default))",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:e.map(l=>{const d=l.id===r,u=o===l.id&&!d;return t.jsx("button",{type:"button",role:"tab","aria-selected":d,tabIndex:d?0:-1,id:`detail-subtab-${s}-${l.id}`,"data-testid":`detail-subtab-${s}-${l.id}`,onClick:()=>i(l.id),onMouseEnter:()=>a(l.id),onMouseLeave:()=>a(p=>p===l.id?null:p),style:{background:u?"var(--surface-2, rgba(0,0,0,0.04))":"transparent",border:"none",borderBottom:d?"2px solid var(--text-primary)":"2px solid var(--border-subtle, transparent)",padding:"8px 10px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:d?500:400,color:d?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap",transition:"background 80ms ease"},children:l.label},l.id)})})}const rk=[{id:"overview",label:"Overview"},{id:"source",label:"Source"},{id:"edit",label:"Edit",visibleWhen:({isReadOnly:e})=>!e},{id:"tests",label:"Tests"},{id:"run",label:"Run"},{id:"history",label:"History"}];function Fu(e){return rk.filter(r=>r.visibleWhen?r.visibleWhen({isReadOnly:e}):!0)}const nk={tests:{tab:"tests"},trigger:{tab:"run",mode:"activation"},activation:{tab:"run",mode:"activation"},versions:{tab:"history",view:"versions"},leaderboard:{tab:"history",view:"models"},editor:{tab:"edit"},overview:{tab:"overview"},source:{tab:"source"},edit:{tab:"edit"},run:{tab:"run"},history:{tab:"history"}};function ps(e){return e?nk[e]??null:null}function ia(e){const r=new URLSearchParams(e),n=r.get("tab"),s=r.get("panel");return ps(n)??ps(s)??{tab:"overview"}}function Du(e,r){return!r||new Set(Fu(!0).map(s=>s.id)).has(e)?e:"source"}const Fr={run:[{id:"benchmark",label:"Benchmark"},{id:"activation",label:"Activation"},{id:"ab",label:"A/B"}],history:[{id:"timeline",label:"Timeline"},{id:"models",label:"Models"},{id:"versions",label:"Versions"}]};function fn(e){const r=Fr[e];return r&&r.length>0?r[0].id:""}function zu(e,r){const n=Fr[e];if(!n)return"";const s=new URLSearchParams(r),o=e==="run"?"mode":e==="history"?"view":"sub",a=s.get(o)??s.get("sub");return a&&n.some(i=>i.id===a)?a:n[0].id}function sk(e){return e==="run"?"mode":e==="history"?"view":null}function ok(e){switch(e){case"editor":case"tests":case"deps":return{tab:"edit"};case"run":return{tab:"run",mode:"benchmark"};case"activation":return{tab:"run",mode:"activation"};case"history":return{tab:"history",view:"timeline"};case"leaderboard":return{tab:"history",view:"models"};case"versions":return{tab:"history",view:"versions"};default:return{tab:"overview"}}}function mo(){const{state:e,setMobileView:r}=Pt();return e.isMobile?t.jsxs("button",{onClick:()=>r("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function ak(e={}){if(e.selectedSkillInfo!==void 0||e.loadError!==void 0)return ik(e);const{state:r,selectSkill:n,setMode:s,refreshSkills:o}=Pt(),[a,i]=c.useState(typeof window<"u"?window.location.hash:"");if(c.useEffect(()=>{const u=()=>i(window.location.hash);return window.addEventListener("hashchange",u),()=>window.removeEventListener("hashchange",u)},[]),a==="#/updates")return t.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[t.jsx(mo,{}),t.jsx(Lu,{})]});if(r.mode==="create")return t.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[t.jsx(mo,{}),t.jsx(f0,{onCreated:async(u,p)=>{s("browse"),await o(),n({plugin:u,skill:p,origin:"source",source:"project"})},onCancel:()=>s("browse")})]});if(!r.selectedSkill)return r.skillsError?t.jsx(ln,{variant:"error",message:r.skillsError,onRetry:o}):!r.skillsLoading&&r.skills.length===0?t.jsx(ln,{variant:"no-skills"}):!r.skillsLoading&&r.skills.length>0&&!r.skills.some(u=>u.scopeV2==="available-project")?t.jsx(ln,{variant:"no-project-skills"}):t.jsx(ln,{variant:"no-selection"});const l=r.selectedSkill,d=r.skills.find(u=>u.plugin===l.plugin&&u.skill===l.skill)??null;return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx(mo,{}),t.jsx(lk,{skillInfo:d,allSkills:r.skills,onSelectSkill:u=>n(u)})]})}function ik(e){const r=e.selectedSkillInfo??null,n=e.activeDetailTab??"overview";if(r==null)return dk();if(e.loadError)return uk(r,e.loadError);const s=e.allSkills&&e.onSelectSkill?{allSkills:e.allSkills,onSelectSkill:e.onSelectSkill}:void 0,o=e.activeDetailSub??fn(n);return Bu(r,n,e.onDetailTabChange,o,e.onDetailSubChange,s)}function lk({skillInfo:e,allSkills:r,onSelectSkill:n}){const s=c.useMemo(()=>typeof window>"u"?{tab:"overview"}:ia(window.location.search),[]),[o,a]=c.useState(s.tab),[i,l]=c.useState(()=>s.mode?s.mode:s.view?s.view:zu(s.tab,typeof window<"u"?window.location.search:""));c.useEffect(()=>{if(!e||!(e.origin==="installed"))return;const p=Du(o,!0);p!==o&&(a(p),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:"This skill is read-only — workbench tabs are hidden.",severity:"info"}})))},[e,o]),c.useEffect(()=>{l(fn(o))},[o]),c.useEffect(()=>{if(typeof window>"u")return;const u=new URLSearchParams(window.location.search);u.delete("panel"),u.delete("sub"),o==="overview"?u.delete("tab"):u.set("tab",o);const p=sk(o),f=Fr[o];u.delete("mode"),u.delete("view"),p&&f&&i&&i!==f[0].id&&u.set(p,i);const h=u.toString(),m=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",m)},[o,i]);const d=c.useMemo(()=>e?Bu(e,o,a,i,l,{}):t.jsx(ln,{variant:"no-selection"}),[e,o,i,r,n]);return t.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:d})}function ck(e,r,n){const s=Fu(n);return t.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:s.map(({id:o,label:a})=>{const i=o===e;return t.jsx("button",{type:"button",role:"tab","aria-selected":i,tabIndex:i?0:-1,id:`detail-tab-${o}`,"aria-controls":`detail-panel-${o}`,"data-testid":`detail-tab-${o}`,onClick:()=>r==null?void 0:r(o),style:{background:"transparent",border:"none",borderBottom:i?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:i?500:400,color:i?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:a},o)})})}function dk(){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[t.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,color:"var(--text-primary)",margin:0,marginBottom:8},children:"Select a skill to view details"}),t.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-secondary)",margin:0,maxWidth:420,textAlign:"center"},children:"Choose a skill from the sidebar — its frontmatter, filesystem info, and benchmark status will appear here."})]})}function uk(e,r){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[Mu({skill:e}),t.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[t.jsxs("h3",{style:{fontFamily:"var(--font-serif)",fontSize:15,fontWeight:500,color:"var(--text-primary)",margin:"0 0 8px"},children:["Couldn't load SKILL.md for ",e.skill]}),t.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:r})]})]})}function pk({active:e,sub:r}){if(e==="edit")return t.jsx(Ab,{});if(e==="tests")return t.jsx(vu,{});if(e==="run"){const n=h1(r)?r:"benchmark";return t.jsx(m1,{mode:n})}if(e==="history"){const n=X1(r)?r:"timeline";return t.jsx(Z1,{view:n})}return null}function fk({active:e,sub:r}){const{state:n,dispatch:s}=vt();return c.useEffect(()=>{if(e==="overview")return;const o=e==="edit"?"editor":e==="tests"?"tests":e==="run"?r==="activation"?"activation":"run":e==="history"?r==="models"?"leaderboard":r==="versions"?"versions":"history":"editor";n.activePanel!==o&&s({type:"SET_PANEL",panel:o})},[e,r,n.activePanel,s]),null}function hk({skill:e}){const{visibility:r,repo:n}=bv(e.repoUrl??null);return Mu({skill:e,repoVisibility:r,tenantName:(n==null?void 0:n.ownerLogin)??null})}function Bu(e,r,n,s="",o,a){var h;const i=e.origin==="installed",l=Du(r,i),d=m=>{const g=ok(m);n==null||n(g.tab),o&&(g.mode?o(g.mode):g.view&&o(g.view))},u=t.jsx(Y0,{skill:e,onNavigate:d,repoUrl:e.homepage??null}),p=a!=null?t.jsxs(Ey,{plugin:e.plugin,skill:e.skill,origin:e.origin,children:[t.jsx(fk,{active:l,sub:s}),t.jsx(pk,{active:l,sub:s})]},`${e.plugin}/${e.skill}`):t.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",l," view."]}),f=e.origin==="installed"&&t.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),t.jsx("span",{style:{flex:1,minWidth:0},children:"This is an installed copy of the skill. Editing and generating tests are disabled — running author-shipped evals is allowed. Open the source skill to make changes."}),e.trackedForUpdates&&t.jsx("button",{type:"button","data-testid":"uninstall-button","aria-label":`Uninstall ${e.skill}`,onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-uninstall",{detail:{skill:{plugin:e.plugin,skill:e.skill,dir:e.dir??"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"installed"}}}))},style:{flexShrink:0,marginLeft:8,padding:"3px 10px",fontSize:11,fontWeight:500,fontFamily:"var(--font-sans)",color:"var(--text-primary)",background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:4,cursor:"pointer"},children:"Uninstall"})]});return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[t.jsx("div",{style:{padding:16,paddingBottom:12},children:t.jsx(hk,{skill:e})}),t.jsx(Q0,{skill:e}),f,e.origin==="installed"&&e.scopeV2!=="available-plugin"&&t.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:t.jsx(Z0,{plugin:e.plugin,skill:e.skill,trackedForUpdates:e.trackedForUpdates})}),ck(l,n,i),Fr[l]&&t.jsx(tk,{parentTabId:l,tabs:Fr[l],active:s||(((h=Fr[l][0])==null?void 0:h.id)??""),onChange:o}),t.jsx("div",{role:"tabpanel",id:`detail-panel-${l}`,"aria-labelledby":`detail-tab-${l}`,"data-testid":`detail-panel-${l}`,style:{flex:1,minHeight:0,overflow:"auto"},children:l==="overview"?u:l==="source"?t.jsx(Yb,{plugin:e.plugin,skill:e.skill}):p})]})}function mk(){const{updateCount:e,state:r,dismissUpdateNotification:n}=Pt(),s=e>0&&!r.updateNotificationDismissed;return c.useEffect(()=>{if(!s)return;const o=setTimeout(()=>n(),1e4);return()=>clearTimeout(o)},[s,n]),s?t.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[t.jsxs("span",{children:[e," update",e===1?"":"s"," available"]}),t.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),t.jsx("button",{onClick:n,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const _u=c.createContext(null),xk=1800*1e3,gk=3600*1e3;function vk(e,r){if(!e||!r)return!1;if(e.updates.skippedVersion===r)return!0;if(!e.updates.snoozedUntil)return!1;const n=new Date(e.updates.snoozedUntil).getTime();return!Number.isNaN(n)&&n>Date.now()}function yk({children:e}){const r=jn(),n=c.useRef("unknown"),s=c.useRef(0),[o,a]=c.useState(null),[i,l]=c.useState("idle"),[d,u]=c.useState({bytes:0,total:null}),[p,f]=c.useState(null),h=c.useCallback((k,R=null)=>k.available&&k.latestVersion&&!vk(R,k.latestVersion)?(a(k),l(w=>w==="ready"||w==="restarting"?w:"idle"),f(null),k):(a(null),l("idle"),f(null),null),[]),m=c.useCallback((k,R=null)=>h(Ga(k,n.current),R),[h]),g=c.useCallback(async()=>{if(!r.available)return null;l(k=>k==="installing"||k==="restarting"?k:"checking"),f(null);try{const[k,R]=await Promise.all([r.getSettings().catch(()=>null),r.checkForUpdates()]);return s.current=Date.now(),h(R,k)}catch(k){const R=k instanceof Error?k.message:String(k);return l("error"),f(R),null}},[h,r]),v=c.useCallback(()=>{r.available&&(Date.now()-s.current<xk||g())},[r.available,g]);c.useEffect(()=>{if(!r.available)return;let k=!1;const R=[];return r.getAppMetadata().then(w=>{n.current=w.version}).catch(()=>{}),(async()=>{const[w,E,N,T]=await Promise.all([Pn("updater://available",A=>{k||m(A.payload)}),Pn("updater://check-result",A=>{k||m(A.payload)}),Pn("updater://restart-required",A=>{k||(l("ready"),a($=>{var W,C;return $??Ga({available:!0,version:((W=A.payload)==null?void 0:W.version)??null,notes:((C=A.payload)==null?void 0:C.notes)??null},n.current)}))}),Pn("updater://error",A=>{var $;k||(l("error"),f((($=A.payload)==null?void 0:$.message)??"Update failed."))})]);for(const A of[w,E,N,T])A&&R.push(A);const I=await r.getSettings().catch(()=>null);!k&&((I==null?void 0:I.updates.autoCheck)??!0)&&await g()})(),()=>{k=!0;for(const w of R)w()}},[m,r,g]),c.useEffect(()=>{if(!r.available)return;const k=()=>v(),R=()=>{document.visibilityState==="visible"&&v()};window.addEventListener("focus",k),document.addEventListener("visibilitychange",R);const w=setInterval(()=>v(),gk);return()=>{window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",R),clearInterval(w)}},[r.available,v]);const x=c.useCallback(async()=>{if(!o||i==="installing"||i==="restarting")return!1;l("installing"),f(null),u({bytes:0,total:null});try{return await r.downloadAndInstallUpdate((k,R)=>{u({bytes:k,total:R})}),l("ready"),!0}catch(k){return l("error"),f(k instanceof Error?k.message:String(k)),!1}},[r,i,o]),b=c.useCallback(async()=>{if(i==="restarting")return!1;l("restarting"),f(null);try{return await r.restartApp(),!0}catch(k){return l("error"),f(k instanceof Error?k.message:String(k)),!1}},[r,i]),y=c.useCallback(async()=>{if(!o||i==="installing"||i==="restarting")return;if(i==="ready"){await b();return}await x()&&await b()},[x,i,b,o]),j=c.useCallback(()=>r.openPreferences("updates").catch(()=>{}),[r]),S=c.useMemo(()=>({update:o,phase:i,progress:d,error:p,available:!!o,checkNow:g,install:x,restart:b,installAndRestart:y,openDetails:j}),[o,i,d,p,g,x,b,y,j]);return t.jsx(_u.Provider,{value:S,children:e})}function bk(){const e=c.useContext(_u);if(!e)throw new Error("useAppUpdater must be used inside AppUpdaterProvider");return e}function kk(){var u;const e=bk(),{phase:r,progress:n}=e,s=n.total&&n.total>0?Math.min(100,Math.round(n.bytes/n.total*100)):null,o=c.useMemo(()=>r==="installing"?s===null?"Installing…":`Installing… ${s}%`:r==="restarting"?"Restarting…":r==="ready"?"Restart to update":r==="error"?"Update failed":"Update available",[r,s]);if(!e.available&&!(e.update&&r==="error"))return null;const a=r==="installing"||r==="restarting",i=r==="error",l=(u=e.update)==null?void 0:u.latestVersion,d=e.error?`Update failed: ${e.error}`:l?`Install Skill Studio ${l} and restart`:"Install the latest Skill Studio update";return t.jsxs("button",{type:"button","data-testid":"app-update-header-button","data-update-available":i?void 0:"true","aria-label":d,title:d,disabled:a,onClick:()=>{e.installAndRestart()},style:{display:"inline-flex",alignItems:"center",gap:7,height:28,padding:"0 12px",borderRadius:999,border:i?"1px solid var(--status-danger-text)":"1px solid var(--color-own)",background:i?"var(--bg-surface)":a?"var(--bg-muted)":"var(--color-own)",color:i?"var(--status-danger-text)":a?"var(--text-secondary)":"var(--color-paper)",fontSize:12,fontWeight:700,fontFamily:"var(--font-sans)",cursor:a?"wait":"pointer",whiteSpace:"nowrap",boxShadow:i?"none":"0 0 0 3px color-mix(in srgb, var(--color-own) 22%, transparent), 0 1px 2px rgba(0,0,0,0.18)"},children:[t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:15,height:15,borderRadius:999,fontSize:11,fontWeight:900,lineHeight:1,background:i?"transparent":"color-mix(in srgb, var(--color-paper) 28%, transparent)",color:"currentColor"},children:"↑"}),o]})}const jk=[{name:_.shortcuts.groupNavigation,items:[{keys:"/",label:_.shortcuts.search},{keys:"j",label:_.shortcuts.moveDown},{keys:"k",label:_.shortcuts.moveUp},{keys:"Enter",label:_.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:_.shortcuts.groupActions,items:[{keys:"⌘K",label:_.shortcuts.openPalette},{keys:"?",label:_.shortcuts.openShortcuts},{keys:"⌘B",label:_.shortcuts.toggleSidebar},{keys:"E",label:_.actions.edit}]},{name:_.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:_.shortcuts.toggleTheme}]}];function wk({open:e,onClose:r,groups:n=jk,title:s=_.shortcuts.title}){const o=c.useRef(null),a=c.useRef(null);return c.useEffect(()=>{var i;if(e)return o.current=document.activeElement??null,(i=a.current)==null||i.focus(),()=>{var l,d;(d=(l=o.current)==null?void 0:l.focus)==null||d.call(l),o.current=null}},[e]),c.useEffect(()=>{if(!e)return;function i(l){var d;if(l.key==="Escape"){l.preventDefault(),r();return}l.key==="Tab"&&(l.preventDefault(),(d=a.current)==null||d.focus())}return window.addEventListener("keydown",i,!0),()=>window.removeEventListener("keydown",i,!0)},[e,r]),e?t.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:i=>{i.target===i.currentTarget&&r()},children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[t.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[t.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:s}),t.jsx("button",{ref:a,type:"button","aria-label":"Close",onClick:r,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),n.map(i=>t.jsxs("section",{style:{marginBottom:12},children:[t.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:i.name}),t.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:i.items.map(l=>t.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[t.jsx("span",{children:l.label}),t.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:l.keys})]},`${i.name}:${l.keys}`))})]},i.name))]})}):null}function Sk(e){const r=_.actions,n=[{action:"open",label:r.open},{action:"copy-path",label:r.copyPath},{action:"reveal",label:r.revealInEditor},{action:"run-benchmark",label:r.runBenchmark}];if(e.origin==="source")return[...n,{action:"edit",label:r.edit},{action:"duplicate",label:r.duplicate},{action:"delete",label:r.delete}];const s=[...n];return s.push({action:"clone",label:r.cloneToAuthoring}),e.updateAvailable&&s.push({action:"update",label:r.update}),s.push({action:"uninstall",label:r.uninstall}),s.push({action:"delete",label:r.delete,disabled:!0,title:r.deletePluginTooltip}),s}function Ck({state:e,onClose:r,onAction:n,itemsOverride:s}){const o=c.useRef(null),a=c.useRef(null),[i,l]=c.useState(0),d=c.useMemo(()=>e.skill?s??Sk(e.skill):[],[e.skill,s]),u=c.useMemo(()=>{if(typeof window>"u")return{left:e.x,top:e.y};const f=8,h=220,m=44+d.length*28;let g=e.x,v=e.y;return g+h+f>window.innerWidth&&(g=Math.max(f,e.x-h)),v+m+f>window.innerHeight&&(v=Math.max(f,e.y-m)),{left:g,top:v}},[e.x,e.y,d.length]);c.useEffect(()=>{if(e.open)return a.current=document.activeElement??null,l(0),requestAnimationFrame(()=>{var f;(f=o.current)==null||f.focus()}),()=>{var f,h;(h=(f=a.current)==null?void 0:f.focus)==null||h.call(f),a.current=null}},[e.open]);const p=c.useCallback(()=>{if(!e.skill)return;const f=d[i];!f||f.disabled||(n(f.action,e.skill),r())},[d,i,e.skill,n,r]);return c.useEffect(()=>{if(!e.open)return;function f(m){if(m.key==="Escape"){m.preventDefault(),r();return}if(m.key==="ArrowDown"){m.preventDefault(),l(g=>Math.min(g+1,Math.max(d.length-1,0)));return}if(m.key==="ArrowUp"){m.preventDefault(),l(g=>Math.max(g-1,0));return}if(m.key==="Enter"||m.key===" "){m.preventDefault(),p();return}}function h(m){o.current&&m.target instanceof Node&&(o.current.contains(m.target)||r())}return window.addEventListener("keydown",f,!0),window.addEventListener("mousedown",h,!0),()=>{window.removeEventListener("keydown",f,!0),window.removeEventListener("mousedown",h,!0)}},[e.open,r,d.length,p]),!e.open||!e.skill?null:t.jsx("div",{ref:o,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:u.left,top:u.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:d.map((f,h)=>t.jsx("div",{role:"menuitem","aria-disabled":f.disabled||void 0,title:f.title||void 0,"data-action":f.action,"data-selected":h===i||void 0,onMouseEnter:()=>l(h),onClick:()=>{f.disabled||(n(f.action,e.skill),r())},style:{padding:"5px 10px",borderRadius:4,cursor:f.disabled?"default":"pointer",opacity:f.disabled?.5:1,background:h===i?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:f.label},f.action))})}const Ek=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function Nk(e){const{skill:r,onCloned:n,onCancel:s}=e,[o,a]=c.useState({target:"standalone",plugin:"",pluginName:""}),[i,l]=c.useState(!1),[d,u]=c.useState(null),p=c.useRef(null),f=c.useRef(null),h=c.useRef(null);c.useEffect(()=>(h.current=document.activeElement??null,requestAnimationFrame(()=>{var v;return(v=f.current)==null?void 0:v.focus()}),()=>{var v,x;(x=(v=h.current)==null?void 0:v.focus)==null||x.call(v),h.current=null}),[]),c.useEffect(()=>{function v(x){x.key==="Escape"&&(x.stopPropagation(),s())}return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]);const m=i||o.target==="plugin"&&!o.plugin.trim()||o.target==="new-plugin"&&!Ek.test(o.pluginName.trim()),g=c.useCallback(async v=>{if(v.preventDefault(),!m){l(!0),u(null);try{const x={source:r.skill,sourcePlugin:r.plugin,target:o.target};o.target==="plugin"&&(x.plugin=o.plugin.trim()),o.target==="new-plugin"&&(x.pluginName=o.pluginName.trim());const b=await fetch("/api/skills/clone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)}),y=await b.json().catch(()=>({}));if(!b.ok||!y.ok){u(y.message||y.error||`HTTP ${b.status}`);return}n({target:y.target??"",files:y.files??null})}catch(x){u(x.message??"Network error")}finally{l(!1)}}},[m,o,r,n]);return t.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"clone-dialog-title",ref:p,"data-testid":"clone-to-authoring-dialog",style:Rk,onClick:v=>{v.target===v.currentTarget&&s()},children:t.jsxs("form",{onSubmit:g,style:Tk,children:[t.jsx("h2",{id:"clone-dialog-title",style:Ik,children:"Clone to authoring"}),t.jsxs("p",{style:Lk,children:["Fork ",t.jsx("code",{style:Il,children:r.skill})," into the authoring scope so you can edit it."]}),t.jsxs("fieldset",{style:Ak,children:[t.jsx("legend",{style:Pk,children:"Target"}),t.jsxs("label",{style:xo,children:[t.jsx("input",{type:"radio",name:"target",value:"standalone",checked:o.target==="standalone",onChange:()=>a(v=>({...v,target:"standalone"})),"data-testid":"clone-target-standalone"}),t.jsxs("span",{style:go,children:[t.jsx("strong",{children:"Standalone"}),t.jsxs("span",{style:vo,children:["Lands at ",t.jsxs("code",{style:Il,children:["skills/",r.skill,"-fork/"]})]})]})]}),t.jsxs("label",{style:xo,children:[t.jsx("input",{type:"radio",name:"target",value:"plugin",checked:o.target==="plugin",onChange:()=>a(v=>({...v,target:"plugin"})),"data-testid":"clone-target-plugin"}),t.jsxs("span",{style:go,children:[t.jsx("strong",{children:"Add to existing plugin"}),t.jsx("span",{style:vo,children:"Lands inside a plugin you already author."})]})]}),o.target==="plugin"&&t.jsx("input",{type:"text",placeholder:"plugin name or path",value:o.plugin,onChange:v=>a(x=>({...x,plugin:v.target.value})),"data-testid":"clone-plugin-input",autoFocus:!0,style:Tl}),t.jsxs("label",{style:xo,children:[t.jsx("input",{type:"radio",name:"target",value:"new-plugin",checked:o.target==="new-plugin",onChange:()=>a(v=>({...v,target:"new-plugin"})),"data-testid":"clone-target-new-plugin"}),t.jsxs("span",{style:go,children:[t.jsx("strong",{children:"Create new plugin"}),t.jsx("span",{style:vo,children:"Scaffolds a fresh plugin folder with this skill inside."})]})]}),o.target==="new-plugin"&&t.jsx("input",{type:"text",placeholder:"plugin-name (kebab-case)",value:o.pluginName,onChange:v=>a(x=>({...x,pluginName:v.target.value})),"data-testid":"clone-new-plugin-name-input",autoFocus:!0,style:Tl})]}),d&&t.jsx("div",{role:"alert",style:$k,"data-testid":"clone-error",children:d}),t.jsxs("div",{style:Mk,children:[t.jsx("button",{type:"button",ref:f,onClick:s,disabled:i,style:Fk,"data-testid":"clone-cancel",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:m,style:Dk,"data-testid":"clone-submit",children:i?"Cloning…":"Clone"})]})]})})}const Rk={position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Tk={background:"var(--bg, #fff)",color:"var(--text, #111)",borderRadius:12,padding:"24px 28px",minWidth:460,maxWidth:560,boxShadow:"0 24px 60px rgba(0,0,0,0.5)",border:"1px solid var(--border, rgba(0,0,0,0.10))"},Ik={fontSize:18,fontWeight:700,margin:0},Lk={margin:"12px 0 18px",fontSize:14,color:"var(--text-muted, #555)"},Ak={border:"none",padding:0,margin:"0 0 16px"},Pk={fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:1.2,color:"var(--text-muted, #555)",padding:0,marginBottom:10},xo={display:"flex",alignItems:"flex-start",gap:10,padding:"10px 4px",cursor:"pointer",borderRadius:6},go={display:"flex",flexDirection:"column",gap:2,fontSize:14},vo={fontSize:12,color:"var(--text-muted, #777)"},Tl={display:"block",width:"100%",padding:"8px 12px",margin:"4px 0 8px 28px",maxWidth:380,fontSize:14,borderRadius:6,border:"1px solid var(--border, rgba(0,0,0,0.20))",background:"var(--bg, #fff)",color:"var(--text, #111)",fontFamily:"var(--font-geist-mono, monospace)"},Il={fontFamily:"var(--font-geist-mono, monospace)",fontSize:13,padding:"1px 6px",borderRadius:4,background:"rgba(127,127,127,0.12)"},$k={fontSize:13,color:"#c62828",background:"rgba(198,40,40,0.10)",border:"1px solid rgba(198,40,40,0.40)",padding:"8px 12px",borderRadius:6,margin:"0 0 12px"},Mk={display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},Fk={padding:"8px 16px",borderRadius:6,border:"1px solid var(--border, rgba(0,0,0,0.20))",background:"transparent",color:"var(--text, #111)",cursor:"pointer",fontSize:14},Dk={padding:"8px 16px",borderRadius:6,border:"1px solid var(--accent, #06b6d4)",background:"var(--accent, #06b6d4)",color:"#fff",cursor:"pointer",fontSize:14,fontWeight:600},Ll=e=>`${e.plugin}/${e.skill}`;function Al(e){const r=(e==null?void 0:e.delayMs)??1e4,n=e==null?void 0:e.onCommit,s=e==null?void 0:e.onFailure,o=(e==null?void 0:e.apiCall)??ce.deleteSkill.bind(ce),a=c.useRef(n),i=c.useRef(s),l=c.useRef(o);a.current=n,i.current=s,l.current=o;const d=c.useRef(new Map),[,u]=c.useState(0),p=c.useCallback(()=>u(y=>y+1),[]),f=c.useCallback(async y=>{var j,S;try{await l.current(y.skill.plugin,y.skill.skill),(j=a.current)==null||j.call(a,y.skill)}catch(k){(S=i.current)==null||S.call(i,y.skill,k)}finally{d.current.delete(Ll(y.skill)),p()}},[p]),h=c.useCallback(y=>{const j=Ll(y),S=d.current.get(j);S!=null&&S.timeoutId&&clearTimeout(S.timeoutId);const k={skill:y,timeoutId:null};k.timeoutId=setTimeout(()=>{k.timeoutId=null,f(k)},r),d.current.set(j,k),p()},[r,f,p]),m=c.useCallback(y=>{const j=d.current.get(y);j&&(j.timeoutId&&clearTimeout(j.timeoutId),d.current.delete(y),p())},[p]),g=c.useCallback(async()=>{const y=Array.from(d.current.values());for(const j of y)j.timeoutId&&(clearTimeout(j.timeoutId),j.timeoutId=null);await Promise.all(y.map(j=>f(j)))},[f]),v=c.useCallback(y=>d.current.has(y),[]),x=c.useCallback(async y=>{const j=d.current.get(y);j&&(j.timeoutId&&(clearTimeout(j.timeoutId),j.timeoutId=null),await f(j))},[f]),b=c.useCallback(async y=>{const j=Array.from(d.current.values()).filter(S=>S.skill.skill===y);for(const S of j)S.timeoutId&&(clearTimeout(S.timeoutId),S.timeoutId=null);await Promise.all(j.map(S=>f(S)))},[f]);return c.useEffect(()=>{const y=()=>{g()};return window.addEventListener("beforeunload",y),()=>{window.removeEventListener("beforeunload",y)}},[g]),c.useEffect(()=>{const y=d.current;return()=>{for(const j of y.values())j.timeoutId&&(clearTimeout(j.timeoutId),j.timeoutId=null,f(j));y.clear()}},[]),{enqueueDelete:h,cancelDelete:m,flushPending:g,isPending:v,flushKey:x,flushBySkillName:b}}const zk={"anthropic-api":{name:_.setupProviders.anthropic.name,description:_.setupProviders.anthropic.description,envVars:_.setupProviders.anthropic.envVars,keyUrl:_.setupProviders.anthropic.keyUrl,learnMoreUrl:_.setupProviders.anthropic.learnMoreUrl},openai:{name:_.setupProviders.openai.name,description:_.setupProviders.openai.description,envVars:_.setupProviders.openai.envVars,keyUrl:_.setupProviders.openai.keyUrl,learnMoreUrl:_.setupProviders.openai.learnMoreUrl},openrouter:{name:_.setupProviders.openrouter.name,description:_.setupProviders.openrouter.description,envVars:_.setupProviders.openrouter.envVars,keyUrl:_.setupProviders.openrouter.keyUrl,learnMoreUrl:_.setupProviders.openrouter.learnMoreUrl},gemini:{name:_.setupProviders.gemini.name,description:_.setupProviders.gemini.description,envVars:_.setupProviders.gemini.envVars,keyUrl:_.setupProviders.gemini.keyUrl,learnMoreUrl:_.setupProviders.gemini.learnMoreUrl},ollama:{name:_.setupProviders.ollama.name,description:_.setupProviders.ollama.description,envVars:_.setupProviders.ollama.envVars,install:[_.setupProviders.ollama.installCmd],start:[_.setupProviders.ollama.startCmd],pullExample:_.setupProviders.ollama.pullExample,learnMoreUrl:_.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:_.setupProviders.lmStudio.name,description:_.setupProviders.lmStudio.description,envVars:_.setupProviders.lmStudio.envVars,install:[_.setupProviders.lmStudio.installCmd],start:[_.setupProviders.lmStudio.startCmd],pullExample:_.setupProviders.lmStudio.pullExample,learnMoreUrl:_.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:_.setupProviders.claudeCode.name,description:_.setupProviders.claudeCode.description,envVars:[],notes:[_.setupProviders.claudeCode.loginHint,_.claudeCodeLabel.compactLabel],learnMoreUrl:_.setupProviders.claudeCode.learnMoreUrl}};function Bk(e){return e?zk[e]??null:null}function _k({open:e,providerKey:r,onClose:n}){const s=c.useRef(null);if(c.useEffect(()=>{if(!e)return;const i=l=>{l.key==="Escape"&&(l.preventDefault(),n())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e,n]),c.useEffect(()=>{if(!e)return;const i=s.current;if(!i)return;const l=i.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");l==null||l.focus()},[e]),!e||typeof document>"u")return null;const o=Bk(r),a=(o==null?void 0:o.name)??_.setupDrawer.fallbackTitle;return Ur.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:n,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),t.jsxs("div",{"data-testid":"setup-drawer",ref:s,role:"dialog","aria-modal":"true","aria-label":_.setupDrawer.title(a),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[t.jsx(Ok,{title:a,onClose:n}),t.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:o?t.jsx(Wk,{content:o}):t.jsx(Uk,{})}),t.jsx("style",{children:`@keyframes vskillDrawerIn {
|
|
66
|
+
from { transform: translateX(100%); }
|
|
67
|
+
to { transform: translateX(0); }
|
|
68
|
+
}
|
|
69
|
+
@keyframes vskillDrawerBackdropIn {
|
|
70
|
+
from { opacity: 0; }
|
|
71
|
+
to { opacity: 1; }
|
|
72
|
+
}`})]})]}),document.body)}function Ok({title:e,onClose:r}){return t.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[t.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:_.setupDrawer.title(e)}),t.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:r,"aria-label":_.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function Wk({content:e}){var r,n;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:e.description}),e.notes&&e.notes.length>0&&t.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:e.notes.map(s=>t.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:s},s))}),e.envVars.length>0&&t.jsxs("section",{children:[t.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:_.setupDrawer.requiredEnv}),t.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:e.envVars.map(s=>t.jsx("li",{children:t.jsx(Hk,{name:s})},s))})]}),e.keyUrl&&t.jsx(Vk,{href:e.keyUrl,label:_.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(e.install||e.start||e.pullExample)&&t.jsxs("section",{children:[t.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:_.setupDrawer.installRun}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(r=e.install)==null?void 0:r.map((s,o)=>t.jsx(yo,{code:s},`install-${o}`)),(n=e.start)==null?void 0:n.map((s,o)=>t.jsx(yo,{code:s},`start-${o}`)),e.pullExample&&t.jsx(yo,{code:e.pullExample})]})]}),t.jsx("footer",{style:{marginTop:8},children:t.jsxs("a",{href:e.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[_.setupDrawer.learnMore," →"]})})]})}function Uk(){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:_.setupDrawer.fallbackTitle}),t.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:_.setupDrawer.fallbackBody})]})}function Hk({name:e}){const r=async()=>{var n;try{await((n=navigator.clipboard)==null?void 0:n.writeText(e))}catch{}};return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[t.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:e}),t.jsx("button",{type:"button",onClick:r,"aria-label":`Copy ${e} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:_.setupDrawer.copy})]})}function yo({code:e}){return t.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"var(--bg-canvas, #111)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:11.5,lineHeight:1.5,borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})}function Vk({href:e,label:r,testId:n}){return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer","data-testid":n,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 12%, transparent)",color:"var(--text-primary)",textDecoration:"none",fontSize:13,fontWeight:500,fontFamily:"var(--font-sans)",width:"fit-content"},children:[r," →"]})}function Gk(){const[e,r]=c.useState(!1),[n,s]=c.useState(null),o=c.useRef(null),a=c.useCallback((l,d)=>{var u;o.current=typeof document<"u"?document.activeElement:null,(u=d==null?void 0:d.beforeOpen)==null||u.call(d),s(l),r(!0)},[]),i=c.useCallback(()=>{r(!1);const l=o.current;l&&"focus"in l&&typeof l.focus=="function"&&queueMicrotask(()=>l.focus())},[]);return c.useMemo(()=>({open:a,close:i,isOpen:e,providerKey:n}),[a,i,e,n])}function Kk(e){return(e instanceof DOMException||e instanceof Error)&&e.name==="AbortError"}function qk(e){let r="message";const n=[];for(const s of e.split(`
|
|
73
|
+
`)){if(!s||s.startsWith(":"))continue;const o=s.indexOf(":"),a=o===-1?s:s.slice(0,o),i=o===-1?"":s.slice(o+1),l=i.startsWith(" ")?i.slice(1):i;a==="event"?r=l||"message":a==="data"&&n.push(l)}return n.length===0?null:{event:r,data:n.join(`
|
|
74
|
+
`)}}function Pl(e,r){let n=e.replace(/\r\n/g,`
|
|
75
|
+
`).replace(/\r/g,`
|
|
76
|
+
`),s=n.indexOf(`
|
|
77
|
+
|
|
78
|
+
`);for(;s!==-1;){const o=n.slice(0,s);n=n.slice(s+2);const a=qk(o);a&&r(a),s=n.indexOf(`
|
|
79
|
+
|
|
80
|
+
`)}return n}function Ou(e,r){const n=r.fetchImpl??fetch,s=new AbortController;let o=!1;const a=()=>{o||(o=!0,clearTimeout(i),s.abort())},i=setTimeout(()=>{var d;if(o)return;const l=new Error(r.timeoutMessage??"SSE stream timed out");a(),(d=r.onError)==null||d.call(r,l)},r.timeoutMs??2e5);return(async()=>{var l,d;try{const u=await n(e,{headers:{Accept:"text/event-stream"},signal:s.signal});if(!u.ok){const v=u.statusText?` ${u.statusText}`:"";throw new Error(`SSE stream failed: HTTP ${u.status}${v}`)}if(!u.body)throw new Error("SSE stream failed: response body is empty");const p=u.body.getReader(),f=new TextDecoder;let h="";for(;;){const{done:v,value:x}=await p.read();if(v)break;h=Pl(h+f.decode(x,{stream:!0}),r.onEvent)}const m=f.decode();(m||h)&&Pl(`${h}${m}
|
|
81
|
+
|
|
82
|
+
`,r.onEvent),clearTimeout(i);const g=!o;o=!0,g&&((l=r.onClose)==null||l.call(r))}catch(u){if(clearTimeout(i),o&&Kk(u))return;o=!0,(d=r.onError)==null||d.call(r,u instanceof Error?u:new Error(String(u)))}})(),{close:a}}function Wa(e){return(e==null?void 0:e.fetchImpl)??fetch}async function Wu(e){const n=await Wa(e)("/api/studio/supported-agents",{headers:{Accept:"application/json"}});if(!n.ok)throw new Error(`fetchSupportedAgents failed: HTTP ${n.status}`);const s=await n.json();return Array.isArray(s==null?void 0:s.agents)?s.agents:[]}async function Yk(e,r){const s=await Wa(r)("/api/studio/install-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.error||`install-skill failed: HTTP ${s.status}`)}const o=await s.json();if(!o.jobId)throw new Error("install-skill: server did not return a jobId");return{jobId:o.jobId,...typeof o.streamPath=="string"&&o.streamPath.startsWith("/")?{streamPath:o.streamPath}:{},...typeof o.mode=="string"?{mode:o.mode}:{}}}function Jk(e,r,n){const s=Wa(n),o=e.startsWith("/")?e:`/api/studio/install-skill/${encodeURIComponent(e)}/stream`;let a;return a=Ou(o,{fetchImpl:s,timeoutMessage:"install-skill SSE stream timed out",onEvent:({event:i,data:l})=>{var d;if(i==="result"){try{const u=JSON.parse(l);r.onResult(u)}catch(u){(d=r.onError)==null||d.call(r,u instanceof Error?u:new Error(String(u)))}return}if(i==="done"){let u={results:[]};try{u=JSON.parse(l)}catch{}a.close(),r.onDone(u)}},onError:i=>{var l;return(l=r.onError)==null?void 0:l.call(r,i)}}),a}function Qk(e){const r=[],n=[],s=[];for(const a of e)a.installMode==="clipboard"?s.push(a):a.detected?r.push(a):n.push(a);const o=(a,i)=>a.displayName.localeCompare(i.displayName);return{detected:r.sort(o),available:n.sort(o),cloud:s.sort(o)}}function Xk(e){const r=[],n=[],s=[];for(const a of e)a.tier===1&&a.installMode==="filesystem"?r.push(a):a.tier===2&&a.installMode==="filesystem"?n.push(a):a.tier===3||a.installMode==="clipboard"?s.push(a):r.push(a);const o=(a,i)=>a.detected!==i.detected?a.detected?-1:1:a.displayName.localeCompare(i.displayName);return{dropIn:r.sort(o),formatConverted:n.sort(o),cloud:s.sort(o)}}function Zk(e){const r=[],n=[],s=new Set;for(const o of e){if(o.presence==="absent"||o.health==="missing"){n.push({kind:"individual",key:o.id,agent:o});continue}if(o.sharedFolderGroup&&o.sharedFolderGroup.length>1){const a=[...o.sharedFolderGroup].sort().join("+");if(s.has(a))continue;s.add(a);const i=e.filter(l=>o.sharedFolderGroup.includes(l.id));r.push({kind:"aggregate",key:`shared:${a}`,consumers:i,sharedFolderPath:o.sharedFolderPath??"~/.config/agents/skills",combinedCount:i.reduce((l,d)=>l+d.globalCount,0)});continue}r.push({kind:"individual",key:o.id,agent:o})}return{detected:r,notDetected:n}}function ej({agents:e,activeAgentId:r,focusedAgentId:n,onFocusAgent:s,onSwitch:o,onOpenSetup:a,onClose:i,groupBy:l="presence",onRequestInstall:d,fetchSupportedAgentsImpl:u}){const p=c.useRef(null);c.useEffect(()=>{const b=y=>{y.key==="Escape"&&(y.preventDefault(),i())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[i]),c.useEffect(()=>{const b=j=>{p.current&&!p.current.contains(j.target)&&i()},y=setTimeout(()=>{document.addEventListener("mousedown",b)},0);return()=>{clearTimeout(y),document.removeEventListener("mousedown",b)}},[i]);const f=c.useMemo(()=>Zk(e),[e]),[h,m]=c.useState(null),[g,v]=c.useState(null);c.useEffect(()=>{if(l!=="installMode")return;let b=!1;return(u??Wu)().then(j=>{b||m(j)}).catch(j=>{b||v(j instanceof Error?j.message:String(j))}),()=>{b=!0}},[l,u]);const x=e.find(b=>b.id===n)??e.find(b=>b.id===r)??e[0];return typeof document>"u"?null:Ur.createPortal(t.jsxs("div",{ref:p,"data-testid":"agent-scope-picker-popover","data-group-by":l,role:"dialog","aria-label":_.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[t.jsx("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:l==="installMode"?t.jsx(rj,{supported:h,error:g,focusedAgentId:n,activeAgentId:r,onFocus:s,onRequestInstall:d}):t.jsx(tj,{rows:f,activeAgentId:r,focusedAgentId:n,onFocus:s})}),t.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:x?t.jsx(aj,{agent:x,activeAgentId:r,onSwitch:()=>o(x.id)}):t.jsx(Uu,{})})]}),t.jsx("style",{children:`@keyframes scopePickerFadeIn {
|
|
83
|
+
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
84
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
85
|
+
}`})]}),document.body)}function tj({rows:e,activeAgentId:r,focusedAgentId:n,onFocus:s}){return e.detected.length===0&&e.notDetected.length===0?t.jsx(Uu,{}):t.jsxs(t.Fragment,{children:[e.detected.map(o=>o.kind==="aggregate"?t.jsx(sj,{row:o,onFocus:()=>{var a;return s(((a=o.consumers[0])==null?void 0:a.id)??r??"")}},o.key):t.jsx(nj,{agent:o.agent,focused:o.agent.id===n,active:o.agent.id===r,onClick:()=>s(o.agent.id)},o.key)),e.notDetected.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:_.scopePicker.notDetectedSubheading}),e.notDetected.map(o=>t.jsx(oj,{agent:o.agent},o.key))]})]})}function rj({supported:e,error:r,focusedAgentId:n,activeAgentId:s,onFocus:o,onRequestInstall:a}){if(r)return t.jsxs("div",{"data-testid":"agent-scope-supported-error",style:{padding:"16px 18px",fontSize:12,color:"var(--color-error, #dc2626)"},children:["Failed to load supported agents: ",r]});if(e===null)return t.jsx("div",{"data-testid":"agent-scope-supported-loading",style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"Loading agents…"});const i=Qk(e);return t.jsxs(t.Fragment,{children:[t.jsx(bo,{testId:"agent-scope-section-detected",title:"Detected on this machine",agents:i.detected,emptyHint:"No agents detected on this machine yet.",renderRow:l=>t.jsx(ko,{agent:l,focused:l.id===n,active:l.id===s,onClick:()=>o(l.id),kind:"detected"},l.id)}),t.jsx(bo,{testId:"agent-scope-section-available",title:"Available to install",agents:i.available,emptyHint:"All supported agents are detected — nothing left to install here.",renderRow:l=>t.jsx(ko,{agent:l,focused:l.id===n,active:!1,onClick:()=>o(l.id),kind:"available",onRequestInstall:a},l.id)}),t.jsx(bo,{testId:"agent-scope-section-cloud",title:"Cloud only (paste required)",agents:i.cloud,emptyHint:"No cloud-only tools available.",renderRow:l=>t.jsx(ko,{agent:l,focused:l.id===n,active:!1,onClick:()=>o(l.id),kind:"cloud",onRequestInstall:a},l.id)})]})}function bo({testId:e,title:r,agents:n,emptyHint:s,renderRow:o}){return t.jsxs("div",{"data-testid":e,children:[t.jsx("div",{style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:r}),n.length===0?t.jsx("div",{style:{padding:"4px 14px 8px",fontSize:11,color:"var(--text-tertiary)",fontStyle:"italic"},children:s}):n.map(o)]})}function ko({agent:e,focused:r,active:n,onClick:s,kind:o,onRequestInstall:a}){const i=o==="detected"?"var(--color-ok, #22c55e)":o==="available"?"var(--color-own, #f59e0b)":"var(--text-tertiary)",l=o==="cloud"?"Copy to clipboard":e.resolvedGlobalDir;return t.jsxs("div",{"data-testid":`agent-scope-supported-row-${e.id}`,"data-kind":o,"data-detected":e.detected?"true":"false",style:{display:"flex",flexDirection:"column",gap:2,padding:"6px 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:[t.jsxs("button",{type:"button",onClick:s,"data-testid":`agent-scope-supported-row-button-${e.id}`,"data-active":n?"true":"false",style:{display:"flex",alignItems:"center",gap:10,width:"100%",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",padding:0,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:i,flexShrink:0}}),t.jsx("span",{style:{flex:1,fontSize:13},children:e.displayName}),t.jsxs("span",{title:"Install tier",style:{fontFamily:"var(--font-mono)",fontSize:9,color:"var(--text-secondary)",letterSpacing:"0.04em",textTransform:"uppercase"},children:["T",e.tier]})]}),t.jsx("div",{title:l,style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",paddingLeft:16,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l}),o==="available"&&a&&t.jsx("button",{type:"button","data-testid":`agent-scope-install-cta-${e.id}`,onClick:d=>{d.stopPropagation(),a(e.id)},style:{alignSelf:"flex-start",marginLeft:16,marginTop:2,padding:"2px 8px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:4,background:"transparent",color:"var(--accent-text, var(--text-primary))",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"+ Install here"})]})}function nj({agent:e,focused:r,active:n,onClick:s}){const o=e.health==="ok"?"var(--color-ok, #22c55e)":e.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return t.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":e.id,"data-active":n?"true":"false",onClick:s,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:r?"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:[t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:o,flexShrink:0}}),t.jsx("span",{style:{flex:1,fontSize:13},children:e.displayName}),t.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[e.installedCount,"·",e.globalCount,"·",e.pluginCount??0]})]})}function sj({row:e,onFocus:r}){return t.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:r,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:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:e.sharedFolderPath}),t.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.consumers.map(n=>t.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:n.id},n.id)),t.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",e.combinedCount," skills"]})]})]})}function oj({agent:e}){const r=e.isRemoteOnly?`${e.displayName} is a web-only product — no local CLI or folder to detect.`:e.resolvedGlobalDir?`Looked for ${e.resolvedGlobalDir} — not found.`:`${e.displayName} was not found on this machine.`;return t.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${e.id}`,title:r,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),t.jsx("span",{style:{flex:1},children:e.displayName}),e.isRemoteOnly&&t.jsx("span",{"data-testid":`agent-scope-remote-badge-${e.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 aj({agent:e,activeAgentId:r,onSwitch:n}){const s=e.id===r,o=e.isRemoteOnly===!0,a=s||o,i=s?"Active":o?"Remote-only":_.scopePicker.switchCta;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:e.displayName}),t.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:o?"Remote service — no local install":lj(e.health)})]}),t.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[t.jsx(Vn,{label:_.scopePicker.statsInstalled,value:String(e.installedCount)}),t.jsx(Vn,{label:_.scopePicker.statsGlobal,value:String(e.globalCount)}),t.jsx(Vn,{label:_.scopePicker.statsPlugins,value:String(e.pluginCount??0)}),t.jsx(Vn,{label:_.scopePicker.statsLastSync,value:e.lastSync?ij(e.lastSync):"—"})]}),t.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:n,disabled:a,title:o?"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:a?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:a?"default":"pointer",opacity:a?.5:1},children:i})]})}function Vn({label:e,value:r}){return t.jsxs(t.Fragment,{children:[t.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:e}),t.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:r})]})}function Uu(){return t.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function ij(e){try{const r=new Date(e).getTime(),n=Date.now()-r;if(Number.isNaN(r))return"—";const s=Math.round(n/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const o=Math.round(s/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}catch{return"—"}}function lj(e){switch(e){case"ok":return _.scopePicker.statsHealthOk;case"stale":return _.scopePicker.statsHealthStale;case"missing":return _.scopePicker.statsHealthMissing}}function cj(e){const r=new Map;for(const n of e.sharedFolders??[])for(const s of n.consumers)r.set(s,n);return e.agents.map(n=>{const s=r.get(n.id);return{id:n.id,displayName:n.displayName,presence:n.detected?"detected":"absent",installedCount:n.localSkillCount,globalCount:n.globalSkillCount,pluginCount:n.pluginSkillCount??0,lastSync:n.lastSync,health:n.health,sharedFolderGroup:s?s.consumers:void 0,sharedFolderPath:s?s.path:void 0,isRemoteOnly:n.isRemoteOnly,resolvedGlobalDir:n.resolvedGlobalDir}})}function dj({agents:e,activeAgentId:r,onActiveAgentChange:n,onOpenSetup:s}){const[o,a]=c.useState(!1),[i,l]=c.useState(null),d=c.useRef(null),u=c.useMemo(()=>e.find(m=>m.id===r)??e[0]??null,[e,r]),p=c.useMemo(()=>u?u.health==="ok"?"var(--color-ok, #22c55e)":u.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[u]),f=c.useCallback(()=>{var m;a(!1),(m=d.current)==null||m.focus()},[]),h=c.useCallback(m=>{n(m),a(!1)},[n]);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":o,onClick:()=>a(m=>!m),onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a(!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:[t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:p,flexShrink:0}}),t.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(u==null?void 0:u.displayName)??"Select agent"}),t.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(u==null?void 0:u.installedCount)??0," · ",(u==null?void 0:u.globalCount)??0," · ",(u==null?void 0:u.pluginCount)??0,")"]}),t.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),o&&t.jsx(ej,{agents:e,activeAgentId:r,focusedAgentId:i??r,onFocusAgent:l,onSwitch:h,onOpenSetup:m=>{s(m),f()},onClose:f})]})}const Hu="vskill-ccode-banner-dismissed",uj=new Set(["claude-cli","claude-code"]);function pj(){try{return sessionStorage.getItem(Hu)==="true"}catch{return!1}}function fj(){try{sessionStorage.setItem(Hu,"true")}catch{}}function hj({activeAgentId:e}){const[r,n]=c.useState(()=>pj()),s=c.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),o=c.useCallback(()=>{fj(),n(!0)},[]);return!e||!uj.has(e)||r?null:t.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:[t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("span",{children:[_.claudeCodeLabel.firstUseBanner," "]}),t.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:s,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:_.claudeCodeLabel.learnMore})]}),t.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:o,"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 mj(){const[e,r]=c.useState(null),[n,s]=c.useState("loading"),[o,a]=c.useState(null),i=c.useCallback(async()=>{try{const l=await ce.getAgents();r(l),s("ready"),a(null)}catch(l){s("error"),a(l.message)}},[]);return c.useEffect(()=>{i()},[i]),c.useEffect(()=>{const l=()=>void i();return window.addEventListener("studio:agent-changed",l),window.addEventListener("studio:project-changed",l),()=>{window.removeEventListener("studio:agent-changed",l),window.removeEventListener("studio:project-changed",l)}},[i]),{status:n,response:e,error:o,refresh:()=>void i()}}const Gn="workspace",xj=["skills","agents"];async function gj(){const e=await fetch("/api/workspace");if(!e.ok)throw new Error(`GET /api/workspace failed: ${e.status}`);return await e.json()}class vj extends Error{constructor(r,n,s){super(r),this.name="SwitchProjectError",this.status=n,this.fallbackCommand=s}}async function yj(e){const r=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})});if(!r.ok){const n=await r.json().catch(()=>({}));throw new vj(n.error??`POST /api/workspace/active failed: ${r.status}`,r.status,n.fallbackCommand)}return await r.json()}async function bj(e){const r=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(n.error??`POST /api/workspace/projects failed: ${r.status}`)}return await r.json()}async function kj(e){const r=await fetch(`/api/workspace/projects/${encodeURIComponent(e)}`,{method:"DELETE"});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(n.error??`DELETE /api/workspace/projects/${e} failed: ${r.status}`)}return await r.json()}function jo(){for(const e of xj)He(e);typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:project-changed"))}function jj(){const{data:e,loading:r,error:n,revalidate:s}=It(Gn,gj),o=e,a=o==null?void 0:o.projects.find(u=>u.id===o.activeProjectId),i=c.useCallback(async u=>{const p=await yj(u);return He(Gn),jo(),{skillCount:p.skillCount}},[]),l=c.useCallback(async u=>{const p=await bj(u);He(Gn),jo();const f=p.projects.find(h=>h.path===u.path);return{id:f==null?void 0:f.id}},[]),d=c.useCallback(async u=>{await kj(u),He(Gn),jo()},[]);return{workspace:o,activeProject:a,loading:r,error:n,switchProject:i,addProject:l,removeProject:d,revalidate:s}}function wj(){return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:"@keyframes vskillProjSpin { to { transform: rotate(360deg); } }"}),t.jsx("span",{"aria-hidden":!0,style:{width:9,height:9,borderRadius:"50%",border:"2px solid color-mix(in oklch, currentColor 30%, transparent)",borderTopColor:"currentColor",display:"inline-block",animation:"vskillProjSpin 600ms linear infinite"}})]})}function Sj({workspace:e,onSwitch:r,onAdd:n,onRemove:s,isPathStale:o}){const[a,i]=c.useState(!1),[l,d]=c.useState(!1),[u,p]=c.useState(""),[f,h]=c.useState(null),[m,g]=c.useState(null),[v,x]=c.useState(null),[b,y]=c.useState(null),[j,S]=c.useState(!1),[k,R]=c.useState(null),w=c.useRef(null);async function E(C){if(k)return!1;R(C.id),h(null);try{const P=await r(C.id),L=P&&typeof P=="object"&&"skillCount"in P?P.skillCount:void 0,F=L!=null?` — ${L} ${L===1?"skill":"skills"}`:"";return window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:`Switched to ${C.name}${F}`,severity:"success"}})),i(!1),!0}catch(P){const L=P&&typeof P=="object"&&"fallbackCommand"in P?P.fallbackCommand:void 0;return y(L??`cd "${C.path}" && npx vskill@latest studio`),x({id:C.id,name:C.name,path:C.path}),!1}finally{R(null)}}async function N(C){const P=T.find(L=>L.path===C);if(P)return E(P);try{const L=await n({path:C}),F=L&&typeof L=="object"?L.id:void 0,H=C.split(/[\\/]/).filter(Boolean).pop()??C;return F?E({id:F,name:H,path:C}):(i(!1),!0)}catch(L){const F=L instanceof Error?L.message:String(L);return/does not exist/i.test(F)?h(`Path not found on disk: ${C}`):/duplicate/i.test(F)?h("That project is already registered."):h(F),d(!0),!1}}const T=(e==null?void 0:e.projects)??[],I=T.find(C=>C.id===(e==null?void 0:e.activeProjectId));c.useEffect(()=>{if(!a)return;function C(P){w.current&&!w.current.contains(P.target)&&(i(!1),d(!1),h(null))}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[a]);async function A(){h(null);const C=u.trim();if(!C){h("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!C.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(C)){h("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}await N(C)&&p("")}async function $(){if(h(null),Ac()){try{const{open:C}=await ar(async()=>{const{open:L}=await import("./index-D0lWXViJ.js");return{open:L}},__vite__mapDeps([7,1])),P=await C({directory:!0,multiple:!1,title:"Open project folder"});typeof P=="string"&&P&&await N(P)}catch(C){h(C instanceof Error?C.message:String(C))}return}d(!0)}function W(C){if(C.length<=50)return C;const P=C.split("/");return P.length<=4?C:`${P.slice(0,3).join("/")}/…/${P.slice(-2).join("/")}`}return t.jsxs("div",{ref:w,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[t.jsxs("button",{type:"button",onClick:()=>i(C=>!C),"aria-expanded":a,"aria-haspopup":"menu",title:(I==null?void 0:I.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:a?"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:[t.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(I==null?void 0:I.colorDot)??"var(--text-tertiary, #999)"}}),t.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I?I.name:"No project"}),t.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:a?"▴":"▾"})]}),a&&t.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:[T.length===0&&t.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."}),T.length>0&&t.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:T.map(C=>{const P=o?o(C.path):!1,L=C.id===(e==null?void 0:e.activeProjectId),F=m===C.id,H=k!==null,re=k===C.id,V=L||re;return t.jsxs("li",{role:"menuitem","data-stale":P?"true":"false","data-switching":re?"true":"false","aria-busy":re||void 0,onMouseEnter:()=>g(C.id),onMouseLeave:()=>g(O=>O===C.id?null:O),onClick:()=>{if(!(P||H)){if(L){i(!1);return}E(C)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:P||H?re?"progress":"not-allowed":"pointer",background:F&&!P&&!H?"var(--surface-2, rgba(0,0,0,0.04))":V?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:P?.5:H&&!re?.55:1,transition:"background-color 120ms ease, opacity 120ms ease"},children:[t.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:C.colorDot,boxShadow:V?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:V?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.name}),re?t.jsxs("span",{"aria-label":"Switching",style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:[t.jsx(wj,{}),"Switching…"]}):L&&t.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),t.jsx("div",{title:C.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:W(C.path)}),P&&t.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),t.jsx("button",{type:"button","aria-label":`Remove ${C.name}`,onClick:O=>{O.stopPropagation(),s(C.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:F?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:O=>{O.currentTarget.style.color="var(--color-error, #b91c1c)",O.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:O=>{O.currentTarget.style.color="var(--text-tertiary)",O.currentTarget.style.backgroundColor="transparent"},children:t.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:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),t.jsx("path",{d:"M10 11v6"}),t.jsx("path",{d:"M14 11v6"}),t.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},C.id)})}),t.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:l?8:6},children:[!l&&t.jsxs("button",{type:"button",onClick:()=>void $(),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:C=>{C.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:[t.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:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Open folder…"]}),l&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("input",{type:"text",value:u,onChange:C=>p(C.target.value),onKeyDown:C=>{C.key==="Enter"&&A(),C.key==="Escape"&&(d(!1),h(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"}}),t.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[t.jsx("button",{type:"button",onClick:()=>{d(!1),h(null),p("")},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"}),t.jsx("button",{type:"button",onClick:()=>void A(),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"})]}),f&&t.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:f})]})]})]}),v&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project failed",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>{x(null),y(null)},children:[t.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),t.jsxs("div",{onClick:C=>C.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:[t.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Couldn't switch to ",v.name]}),t.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"That folder couldn't be loaded — it may have moved or become unreadable. The current project is still active. As a last resort you can relaunch Skill Studio directly from the target folder:"}),t.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:b??`cd "${v.path}" && npx vskill@latest studio`}),t.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[t.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(b??`cd "${v.path}" && npx vskill@latest studio`),S(!0),setTimeout(()=>S(!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:j?"Copied!":"Copy command"}),t.jsx("button",{type:"button",onClick:()=>{x(null),y(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 Cj(e,r){const n=r.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(s=>{const o=`${s.name} ${s.path}`.toLowerCase();return n.every(a=>o.includes(a))})}function Ej({open:e,projects:r,onSwitch:n,onClose:s}){const[o,a]=c.useState(""),[i,l]=c.useState(0),d=c.useMemo(()=>Cj(r,o),[r,o]);c.useEffect(()=>{e||(a(""),l(0))},[e]),c.useEffect(()=>{i>=d.length&&l(0)},[d.length,i]);const u=p=>{if(p.key==="Escape"){p.preventDefault(),s();return}if(p.key==="ArrowDown"){p.preventDefault(),l(f=>Math.min(f+1,Math.max(d.length-1,0)));return}if(p.key==="ArrowUp"){p.preventDefault(),l(f=>Math.max(f-1,0));return}if(p.key==="Enter"){p.preventDefault();const f=d[i];f&&(n(f.id),s())}};return e?t.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:[t.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:s}),t.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[t.jsx("input",{type:"text",autoFocus:!0,value:o,onChange:p=>a(p.target.value),onKeyDown:u,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),t.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[d.length===0&&t.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),d.map((p,f)=>t.jsxs("li",{role:"option","aria-selected":f===i,"data-highlighted":f===i,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",f===i?"bg-muted":""].join(" "),onMouseEnter:()=>l(f),onClick:()=>{n(p.id),s()},children:[t.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:p.colorDot}}),t.jsxs("span",{className:"flex-1",children:[t.jsx("span",{className:"vskill-palette-name",children:p.name}),t.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:p.path})]})]},p.id))]})]})]}):null}const $l=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function Nj({open:e,onClose:r,initialMode:n="standalone",isClaudeCode:s,projectRoot:o,onCreated:a}){const[i,l]=c.useState("destination"),[d,u]=c.useState(n),[p,f]=c.useState(""),[h,m]=c.useState(""),[g,v]=c.useState(""),[x,b]=c.useState([]),[y,j]=c.useState(!1),[S,k]=c.useState(null);if(c.useEffect(()=>{e&&(l("destination"),u(n),f(""),m(""),v(""),k(null))},[e,n]),c.useEffect(()=>{if(!e)return;let C=!0;return fetch("/api/authoring/plugins").then(P=>P.json()).then(P=>{C&&b(P.plugins??[])}).catch(()=>{}),()=>{C=!1}},[e]),c.useEffect(()=>{if(!e)return;function C(P){P.key==="Escape"&&(P.preventDefault(),r())}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[e,r]),!e)return null;const R=x.length>0,w=s&&R,E=s,N=$l.test(p),T=d==="existing-plugin"?h.length>0:$l.test(h),I=!y&&N&&(d==="standalone"||T),A=Rj(o,d,h,p);async function $(){k(null),j(!0);try{const L=new URLSearchParams;L.set("mode",d),L.set("skillName",p),h&&L.set("pluginName",h);const F=await fetch(`/api/authoring/skill-exists?${L.toString()}`),H=await F.json();if(!F.ok){k(H.error??`Check failed: ${F.status}`);return}if(H.exists){k(`Skill '${p}' already exists${H.path?` at ${H.path}`:""}`);return}}catch(L){k(L instanceof Error?L.message:String(L));return}finally{j(!1)}const C=new URLSearchParams;C.set("mode",d),C.set("skillName",p),g.trim()&&C.set("description",g.trim()),h&&C.set("pluginName",h);const P=`#/create?${C.toString()}`;typeof window<"u"&&(window.location.hash=P),r()}async function W(){k(null),j(!0);try{const C=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:d,skillName:p,description:g.trim()||void 0,pluginName:d==="standalone"?void 0:h})}),P=await C.json();if(!C.ok||!P.ok){k(P.error??`Create failed: ${C.status}`);return}He("skills"),a==null||a({mode:d,skillName:p,pluginName:P.pluginName??null,skillMdPath:P.skillMdPath}),r()}catch(C){k(C instanceof Error?C.message:String(C))}finally{j(!1)}}return t.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:[t.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),t.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:[t.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:[t.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:i==="destination"?"Create a skill":"Name and describe"}),t.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",i==="destination"?"1":"2"," of 2"]})]}),i==="destination"&&t.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[t.jsx(wo,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:d==="standalone",onClick:()=>u("standalone")}),t.jsx(wo,{title:"Add to existing plugin",subtitle:w?`${x.length} plugin source${x.length===1?"":"s"} in this project`:s?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:d==="existing-plugin",onClick:()=>w&&u("existing-plugin")}),t.jsx(wo,{title:"Plugin (multi-skill)",subtitle:E?"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:!E,selected:d==="new-plugin",onClick:()=>E&&u("new-plugin")})]}),i==="details"&&t.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[d==="new-plugin"&&t.jsx(Kn,{label:"Plugin name",hint:"kebab-case",children:t.jsx("input",{type:"text",value:h,onChange:C=>m(C.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:qn(!h||T)})}),d==="existing-plugin"&&t.jsx(Kn,{label:"Plugin",children:t.jsxs("select",{value:h,onChange:C=>m(C.target.value),style:{...qn(!0),fontFamily:"var(--font-mono)"},children:[t.jsx("option",{value:"",children:"Select a plugin…"}),x.map(C=>t.jsx("option",{value:C.name,children:C.name},C.path))]})}),t.jsx(Kn,{label:"Skill name",hint:"kebab-case",children:t.jsx("input",{type:"text",value:p,onChange:C=>f(C.target.value.trim()),placeholder:"my-new-skill",autoFocus:d!=="new-plugin",style:qn(!p||N)})}),t.jsx(Kn,{label:"Description",hint:"One short sentence — shown in frontmatter",children:t.jsx("textarea",{value:g,onChange:C=>v(C.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...qn(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),A&&t.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:[t.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),A.map((C,P)=>t.jsx("div",{children:C},P))]}),S&&t.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:S})]}),t.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:[t.jsx("button",{type:"button",onClick:r,style:So,children:"Cancel"}),i==="destination"&&t.jsx("button",{type:"button",onClick:()=>l("details"),style:Ml,children:"Continue →"}),i==="details"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>l("destination"),style:So,children:"← Back"}),t.jsx("button",{type:"button",onClick:()=>void $(),disabled:!I,style:{...So,opacity:I?1:.5,cursor:I?"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"}),t.jsx("button",{type:"button",onClick:()=>void W(),disabled:!I,style:{...Ml,opacity:I?1:.5,cursor:I?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:y?"Creating…":"Create empty scaffold"})]})]})]})]})}function wo({title:e,subtitle:r,description:n,icon:s,selected:o,disabled:a,onClick:i}){return t.jsxs("button",{type:"button",onClick:i,disabled:a,"aria-pressed":o,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:o?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:o?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":a?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:a?"var(--text-tertiary)":"var(--text-primary)",cursor:a?"not-allowed":"pointer",opacity:a?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[t.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:s}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:e}),t.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:r}),t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:n})]})]})}function Kn({label:e,hint:r,children:n}){return t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:e}),r&&t.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:r})]}),n]})}function qn(e){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${e?"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 Ml={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"},So={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 Rj(e,r,n,s){const o=s||"<skill-name>",a=n||"<plugin-name>",i=e||"<project>";return r==="standalone"?[`${i}/skills/${o}/SKILL.md`]:r==="existing-plugin"?[`${i}/${a}/skills/${o}/SKILL.md`]:r==="new-plugin"?[`${i}/${a}/.claude-plugin/plugin.json`,`${i}/${a}/skills/${o}/SKILL.md`]:null}function Vu(e){return e.trim().toLowerCase()}function Tj(e,r){const n=Vu(r);return n?e.filter(s=>s.name.toLowerCase().includes(n)||s.source.toLowerCase().includes(n)):e}function Ij(e,r){const n=Vu(r);return n?e.filter(s=>[s.name,s.description??"",s.category??"",s.author??""].join(" ").toLowerCase().includes(n)):e}function Lj({open:e,onClose:r,onInstall:n,onUninstall:s,installedNames:o,privatePlugins:a}){const[i,l]=c.useState(null),[d,u]=c.useState([]),[p,f]=c.useState(null),[h,m]=c.useState(null),[g,v]=c.useState(!1),[x,b]=c.useState(null),[y,j]=c.useState(""),[S,k]=c.useState("");c.useEffect(()=>{p?j(""):k("")},[p]);const R=c.useMemo(()=>Tj(d,y),[d,y]),w=c.useMemo(()=>Ij((h==null?void 0:h.plugins)??[],S),[h,S]);return c.useEffect(()=>{e&&(v(!0),b(null),fetch("/api/plugins/marketplaces").then(E=>E.json()).then(E=>{if(E.error)throw new Error(E.error);u(E.marketplaces??[])}).catch(E=>b(E instanceof Error?E.message:String(E))).finally(()=>v(!1)))},[e]),c.useEffect(()=>{if(!p){m(null);return}v(!0),b(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(p)}`).then(E=>E.json()).then(E=>{if(E.error)throw new Error(E.error);m(E)}).catch(E=>b(E instanceof Error?E.message:String(E))).finally(()=>v(!1))},[p]),c.useEffect(()=>{if(!e)return;function E(N){N.key==="Escape"&&r()}return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[e,r]),e?t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[t.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[p&&t.jsx("button",{type:"button",onClick:()=>f(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),t.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:p?(h==null?void 0:h.name)??p:"Browse plugins"}),t.jsx("button",{type:"button",onClick:r,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[g&&t.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),x&&t.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:x}),!p&&a&&a.length>0&&t.jsx(Aj,{plugins:a}),!p&&!g&&d.length===0&&!x&&t.jsx(Pj,{}),!p&&d.length>0&&t.jsx(Fl,{value:y,onChange:j,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!p&&d.length>0&&R.length===0&&t.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",y,"”."]}),!p&&R.map(E=>t.jsxs("button",{type:"button",onClick:()=>f(E.name),style:Mj,onMouseEnter:N=>{N.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:N=>{N.currentTarget.style.background="transparent"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:E.name}),t.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.source})]},E.name)),p&&h&&t.jsxs(t.Fragment,{children:[h.description&&t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:h.description}),h.plugins.length===0&&t.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),h.plugins.length>0&&t.jsx(Fl,{value:S,onChange:k,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),h.plugins.length>0&&w.length===0&&t.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",S,"”."]}),w.map(E=>{const N=o.has(E.name);return t.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:t.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[E.name,E.version&&t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:E.version}),E.category&&t.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:E.category})]}),E.description&&t.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:E.description})]}),N&&s?t.jsx("button",{type:"button",disabled:i===E.name,onClick:async()=>{l(E.name);try{await s(E.name)}finally{l(null)}},"aria-label":`Uninstall ${E.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:i===E.name?"wait":"pointer",opacity:i===E.name?.6:1,fontFamily:"inherit"},children:i===E.name?"Uninstalling…":"Uninstall"}):t.jsx("button",{type:"button",disabled:N,onClick:()=>n(E.name,p),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:N?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:N?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:N?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:N?"default":"pointer",fontFamily:"inherit",boxShadow:N?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Installed":"Install"})]})},E.name)})]})]}),!p&&t.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:t.jsx($j,{onAdded:()=>{He("marketplaces"),fetch("/api/plugins/marketplaces").then(E=>E.json()).then(E=>u(E.marketplaces??[]))}})})]})]}):null}function Fl({value:e,onChange:r,placeholder:n,ariaLabel:s,testId:o}){return t.jsx("div",{style:{padding:"0 4px 10px"},children:t.jsx("input",{type:"search",value:e,onChange:a=>r(a.target.value),placeholder:n,"aria-label":s,"data-testid":o,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 Aj({plugins:e}){return t.jsxs("section",{"data-testid":"marketplace-private-plugins","aria-label":"Your private plugins",style:{marginBottom:12,padding:"10px 10px 6px",borderRadius:6,background:"#FFFBEB",border:"1px solid #FCD34D"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"#92400E"},children:[t.jsx("span",{"aria-hidden":"true",children:"🔒"}),"Your private plugins"]}),e.map(r=>t.jsxs("div",{style:{padding:"6px 4px",borderTop:"1px solid rgba(146,64,14,0.12)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#7C2D12"},children:r.name}),t.jsx("div",{style:{fontSize:11,color:"#92400E",fontFamily:"var(--font-mono)",opacity:.8,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.repoFullName})]},r.name))]})}function Pj(){return t.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",t.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[t.jsx("li",{children:t.jsx("code",{children:"anthropics/claude-plugins-official"})}),t.jsx("li",{children:t.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function $j({onAdded:e}){const[r,n]=c.useState(""),[s,o]=c.useState(!1),[a,i]=c.useState(null);async function l(){const d=r.trim();if(d){o(!0),i(null);try{const u=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:d})}),p=await u.json().catch(()=>({}));if(!u.ok||!p.ok){i(p.error??`Add failed (${u.status})`);return}n(""),e()}catch(u){i(u instanceof Error?u.message:String(u))}finally{o(!1)}}}return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{type:"text",value:r,onChange:d=>n(d.target.value),onKeyDown:d=>{d.key==="Enter"&&l()},placeholder:"anthropics/claude-plugins-official",disabled:s,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"}}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:s||!r.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:s||!r.trim()?"not-allowed":"pointer",opacity:s||!r.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:s?"Adding…":"Add"})]}),a&&t.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:a})]})}const Mj={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Co=12;function Fj({job:e,onDone:r}){const[n,s]=c.useState([]),[o,a]=c.useState("running"),[i,l]=c.useState(!1);if(c.useEffect(()=>{if(!e)return;s([]),a("running"),l(!1);const f=new AbortController;let h=[],m="running";return(async()=>{try{const g=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:e.ref}),signal:f.signal});if(!g.ok||!g.body){a("failed"),r({ok:!1,code:g.status,lines:[`HTTP ${g.status}`]});return}const v=g.body.getReader(),x=new TextDecoder;let b="";for(;;){const{value:y,done:j}=await v.read();if(j)break;b+=x.decode(y,{stream:!0});const S=b.split(/\n\n/);b=S.pop()??"";for(const k of S){const R=k.match(/^data:\s*(.*)$/m);if(R)try{const w=JSON.parse(R[1]);w.type==="stdout"&&w.line?(h=[...h,w.line].slice(-Co),s(h)):w.type==="stderr"&&w.line?(h=[...h,`⚠ ${w.line}`].slice(-Co),s(h)):w.type==="done"?(m=w.ok?"ok":"failed",a(m),Hc(),He("skills"),r({ok:w.ok??!1,code:w.code??null,lines:h})):w.type==="error"&&w.error&&(h=[...h,`✘ ${w.error}`].slice(-Co),s(h))}catch{}}}m==="running"&&r({ok:!0,code:0,lines:h})}catch(g){if(g.name==="AbortError")return;a("failed"),r({ok:!1,code:null,lines:[...h,g instanceof Error?g.message:String(g)]})}})(),()=>f.abort()},[e==null?void 0:e.ref]),!e)return null;const d=o==="ok"?"var(--color-installed, #2F6A4A)":o==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",u=o==="ok"?"✔":o==="failed"?"✘":"…",p=o==="ok"?"Installed":o==="failed"?"Install failed":"Installing";return t.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 ${d}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[t.jsxs("button",{type:"button",onClick:()=>l(f=>!f),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[t.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:d,width:16,textAlign:"center"},children:o==="running"?t.jsx(Dj,{}):u}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[p,": ",e.plugin,t.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginLeft:4},children:["@",e.marketplace]})]}),!i&&n.length>0&&t.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n[n.length-1]})]}),t.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-primary)"},children:i?"▾":"▸"})]}),i&&t.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:n.length===0?"Waiting for output…":n.join(`
|
|
86
|
+
`)})]})}function Dj(){return t.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:t.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}async function Dl(e,r){const s=await((r==null?void 0:r.fetchImpl)??fetch)("/api/studio/remove-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.error||`remove-skill failed: HTTP ${s.status}`)}return await s.json()}async function zj(e){if(typeof navigator<"u"&&navigator.clipboard){await navigator.clipboard.writeText(e);return}throw new Error("Clipboard API unavailable in this environment")}function Bj({agentId:e,agentDisplayName:r,blob:n,pasteInstructionsUrl:s,docsUrl:o,scopeDowngradeWarning:a,onClose:i,writeClipboardImpl:l}){const d=c.useRef(null),[u,p]=c.useState(!1),[f,h]=c.useState(null);c.useEffect(()=>{const g=v=>{v.key==="Escape"&&(v.preventDefault(),i())};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]);const m=c.useCallback(async()=>{const g=l??zj;try{await g(n),p(!0),h(null)}catch(v){h(v instanceof Error?v.message:String(v))}},[n,l]);return typeof document>"u"?null:Ur.createPortal(t.jsx("div",{"data-testid":"clipboard-export-dialog-backdrop",role:"presentation",onClick:g=>{g.target===g.currentTarget&&i()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",backdropFilter:"blur(4px)",display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"min(10vh, 80px)",zIndex:10040},children:t.jsxs("div",{ref:d,"data-testid":"clipboard-export-dialog","data-agent-id":e,role:"dialog","aria-modal":"true","aria-label":`Copy skill to ${r}`,style:{position:"relative",width:"100%",maxWidth:640,margin:"0 1rem",background:"var(--bg-surface, #FFFFFF)",color:"var(--text-primary, #191919)",borderRadius:8,border:"1px solid var(--color-rule, #E8E1D6)",boxShadow:"0 20px 60px rgba(0,0,0,0.18)",overflow:"hidden",maxHeight:"80vh",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{padding:"0.875rem 1.125rem",borderBottom:"1px solid var(--color-rule, #E8E1D6)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{fontFamily:"var(--font-serif, serif)",fontSize:16,fontWeight:500},children:["Copy to ",r]}),t.jsx("button",{type:"button","data-testid":"clipboard-export-dialog-close",onClick:i,"aria-label":"Close",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:18,color:"var(--text-secondary, #5A5651)",padding:"0 4px",lineHeight:1},children:"×"})]}),t.jsxs("div",{style:{padding:"1rem 1.125rem",overflowY:"auto",display:"flex",flexDirection:"column",gap:"0.75rem"},children:[a&&t.jsx("div",{"data-testid":"clipboard-export-scope-warning",role:"status",style:{padding:"0.625rem 0.875rem",background:"color-mix(in srgb, var(--color-own, #f59e0b) 14%, transparent)",border:"1px solid color-mix(in srgb, var(--color-own, #f59e0b) 45%, transparent)",borderRadius:6,fontSize:12,color:"var(--text-primary, #191919)"},children:a}),t.jsxs("div",{style:{fontSize:12,color:"var(--text-secondary, #5A5651)",lineHeight:1.5},children:["Click ",t.jsx("strong",{children:"Copy"})," below, then paste the skill into"," ",r,".",s?t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{"data-testid":"clipboard-export-paste-instructions-link",href:s,target:"_blank",rel:"noreferrer noopener",style:{color:"var(--accent-text, var(--text-primary))",textDecoration:"underline"},children:"Open paste instructions →"})]}):null]}),t.jsx("pre",{"data-testid":"clipboard-export-blob",style:{margin:0,padding:"0.75rem",background:"var(--surface-2, #F6F4EE)",border:"1px solid var(--color-rule, #E8E1D6)",borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,lineHeight:1.5,overflowX:"auto",maxHeight:"40vh",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n}),f&&t.jsxs("div",{"data-testid":"clipboard-export-error",role:"alert",style:{fontSize:12,color:"var(--color-error, #dc2626)"},children:["Copy failed: ",f]})]}),t.jsxs("div",{style:{padding:"0.75rem 1.125rem",borderTop:"1px solid var(--color-rule, #E8E1D6)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.75rem"},children:[t.jsx("div",{style:{display:"flex",gap:"0.625rem"},children:o&&t.jsxs("a",{"data-testid":"clipboard-export-docs-link",href:o,target:"_blank",rel:"noreferrer noopener",style:{fontSize:12,color:"var(--text-secondary)",textDecoration:"underline"},children:[r," docs"]})}),t.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[t.jsx("button",{type:"button","data-testid":"clipboard-export-dialog-cancel",onClick:i,style:{padding:"0.5rem 0.875rem",borderRadius:6,border:"1px solid var(--color-rule, #E8E1D6)",background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontSize:13,fontFamily:"var(--font-sans)"},children:"Close"}),t.jsx("button",{type:"button","data-testid":"clipboard-export-copy",onClick:m,style:{padding:"0.5rem 1rem",borderRadius:6,border:"1px solid var(--text-primary, #191919)",background:u?"var(--color-ok, #22c55e)":"var(--text-primary, #191919)",color:"var(--bg-surface, #FFFFFF)",cursor:"pointer",fontSize:13,fontWeight:600,fontFamily:"var(--font-sans)"},children:u?"Copied ✓":"Copy"})]})]})]})}),document.body)}function zl(e,r){return e.length===r.length?e===r?0:e<r?-1:1:e.length<r.length?-1:1}function _j(e,r){if(!us(e)||!us(r))return null;const n=a=>{const[i]=a.trim().split("+"),l=i.indexOf("-");return{core:(l<0?i:i.slice(0,l)).split("."),pre:l<0?[]:i.slice(l+1).split(".")}},s=n(e),o=n(r);for(let a=0;a<3;a++){const i=zl(s.core[a],o.core[a]);if(i)return i}if(!s.pre.length||!o.pre.length)return s.pre.length===o.pre.length?0:s.pre.length?-1:1;for(let a=0;a<Math.max(s.pre.length,o.pre.length);a++){const i=s.pre[a],l=o.pre[a];if(i===void 0||l===void 0)return i===void 0?-1:1;if(i===l)continue;const d=/^\d+$/.test(i),u=/^\d+$/.test(l);return d&&u?zl(i,l):d!==u?d?-1:1:i<l?-1:1}return 0}function Oj(e,r,n,s){if(!n||!n.scopes)return{kind:"not-installed"};const o=r==="project"?"user":"project",a=n.scopes[r],i=n.scopes[o];if(!a||!i)return{kind:"not-installed"};const l=a.installed&&a.installedAgentTools.includes(e),d=i.installed&&i.installedAgentTools.includes(e);if(!l)return d?{kind:"installed-other-scope",otherScope:o,version:i.version}:{kind:"not-installed"};const u=a.version;if(!u||!s)return{kind:"installed-current",version:u};const p=_j(u,s);return p===null||p===0?{kind:"installed-current",version:u}:p<0?{kind:"update-available",installed:u,target:s}:{kind:"newer-installed",installed:u,target:s}}const Wj=Object.freeze({"claude-cli":"claude-code","codex-cli":"codex"});function Bl(e){return e?Wj[e]??e:null}function Uj(e){var r,n;return((r=e.find(s=>s.detected&&s.installMode==="filesystem"))==null?void 0:r.id)??((n=e.find(s=>s.installMode==="filesystem"))==null?void 0:n.id)??null}function Hj(e){switch(e){case"installed":return"Installed";case"exported":return"Exported";case"skipped":return"Skipped";case"error":return"Error"}}function la(e){switch(e){case"installed":return"var(--color-ok, #22c55e)";case"exported":return"var(--accent-text, #3b82f6)";case"skipped":return"var(--text-tertiary)";case"error":return"var(--color-error, #dc2626)"}}function Vj({skill:e,skillDisplayName:r,scope:n,targetVersion:s,activeAgentId:o,preCheckedAgentIds:a,onClose:i,onSuccess:l,onRemoved:d,fetchSupportedAgentsImpl:u,installToAgentsImpl:p,startInstallStreamImpl:f,fetchInstallStateImpl:h,removeSkillImpl:m,writeClipboardImpl:g}){var Te;const v=c.useRef(null),[x,b]=c.useState("loading"),[y,j]=c.useState([]),[S,k]=c.useState(null),[R,w]=c.useState(new Set),[E,N]=c.useState(null),[T,I]=c.useState(null),[A,$]=c.useState(null),[W,C]=c.useState(!1),[P,L]=c.useState({}),[F,H]=c.useState(null),[re,V]=c.useState(0),[O,se]=c.useState(new Set),[ge,ye]=c.useState([]),[z,ne]=c.useState(null),M=c.useRef(null);c.useEffect(()=>{const Q=Se=>{Se.key==="Escape"&&(z||(Se.preventDefault(),Se.stopPropagation(),x!=="installing"&&i()))};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[z,x,i]),c.useEffect(()=>{let Q=!1;return(u??Wu)().then(he=>{if(Q)return;j(he);const Ce=new Set,Ae=Bl(o);Ae&&he.some(Pe=>Pe.id===Ae)&&Ce.add(Ae);for(const Pe of a??[]){const _e=Bl(Pe);_e&&he.some(wt=>wt.id===_e)&&Ce.add(_e)}if(Ce.size===0){const Pe=Uj(he);Pe&&Ce.add(Pe)}w(Ce),b("select")}).catch(he=>{Q||(k(he instanceof Error?he.message:String(he)),b("error"))}),()=>{Q=!0}},[u,o,a]),c.useEffect(()=>()=>{var Q;try{(Q=M.current)==null||Q.close()}catch{}},[]),c.useEffect(()=>{let Q=!1;return(h??(he=>ce.getSkillInstallState(he)))(e).then(he=>{Q||H(he)},()=>{Q||H(null)}),()=>{Q=!0}},[e,h,re]);const U=c.useMemo(()=>Xk(y),[y]),K=c.useCallback(Q=>{w(Se=>{const he=new Set(Se);return he.has(Q)?he.delete(Q):he.add(Q),he})},[]),X=c.useCallback(()=>{w(()=>{const Q=new Set;for(const Se of y)Se.detected&&Q.add(Se.id);return Q})},[y]),ie=c.useCallback(()=>{w(new Set)},[]),G=c.useCallback(()=>{var Q;if(x!=="installing"){try{(Q=M.current)==null||Q.close()}catch{}i()}},[x,i]),te=c.useCallback(async()=>{if(R.size===0)return;N(null),L({}),b("installing");const Q=Array.from(R),Se=p??Yk,he=f??Jk;try{const{jobId:Ce,streamPath:Ae}=await Se({skill:e,agentIds:Q,scope:n});M.current=he(Ae??Ce,{onResult:Pe=>{L(_e=>({..._e,[Pe.agentId]:Pe}))},onDone:Pe=>{const _e={},wt=(Pe.results??[]).length>0,oe=Pe.success===!1&&!wt?typeof Pe.error=="string"&&Pe.error.trim()||"Install failed before any target reported a result.":null;for(const $e of Q)_e[$e]=oe?{agentId:$e,status:"error",detail:oe}:{agentId:$e,status:"skipped"};if(oe)N(oe);else for(const $e of Pe.results??[])_e[$e.agentId]=$e;L($e=>{var St;const Fe={..._e};for(const[We,Je]of Object.entries($e))((St=Fe[We])==null?void 0:St.status)==="skipped"&&Je.status!=="skipped"&&(Fe[We]=Je);if(!Object.values(Fe).some(We=>We.status==="installed"||We.status==="exported"||We.status==="error")){const We="Install finished without writing any selected target.";for(const Je of Q)Fe[Je]={agentId:Je,status:"error",detail:We};N(We)}const Qe=Object.values(Fe),zt=Qe.filter(We=>We.status==="exported"&&typeof We.blob=="string");return zt.length>0&&(ye(zt),ne(zt[0]??null)),globalThis.setTimeout(()=>{try{l==null||l(Qe)}catch{}},0),Fe}),V($e=>$e+1),b("done")},onError:Pe=>{N(Pe.message),b("error")}})}catch(Ce){N(Ce instanceof Error?Ce.message:String(Ce)),b("error")}},[R,e,n,p,f,l]),de=c.useCallback(()=>{if(typeof window<"u")try{window.dispatchEvent(new CustomEvent("studio:skill-installed",{detail:{skill:e,scope:n}}))}catch{}V(Q=>Q+1),d==null||d()},[e,n,d]),fe=c.useCallback(async Q=>{const Se=m??Dl;I(null),$(null),se(he=>{const Ce=new Set(he);return Ce.add(Q),Ce});try{const he=await Se({skill:e,agentIds:[Q],scope:n});de();const Ce=he.skipped.find(Ae=>Ae.sharedWith&&Ae.sharedWith.length>0);he.errors.length>0?I(`Remove failed for ${he.errors[0].agentId}: ${he.errors[0].message}`):Ce&&$({agentId:Ce.agentId,sharedWith:Ce.sharedWith})}catch(he){I(he instanceof Error?he.message:String(he))}finally{se(he=>{const Ce=new Set(he);return Ce.delete(Q),Ce})}},[m,e,n,de]),ke=c.useCallback(async()=>{if(!A)return;const Q=m??Dl;C(!0),I(null);try{const Se=await Q({skill:e,scope:n,agentIds:[A.agentId,...A.sharedWith],all:!0});de(),$(null),Se.errors.length>0&&I(`Remove failed for ${Se.errors[0].agentId}: ${Se.errors[0].message}`)}catch(Se){I(Se instanceof Error?Se.message:String(Se))}finally{C(!1)}},[m,e,n,A,de]),B=c.useCallback(()=>{ye(Q=>{const Se=Q.slice(1);return ne(Se[0]??null),Se})},[]),Y=c.useMemo(()=>y.filter(Q=>Q.detected).length,[y]);if(typeof document>"u")return null;const J=R.size===0||x==="installing",ee=R.size===0?"Select at least one target":void 0,ue=`Install ${r??e} to:`,be=n==="project"?"Project scope — writes under <project>/.claude/skills (or each tool's local dir)":"User scope — writes under ~/.claude/skills (or each tool's global dir)";return Ur.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-testid":"install-targets-modal-backdrop",role:"presentation",onClick:Q=>{Q.target===Q.currentTarget&&G()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",backdropFilter:"blur(4px)",display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"min(8vh, 64px)",zIndex:10020},children:t.jsxs("div",{ref:v,"data-testid":"install-targets-modal",role:"dialog","aria-modal":"true","aria-label":ue,style:{position:"relative",width:"100%",maxWidth:640,margin:"0 1rem",background:"var(--bg-surface, #FFFFFF)",color:"var(--text-primary, #191919)",borderRadius:8,border:"1px solid var(--color-rule, #E8E1D6)",boxShadow:"0 20px 60px rgba(0,0,0,0.18)",overflow:"hidden",maxHeight:"84vh",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{padding:"0.875rem 1.125rem",borderBottom:"1px solid var(--color-rule, #E8E1D6)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.75rem"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[t.jsx("div",{"data-testid":"install-targets-modal-title",style:{fontFamily:"var(--font-serif, serif)",fontSize:16,fontWeight:500},children:ue}),t.jsx("div",{"data-testid":"install-targets-modal-scope-line",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:be})]}),t.jsx("button",{type:"button","data-testid":"install-targets-modal-close",onClick:G,"aria-label":"Close",disabled:x==="installing",style:{background:"transparent",border:"none",cursor:x==="installing"?"not-allowed":"pointer",fontSize:18,color:"var(--text-secondary, #5A5651)",padding:"0 4px",lineHeight:1,opacity:x==="installing"?.4:1},children:"×"})]}),t.jsxs("div",{style:{padding:"0.75rem 1.125rem",overflowY:"auto",flex:1},children:[x==="loading"&&t.jsx("div",{"data-testid":"install-targets-modal-loading",style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading agents…"}),S&&x==="error"&&y.length===0&&t.jsxs("div",{"data-testid":"install-targets-modal-load-error",role:"alert",style:{fontSize:12,color:"var(--color-error, #dc2626)"},children:["Failed to load agents: ",S]}),(x==="select"||x==="installing"||x==="done"||x==="error"&&y.length>0)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.5rem",marginBottom:"0.625rem"},children:[t.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:[R.size," selected · ",Y," detected"]}),t.jsxs("div",{style:{display:"flex",gap:"0.375rem"},children:[t.jsx("button",{type:"button","data-testid":"install-targets-select-all-detected",onClick:X,disabled:x==="installing"||Y===0,style:_l(),children:"Select all detected"}),t.jsx("button",{type:"button","data-testid":"install-targets-clear",onClick:ie,disabled:x==="installing"||R.size===0,style:_l(),children:"Clear"})]})]}),x==="installing"&&t.jsxs("div",{"data-testid":"install-targets-modal-installing-status",role:"status","aria-live":"polite",style:{margin:"0 0 0.75rem 0",padding:"0.625rem 0.875rem",borderRadius:6,border:"1px solid var(--color-rule, #E8E1D6)",background:"var(--surface-2, #F6F4EE)",color:"var(--text-primary)",fontSize:12},children:["Installing ",r??e," to ",R.size," target",R.size===1?"":"s","…"]}),t.jsx(Eo,{testId:"install-targets-section-dropin",title:"Drop-in",description:"Filesystem install — Claude-style SKILL.md drops in unchanged.",agents:U.dropIn,selected:R,results:P,phase:x,onToggle:K,scope:n,installState:F,targetVersion:s??null,removingAgents:O,onRemove:fe}),t.jsx(Eo,{testId:"install-targets-section-format-converted",title:"Format-converted",description:"Auto-converted to the tool's native format on install.",agents:U.formatConverted,selected:R,results:P,phase:x,onToggle:K,scope:n,installState:F,targetVersion:s??null,removingAgents:O,onRemove:fe}),t.jsx(Eo,{testId:"install-targets-section-cloud",title:"Cloud only (paste required)",description:"No local filesystem — opens a paste-ready blob.",agents:U.cloud,selected:R,results:P,phase:x,onToggle:K,tierBadge:"T3",pathOverride:"Copy to clipboard",scope:n,installState:F,targetVersion:s??null,removingAgents:O,onRemove:fe})]}),x==="done"&&t.jsx(Gj,{results:Object.values(P),agents:y,writeClipboardImpl:g}),A&&t.jsxs("div",{"data-testid":"install-targets-remove-shared",role:"alert",style:{marginTop:"0.75rem",padding:"0.625rem 0.875rem",borderRadius:6,background:"color-mix(in srgb, var(--color-own, #f59e0b) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--color-own, #f59e0b) 45%, transparent)",color:"var(--text-primary)",fontSize:12,display:"flex",alignItems:"center",gap:"0.75rem"},children:[t.jsxs("span",{style:{flex:1},children:["Not removed: ",A.agentId," loads this skill from the shared .agents/skills folder, which ",A.sharedWith.join(", ")," also",A.sharedWith.length===1?" uses":" use",". It can only be removed for all of them."]}),t.jsx("button",{type:"button","data-testid":"install-targets-remove-all",disabled:W,onClick:()=>{ke()},style:{fontSize:12,padding:"0.25rem 0.625rem",borderRadius:6,background:"transparent",border:"1px solid var(--color-error, #dc2626)",color:"var(--color-error, #dc2626)",cursor:W?"wait":"pointer",whiteSpace:"nowrap",fontFamily:"var(--font-sans)"},children:W?"Removing…":"Remove from all agents"})]}),T&&t.jsx("div",{"data-testid":"install-targets-remove-error",role:"alert",style:{marginTop:"0.75rem",padding:"0.625rem 0.875rem",borderRadius:6,background:"color-mix(in srgb, var(--color-error, #dc2626) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--color-error, #dc2626) 45%, transparent)",color:"var(--text-primary)",fontSize:12},children:T}),(x==="error"||x==="done")&&E&&t.jsx("div",{"data-testid":"install-targets-modal-install-error",role:"alert",style:{marginTop:"0.75rem",padding:"0.625rem 0.875rem",borderRadius:6,background:"color-mix(in srgb, var(--color-error, #dc2626) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--color-error, #dc2626) 45%, transparent)",color:"var(--text-primary)",fontSize:12},children:E})]}),t.jsxs("div",{style:{padding:"0.75rem 1.125rem",borderTop:"1px solid var(--color-rule, #E8E1D6)",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"0.5rem"},children:[x!=="done"&&t.jsx("button",{type:"button","data-testid":"install-targets-modal-cancel",onClick:G,disabled:x==="installing",style:{padding:"0.5rem 0.875rem",borderRadius:6,border:"1px solid var(--color-rule, #E8E1D6)",background:"transparent",color:"var(--text-primary)",cursor:x==="installing"?"not-allowed":"pointer",fontSize:13,fontFamily:"var(--font-sans)",opacity:x==="installing"?.5:1},children:"Cancel"}),x==="done"?t.jsx("button",{type:"button","data-testid":"install-targets-modal-done",onClick:G,style:{padding:"0.5rem 1.125rem",borderRadius:6,border:"1px solid var(--text-primary, #191919)",background:"var(--text-primary, #191919)",color:"var(--bg-surface, #FFFFFF)",cursor:"pointer",fontSize:13,fontWeight:600,fontFamily:"var(--font-sans)"},children:"Done"}):t.jsx("button",{type:"button","data-testid":"install-targets-modal-install",onClick:te,disabled:J,"aria-disabled":J,title:ee,style:{padding:"0.5rem 1.125rem",borderRadius:6,border:"1px solid var(--text-primary, #191919)",background:J?"var(--bg-surface, #FFFFFF)":"var(--text-primary, #191919)",color:J?"var(--text-secondary, #5A5651)":"var(--bg-surface, #FFFFFF)",cursor:J?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"var(--font-sans)",opacity:J?.6:1},children:x==="installing"?"Installing…":`Install (${R.size})`})]})]})}),z&&t.jsx(Bj,{agentId:z.agentId,agentDisplayName:((Te=y.find(Q=>Q.id===z.agentId))==null?void 0:Te.displayName)??z.agentId,blob:z.blob??"",pasteInstructionsUrl:z.pasteInstructionsUrl,docsUrl:z.docsUrl,scopeDowngradeWarning:z.detail&&z.detail.includes("project-scoped")?z.detail:void 0,onClose:B,writeClipboardImpl:g})]}),document.body)}function Eo({testId:e,title:r,description:n,agents:s,selected:o,results:a,phase:i,onToggle:l,tierBadge:d,pathOverride:u,scope:p,installState:f,targetVersion:h,removingAgents:m,onRemove:g}){return s.length===0?null:t.jsxs("div",{"data-testid":e,style:{marginTop:"0.625rem"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",padding:"0 0 0.25rem 0"},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:r}),t.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)"},children:n})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:s.map(v=>{const x=o.has(v.id),b=a[v.id],y=i==="installing"||i==="done",j=u??(p==="project"?v.resolvedProjectDir??v.resolvedLocalDir:v.resolvedGlobalDir),S=Oj(v.id,p,f,h),k=m.has(v.id);return t.jsxs("label",{"data-testid":`install-targets-row-${v.id}`,"data-checked":x?"true":"false","data-detected":v.detected?"true":"false",style:{display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.375rem 0.5rem",borderRadius:4,cursor:y?"default":"pointer",background:x?"color-mix(in srgb, var(--accent-surface) 8%, transparent)":"transparent"},children:[t.jsx("input",{type:"checkbox","data-testid":`install-targets-checkbox-${v.id}`,checked:x,disabled:y,onChange:()=>l(v.id),style:{margin:0}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[t.jsx("span",{style:{fontSize:13},children:v.displayName}),!v.detected&&t.jsx("span",{"data-testid":`install-targets-undetected-badge-${v.id}`,style:{fontSize:9,padding:"1px 6px",borderRadius:8,background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",color:"var(--text-secondary)",letterSpacing:"0.04em",textTransform:"uppercase"},children:"Not detected"}),d&&t.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:8,background:"color-mix(in srgb, var(--color-own, #f59e0b) 14%, transparent)",color:"var(--text-secondary)",letterSpacing:"0.04em",textTransform:"uppercase"},children:d}),t.jsx(Kj,{agentId:v.id,badge:S,isRemoving:k,onRemove:g})]}),t.jsx("div",{title:j,"data-testid":`install-targets-path-${v.id}`,style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j})]}),b&&t.jsx("span",{"data-testid":`install-targets-status-${v.id}`,"data-status":b.status,style:{fontSize:11,padding:"1px 8px",borderRadius:10,background:`color-mix(in srgb, ${la(b.status)} 16%, transparent)`,color:la(b.status),fontFamily:"var(--font-mono)"},children:Hj(b.status)})]},v.id)})})]})}function Gj({results:e,agents:r,writeClipboardImpl:n}){const[s,o]=c.useState(null);if(e.length===0)return null;const a=async(i,l)=>{try{n?await n(l):await navigator.clipboard.writeText(l),o(i)}catch{o(null)}};return t.jsxs("div",{"data-testid":"install-targets-results-toast",role:"status","aria-live":"polite",style:{marginTop:"0.875rem",padding:"0.75rem 0.875rem",borderRadius:6,border:"1px solid var(--color-rule, #E8E1D6)",background:"var(--surface-2, #F6F4EE)",display:"flex",flexDirection:"column",gap:"0.375rem"},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-tertiary)",marginBottom:"0.125rem"},children:"Install results"}),e.map(i=>{const l=r.find(p=>p.id===i.agentId),d=i.status==="installed"?i.path??i.detail:i.status==="exported"?i.detail&&i.detail.includes("project-scoped")?i.detail:"Copied to clipboard":i.status==="error"?i.detail??"Unknown error":i.detail??"",u=i.status==="installed"?"✓":i.status==="exported"?"⧉":i.status==="skipped"?"·":"✗";return t.jsxs("div",{"data-testid":`install-targets-result-row-${i.agentId}`,"data-status":i.status,style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",fontSize:12},children:[t.jsx("span",{"aria-hidden":"true",style:{color:la(i.status),fontWeight:600,fontFamily:"var(--font-mono)",width:"0.875rem",flexShrink:0},children:u}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsx("span",{style:{fontWeight:500},children:(l==null?void 0:l.displayName)??i.agentId}),d&&t.jsx("span",{style:{marginLeft:"0.5rem",color:"var(--text-secondary)",fontFamily:"var(--font-mono)",fontSize:11,wordBreak:"break-all"},children:d}),i.status==="installed"&&(i.path??i.detail)&&t.jsx("button",{type:"button","data-testid":`install-targets-result-copy-${i.agentId}`,onClick:()=>void a(i.agentId,i.path??i.detail),style:{marginLeft:"0.5rem",fontSize:10,padding:"1px 6px",borderRadius:8,background:"transparent",border:"1px solid var(--color-rule, #E8E1D6)",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-sans)"},children:s===i.agentId?"Copied":"Copy path"}),i.status==="exported"&&i.pasteInstructionsUrl&&t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{"data-testid":`install-targets-result-paste-link-${i.agentId}`,href:i.pasteInstructionsUrl,target:"_blank",rel:"noreferrer noopener",style:{fontSize:11,color:"var(--accent-text, var(--text-primary))",textDecoration:"underline"},children:"open paste instructions →"})]})]})]},i.agentId)})]})}function Kj({agentId:e,badge:r,isRemoving:n,onRemove:s}){if(r.kind==="not-installed")return null;let o,a,i;switch(r.kind){case"installed-current":o=r.version?`Installed v${r.version}`:"Installed",a="color-mix(in srgb, var(--color-ok, #22c55e) 14%, transparent)",i="var(--color-ok, #22c55e)";break;case"update-available":o=`Update available v${r.installed} → v${r.target}`,a="color-mix(in srgb, var(--color-own, #f59e0b) 18%, transparent)",i="var(--color-own, #f59e0b)";break;case"newer-installed":o=`Newer installed v${r.installed}`,a="color-mix(in srgb, var(--accent-text, #3b82f6) 14%, transparent)",i="var(--accent-text, #3b82f6)";break;case"installed-other-scope":o=r.version?`Installed v${r.version} (${r.otherScope} scope)`:`Installed (${r.otherScope} scope)`,a="color-mix(in srgb, var(--text-tertiary) 18%, transparent)",i="var(--text-secondary)";break}const l=r.kind!=="installed-other-scope";return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-testid":`install-targets-status-badge-${e}`,"data-badge-kind":r.kind,style:{fontSize:9,padding:"1px 6px",borderRadius:8,background:a,color:i,letterSpacing:"0.04em",textTransform:"uppercase",whiteSpace:"nowrap"},children:o}),l&&t.jsx("button",{type:"button","data-testid":`install-targets-remove-${e}`,disabled:n,onClick:d=>{d.preventDefault(),d.stopPropagation(),s(e)},style:{fontSize:10,padding:"1px 6px",borderRadius:8,background:"transparent",border:"1px solid var(--color-rule, #E8E1D6)",color:"var(--color-error, #dc2626)",cursor:n?"wait":"pointer",fontFamily:"var(--font-sans)"},children:n?"Removing…":"Remove"})]})}function _l(){return{padding:"3px 8px",borderRadius:4,border:"1px solid var(--color-rule, #E8E1D6)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"}}const qj=3e3,Yj={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Ol(e){return e==="anthropic"||e==="openai"||e==="openrouter"}function Jj(){const{toast:e}=ys(),r=c.useRef(new Map),n=c.useCallback(s=>{if(!Ol(s.provider))return;const o=Date.now(),a=r.current.get(s.provider)??0;if(o-a<qj)return;r.current.set(s.provider,o);const i=Yj[s.provider];e({message:`${i} 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:s.provider}}))}}})},[e]);return c.useEffect(()=>{function s(o){const a=o.detail;!a||!Ol(a.provider)||n({provider:a.provider})}return window.addEventListener("studio:api-key-error",s),()=>window.removeEventListener("studio:api-key-error",s)},[n]),{report:n}}const Gu="vskill.studio.prefs";function Ku(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function qu(){const e=Ku();if(!e)return{};try{const r=e.getItem(Gu);if(!r)return{};const n=JSON.parse(r);return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}catch{return{}}}function Qj(e,r){const n=Ku();if(n)try{const o={...qu(),[e]:r};n.setItem(Gu,JSON.stringify(o))}catch{}}function Xj(e,r){const s=qu()[e];return s===void 0?r:s}const Wl={open:!1,x:0,y:0,skill:null};function Zj(e,r){return{open:!0,x:e.clientX,y:e.clientY,skill:r}}function Ut(e,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function ew(e){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:e}}))}async function Ul(e,r){var n;try{await ce.revealInEditor(e.plugin,e.skill,r),Ut(_.toasts.openingInEditor,"info")}catch(s){if(s instanceof Jt){const o=(n=s.details)==null?void 0:n.error;if(s.status===404){Ut(_.toasts.skillNotFound,"error");return}if(s.status===500&&o==="no_editor"){Ut(_.toasts.noEditor,"error");return}}Ut(_.toasts.openFailed,"error")}}async function tw(e,r){var n;switch(e){case"copy-path":try{(n=navigator.clipboard)==null||n.writeText(r.dir)}catch{Ut(_.toasts.permissionDenied,"error");return}Ut(_.toasts.pathCopied,"info");return;case"reveal":case"edit":await Ul(r,"SKILL.md");return;case"open":await Ul(r);return;case"run-benchmark":Ut(_.toasts.benchmarkQueued,"info");return;case"duplicate":Ut(_.toasts.skillDuplicated,"info");return;case"clone":try{window.dispatchEvent(new CustomEvent("studio:request-clone",{detail:{skill:r}}))}catch{}return;case"update":Ut(_.toasts.skillUpdated,"info");return;case"uninstall":Ut(_.toasts.uninstallNotImplemented,"info");return;case"delete":ew(r);return;default:return}}function rw(e){return e.startsWith("#/create")}function nw(e){return e.startsWith("#/updates")}function Yu(e){const[r,n]=c.useState(()=>typeof window<"u"&&e(window.location.hash));return c.useEffect(()=>{function s(){n(e(window.location.hash))}return window.addEventListener("hashchange",s),s(),()=>window.removeEventListener("hashchange",s)},[]),r}function sw(){return Yu(rw)}function ow(){return Yu(nw)}function aw(){var s,o;if(typeof navigator>"u")return"⌘⇧K";const e=((s=navigator.platform)==null?void 0:s.toUpperCase())??"",r=((o=navigator.userAgent)==null?void 0:o.toUpperCase())??"";return e.includes("MAC")||r.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function iw(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function lw(){const[e,r]=c.useState("⌘⇧K");c.useEffect(()=>{r(aw())},[]);const n=iw();function s(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return t.jsxs("button",{type:"button",onClick:s,"aria-label":`Find verified skills — opens search (${e})`,title:`Find verified skills (${e})`,"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:[t.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:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("span",{children:"Find skills"}),t.jsx("kbd",{"data-animated":n?"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:e})]})}function cw(){const e=jn(),[r,n]=c.useState(null),[s,o]=c.useState(!0),[a,i]=c.useState(!1),[l,d]=c.useState(null),[u,p]=c.useState(null),[f,h]=c.useState(!1),m=c.useRef(!1);c.useEffect(()=>{let j=!1;return(async()=>{try{const S=await e.getSignedInUser();j||n(S)}catch{}finally{j||o(!1)}})(),()=>{j=!0}},[e]);const g=c.useRef(null);c.useEffect(()=>{if(!a)return;function j(k){g.current&&(g.current.contains(k.target)||i(!1))}function S(k){k.key==="Escape"&&i(!1)}return document.addEventListener("pointerdown",j),document.addEventListener("keydown",S),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",S)}},[a]);const v=c.useCallback(async j=>{try{if(typeof e.openExternalUrl=="function"){await e.openExternalUrl(j);return}}catch(S){console.warn("open external URL:",S)}window.open(j,"_blank","noopener,noreferrer")},[e]),x=c.useCallback(async()=>{p(null),h(!0),m.current=!1;let j=null;const S=k=>{j=k,p(k)};try{const k=await e.startGithubDeviceFlow();window.__vskillOauthState=k.userCode,d(k),v(k.verificationUri);let R=Math.max(1,k.interval);const w=Date.now()+k.expiresIn*1e3;for(;!m.current&&Date.now()<w&&(await pw(R*1e3,()=>m.current),!m.current);){const E=await e.pollGithubDeviceFlow();if(E.status==="granted"){n(E.user),d(null),h(!1);return}if(E.status!=="pending"){if(E.status==="slow_down"){R=Math.max(R+1,E.newInterval);continue}if(E.status==="denied"){S("Sign-in was denied at GitHub. You can try again.");break}if(E.status==="expired"){S("Sign-in code expired. Try again to get a fresh code.");break}if(E.status==="no-flow"){S("Sign-in state lost. Please retry.");break}S(E.message);break}}!m.current&&!j&&S("Sign-in code expired. Try again to get a fresh code.")}catch(k){S(k instanceof Error?k.message:String(k))}finally{h(!1)}},[e,v]),b=c.useCallback(()=>{m.current=!0,d(null),p(null),h(!1)},[]),y=c.useCallback(async()=>{i(!1);try{await e.signOut()}catch(j){console.warn("sign-out:",j)}n(null)},[e]);return s?t.jsx("div",{"data-slot":"user-dropdown-placeholder",style:{width:28,height:28}}):r?t.jsxs("div",{"data-slot":"user-dropdown",style:{position:"relative"},ref:g,children:[t.jsxs("button",{type:"button","data-slot":"user-chip",onClick:()=>i(j=>!j),"aria-label":`Signed in as ${r.login}`,"aria-haspopup":"menu","aria-expanded":a,title:`Signed in as ${r.login}`,style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 6px 0 4px",borderRadius:14,border:"1px solid var(--border-default)",background:"var(--surface-1, transparent)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer"},children:[t.jsx("img",{src:r.avatar_url,alt:"",width:20,height:20,onError:j=>{const S=hw(r.login);j.currentTarget.src!==S&&(j.currentTarget.src=S)},style:{borderRadius:"50%",display:"block"}}),t.jsx("span",{style:{maxWidth:100,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.login})]}),a&&t.jsxs("div",{role:"menu","data-slot":"user-menu",style:{position:"absolute",top:"calc(100% + 4px)",right:0,minWidth:180,background:"var(--surface-2, #1a1d22)",border:"1px solid var(--border-default)",borderRadius:8,padding:4,boxShadow:"0 4px 16px rgba(0,0,0,0.32)",zIndex:50},children:[t.jsx(Hl,{label:"View on GitHub",onClick:()=>{v(`https://github.com/${r.login}`),i(!1)}}),t.jsx(Hl,{label:"Sign out",onClick:y})]})]}):t.jsxs("div",{"data-slot":"user-dropdown",style:{position:"relative"},ref:g,children:[t.jsxs("button",{type:"button","data-slot":"sign-in-button",onClick:x,disabled:f,"aria-label":"Sign in with GitHub",title:"Sign in with GitHub",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 10px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--surface-1, transparent)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:f?"wait":"pointer"},children:[t.jsx(uw,{size:14}),f?"Signing in…":"Sign in"]}),l&&t.jsx(dw,{response:l,error:u,onCancel:b,onOpenGithub:()=>void v(l.verificationUri),onRetry:x})]})}function dw({response:e,error:r,onCancel:n,onOpenGithub:s,onRetry:o}){const[a,i]=c.useState("idle"),l=c.useRef(null);c.useEffect(()=>()=>{l.current!=null&&window.clearTimeout(l.current)},[]);let d=e.verificationUri;try{const p=new URL(e.verificationUri);d=`${p.host}${p.pathname}`}catch{}const u=c.useCallback(async()=>{l.current!=null&&window.clearTimeout(l.current);try{await fw(e.verificationUri),i("copied"),l.current=window.setTimeout(()=>i("idle"),1500)}catch{i("failed"),l.current=window.setTimeout(()=>i("idle"),1500)}},[e.verificationUri]);return t.jsxs("div",{role:"dialog","aria-label":"Sign in with GitHub","data-slot":"sign-in-dialog",style:{position:"absolute",top:"calc(100% + 8px)",right:0,width:320,background:"var(--surface-2, #1a1d22)",border:"1px solid var(--border-default)",borderRadius:10,padding:16,boxShadow:"0 6px 24px rgba(0,0,0,0.42)",zIndex:60,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[t.jsx("div",{style:{fontSize:13,marginBottom:8},children:"Authorize Skill Studio in GitHub. If the browser did not open, use the button or copy the link."}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[t.jsx("code",{"aria-label":"Authorization URL",title:e.verificationUri,style:{flex:1,fontFamily:"var(--font-mono)",fontSize:12,padding:"6px 10px",background:"var(--surface-1, #0f1115)",border:"1px solid var(--border-default)",borderRadius:6,textAlign:"left",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),t.jsx("button",{type:"button",onClick:u,"aria-label":"Copy sign-in link",title:a==="copied"?"Copied":"Copy sign-in link",style:{height:32,padding:"0 10px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontSize:12},children:a==="copied"?"Copied":a==="failed"?"Copy failed":"Copy link"})]}),t.jsx("div",{"aria-live":"polite","data-slot":"copy-feedback",style:{minHeight:14,fontSize:11,color:"var(--text-secondary)",marginBottom:8},children:a==="copied"?"Link copied":a==="failed"?"Copy failed":""}),r?t.jsx("div",{role:"alert",style:{fontSize:12,color:"var(--color-danger, #d44)",marginBottom:10},children:r}):t.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginBottom:10},children:"Waiting for you to authorize on GitHub…"}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{type:"button","data-slot":"open-github-button",onClick:s,style:{flex:1,height:32,borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:"pointer",fontSize:12,fontWeight:600},children:"Authorize in GitHub"}),r?t.jsx("button",{type:"button",onClick:o,style:{height:32,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontSize:12},children:"Try again"}):null,t.jsx("button",{type:"button",onClick:n,style:{height:32,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontSize:12},children:"Cancel"})]})]})}function Hl({label:e,onClick:r}){return t.jsx("button",{type:"button",role:"menuitem",onClick:r,style:{display:"block",width:"100%",textAlign:"left",padding:"8px 12px",background:"transparent",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:13,fontFamily:"inherit",borderRadius:4},onMouseEnter:n=>{n.currentTarget.style.background="var(--surface-3, #25292f)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:e})}function uw({size:e=16}){return t.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",fill:"currentColor",children:t.jsx("path",{d:"M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.1.79-.25.79-.56v-2.04c-3.2.7-3.87-1.37-3.87-1.37-.52-1.32-1.27-1.67-1.27-1.67-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.18 1.76 1.18 1.02 1.75 2.69 1.24 3.34.95.1-.74.4-1.24.72-1.52-2.55-.29-5.24-1.27-5.24-5.66 0-1.25.45-2.27 1.18-3.07-.12-.29-.51-1.46.11-3.04 0 0 .96-.31 3.15 1.18a10.91 10.91 0 0 1 5.74 0c2.18-1.49 3.14-1.18 3.14-1.18.62 1.58.23 2.75.11 3.04.74.8 1.18 1.82 1.18 3.07 0 4.4-2.69 5.36-5.25 5.65.41.36.77 1.07.77 2.16v3.2c0 .31.21.67.8.55C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5z"})})}async function pw(e,r){const s=Date.now()+e;for(;Date.now()<s;){if(r())return;const o=s-Date.now();await new Promise(a=>setTimeout(a,Math.min(250,o)))}}async function fw(e){var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(e));return}catch{}const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.focus(),r.select();const n=document.execCommand("copy");if(r.remove(),!n)throw new Error("copy failed")}function hw(e){return`https://github.com/${encodeURIComponent(e)}.png?size=40`}function mw({forcedTone:e}){const{snapshot:r,refreshing:n,forceSync:s}=Ba(),o=(r==null?void 0:r.daysRemaining)??0,a=(r==null?void 0:r.isFresh)??!1;if(!((r==null?void 0:r.cache)??null))return null;const l=e??xw(o,a);if(!l)return null;const d=c.useCallback(()=>{s(!0)},[s]),u=l==="danger"?"Sign in to refresh your plan. Some features will be locked until you reconnect.":"Sync to verify your plan — last synced 7 days ago.";return t.jsxs("div",{role:"status","aria-live":"polite","data-testid":"quota-grace-banner","data-tone":l,style:{...gw,background:l==="danger"?"var(--color-danger-bg, rgba(220, 50, 47, 0.12))":"var(--color-warn-bg, rgba(203, 75, 22, 0.12))",color:l==="danger"?"var(--color-danger, #dc322f)":"var(--color-warn, #cb4b16)",borderColor:l==="danger"?"var(--color-danger, #dc322f)":"var(--color-warn, #cb4b16)"},children:[t.jsx("span",{style:{fontWeight:500},children:u}),t.jsx("button",{type:"button",onClick:d,disabled:n,"data-testid":"quota-grace-sync",style:vw,children:n?"Syncing…":"Sync now"})]})}function xw(e,r){return r?e<=1?"warn":null:"danger"}const gw={display:"inline-flex",alignItems:"center",gap:12,padding:"6px 12px",borderRadius:6,fontSize:12,border:"1px solid currentColor",fontFamily:"var(--font-system, -apple-system, system-ui)"},vw={padding:"2px 10px",borderRadius:4,border:"1px solid currentColor",background:"transparent",color:"inherit",cursor:"pointer",fontSize:12,fontWeight:500};function yw({active:e,onClick:r,badgeCount:n}){return t.jsxs("button",{type:"button","data-testid":"account-sidebar-entry","data-active":e?"true":"false",onClick:r,style:{display:"flex",alignItems:"center",gap:8,width:"100%",textAlign:"left",padding:"8px 14px",fontSize:13,fontWeight:e?600:500,fontFamily:"var(--font-sans)",color:"var(--text-primary)",background:e?"var(--bg-canvas, #f3f4f6)":"transparent",border:"none",borderLeft:`3px solid ${e?"var(--color-accent, #2563eb)":"transparent"}`,cursor:"pointer"},children:[t.jsx("span",{"aria-hidden":!0,children:"👤"}),t.jsx("span",{style:{flex:1},children:"Account"}),n&&n>0?t.jsx("span",{style:{padding:"1px 6px",fontSize:10,fontWeight:600,background:"var(--color-accent, #2563eb)",color:"#fff",borderRadius:999},children:n}):null]})}const bw={green:"#16a34a",amber:"#f59e0b",grey:"#9ca3af",red:"#dc2626"},kw={green:"Synced",amber:"Reauth needed",grey:"Idle",red:"Error"};function jw({repos:e,viewMode:r="table",pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,onConnectNew:i,now:l=new Date}){const d=Sw(e),u=e.filter(f=>f.isPrivate).slice().sort((f,h)=>f.repoFullName.localeCompare(h.repoFullName)),p=e.filter(f=>!f.isPrivate).slice().sort((f,h)=>f.repoFullName.localeCompare(h.repoFullName));return t.jsxs("div",{"data-testid":"connected-repos-table",style:{width:"100%"},children:[t.jsx(Cw,{summary:d,onConnectNew:i,showConnectAction:!0}),e.length===0?t.jsx(Ew,{}):t.jsxs(t.Fragment,{children:[u.length>0?t.jsx(Vl,{kind:"private",repos:u,viewMode:r,pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,now:l}):null,p.length>0?t.jsx(Vl,{kind:"public",repos:p,viewMode:r,pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,now:l}):null]})]})}function Vl({kind:e,repos:r,viewMode:n,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:l}){const d=e==="private";return t.jsxs("section",{"data-testid":`repos-section-${e}`,"data-visibility":e,style:{marginBottom:16,border:d?"1px solid rgba(245,158,11,0.45)":"1px solid var(--border-default, #e5e7eb)",borderRadius:8,overflow:"hidden"},children:[t.jsxs("header",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 12px",background:d?"rgba(245,158,11,0.10)":"var(--bg-canvas, #f9fafb)",borderBottom:d?"1px solid rgba(245,158,11,0.35)":"1px solid var(--border-default, #e5e7eb)",fontFamily:"var(--font-sans)",fontSize:12},children:[t.jsx(ww,{kind:e}),t.jsx("strong",{style:{color:d?"#92400e":"var(--text-primary)",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:11},children:d?"Private repositories":"Public repositories"}),t.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),t.jsx("span",{style:{color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:r.length}),t.jsx("span",{style:{flex:1}}),t.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:d?"Skills here stay scoped to your account / org.":"Skills here are eligible for the public registry."})]}),n==="cards"?t.jsx(Rw,{repos:r,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:l}):t.jsx(Nw,{repos:r,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:l})]})}function ww({kind:e}){return e==="private"?t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",style:{flexShrink:0,color:"#92400e"},children:[t.jsx("rect",{x:"2.75",y:"7",width:"10.5",height:"6.75",rx:"1.25",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("path",{d:"M5 7V5.25C5 3.59 6.34 2.25 8 2.25C9.66 2.25 11 3.59 11 5.25V7",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",fill:"none"}),t.jsx("circle",{cx:"8",cy:"10.25",r:"0.9",fill:"currentColor"})]}):t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",style:{flexShrink:0,color:"var(--text-secondary)"},children:[t.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.25",fill:"none"}),t.jsx("path",{d:"M2 8H14M8 2C9.5 4 10 6 10 8C10 10 9.5 12 8 14M8 2C6.5 4 6 6 6 8C6 10 6.5 12 8 14",stroke:"currentColor",strokeWidth:"1",fill:"none"})]})}function Sw(e){let r=0,n=0;for(const s of e)s.isPrivate?n++:r++;return{total:e.length,publicCount:r,privateCount:n}}function Cw({summary:e,onConnectNew:r,showConnectAction:n}){return t.jsxs("div",{"data-testid":"repos-summary-chip",style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",marginBottom:12,background:"var(--bg-canvas, #f9fafb)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:8,fontFamily:"var(--font-sans)",fontSize:13},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap",color:"var(--text-primary)",fontWeight:500},children:[t.jsx("strong",{children:e.total}),t.jsxs("span",{children:[e.total===1?"repo":"repos"," connected"]}),t.jsx("span",{"aria-hidden":!0,style:{color:"var(--text-tertiary)"},children:"·"}),t.jsxs("span",{title:"Public repos","aria-label":"Public repos",children:[t.jsx(ca,{isPrivate:!1})," ",e.publicCount]}),t.jsx("span",{"aria-hidden":!0,style:{color:"var(--text-tertiary)"},children:"·"}),t.jsxs("span",{title:"Private repos","aria-label":"Private repos",children:[t.jsx(ca,{isPrivate:!0})," ",e.privateCount]})]}),t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.4},children:"Connect public and private repositories through the GitHub App."})]}),n?t.jsx("button",{type:"button",onClick:r,"data-testid":"connect-new-repo-button",style:{padding:"6px 14px",fontSize:13,fontWeight:500,fontFamily:"inherit",border:"1px solid var(--color-accent, #2563eb)",background:"var(--color-accent, #2563eb)",color:"#fff",borderRadius:6,cursor:"pointer",whiteSpace:"nowrap"},children:"Connect GitHub App"}):null]})}function ca({isPrivate:e}){return t.jsx("span",{"aria-label":e?"Private repository":"Public repository",title:e?"Private repository":"Public repository",style:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:999,border:"1px solid var(--border-default, #e5e7eb)",color:e?"#92400e":"#166534",background:e?"rgba(245, 158, 11, 0.12)":"rgba(22, 163, 74, 0.10)",fontSize:11,fontWeight:600,lineHeight:1,whiteSpace:"nowrap"},children:e?"Private":"Public"})}function Ew(){return t.jsxs("div",{"data-testid":"repos-empty-state",style:{textAlign:"center",padding:"32px 24px",background:"var(--bg-canvas, #f9fafb)",border:"1px dashed var(--border-default, #e5e7eb)",borderRadius:8,fontFamily:"var(--font-sans)"},children:[t.jsx("div",{style:{fontSize:15,fontWeight:600,color:"var(--text-primary)",marginBottom:6},children:"No repositories connected yet."}),t.jsxs("div",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:["Click the ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:"Connect GitHub App"})," ","button above, install the app, then pick the repos to share."]})]})}function Nw({repos:e,pendingActions:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){return t.jsxs("table",{"data-testid":"repos-table",style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--font-sans)",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-default, #e5e7eb)"},children:[t.jsx(rn,{children:"Repository"}),t.jsx(rn,{align:"right",children:"Skills"}),t.jsx(rn,{children:"Status"}),t.jsx(rn,{children:"Last activity"}),t.jsx(rn,{align:"right",style:{width:48},children:t.jsx("span",{style:{visibility:"hidden"},children:"Actions"})})]})}),t.jsx("tbody",{children:e.map(i=>t.jsx(Tw,{repo:i,pending:r==null?void 0:r[i.repoId],onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a},i.repoId))})]})}function Rw({repos:e,pendingActions:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){return t.jsx("div",{"data-testid":"repos-card-list",style:{display:"flex",flexDirection:"column",gap:8},children:e.map(i=>t.jsx(Iw,{repo:i,pending:r==null?void 0:r[i.repoId],onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a},i.repoId))})}function Tw({repo:e,pending:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){const[i,l]=c.useState(!1);return t.jsxs("tr",{"data-testid":`repo-row-${e.repoId}`,style:{borderBottom:"1px solid var(--border-default, #e5e7eb)"},children:[t.jsx(nn,{children:t.jsx(Ju,{repo:e})}),t.jsx(nn,{align:"right",children:e.skillsCount===0?t.jsx("span",{style:{color:"var(--text-tertiary)"},children:"—"}):t.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:e.skillsCount})}),t.jsx(nn,{children:t.jsx(Qu,{status:e.syncStatus,errorMessage:e.lastErrorMessage})}),t.jsx(nn,{children:t.jsx("span",{style:{color:"var(--text-secondary)"},children:Zu(e.lastActivityAt,a)})}),t.jsx(nn,{align:"right",children:t.jsx(Xu,{repo:e,pending:r,isOpen:i,onToggle:()=>l(d=>!d),onClose:()=>l(!1),onOpenOnGitHub:n,onResync:s,onDisconnect:o})})]})}function Iw({repo:e,pending:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){const[i,l]=c.useState(!1);return t.jsxs("div",{"data-testid":`repo-card-${e.repoId}`,style:{padding:14,border:"1px solid var(--border-default, #e5e7eb)",borderRadius:8,background:"var(--bg-elevated, #fff)",display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[t.jsx(Ju,{repo:e}),t.jsx(Xu,{repo:e,pending:r,isOpen:i,onToggle:()=>l(d=>!d),onClose:()=>l(!1),onOpenOnGitHub:n,onResync:s,onDisconnect:o})]}),t.jsx(No,{label:"Skills",children:e.skillsCount===0?"—":String(e.skillsCount)}),t.jsx(No,{label:"Status",children:t.jsx(Qu,{status:e.syncStatus,errorMessage:e.lastErrorMessage})}),t.jsx(No,{label:"Last activity",children:Zu(e.lastActivityAt,a)})]})}function Ju({repo:e}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx(ca,{isPrivate:e.isPrivate}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.repoFullName})]})}function Qu({status:e,errorMessage:r}){const n=bw[e],s=kw[e],o=e==="red"&&r?r:s;return t.jsxs("span",{"data-testid":`status-${e}`,title:o,style:{display:"inline-flex",alignItems:"center",gap:6},children:[t.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",background:n,display:"inline-block"}}),t.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:s})]})}function No({label:e,children:r}){return t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:12},children:[t.jsx("span",{style:{color:"var(--text-tertiary)"},children:e}),t.jsx("span",{style:{color:"var(--text-primary)"},children:r})]})}function Xu({repo:e,pending:r,isOpen:n,onToggle:s,onClose:o,onOpenOnGitHub:a,onResync:i,onDisconnect:l}){return t.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[t.jsx("button",{type:"button","aria-label":`Actions for ${e.repoFullName}`,"aria-expanded":n,"aria-haspopup":"menu","data-testid":`kebab-${e.repoId}`,onClick:s,disabled:r==="disconnect",style:{width:28,height:28,padding:0,border:"1px solid transparent",background:"transparent",borderRadius:4,cursor:r==="disconnect"?"not-allowed":"pointer",color:"var(--text-secondary)",fontSize:16,lineHeight:1},children:"⋯"}),n&&t.jsxs("div",{role:"menu","data-testid":`kebab-menu-${e.repoId}`,style:{position:"absolute",top:"100%",right:0,marginTop:4,minWidth:180,background:"var(--bg-elevated, #fff)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,boxShadow:"0 6px 18px rgba(0,0,0,0.12)",zIndex:10,padding:4},children:[t.jsx(Ro,{onClick:()=>{a(e),o()},children:"Open on GitHub"}),t.jsx(Ro,{disabled:r==="resync",onClick:async()=>{await i(e),o()},children:r==="resync"?"Resyncing…":"Resync now"}),t.jsx(Ro,{danger:!0,onClick:async()=>{await l(e),o()},children:"Disconnect"})]})]})}function Ro({children:e,onClick:r,disabled:n,danger:s}){return t.jsx("button",{type:"button",role:"menuitem",onClick:r,disabled:n,style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",fontSize:13,fontFamily:"inherit",background:"transparent",border:"none",borderRadius:4,cursor:n?"not-allowed":"pointer",color:s?"#dc2626":"var(--text-primary)",opacity:n?.6:1},children:e})}function rn({children:e,align:r="left",style:n}){return t.jsx("th",{style:{textAlign:r,padding:"10px 12px",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-secondary)",...n},children:e})}function nn({children:e,align:r="left"}){return t.jsx("td",{style:{textAlign:r,padding:"12px 12px",verticalAlign:"middle"},children:e})}function Zu(e,r){if(!e)return"Never";const n=new Date(e).getTime();if(Number.isNaN(n))return"Never";const s=r.getTime()-n;if(s<0)return"Just now";const o=Math.floor(s/1e3);if(o<60)return"Just now";const a=Math.floor(o/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);if(i<24)return`${i}h ago`;const l=Math.floor(i/24);if(l<30)return`${l}d ago`;const d=Math.floor(l/30);return d<12?`${d}mo ago`:`${Math.floor(l/365)}y ago`}const To=80,Io=280;function Lw({profile:e,onSubmit:r,saving:n=!1,errorMessage:s=null}){const[o,a]=c.useState(e.displayName),[i,l]=c.useState(e.bio??""),[d,u]=c.useState(e.publicProfile);c.useEffect(()=>{a(e.displayName),l(e.bio??""),u(e.publicProfile)},[e.userId,e.displayName,e.bio,e.publicProfile]);const p=o!==e.displayName||i!==(e.bio??"")||d!==e.publicProfile,f=o.length>To,h=i.length>Io,m=o.trim().length>0&&!f&&!h;async function g(v){if(v.preventDefault(),!p||!m||n)return;const x={};o!==e.displayName&&(x.displayName=o),i!==(e.bio??"")&&(x.bio=i||null),d!==e.publicProfile&&(x.publicProfile=d),await r(x)}return t.jsxs("form",{"data-testid":"profile-form",onSubmit:g,style:{display:"flex",flexDirection:"column",gap:18,maxWidth:560,fontFamily:"var(--font-sans)"},children:[t.jsx(Aw,{profile:e}),t.jsxs(Lo,{label:"Display name",htmlFor:"profile-display-name",children:[t.jsx("input",{id:"profile-display-name","data-testid":"profile-display-name",type:"text",value:o,maxLength:To+20,disabled:n,onChange:v=>a(v.target.value),style:Ao}),t.jsx(Gl,{current:o.length,max:To})]}),t.jsx(Lo,{label:"GitHub handle",htmlFor:"profile-github-handle",caption:"Synced from GitHub",children:t.jsx("input",{id:"profile-github-handle",type:"text",value:e.githubHandle,readOnly:!0,"aria-readonly":"true",style:{...Ao,background:"var(--bg-canvas, #f3f4f6)"}})}),t.jsxs(Lo,{label:"Public bio",htmlFor:"profile-bio",children:[t.jsx("textarea",{id:"profile-bio","data-testid":"profile-bio",value:i,maxLength:Io+40,rows:3,disabled:n,onChange:v=>l(v.target.value),style:{...Ao,fontFamily:"inherit",resize:"vertical"}}),t.jsx(Gl,{current:i.length,max:Io})]}),t.jsx(Pw,{label:"Public profile page",helper:"Your bio + public skills appear on a verified-skill.com/u/{handle} page.",checked:d,disabled:n,onChange:u}),s&&t.jsx("div",{role:"alert","data-testid":"profile-form-error",style:{padding:"8px 12px",background:"rgba(220, 38, 38, 0.08)",border:"1px solid rgba(220, 38, 38, 0.4)",color:"#991b1b",borderRadius:6,fontSize:13},children:s}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{type:"submit","data-testid":"profile-save-button",disabled:!p||!m||n,style:{padding:"8px 20px",fontSize:13,fontWeight:500,fontFamily:"inherit",border:"1px solid var(--color-accent, #2563eb)",background:!p||!m||n?"var(--bg-canvas, #f3f4f6)":"var(--color-accent, #2563eb)",color:!p||!m||n?"var(--text-tertiary, #9ca3af)":"#fff",borderColor:!p||!m||n?"var(--border-default, #e5e7eb)":"var(--color-accent, #2563eb)",borderRadius:6,cursor:!p||!m||n?"not-allowed":"pointer"},children:n?"Saving…":"Save changes"})})]})}function Aw({profile:e}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14},children:[e.avatarUrl?t.jsx("img",{src:e.avatarUrl,alt:`Avatar for ${e.githubHandle}`,width:56,height:56,style:{width:56,height:56,borderRadius:"50%",objectFit:"cover",border:"1px solid var(--border-default, #e5e7eb)",background:"var(--bg-canvas, #f3f4f6)"}}):t.jsx("div",{"aria-hidden":!0,style:{width:56,height:56,borderRadius:"50%",background:"var(--bg-canvas, #f3f4f6)",border:"1px solid var(--border-default, #e5e7eb)"}}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:e.displayName||e.githubHandle}),t.jsxs("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:["@",e.githubHandle]})]})]})}function Lo({label:e,htmlFor:r,caption:n,children:s}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{htmlFor:r,style:{fontSize:13,fontWeight:500,color:"var(--text-primary)"},children:e}),s,n&&t.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:n})]})}function Gl({current:e,max:r}){const n=e>r;return t.jsxs("span",{style:{alignSelf:"flex-end",fontSize:11,color:n?"#dc2626":"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:[e,"/",r]})}function Pw({label:e,helper:r,checked:n,disabled:s,onChange:o}){return t.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:10,cursor:s?"not-allowed":"pointer"},children:[t.jsx("input",{type:"checkbox","data-testid":"profile-public-toggle",checked:n,disabled:s,onChange:a=>o(a.target.checked),style:{marginTop:2}}),t.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--text-primary)"},children:e}),r&&t.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:r})]})]})}const Ao={width:"100%",padding:"8px 10px",fontSize:13,fontFamily:"inherit",color:"var(--text-primary)",background:"var(--bg-elevated, #fff)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,boxSizing:"border-box"},$w={free:{label:"Free",badge:"Open Source · MIT",bullets:["Unlimited public skills","Public GitHub repo connections","Community support"],upgradeLabel:"Upgrade to Pro"},pro:{label:"Pro",badge:"Active",bullets:["Hosted private skill storage","Connect private GitHub repos","Sync skills automatically","Priority email support"],upgradeLabel:"Talk to sales about Enterprise"},enterprise:{label:"Enterprise",badge:"Active",bullets:["Everything in Pro","SSO + audit log","Dedicated support","Custom contract"],upgradeLabel:null}};function Mw({tier:e,onUpgradeClick:r,showUpgradeCta:n=!0}){const s=$w[e];return t.jsxs("div",{"data-testid":`plan-card-${e}`,style:{padding:20,border:"1px solid var(--border-default, #e5e7eb)",borderRadius:10,background:"var(--bg-elevated, #fff)",fontFamily:"var(--font-sans)",display:"flex",flexDirection:"column",gap:14},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12},children:[t.jsx("h3",{style:{margin:0,fontSize:20,fontWeight:600,color:"var(--text-primary)"},children:s.label}),t.jsx("span",{"data-testid":"plan-card-badge",style:{padding:"2px 10px",fontSize:11,fontWeight:500,background:e==="free"?"rgba(37, 99, 235, 0.1)":"rgba(22, 163, 74, 0.1)",color:e==="free"?"#1d4ed8":"#15803d",borderRadius:999},children:s.badge})]})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-secondary)",marginBottom:6},children:"What's included"}),t.jsx("ul",{style:{margin:0,paddingLeft:18,display:"flex",flexDirection:"column",gap:4,fontSize:13,color:"var(--text-primary)"},children:s.bullets.map(o=>t.jsx("li",{children:o},o))})]}),n&&s.upgradeLabel&&t.jsx("div",{children:t.jsx("button",{type:"button","data-testid":"plan-card-upgrade",onClick:r,disabled:!r,style:{padding:"8px 16px",fontSize:13,fontWeight:500,fontFamily:"inherit",background:r?"var(--color-accent, #2563eb)":"var(--bg-canvas, #f3f4f6)",color:r?"#fff":"var(--text-tertiary, #9ca3af)",border:`1px solid ${r?"var(--color-accent, #2563eb)":"var(--border-default, #e5e7eb)"}`,borderRadius:6,cursor:r?"pointer":"not-allowed"},children:s.upgradeLabel})})]})}const Fw=[{value:30,label:"30 days"},{value:90,label:"90 days"},{value:365,label:"1 year"},{value:0,label:"Never"}];function Dw({tokens:e,recentlyCreated:r,onDismissRecentlyCreated:n,onCreate:s,onRevoke:o,pendingRevokeId:a,creating:i=!1,now:l=new Date}){const[d,u]=c.useState(!1),[p,f]=c.useState(null);return t.jsxs("div",{"data-testid":"tokens-table-root",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:"API tokens"}),t.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--text-secondary)"},children:"For CLI and automation access; repository sync uses GitHub connections instead."})]}),t.jsx("button",{type:"button","data-testid":"tokens-generate-button",onClick:()=>u(!0),disabled:i,style:{padding:"8px 14px",fontSize:13,fontWeight:500,fontFamily:"inherit",background:"var(--color-accent, #2563eb)",color:"#fff",border:"1px solid var(--color-accent, #2563eb)",borderRadius:6,cursor:i?"not-allowed":"pointer",opacity:i?.6:1},children:"Generate new token"})]}),t.jsx("div",{"data-testid":"tokens-scope-note",style:{marginBottom:12,padding:"10px 12px",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:8,background:"var(--bg-elevated, #fff)",color:"var(--text-secondary)",fontSize:12,lineHeight:1.45},children:"Keep this page for scripts that call verified-skill APIs. To connect public or private repositories, use Connected repositories."}),e.length===0?t.jsx(zw,{onGenerateClick:()=>u(!0)}):t.jsxs("table",{"data-testid":"tokens-table",style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--font-sans)",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-default, #e5e7eb)"},children:[t.jsx(Nr,{children:"Name"}),t.jsx(Nr,{children:"Prefix"}),t.jsx(Nr,{children:"Scopes"}),t.jsx(Nr,{children:"Last used"}),t.jsx(Nr,{children:"Created"}),t.jsx(Nr,{align:"right",children:"Actions"})]})}),t.jsx("tbody",{children:e.map(h=>t.jsxs("tr",{"data-testid":`token-row-${h.id}`,style:{borderBottom:"1px solid var(--border-default, #e5e7eb)",opacity:h.revokedAt?.55:1},children:[t.jsx(Rr,{children:h.name}),t.jsx(Rr,{children:t.jsxs("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)"},children:[h.prefix,"…"]})}),t.jsx(Rr,{children:h.scopes.join(", ")}),t.jsx(Rr,{children:ql(h.lastUsedAt,l)}),t.jsx(Rr,{children:ql(h.createdAt,l)}),t.jsx(Rr,{align:"right",children:h.revokedAt?t.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Revoked"}):t.jsx("button",{type:"button","data-testid":`token-revoke-${h.id}`,disabled:a===h.id,onClick:()=>f(h),style:{padding:"4px 10px",fontSize:12,fontFamily:"inherit",background:"transparent",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:4,color:"#dc2626",cursor:a===h.id?"not-allowed":"pointer"},children:a===h.id?"Revoking…":"Revoke"})})]},h.id))})]}),d&&t.jsx(Bw,{creating:i,onCancel:()=>u(!1),onSubmit:async h=>{await s(h),u(!1)}}),r&&t.jsx(_w,{created:r,onDismiss:()=>n==null?void 0:n()}),p&&t.jsx(Ow,{token:p,pending:a===p.id,onCancel:()=>f(null),onConfirm:async()=>{await o(p),f(null)}})]})}function zw({onGenerateClick:e}){return t.jsxs("div",{"data-testid":"tokens-empty-state",style:{textAlign:"center",padding:"40px 20px",background:"var(--bg-canvas, #f9fafb)",border:"1px dashed var(--border-default, #e5e7eb)",borderRadius:8,fontFamily:"var(--font-sans)"},children:[t.jsx("div",{style:{fontSize:14,color:"var(--text-primary)",marginBottom:6},children:"No API tokens yet"}),t.jsx("div",{style:{fontSize:13,color:"var(--text-secondary)",marginBottom:14},children:"Generate one only for local CLI auth, CI, or another scripted integration. GitHub repository access is managed separately."}),t.jsx("button",{type:"button",onClick:e,style:{padding:"6px 14px",fontSize:13,fontFamily:"inherit",background:"var(--color-accent, #2563eb)",color:"#fff",border:"none",borderRadius:6,cursor:"pointer"},children:"Generate new token"})]})}function Bw({creating:e,onCancel:r,onSubmit:n}){const[s,o]=c.useState(""),[a,i]=c.useState(!0),[l,d]=c.useState(!1),[u,p]=c.useState(90),f=s.trim().length>0&&(a||l);return t.jsxs(Ua,{title:"Generate new token",onDismiss:r,testId:"tokens-generate-modal",children:[t.jsx(Po,{label:"Name",htmlFor:"token-name",children:t.jsx("input",{id:"token-name","data-testid":"token-name-input",type:"text",value:s,maxLength:64,disabled:e,onChange:h=>o(h.target.value),placeholder:"e.g. Build CI",style:Yl})}),t.jsx(Po,{label:"Scopes",children:t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(Kl,{label:"read",checked:a,disabled:e,onChange:i,testId:"scope-read"}),t.jsx(Kl,{label:"write",checked:l,disabled:e,onChange:d,testId:"scope-write"})]})}),t.jsx(Po,{label:"Expiry",children:t.jsx("select",{"data-testid":"token-expiry-select",value:u,disabled:e,onChange:h=>p(Number(h.target.value)),style:Yl,children:Fw.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value))})}),t.jsxs(Ha,{children:[t.jsx(Va,{onClick:r,disabled:e,children:"Cancel"}),t.jsx(ep,{disabled:!f||e,onClick:()=>{const h=[];a&&h.push("read"),l&&h.push("write"),n({name:s.trim(),scopes:h,expiresInDays:u})},children:e?"Generating…":"Generate"})]})]})}function _w({created:e,onDismiss:r}){const[n,s]=c.useState(!1);async function o(){try{await navigator.clipboard.writeText(e.plaintext),s(!0)}catch{}}return t.jsxs(Ua,{title:"Token created",onDismiss:r,testId:"tokens-created-modal",children:[t.jsxs("p",{style:{margin:0,fontSize:13,color:"var(--text-primary)",background:"rgba(245, 158, 11, 0.12)",border:"1px solid rgba(245, 158, 11, 0.4)",padding:12,borderRadius:6},children:[t.jsx("strong",{children:"This is the only time you'll see this token."})," Store it somewhere safe — verified-skill never stores the plaintext."]}),t.jsx("div",{"data-testid":"tokens-plaintext",style:{fontFamily:"var(--font-mono)",fontSize:13,padding:12,background:"var(--bg-canvas, #f3f4f6)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,wordBreak:"break-all",userSelect:"all"},children:e.plaintext}),t.jsxs(Ha,{children:[t.jsx(Va,{onClick:o,children:n?"Copied!":"Copy to clipboard"}),t.jsx(ep,{onClick:r,children:"Done"})]})]})}function Ow({token:e,pending:r,onCancel:n,onConfirm:s}){return t.jsxs(Ua,{title:`Revoke ${e.prefix}…?`,onDismiss:n,testId:"tokens-revoke-modal",children:[t.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-primary)"},children:"Any process using this token will fail immediately. This cannot be undone."}),t.jsxs(Ha,{children:[t.jsx(Va,{onClick:n,disabled:r,children:"Cancel"}),t.jsx(Ww,{disabled:r,onClick:()=>void s(),children:r?"Revoking…":"Revoke"})]})]})}function Ua({title:e,testId:r,onDismiss:n,children:s}){return t.jsx("div",{role:"dialog","aria-modal":"true","aria-label":e,"data-testid":r,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,fontFamily:"var(--font-sans)"},onClick:o=>{o.target===o.currentTarget&&n()},children:t.jsxs("div",{style:{width:"min(440px, calc(100vw - 32px))",background:"var(--bg-elevated, #fff)",borderRadius:10,border:"1px solid var(--border-default, #e5e7eb)",boxShadow:"0 18px 40px rgba(0,0,0,0.18)",padding:20,display:"flex",flexDirection:"column",gap:14},children:[t.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:e}),s]})})}function Ha({children:e}){return t.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:e})}function ep({children:e,onClick:r,disabled:n}){return t.jsx("button",{type:"button",onClick:r,disabled:n,style:{padding:"8px 16px",fontSize:13,fontFamily:"inherit",background:n?"var(--bg-canvas, #f3f4f6)":"var(--color-accent, #2563eb)",color:n?"var(--text-tertiary)":"#fff",border:`1px solid ${n?"var(--border-default, #e5e7eb)":"var(--color-accent, #2563eb)"}`,borderRadius:6,cursor:n?"not-allowed":"pointer"},children:e})}function Va({children:e,onClick:r,disabled:n}){return t.jsx("button",{type:"button",onClick:r,disabled:n,style:{padding:"8px 16px",fontSize:13,fontFamily:"inherit",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,cursor:n?"not-allowed":"pointer",opacity:n?.6:1},children:e})}function Ww({children:e,onClick:r,disabled:n}){return t.jsx("button",{type:"button",onClick:r,disabled:n,style:{padding:"8px 16px",fontSize:13,fontFamily:"inherit",background:n?"var(--bg-canvas, #f3f4f6)":"#dc2626",color:n?"var(--text-tertiary)":"#fff",border:"1px solid #dc2626",borderRadius:6,cursor:n?"not-allowed":"pointer",opacity:n?.6:1},children:e})}function Po({label:e,htmlFor:r,children:n}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{htmlFor:r,style:{fontSize:12,fontWeight:500,color:"var(--text-primary)"},children:e}),n]})}function Kl({label:e,checked:r,onChange:n,disabled:s,testId:o}){return t.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:13,cursor:s?"not-allowed":"pointer",color:"var(--text-primary)"},children:[t.jsx("input",{type:"checkbox","data-testid":o,checked:r,disabled:s,onChange:a=>n(a.target.checked)}),e]})}function Nr({children:e,align:r="left"}){return t.jsx("th",{style:{textAlign:r,padding:"10px 12px",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-secondary)"},children:e})}function Rr({children:e,align:r="left"}){return t.jsx("td",{style:{textAlign:r,padding:"12px 12px",verticalAlign:"middle"},children:e})}function ql(e,r){if(!e)return"—";const n=new Date(e).getTime();if(Number.isNaN(n))return"—";const s=r.getTime()-n;if(s<6e4)return"Just now";const o=Math.floor(s/6e4);if(o<60)return`${o}m ago`;const a=Math.floor(o/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);if(i<30)return`${i}d ago`;const l=Math.floor(i/30);return l<12?`${l}mo ago`:`${Math.floor(i/365)}y ago`}const Yl={width:"100%",padding:"8px 10px",fontSize:13,fontFamily:"inherit",color:"var(--text-primary)",background:"var(--bg-elevated, #fff)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,boxSizing:"border-box"},Uw=[{key:"weeklyDigest",label:"Weekly digest",helper:"Daily/weekly digest emails ship in a future update.",defaultOn:!1},{key:"securityAlerts",label:"Security alerts",helper:"We'll always notify you about suspicious account activity.",forcedOn:!0,defaultOn:!0},{key:"commentReplies",label:"Comment replies",defaultOn:!0},{key:"productUpdates",label:"Product updates",helper:"Marketing emails — opt out anytime.",defaultOn:!1}];function Hw({prefs:e,onSubmit:r,saving:n=!1,errorMessage:s=null}){const[o,a]=c.useState(()=>Jl(e));c.useEffect(()=>{a(Jl(e))},[e]);const i=o.weeklyDigest!==e.weeklyDigest||o.commentReplies!==e.commentReplies||o.productUpdates!==e.productUpdates;function l(u,p){a(f=>({...f,[u]:p}))}async function d(u){u.preventDefault(),!(!i||n)&&await r({...o,securityAlerts:!0})}return t.jsxs("form",{"data-testid":"notifications-form",onSubmit:d,style:{display:"flex",flexDirection:"column",gap:16,maxWidth:560,fontFamily:"var(--font-sans)"},children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:Uw.map(u=>t.jsx(Vw,{meta:u,checked:u.forcedOn?!0:!!o[u.key],disabled:n||!!u.forcedOn,onChange:p=>{u.key!=="securityAlerts"&&l(u.key,p)}},u.key))}),s&&t.jsx("div",{role:"alert","data-testid":"notifications-form-error",style:{padding:"8px 12px",background:"rgba(220, 38, 38, 0.08)",border:"1px solid rgba(220, 38, 38, 0.4)",color:"#991b1b",borderRadius:6,fontSize:13},children:s}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{type:"submit","data-testid":"notifications-save-button",disabled:!i||n,style:{padding:"8px 20px",fontSize:13,fontWeight:500,fontFamily:"inherit",border:`1px solid ${!i||n?"var(--border-default, #e5e7eb)":"var(--color-accent, #2563eb)"}`,background:!i||n?"var(--bg-canvas, #f3f4f6)":"var(--color-accent, #2563eb)",color:!i||n?"var(--text-tertiary, #9ca3af)":"#fff",borderRadius:6,cursor:!i||n?"not-allowed":"pointer"},children:n?"Saving…":"Save preferences"})})]})}function Vw({meta:e,checked:r,disabled:n,onChange:s}){return t.jsxs("label",{"data-testid":`notif-row-${e.key}`,style:{display:"flex",alignItems:"flex-start",gap:10,padding:12,border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,background:"var(--bg-elevated, #fff)",cursor:n&&!e.forcedOn?"not-allowed":"pointer",opacity:n&&!e.forcedOn?.7:1},children:[t.jsx("input",{type:"checkbox","data-testid":`notif-checkbox-${e.key}`,checked:r,disabled:n,onChange:o=>s(o.target.checked),style:{marginTop:2}}),t.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:4,flex:1},children:[t.jsxs("span",{style:{fontSize:13,fontWeight:500,color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8},children:[e.label,e.forcedOn&&t.jsx("span",{style:{fontSize:10,fontWeight:500,padding:"2px 8px",background:"rgba(37, 99, 235, 0.1)",color:"#1d4ed8",borderRadius:999},children:"Always on"})]}),e.helper&&t.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:e.helper})]})]})}function Jl(e){return{weeklyDigest:!!e.weeklyDigest,securityAlerts:!0,commentReplies:e.commentReplies??!0,productUpdates:!!e.productUpdates}}function Gw({githubHandle:e,exports:r=[],onSignOutAll:n,onExportRequest:s,onDeleteAccount:o,pending:a,errorMessage:i=null}){const[l,d]=c.useState(!1),[u,p]=c.useState(!1);return t.jsxs("div",{"data-testid":"danger-zone",style:{display:"flex",flexDirection:"column",gap:14,fontFamily:"var(--font-sans)"},children:[t.jsx($o,{title:"Sign out of all devices",description:"Revoke every active session and API token. You'll need to sign back in everywhere.",actionLabel:a!=null&&a.signOutAll?"Signing out…":"Sign out everywhere",actionDisabled:a==null?void 0:a.signOutAll,onClick:()=>d(!0)}),t.jsx($o,{title:"Export my data",description:"Queue an export of your skills, profile, and connected-repo metadata. Download link emailed within 24 hours.",actionLabel:a!=null&&a.exportRequest?"Queuing…":"Export my data",actionDisabled:a==null?void 0:a.exportRequest,onClick:()=>void s(),children:t.jsx(Kw,{exports:r})}),t.jsx($o,{title:"Delete account",description:"Soft-delete your account. We retain your data for 30 days, then purge permanently. Connected repos are disconnected; tokens revoked.",actionLabel:"Delete account…",actionDisabled:a==null?void 0:a.deleteAccount,destructive:!0,onClick:()=>p(!0)}),i&&t.jsx("div",{role:"alert","data-testid":"danger-zone-error",style:{padding:"8px 12px",background:"rgba(220, 38, 38, 0.08)",border:"1px solid rgba(220, 38, 38, 0.4)",color:"#991b1b",borderRadius:6,fontSize:13},children:i}),l&&t.jsx(qw,{pending:!!(a!=null&&a.signOutAll),onCancel:()=>d(!1),onConfirm:async()=>{await n(),d(!1)}}),u&&t.jsx(Yw,{githubHandle:e,pending:!!(a!=null&&a.deleteAccount),onCancel:()=>p(!1),onConfirm:async f=>{await o(f),p(!1)}})]})}function $o({title:e,description:r,actionLabel:n,actionDisabled:s,destructive:o,onClick:a,children:i}){return t.jsxs("section",{"data-testid":`danger-card-${e.toLowerCase().replace(/\s+/g,"-")}`,style:{padding:16,border:"1px solid rgba(220, 38, 38, 0.4)",borderRadius:8,background:"rgba(220, 38, 38, 0.04)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[t.jsxs("div",{style:{flex:1},children:[t.jsx("h3",{style:{margin:0,fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:e}),t.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:r})]}),t.jsx("button",{type:"button",onClick:a,disabled:s,style:{padding:"6px 14px",fontSize:13,fontFamily:"inherit",background:o?"#dc2626":"transparent",color:o?"#fff":"#dc2626",border:"1px solid #dc2626",borderRadius:6,cursor:s?"not-allowed":"pointer",opacity:s?.6:1,whiteSpace:"nowrap"},children:n})]}),i]})}function Kw({exports:e}){return e.length===0?t.jsx("div",{style:{marginTop:12,padding:10,fontSize:12,color:"var(--text-tertiary)",background:"var(--bg-elevated, #fff)",border:"1px dashed var(--border-default, #e5e7eb)",borderRadius:6},children:"No export jobs yet."}):t.jsxs("table",{"data-testid":"exports-table",style:{marginTop:12,width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-default, #e5e7eb)"},children:[t.jsx("th",{style:Mo,children:"Requested"}),t.jsx("th",{style:Mo,children:"Status"}),t.jsx("th",{style:Mo,children:"Download"})]})}),t.jsx("tbody",{children:e.map(r=>t.jsxs("tr",{style:{borderBottom:"1px solid var(--border-default, #e5e7eb)"},children:[t.jsx("td",{style:Fo,children:new Date(r.requestedAt).toLocaleString()}),t.jsx("td",{style:Fo,children:r.status}),t.jsx("td",{style:Fo,children:r.status==="ready"&&r.downloadUrl?t.jsx("a",{href:r.downloadUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--color-accent, #2563eb)"},children:"Download"}):t.jsx("span",{style:{color:"var(--text-tertiary)"},children:"—"})})]},r.id))})]})}function qw({pending:e,onCancel:r,onConfirm:n}){return t.jsxs(tp,{title:"Sign out of all devices?",onDismiss:r,testId:"sign-out-all-modal",children:[t.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-primary)"},children:"Every active session and API token will be revoked. You'll need to sign back in on every device. This cannot be undone."}),t.jsxs(rp,{children:[t.jsx(np,{onClick:r,disabled:e,children:"Cancel"}),t.jsx(sp,{disabled:e,onClick:()=>void n(),children:e?"Signing out…":"Sign out everywhere"})]})]})}function Yw({githubHandle:e,pending:r,onCancel:n,onConfirm:s}){const[o,a]=c.useState(""),i=o.trim()===e;return t.jsxs(tp,{title:"Delete your account?",onDismiss:n,testId:"delete-account-modal",children:[t.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-primary)",lineHeight:1.5},children:"Your account will be soft-deleted for 30 days, then purged permanently. Connected repos are disconnected, API tokens revoked, and skills you've published become orphaned."}),t.jsxs("p",{style:{margin:0,fontSize:13,color:"var(--text-primary)"},children:["Type ",t.jsx("strong",{children:e})," to confirm:"]}),t.jsx("input",{type:"text","data-testid":"delete-account-confirm-input",value:o,onChange:l=>a(l.target.value),autoFocus:!0,placeholder:e,disabled:r,style:{width:"100%",padding:"8px 10px",fontSize:13,fontFamily:"var(--font-mono)",color:"var(--text-primary)",background:"var(--bg-elevated, #fff)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,boxSizing:"border-box"}}),t.jsxs(rp,{children:[t.jsx(np,{onClick:n,disabled:r,children:"Cancel"}),t.jsx(sp,{disabled:!i||r,onClick:()=>void s(o.trim()),children:r?"Deleting…":"Delete account"})]})]})}function tp({title:e,testId:r,onDismiss:n,children:s}){return t.jsx("div",{role:"dialog","aria-modal":"true","aria-label":e,"data-testid":r,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,fontFamily:"var(--font-sans)"},onClick:o=>{o.target===o.currentTarget&&n()},children:t.jsxs("div",{style:{width:"min(440px, calc(100vw - 32px))",background:"var(--bg-elevated, #fff)",borderRadius:10,border:"1px solid var(--border-default, #e5e7eb)",boxShadow:"0 18px 40px rgba(0,0,0,0.18)",padding:20,display:"flex",flexDirection:"column",gap:14},children:[t.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:e}),s]})})}function rp({children:e}){return t.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:e})}function np({children:e,onClick:r,disabled:n}){return t.jsx("button",{type:"button",onClick:r,disabled:n,style:{padding:"8px 16px",fontSize:13,fontFamily:"inherit",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default, #e5e7eb)",borderRadius:6,cursor:n?"not-allowed":"pointer",opacity:n?.6:1},children:e})}function sp({children:e,onClick:r,disabled:n}){return t.jsx("button",{type:"button",onClick:r,disabled:n,style:{padding:"8px 16px",fontSize:13,fontFamily:"inherit",background:n?"var(--bg-canvas, #f3f4f6)":"#dc2626",color:n?"var(--text-tertiary)":"#fff",border:"1px solid #dc2626",borderRadius:6,cursor:n?"not-allowed":"pointer",opacity:n?.6:1},children:e})}const Mo={textAlign:"left",padding:"8px 10px",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-secondary)"},Fo={padding:"8px 10px",color:"var(--text-primary)"},Jw="/api/v1/submissions/stream?mine=1",Do=new Set([...vs,...ya]);function Qw(e){return!!e&&typeof e=="object"&&typeof e.submissionId=="string"&&typeof e.state=="string"}function Xw(e){const r=new Date(e);return Number.isNaN(r.getTime())?"—":r.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Zw(e){return vs.has(e)?"#22C55E":ya.has(e)?"#EF4444":"#F59E0B"}function eS({openStream:e=Ou,notify:r=Tc}={}){const[n,s]=c.useState([]),[o,a]=c.useState({}),[i,l]=c.useState(!0),[d,u]=c.useState(null),[p,f]=c.useState(!1),h=c.useRef(new Set),m=c.useRef(!0),g=c.useCallback(async()=>{l(!0),u(null);try{const x=await ce.getMyQueue();if(!m.current)return;const b=x.submissions??[];s(b),a(x.queuePositions??{}),h.current=new Set(b.map(y=>y.id));for(const y of b)Do.has(y.state)&&jh(y.id,y.state)}catch(x){if(!m.current)return;u(x instanceof Error?x.message:String(x))}finally{m.current&&l(!1)}},[]),v=c.useCallback(x=>{h.current.has(x.submissionId)&&(s(b=>{let y=!1;const j=b.map(S=>S.id!==x.submissionId?S:(y=!0,{...S,state:x.state,skillName:x.skillName||S.skillName,updatedAt:x.timestamp||S.updatedAt}));return y?j:b}),Do.has(x.state)&&(a(b=>{if(!(x.submissionId in b))return b;const y={...b};return delete y[x.submissionId],y}),Rc(x.submissionId,x.state)&&r(x.submissionId,x.skillName,x.state)))},[r]);return c.useEffect(()=>(m.current=!0,g(),()=>{m.current=!1}),[g]),c.useEffect(()=>{let x=null,b=null,y=0,j=!1;const S=()=>{j||(x=e(Jw,{timeoutMs:6e5,onEvent:R=>{if(j||(f(!0),y=0,!R.data||R.data==="connected"||R.data==="keepalive"))return;let w;try{w=JSON.parse(R.data)}catch{return}Qw(w)&&v(w)},onError:()=>{j||(f(!1),k())},onClose:()=>{j||(f(!1),k())}}))},k=()=>{if(j||b!=null)return;const R=Math.min(1e3*2**y,3e4);y+=1,b=setTimeout(()=>{if(b=null,!j){try{x==null||x.close()}catch{}S()}},R)};return S(),()=>{j=!0,b!=null&&clearTimeout(b);try{x==null||x.close()}catch{}}},[]),t.jsxs("section",{"data-testid":"submission-queue-panel","aria-label":"My submission queue",style:{fontFamily:"var(--font-mono, monospace)"},children:[t.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[t.jsx("strong",{style:{fontSize:13,letterSpacing:"-0.01em"},children:"My submissions"}),t.jsxs("span",{"data-testid":"queue-stream-status",title:p?"Live":"Reconnecting…",style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em",color:p?"#22C55E":"#9CA3AF"},children:[t.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:p?"#22C55E":"#9CA3AF",display:"inline-block"}}),p?"Live":"Offline"]})]}),i&&t.jsx("div",{"data-testid":"queue-loading",style:{fontSize:12,color:"#9CA3AF",padding:"8px 0"},children:"Loading your submissions…"}),d&&!i&&t.jsxs("div",{role:"alert","data-testid":"queue-error",style:{fontSize:12,color:"#EF4444",padding:"8px 0"},children:["Couldn’t load your submissions: ",d," ",t.jsx("button",{type:"button",onClick:()=>void g(),style:{background:"none",border:"none",color:"var(--color-accent, #2563EB)",textDecoration:"underline",cursor:"pointer",padding:0,font:"inherit"},children:"Retry"})]}),!i&&!d&&n.length===0&&t.jsx("div",{"data-testid":"queue-empty",style:{fontSize:12,color:"#9CA3AF",padding:"8px 0"},children:"No submissions yet. Publish a skill to add it to the queue."}),n.length>0&&t.jsxs("table",{"data-testid":"queue-table",style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{textAlign:"left",color:"#9CA3AF",fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em"},children:[t.jsx("th",{style:{padding:"6px 8px",fontWeight:600},children:"Skill"}),t.jsx("th",{style:{padding:"6px 8px",fontWeight:600},children:"State"}),t.jsx("th",{style:{padding:"6px 8px",fontWeight:600},children:"Position"}),t.jsx("th",{style:{padding:"6px 8px",fontWeight:600},children:"Updated"})]})}),t.jsx("tbody",{children:n.map(x=>{const b=o[x.id],y=Do.has(x.state);return t.jsxs("tr",{"data-testid":`queue-row-${x.id}`,"data-state":x.state,style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[t.jsx("td",{style:{padding:"6px 8px",fontWeight:600},children:x.skillName}),t.jsx("td",{style:{padding:"6px 8px"},children:t.jsx("span",{"data-testid":`queue-state-${x.id}`,style:{color:Zw(x.state)},children:x.state})}),t.jsx("td",{style:{padding:"6px 8px",fontVariantNumeric:"tabular-nums"},"data-testid":`queue-position-${x.id}`,children:y||b==null?"—":`#${b}`}),t.jsx("td",{style:{padding:"6px 8px",color:"#9CA3AF",fontVariantNumeric:"tabular-nums"},children:Xw(x.updatedAt)})]},x.id)})})]})]})}const tS=[{key:"profile",label:"Profile"},{key:"billing",label:"Plan & billing"},{key:"repos",label:"Connected repositories"},{key:"skills",label:"Skills"},{key:"queue",label:"My queue"},{key:"tokens",label:"API tokens"},{key:"notifications",label:"Notifications"},{key:"danger",label:"Danger zone"}];function rS({initialTab:e="profile",online:r=!0,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o}){const[a,i]=c.useState(e);return t.jsxs("div",{"data-testid":"account-shell",style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,fontFamily:"var(--font-sans)"},children:[t.jsx(nS,{}),!r&&t.jsx(sS,{}),t.jsxs("div",{style:{display:"flex",flex:1,minHeight:0},children:[t.jsx(oS,{activeTab:a,onSelectTab:i}),t.jsx("main",{"data-testid":"account-shell-pane",style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-canvas, #f9fafb)"},children:t.jsx(aS,{tab:a,online:r,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o})})]})]})}function nS(){const{data:e}=Tn();return t.jsxs("header",{"data-testid":"account-shell-header",style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:"1px solid var(--border-default, #e5e7eb)",background:"var(--bg-elevated, #fff)"},children:[e!=null&&e.avatarUrl?t.jsx("img",{src:e.avatarUrl,alt:"",width:28,height:28,style:{width:28,height:28,borderRadius:"50%",objectFit:"cover",border:"1px solid var(--border-default, #e5e7eb)"}}):t.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"var(--bg-canvas, #f3f4f6)"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",lineHeight:1.2},children:[t.jsx("strong",{style:{fontSize:13,color:"var(--text-primary)"},children:(e==null?void 0:e.displayName)??"Loading…"}),t.jsx("span",{style:{fontSize:11,color:"var(--text-secondary)"},children:e?`@${e.githubHandle}`:""})]})]})}function sS(){return t.jsx("div",{role:"status","data-testid":"account-shell-offline-banner",style:{padding:"8px 16px",background:"rgba(245, 158, 11, 0.15)",color:"#92400e",fontSize:12,borderBottom:"1px solid rgba(245, 158, 11, 0.4)"},children:"Offline — showing the last synced data."})}function oS({activeTab:e,onSelectTab:r}){return t.jsx("nav",{"data-testid":"account-shell-sidenav","aria-label":"Account sections",style:{width:220,flexShrink:0,borderRight:"1px solid var(--border-default, #e5e7eb)",background:"var(--bg-elevated, #fff)",padding:"12px 8px",display:"flex",flexDirection:"column",gap:2},children:tS.map(n=>{const s=e===n.key;return t.jsx("button",{type:"button","data-testid":`account-tab-${n.key}`,"data-active":s?"true":"false",onClick:()=>r(n.key),style:{display:"block",textAlign:"left",padding:"8px 12px",fontSize:13,fontFamily:"inherit",fontWeight:s?600:400,color:"var(--text-primary)",background:s?"var(--bg-canvas, #f3f4f6)":"transparent",border:"none",borderLeft:`3px solid ${s?"var(--color-accent, #2563eb)":"transparent"}`,borderRadius:0,cursor:"pointer"},children:n.label},n.key)})})}function aS({tab:e,online:r,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o}){switch(e){case"profile":return t.jsx(iS,{});case"billing":return t.jsx(lS,{onUpgradeClick:o});case"repos":return t.jsx(cS,{online:r,onConnectRepo:n,onOpenRepoOnGitHub:s});case"skills":return t.jsx(dS,{});case"queue":return t.jsx(uS,{});case"tokens":return t.jsx(pS,{});case"notifications":return t.jsx(hS,{});case"danger":return t.jsx(mS,{});default:return null}}function iS(){const{data:e,loading:r,error:n}=Tn(),s=Rd(),[o,a]=c.useState(!1),[i,l]=c.useState(null);return r||!e?t.jsx(Sr,{error:n}):t.jsx(Lw,{profile:e,saving:o,errorMessage:i,onSubmit:async d=>{a(!0),l(null);try{await s(d)}catch(u){l(u instanceof Error?u.message:String(u))}finally{a(!1)}}})}function lS({onUpgradeClick:e}){const{data:r,loading:n,error:s}=Tn();return n||!r?t.jsx(Sr,{error:s}):t.jsx(Mw,{tier:r.tier,onUpgradeClick:e})}function cS({online:e,onConnectRepo:r,onOpenRepoOnGitHub:n}){const{data:s,loading:o,error:a}=Ss(),i=Td(),l=Id(),[d,u]=c.useState({});return o&&!s?t.jsx(Sr,{error:a}):t.jsx(jw,{repos:Fa(s),pendingActions:d,onConnectNew:()=>r==null?void 0:r(),onOpenOnGitHub:p=>{const f=`https://github.com/${p.repoFullName}`;n?n(f):typeof window<"u"&&window.open(f,"_blank")},onResync:async p=>{if(e){u(f=>({...f,[p.repoId]:"resync"}));try{await i(p.repoId)}finally{u(f=>{const h={...f};return delete h[p.repoId],h})}}},onDisconnect:async p=>{if(e){u(f=>({...f,[p.repoId]:"disconnect"}));try{await l(p.repoId)}finally{u(f=>{const h={...f};return delete h[p.repoId],h})}}}})}function dS(){const{skills:e}=xv();return e.data?t.jsxs("div",{"data-testid":"account-skills-tab",style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{display:"flex",gap:12},children:[t.jsx(Ql,{label:"Public skills",value:e.data.publicCount}),t.jsx(Ql,{label:"Private skills",value:e.data.privateCount})]}),t.jsxs("section",{style:{marginTop:8},children:[t.jsx("h3",{style:{margin:"0 0 8px",fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:"Recent activity"}),e.data.recentActivity.length===0?t.jsx("p",{style:{margin:0,fontSize:12,color:"var(--text-secondary)"},children:"No recent activity."}):t.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:e.data.recentActivity.map((r,n)=>t.jsxs("li",{style:{padding:"6px 0",fontSize:12,borderBottom:"1px solid var(--border-default, #e5e7eb)",color:"var(--text-primary)"},children:[t.jsx("strong",{children:r.skillName})," ",t.jsx("span",{style:{color:"var(--text-secondary)"},children:r.action})]},`${r.skillName}-${n}`))})]})]}):t.jsx(Sr,{error:e.error})}function Ql({label:e,value:r}){return t.jsxs("div",{style:{flex:1,padding:16,border:"1px solid var(--border-default, #e5e7eb)",borderRadius:8,background:"var(--bg-elevated, #fff)"},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-secondary)"},children:e}),t.jsx("div",{style:{fontSize:24,fontWeight:600,color:"var(--text-primary)",fontVariantNumeric:"tabular-nums"},children:r})]})}function uS(){return t.jsx("section",{"data-testid":"account-queue-tab",style:{display:"flex",flexDirection:"column",gap:12},children:t.jsx(eS,{})})}function pS(){const{data:e,loading:r,error:n}=Ld(),s=Ad(),o=Pd(),[a,i]=c.useState(!1),[l,d]=c.useState(null),[u,p]=c.useState(null);return r&&!e?t.jsx(Sr,{error:n}):n&&!e?t.jsx(fS,{title:"API tokens are unavailable",message:"This page is for CLI and automation tokens, separate from GitHub repository access. Sign in again, then retry token management.",detail:n.message}):t.jsx(Dw,{tokens:e??[],creating:a,pendingRevokeId:l,recentlyCreated:u,onDismissRecentlyCreated:()=>p(null),onCreate:async f=>{i(!0);try{const h=await s(f);p(h)}finally{i(!1)}},onRevoke:async f=>{d(f.id);try{await o(f.id)}finally{d(null)}}})}function fS({title:e,message:r,detail:n}){return t.jsxs("div",{role:"alert","data-testid":"account-shell-section-error",style:{padding:16,border:"1px solid rgba(220, 38, 38, 0.35)",background:"rgba(220, 38, 38, 0.06)",borderRadius:8,color:"#7f1d1d",fontSize:13,display:"flex",flexDirection:"column",gap:6},children:[t.jsx("strong",{style:{color:"#991b1b"},children:e}),t.jsx("span",{children:r}),n?t.jsx("code",{style:{color:"#991b1b",fontSize:12,wordBreak:"break-word"},children:n}):null]})}function hS(){const{data:e,loading:r,error:n}=$d(),s=Md(),[o,a]=c.useState(!1),[i,l]=c.useState(null);return r||!e?t.jsx(Sr,{error:n}):t.jsx(Hw,{prefs:e,saving:o,errorMessage:i,onSubmit:async d=>{a(!0),l(null);try{await s(d)}catch(u){l(u instanceof Error?u.message:String(u))}finally{a(!1)}}})}function mS(){const{data:e}=Tn(),{data:r}=Fd(),n=Dd(),s=zd(),o=Bd(),[a,i]=c.useState({}),[l,d]=c.useState(null);return e?t.jsx(Gw,{githubHandle:e.githubHandle,exports:r??[],pending:a,errorMessage:l,onSignOutAll:async()=>{i(u=>({...u,signOutAll:!0})),d(null);try{await n()}catch(u){d(u instanceof Error?u.message:String(u))}finally{i(u=>({...u,signOutAll:!1}))}},onExportRequest:async()=>{i(u=>({...u,exportRequest:!0})),d(null);try{await s()}catch(u){d(u instanceof Error?u.message:String(u))}finally{i(u=>({...u,exportRequest:!1}))}},onDeleteAccount:async u=>{i(p=>({...p,deleteAccount:!0})),d(null);try{await o(u)}catch(p){d(p instanceof Error?p.message:String(p))}finally{i(p=>({...p,deleteAccount:!1}))}}}):t.jsx(Sr,{})}function Sr({error:e}={}){return e?t.jsxs("div",{role:"alert","data-testid":"account-shell-tab-error",style:{padding:16,border:"1px solid rgba(220, 38, 38, 0.4)",background:"rgba(220, 38, 38, 0.06)",borderRadius:8,color:"#991b1b",fontSize:13},children:["Couldn't load this section: ",e.message]}):t.jsx("div",{"data-testid":"account-shell-tab-loading",style:{padding:16,color:"var(--text-secondary)",fontSize:13},children:"Loading…"})}const xS=c.lazy(()=>ar(()=>import("./FindSkillsPalette-B5-3ZLEo.js"),__vite__mapDeps([8,5,3,4])).then(e=>({default:e.FindSkillsPalette})));bh();const gS=c.lazy(()=>ar(()=>import("./SkillDetailPanel-B5LYvcry.js"),__vite__mapDeps([9,3,4,10,5,6])).then(e=>({default:e.SkillDetailPanel}))),vS=c.lazy(()=>ar(()=>import("./CreateSkillPage-CwreCn22.js"),__vite__mapDeps([11,3,4,5,6])).then(e=>({default:e.CreateSkillPage}))),yS=c.lazy(()=>ar(()=>Promise.resolve().then(()=>x0),void 0).then(e=>({default:e.UpdatesPanel})));function bS(){return t.jsx(em,{children:t.jsx(Jy,{children:t.jsx(Qh,{children:t.jsx(Qm,{children:t.jsx(kS,{children:t.jsxs(yk,{children:[t.jsx(jS,{}),t.jsx(mk,{})]})})})})})})}function kS({children:e}){const[r,n]=c.useState(void 0);return c.useEffect(()=>{let s=!1;if(Ac())return Gh().then(o=>{s||n(o)}),()=>{s=!0}},[]),t.jsx(uv,{value:r,children:e})}function jS(){var dr,ur;const{state:e,selectSkill:r,clearSelection:n,refreshSkills:s,outdatedByOrigin:o,revealSkill:a,clearReveal:i}=Pt(),{config:l}=kr(),{resolvedTheme:d,setTheme:u}=Uc(),{toast:p}=ys(),[f,h]=c.useState(()=>dy()),[m]=c.useState(!0),[g,v]=c.useState(!1),[x,b]=c.useState(!1),[y,j]=c.useState(!1),[S,k]=c.useState(()=>typeof window>"u"?"overview":ia(window.location.search).tab),[R,w]=c.useState(()=>{if(typeof window>"u")return"";const D=ia(window.location.search);return D.mode?D.mode:D.view?D.view:zu(D.tab,window.location.search)}),E=c.useCallback(D=>{k(ae=>(ae!==D&&w(fn(D)),D))},[]);c.useEffect(()=>{if(typeof window>"u")return;const D=()=>{const ae=new URLSearchParams(window.location.search),q=ae.get("tab"),Xe=ae.get("panel"),De=ps(q)??ps(Xe);if(!De)return;const at=new URLSearchParams(window.location.search);at.delete("panel"),at.delete("sub"),De.tab==="overview"?at.delete("tab"):at.set("tab",De.tab),at.delete("mode"),at.delete("view"),De.mode&&at.set("mode",De.mode),De.view&&at.set("view",De.view);const lt=at.toString(),As=`${window.location.pathname}${lt?"?"+lt:""}${window.location.hash}`,er=`${window.location.pathname}${window.location.search}${window.location.hash}`;As!==er&&window.history.replaceState(null,"",As),k(De.tab),De.mode?w(De.mode):De.view?w(De.view):w(fn(De.tab))};return D(),window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[]),c.useEffect(()=>{if(typeof window>"u")return;const D=new URLSearchParams(window.location.search);D.delete("panel"),D.delete("sub"),S==="overview"?D.delete("tab"):D.set("tab",S),D.delete("mode"),D.delete("view"),!(R===fn(S))&&R&&(S==="run"?D.set("mode",R):S==="history"&&D.set("view",R));const q=D.toString(),Xe=`${window.location.pathname}${q?"?"+q:""}${window.location.hash}`,De=`${window.location.pathname}${window.location.search}${window.location.hash}`;Xe!==De&&window.history.replaceState(null,"",Xe)},[S,R]);const[N,T]=c.useState(Wl),I=c.useCallback((D,ae)=>{T(Zj(D,ae))},[]),A=mj(),[$,W]=c.useState(()=>Xj("activeAgent",null)),C=c.useCallback(D=>{W(D),Qj("activeAgent",D),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:D}}))},[]);c.useEffect(()=>{var D;!$&&((D=A.response)!=null&&D.suggested)&&C(A.response.suggested)},[$,(dr=A.response)==null?void 0:dr.suggested,C]);const P=c.useMemo(()=>A.response?cj(A.response):[],[A.response]),{workspace:L,switchProject:F,addProject:H,removeProject:re,activeProject:V}=jj(),[O,se]=c.useState(!1);c.useEffect(()=>{ie.current=(V==null?void 0:V.path)??null},[V==null?void 0:V.path]);const[ge,ye]=c.useState(!1),[z,ne]=c.useState("standalone"),[M,U]=c.useState(!1),[K,X]=c.useState(null),ie=c.useRef(null),G=nu(),te=jn(),de=c.useCallback(D=>{te.openExternalUrl(D).catch(()=>{typeof window<"u"&&window.open(D,"_blank","noopener,noreferrer")})},[te]),fe=c.useCallback(async(D="standalone")=>{ne(D),ye(!0)},[]);c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;fe((q==null?void 0:q.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",D),()=>window.removeEventListener("studio:request-create-skill",D)},[fe]),c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;X(q!=null&&q.repoName?{repoName:q.repoName}:null),U(!0)}return window.addEventListener("studio:request-paywall",D),()=>window.removeEventListener("studio:request-paywall",D)},[]);const[ke,B]=c.useState(!1),[Y,J]=c.useState(null),[ee,ue]=c.useState(null);c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;!q||typeof q.skill!="string"||q.skill.length===0||ue({skill:q.skill,skillDisplayName:q.skillDisplayName,scope:q.scope==="project"?"project":"user",activeAgentId:q.activeAgentId,preCheckedAgentIds:q.preCheckedAgentIds})}return window.addEventListener("studio:open-install-targets-modal",D),()=>window.removeEventListener("studio:open-install-targets-modal",D)},[]);const[be,Te]=c.useState(null);c.useEffect(()=>{function D(){B(!0)}return window.addEventListener("studio:open-marketplace",D),()=>window.removeEventListener("studio:open-marketplace",D)},[]);const Q=c.useMemo(()=>{const D=new Set;for(const ae of e.skills)ae.source==="plugin"&&ae.pluginName&&D.add(ae.pluginName);return D},[e.skills]),{lookup:Se}=Od(),he=c.useMemo(()=>{const D=new Map;for(const ae of e.skills){const q=In(ae.repoUrl);if(!q)continue;const Xe=Se.get(q);if(!Xe||!Xe.isPrivate)continue;const De=ae.pluginName??ae.plugin;D.has(De)||D.set(De,{name:De,repoFullName:Xe.repoFullName})}return Array.from(D.values())},[e.skills,Se]);Qo([{key:"p",meta:!0,handler:D=>{var q;const ae=typeof document<"u"?document.activeElement:null;ae&&ae.tagName==="INPUT"||((q=D==null?void 0:D.preventDefault)==null||q.call(D),se(Xe=>!Xe))}}],{enabled:!0});const Ce=Gk(),Ae=Ce.open;c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;q!=null&&q.provider&&Ae(q.provider)}return window.addEventListener("studio:open-setup-drawer",D),()=>window.removeEventListener("studio:open-setup-drawer",D)},[Ae]);const Pe=c.useCallback(()=>{T(Wl)},[]);c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;q!=null&&q.message&&p({message:q.message,severity:q.severity??"info"})}return window.addEventListener("studio:toast",D),()=>window.removeEventListener("studio:toast",D)},[p]),Jj();const[_e,wt]=c.useState(!1),[oe,$e]=c.useState(void 0);c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;$e(q==null?void 0:q.provider),wt(!0)}return window.addEventListener("studio:open-settings",D),()=>window.removeEventListener("studio:open-settings",D)},[]),c.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${f}px`)},[f]),c.useEffect(()=>{function D(){s()}return window.addEventListener("studio:content-saved",D),()=>window.removeEventListener("studio:content-saved",D)},[s]);const[Fe,Ye]=c.useState(null),[tt,Qe]=c.useState(()=>new Set),zt=c.useRef(!1),St=c.useMemo(()=>Nv(),[]),We=c.useCallback(D=>`${D.plugin}/${D.skill}`,[]),Je=c.useCallback(D=>{Qe(ae=>{const q=new Set(ae);return q.add(We(D)),q})},[We]),yt=c.useCallback(D=>{Qe(ae=>{const q=new Set(ae);return q.delete(We(D)),q})},[We]),ut=Al({delayMs:1e4,onCommit:D=>{s(),yt(D)},onFailure:(D,ae)=>{yt(D),p({message:`Couldn't delete ${D.skill}: ${ae.message}`,severity:"error",durationMs:0,action:{label:_.actions.retry,onInvoke:()=>{Je(D),ut.enqueueDelete(D)}}})}});c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;q!=null&&q.skill&&Ye(q.skill)}return window.addEventListener("studio:request-delete",D),()=>window.removeEventListener("studio:request-delete",D)},[]);const[Kt,Bt]=c.useState(null);c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;q!=null&&q.skill&&Bt(q.skill)}return window.addEventListener("studio:request-clone",D),()=>window.removeEventListener("studio:request-clone",D)},[]);const[Ue,bt]=c.useState(null),_t=Al({delayMs:250,apiCall:(D,ae)=>api.uninstallSkill(D,ae),onCommit:D=>{s(),yt(D)},onFailure:(D,ae)=>{var q;if(yt(D),ae instanceof Jt&&((q=ae.details)==null?void 0:q.code)==="not-installed"){p({message:`${D.skill} is a source-authored skill — use Delete instead`,severity:"info",durationMs:4e3});return}p({message:`Couldn't uninstall ${D.skill}: ${ae.message}`,severity:"error",durationMs:0,action:{label:_.actions.retry,onInvoke:()=>{Je(D),_t.enqueueDelete(D)}}})}});c.useEffect(()=>{function D(ae){if(!(ae instanceof CustomEvent))return;const q=ae.detail;q!=null&&q.skill&&bt(q.skill)}return window.addEventListener("studio:request-uninstall",D),()=>window.removeEventListener("studio:request-uninstall",D)},[]);const Ot=c.useCallback(async D=>{await Promise.all([ut.flushBySkillName(D),_t.flushBySkillName(D)])},[ut,_t]),Cr=c.useMemo(()=>({flushBySkillName:Ot}),[Ot]),Ns=c.useCallback(()=>{const D=Ue;if(bt(null),!D)return;const ae={plugin:D.plugin,skill:D.skill};Je(ae),_t.enqueueDelete(ae),p({message:`Uninstalled ${D.skill}. Sent to your ${St}.`,severity:"info",durationMs:4e3})},[Ue,Je,_t,p,St]),Rs=c.useCallback(()=>{bt(null)},[]),Ts=c.useCallback(()=>{const D=Fe;if(Ye(null),!D)return;const ae={plugin:D.plugin,skill:D.skill};Je(ae),ut.enqueueDelete(ae);const q=zt.current?"":`Sent to your ${St}. Open Trash to restore. `;zt.current=!0,p({message:`${q}Deleted ${D.skill}`,severity:"info",durationMs:1e4,action:{label:_.actions.undo,onInvoke:()=>{ut.cancelDelete(We(ae)),yt(ae)}}})},[Fe,Je,yt,ut,p,St,We]),Is=c.useCallback(()=>{Ye(null)},[]),Kr=c.useMemo(()=>e.skills.filter(D=>!tt.has(We(D))),[e.skills,tt,We]),Ie=vy(Kr,(V==null?void 0:V.path)??null),Ne=c.useMemo(()=>e.selectedSkill?e.skills.find(D=>D.plugin===e.selectedSkill.plugin&&D.skill===e.selectedSkill.skill)??null:null,[e.skills,e.selectedSkill]),Ct=c.useRef(null);c.useEffect(()=>{if(!Ne||typeof window>"u"||new URLSearchParams(window.location.search).get("tab")||!(Ne.origin==="installed"))return;const q=`${Ne.plugin}/${Ne.skill}`;Ct.current!==q&&(Ct.current=q,S==="overview"&&k("source"))},[Ne==null?void 0:Ne.plugin,Ne==null?void 0:Ne.skill,Ne==null?void 0:Ne.origin]);const kt=c.useCallback(D=>{r({plugin:D.plugin,skill:D.skill,origin:D.origin,source:D.source})},[r]),it=c.useMemo(()=>{if(!e.selectedSkill)return"";const D=e.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${e.selectedSkill.skill} (${D})`},[e.selectedSkill]),[pt,Er]=c.useState(null);Qo([{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:"cmd+shift+m",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openAgentModelPicker"))}},{key:"ctrl+shift+m",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openAgentModelPicker"))}},{key:"?",handler:()=>v(D=>!D)},{key:"cmd+shift+d",handler:()=>u(d==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>u(d==="light"?"dark":"light")},{key:"cmd+b",handler:()=>b(D=>!D)},{key:"ctrl+b",handler:()=>b(D=>!D)}]);const Ls=sw(),qr=ow(),qt=y?t.jsx(rS,{online:typeof navigator>"u"?!0:navigator.onLine!==!1,onConnectRepo:()=>{de("https://verified-skill.com/account/repos/connect")},onOpenRepoOnGitHub:de,onUpgradeClick:()=>{de(_a)}}):qr?t.jsx(c.Suspense,{fallback:t.jsx("div",{style:{padding:40},children:"Loading…"}),children:t.jsx(yS,{})}):Ls?t.jsx(c.Suspense,{fallback:t.jsx("div",{style:{padding:40},children:"Loading…"}),children:t.jsx(vS,{})}):t.jsx(ak,{selectedSkillInfo:Ne,activeDetailTab:S,onDetailTabChange:E,activeDetailSub:R,onDetailSubChange:w,allSkills:e.skills,onSelectSkill:kt});return t.jsxs(Ru.Provider,{value:Cr,children:[t.jsx(tm,{sidebarWidth:f,sidebarHidden:x||e.isMobile&&e.mobileView==="detail",banner:t.jsx(yy,{connected:m}),liveMessage:it,topRail:t.jsx(ox,{projectName:(l==null?void 0:l.projectName)??null,selected:e.selectedSkill,onHome:n,onRequestCreateSkill:()=>fe("standalone"),projectPickerSlot:L&&L.projects.length>0?t.jsx(Sj,{workspace:L,onSwitch:F,onAdd:H,onRemove:re}):void 0,findSkillsSlot:t.jsx(lw,{}),appUpdateSlot:t.jsx(kk,{}),userDropdownSlot:t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[t.jsx(mw,{}),t.jsx(cw,{})]})}),sidebar:t.jsxs("div",{"data-testid":"desktop-sidebar",style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[t.jsx("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:t.jsx(Zv,{skills:Kr,selectedKey:e.selectedSkill?{plugin:e.selectedSkill.plugin,skill:e.selectedSkill.skill}:null,onSelect:D=>{j(!1),kt(D)},isLoading:e.skillsLoading,error:e.skillsError??null,onRetry:s,onContextMenu:I,outdatedByOrigin:o,activeAgentId:$,revealSkillId:e.revealSkillId,onRevealComplete:i,dirtySkillIds:Ie,onSkillsChanged:s,topSlot:t.jsxs(t.Fragment,{children:[A.status==="ready"&&P.length>0?t.jsxs(t.Fragment,{children:[t.jsx(dj,{agents:P,activeAgentId:$,onActiveAgentChange:C,onOpenSetup:D=>Ce.open(D)}),t.jsx(hj,{activeAgentId:$})]}):null,V!=null&&V.path?t.jsx(Hd,{folder:V.path,tier:G.tier}):null]})})}),t.jsx("div",{style:{borderTop:"1px solid var(--border-default, rgba(128,128,128,0.25))",padding:"6px 0"},children:t.jsx(yw,{active:y,onClick:()=>j(D=>!D)})})]}),resizeHandle:t.jsx(py,{initialWidth:f??pn,onChange:h}),main:qt,statusBar:t.jsx(xx,{projectPath:(l==null?void 0:l.root)??null,modelName:(l==null?void 0:l.model)??null,health:l!=null&&l.error?"degraded":"ok",providers:(ur=l==null?void 0:l.providers)==null?void 0:ur.map(D=>{const ae=D.id;return{id:ae,label:D.label,available:D.available,kind:ae==="ollama"||ae==="lm-studio"?"start-service":ae==="anthropic"||ae==="openrouter"?"api-key":"cli-install"}})})}),t.jsx(wk,{open:g,onClose:()=>v(!1)}),t.jsx(_k,{open:Ce.isOpen,providerKey:Ce.providerKey,onClose:Ce.close}),t.jsx(Ck,{state:N,onClose:Pe,onAction:(D,ae)=>tw(D,ae)}),t.jsx(c.Suspense,{fallback:null,children:t.jsx(xS,{onSelect:D=>{const ae=D.name.split("/");ae.length===3&&Er({owner:ae[0],repo:ae[1],slug:ae[2],displayName:D.displayName??D.name})}})}),pt&&t.jsx(c.Suspense,{fallback:null,children:t.jsx(gS,{selectedSkill:pt,activeAgentId:$,onClose:()=>Er(null),onSkillsChanged:s})}),t.jsx(Ej,{open:O,projects:(L==null?void 0:L.projects)??[],onSwitch:D=>{F(D)},onClose:()=>se(!1)}),t.jsx(Nj,{open:ge,onClose:()=>ye(!1),initialMode:z,isClaudeCode:$==="claude-code",projectRoot:(V==null?void 0:V.path)??(l==null?void 0:l.projectName)??"",onCreated:D=>{s(),setTimeout(()=>{a(D.pluginName??"",D.skillName)},500),te.quotaReportCount(Kr.length+1)}}),t.jsx(Lj,{open:ke,onClose:()=>B(!1),installedNames:Q,privatePlugins:he,onInstall:(D,ae)=>{J({plugin:D,marketplace:ae,ref:`${D}@${ae}`}),B(!1)},onUninstall:async D=>{if(await new Promise(q=>{Te({plugin:D,resolve:q})}))try{const q=await fetch(`/api/plugins/${encodeURIComponent(D)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Xe=await q.json().catch(()=>({}));if(!q.ok||!Xe.ok){p({message:Xe.error??`Uninstall failed (${q.status})`,severity:"error"});return}const De=Xe.fallback==="orphan-cache-removed"?`Removed orphaned ${D}.`:`Uninstalled ${D}.`;p({message:De,severity:"success"}),s()}catch(q){p({message:q instanceof Error?q.message:String(q),severity:"error"})}}}),t.jsx(Bc,{open:_e,onClose:()=>wt(!1),initialProvider:oe,onToast:D=>p({message:D,severity:"info"})}),t.jsx(Fj,{job:Y,onDone:D=>{D.ok&&(s(),setTimeout(()=>J(null),3e3))}}),ee&&t.jsx(Vj,{skill:ee.skill,skillDisplayName:ee.skillDisplayName,scope:ee.scope,activeAgentId:ee.activeAgentId===void 0?$:ee.activeAgentId,preCheckedAgentIds:ee.preCheckedAgentIds,onClose:()=>ue(null),onRemoved:s,onSuccess:D=>{s();const ae=D.filter(at=>at.status==="installed").length,q=D.filter(at=>at.status==="exported").length,Xe=D.find(at=>at.status==="error"),De=ee.skillDisplayName??ee.skill;Xe?p({message:Xe.detail||`Could not install ${De}.`,severity:"error"}):q>0?p({message:`Installed ${De}; ${q} target${q===1?"":"s"} need paste.`,severity:"info"}):ae>0&&p({message:`Installed ${De} to ${ae} target${ae===1?"":"s"}.`,severity:"success"})}}),t.jsx(ts,{open:Fe!==null,title:Fe?`Delete "${Fe.skill}"?`:"",body:`It will be sent to your ${St}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Ts,onCancel:Is}),t.jsx(ts,{open:Ue!==null,title:Ue?`Uninstall "${Ue.skill}"?`:"",body:`It will be sent to your ${St} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:Ns,onCancel:Rs}),t.jsx(ts,{open:be!==null,title:be?`Uninstall ${be.plugin}?`:"",body:be?`This removes the ${be.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{be==null||be.resolve(!0),Te(null)},onCancel:()=>{be==null||be.resolve(!1),Te(null)}}),t.jsx(su,{open:M,skillName:(K==null?void 0:K.repoName)??void 0,onClose:()=>{U(!1),X(null)},onProceed:()=>{X(null)}}),Kt&&t.jsx(Nk,{skill:Kt,onCloned:D=>{p({message:_.toasts.cloneSucceeded,severity:"info"}),Bt(null);try{window.dispatchEvent(new CustomEvent("studio:skills-changed",{detail:D}))}catch{}s()},onCancel:()=>Bt(null)})]})}const Xl="vskill.migrations.scope-rename.v1",wS={own:"authoring-project",installed:"available-project",global:"available-personal"},SS=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function CS(e){if(e.getItem(Xl)==="done")return;const r=[];for(let n=0;n<e.length;n++){const s=e.key(n);if(!s)continue;const o=s.match(SS);if(!o)continue;const[,a,i]=o,l=wS[i];if(!l)continue;const d=e.getItem(s);d!==null&&r.push({oldKey:s,newKey:`vskill-sidebar-${a}-${l}-collapsed`,value:d})}for(const{oldKey:n,newKey:s,value:o}of r)e.getItem(s)===null&&e.setItem(s,o),e.removeItem(n);e.setItem(Xl,"done")}if(typeof PerformanceObserver<"u")try{const e=new PerformanceObserver(r=>{for(const n of r.getEntries())if(n.name==="first-contentful-paint"){window.__vskillPaint=n.startTime,e.disconnect();return}});e.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{CS(window.localStorage)}catch{}lp.createRoot(document.getElementById("root")).render(t.jsx(c.StrictMode,{children:t.jsx($f,{children:t.jsx(ux,{children:t.jsx(bS,{})})})}));export{Es as E,Vj as I,bc as L,An as P,p0 as S,TS as T,ce as a,Pt as b,c0 as c,i0 as d,Ln as e,ys as f,Xj as g,Eu as h,us as i,Ou as o,Xd as p,qu as r,ih as s,Pr as t,kr as u,Qj as w};
|