vskill 1.2.0 → 1.2.1

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.
Files changed (59) hide show
  1. package/agents.json +1 -1
  2. package/dist/api/client.js +7 -6
  3. package/dist/api/client.js.map +1 -1
  4. package/dist/blocklist/blocklist.d.ts +12 -0
  5. package/dist/blocklist/blocklist.js +19 -0
  6. package/dist/blocklist/blocklist.js.map +1 -1
  7. package/dist/commands/add.js +71 -43
  8. package/dist/commands/add.js.map +1 -1
  9. package/dist/commands/auth.js +32 -1
  10. package/dist/commands/auth.js.map +1 -1
  11. package/dist/commands/diff.js +8 -0
  12. package/dist/commands/diff.js.map +1 -1
  13. package/dist/commands/info.js +7 -0
  14. package/dist/commands/info.js.map +1 -1
  15. package/dist/commands/outdated.js +24 -7
  16. package/dist/commands/outdated.js.map +1 -1
  17. package/dist/commands/pin.js +7 -2
  18. package/dist/commands/pin.js.map +1 -1
  19. package/dist/commands/submit.js +8 -0
  20. package/dist/commands/submit.js.map +1 -1
  21. package/dist/commands/update.js +14 -5
  22. package/dist/commands/update.js.map +1 -1
  23. package/dist/commands/versions.js +11 -0
  24. package/dist/commands/versions.js.map +1 -1
  25. package/dist/discovery/github-tree.js +14 -2
  26. package/dist/discovery/github-tree.js.map +1 -1
  27. package/dist/eval-server/api-routes.js +33 -2
  28. package/dist/eval-server/api-routes.js.map +1 -1
  29. package/dist/eval-server/install-skill-routes.d.ts +2 -0
  30. package/dist/eval-server/install-skill-routes.js +7 -0
  31. package/dist/eval-server/install-skill-routes.js.map +1 -1
  32. package/dist/eval-server/oauth-github-routes.js +25 -0
  33. package/dist/eval-server/oauth-github-routes.js.map +1 -1
  34. package/dist/eval-server/origin-resolver.d.ts +6 -0
  35. package/dist/eval-server/origin-resolver.js +35 -5
  36. package/dist/eval-server/origin-resolver.js.map +1 -1
  37. package/dist/eval-server/platform-proxy.d.ts +3 -3
  38. package/dist/eval-server/platform-proxy.js +10 -25
  39. package/dist/eval-server/platform-proxy.js.map +1 -1
  40. package/dist/eval-server/studio-privacy.d.ts +26 -0
  41. package/dist/eval-server/studio-privacy.js +129 -0
  42. package/dist/eval-server/studio-privacy.js.map +1 -0
  43. package/dist/eval-ui/assets/{CreateSkillPage-ENMve2K8.js → CreateSkillPage-DXOVLzCp.js} +1 -1
  44. package/dist/eval-ui/assets/{FindSkillsPalette-BMVKCk6E.js → FindSkillsPalette-D_qkIke-.js} +2 -2
  45. package/dist/eval-ui/assets/{SearchPaletteCore-C9G-ySXc.js → SearchPaletteCore-BbJxHT_o.js} +1 -1
  46. package/dist/eval-ui/assets/{SkillDetailPanel-BCJj8p79.js → SkillDetailPanel-DMkcBtBv.js} +1 -1
  47. package/dist/eval-ui/assets/{UpdateDropdown-C4BH7W_M.js → UpdateDropdown-CH05KQXq.js} +1 -1
  48. package/dist/eval-ui/assets/{main-tzMA8J07.js → main-DpG_H4H8.js} +5 -5
  49. package/dist/eval-ui/index.html +1 -1
  50. package/dist/lib/github-fetch.d.ts +2 -0
  51. package/dist/lib/github-fetch.js +27 -1
  52. package/dist/lib/github-fetch.js.map +1 -1
  53. package/dist/lib/private-source.d.ts +77 -0
  54. package/dist/lib/private-source.js +392 -0
  55. package/dist/lib/private-source.js.map +1 -0
  56. package/dist/lib/repo-visibility.d.ts +16 -0
  57. package/dist/lib/repo-visibility.js +43 -3
  58. package/dist/lib/repo-visibility.js.map +1 -1
  59. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DhhmQddr.js","assets/core-DZjBCfjp.js","assets/UpdateDropdown-C4BH7W_M.js","assets/globals-hm1COkXX.js","assets/globals-Dpf9KmYH.css","assets/useDesktopBridge-9oZFQsrw.js","assets/fonts-i7Lkz2zN.css","assets/index-DDNzcrhv.js","assets/FindSkillsPalette-BMVKCk6E.js","assets/SkillDetailPanel-BCJj8p79.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-ENMve2K8.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DhhmQddr.js","assets/core-DZjBCfjp.js","assets/UpdateDropdown-CH05KQXq.js","assets/globals-hm1COkXX.js","assets/globals-Dpf9KmYH.css","assets/useDesktopBridge-9oZFQsrw.js","assets/fonts-i7Lkz2zN.css","assets/index-DDNzcrhv.js","assets/FindSkillsPalette-D_qkIke-.js","assets/SkillDetailPanel-DMkcBtBv.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-DXOVLzCp.js"])))=>i.map(i=>d[i]);
2
2
  import{r as l,a as Su,g as Cu,j as t,R as ve,c as Eu}from"./globals-hm1COkXX.js";import{o as Jn,_ as ar,u as fn,n as Ea,l as En}from"./useDesktopBridge-9oZFQsrw.js";/* empty css *//**
3
3
  * react-router v7.13.1
4
4
  *
@@ -10,12 +10,12 @@ import{r as l,a as Su,g as Cu,j as t,R as ve,c as Eu}from"./globals-hm1COkXX.js"
10
10
  * @license MIT
11
11
  */var Na="popstate";function Ra(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Nu(e={}){function r(o,a){let{pathname:i="/",search:c="",hash:d=""}=$r(o.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),ko("",{pathname:i,search:c,hash:d},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(o,a){let i=o.document.querySelector("base"),c="";if(i&&i.getAttribute("href")){let d=o.location.href,u=d.indexOf("#");c=u===-1?d:d.slice(0,u)}return c+"#"+(typeof a=="string"?a:sn(a))}function s(o,a){Mt(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(a)})`)}return Tu(r,n,s,e)}function tt(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Mt(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function Ru(){return Math.random().toString(36).substring(2,10)}function Ta(e,r){return{usr:e.state,key:e.key,idx:r,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ko(e,r,n=null,s,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof r=="string"?$r(r):r,state:n,key:r&&r.key||s||Ru(),unstable_mask:o}}function sn({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 $r(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 Tu(e,r,n,s={}){let{window:o=document.defaultView,v5Compat:a=!1}=s,i=o.history,c="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(){c="POP";let g=p(),b=g==null?null:g-u;u=g,d&&d({action:c,location:x.location,delta:b})}function h(g,b){c="PUSH";let v=Ra(g)?g:ko(x.location,g,b);n&&n(v,g),u=p()+1;let k=Ta(v,u),E=x.createHref(v.unstable_mask||v);try{i.pushState(k,"",E)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;o.location.assign(E)}a&&d&&d({action:c,location:x.location,delta:1})}function m(g,b){c="REPLACE";let v=Ra(g)?g:ko(x.location,g,b);n&&n(v,g),u=p();let k=Ta(v,u),E=x.createHref(v.unstable_mask||v);i.replaceState(k,"",E),a&&d&&d({action:c,location:x.location,delta:0})}function y(g){return Iu(g)}let x={get action(){return c},get location(){return e(o,i)},listen(g){if(d)throw new Error("A history only accepts one active listener");return o.addEventListener(Na,f),d=g,()=>{o.removeEventListener(Na,f),d=null}},createHref(g){return r(o,g)},createURL:y,encodeLocation(g){let b=y(g);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:h,replace:m,go(g){return i.go(g)}};return x}function Iu(e,r=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),tt(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:sn(e);return s=s.replace(/ $/,"%20"),!r&&s.startsWith("//")&&(s=n+s),new URL(s,n)}function El(e,r,n="/"){return Lu(e,r,n,!1)}function Lu(e,r,n,s){let o=typeof r=="string"?$r(r):r,a=Yt(o.pathname||"/",n);if(a==null)return null;let i=Nl(e);Au(i);let c=null;for(let d=0;c==null&&d<i.length;++d){let u=Uu(a);c=Ou(i[d],u,s)}return c}function Nl(e,r=[],n=[],s="",o=!1){let a=(i,c,d=o,u)=>{let p={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(s)&&d)return;tt(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=Wt([s,p.relativePath]),h=n.concat(p);i.children&&i.children.length>0&&(tt(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Nl(i.children,r,h,f,d)),!(i.path==null&&!i.index)&&r.push({path:f,score:Bu(f,i.index),routesMeta:h})};return e.forEach((i,c)=>{var d;if(i.path===""||!((d=i.path)!=null&&d.includes("?")))a(i,c);else for(let u of Rl(i.path))a(i,c,!0,u)}),r}function Rl(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=Rl(s.join("/")),c=[];return c.push(...i.map(d=>d===""?a:[a,d].join("/"))),o&&c.push(...i),c.map(d=>e.startsWith("/")&&d===""?"/":d)}function Au(e){e.sort((r,n)=>r.score!==n.score?n.score-r.score:_u(r.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var Pu=/^:[\w-]+$/,$u=3,Mu=2,Du=1,Fu=10,zu=-2,Ia=e=>e==="*";function Bu(e,r){let n=e.split("/"),s=n.length;return n.some(Ia)&&(s+=zu),r&&(s+=Mu),n.filter(o=>!Ia(o)).reduce((o,a)=>o+(Pu.test(a)?$u:a===""?Du:Fu),s)}function _u(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 Ou(e,r,n=!1){let{routesMeta:s}=e,o={},a="/",i=[];for(let c=0;c<s.length;++c){let d=s[c],u=c===s.length-1,p=a==="/"?r:r.slice(a.length)||"/",f=Xn({path:d.relativePath,caseSensitive:d.caseSensitive,end:u},p),h=d.route;if(!f&&u&&n&&!s[s.length-1].route.index&&(f=Xn({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},p)),!f)return null;Object.assign(o,f.params),i.push({params:o,pathname:Wt([a,f.pathname]),pathnameBase:Ku(Wt([a,f.pathnameBase])),route:h}),f.pathnameBase!=="/"&&(a=Wt([a,f.pathnameBase]))}return i}function Xn(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,s]=Wu(e.path,e.caseSensitive,e.end),o=r.match(n);if(!o)return null;let a=o[0],i=a.replace(/(.)\/+$/,"$1"),c=o.slice(1);return{params:s.reduce((u,{paramName:p,isOptional:f},h)=>{if(p==="*"){let y=c[h]||"";i=a.slice(0,a.length-y.length).replace(/(.)\/+$/,"$1")}const m=c[h];return f&&!m?u[p]=void 0:u[p]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:i,pattern:e}}function Wu(e,r=!1,n=!0){Mt(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,c,d,u,p)=>{if(s.push({paramName:c,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 Uu(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Mt(!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 Yt(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)||"/"}var Hu=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Vu(e,r="/"){let{pathname:n,search:s="",hash:o=""}=typeof e=="string"?$r(e):e,a;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?a=La(n.substring(1),"/"):a=La(n,r)):a=r,{pathname:a,search:qu(s),hash:Yu(o)}}function La(e,r){let n=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function ks(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 Gu(e){return e.filter((r,n)=>n===0||r.route.path&&r.route.path.length>0)}function Tl(e){let r=Gu(e);return r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase)}function Go(e,r,n,s=!1){let o;typeof e=="string"?o=$r(e):(o={...e},tt(!o.pathname||!o.pathname.includes("?"),ks("?","pathname","search",o)),tt(!o.pathname||!o.pathname.includes("#"),ks("#","pathname","hash",o)),tt(!o.search||!o.search.includes("#"),ks("#","search","hash",o)));let a=e===""||o.pathname==="",i=a?"/":o.pathname,c;if(i==null)c=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("/")}c=f>=0?r[f]:"/"}let d=Vu(o,c),u=i&&i!=="/"&&i.endsWith("/"),p=(a||i===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}var Wt=e=>e.join("/").replace(/\/\/+/g,"/"),Ku=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),qu=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Yu=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Ju=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 Xu(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Qu(e){return e.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Il=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ll(e,r){let n=e;if(typeof n!="string"||!Hu.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,o=!1;if(Il)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Yt(i.pathname,r);i.origin===a.origin&&c!=null?n=c+i.search+i.hash:o=!0}catch{Mt(!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 Al=["POST","PUT","PATCH","DELETE"];new Set(Al);var Zu=["GET",...Al];new Set(Zu);var Mr=l.createContext(null);Mr.displayName="DataRouter";var ss=l.createContext(null);ss.displayName="DataRouterState";var ep=l.createContext(!1),Pl=l.createContext({isTransitioning:!1});Pl.displayName="ViewTransition";var tp=l.createContext(new Map);tp.displayName="Fetchers";var rp=l.createContext(null);rp.displayName="Await";var Tt=l.createContext(null);Tt.displayName="Navigation";var os=l.createContext(null);os.displayName="Location";var Jt=l.createContext({outlet:null,matches:[],isDataRoute:!1});Jt.displayName="Route";var Ko=l.createContext(null);Ko.displayName="RouteError";var $l="REACT_ROUTER_ERROR",np="REDIRECT",sp="ROUTE_ERROR_RESPONSE";function op(e){if(e.startsWith(`${$l}:${np}:{`))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 ap(e){if(e.startsWith(`${$l}:${sp}:{`))try{let r=JSON.parse(e.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new Ju(r.status,r.statusText,r.data)}catch{}}function ip(e,{relative:r}={}){tt(hn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:s}=l.useContext(Tt),{hash:o,pathname:a,search:i}=mn(e,{relative:r}),c=a;return n!=="/"&&(c=a==="/"?n:Wt([n,a])),s.createHref({pathname:c,search:i,hash:o})}function hn(){return l.useContext(os)!=null}function ir(){return tt(hn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(os).location}var Ml="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Dl(e){l.useContext(Tt).static||l.useLayoutEffect(e)}function lp(){let{isDataRoute:e}=l.useContext(Jt);return e?kp():cp()}function cp(){tt(hn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Mr),{basename:r,navigator:n}=l.useContext(Tt),{matches:s}=l.useContext(Jt),{pathname:o}=ir(),a=JSON.stringify(Tl(s)),i=l.useRef(!1);return Dl(()=>{i.current=!0}),l.useCallback((d,u={})=>{if(Mt(i.current,Ml),!i.current)return;if(typeof d=="number"){n.go(d);return}let p=Go(d,JSON.parse(a),o,u.relative==="path");e==null&&r!=="/"&&(p.pathname=p.pathname==="/"?r:Wt([r,p.pathname])),(u.replace?n.replace:n.push)(p,u.state,u)},[r,n,a,o,e])}l.createContext(null);function mn(e,{relative:r}={}){let{matches:n}=l.useContext(Jt),{pathname:s}=ir(),o=JSON.stringify(Tl(n));return l.useMemo(()=>Go(e,JSON.parse(o),s,r==="path"),[e,o,s,r])}function dp(e,r,n){tt(hn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=l.useContext(Tt),{matches:o}=l.useContext(Jt),a=o[o.length-1],i=a?a.params:{},c=a?a.pathname:"/",d=a?a.pathnameBase:"/",u=a&&a.route;{let g=u&&u.path||"";zl(c,!u||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${g}">) 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
12
 
13
- Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let p=ir(),f;f=p;let h=f.pathname||"/",m=h;if(d!=="/"){let g=d.replace(/^\//,"").split("/");m="/"+h.replace(/^\//,"").split("/").slice(g.length).join("/")}let y=El(e,{pathname:m});return Mt(u||y!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Mt(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.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.`),mp(y&&y.map(g=>Object.assign({},g,{params:Object.assign({},i,g.params),pathname:Wt([d,s.encodeLocation?s.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?d:Wt([d,s.encodeLocation?s.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),o,n)}function up(){let e=bp(),r=Xu(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=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:a},"ErrorBoundary")," or"," ",l.createElement("code",{style:a},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},r),n?l.createElement("pre",{style:o},n):null,i)}var pp=l.createElement(up,null),Fl=class extends l.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=ap(e.digest);n&&(e=n)}let r=e!==void 0?l.createElement(Jt.Provider,{value:this.props.routeContext},l.createElement(Ko.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(fp,{error:e},r):r}};Fl.contextType=ep;var js=new WeakMap;function fp({children:e,error:r}){let{basename:n}=l.useContext(Tt);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let s=op(r.digest);if(s){let o=js.get(r);if(o)throw o;let a=Ll(s.location,n);if(Il&&!js.get(r))if(a.isExternal||s.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:s.replace}));throw js.set(r,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function hp({routeContext:e,match:r,children:n}){let s=l.useContext(Mr);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),l.createElement(Jt.Provider,{value:e},n)}function mp(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);tt(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,c=-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)&&(c=p),f.route.id){let{loaderData:h,errors:m}=s,y=f.route.loader&&!h.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||y){n.isStatic&&(i=!0),c>=0?o=o.slice(0,c+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)??{},unstable_pattern:Qu(s.matches),errorInfo:f})}:void 0;return o.reduceRight((p,f,h)=>{let m,y=!1,x=null,g=null;s&&(m=a&&f.route.id?a[f.route.id]:void 0,x=f.route.errorElement||pp,i&&(c<0&&h===0?(zl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,g=null):c===h&&(y=!0,g=f.route.hydrateFallbackElement||null)));let b=r.concat(o.slice(0,h+1)),v=()=>{let k;return m?k=x:y?k=g:f.route.Component?k=l.createElement(f.route.Component,null):f.route.element?k=f.route.element:k=p,l.createElement(hp,{match:f,routeContext:{outlet:p,matches:b,isDataRoute:s!=null},children:k})};return s&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?l.createElement(Fl,{location:s.location,revalidation:s.revalidation,component:x,error:m,children:v(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):v()},null)}function qo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xp(e){let r=l.useContext(Mr);return tt(r,qo(e)),r}function gp(e){let r=l.useContext(ss);return tt(r,qo(e)),r}function yp(e){let r=l.useContext(Jt);return tt(r,qo(e)),r}function Yo(e){let r=yp(e),n=r.matches[r.matches.length-1];return tt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function vp(){return Yo("useRouteId")}function bp(){var s;let e=l.useContext(Ko),r=gp("useRouteError"),n=Yo("useRouteError");return e!==void 0?e:(s=r.errors)==null?void 0:s[n]}function kp(){let{router:e}=xp("useNavigate"),r=Yo("useNavigate"),n=l.useRef(!1);return Dl(()=>{n.current=!0}),l.useCallback(async(o,a={})=>{Mt(n.current,Ml),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:r,...a}))},[e,r])}var Aa={};function zl(e,r,n){!r&&!Aa[e]&&(Aa[e]=!0,Mt(!1,n))}l.memo(jp);function jp({routes:e,future:r,state:n,isStatic:s,onError:o}){return dp(e,void 0,{state:n,isStatic:s,onError:o})}function wp({basename:e="/",children:r=null,location:n,navigationType:s="POP",navigator:o,static:a=!1,unstable_useTransitions:i}){tt(!hn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),d=l.useMemo(()=>({basename:c,navigator:o,static:a,unstable_useTransitions:i,future:{}}),[c,o,a,i]);typeof n=="string"&&(n=$r(n));let{pathname:u="/",search:p="",hash:f="",state:h=null,key:m="default",unstable_mask:y}=n,x=l.useMemo(()=>{let g=Yt(u,c);return g==null?null:{location:{pathname:g,search:p,hash:f,state:h,key:m,unstable_mask:y},navigationType:s}},[c,u,p,f,h,m,s,y]);return Mt(x!=null,`<Router basename="${c}"> 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.`),x==null?null:l.createElement(Tt.Provider,{value:d},l.createElement(os.Provider,{children:r,value:x}))}var Un="get",Hn="application/x-www-form-urlencoded";function as(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Sp(e){return as(e)&&e.tagName.toLowerCase()==="button"}function Cp(e){return as(e)&&e.tagName.toLowerCase()==="form"}function Ep(e){return as(e)&&e.tagName.toLowerCase()==="input"}function Np(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Rp(e,r){return e.button===0&&(!r||r==="_self")&&!Np(e)}var Nn=null;function Tp(){if(Nn===null)try{new FormData(document.createElement("form"),0),Nn=!1}catch{Nn=!0}return Nn}var Ip=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ws(e){return e!=null&&!Ip.has(e)?(Mt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Hn}"`),null):e}function Lp(e,r){let n,s,o,a,i;if(Cp(e)){let c=e.getAttribute("action");s=c?Yt(c,r):null,n=e.getAttribute("method")||Un,o=ws(e.getAttribute("enctype"))||Hn,a=new FormData(e)}else if(Sp(e)||Ep(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||c.getAttribute("action");if(s=d?Yt(d,r):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Un,o=ws(e.getAttribute("formenctype"))||ws(c.getAttribute("enctype"))||Hn,a=new FormData(c,e),!Tp()){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(as(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Un,s=null,o=Hn,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 Jo(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Ap(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&&Yt(o.pathname,r)==="/"?o.pathname=`${r.replace(/\/$/,"")}/_root.${s}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${s}`,o}async function Pp(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 $p(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 Mp(e,r,n){let s=await Promise.all(e.map(async o=>{let a=r.routes[o.route.id];if(a){let i=await Pp(a,n);return i.links?i.links():[]}return[]}));return Bp(s.flat(1).filter($p).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function Pa(e,r,n,s,o,a){let i=(d,u)=>n[u]?d.route.id!==n[u].route.id:!0,c=(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)||c(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)||c(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 Dp(e,r,{includeHydrateFallback:n}={}){return Fp(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 Fp(e){return[...new Set(e)]}function zp(e){let r={},n=Object.keys(e).sort();for(let s of n)r[s]=e[s];return r}function Bp(e,r){let n=new Set;return new Set(r),e.reduce((s,o)=>{let a=JSON.stringify(zp(o));return n.has(a)||(n.add(a),s.push({key:a,link:o})),s},[])}function Bl(){let e=l.useContext(Mr);return Jo(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function _p(){let e=l.useContext(ss);return Jo(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Xo=l.createContext(void 0);Xo.displayName="FrameworkContext";function _l(){let e=l.useContext(Xo);return Jo(e,"You must render this element inside a <HydratedRouter> element"),e}function Op(e,r){let n=l.useContext(Xo),[s,o]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:d,onMouseEnter:u,onMouseLeave:p,onTouchStart:f}=r,h=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=b=>{b.forEach(v=>{i(v.isIntersecting)})},g=new IntersectionObserver(x,{threshold:.5});return h.current&&g.observe(h.current),()=>{g.disconnect()}}},[e]),l.useEffect(()=>{if(s){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[s]);let m=()=>{o(!0)},y=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,h,{}]:[a,h,{onFocus:Or(c,m),onBlur:Or(d,y),onMouseEnter:Or(u,m),onMouseLeave:Or(p,y),onTouchStart:Or(f,m)}]:[!1,h,{}]}function Or(e,r){return n=>{e&&e(n),n.defaultPrevented||r(n)}}function Wp({page:e,...r}){let{router:n}=Bl(),s=l.useMemo(()=>El(n.routes,e,n.basename),[n.routes,e,n.basename]);return s?l.createElement(Hp,{page:e,matches:s,...r}):null}function Up(e){let{manifest:r,routeModules:n}=_l(),[s,o]=l.useState([]);return l.useEffect(()=>{let a=!1;return Mp(e,r,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,r,n]),s}function Hp({page:e,matches:r,...n}){let s=ir(),{future:o,manifest:a,routeModules:i}=_l(),{basename:c}=Bl(),{loaderData:d,matches:u}=_p(),p=l.useMemo(()=>Pa(e,r,u,a,s,"data"),[e,r,u,a,s]),f=l.useMemo(()=>Pa(e,r,u,a,s,"assets"),[e,r,u,a,s]),h=l.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let x=new Set,g=!1;if(r.forEach(v=>{var E;let k=a.routes[v.route.id];!k||!k.hasLoader||(!p.some(j=>j.route.id===v.route.id)&&v.route.id in d&&((E=i[v.route.id])!=null&&E.shouldRevalidate)||k.hasClientLoader?g=!0:x.add(v.route.id))}),x.size===0)return[];let b=Ap(e,c,o.unstable_trailingSlashAwareDataRequests,"data");return g&&x.size>0&&b.searchParams.set("_routes",r.filter(v=>x.has(v.route.id)).map(v=>v.route.id).join(",")),[b.pathname+b.search]},[c,o.unstable_trailingSlashAwareDataRequests,d,s,a,p,r,e,i]),m=l.useMemo(()=>Dp(f,a),[f,a]),y=Up(f);return l.createElement(l.Fragment,null,h.map(x=>l.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),m.map(x=>l.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),y.map(({key:x,link:g})=>l.createElement("link",{key:x,nonce:n.nonce,...g,crossOrigin:g.crossOrigin??n.crossOrigin})))}function Vp(...e){return r=>{e.forEach(n=>{typeof n=="function"?n(r):n!=null&&(n.current=r)})}}var Gp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Gp&&(window.__reactRouterVersion="7.13.1")}catch{}function Kp({basename:e,children:r,unstable_useTransitions:n,window:s}){let o=l.useRef();o.current==null&&(o.current=Nu({window:s,v5Compat:!0}));let a=o.current,[i,c]=l.useState({action:a.action,location:a.location}),d=l.useCallback(u=>{n===!1?c(u):l.startTransition(()=>c(u))},[n]);return l.useLayoutEffect(()=>a.listen(d),[a,d]),l.createElement(wp,{basename:e,children:r,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var Ol=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Wl=l.forwardRef(function({onClick:r,discover:n="render",prefetch:s="none",relative:o,reloadDocument:a,replace:i,unstable_mask:c,state:d,target:u,to:p,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:m,...y},x){let{basename:g,navigator:b,unstable_useTransitions:v}=l.useContext(Tt),k=typeof p=="string"&&Ol.test(p),E=Ll(p,g);p=E.to;let j=ip(p,{relative:o}),T=ir(),w=null;if(c){let C=Go(c,[],T.unstable_mask?T.unstable_mask.pathname:"/",!0);g!=="/"&&(C.pathname=C.pathname==="/"?g:Wt([g,C.pathname])),w=b.createHref(C)}let[S,N,R]=Op(s,y),I=Xp(p,{replace:i,unstable_mask:c,state:d,target:u,preventScrollReset:f,relative:o,viewTransition:h,unstable_defaultShouldRevalidate:m,unstable_useTransitions:v});function A(C){r&&r(C),C.defaultPrevented||I(C)}let $=!(E.isExternal||a),B=l.createElement("a",{...y,...R,href:($?w:void 0)||E.absoluteURL||j,onClick:$?A:r,ref:Vp(x,N),target:u,"data-discover":!k&&n==="render"?"true":void 0});return S&&!k?l.createElement(l.Fragment,null,B,l.createElement(Wp,{page:j})):B});Wl.displayName="Link";var qp=l.forwardRef(function({"aria-current":r="page",caseSensitive:n=!1,className:s="",end:o=!1,style:a,to:i,viewTransition:c,children:d,...u},p){let f=mn(i,{relative:u.relative}),h=ir(),m=l.useContext(ss),{navigator:y,basename:x}=l.useContext(Tt),g=m!=null&&rf(f)&&c===!0,b=y.encodeLocation?y.encodeLocation(f).pathname:f.pathname,v=h.pathname,k=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(v=v.toLowerCase(),k=k?k.toLowerCase():null,b=b.toLowerCase()),k&&x&&(k=Yt(k,x)||k);const E=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let j=v===b||!o&&v.startsWith(b)&&v.charAt(E)==="/",T=k!=null&&(k===b||!o&&k.startsWith(b)&&k.charAt(b.length)==="/"),w={isActive:j,isPending:T,isTransitioning:g},S=j?r:void 0,N;typeof s=="function"?N=s(w):N=[s,j?"active":null,T?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(w):a;return l.createElement(Wl,{...u,"aria-current":S,className:N,ref:p,style:R,to:i,viewTransition:c},typeof d=="function"?d(w):d)});qp.displayName="NavLink";var Yp=l.forwardRef(({discover:e="render",fetcherKey:r,navigate:n,reloadDocument:s,replace:o,state:a,method:i=Un,action:c,onSubmit:d,relative:u,preventScrollReset:p,viewTransition:f,unstable_defaultShouldRevalidate:h,...m},y)=>{let{unstable_useTransitions:x}=l.useContext(Tt),g=ef(),b=tf(c,{relative:u}),v=i.toLowerCase()==="get"?"get":"post",k=typeof c=="string"&&Ol.test(c),E=j=>{if(d&&d(j),j.defaultPrevented)return;j.preventDefault();let T=j.nativeEvent.submitter,w=(T==null?void 0:T.getAttribute("formmethod"))||i,S=()=>g(T||j.currentTarget,{fetcherKey:r,method:w,navigate:n,replace:o,state:a,relative:u,preventScrollReset:p,viewTransition:f,unstable_defaultShouldRevalidate:h});x&&n!==!1?l.startTransition(()=>S()):S()};return l.createElement("form",{ref:y,method:v,action:b,onSubmit:s?d:E,...m,"data-discover":!k&&e==="render"?"true":void 0})});Yp.displayName="Form";function Jp(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ul(e){let r=l.useContext(Mr);return tt(r,Jp(e)),r}function Xp(e,{target:r,replace:n,unstable_mask:s,state:o,preventScrollReset:a,relative:i,viewTransition:c,unstable_defaultShouldRevalidate:d,unstable_useTransitions:u}={}){let p=lp(),f=ir(),h=mn(e,{relative:i});return l.useCallback(m=>{if(Rp(m,r)){m.preventDefault();let y=n!==void 0?n:sn(f)===sn(h),x=()=>p(e,{replace:y,unstable_mask:s,state:o,preventScrollReset:a,relative:i,viewTransition:c,unstable_defaultShouldRevalidate:d});u?l.startTransition(()=>x()):x()}},[f,p,h,n,s,o,r,e,a,i,c,d,u])}var Qp=0,Zp=()=>`__${String(++Qp)}__`;function ef(){let{router:e}=Ul("useSubmit"),{basename:r}=l.useContext(Tt),n=vp(),s=e.fetch,o=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:d,encType:u,formData:p,body:f}=Lp(a,r);if(i.navigate===!1){let h=i.fetcherKey||Zp();await s(h,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,formMethod:i.method||d,formEncType:i.encType||u,flushSync:i.flushSync})}else await o(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_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 tf(e,{relative:r}={}){let{basename:n}=l.useContext(Tt),s=l.useContext(Jt);tt(s,"useFormAction must be used inside a RouteContext");let[o]=s.matches.slice(-1),a={...mn(e||".",{relative:r})},i=ir();if(e==null){a.search=i.search;let c=new URLSearchParams(a.search),d=c.getAll("index");if(d.some(p=>p==="")){c.delete("index"),d.filter(f=>f).forEach(f=>c.append("index",f));let p=c.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:Wt([n,a.pathname])),sn(a)}function rf(e,{relative:r}={}){let n=l.useContext(Pl);tt(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=Ul("useViewTransitionState"),o=mn(e,{relative:r});if(!n.isTransitioning)return!1;let a=Yt(n.currentLocation.pathname,s)||n.currentLocation.pathname,i=Yt(n.nextLocation.pathname,s)||n.nextLocation.pathname;return Xn(o.pathname,i)!=null||Xn(o.pathname,a)!=null}var Dr=Su();const nf=Cu(Dr),sf=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Rn(e){if(typeof e!="string")return null;const r=e.trim();return r===""||!sf.test(r)||r==="0.0.0"?null:r}function Hl(e){if(e.preferInstalled){const o=Rn(e.installedCurrentVersion);if(o)return{version:o,versionSource:"registry"}}const r=Rn(e.frontmatterVersion);if(r)return{version:r,versionSource:"frontmatter"};const n=Rn(e.registryCurrentVersion);if(n)return{version:n,versionSource:"registry"};const s=Rn(e.pluginVersion);return s?{version:s,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const of={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},$a={own:"authoring-project",installed:"available-project",global:"available-personal"},jo=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function af(e){if(typeof e=="string"){if(jo.has(e))return e;if(Object.prototype.hasOwnProperty.call($a,e))return $a[e]}return"authoring-project"}function lf(e){return e.startsWith("available-")?"available":"authoring"}function cf(e){const r=e.indexOf("-");return e.slice(r+1)}const bt="";function Tn(e,r){try{let n=!1;const s=of;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 qt extends Error{constructor(r,n,s){super(r),this.name="ApiError",this.status=n,this.details=s}}async function ye(e,r){const n=await fetch(`${bt}${e}`,r);if(!n.ok){const s=await n.json().catch(()=>({error:n.statusText})),o=s&&typeof s=="object"?s:void 0;throw new qt((s==null?void 0:s.error)||`HTTP ${n.status}`,n.status,o)}return n.json()}async function Ma(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 Da=100;function Fa(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 Ge(e){return typeof e=="string"&&e.length>0?e:null}function df(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Nr(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 uf(e){if(!e||typeof e!="object")return null;const r=e,n=Ge(r.python)??void 0,s=Nr(r.pip)??void 0,o=Ge(r.node)??void 0;return!n&&!s&&!o?null:{python:n,pip:s,node:o}}function pf(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:Ge(r.file)??void 0,requires:Nr(r.requires)??void 0}}function ff(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"&&jo.has(r.scopeV2)?r.scopeV2:af(r.scope),i=lf(a),c=cf(a),d=typeof r.precedenceRank=="number"?r.precedenceRank:void 0;let u;r.shadowedBy===null?u=null:typeof r.shadowedBy=="string"&&jo.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,scope:s,isSymlink:typeof r.isSymlink=="boolean"?r.isSymlink:!1,symlinkTarget:Ge(r.symlinkTarget),installMethod:o,sourcePath:Ge(r.sourcePath),scopeV2:a,group:i,source:c,pluginName:Ge(r.pluginName),pluginNamespace:Ge(r.pluginNamespace),pluginMarketplace:Ge(r.pluginMarketplace),pluginManifestPath:Ge(r.pluginManifestPath),pluginVersion:Ge(r.pluginVersion),...typeof r.pluginDisplay=="string"&&r.pluginDisplay?{pluginDisplay:r.pluginDisplay}:{},precedenceRank:d,shadowedBy:u,description:Ge(r.description),version:Ge(r.version),category:Ge(r.category),author:Ge(r.author),license:Ge(r.license),homepage:Ge(r.homepage),repoUrl:Ge(r.repoUrl),skillPath:Ge(r.skillPath),tags:Nr(r.tags),deps:Nr(r.deps),mcpDeps:Nr(r.mcpDeps),entryPoint:Ge(r.entryPoint),lastModified:Ge(r.lastModified),sizeBytes:df(r.sizeBytes),sourceAgent:Ge(r.sourceAgent),secrets:Nr(r.secrets),runtime:uf(r.runtime),integrationTests:pf(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=Hl({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 ye("/api/config")},setConfig(e,r){return ye("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:r})})},revealInEditor(e,r,n){return ye("/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 ye(`/api/skills${n?"?"+n:""}`);return Array.isArray(s)?s.map(ff):[]},getSkillInstallState(e){return ye(`/api/studio/install-state?skill=${encodeURIComponent(e)}`)},async convertToPlugin(e){return ye("/api/authoring/convert-to-plugin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getAgents(){return ye("/api/agents")},getSkillDetail(e,r){return ye(`/api/skills/${e}/${r}`)},async getEvals(e,r){const n=await ye(`/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 ye(`/api/skills/${e}/${r}/evals`)},getActivationHistoryEnvelope(e,r){return ye(`/api/skills/${e}/${r}/activation-history`)},saveEvals(e,r,n){return ye(`/api/skills/${e}/${r}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},generateEvals(e,r){return ye(`/api/skills/${e}/${r}/generate-evals`,{method:"POST"})},async getLatestBenchmark(e,r){const n=await fetch(`${bt}/api/skills/${e}/${r}/benchmark/latest`);if(!n.ok){const s=await n.json().catch(()=>({error:n.statusText}));throw new qt(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 ye(`/api/skills/${e}/${r}/history${o?"?"+o:""}`)},getHistoryEntry(e,r,n){return ye(`/api/skills/${e}/${r}/history/${encodeURIComponent(n)}`)},compareRuns(e,r,n,s){return ye(`/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 ye(`/api/skills/${e}/${r}/history/case/${n}${a?"?"+a:""}`)},deleteHistoryEntry(e,r,n){return ye(`/api/skills/${e}/${r}/history/${encodeURIComponent(n)}`,{method:"DELETE"})},deleteSkill(e,r){return ye(`/api/skills/${e}/${r}`,{method:"DELETE"})},uninstallSkill(e,r){return ye(`/api/skills/${e}/${r}/uninstall`,{method:"POST"})},improveSkill(e,r,n){return ye(`/api/skills/${e}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},instructEdit(e,r,n){return ye(`/api/skills/${e}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...n})})},applyImprovement(e,r,n){return ye(`/api/skills/${e}/${r}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})})},getStats(e,r){return ye(`/api/skills/${e}/${r}/stats`)},getDependencies(e,r){return ye(`/api/skills/${e}/${r}/dependencies`)},getProjectLayout(){return ye("/api/project-layout")},getProjectGitHubStatus(){return ye("/api/project/github-status")},createSkill(e){return ye("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},detectEngines(){return ye("/api/studio/detect-engines")},saveDraft(e){return ye("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getSkillCreatorStatus(){return ye("/api/skill-creator-status")},generateSkill(e){return ye("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getSkillFiles(e,r){return ye(`/api/skills/${e}/${r}/files`)},getSkillFile(e,r,n){return ye(`/api/skills/${e}/${r}/file?path=${encodeURIComponent(n)}`)},saveSkillFile(e,r,n,s){return ye(`/api/skills/${e}/${r}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:s})})},getLeaderboard(e,r){return ye(`/api/skills/${e}/${r}/leaderboard`)},getLeaderboardEntry(e,r,n){return ye(`/api/skills/${e}/${r}/leaderboard/${encodeURIComponent(n)}`)},startSweep(e,r,n){const s=`${bt}/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 ye(`/api/credentials/${e}/${r}`)},setCredential(e,r,n,s){return ye(`/api/credentials/${e}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,value:s})})},getParams(e,r){return ye(`/api/credentials/${e}/${r}/params`)},getParamsRevealed(e,r,n){const s=n?`reveal=true&key=${encodeURIComponent(n)}`:"reveal=true";return ye(`/api/credentials/${e}/${r}/params?${s}`)},searchModels(){return ye("/api/openrouter/models")},async getSkillVersions(e,r){const n=await ye(`/api/skills/${e}/${r}/versions`);return Array.isArray(n)?n:Array.isArray(n.versions)?n.versions:[]},getSkillVersionsEnvelope(e,r){return ye(`/api/skills/${e}/${r}/versions`)},getVersionDiff(e,r,n,s){return ye(`/api/skills/${e}/${r}/versions/diff?from=${n}&to=${s}`)},startBatchUpdate(e){const r=`${bt}/api/skills/batch-update`,n=new EventSource(r);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:e})}),n},startSkillUpdate(e,r){const n=`${bt}/api/skills/${e}/${r}/update`,s=new EventSource(n);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),s},async postSkillUpdate(e,r,n){let s,o;if(n&&typeof n.aborted=="boolean")s=n;else if(n&&typeof n=="object"){const p=n;s=p.signal,o=p.agentId}const a=o?`?agent=${encodeURIComponent(o)}`:"",i=`${bt}/api/skills/${e}/${r}/update${a}`,c=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},signal:s});let d,u="";if(c.body){const p=c.body.getReader(),f=new TextDecoder;let h=!1,m="";for(;!h;){const x=await p.read();if(h=x.done,x.value){const g=f.decode(x.value,{stream:!h});m+=g,u.length<200&&(u+=g)}}const y=m.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(y)try{d=JSON.parse(y[1]).version}catch{}u=u.slice(0,200)}else{const p=await c.text();u=p.slice(0,200);const f=p.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(f)try{d=JSON.parse(f[1]).version}catch{}}return{ok:c.ok,status:c.status,body:u,version:d}},async rescanSkill(e,r){const n=`${e}/${r}`,s=await fetch(`${bt}/api/v1/skills/${encodeURIComponent(n)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!s.ok)throw new Error(`rescan failed: HTTP ${s.status}`);return await s.json()},async getSkillUpdates(){try{const e=await fetch(`${bt}/api/skills/updates`);return e.ok?await e.json():[]}catch{return[]}},async checkSkillUpdates(e){if(e.length===0)return[];const r=[...e].sort(),n=Fa(r,Da),s=async a=>{try{const i=await Ma(`${bt}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(d=>({name:d,currentVersion:"0.0.0"}))})});if(!i.ok)return[];const c=await i.json().catch(()=>null);return Array.isArray(c)?c:c&&typeof c=="object"&&Array.isArray(c.results)?c.results.map(d=>({skillId:typeof d.skillId=="string"?d.skillId:typeof d.name=="string"?d.name:"",version:typeof d.version=="string"?d.version:typeof d.latest=="string"?d.latest:"",eventId:typeof d.eventId=="string"?d.eventId:"",publishedAt:typeof d.publishedAt=="string"?d.publishedAt:"",diffSummary:typeof d.diffSummary=="string"?d.diffSummary:void 0,trackedForUpdates:typeof d.trackedForUpdates=="boolean"?d.trackedForUpdates:void 0,updateAvailable:typeof d.updateAvailable=="boolean"?d.updateAvailable:void 0,installed:typeof d.installed=="string"&&d.installed!=="0.0.0"?d.installed:void 0,latest:typeof d.latest=="string"?d.latest:void 0,name:typeof d.name=="string"?d.name:void 0})):[]}catch{return[]}};return(await Promise.all(n.map(s))).flat()},async resolveInstalledSkillIds(e){if(e.length===0)return[];const r=Fa(e,Da),n=async a=>{try{const i=await Ma(`${bt}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!i.ok)return{ok:!1,map:new Map};const c=await i.json().catch(()=>null),d=Array.isArray(c)?c:Array.isArray(c==null?void 0:c.results)?c.results:[];return{ok:!0,map:new Map(d.filter(u=>typeof u.name=="string"&&u.name.length>0).map(u=>[u.name,u]))}}catch{return{ok:!1,map:new Map}}},s=await Promise.all(r.map(n));if(s.length>0&&s.every(a=>!a.ok))throw new Error("resolveInstalledSkillIds: all chunks failed");const o=new Map;for(const a of s)for(const[i,c]of a.map)o.set(i,c);return e.map(a=>{const i=o.get(a.name);return{plugin:a.plugin,skill:a.skill,uuid:typeof(i==null?void 0:i.id)=="string"&&i.id.length>0?i.id:void 0,slug:typeof(i==null?void 0:i.slug)=="string"&&i.slug.length>0?i.slug:void 0}})},async lookupSkillsByName(e){if(!Array.isArray(e)||e.length===0)return[];const r=e.slice(0,50);try{const n=await fetch(`${bt}/api/v1/skills/lookup-by-name`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entries:r})});if(!n.ok)return Tn("lookup-by-name-error",{status:n.status}),[];const s=await n.json().catch(a=>(Tn("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&&Tn("lookup-by-name-no-results-array",{}),[])}catch(n){return Tn("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 Ss(`/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 Ss(`/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 Ss(`/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 ye(`/api/studio/ops${n?"?"+n:""}`)},deleteStudioOp(e){return ye(`/api/studio/ops/${encodeURIComponent(e)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${bt}/api/studio/ops/stream`)},gitRemote(){return ye("/api/git/remote")},gitDiff(){return ye("/api/git/diff",{method:"POST"})},gitStatus(){return ye("/api/git/status")},gitCommitMessage(e){return ye("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})},gitPublish(e){return ye("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})},async submitToQueue(e){const r=await ye("/api/v1/submissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});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 ye("/api/v1/submissions?mine=1")},getSubmission(e){return ye(`/api/v1/submissions/${encodeURIComponent(e)}`)},getPositions(e){const r=e&&e.length>0?`?ids=${encodeURIComponent(e.join(","))}`:"";return ye(`/api/v1/submissions/positions${r}`)},async getAccountTenants(){return ye("/api/v1/account/tenants")},async getActiveTenant(){return ye("/__internal/active-tenant")},async setActiveTenant(e){return ye("/__internal/active-tenant",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentTenant:e})})}};async function Ss(e,r,n){const s=await fetch(`${bt}${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 qt(p,s.status);throw f&&(h.code=f),h}const o=s.body.getReader(),a=new TextDecoder;let i="",c="",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: "))c=m.slice(7).trim();else if(m.startsWith("data: ")){let y={};try{y=JSON.parse(m.slice(6))}catch{c="";continue}if(c==="started"||c==="copied"||c==="deleted"||c==="indexed"||c==="done"||c==="error"){const x={type:c,...y};r==null||r(x),x.type==="done"&&(d=x),x.type==="error"&&(u=x)}c=""}}if(u){const p=new qt(u.message,500);throw p.code=u.code,p}if(!d)throw new qt("Transfer stream ended without 'done' event",500);return d}function hf(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,c]=s.map(Number),[,d,u,p]=o.map(Number);return a!==d?a>d:i!==u?i>u:c>=p}function mf(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 c=a[a.length-1];n.set(`${c}/${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&&!hf(o.version,a.latest),c=a.installed&&a.installed!=="0.0.0"?a.installed:null,d={...o,updateAvailable:i,currentVersion:c??o.currentVersion,latestVersion:a.latest??void 0};typeof a.trackedForUpdates=="boolean"&&(d.trackedForUpdates=a.trackedForUpdates);const u=Hl({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 Vn=new Map,pr=new Map,Yr=new Map;function Be(e){Vn.delete(e),pr.delete(e);const r=Yr.get(e);if(r)for(const n of r)n()}function St(e,r,n={}){const{ttl:s=3e4,enabled:o=!0}=n,[,a]=l.useState(0),[i,c]=l.useState(void 0),[d,u]=l.useState(0),p=l.useRef(!0),f=l.useRef(e);f.current=e;const h=()=>{c(void 0),Be(e),u(x=>x+1)};l.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),l.useEffect(()=>{if(!o)return;const x=()=>{p.current&&u(g=>g+1)};return Yr.has(e)||Yr.set(e,new Set),Yr.get(e).add(x),()=>{var g;(g=Yr.get(e))==null||g.delete(x)}},[e,o]),l.useEffect(()=>{if(!o)return;const x=Vn.get(e);if(!(!x||Date.now()-x.fetchedAt>s))return;if(pr.has(e)){const k=pr.get(e),E=()=>{p.current&&f.current===e&&a(j=>j+1)};k.subscribers.push(E);return}const b={promise:Promise.resolve(),subscribers:[]},v=r().then(k=>{Vn.set(e,{data:k,fetchedAt:Date.now()}),pr.delete(e),p.current&&f.current===e&&(c(void 0),a(E=>E+1));for(const E of b.subscribers)E()},k=>{pr.delete(e);const E=k instanceof Error?k:new Error(String(k));p.current&&f.current===e&&(c(E),a(j=>j+1));for(const j of b.subscribers)j()});b.promise=v,pr.set(e,b)},[e,r,s,o,d]);const m=Vn.get(e),y=o&&!m&&!i&&pr.has(e);return{data:m==null?void 0:m.data,loading:y,error:i,revalidate:h}}function xf(e){const[r,n]=l.useState(()=>typeof window>"u"?!1:window.matchMedia(e).matches);return l.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}const gf=500,wo="vskill.updates.seenLastId";function yf(){if(typeof window>"u")return null;try{return window.localStorage.getItem(wo)}catch{return null}}function Cs(e){if(!(typeof window>"u"))try{e==null?window.localStorage.removeItem(wo):window.localStorage.setItem(wo,e)}catch{}}function vf(){let e=new Map;const r=new Set,n=new Set,s=[];let o=yf();o&&(n.add(o),s.push(o));function a(){e=new Map(e);for(const c of Array.from(r))c()}function i(c){if(!n.has(c)){if(n.add(c),s.push(c),s.length>gf){const d=s.shift();d&&n.delete(d)}o=c,Cs(c)}}return{getSnapshot(){return e},subscribe(c){return r.add(c),()=>{r.delete(c)}},ingest(c){return n.has(c.eventId)?"duplicate":(i(c.eventId),e.set(c.skillId,{skillId:c.skillId,version:c.version,diffSummary:c.diffSummary,eventId:c.eventId,publishedAt:c.publishedAt,receivedAt:Date.now()}),a(),"stored")},dismiss(c){e.has(c)&&(e.delete(c),a())},clearSeen(){n.clear(),s.length=0,o=null,Cs(null)},mergeBulk(c){if(c.length!==0){for(const d of c)e.set(d.skillId,d);a()}},getSeenLastId(){return o},reset(){e=new Map,n.clear(),s.length=0,o=null,Cs(null),a()}}}const tr=vf(),Vl="vskill:toast-queue",bf=10,kf=1800*1e3;function is(){return typeof window<"u"&&typeof window.localStorage<"u"}function Gl(){if(!is())return[];try{const e=window.localStorage.getItem(Vl);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 Kl(e){if(is())try{window.localStorage.setItem(Vl,JSON.stringify(e))}catch{}}function jf(e){if(!is())return"enqueued";const r=Gl();if(r.some(o=>o.eventId===e.eventId))return"deduped";let n=!1;const s=[...r,e];for(;s.length>bf;)s.shift(),n=!0;return Kl(s),n?"evicted":"enqueued"}function wf(){if(!is())return[];const e=Gl();if(e.length===0)return[];Kl([]);const r=Date.now()-kf;return e.filter(n=>n.enqueuedAt>=r)}const Sf="X-Studio-Token";let hr=null,Wr=null,za=!1,In=null;function Cf(){var e;return typeof window>"u"?!1:!!((e=window.__TAURI_INTERNALS__)!=null&&e.invoke)}function Qo(){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 Ef(){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 Nf(){if(hr)return hr;const e=Qo();return e?(hr=e,e):Wr||(Wr=Ef().then(r=>(r&&(hr=r),Wr=null,r)),Wr)}function Rf(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 Tf(){za||typeof globalThis.fetch!="function"||!(Qo()!==null)&&!Cf()||(za=!0,In=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,!Rf(s))return In(r,n);const o=await Nf();if(!o)return In(r,n);const a={...n??{}},i=new Headers(a.headers??{});return i.set(Sf,o),a.headers=i,In(r,a)})}function If(){if(hr)return hr;const e=Qo();return e?(hr=e,e):null}const ls=new Set(["PUBLISHED","AUTO_APPROVED","VENDOR_APPROVED"]),Zo=new Set(["REJECTED","TIER1_FAILED","BLOCKED"]),So=new Set;function ql(e,r){return`${e}::${r}`}function Yl(e,r){const n=ql(e,r);return So.has(n)?!1:(So.add(n),!0)}function Lf(e,r){So.add(ql(e,r))}function Af(e){return`https://verified-skill.com/submit/${encodeURIComponent(e)}`}function Pf(e,r,n){const s=r||"Your skill";return ls.has(n)?{outcome:"approved",title:"Skill approved",body:`${s} is now published on verified-skill.com`}:Zo.has(n)?{outcome:"rejected",title:"Skill rejected",body:`${s} ${n==="BLOCKED"?"was blocked":"was rejected"}. Tap to see why.`,clickUrl:Af(e)}:null}function $f(){return typeof window<"u"&&"__TAURI_INTERNALS__"in window}async function Mf(){try{return await ar(()=>import("./index-DhhmQddr.js"),__vite__mapDeps([0,1]))}catch{return null}}async function Df(e){try{let r=await e.isPermissionGranted();return r||(r=await e.requestPermission()==="granted"),r}catch{return!1}}async function Jl(e,r,n){const s=Pf(e,r,n);if(!s||!$f())return!1;const o=await Mf();if(!o||!await Df(o))return!1;if(s.outcome==="rejected"&&s.clickUrl&&typeof o.onAction=="function")try{const i=s.clickUrl;let c=null;c=await o.onAction(()=>{Jn(i);try{c==null||c()}catch{}})}catch{}try{return o.sendNotification({title:s.title,body:s.body}),!0}catch{return!1}}function Ba(e){return typeof e=="string"&&e.length>0}function Ff(e){if(typeof e!="string")return null;const r=e.trim();return r.length>0?`usr_${r}`:null}function zf(e){const r=[];for(const n of e){const s=Ba(n.uuid),o=Ba(n.slug);if(!s&&!o)continue;const a={};s&&(a.uuid=n.uuid),o&&(a.slug=n.slug),r.push(a)}return r}const Bf=3e5,_f=500,Of=15e3,Wf=6e4,Uf=6e4,Hf="/api/v1/skills/stream",Vf=250,Gf=500,Kf="/api/v1/studio/telemetry/sse",_a="vskill.studio.sse.sessionId";function Xl(){var e;try{const r=(e=import.meta)==null?void 0:e.env;if(r&&typeof r=="object")return r}catch{}return{}}function qf(){if(typeof window>"u")return!1;const e=Xl();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 Yf(){if(typeof window>"u")return!0;const e=Xl();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 gt(e,r){if(qf())try{const n=new Date().toISOString();r?console.debug(`[sse] ${n} ${e}`,r):console.debug(`[sse] ${n} ${e}`)}catch{}}function Oa(){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 Jf(){if(typeof window>"u")return"";try{const e=window.sessionStorage.getItem(_a);if(e)return e;const r=Oa();return window.sessionStorage.setItem(_a,r),r}catch{return Oa()}}function Wa(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 Ua(e){let r=0;for(const n of e)n.updateAvailable&&r++;return r}function Xf(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 Qf(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 Zf(e){const r=(e==null?void 0:e.intervalMs)??Bf,n=(e==null?void 0:e.debounceMs)??_f,s=(e==null?void 0:e.timeoutMs)??Of,o=(e==null?void 0:e.staleAfterMs)??Wf,a=(e==null?void 0:e.disconnectFallbackMs)??Uf,i=(e==null?void 0:e.streamUrlBase)??Hf,c=(e==null?void 0:e.replayIntervalMs)??Vf,d=Ff(e==null?void 0:e.userId),u=l.useMemo(()=>{const U=(e==null?void 0:e.skillIds)??[];if(U.length===0&&!d)return"";const K=d?1:0,V=[...new Set(U)].filter(J=>J!==d).sort().slice(0,Gf-K),Y=d?[...V,d]:V;return Y.length===0?"":Y.sort().join(",")},[e==null?void 0:e.skillIds,d]),p=l.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]=l.useState([]),[m,y]=l.useState(()=>new Map),[x,g]=l.useState(0),[b,v]=l.useState(!1),[k,E]=l.useState(null),[j,T]=l.useState(null),w=l.useRef(null),S=l.useRef(null),N=l.useRef(null),R=l.useRef(null),I=l.useRef(!0),A=l.useRef(new Set),[$,B]=l.useState(()=>u?"connecting":"fallback"),C=l.useRef($);C.current=$;const L=l.useRef(new Set),P=l.useRef(null),M=l.useSyncExternalStore(U=>tr.subscribe(U),()=>tr.getSnapshot(),()=>tr.getSnapshot()),H=M.size,le=l.useCallback(U=>{if(Yf()||L.current.has(U))return;L.current.add(U);const K=Jf(),V=Date.now(),Y={event:U,sessionId:K,sourceTier:"platform-proxy",timestamp:V};U!=="connected"&&P.current!=null&&(Y.durationSinceOpenMs=V-P.current);try{fetch(Kf,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Y),keepalive:!0}).catch(()=>{})}catch{}},[]),G=l.useCallback(async()=>{v(!0);const U=new AbortController,K=setTimeout(()=>U.abort(),s);try{const V=await Promise.race([ce.getSkillUpdates(),new Promise((Y,J)=>{U.signal.addEventListener("abort",()=>{J(new Error("TIMEOUT"))})})]);if(V==="TIMEOUT")throw new Error("TIMEOUT");if(!I.current)return;h(V),y(Wa(V)),g(Ua(V)),S.current=Date.now(),E(S.current),T(null)}catch(V){if(!I.current)return;T(V instanceof Error?V:new Error(String(V)))}finally{clearTimeout(K),I.current&&v(!1)}},[s]),W=l.useCallback(()=>{if(w.current)return w.current;const U=G().finally(()=>{w.current=null});return w.current=U,U},[G]),Z=l.useCallback(()=>{N.current==null&&(N.current=setInterval(()=>{W()},r))},[r,W]),he=l.useCallback(()=>{N.current!=null&&(clearInterval(N.current),N.current=null)},[]),me=l.useCallback(()=>{if(typeof window>"u")return;const U=wf();U.length!==0&&(gt("queue-drain",{count:U.length}),U.forEach((K,V)=>{let Y;Y=setTimeout(()=>{if(A.current.delete(Y),!I.current)return;const te=tr.getSnapshot().get(K.skillId);if(te&&te.eventId!==K.eventId){gt("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}})),gt("queue-replay",{eventId:K.eventId})}catch{}},V*c),A.current.add(Y)}))},[c]),_=l.useCallback(()=>{for(const U of A.current)clearTimeout(U);A.current.clear()},[]);l.useEffect(()=>{I.current=!0,(S.current==null||Date.now()-S.current>o)&&W(),(typeof document>"u"||document.visibilityState!=="hidden")&&Z();const V=()=>{if(R.current&&(clearTimeout(R.current),R.current=null),document.visibilityState==="hidden"){he();return}me(),R.current=setTimeout(()=>{R.current=null,(S.current==null||Date.now()-S.current>o)&&W(),Z()},n)};return typeof document<"u"&&document.addEventListener("visibilitychange",V),()=>{I.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",V),R.current&&clearTimeout(R.current),_(),he()}},[]);const ne=l.useCallback(async U=>{if(U.length!==0)try{const K=await ce.checkSkillUpdates(U);if(!I.current||K.length===0)return;const V=Date.now(),Y=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:V}));Y.length>0&&tr.mergeBulk(Y);const J=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}));J.length>0&&h(te=>{const de=new Map;for(const F of te)de.set(F.name,F);let se=0;for(const F of J){const q=F.name,re=de.get(q);if(re){const Q={...re};re.trackedForUpdates===void 0&&F.trackedForUpdates!==void 0&&(Q.trackedForUpdates=F.trackedForUpdates),de.set(q,Q)}else de.set(q,{name:F.name,installed:F.installed??"",latest:F.latest??null,updateAvailable:F.updateAvailable??!1,trackedForUpdates:F.trackedForUpdates}),se+=1}if(se===0&&de.size===te.length)return te;const ue=[...de.values()];return y(Wa(ue)),g(Ua(ue)),ue})}catch{}},[]);l.useEffect(()=>{const U=u||p;if(!U){B("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){B("fallback");return}B("connecting");const K=U.split(",");let V=`${i}?skills=${encodeURIComponent(U)}`;const Y=If();Y&&(V+=`&studioToken=${encodeURIComponent(Y)}`);let J=null,te=null,de=null;const se=()=>{te==null&&(te=setTimeout(()=>{te=null,I.current&&C.current!=="connected"&&(B("fallback"),gt("fallback-flipped",{reason:"watchdog-timeout"}),le("fallback"))},a),gt("fallback-armed",{fallbackMs:a}))},ue=()=>{te!=null&&(clearTimeout(te),te=null)};se();const F=1e3,q=()=>{I.current&&de==null&&(de=setTimeout(()=>{if(de=null,!!I.current&&!(J&&J.readyState!==EventSource.CLOSED)){if(J)try{J.close()}catch{}gt("reconnect-scheduled",{backoffMs:F}),le("reconnect-scheduled"),xe()}},F))},re=we=>{if(!I.current)return;let ge;try{ge=JSON.parse(we.data)}catch{return}if(!Xf(ge))return;const Ve=tr.ingest(ge);if(gt("message",{eventId:ge.eventId,skillId:ge.skillId,outcome:Ve}),Ve==="duplicate")return;const Ye=typeof document>"u"||document.visibilityState!=="hidden",Pe=`${ge.skillId} updated to ${ge.version}`;if(Ye)try{window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Pe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId}}))}catch{}else{const rt={message:Pe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId,enqueuedAt:Date.now()},Je=jf(rt);gt("queue-enqueue",{eventId:ge.eventId,outcome:Je})}},Q=()=>{I.current&&(gt("gone",{skillsCount:K.length}),le("gone-frame-received"),tr.clearSeen(),ne(K))},pe=we=>{if(!I.current)return;let ge;try{ge=JSON.parse(we.data)}catch{return}if(Qf(ge)){if(!Yl(ge.submissionId,ge.state)){gt("submission-decision-duplicate",{submissionId:ge.submissionId,state:ge.state});return}gt("submission-decision",{submissionId:ge.submissionId,state:ge.state}),Jl(ge.submissionId,ge.skillName??"",ge.state),ls.has(ge.state)&&W()}},xe=()=>{I.current&&(J=new EventSource(V),gt("open-attempt",{url:V}),J.onopen=()=>{I.current&&(ue(),B("connected"),P.current=Date.now(),gt("open",{url:V}),le("connected"))},J.onerror=()=>{I.current&&(gt("error",{readyState:J==null?void 0:J.readyState}),se(),J&&J.readyState===EventSource.CLOSED&&q())},J.onmessage=re,J.addEventListener("gone",Q),J.addEventListener("submission_decision",pe))};return xe(),()=>{if(ue(),de!=null&&(clearTimeout(de),de=null),J){try{J.removeEventListener("gone",Q)}catch{}try{J.removeEventListener("submission_decision",pe)}catch{}try{J.close()}catch{}}_()}},[u,p,i,a,ne,le,_]),l.useEffect(()=>{if(!p)return;const U=p.split(",");ne(U)},[p,ne]);const D=l.useCallback(U=>{tr.dismiss(U)},[]);return{updates:f,updatesMap:m,updateCount:x,isRefreshing:b,lastFetchAt:k,error:j,refresh:W,updatesById:M,pushUpdateCount:H,status:$,dismiss:D}}async function eh(){return Ql("account_get_platform_url"),{platformBaseUrl:"",authMode:"cookie",getAuthHeader:async()=>null}}async function th(){const e=await Ql("account_get_user_summary");return e&&typeof e=="object"?e:{signedIn:!1,login:null,avatarUrl:null,tier:"free"}}async function Ql(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 Zl(){var e;return typeof window>"u"?!1:!!((e=window.__TAURI_INTERNALS__)!=null&&e.invoke)}const rh={signedIn:!1,login:null,avatarUrl:null,tier:"free"};function ec(){const[e,r]=l.useState(rh);return l.useEffect(()=>{let n=!1;const s=()=>{th().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 nh={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function sh(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 tc=l.createContext(null),rc=tc;function It(){const e=l.useContext(rc);if(!e)throw new Error("useStudio must be used within StudioProvider");return e}function oh({children:e}){const[r,n]=l.useReducer(sh,nh),s=xf("(max-width: 767px)");l.useEffect(()=>{n({type:"SET_MOBILE",isMobile:s})},[s]);const[o,a]=l.useState(()=>{try{const _=window.localStorage.getItem("vskill.studio.prefs");if(!_)return null;const ne=JSON.parse(_);return typeof ne.activeAgent=="string"?ne.activeAgent:null}catch{return null}}),[i,c]=l.useState(o!==null);l.useEffect(()=>{function _(ne){if(!(ne instanceof CustomEvent))return;const D=ne.detail;D!=null&&D.agentId&&(a(D.agentId),c(!0))}return window.addEventListener("studio:agent-changed",_),()=>window.removeEventListener("studio:agent-changed",_)},[]),l.useEffect(()=>{if(i)return;let _=!1;return ce.getAgents().then(ne=>{if(_)return;const D=(ne==null?void 0:ne.suggested)??"claude-code";a(U=>U??D),c(!0)}).catch(()=>{_||(a(ne=>ne??"claude-code"),c(!0))}),()=>{_=!0}},[i]);const d=l.useCallback(()=>{if(!i||!o)return Promise.resolve();n({type:"SET_SKILLS_LOADING",loading:!0});const _={agent:o};return ce.getSkills(_).then(ne=>{n({type:"SET_SKILLS",skills:ne});const D=window.location.hash,U=D.match(/^#\/skills\/(project|personal|plugin)\/([^/]+)\/([^/?]+)/);if(U){const[,V,Y,J]=U,te=V,de=ne.find(ue=>ue.plugin===Y&&ue.skill===J&&ue.source===te);if(de){n({type:"SELECT_SKILL",skill:{plugin:Y,skill:J,origin:de.origin,source:de.source}});return}const se=ne.find(ue=>ue.plugin===Y&&ue.skill===J);se&&n({type:"SELECT_SKILL",skill:{plugin:Y,skill:J,origin:se.origin,source:se.source}});return}const K=D.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(K){const[,V,Y]=K,J=ne.find(te=>te.plugin===V&&te.skill===Y);J&&n({type:"SELECT_SKILL",skill:{plugin:V,skill:Y,origin:J.origin,source:J.source}})}}).catch(ne=>n({type:"SET_SKILLS_ERROR",error:ne.message}))},[o,i]);l.useEffect(()=>{d()},[d]),l.useEffect(()=>{function _(){d()}return window.addEventListener("studio:project-changed",_),()=>window.removeEventListener("studio:project-changed",_)},[d]);const u=l.useCallback(_=>{n({type:"SELECT_SKILL",skill:_}),window.location.hash=_.source?`/skills/${_.source}/${_.plugin}/${_.skill}`:`/skills/${_.plugin}/${_.skill}`},[]),p=l.useRef(r.skills);l.useEffect(()=>{p.current=r.skills},[r.skills]);const f=l.useCallback((_,ne)=>{const D=p.current,U=_?D.find(J=>J.plugin===_&&J.skill===ne):D.find(J=>J.skill===ne&&J.source!=="plugin");if(!_&&!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)??_,V=(U==null?void 0:U.origin)??"source",Y=U==null?void 0:U.source;n({type:"REVEAL_SKILL",skill:{plugin:K,skill:ne,origin:V,source:Y}}),window.location.hash=Y?`/skills/${Y}/${K}/${ne}`:`/skills/${K}/${ne}`},[]),h=l.useCallback(()=>{n({type:"CLEAR_REVEAL"})},[]),m=l.useCallback(()=>{n({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),y=l.useCallback(_=>{n({type:"SET_MODE",mode:_})},[]),x=l.useCallback(_=>{n({type:"SET_SEARCH",query:_})},[]),g=l.useCallback(_=>{n({type:"SET_MOBILE_VIEW",view:_})},[]),b=l.useCallback(()=>{n({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),v=l.useRef(new Map),k=l.useRef(""),E=l.useRef(!1),[j,T]=l.useState(""),w=l.useRef(""),S=l.useRef(""),[N,R]=l.useState(""),I=l.useMemo(()=>r.skills.map(_=>`${_.plugin}/${_.skill}`),[r.skills]),A=l.useMemo(()=>{const _=j?j.split(",").filter(Boolean):[],ne=N?N.split(",").filter(Boolean):[];return _.length===0&&ne.length===0?[]:[...new Set([..._,...ne])]},[j,N]),$=ec(),B=$.signedIn?$.userId:void 0,C=Zf({skillIds:A,trackingSkillIds:I,userId:B}),L=l.useMemo(()=>A.length,[A]),P=l.useRef("");l.useEffect(()=>{const _=r.skills.filter(V=>V.origin==="installed");if(_.length===0){T(""),P.current="";return}const ne=new Map;for(const V of C.updates)ne.set(V.name.split("/").pop()||V.name,V);const D=_.map(V=>{const Y=ne.get(V.skill),J=V.currentVersion??(Y==null?void 0:Y.installed)??V.version??V.pluginVersion??"1.0.0";return{plugin:V.plugin,skill:V.skill,name:(Y==null?void 0:Y.name)??V.skill,currentVersion:J}}),U=D.map(V=>`${V.plugin}/${V.skill}@${V.currentVersion}#${V.name}`).sort().join("|");if(U===P.current)return;P.current=U;let K=!1;return ce.resolveInstalledSkillIds(D).then(V=>{if(K)return;const te=[...zf(V).flatMap(de=>[de.uuid,de.slug].filter(Boolean))].sort().join(",");te!==k.current&&(k.current=te,v.current=new Map(V.map(de=>[`${de.plugin}/${de.skill}`,{uuid:de.uuid,slug:de.slug}])),T(te))}).catch(V=>{if(K||(P.current=""),!E.current){E.current=!0;const Y=V instanceof Error?V.message:String(V);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",Y)}}),()=>{K=!0}},[r.skills,C.updates]),l.useEffect(()=>{const _=r.skills.filter(K=>K.origin==="source"&&typeof K.author=="string"&&K.author.length>0);if(_.length===0){w.current!==""&&(w.current="",R("")),S.current="";return}const ne=_.map(K=>({name:K.skill,author:K.author})),D=ne.map(K=>`${K.name.toLowerCase()}|${K.author}`).sort().join(`
13
+ Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let p=ir(),f;f=p;let h=f.pathname||"/",m=h;if(d!=="/"){let g=d.replace(/^\//,"").split("/");m="/"+h.replace(/^\//,"").split("/").slice(g.length).join("/")}let y=El(e,{pathname:m});return Mt(u||y!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Mt(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.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.`),mp(y&&y.map(g=>Object.assign({},g,{params:Object.assign({},i,g.params),pathname:Wt([d,s.encodeLocation?s.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?d:Wt([d,s.encodeLocation?s.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),o,n)}function up(){let e=bp(),r=Xu(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=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:a},"ErrorBoundary")," or"," ",l.createElement("code",{style:a},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},r),n?l.createElement("pre",{style:o},n):null,i)}var pp=l.createElement(up,null),Fl=class extends l.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=ap(e.digest);n&&(e=n)}let r=e!==void 0?l.createElement(Jt.Provider,{value:this.props.routeContext},l.createElement(Ko.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(fp,{error:e},r):r}};Fl.contextType=ep;var js=new WeakMap;function fp({children:e,error:r}){let{basename:n}=l.useContext(Tt);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let s=op(r.digest);if(s){let o=js.get(r);if(o)throw o;let a=Ll(s.location,n);if(Il&&!js.get(r))if(a.isExternal||s.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:s.replace}));throw js.set(r,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function hp({routeContext:e,match:r,children:n}){let s=l.useContext(Mr);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),l.createElement(Jt.Provider,{value:e},n)}function mp(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);tt(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,c=-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)&&(c=p),f.route.id){let{loaderData:h,errors:m}=s,y=f.route.loader&&!h.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||y){n.isStatic&&(i=!0),c>=0?o=o.slice(0,c+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)??{},unstable_pattern:Qu(s.matches),errorInfo:f})}:void 0;return o.reduceRight((p,f,h)=>{let m,y=!1,x=null,g=null;s&&(m=a&&f.route.id?a[f.route.id]:void 0,x=f.route.errorElement||pp,i&&(c<0&&h===0?(zl("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,g=null):c===h&&(y=!0,g=f.route.hydrateFallbackElement||null)));let b=r.concat(o.slice(0,h+1)),v=()=>{let k;return m?k=x:y?k=g:f.route.Component?k=l.createElement(f.route.Component,null):f.route.element?k=f.route.element:k=p,l.createElement(hp,{match:f,routeContext:{outlet:p,matches:b,isDataRoute:s!=null},children:k})};return s&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?l.createElement(Fl,{location:s.location,revalidation:s.revalidation,component:x,error:m,children:v(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):v()},null)}function qo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xp(e){let r=l.useContext(Mr);return tt(r,qo(e)),r}function gp(e){let r=l.useContext(ss);return tt(r,qo(e)),r}function yp(e){let r=l.useContext(Jt);return tt(r,qo(e)),r}function Yo(e){let r=yp(e),n=r.matches[r.matches.length-1];return tt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function vp(){return Yo("useRouteId")}function bp(){var s;let e=l.useContext(Ko),r=gp("useRouteError"),n=Yo("useRouteError");return e!==void 0?e:(s=r.errors)==null?void 0:s[n]}function kp(){let{router:e}=xp("useNavigate"),r=Yo("useNavigate"),n=l.useRef(!1);return Dl(()=>{n.current=!0}),l.useCallback(async(o,a={})=>{Mt(n.current,Ml),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:r,...a}))},[e,r])}var Aa={};function zl(e,r,n){!r&&!Aa[e]&&(Aa[e]=!0,Mt(!1,n))}l.memo(jp);function jp({routes:e,future:r,state:n,isStatic:s,onError:o}){return dp(e,void 0,{state:n,isStatic:s,onError:o})}function wp({basename:e="/",children:r=null,location:n,navigationType:s="POP",navigator:o,static:a=!1,unstable_useTransitions:i}){tt(!hn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),d=l.useMemo(()=>({basename:c,navigator:o,static:a,unstable_useTransitions:i,future:{}}),[c,o,a,i]);typeof n=="string"&&(n=$r(n));let{pathname:u="/",search:p="",hash:f="",state:h=null,key:m="default",unstable_mask:y}=n,x=l.useMemo(()=>{let g=Yt(u,c);return g==null?null:{location:{pathname:g,search:p,hash:f,state:h,key:m,unstable_mask:y},navigationType:s}},[c,u,p,f,h,m,s,y]);return Mt(x!=null,`<Router basename="${c}"> 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.`),x==null?null:l.createElement(Tt.Provider,{value:d},l.createElement(os.Provider,{children:r,value:x}))}var Un="get",Hn="application/x-www-form-urlencoded";function as(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Sp(e){return as(e)&&e.tagName.toLowerCase()==="button"}function Cp(e){return as(e)&&e.tagName.toLowerCase()==="form"}function Ep(e){return as(e)&&e.tagName.toLowerCase()==="input"}function Np(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Rp(e,r){return e.button===0&&(!r||r==="_self")&&!Np(e)}var Nn=null;function Tp(){if(Nn===null)try{new FormData(document.createElement("form"),0),Nn=!1}catch{Nn=!0}return Nn}var Ip=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ws(e){return e!=null&&!Ip.has(e)?(Mt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Hn}"`),null):e}function Lp(e,r){let n,s,o,a,i;if(Cp(e)){let c=e.getAttribute("action");s=c?Yt(c,r):null,n=e.getAttribute("method")||Un,o=ws(e.getAttribute("enctype"))||Hn,a=new FormData(e)}else if(Sp(e)||Ep(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||c.getAttribute("action");if(s=d?Yt(d,r):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Un,o=ws(e.getAttribute("formenctype"))||ws(c.getAttribute("enctype"))||Hn,a=new FormData(c,e),!Tp()){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(as(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Un,s=null,o=Hn,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 Jo(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Ap(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&&Yt(o.pathname,r)==="/"?o.pathname=`${r.replace(/\/$/,"")}/_root.${s}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${s}`,o}async function Pp(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 $p(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 Mp(e,r,n){let s=await Promise.all(e.map(async o=>{let a=r.routes[o.route.id];if(a){let i=await Pp(a,n);return i.links?i.links():[]}return[]}));return Bp(s.flat(1).filter($p).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function Pa(e,r,n,s,o,a){let i=(d,u)=>n[u]?d.route.id!==n[u].route.id:!0,c=(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)||c(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)||c(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 Dp(e,r,{includeHydrateFallback:n}={}){return Fp(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 Fp(e){return[...new Set(e)]}function zp(e){let r={},n=Object.keys(e).sort();for(let s of n)r[s]=e[s];return r}function Bp(e,r){let n=new Set;return new Set(r),e.reduce((s,o)=>{let a=JSON.stringify(zp(o));return n.has(a)||(n.add(a),s.push({key:a,link:o})),s},[])}function Bl(){let e=l.useContext(Mr);return Jo(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function _p(){let e=l.useContext(ss);return Jo(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Xo=l.createContext(void 0);Xo.displayName="FrameworkContext";function _l(){let e=l.useContext(Xo);return Jo(e,"You must render this element inside a <HydratedRouter> element"),e}function Op(e,r){let n=l.useContext(Xo),[s,o]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:d,onMouseEnter:u,onMouseLeave:p,onTouchStart:f}=r,h=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=b=>{b.forEach(v=>{i(v.isIntersecting)})},g=new IntersectionObserver(x,{threshold:.5});return h.current&&g.observe(h.current),()=>{g.disconnect()}}},[e]),l.useEffect(()=>{if(s){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[s]);let m=()=>{o(!0)},y=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,h,{}]:[a,h,{onFocus:Or(c,m),onBlur:Or(d,y),onMouseEnter:Or(u,m),onMouseLeave:Or(p,y),onTouchStart:Or(f,m)}]:[!1,h,{}]}function Or(e,r){return n=>{e&&e(n),n.defaultPrevented||r(n)}}function Wp({page:e,...r}){let{router:n}=Bl(),s=l.useMemo(()=>El(n.routes,e,n.basename),[n.routes,e,n.basename]);return s?l.createElement(Hp,{page:e,matches:s,...r}):null}function Up(e){let{manifest:r,routeModules:n}=_l(),[s,o]=l.useState([]);return l.useEffect(()=>{let a=!1;return Mp(e,r,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,r,n]),s}function Hp({page:e,matches:r,...n}){let s=ir(),{future:o,manifest:a,routeModules:i}=_l(),{basename:c}=Bl(),{loaderData:d,matches:u}=_p(),p=l.useMemo(()=>Pa(e,r,u,a,s,"data"),[e,r,u,a,s]),f=l.useMemo(()=>Pa(e,r,u,a,s,"assets"),[e,r,u,a,s]),h=l.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let x=new Set,g=!1;if(r.forEach(v=>{var E;let k=a.routes[v.route.id];!k||!k.hasLoader||(!p.some(j=>j.route.id===v.route.id)&&v.route.id in d&&((E=i[v.route.id])!=null&&E.shouldRevalidate)||k.hasClientLoader?g=!0:x.add(v.route.id))}),x.size===0)return[];let b=Ap(e,c,o.unstable_trailingSlashAwareDataRequests,"data");return g&&x.size>0&&b.searchParams.set("_routes",r.filter(v=>x.has(v.route.id)).map(v=>v.route.id).join(",")),[b.pathname+b.search]},[c,o.unstable_trailingSlashAwareDataRequests,d,s,a,p,r,e,i]),m=l.useMemo(()=>Dp(f,a),[f,a]),y=Up(f);return l.createElement(l.Fragment,null,h.map(x=>l.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),m.map(x=>l.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),y.map(({key:x,link:g})=>l.createElement("link",{key:x,nonce:n.nonce,...g,crossOrigin:g.crossOrigin??n.crossOrigin})))}function Vp(...e){return r=>{e.forEach(n=>{typeof n=="function"?n(r):n!=null&&(n.current=r)})}}var Gp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Gp&&(window.__reactRouterVersion="7.13.1")}catch{}function Kp({basename:e,children:r,unstable_useTransitions:n,window:s}){let o=l.useRef();o.current==null&&(o.current=Nu({window:s,v5Compat:!0}));let a=o.current,[i,c]=l.useState({action:a.action,location:a.location}),d=l.useCallback(u=>{n===!1?c(u):l.startTransition(()=>c(u))},[n]);return l.useLayoutEffect(()=>a.listen(d),[a,d]),l.createElement(wp,{basename:e,children:r,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var Ol=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Wl=l.forwardRef(function({onClick:r,discover:n="render",prefetch:s="none",relative:o,reloadDocument:a,replace:i,unstable_mask:c,state:d,target:u,to:p,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:m,...y},x){let{basename:g,navigator:b,unstable_useTransitions:v}=l.useContext(Tt),k=typeof p=="string"&&Ol.test(p),E=Ll(p,g);p=E.to;let j=ip(p,{relative:o}),T=ir(),w=null;if(c){let C=Go(c,[],T.unstable_mask?T.unstable_mask.pathname:"/",!0);g!=="/"&&(C.pathname=C.pathname==="/"?g:Wt([g,C.pathname])),w=b.createHref(C)}let[S,N,R]=Op(s,y),I=Xp(p,{replace:i,unstable_mask:c,state:d,target:u,preventScrollReset:f,relative:o,viewTransition:h,unstable_defaultShouldRevalidate:m,unstable_useTransitions:v});function A(C){r&&r(C),C.defaultPrevented||I(C)}let $=!(E.isExternal||a),B=l.createElement("a",{...y,...R,href:($?w:void 0)||E.absoluteURL||j,onClick:$?A:r,ref:Vp(x,N),target:u,"data-discover":!k&&n==="render"?"true":void 0});return S&&!k?l.createElement(l.Fragment,null,B,l.createElement(Wp,{page:j})):B});Wl.displayName="Link";var qp=l.forwardRef(function({"aria-current":r="page",caseSensitive:n=!1,className:s="",end:o=!1,style:a,to:i,viewTransition:c,children:d,...u},p){let f=mn(i,{relative:u.relative}),h=ir(),m=l.useContext(ss),{navigator:y,basename:x}=l.useContext(Tt),g=m!=null&&rf(f)&&c===!0,b=y.encodeLocation?y.encodeLocation(f).pathname:f.pathname,v=h.pathname,k=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(v=v.toLowerCase(),k=k?k.toLowerCase():null,b=b.toLowerCase()),k&&x&&(k=Yt(k,x)||k);const E=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let j=v===b||!o&&v.startsWith(b)&&v.charAt(E)==="/",T=k!=null&&(k===b||!o&&k.startsWith(b)&&k.charAt(b.length)==="/"),w={isActive:j,isPending:T,isTransitioning:g},S=j?r:void 0,N;typeof s=="function"?N=s(w):N=[s,j?"active":null,T?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(w):a;return l.createElement(Wl,{...u,"aria-current":S,className:N,ref:p,style:R,to:i,viewTransition:c},typeof d=="function"?d(w):d)});qp.displayName="NavLink";var Yp=l.forwardRef(({discover:e="render",fetcherKey:r,navigate:n,reloadDocument:s,replace:o,state:a,method:i=Un,action:c,onSubmit:d,relative:u,preventScrollReset:p,viewTransition:f,unstable_defaultShouldRevalidate:h,...m},y)=>{let{unstable_useTransitions:x}=l.useContext(Tt),g=ef(),b=tf(c,{relative:u}),v=i.toLowerCase()==="get"?"get":"post",k=typeof c=="string"&&Ol.test(c),E=j=>{if(d&&d(j),j.defaultPrevented)return;j.preventDefault();let T=j.nativeEvent.submitter,w=(T==null?void 0:T.getAttribute("formmethod"))||i,S=()=>g(T||j.currentTarget,{fetcherKey:r,method:w,navigate:n,replace:o,state:a,relative:u,preventScrollReset:p,viewTransition:f,unstable_defaultShouldRevalidate:h});x&&n!==!1?l.startTransition(()=>S()):S()};return l.createElement("form",{ref:y,method:v,action:b,onSubmit:s?d:E,...m,"data-discover":!k&&e==="render"?"true":void 0})});Yp.displayName="Form";function Jp(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ul(e){let r=l.useContext(Mr);return tt(r,Jp(e)),r}function Xp(e,{target:r,replace:n,unstable_mask:s,state:o,preventScrollReset:a,relative:i,viewTransition:c,unstable_defaultShouldRevalidate:d,unstable_useTransitions:u}={}){let p=lp(),f=ir(),h=mn(e,{relative:i});return l.useCallback(m=>{if(Rp(m,r)){m.preventDefault();let y=n!==void 0?n:sn(f)===sn(h),x=()=>p(e,{replace:y,unstable_mask:s,state:o,preventScrollReset:a,relative:i,viewTransition:c,unstable_defaultShouldRevalidate:d});u?l.startTransition(()=>x()):x()}},[f,p,h,n,s,o,r,e,a,i,c,d,u])}var Qp=0,Zp=()=>`__${String(++Qp)}__`;function ef(){let{router:e}=Ul("useSubmit"),{basename:r}=l.useContext(Tt),n=vp(),s=e.fetch,o=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:d,encType:u,formData:p,body:f}=Lp(a,r);if(i.navigate===!1){let h=i.fetcherKey||Zp();await s(h,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,formMethod:i.method||d,formEncType:i.encType||u,flushSync:i.flushSync})}else await o(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_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 tf(e,{relative:r}={}){let{basename:n}=l.useContext(Tt),s=l.useContext(Jt);tt(s,"useFormAction must be used inside a RouteContext");let[o]=s.matches.slice(-1),a={...mn(e||".",{relative:r})},i=ir();if(e==null){a.search=i.search;let c=new URLSearchParams(a.search),d=c.getAll("index");if(d.some(p=>p==="")){c.delete("index"),d.filter(f=>f).forEach(f=>c.append("index",f));let p=c.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:Wt([n,a.pathname])),sn(a)}function rf(e,{relative:r}={}){let n=l.useContext(Pl);tt(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=Ul("useViewTransitionState"),o=mn(e,{relative:r});if(!n.isTransitioning)return!1;let a=Yt(n.currentLocation.pathname,s)||n.currentLocation.pathname,i=Yt(n.nextLocation.pathname,s)||n.nextLocation.pathname;return Xn(o.pathname,i)!=null||Xn(o.pathname,a)!=null}var Dr=Su();const nf=Cu(Dr),sf=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Rn(e){if(typeof e!="string")return null;const r=e.trim();return r===""||!sf.test(r)||r==="0.0.0"?null:r}function Hl(e){if(e.preferInstalled){const o=Rn(e.installedCurrentVersion);if(o)return{version:o,versionSource:"registry"}}const r=Rn(e.frontmatterVersion);if(r)return{version:r,versionSource:"frontmatter"};const n=Rn(e.registryCurrentVersion);if(n)return{version:n,versionSource:"registry"};const s=Rn(e.pluginVersion);return s?{version:s,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const of={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},$a={own:"authoring-project",installed:"available-project",global:"available-personal"},jo=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function af(e){if(typeof e=="string"){if(jo.has(e))return e;if(Object.prototype.hasOwnProperty.call($a,e))return $a[e]}return"authoring-project"}function lf(e){return e.startsWith("available-")?"available":"authoring"}function cf(e){const r=e.indexOf("-");return e.slice(r+1)}const bt="";function Tn(e,r){try{let n=!1;const s=of;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 qt extends Error{constructor(r,n,s){super(r),this.name="ApiError",this.status=n,this.details=s}}async function ye(e,r){const n=await fetch(`${bt}${e}`,r);if(!n.ok){const s=await n.json().catch(()=>({error:n.statusText})),o=s&&typeof s=="object"?s:void 0;throw new qt((s==null?void 0:s.error)||`HTTP ${n.status}`,n.status,o)}return n.json()}async function Ma(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 Da=100;function Fa(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 Ge(e){return typeof e=="string"&&e.length>0?e:null}function df(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Nr(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 uf(e){if(!e||typeof e!="object")return null;const r=e,n=Ge(r.python)??void 0,s=Nr(r.pip)??void 0,o=Ge(r.node)??void 0;return!n&&!s&&!o?null:{python:n,pip:s,node:o}}function pf(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:Ge(r.file)??void 0,requires:Nr(r.requires)??void 0}}function ff(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"&&jo.has(r.scopeV2)?r.scopeV2:af(r.scope),i=lf(a),c=cf(a),d=typeof r.precedenceRank=="number"?r.precedenceRank:void 0;let u;r.shadowedBy===null?u=null:typeof r.shadowedBy=="string"&&jo.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:Ge(r.symlinkTarget),installMethod:o,sourcePath:Ge(r.sourcePath),scopeV2:a,group:i,source:c,pluginName:Ge(r.pluginName),pluginNamespace:Ge(r.pluginNamespace),pluginMarketplace:Ge(r.pluginMarketplace),pluginManifestPath:Ge(r.pluginManifestPath),pluginVersion:Ge(r.pluginVersion),...typeof r.pluginDisplay=="string"&&r.pluginDisplay?{pluginDisplay:r.pluginDisplay}:{},precedenceRank:d,shadowedBy:u,description:Ge(r.description),version:Ge(r.version),category:Ge(r.category),author:Ge(r.author),license:Ge(r.license),homepage:Ge(r.homepage),repoUrl:Ge(r.repoUrl),skillPath:Ge(r.skillPath),tags:Nr(r.tags),deps:Nr(r.deps),mcpDeps:Nr(r.mcpDeps),entryPoint:Ge(r.entryPoint),lastModified:Ge(r.lastModified),sizeBytes:df(r.sizeBytes),sourceAgent:Ge(r.sourceAgent),secrets:Nr(r.secrets),runtime:uf(r.runtime),integrationTests:pf(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=Hl({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 ye("/api/config")},setConfig(e,r){return ye("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:r})})},revealInEditor(e,r,n){return ye("/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 ye(`/api/skills${n?"?"+n:""}`);return Array.isArray(s)?s.map(ff):[]},getSkillInstallState(e){return ye(`/api/studio/install-state?skill=${encodeURIComponent(e)}`)},async convertToPlugin(e){return ye("/api/authoring/convert-to-plugin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getAgents(){return ye("/api/agents")},getSkillDetail(e,r){return ye(`/api/skills/${e}/${r}`)},async getEvals(e,r){const n=await ye(`/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 ye(`/api/skills/${e}/${r}/evals`)},getActivationHistoryEnvelope(e,r){return ye(`/api/skills/${e}/${r}/activation-history`)},saveEvals(e,r,n){return ye(`/api/skills/${e}/${r}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},generateEvals(e,r){return ye(`/api/skills/${e}/${r}/generate-evals`,{method:"POST"})},async getLatestBenchmark(e,r){const n=await fetch(`${bt}/api/skills/${e}/${r}/benchmark/latest`);if(!n.ok){const s=await n.json().catch(()=>({error:n.statusText}));throw new qt(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 ye(`/api/skills/${e}/${r}/history${o?"?"+o:""}`)},getHistoryEntry(e,r,n){return ye(`/api/skills/${e}/${r}/history/${encodeURIComponent(n)}`)},compareRuns(e,r,n,s){return ye(`/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 ye(`/api/skills/${e}/${r}/history/case/${n}${a?"?"+a:""}`)},deleteHistoryEntry(e,r,n){return ye(`/api/skills/${e}/${r}/history/${encodeURIComponent(n)}`,{method:"DELETE"})},deleteSkill(e,r){return ye(`/api/skills/${e}/${r}`,{method:"DELETE"})},uninstallSkill(e,r){return ye(`/api/skills/${e}/${r}/uninstall`,{method:"POST"})},improveSkill(e,r,n){return ye(`/api/skills/${e}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},instructEdit(e,r,n){return ye(`/api/skills/${e}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...n})})},applyImprovement(e,r,n){return ye(`/api/skills/${e}/${r}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})})},getStats(e,r){return ye(`/api/skills/${e}/${r}/stats`)},getDependencies(e,r){return ye(`/api/skills/${e}/${r}/dependencies`)},getProjectLayout(){return ye("/api/project-layout")},getProjectGitHubStatus(){return ye("/api/project/github-status")},createSkill(e){return ye("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},detectEngines(){return ye("/api/studio/detect-engines")},saveDraft(e){return ye("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getSkillCreatorStatus(){return ye("/api/skill-creator-status")},generateSkill(e){return ye("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},getSkillFiles(e,r){return ye(`/api/skills/${e}/${r}/files`)},getSkillFile(e,r,n){return ye(`/api/skills/${e}/${r}/file?path=${encodeURIComponent(n)}`)},saveSkillFile(e,r,n,s){return ye(`/api/skills/${e}/${r}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:s})})},getLeaderboard(e,r){return ye(`/api/skills/${e}/${r}/leaderboard`)},getLeaderboardEntry(e,r,n){return ye(`/api/skills/${e}/${r}/leaderboard/${encodeURIComponent(n)}`)},startSweep(e,r,n){const s=`${bt}/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 ye(`/api/credentials/${e}/${r}`)},setCredential(e,r,n,s){return ye(`/api/credentials/${e}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,value:s})})},getParams(e,r){return ye(`/api/credentials/${e}/${r}/params`)},getParamsRevealed(e,r,n){const s=n?`reveal=true&key=${encodeURIComponent(n)}`:"reveal=true";return ye(`/api/credentials/${e}/${r}/params?${s}`)},searchModels(){return ye("/api/openrouter/models")},async getSkillVersions(e,r){const n=await ye(`/api/skills/${e}/${r}/versions`);return Array.isArray(n)?n:Array.isArray(n.versions)?n.versions:[]},getSkillVersionsEnvelope(e,r){return ye(`/api/skills/${e}/${r}/versions`)},getVersionDiff(e,r,n,s){return ye(`/api/skills/${e}/${r}/versions/diff?from=${n}&to=${s}`)},startBatchUpdate(e){const r=`${bt}/api/skills/batch-update`,n=new EventSource(r);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:e})}),n},startSkillUpdate(e,r){const n=`${bt}/api/skills/${e}/${r}/update`,s=new EventSource(n);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),s},async postSkillUpdate(e,r,n){let s,o;if(n&&typeof n.aborted=="boolean")s=n;else if(n&&typeof n=="object"){const p=n;s=p.signal,o=p.agentId}const a=o?`?agent=${encodeURIComponent(o)}`:"",i=`${bt}/api/skills/${e}/${r}/update${a}`,c=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},signal:s});let d,u="";if(c.body){const p=c.body.getReader(),f=new TextDecoder;let h=!1,m="";for(;!h;){const x=await p.read();if(h=x.done,x.value){const g=f.decode(x.value,{stream:!h});m+=g,u.length<200&&(u+=g)}}const y=m.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(y)try{d=JSON.parse(y[1]).version}catch{}u=u.slice(0,200)}else{const p=await c.text();u=p.slice(0,200);const f=p.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(f)try{d=JSON.parse(f[1]).version}catch{}}return{ok:c.ok,status:c.status,body:u,version:d}},async rescanSkill(e,r){const n=`${e}/${r}`,s=await fetch(`${bt}/api/v1/skills/${encodeURIComponent(n)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!s.ok)throw new Error(`rescan failed: HTTP ${s.status}`);return await s.json()},async getSkillUpdates(){try{const e=await fetch(`${bt}/api/skills/updates`);return e.ok?await e.json():[]}catch{return[]}},async checkSkillUpdates(e){if(e.length===0)return[];const r=[...e].sort(),n=Fa(r,Da),s=async a=>{try{const i=await Ma(`${bt}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(d=>({name:d,currentVersion:"0.0.0"}))})});if(!i.ok)return[];const c=await i.json().catch(()=>null);return Array.isArray(c)?c:c&&typeof c=="object"&&Array.isArray(c.results)?c.results.map(d=>({skillId:typeof d.skillId=="string"?d.skillId:typeof d.name=="string"?d.name:"",version:typeof d.version=="string"?d.version:typeof d.latest=="string"?d.latest:"",eventId:typeof d.eventId=="string"?d.eventId:"",publishedAt:typeof d.publishedAt=="string"?d.publishedAt:"",diffSummary:typeof d.diffSummary=="string"?d.diffSummary:void 0,trackedForUpdates:typeof d.trackedForUpdates=="boolean"?d.trackedForUpdates:void 0,updateAvailable:typeof d.updateAvailable=="boolean"?d.updateAvailable:void 0,installed:typeof d.installed=="string"&&d.installed!=="0.0.0"?d.installed:void 0,latest:typeof d.latest=="string"?d.latest:void 0,name:typeof d.name=="string"?d.name:void 0})):[]}catch{return[]}};return(await Promise.all(n.map(s))).flat()},async resolveInstalledSkillIds(e){if(e.length===0)return[];const r=Fa(e,Da),n=async a=>{try{const i=await Ma(`${bt}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!i.ok)return{ok:!1,map:new Map};const c=await i.json().catch(()=>null),d=Array.isArray(c)?c:Array.isArray(c==null?void 0:c.results)?c.results:[];return{ok:!0,map:new Map(d.filter(u=>typeof u.name=="string"&&u.name.length>0).map(u=>[u.name,u]))}}catch{return{ok:!1,map:new Map}}},s=await Promise.all(r.map(n));if(s.length>0&&s.every(a=>!a.ok))throw new Error("resolveInstalledSkillIds: all chunks failed");const o=new Map;for(const a of s)for(const[i,c]of a.map)o.set(i,c);return e.map(a=>{const i=o.get(a.name);return{plugin:a.plugin,skill:a.skill,uuid:typeof(i==null?void 0:i.id)=="string"&&i.id.length>0?i.id:void 0,slug:typeof(i==null?void 0:i.slug)=="string"&&i.slug.length>0?i.slug:void 0}})},async lookupSkillsByName(e){if(!Array.isArray(e)||e.length===0)return[];const r=e.slice(0,50);try{const n=await fetch(`${bt}/api/v1/skills/lookup-by-name`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entries:r})});if(!n.ok)return Tn("lookup-by-name-error",{status:n.status}),[];const s=await n.json().catch(a=>(Tn("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&&Tn("lookup-by-name-no-results-array",{}),[])}catch(n){return Tn("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 Ss(`/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 Ss(`/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 Ss(`/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 ye(`/api/studio/ops${n?"?"+n:""}`)},deleteStudioOp(e){return ye(`/api/studio/ops/${encodeURIComponent(e)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${bt}/api/studio/ops/stream`)},gitRemote(){return ye("/api/git/remote")},gitDiff(){return ye("/api/git/diff",{method:"POST"})},gitStatus(){return ye("/api/git/status")},gitCommitMessage(e){return ye("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})},gitPublish(e){return ye("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})},async submitToQueue(e){const r=await ye("/api/v1/submissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});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 ye("/api/v1/submissions?mine=1")},getSubmission(e){return ye(`/api/v1/submissions/${encodeURIComponent(e)}`)},getPositions(e){const r=e&&e.length>0?`?ids=${encodeURIComponent(e.join(","))}`:"";return ye(`/api/v1/submissions/positions${r}`)},async getAccountTenants(){return ye("/api/v1/account/tenants")},async getActiveTenant(){return ye("/__internal/active-tenant")},async setActiveTenant(e){return ye("/__internal/active-tenant",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentTenant:e})})}};async function Ss(e,r,n){const s=await fetch(`${bt}${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 qt(p,s.status);throw f&&(h.code=f),h}const o=s.body.getReader(),a=new TextDecoder;let i="",c="",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: "))c=m.slice(7).trim();else if(m.startsWith("data: ")){let y={};try{y=JSON.parse(m.slice(6))}catch{c="";continue}if(c==="started"||c==="copied"||c==="deleted"||c==="indexed"||c==="done"||c==="error"){const x={type:c,...y};r==null||r(x),x.type==="done"&&(d=x),x.type==="error"&&(u=x)}c=""}}if(u){const p=new qt(u.message,500);throw p.code=u.code,p}if(!d)throw new qt("Transfer stream ended without 'done' event",500);return d}function hf(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,c]=s.map(Number),[,d,u,p]=o.map(Number);return a!==d?a>d:i!==u?i>u:c>=p}function mf(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 c=a[a.length-1];n.set(`${c}/${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&&!hf(o.version,a.latest),c=a.installed&&a.installed!=="0.0.0"?a.installed:null,d={...o,updateAvailable:i,currentVersion:c??o.currentVersion,latestVersion:a.latest??void 0};typeof a.trackedForUpdates=="boolean"&&(d.trackedForUpdates=a.trackedForUpdates);const u=Hl({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 Vn=new Map,pr=new Map,Yr=new Map;function Be(e){Vn.delete(e),pr.delete(e);const r=Yr.get(e);if(r)for(const n of r)n()}function St(e,r,n={}){const{ttl:s=3e4,enabled:o=!0}=n,[,a]=l.useState(0),[i,c]=l.useState(void 0),[d,u]=l.useState(0),p=l.useRef(!0),f=l.useRef(e);f.current=e;const h=()=>{c(void 0),Be(e),u(x=>x+1)};l.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),l.useEffect(()=>{if(!o)return;const x=()=>{p.current&&u(g=>g+1)};return Yr.has(e)||Yr.set(e,new Set),Yr.get(e).add(x),()=>{var g;(g=Yr.get(e))==null||g.delete(x)}},[e,o]),l.useEffect(()=>{if(!o)return;const x=Vn.get(e);if(!(!x||Date.now()-x.fetchedAt>s))return;if(pr.has(e)){const k=pr.get(e),E=()=>{p.current&&f.current===e&&a(j=>j+1)};k.subscribers.push(E);return}const b={promise:Promise.resolve(),subscribers:[]},v=r().then(k=>{Vn.set(e,{data:k,fetchedAt:Date.now()}),pr.delete(e),p.current&&f.current===e&&(c(void 0),a(E=>E+1));for(const E of b.subscribers)E()},k=>{pr.delete(e);const E=k instanceof Error?k:new Error(String(k));p.current&&f.current===e&&(c(E),a(j=>j+1));for(const j of b.subscribers)j()});b.promise=v,pr.set(e,b)},[e,r,s,o,d]);const m=Vn.get(e),y=o&&!m&&!i&&pr.has(e);return{data:m==null?void 0:m.data,loading:y,error:i,revalidate:h}}function xf(e){const[r,n]=l.useState(()=>typeof window>"u"?!1:window.matchMedia(e).matches);return l.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}const gf=500,wo="vskill.updates.seenLastId";function yf(){if(typeof window>"u")return null;try{return window.localStorage.getItem(wo)}catch{return null}}function Cs(e){if(!(typeof window>"u"))try{e==null?window.localStorage.removeItem(wo):window.localStorage.setItem(wo,e)}catch{}}function vf(){let e=new Map;const r=new Set,n=new Set,s=[];let o=yf();o&&(n.add(o),s.push(o));function a(){e=new Map(e);for(const c of Array.from(r))c()}function i(c){if(!n.has(c)){if(n.add(c),s.push(c),s.length>gf){const d=s.shift();d&&n.delete(d)}o=c,Cs(c)}}return{getSnapshot(){return e},subscribe(c){return r.add(c),()=>{r.delete(c)}},ingest(c){return n.has(c.eventId)?"duplicate":(i(c.eventId),e.set(c.skillId,{skillId:c.skillId,version:c.version,diffSummary:c.diffSummary,eventId:c.eventId,publishedAt:c.publishedAt,receivedAt:Date.now()}),a(),"stored")},dismiss(c){e.has(c)&&(e.delete(c),a())},clearSeen(){n.clear(),s.length=0,o=null,Cs(null)},mergeBulk(c){if(c.length!==0){for(const d of c)e.set(d.skillId,d);a()}},getSeenLastId(){return o},reset(){e=new Map,n.clear(),s.length=0,o=null,Cs(null),a()}}}const tr=vf(),Vl="vskill:toast-queue",bf=10,kf=1800*1e3;function is(){return typeof window<"u"&&typeof window.localStorage<"u"}function Gl(){if(!is())return[];try{const e=window.localStorage.getItem(Vl);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 Kl(e){if(is())try{window.localStorage.setItem(Vl,JSON.stringify(e))}catch{}}function jf(e){if(!is())return"enqueued";const r=Gl();if(r.some(o=>o.eventId===e.eventId))return"deduped";let n=!1;const s=[...r,e];for(;s.length>bf;)s.shift(),n=!0;return Kl(s),n?"evicted":"enqueued"}function wf(){if(!is())return[];const e=Gl();if(e.length===0)return[];Kl([]);const r=Date.now()-kf;return e.filter(n=>n.enqueuedAt>=r)}const Sf="X-Studio-Token";let hr=null,Wr=null,za=!1,In=null;function Cf(){var e;return typeof window>"u"?!1:!!((e=window.__TAURI_INTERNALS__)!=null&&e.invoke)}function Qo(){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 Ef(){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 Nf(){if(hr)return hr;const e=Qo();return e?(hr=e,e):Wr||(Wr=Ef().then(r=>(r&&(hr=r),Wr=null,r)),Wr)}function Rf(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 Tf(){za||typeof globalThis.fetch!="function"||!(Qo()!==null)&&!Cf()||(za=!0,In=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,!Rf(s))return In(r,n);const o=await Nf();if(!o)return In(r,n);const a={...n??{}},i=new Headers(a.headers??{});return i.set(Sf,o),a.headers=i,In(r,a)})}function If(){if(hr)return hr;const e=Qo();return e?(hr=e,e):null}const ls=new Set(["PUBLISHED","AUTO_APPROVED","VENDOR_APPROVED"]),Zo=new Set(["REJECTED","TIER1_FAILED","BLOCKED"]),So=new Set;function ql(e,r){return`${e}::${r}`}function Yl(e,r){const n=ql(e,r);return So.has(n)?!1:(So.add(n),!0)}function Lf(e,r){So.add(ql(e,r))}function Af(e){return`https://verified-skill.com/submit/${encodeURIComponent(e)}`}function Pf(e,r,n){const s=r||"Your skill";return ls.has(n)?{outcome:"approved",title:"Skill approved",body:`${s} is now published on verified-skill.com`}:Zo.has(n)?{outcome:"rejected",title:"Skill rejected",body:`${s} ${n==="BLOCKED"?"was blocked":"was rejected"}. Tap to see why.`,clickUrl:Af(e)}:null}function $f(){return typeof window<"u"&&"__TAURI_INTERNALS__"in window}async function Mf(){try{return await ar(()=>import("./index-DhhmQddr.js"),__vite__mapDeps([0,1]))}catch{return null}}async function Df(e){try{let r=await e.isPermissionGranted();return r||(r=await e.requestPermission()==="granted"),r}catch{return!1}}async function Jl(e,r,n){const s=Pf(e,r,n);if(!s||!$f())return!1;const o=await Mf();if(!o||!await Df(o))return!1;if(s.outcome==="rejected"&&s.clickUrl&&typeof o.onAction=="function")try{const i=s.clickUrl;let c=null;c=await o.onAction(()=>{Jn(i);try{c==null||c()}catch{}})}catch{}try{return o.sendNotification({title:s.title,body:s.body}),!0}catch{return!1}}function Ba(e){return typeof e=="string"&&e.length>0}function Ff(e){if(typeof e!="string")return null;const r=e.trim();return r.length>0?`usr_${r}`:null}function zf(e){const r=[];for(const n of e){const s=Ba(n.uuid),o=Ba(n.slug);if(!s&&!o)continue;const a={};s&&(a.uuid=n.uuid),o&&(a.slug=n.slug),r.push(a)}return r}const Bf=3e5,_f=500,Of=15e3,Wf=6e4,Uf=6e4,Hf="/api/v1/skills/stream",Vf=250,Gf=500,Kf="/api/v1/studio/telemetry/sse",_a="vskill.studio.sse.sessionId";function Xl(){var e;try{const r=(e=import.meta)==null?void 0:e.env;if(r&&typeof r=="object")return r}catch{}return{}}function qf(){if(typeof window>"u")return!1;const e=Xl();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 Yf(){if(typeof window>"u")return!0;const e=Xl();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 gt(e,r){if(qf())try{const n=new Date().toISOString();r?console.debug(`[sse] ${n} ${e}`,r):console.debug(`[sse] ${n} ${e}`)}catch{}}function Oa(){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 Jf(){if(typeof window>"u")return"";try{const e=window.sessionStorage.getItem(_a);if(e)return e;const r=Oa();return window.sessionStorage.setItem(_a,r),r}catch{return Oa()}}function Wa(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 Ua(e){let r=0;for(const n of e)n.updateAvailable&&r++;return r}function Xf(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 Qf(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 Zf(e){const r=(e==null?void 0:e.intervalMs)??Bf,n=(e==null?void 0:e.debounceMs)??_f,s=(e==null?void 0:e.timeoutMs)??Of,o=(e==null?void 0:e.staleAfterMs)??Wf,a=(e==null?void 0:e.disconnectFallbackMs)??Uf,i=(e==null?void 0:e.streamUrlBase)??Hf,c=(e==null?void 0:e.replayIntervalMs)??Vf,d=Ff(e==null?void 0:e.userId),u=l.useMemo(()=>{const U=(e==null?void 0:e.skillIds)??[];if(U.length===0&&!d)return"";const K=d?1:0,V=[...new Set(U)].filter(J=>J!==d).sort().slice(0,Gf-K),Y=d?[...V,d]:V;return Y.length===0?"":Y.sort().join(",")},[e==null?void 0:e.skillIds,d]),p=l.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]=l.useState([]),[m,y]=l.useState(()=>new Map),[x,g]=l.useState(0),[b,v]=l.useState(!1),[k,E]=l.useState(null),[j,T]=l.useState(null),w=l.useRef(null),S=l.useRef(null),N=l.useRef(null),R=l.useRef(null),I=l.useRef(!0),A=l.useRef(new Set),[$,B]=l.useState(()=>u?"connecting":"fallback"),C=l.useRef($);C.current=$;const L=l.useRef(new Set),P=l.useRef(null),M=l.useSyncExternalStore(U=>tr.subscribe(U),()=>tr.getSnapshot(),()=>tr.getSnapshot()),H=M.size,le=l.useCallback(U=>{if(Yf()||L.current.has(U))return;L.current.add(U);const K=Jf(),V=Date.now(),Y={event:U,sessionId:K,sourceTier:"platform-proxy",timestamp:V};U!=="connected"&&P.current!=null&&(Y.durationSinceOpenMs=V-P.current);try{fetch(Kf,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Y),keepalive:!0}).catch(()=>{})}catch{}},[]),G=l.useCallback(async()=>{v(!0);const U=new AbortController,K=setTimeout(()=>U.abort(),s);try{const V=await Promise.race([ce.getSkillUpdates(),new Promise((Y,J)=>{U.signal.addEventListener("abort",()=>{J(new Error("TIMEOUT"))})})]);if(V==="TIMEOUT")throw new Error("TIMEOUT");if(!I.current)return;h(V),y(Wa(V)),g(Ua(V)),S.current=Date.now(),E(S.current),T(null)}catch(V){if(!I.current)return;T(V instanceof Error?V:new Error(String(V)))}finally{clearTimeout(K),I.current&&v(!1)}},[s]),W=l.useCallback(()=>{if(w.current)return w.current;const U=G().finally(()=>{w.current=null});return w.current=U,U},[G]),Z=l.useCallback(()=>{N.current==null&&(N.current=setInterval(()=>{W()},r))},[r,W]),he=l.useCallback(()=>{N.current!=null&&(clearInterval(N.current),N.current=null)},[]),me=l.useCallback(()=>{if(typeof window>"u")return;const U=wf();U.length!==0&&(gt("queue-drain",{count:U.length}),U.forEach((K,V)=>{let Y;Y=setTimeout(()=>{if(A.current.delete(Y),!I.current)return;const te=tr.getSnapshot().get(K.skillId);if(te&&te.eventId!==K.eventId){gt("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}})),gt("queue-replay",{eventId:K.eventId})}catch{}},V*c),A.current.add(Y)}))},[c]),_=l.useCallback(()=>{for(const U of A.current)clearTimeout(U);A.current.clear()},[]);l.useEffect(()=>{I.current=!0,(S.current==null||Date.now()-S.current>o)&&W(),(typeof document>"u"||document.visibilityState!=="hidden")&&Z();const V=()=>{if(R.current&&(clearTimeout(R.current),R.current=null),document.visibilityState==="hidden"){he();return}me(),R.current=setTimeout(()=>{R.current=null,(S.current==null||Date.now()-S.current>o)&&W(),Z()},n)};return typeof document<"u"&&document.addEventListener("visibilitychange",V),()=>{I.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",V),R.current&&clearTimeout(R.current),_(),he()}},[]);const ne=l.useCallback(async U=>{if(U.length!==0)try{const K=await ce.checkSkillUpdates(U);if(!I.current||K.length===0)return;const V=Date.now(),Y=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:V}));Y.length>0&&tr.mergeBulk(Y);const J=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}));J.length>0&&h(te=>{const de=new Map;for(const F of te)de.set(F.name,F);let se=0;for(const F of J){const q=F.name,re=de.get(q);if(re){const Q={...re};re.trackedForUpdates===void 0&&F.trackedForUpdates!==void 0&&(Q.trackedForUpdates=F.trackedForUpdates),de.set(q,Q)}else de.set(q,{name:F.name,installed:F.installed??"",latest:F.latest??null,updateAvailable:F.updateAvailable??!1,trackedForUpdates:F.trackedForUpdates}),se+=1}if(se===0&&de.size===te.length)return te;const ue=[...de.values()];return y(Wa(ue)),g(Ua(ue)),ue})}catch{}},[]);l.useEffect(()=>{const U=u||p;if(!U){B("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){B("fallback");return}B("connecting");const K=U.split(",");let V=`${i}?skills=${encodeURIComponent(U)}`;const Y=If();Y&&(V+=`&studioToken=${encodeURIComponent(Y)}`);let J=null,te=null,de=null;const se=()=>{te==null&&(te=setTimeout(()=>{te=null,I.current&&C.current!=="connected"&&(B("fallback"),gt("fallback-flipped",{reason:"watchdog-timeout"}),le("fallback"))},a),gt("fallback-armed",{fallbackMs:a}))},ue=()=>{te!=null&&(clearTimeout(te),te=null)};se();const F=1e3,q=()=>{I.current&&de==null&&(de=setTimeout(()=>{if(de=null,!!I.current&&!(J&&J.readyState!==EventSource.CLOSED)){if(J)try{J.close()}catch{}gt("reconnect-scheduled",{backoffMs:F}),le("reconnect-scheduled"),xe()}},F))},re=we=>{if(!I.current)return;let ge;try{ge=JSON.parse(we.data)}catch{return}if(!Xf(ge))return;const Ve=tr.ingest(ge);if(gt("message",{eventId:ge.eventId,skillId:ge.skillId,outcome:Ve}),Ve==="duplicate")return;const Ye=typeof document>"u"||document.visibilityState!=="hidden",Pe=`${ge.skillId} updated to ${ge.version}`;if(Ye)try{window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Pe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId}}))}catch{}else{const rt={message:Pe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId,enqueuedAt:Date.now()},Je=jf(rt);gt("queue-enqueue",{eventId:ge.eventId,outcome:Je})}},Q=()=>{I.current&&(gt("gone",{skillsCount:K.length}),le("gone-frame-received"),tr.clearSeen(),ne(K))},pe=we=>{if(!I.current)return;let ge;try{ge=JSON.parse(we.data)}catch{return}if(Qf(ge)){if(!Yl(ge.submissionId,ge.state)){gt("submission-decision-duplicate",{submissionId:ge.submissionId,state:ge.state});return}gt("submission-decision",{submissionId:ge.submissionId,state:ge.state}),Jl(ge.submissionId,ge.skillName??"",ge.state),ls.has(ge.state)&&W()}},xe=()=>{I.current&&(J=new EventSource(V),gt("open-attempt",{url:V}),J.onopen=()=>{I.current&&(ue(),B("connected"),P.current=Date.now(),gt("open",{url:V}),le("connected"))},J.onerror=()=>{I.current&&(gt("error",{readyState:J==null?void 0:J.readyState}),se(),J&&J.readyState===EventSource.CLOSED&&q())},J.onmessage=re,J.addEventListener("gone",Q),J.addEventListener("submission_decision",pe))};return xe(),()=>{if(ue(),de!=null&&(clearTimeout(de),de=null),J){try{J.removeEventListener("gone",Q)}catch{}try{J.removeEventListener("submission_decision",pe)}catch{}try{J.close()}catch{}}_()}},[u,p,i,a,ne,le,_]),l.useEffect(()=>{if(!p)return;const U=p.split(",");ne(U)},[p,ne]);const D=l.useCallback(U=>{tr.dismiss(U)},[]);return{updates:f,updatesMap:m,updateCount:x,isRefreshing:b,lastFetchAt:k,error:j,refresh:W,updatesById:M,pushUpdateCount:H,status:$,dismiss:D}}async function eh(){return Ql("account_get_platform_url"),{platformBaseUrl:"",authMode:"cookie",getAuthHeader:async()=>null}}async function th(){const e=await Ql("account_get_user_summary");return e&&typeof e=="object"?e:{signedIn:!1,login:null,avatarUrl:null,tier:"free"}}async function Ql(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 Zl(){var e;return typeof window>"u"?!1:!!((e=window.__TAURI_INTERNALS__)!=null&&e.invoke)}const rh={signedIn:!1,login:null,avatarUrl:null,tier:"free"};function ec(){const[e,r]=l.useState(rh);return l.useEffect(()=>{let n=!1;const s=()=>{th().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 nh={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function sh(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 tc=l.createContext(null),rc=tc;function It(){const e=l.useContext(rc);if(!e)throw new Error("useStudio must be used within StudioProvider");return e}function oh({children:e}){const[r,n]=l.useReducer(sh,nh),s=xf("(max-width: 767px)");l.useEffect(()=>{n({type:"SET_MOBILE",isMobile:s})},[s]);const[o,a]=l.useState(()=>{try{const _=window.localStorage.getItem("vskill.studio.prefs");if(!_)return null;const ne=JSON.parse(_);return typeof ne.activeAgent=="string"?ne.activeAgent:null}catch{return null}}),[i,c]=l.useState(o!==null);l.useEffect(()=>{function _(ne){if(!(ne instanceof CustomEvent))return;const D=ne.detail;D!=null&&D.agentId&&(a(D.agentId),c(!0))}return window.addEventListener("studio:agent-changed",_),()=>window.removeEventListener("studio:agent-changed",_)},[]),l.useEffect(()=>{if(i)return;let _=!1;return ce.getAgents().then(ne=>{if(_)return;const D=(ne==null?void 0:ne.suggested)??"claude-code";a(U=>U??D),c(!0)}).catch(()=>{_||(a(ne=>ne??"claude-code"),c(!0))}),()=>{_=!0}},[i]);const d=l.useCallback(()=>{if(!i||!o)return Promise.resolve();n({type:"SET_SKILLS_LOADING",loading:!0});const _={agent:o};return ce.getSkills(_).then(ne=>{n({type:"SET_SKILLS",skills:ne});const D=window.location.hash,U=D.match(/^#\/skills\/(project|personal|plugin)\/([^/]+)\/([^/?]+)/);if(U){const[,V,Y,J]=U,te=V,de=ne.find(ue=>ue.plugin===Y&&ue.skill===J&&ue.source===te);if(de){n({type:"SELECT_SKILL",skill:{plugin:Y,skill:J,origin:de.origin,source:de.source}});return}const se=ne.find(ue=>ue.plugin===Y&&ue.skill===J);se&&n({type:"SELECT_SKILL",skill:{plugin:Y,skill:J,origin:se.origin,source:se.source}});return}const K=D.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(K){const[,V,Y]=K,J=ne.find(te=>te.plugin===V&&te.skill===Y);J&&n({type:"SELECT_SKILL",skill:{plugin:V,skill:Y,origin:J.origin,source:J.source}})}}).catch(ne=>n({type:"SET_SKILLS_ERROR",error:ne.message}))},[o,i]);l.useEffect(()=>{d()},[d]),l.useEffect(()=>{function _(){d()}return window.addEventListener("studio:project-changed",_),()=>window.removeEventListener("studio:project-changed",_)},[d]);const u=l.useCallback(_=>{n({type:"SELECT_SKILL",skill:_}),window.location.hash=_.source?`/skills/${_.source}/${_.plugin}/${_.skill}`:`/skills/${_.plugin}/${_.skill}`},[]),p=l.useRef(r.skills);l.useEffect(()=>{p.current=r.skills},[r.skills]);const f=l.useCallback((_,ne)=>{const D=p.current,U=_?D.find(J=>J.plugin===_&&J.skill===ne):D.find(J=>J.skill===ne&&J.source!=="plugin");if(!_&&!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)??_,V=(U==null?void 0:U.origin)??"source",Y=U==null?void 0:U.source;n({type:"REVEAL_SKILL",skill:{plugin:K,skill:ne,origin:V,source:Y}}),window.location.hash=Y?`/skills/${Y}/${K}/${ne}`:`/skills/${K}/${ne}`},[]),h=l.useCallback(()=>{n({type:"CLEAR_REVEAL"})},[]),m=l.useCallback(()=>{n({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),y=l.useCallback(_=>{n({type:"SET_MODE",mode:_})},[]),x=l.useCallback(_=>{n({type:"SET_SEARCH",query:_})},[]),g=l.useCallback(_=>{n({type:"SET_MOBILE_VIEW",view:_})},[]),b=l.useCallback(()=>{n({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),v=l.useRef(new Map),k=l.useRef(""),E=l.useRef(!1),[j,T]=l.useState(""),w=l.useRef(""),S=l.useRef(""),[N,R]=l.useState(""),I=l.useMemo(()=>r.skills.filter(_=>!_.sourcePrivate).map(_=>`${_.plugin}/${_.skill}`),[r.skills]),A=l.useMemo(()=>{const _=j?j.split(",").filter(Boolean):[],ne=N?N.split(",").filter(Boolean):[];return _.length===0&&ne.length===0?[]:[...new Set([..._,...ne])]},[j,N]),$=ec(),B=$.signedIn?$.userId:void 0,C=Zf({skillIds:A,trackingSkillIds:I,userId:B}),L=l.useMemo(()=>A.length,[A]),P=l.useRef("");l.useEffect(()=>{const _=r.skills.filter(V=>V.origin==="installed"&&!V.sourcePrivate);if(_.length===0){T(""),P.current="";return}const ne=new Map;for(const V of C.updates)ne.set(V.name.split("/").pop()||V.name,V);const D=_.map(V=>{const Y=ne.get(V.skill),J=V.currentVersion??(Y==null?void 0:Y.installed)??V.version??V.pluginVersion??"1.0.0";return{plugin:V.plugin,skill:V.skill,name:(Y==null?void 0:Y.name)??V.skill,currentVersion:J}}),U=D.map(V=>`${V.plugin}/${V.skill}@${V.currentVersion}#${V.name}`).sort().join("|");if(U===P.current)return;P.current=U;let K=!1;return ce.resolveInstalledSkillIds(D).then(V=>{if(K)return;const te=[...zf(V).flatMap(de=>[de.uuid,de.slug].filter(Boolean))].sort().join(",");te!==k.current&&(k.current=te,v.current=new Map(V.map(de=>[`${de.plugin}/${de.skill}`,{uuid:de.uuid,slug:de.slug}])),T(te))}).catch(V=>{if(K||(P.current=""),!E.current){E.current=!0;const Y=V instanceof Error?V.message:String(V);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",Y)}}),()=>{K=!0}},[r.skills,C.updates]),l.useEffect(()=>{const _=r.skills.filter(K=>K.origin==="source"&&!K.sourcePrivate&&typeof K.author=="string"&&K.author.length>0);if(_.length===0){w.current!==""&&(w.current="",R("")),S.current="";return}const ne=_.map(K=>({name:K.skill,author:K.author})),D=ne.map(K=>`${K.name.toLowerCase()}|${K.author}`).sort().join(`
15
15
  `);if(D===S.current)return;S.current=D;let U=!1;return ce.lookupSkillsByName(ne).then(K=>{if(U)return;const V=K.flatMap(J=>[J.uuid,J.slug]).filter(J=>typeof J=="string"&&J.length>0),Y=[...new Set(V)].sort().join(",");Y!==w.current&&(w.current=Y,R(Y))}).catch(()=>{U||(S.current="")}),()=>{U=!0}},[r.skills]);const M=l.useMemo(()=>{const _=r.skills.map(ne=>{if(!ne.updateAvailable&&ne.latestVersion===void 0&&ne.trackedForUpdates===void 0)return ne;const D={...ne};return delete D.updateAvailable,delete D.currentVersion,delete D.latestVersion,delete D.trackedForUpdates,D});return mf(_,C.updates)},[r.skills,C.updates]),H=l.useMemo(()=>{const _={source:0,installed:0};for(const ne of M)ne.updateAvailable&&(_[ne.origin]+=1);return _},[M]),le=l.useMemo(()=>({...r,skills:M}),[r,M]),G=C.updateCount,W=C.refresh,Z=C.isRefreshing,he=l.useCallback((_,ne)=>{W(),d(),Be(`versions/${_}/${ne}`),C.dismiss(`${_}/${ne}`)},[W,d,C]),me=l.useMemo(()=>({state:le,selectSkill:u,clearSelection:m,setMode:y,setSearch:x,setMobileView:g,refreshSkills:d,updateCount:G,dismissUpdateNotification:b,updates:C.updates,outdatedByOrigin:H,isRefreshingUpdates:Z,refreshUpdates:W,revealSkill:f,clearReveal:h,updatesById:C.updatesById,pushUpdateCount:C.pushUpdateCount,updateStreamStatus:C.status,dismissPushUpdate:C.dismiss,activeAgent:o,onSkillUpdated:he,trackedSkillCount:L}),[le,u,m,y,x,g,d,G,b,C.updates,H,Z,W,f,h,C.updatesById,C.pushUpdateCount,C.status,C.dismiss,o,he,L]);return t.jsx(rc.Provider,{value:me,children:e})}const ah={config:null,loading:!0};function ih(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 nc=l.createContext(null);function gr(){const e=l.useContext(nc);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e}function lh({children:e}){const[r,n]=l.useReducer(ih,ah),s=l.useCallback(()=>{ce.getConfig().then(i=>n({type:"SET_CONFIG",config:i})).catch(()=>{})},[]);l.useEffect(()=>{s()},[s]);const o=l.useCallback(async(i,c)=>{const d=await ce.setConfig(i,c);return n({type:"SET_CONFIG",config:d}),d},[]),a=l.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:o,refreshConfig:s}),[r,o,s]);return t.jsx(nc.Provider,{value:a,children:e})}function ch({topRail:e,sidebar:r,main:n,statusBar:s,resizeHandle:o,banner:a,liveMessage:i,sidebarWidth:c=320,sidebarHidden:d=!1}){const u={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${c}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 dh={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}`},uh={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"},ph={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"},fh={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"},hh={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"},mh={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"},xh={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."},gh={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},yh={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},vh={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},bh={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"},kh={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)."}},jh={subscriptionBilling:"· subscription",free:"· free"},wh={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`},Sh={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.`},Ch={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}`},Eh={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.`},Nh={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"},Rh={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."},Th={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},Ih={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"}},O={sidebar:dh,shell:uh,detail:ph,actions:fh,palette:hh,shortcuts:mh,toasts:xh,connection:gh,forms:yh,errors:vh,picker:bh,providers:kh,models:jh,settings:wh,statusBar:Sh,scopePicker:Ch,scopeSection:Eh,claudeCodeLabel:Nh,setupDrawer:Rh,setupProviders:Ih,scopeLabels:Th},Ha=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],Lh={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},Ah={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},Ph={"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"},$h={"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 Mh(e,r){var c,d;const n=Lh[e.id]??null,s=Ah[e.id]??null,o=n?!!((c=r==null?void 0:r.wrapperFolders)!=null&&c[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:$h[e.id]??"per-token",...u.pricing?{pricing:u.pricing}:{},...u.resolvedId?{resolvedId:u.resolvedId}:{}}));return{id:e.id,displayName:Dh(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:Ph[e.id]??null,models:i,resolvedModel:e.resolvedModel??null}}function Dh(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 Fh(e){const r=new Map(e.map(s=>[s.id,s])),n=[];for(const s of Ha){const o=r.get(s);o&&n.push(o)}for(const s of e)Ha.includes(s.id)||n.push(s);return n}function sc(e){const[r,n]=l.useState(null),[s,o]=l.useState("loading"),[a,i]=l.useState(null),[c,d]=l.useState(null),u=l.useRef(null),p=l.useRef(0),f=l.useRef(e==null?void 0:e.onStaleCatalog),h=l.useRef(e==null?void 0:e.onSetActiveError);l.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=l.useCallback(async()=>{try{const v=await fetch("/api/config");if(!v.ok)throw new Error(`/api/config returned ${v.status}`);const k=await v.json(),E=Fh((k.providers||[]).map(j=>Mh(j,k.detection)));n({agents:E,activeAgent:k.provider??null,activeModel:k.model??null}),o("ready"),i(null)}catch(v){o("error"),i(v.message)}},[]);l.useEffect(()=>{m()},[m]);const y=l.useCallback(async()=>{var k;const v=Date.now();if(!(v-p.current<5*6e4))try{const E=await fetch("/api/openrouter/models");if(!E.ok){E.status!==400&&d(`OpenRouter catalog fetch failed (${E.status})`);return}const j=await E.json();p.current=v,d(null),n(S=>{if(!S)return S;const N=S.agents.map(R=>{if(R.id!=="openrouter")return R;const A=(Array.isArray(j.models)?j.models:[]).filter(B=>B.id||B.name).map(B=>{const C=B.id||B.name;return{id:C,displayName:B.name??C,contextWindow:B.contextWindow,pricing:B.pricing,billingMode:"per-token"}});return{...R,models:A,catalogAgeMs:j.ageSec?j.ageSec*1e3:0,cacheStale:!!j.stale}});return{...S,agents:N}});const T=j.ageSec??0;(j.stale===!0||T>600)&&((k=f.current)==null||k.call(f,"openrouter",T*1e3))}catch(E){d(`OpenRouter catalog unreachable: ${E.message}`)}},[]),x=l.useCallback(v=>{u.current=v,v==="openrouter"&&y()},[y]),g=l.useCallback(()=>{p.current=0,m()},[m]),b=l.useCallback(async(v,k)=>{var T,w;let E;try{E=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:v,model:k})})}catch(S){(T=h.current)==null||T.call(h,`Network error while setting ${v}: ${S.message}`);return}if(E.ok){n(S=>S&&{...S,activeAgent:v,activeModel:k});return}let j=`Failed to set ${v} (${E.status})`;try{const S=await E.json();S&&typeof S.error=="string"&&(j=S.error)}catch{}(w=h.current)==null||w.call(h,j)},[]);return{status:s,catalog:r,error:a,openRouterError:c,focusAgent:x,refresh:g,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:b}}function Es({variant:e,label:r,onActivate:n,installUrl:s,tooltip:o}){function a(c){if(c.stopPropagation(),e==="cli-install"&&s){window.open(s,"_blank","noopener,noreferrer");return}n()}function i(c){(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),a(c))}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 Co({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 zh=new Set(["claude-cli","claude-code"]);function Va(e){return zh.has(e)}const Ga=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function Bh({agents:e,activeAgentId:r,focusedAgentId:n,onFocus:s,onSelect:o,onOpenSettings:a}){const i=e.filter(d=>Ga.has(d.id)),c=e.filter(d=>!Ga.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(Ka,{agent:d,isActive:d.id===r,isFocused:d.id===n,onFocus:s,onSelect:o,onOpenSettings:a},d.id)),c.length>0&&t.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),c.map(d=>t.jsx(Ka,{agent:d,isActive:d.id===r,isFocused:d.id===n,onFocus:s,onSelect:o,onOpenSettings:a},d.id))]})}function Ka({agent:e,isActive:r,isFocused:n,onFocus:s,onSelect:o,onOpenSettings:a}){const{providers:i}=O,c={"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=Va(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}),Va(e.id)&&t.jsx("span",{"data-testid":"claude-code-billing-label",title:O.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:O.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(Co,{unlocked:!0,size:10}):t.jsx(Co,{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:O.picker.currentlyActive}),!e.available&&e.ctaType==="api-key"&&t.jsx(Es,{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(Es,{variant:"cli-install",label:d[e.id].label,installUrl:d[e.id].url,onActivate:()=>{}}),!e.available&&e.ctaType==="start-service"&&t.jsx(Es,{variant:"start-service",label:e.id==="ollama"?i.ollama.startServiceCta:i.lmStudio.startServiceCta,onActivate:()=>a(e.id)}),c[e.id]&&t.jsx("span",{className:"sr-only","data-testid":`caption-${e.id}`,children:c[e.id]})]})}function _h(e,r,n,s){const i=e>=80,c=l.useRef(null),[d,u]=l.useState(0),p=l.useCallback(m=>{u(m.currentTarget.scrollTop)},[]),{visibleStart:f,visibleEnd:h}=l.useMemo(()=>{if(!i)return{visibleStart:0,visibleEnd:e};const m=Math.max(0,Math.floor(d/r)-4),y=Math.ceil(n/r)+8,x=Math.min(e,m+y);return{visibleStart:m,visibleEnd:x}},[i,d,r,n,e,4]);return{visibleStart:f,visibleEnd:h,totalHeight:e*r,offsetTop:f*r,virtualised:i,containerProps:{onScroll:p,ref:c,style:{overflowY:"auto",maxHeight:n,willChange:i?"transform":void 0}}}}const oc=44,Oh=352,Wh=60,qa=480;function Uh(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 ${O.models.subscriptionBilling}`:O.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 Ns(e){return e.displayName??e.id??""}function Hh(e,r){if(!r)return e;const n=r.toLowerCase();return e.filter(o=>Ns(o).toLowerCase().includes(n)).sort((o,a)=>{const i=Ns(o),c=Ns(a),d=i.toLowerCase().indexOf(n),u=c.toLowerCase().indexOf(n);return d!==u?d-u:i.length-c.length})}function Vh({agent:e,activeModelId:r,focusedIndex:n=-1,onSelect:s,onOpenSettings:o}){const[a,i]=l.useState(""),[c,d]=l.useState(""),u=l.useRef(null);l.useEffect(()=>{const h=setTimeout(()=>d(a),Wh);return()=>clearTimeout(h)},[a]),l.useEffect(()=>{e.id==="openrouter"&&e.available&&u.current&&u.current.focus()},[e.id,e.available]);const p=l.useMemo(()=>Hh(e.models,c),[e.models,c]),f=_h(p.length,oc,Oh);return e.id==="openrouter"&&!e.available?t.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:qa,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:O.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:O.providers.openrouter.addKeyCta})]}):t.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:qa,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:O.picker.searchPlaceholder,value:a,onChange:h=>i(h.target.value),"data-testid":"model-search-input","aria-label":O.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&&c?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:O.picker.noMatches(c)}),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:O.picker.clearSearch})]}):p.length===0?t.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:O.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 y=f.visibleStart+m;return t.jsx(Kh,{model:h,isActive:h.id===r,isFocused:n===y,onSelect:()=>s(h.id),resolvedModel:e.id==="claude-cli"?e.resolvedModel??null:null},h.id)})})})})]})}function Gh(e,r,n){return r&&r.toLowerCase().includes(e.toLowerCase())?r:n??null}function Kh({model:e,isActive:r,isFocused:n,onSelect:s,resolvedModel:o}){const a=Uh(e),i=Gh(e.id,o,e.resolvedId),c=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:oc,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}),c&&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 Ya={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function qh(){const[e,r]=l.useState(null),[n,s]=l.useState(!0),[o,a]=l.useState(null),i=l.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({...Ya,...p}),a(null)}catch(u){a(u.message),r(Ya)}finally{s(!1)}},[]);l.useEffect(()=>{i()},[i]);const c=l.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=l.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:c,remove:d,refresh:i}}function Yh({onMigrated:e,fetchImpl:r}){const[n,s]=l.useState({kind:"loading"}),o=r??globalThis.fetch,a=l.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]);l.useEffect(()=>{a()},[a]);const i=l.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]),c=l.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:Rs,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:{...Rs,background:"var(--accent, var(--color-accent))",color:"white",opacity:d?.6:1},children:d?"Importing…":"Migrate"}),t.jsx("button",{type:"button",onClick:()=>void c(),"data-testid":"migration-dismiss",style:{...Rs,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Rs={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Jh=[{id:"anthropic",name:O.providers.anthropic.name,keyIssuanceUrl:O.providers.anthropic.keyIssuanceUrl,prefix:O.providers.anthropic.keyPrefix,placeholder:`Paste ${O.providers.anthropic.name} key`},{id:"openai",name:O.providers.openai.name,keyIssuanceUrl:O.providers.openai.keyIssuanceUrl,prefix:O.providers.openai.keyPrefix,placeholder:O.providers.openai.pastePlaceholder},{id:"openrouter",name:O.providers.openrouter.name,keyIssuanceUrl:O.providers.openrouter.keyIssuanceUrl,prefix:O.providers.openrouter.keyPrefix,placeholder:`Paste ${O.providers.openrouter.name} key`}];function Xh(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 ac({open:e,onClose:r,initialProvider:n,onToast:s}){const{state:o,save:a,remove:i,refresh:c}=qh(),d=l.useRef(null),u=l.useRef(null),[p,f]=l.useState(null);l.useEffect(()=>{if(!e)return;let m=!1;return(async()=>{try{const y=await fetch("/api/settings/storage-path");if(!y.ok)throw new Error(`GET /api/settings/storage-path returned ${y.status}`);const x=await y.json();m||f(x.path??null)}catch{m||f(null)}})(),()=>{m=!0}},[e]),l.useEffect(()=>{if(!e)return;const m=document.activeElement,y=setTimeout(()=>{var b;const x=n?`input[data-provider="${n}"]`:"input[data-provider]",g=(b=d.current)==null?void 0:b.querySelector(x);g==null||g.focus()},0);return()=>{var x;clearTimeout(y),(x=m==null?void 0:m.focus)==null||x.call(m)}},[e,n]),l.useEffect(()=>{if(!e)return;const m=y=>{if(y.key==="Escape"){y.preventDefault(),y.stopPropagation(),r();return}if(y.key==="Tab"&&d.current){y.stopPropagation();const x=d.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(x.length===0)return;const g=x[0],b=x[x.length-1];y.shiftKey&&document.activeElement===g?(y.preventDefault(),b.focus()):!y.shiftKey&&document.activeElement===b&&(y.preventDefault(),g.focus())}};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[e,r]);const h=l.useCallback(async()=>{var m,y;if(p)try{await((y=(m=navigator.clipboard)==null?void 0:m.writeText)==null?void 0:y.call(m,p)),s==null||s(O.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:O.settings.title}),t.jsx(Yh,{onMigrated:()=>{c()}}),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:O.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:O.settings.sectionApiKeys}),Jh.map(m=>t.jsx(Qh,{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 y=>{const x=await a(m.id,y);return s==null||s(O.settings.keySaved(m.name)),x},onRemove:async()=>{await i(m.id),s==null||s(O.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?O.settings.storagePath(p):O.settings.storagePathFallback}),t.jsx("button",{type:"button",onClick:h,disabled:!p,"data-testid":"settings-copy-path",style:{...fr,opacity:p?1:.5,cursor:p?"pointer":"not-allowed"},children:O.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 Qh({providerId:e,providerName:r,keyIssuanceUrl:n,prefix:s,placeholder:o,metadata:a,onSave:i,onRemove:c,inputRef:d}){const[u,p]=l.useState(""),[f,h]=l.useState(!1),[m,y]=l.useState(!1),[x,g]=l.useState(!1),[b,v]=l.useState(null),k=u.trim(),E=k.length===0,j=k.length>0&&!k.startsWith(s),T=l.useCallback(async()=>{if(E)return;y(!0);const N=k;p("");try{const R=await i(N);R.warning?v(R.warning):v(null)}finally{y(!1)}},[E,i,k]),w=l.useCallback(async()=>{var N;try{if(!((N=navigator.clipboard)!=null&&N.readText))return;const R=await navigator.clipboard.readText();p(R)}catch{}},[]),S=l.useCallback(async()=>{g(!1),await c()},[c]);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),v(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:fr,children:f?O.settings.hide:O.settings.show}),t.jsx("button",{type:"button",onClick:w,style:fr,children:O.settings.paste})]}),j&&t.jsx("div",{role:"status","data-testid":`prefix-warn-${e}`,style:Ja,children:O.settings.prefixWarn(r)}),b&&t.jsx("div",{role:"status",style:Ja,children:b}),t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[t.jsx("button",{type:"button",onClick:T,disabled:E||m,"data-testid":`save-${e}`,style:{...fr,background:E?"var(--surface-2)":"var(--accent, var(--color-accent))",color:E?"var(--text-muted)":"white",cursor:E?"not-allowed":"pointer"},children:O.settings.save}),(a==null?void 0:a.stored)&&t.jsx(t.Fragment,{children:x?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:12},children:O.settings.removeConfirm(r)}),t.jsx("button",{type:"button",onClick:S,"data-testid":`remove-confirm-${e}`,style:{...fr,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),t.jsx("button",{type:"button",onClick:()=>g(!1),style:fr,children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>g(!0),"data-testid":`remove-${e}`,style:{...fr,color:"var(--text-muted)"},children:O.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?O.settings.keyStoredAt(Xh(a.updatedAt)):O.settings.noKey})]})]})}const fr={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Ja={fontSize:11,color:"var(--warning, var(--text-muted))"};function Zh(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function em({onToast:e}){const{status:r,catalog:n,focusAgent:s,setActive:o}=sc({onStaleCatalog:(R,I)=>{const A=Math.round(I/6e4);e==null||e(`Using cached ${R} catalog (${A} min old)`)},onSetActiveError:R=>e==null?void 0:e(R)}),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[u,p]=l.useState(),[f,h]=l.useState(null),[m,y]=l.useState("agents"),[x,g]=l.useState(0),b=l.useRef(null);l.useRef(null),l.useEffect(()=>{var R;n&&!f&&h(n.activeAgent??((R=n.agents[0])==null?void 0:R.id)??null)},[n,f]);const v=(n==null?void 0:n.agents)??[],k=l.useMemo(()=>v.find(R=>R.id===f)??v[0],[v,f]);l.useEffect(()=>{g(0)},[f]);const E=l.useCallback(()=>{var R;i(!0),y("agents"),h((n==null?void 0:n.activeAgent)??((R=v[0])==null?void 0:R.id)??null),g(0)},[n,v]),j=l.useCallback(()=>{var R;i(!1),(R=b.current)==null||R.focus()},[]);l.useEffect(()=>{const R=()=>i(I=>!I);return window.addEventListener("openAgentModelPicker",R),()=>{window.removeEventListener("openAgentModelPicker",R)}},[]),l.useEffect(()=>{if(!a)return;const R=A=>{if(A.key==="Escape"){A.preventDefault(),j();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(),y("models"),g($=>{const B=((k==null?void 0:k.models.length)??1)-1;return Math.max(0,Math.min($,Math.max(0,B)))});return}if(A.key==="ArrowLeft"&&m==="models"){A.preventDefault(),y("agents");return}if(A.key==="Enter"){if(A.preventDefault(),m==="agents"&&k)y("models"),g(0);else if(m==="models"&&k){const $=Math.max(0,Math.min(k.models.length-1,x)),B=k.models[$];B&&(o(k.id,B.id),j())}return}};function I(A){if(m==="agents"){const $=v.findIndex(C=>C.id===f),B=v[Math.max(0,Math.min(v.length-1,$+A))];B&&(h(B.id),s(B.id));return}if(m==="models"&&k){const $=k.models.length;if($===0)return;g(B=>{const C=B+A;return Math.max(0,Math.min($-1,C))})}}return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[a,m,v,f,k,x,j,s,o]);const T=l.useCallback(R=>{p(R==="anthropic"||R==="openrouter"?R:void 0),d(!0),i(!1)},[]),w=v.find(R=>R.id===(n==null?void 0:n.activeAgent)),S=w==null?void 0:w.models.find(R=>R.id===(n==null?void 0:n.activeModel)),N=l.useMemo(()=>{if(r!=="ready"||!n)return"Loading…";const R=(w==null?void 0:w.displayName)??"Agent",I=(S==null?void 0:S.displayName)??n.activeModel??"Model";return`${R} · ${I}`},[r,n,w,S]);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:b,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>a?j():E(),"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"&&Dr.createPortal(t.jsxs(tm,{reducedMotion:Zh(),onClickOutside:j,children:[t.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[t.jsx(Bh,{agents:v,activeAgentId:(n==null?void 0:n.activeAgent)??null,focusedAgentId:f,onFocus:R=>{h(R),s(R)},onSelect:R=>{h(R),s(R),y("models")},onOpenSettings:T}),k&&t.jsx(Vh,{agent:k,activeModelId:(n==null?void 0:n.activeModel)??null,focusedIndex:m==="models"?x:-1,onSelect:R=>{o(k.id,R),j()},onOpenSettings:T})]}),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:()=>T(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:O.picker.settingsButton}),t.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:O.picker.footerHint})]})]}),document.body),t.jsx(ac,{open:c,onClose:()=>d(!1),initialProvider:u,onToast:e})]})}function tm({children:e,reducedMotion:r,onClickOutside:n}){const s=l.useRef(null);return l.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
16
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
17
17
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
18
- }`})]})}const Ts="#F25F1C";function Xa(){typeof window>"u"||(window.location.hash="#/")}function rm({onHome:e}){const[r,n]=l.useState(!1),[s,o]=l.useState(!1),a=c=>{c.metaKey||c.ctrlKey||c.shiftKey||c.button!==0||(c.preventDefault(),Xa(),e==null||e())},i=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Xa(),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:Ts}),t.jsx("path",{d:"M9.75 19.4h4.5a2.25 2.25 0 11-4.5 0z",fill:Ts}),t.jsx("circle",{cx:"18.5",cy:"5.5",r:"2.75",fill:Ts,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 Qa=l.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 nm({toast:e,onDismiss:r}){const[n,s]=l.useState(!0),o=l.useRef(null);l.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 sm({toasts:e,onDismiss:r,liveMessage:n,liveAssertiveMessage:s}){return t.jsxs(t.Fragment,{children:[t.jsx(Qa,{politeness:"polite",message:n}),t.jsx(Qa,{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(nm,{toast:o,onDismiss:r})},o.id))})]})}const ic=l.createContext(null);function cs(){const e=l.useContext(ic);if(!e)throw new Error("useToast must be used inside <ToastProvider>.");return e}function om({children:e,maxVisible:r=4,defaultDurationMs:n=4e3}){const[s,o]=l.useState([]),[a,i]=l.useState(""),[c,d]=l.useState(""),u=l.useRef(new Map),p=l.useCallback(g=>{const b=u.current.get(g);b&&(clearTimeout(b),u.current.delete(g)),o(v=>v.filter(k=>k.id!==g))},[]),f=l.useCallback((g,b)=>{if(b<=0)return;const v=setTimeout(()=>{p(g)},b);u.current.set(g,v)},[p]),h=l.useCallback(g=>{const b=g.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,v={id:b,message:g.message,severity:g.severity??"info",durationMs:g.durationMs??n,action:g.action};return o(k=>[...k,v]),v.severity==="error"?d(v.message):i(v.message),f(b,v.durationMs),b},[n,f]),m=l.useCallback(()=>{for(const g of u.current.values())clearTimeout(g);u.current.clear(),o([])},[]);l.useEffect(()=>{function g(b){b.key==="Escape"&&o(v=>{if(v.length===0)return v;const k=v.slice(0,r),E=k[k.length-1],j=u.current.get(E.id);return j&&(clearTimeout(j),u.current.delete(E.id)),v.filter(T=>T.id!==E.id)})}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r]),l.useEffect(()=>()=>{for(const g of u.current.values())clearTimeout(g);u.current.clear()},[]);const y=s.slice(0,r),x=l.useMemo(()=>({toast:h,dismiss:p,clear:m}),[h,p,m]);return t.jsxs(ic.Provider,{value:x,children:[e,t.jsx(sm,{toasts:y,onDismiss:p,liveMessage:a,liveAssertiveMessage:c})]})}function am(){const{data:e,loading:r}=St("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 im=l.lazy(()=>ar(()=>import("./UpdateDropdown-C4BH7W_M.js"),__vite__mapDeps([2,3,4,5,6])));function lm(e){switch(e){case"connected":return"connected";case"fallback":return"reconnecting";case"connecting":default:return"connecting"}}function cm(e){switch(e){case"connected":return"var(--status-success-text)";case"fallback":return"var(--color-own)";case"connecting":default:return"var(--text-secondary)"}}function dm(){const{updateCount:e,updates:r,isRefreshingUpdates:n,refreshUpdates:s,selectSkill:o,revealSkill:a,skills:i,updatesById:c,activeAgent:d,updateStreamStatus:u,trackedSkillCount:p}=It(),{toast:f}=cs(),{data:h}=am(),m=(h==null?void 0:h.degraded)===!0,y=l.useId(),x=u??"connecting",g=typeof p=="number"?p:null,b=g===null?!0:g>0,v=l.useMemo(()=>{if(!c||c.size===0)return;const A=new Map;for(const[$,B]of c)B.diffSummary&&A.set($,B.diffSummary);return A.size>0?A:void 0},[c]),[k,E]=l.useState(!1),j=l.useRef(null),T=l.useCallback(()=>E(!1),[]),w=m?"var(--color-own)":e>0?"var(--text-primary)":"var(--text-secondary)",S=e>9?"9+":String(e),N=e===0?"No updates available":`${e} updates available, open summary`,R=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:j,type:"button","data-testid":"update-bell","aria-label":R,"aria-haspopup":"dialog","aria-expanded":k,"aria-describedby":y,title:I,onClick:()=>E(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:S}),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:cm(x),border:"1px solid var(--color-paper)",display:"inline-block",lineHeight:0}})]}),t.jsx("span",{id:y,"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: ${lm(x)}`}),k&&t.jsx(l.Suspense,{fallback:t.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:t.jsx(im,{updates:r,isRefreshing:n,diffSummariesById:v,onRefresh:()=>s(),onSelectSkill:A=>{const $=A.localSkill??A.name.split("/").pop()??"",B=A.localPlugin??"";if(a)a(B,$);else{const L=A.name.split("/"),P=L.length>=2?L[L.length-2]:L[0];o({plugin:P,skill:$,origin:"installed"})}if(!(i??[]).some(L=>L.skill===$&&(B===""||L.plugin===B))){const L=A.installLocations??[];if(L.length>0){const P=d?L.filter(H=>H.agent===d):[],M=d?L.filter(H=>H.agent!==d):L;if(P.length>0&&M.length>0){const H=M.length>=2?`Also installed under ${M.length} other locations.`:`Also installed under ${M[0].agentLabel}.`;f({severity:"info",message:H})}else{const H=L[0].agentLabel;f({severity:"info",message:`Skill installed under ${H} — switch to ${H} to view details.`})}}}T()},onViewAll:()=>{window.location.hash="#/updates",T()},onClose:T,anchorRef:j})})]})}function Za(e){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:e}))}function um(e){return e.source==="project"?O.scopeLabels.sourceProject:e.source==="personal"?O.scopeLabels.sourcePersonal:e.source==="plugin"?O.scopeLabels.sourcePlugin:e.origin==="installed"?O.scopeLabels.sourcePersonal:O.scopeLabels.sourceProject}function pm(e){return e.source==="project"?"var(--status-installed)":e.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)"}function fm({projectName:e,selected:r,onHome:n,projectPickerSlot:s,onRequestCreateSkill:o,findSkillsSlot:a,userDropdownSlot:i,appUpdateSlot:c}){const d=r?um(r):null,u=r?pm(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(rm,{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}),c&&t.jsx("span",{"data-slot":"app-update",style:{display:"inline-flex",flexShrink:0},children:c})]}),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(ei,{segment:"origin",onClick:()=>Za({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:u},children:d}),t.jsx(ti,{}),t.jsx(ei,{segment:"plugin",onClick:()=>Za({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),t.jsx(ti,{}),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(em,{})}),t.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:t.jsx(dm,{})}),i&&t.jsx("span",{"data-slot":"user-dropdown",style:{display:"inline-flex"},children:i})]})]})]})}function ei({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 ti(){return t.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const ds="vskill-theme";function lc(e){return e==="light"||e==="dark"||e==="auto"?e:"auto"}function hm(e,r){return e==="light"||e==="dark"?e:r?"dark":"light"}function mm(e){try{const r=e.getItem(ds);return lc(r)}catch{return"auto"}}function xm(e,r){try{e.setItem(ds,r)}catch{}}function gm(e,r,n){e.dataset.theme=n,e.dataset.themeMode=r}function ym(e){if(!e)return!1;try{return e("(prefers-color-scheme: dark)").matches}catch{return!1}}const cc=l.createContext(null);function vm({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),[c,d]=l.useState(()=>o?mm(o):"auto"),[u,p]=l.useState(()=>ym(a)),f=l.useMemo(()=>hm(c,u),[c,u]);l.useEffect(()=>{i&&gm(i,c,f)},[i,c,f]),l.useEffect(()=>{if(!a)return;const y=a("(prefers-color-scheme: dark)"),x=b=>p(b.matches);if(typeof y.addEventListener=="function")return y.addEventListener("change",x),()=>y.removeEventListener("change",x);const g=y;return g.addListener(x),()=>g.removeListener(x)},[a]),l.useEffect(()=>{if(typeof window>"u")return;const y=x=>{x.key===ds&&d(lc(x.newValue))};return window.addEventListener("storage",y),()=>window.removeEventListener("storage",y)},[]),l.useEffect(()=>{if(!a||!i)return;let y;try{y=a("(prefers-contrast: more)")}catch{return}const x=v=>{v?i.dataset.contrast="more":i.dataset.contrast==="more"&&delete i.dataset.contrast};x(y.matches);const g=v=>x(v.matches);if(typeof y.addEventListener=="function")return y.addEventListener("change",g),()=>y.removeEventListener("change",g);const b=y;return b.addListener(g),()=>b.removeListener(g)},[a,i]);const h=l.useCallback(y=>{d(y),o&&xm(o,y)},[o]),m=l.useMemo(()=>({mode:c,resolvedTheme:f,setTheme:h}),[c,f,h]);return t.jsx(cc.Provider,{value:m,children:s})}function dc(){const e=l.useContext(cc);if(!e)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return e}const ri=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function bm(e){const r=new Map(e.map(s=>[s.id,s])),n=[];for(const s of ri){const o=r.get(s);o&&n.push(o)}for(const s of e)ri.includes(s.id)||n.push(s);return n}function km(e){const[r,n]=l.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${e}px)`).matches);return l.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 jm({providers:e,onOpenSettings:r,onOpenInstallHelp:n}){const s=bm(e),o=km(640),[a,i]=l.useState(!1),c=l.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":O.statusBar.providerSummary(d,s.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:O.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(ni,{p:u,onClick:c},u.id))})]})}return t.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:s.map(d=>t.jsx(ni,{p:d,onClick:c,compact:!0},d.id))})}function ni({p:e,onClick:r,compact:n}){const s=e.available?O.statusBar.unlocked(e.label):e.kind==="cli-install"?O.statusBar.lockedCli(e.label):O.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(Co,{unlocked:e.available,size:10}),!n&&t.jsx("span",{children:e.label})]})}function wm(){try{return typeof localStorage>"u"?null:localStorage.getItem(ds)}catch{return null}}function Sm({projectPath:e,modelName:r,health:n="ok",onPathClick:s,providers:o,onOpenProviderSettings:a,onOpenProviderInstallHelp:i}){const{mode:c,resolvedTheme:d,setTheme:u}=dc(),f=wm()==="auto",h=Cm(c,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(si,{}),t.jsxs("span",{"aria-label":`Health: ${n}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[t.jsx(Em,{color:m}),t.jsx("span",{style:{textTransform:"capitalize"},children:n})]}),o&&o.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(si,{}),t.jsx(jm,{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: ${c} — 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(Nm,{mode:c}),t.jsx("span",{style:{textTransform:"capitalize"},children:c})]})]})}function Cm(e,r,n){return e==="light"?"dark":e==="dark"?"auto":n?"light":r==="light"?"dark":"light"}function Em({color:e}){return t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:e,display:"inline-block",flexShrink:0}})}function si(){return t.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function Nm({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 Eo=new Set;function uc(){for(const e of Eo)e()}const Rm=5,Tm=1e3,Im=6e4;function Lm(){const[e,r]=l.useState(void 0),[n,s]=l.useState(!1),[o,a]=l.useState(!0),i=l.useRef(0),c=l.useRef(null),d=l.useRef(null),u=l.useRef(!0),p=l.useRef(0),[f,h]=l.useState(0),m=()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},y=l.useCallback(()=>{c.current&&(c.current.abort(),c.current=null)},[]),x=l.useCallback(async()=>{if(!u.current||document.visibilityState==="hidden")return;y();const b=new AbortController;c.current=b;try{const v=await fetch("/api/plugins",{signal:b.signal});if(!u.current)return;const k=await v.json();if(!u.current)return;i.current=0,r(k.plugins??[]),a(!1),s(!1),d.current=setTimeout(()=>{u.current&&h(E=>E+1)},Im)}catch(v){if(!u.current||v instanceof DOMException&&v.name==="AbortError")return;if(i.current+=1,a(!1),i.current>Rm){s(!0);return}const k=Tm*Math.pow(2,i.current-1);d.current=setTimeout(()=>{u.current&&h(E=>E+1)},k)}},[y]);l.useEffect(()=>(u.current=!0,()=>{u.current=!1,m(),y()}),[y]),l.useEffect(()=>{document.visibilityState!=="hidden"&&(m(),x())},[f,x]),l.useEffect(()=>{const b=()=>{document.visibilityState==="hidden"?(m(),y()):(i.current=0,s(!1),h(v=>v+1))};return document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b)}},[y]);const g=l.useCallback(()=>{i.current=0,s(!1),m(),p.current+=1,h(b=>b+1)},[]);return l.useEffect(()=>(Eo.add(g),()=>{Eo.delete(g)}),[g]),{plugins:e,paused:n,loading:o,retry:g}}const us=0,lr=1,Fr=2,pc=4;function oi(e){return()=>e}function Am(e){e()}function fc(e,r){return n=>e(r(n))}function ai(e,r){return()=>e(r)}function Pm(e,r){return n=>e(r,n)}function ea(e){return e!==void 0}function $m(...e){return()=>{e.map(Am)}}function zr(){}function ps(e,r){return r(e),e}function Mm(e,r){return r(e)}function We(...e){return e}function Ae(e,r){return e(lr,r)}function Ee(e,r){e(us,r)}function ta(e){e(Fr)}function He(e){return e(pc)}function be(e,r){return Ae(e,Pm(r,us))}function $t(e,r){const n=e(lr,s=>{n(),r(s)});return n}function ii(e){let r,n;return s=>o=>{r=o,n&&clearTimeout(n),n=setTimeout(()=>{s(r)},e)}}function hc(e,r){return e===r}function Oe(e=hc){let r;return n=>s=>{e(r,s)||(r=s,n(s))}}function je(e){return r=>n=>{e(n)&&r(n)}}function fe(e){return r=>fc(r,e)}function zt(e){return r=>()=>{r(e)}}function X(e,...r){const n=Dm(...r);return((s,o)=>{switch(s){case Fr:ta(e);return;case lr:return Ae(e,n(o))}})}function Ot(e,r){return n=>s=>{n(r=e(r,s))}}function xr(e){return r=>n=>{e>0?e--:r(n)}}function Kt(e){let r=null,n;return s=>o=>{r=o,!n&&(n=setTimeout(()=>{n=void 0,s(r)},e))}}function Re(...e){const r=new Array(e.length);let n=0,s=null;const o=2**e.length-1;return e.forEach((a,i)=>{const c=2**i;Ae(a,d=>{const u=n;n|=c,r[i]=d,u!==o&&n===o&&s&&(s(),s=null)})}),a=>i=>{const c=()=>{a([i].concat(r))};n===o?c():s=c}}function Dm(...e){return r=>e.reduceRight(Mm,r)}function Fm(e){let r,n;const s=()=>r==null?void 0:r();return function(o,a){switch(o){case lr:return a?n===a?void 0:(s(),n=a,r=Ae(e,a),r):(s(),zr);case Fr:s(),n=null;return}}}function oe(e){let r=e;const n=Te();return((s,o)=>{switch(s){case us:r=o;break;case lr:{o(r);break}case pc:return r}return n(s,o)})}function dt(e,r){return ps(oe(r),n=>be(e,n))}function Te(){const e=[];return((r,n)=>{switch(r){case us:e.slice().forEach(s=>{s(n)});return;case Fr:e.splice(0,e.length);return;case lr:return e.push(n),()=>{const s=e.indexOf(n);s>-1&&e.splice(s,1)}}})}function jt(e){return ps(Te(),r=>be(e,r))}function Le(e,r=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:r,id:zm(),singleton:n}}const zm=()=>Symbol();function Bm(e){const r=new Map,n=({constructor:s,dependencies:o,id:a,singleton:i})=>{if(i&&r.has(a))return r.get(a);const c=s(o.map(d=>n(d)));return i&&r.set(a,c),c};return n(e)}function qe(...e){const r=Te(),n=new Array(e.length);let s=0;const o=2**e.length-1;return e.forEach((a,i)=>{const c=2**i;Ae(a,d=>{n[i]=d,s|=c,s===o&&Ee(r,n)})}),function(a,i){switch(a){case Fr:{ta(r);return}case lr:return s===o&&i(n),Ae(r,i)}}}function ke(e,r=hc){return X(e,Oe(r))}function No(...e){return function(r,n){switch(r){case Fr:return;case lr:return $m(...e.map(s=>Ae(s,n)))}}}const et={DEBUG:0,INFO:1,WARN:2,ERROR:3},_m={[et.DEBUG]:"debug",[et.ERROR]:"error",[et.INFO]:"log",[et.WARN]:"warn"},Om=()=>typeof globalThis>"u"?window:globalThis,cr=Le(()=>{const e=oe(et.ERROR);return{log:oe((r,n,s=et.INFO)=>{const o=Om().VIRTUOSO_LOG_LEVEL??He(e);s>=o&&console[_m[s]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,n)}),logLevel:e}},[],{singleton:!0});function yr(e,r,n){return ra(e,r,n).callbackRef}function ra(e,r,n){const s=ve.useRef(null);let o=i=>{};const a=ve.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const c=()=>{const d=i[0].target;d.offsetParent!==null&&e(d)};n?c():requestAnimationFrame(c)}):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 Wm(e,r,n,s,o,a,i,c,d){const u=ve.useCallback(p=>{const f=Um(p.children,r,c?"offsetWidth":"offsetHeight",o);let h=p.parentElement;for(;h.dataset.virtuosoScroller===void 0;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let y;m&&(y=h.ownerDocument.defaultView);const x=i?c?i.scrollLeft:i.scrollTop:m?c?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:c?h.scrollLeft:h.scrollTop,g=i?c?i.scrollWidth:i.scrollHeight:m?c?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:c?h.scrollWidth:h.scrollHeight,b=i?c?i.offsetWidth:i.offsetHeight:m?c?y.innerWidth:y.innerHeight:c?h.offsetWidth:h.offsetHeight;s({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:b}),a==null||a(c?li("column-gap",getComputedStyle(p).columnGap,o):li("row-gap",getComputedStyle(p).rowGap,o)),f!==null&&e(f)},[e,r,o,a,i,s,c]);return ra(u,n,d)}function Um(e,r,n,s){const o=e.length;if(o===0)return null;const a=[];for(let i=0;i<o;i++){const c=e.item(i);if(c.dataset.index===void 0)continue;const d=parseInt(c.dataset.index),u=parseFloat(c.dataset.knownSize),p=r(c,n);if(p===0&&s("Zero-sized element, this should not happen",{child:c},et.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 li(e,r,n){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,r,et.WARN),r==="normal"?0:parseInt(r??"0",10)}function mc(e,r,n){const s=ve.useRef(null),o=ve.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const u=d.getBoundingClientRect(),p=u.width;let f,h;if(r){const m=r.getBoundingClientRect(),y=u.top-m.top;h=m.height-Math.max(0,y),f=y+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}=ra(o,!0,n),c=ve.useCallback(()=>{o(i.current)},[o,i]);return ve.useEffect(()=>{var u;if(r){r.addEventListener("scroll",c);const p=new ResizeObserver(()=>{requestAnimationFrame(c)});return p.observe(r),()=>{r.removeEventListener("scroll",c),p.unobserve(r)}}const d=(u=i.current)==null?void 0:u.ownerDocument.defaultView;return d==null||d.addEventListener("scroll",c),d==null||d.addEventListener("resize",c),()=>{d==null||d.removeEventListener("scroll",c),d==null||d.removeEventListener("resize",c)}},[c,r,i]),a}const ft=Le(()=>{const e=Te(),r=Te(),n=oe(0),s=Te(),o=oe(0),a=Te(),i=Te(),c=oe(0),d=oe(0),u=oe(0),p=oe(0),f=Te(),h=Te(),m=oe(!1),y=oe(!1),x=oe(!1);return be(X(e,fe(({scrollTop:g})=>g)),r),be(X(e,fe(({scrollHeight:g})=>g)),i),be(r,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:d,footerHeight:p,headerHeight:c,horizontalDirection:y,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:r,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:s,statefulScrollTop:o,viewportHeight:a}},[],{singleton:!0}),on={lvl:0};function xc(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:c,value:d}=r(e[i]);a.push({end:c-1,start:s,value:o}),s=c,o=d}return a.push({end:1/0,start:s,value:o}),a}function De(e){return e===on}function an(e,r){if(!De(e))return r===e.k?e.v:r<e.k?an(e.l,r):an(e.r,r)}function Dt(e,r,n="k"){if(De(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 kt(e,r,n){return De(e)?vc(r,n,1):r===e.k?Qe(e,{k:r,v:n}):r<e.k?ci(Qe(e,{l:kt(e.l,r,n)})):ci(Qe(e,{r:kt(e.r,r,n)}))}function Tr(){return on}function Ir(e,r,n){if(De(e))return[];const s=Dt(e,r)[0];return Hm(To(e,s,n))}function Ro(e,r){if(De(e))return on;const{k:n,l:s,r:o}=e;if(r===n){if(De(s))return o;if(De(o))return s;const[a,i]=yc(s);return Gn(Qe(e,{k:a,l:gc(s),v:i}))}return r<n?Gn(Qe(e,{l:Ro(s,r)})):Gn(Qe(e,{r:Ro(o,r)}))}function mr(e){return De(e)?[]:[...mr(e.l),{k:e.k,v:e.v},...mr(e.r)]}function To(e,r,n){if(De(e))return[];const{k:s,l:o,r:a,v:i}=e;let c=[];return s>r&&(c=c.concat(To(o,r,n))),s>=r&&s<=n&&c.push({k:s,v:i}),s<=n&&(c=c.concat(To(a,r,n))),c}function Gn(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(Is(r))return bc(Qe(e,{lvl:n-1}));if(!De(r)&&!De(r.r))return Qe(r.r,{l:Qe(r,{r:r.r.l}),lvl:n,r:Qe(e,{l:r.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}if(Is(e))return Io(Qe(e,{lvl:n-1}));if(!De(s)&&!De(s.l)){const o=s.l,a=Is(o)?s.lvl-1:s.lvl;return Qe(o,{l:Qe(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Io(Qe(s,{l:o.r,lvl:a}))})}throw new Error("Unexpected empty nodes")}function Qe(e,r){return vc(r.k!==void 0?r.k:e.k,r.v!==void 0?r.v:e.v,r.lvl!==void 0?r.lvl:e.lvl,r.l!==void 0?r.l:e.l,r.r!==void 0?r.r:e.r)}function gc(e){return De(e.r)?e.l:Gn(Qe(e,{r:gc(e.r)}))}function Is(e){return De(e)||e.lvl>e.r.lvl}function yc(e){return De(e.r)?[e.k,e.v]:yc(e.r)}function vc(e,r,n,s=on,o=on){return{k:e,l:s,lvl:n,r:o,v:r}}function ci(e){return Io(bc(e))}function bc(e){const{l:r}=e;return!De(r)&&r.lvl===e.lvl?Qe(r,{r:Qe(e,{l:r.r})}):e}function Io(e){const{lvl:r,r:n}=e;return!De(n)&&!De(n.r)&&n.lvl===r&&n.r.lvl===r?Qe(n,{l:Qe(e,{r:n.l}),lvl:r+1}):e}function Hm(e){return xc(e,({k:r,v:n})=>({index:r,value:n}))}function kc(e,r){return!!(e&&e.startIndex===r.startIndex&&e.endIndex===r.endIndex)}function ln(e,r){return!!(e&&e[0]===r[0]&&e[1]===r[1])}const na=Le(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function jc(e,r,n){return e[Qn(e,r,n)]}function Qn(e,r,n,s=0){let o=e.length-1;for(;s<=o;){const a=Math.floor((s+o)/2),i=e[a],c=n(i,r);if(c===0)return a;if(c===-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 Vm(e,r,n,s){const o=Qn(e,r,s),a=Qn(e,n,s,o);return e.slice(o,a+1)}function or(e,r){return Math.round(e.getBoundingClientRect()[r])}function fs(e){return!De(e.groupOffsetTree)}function sa({index:e},r){return r===e?0:r<e?-1:1}function Gm(){return{groupIndices:[],groupOffsetTree:Tr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Tr()}}function Km(e,r){let n=De(e)?0:1/0;for(const s of r){const{endIndex:o,size:a,startIndex:i}=s;if(n=Math.min(n,i),De(e)){e=kt(e,0,a);continue}const c=Ir(e,i-1,o+1);if(c.some(ex(s)))continue;let d=!1,u=!1;for(const{end:p,start:f,value:h}of c)d?(o>=f||a===h)&&(e=Ro(e,f)):(u=h!==a,d=!0),p>o&&o>=f&&h!==a&&(e=kt(e,o+1,h));u&&(e=kt(e,i,a))}return[e,n]}function qm(e){return typeof e.groupIndex<"u"}function Ym({offset:e},r){return r===e?0:r<e?-1:1}function cn(e,r,n){if(r.length===0)return 0;const{index:s,offset:o,size:a}=jc(r,e,sa),i=e-s,c=a*i+(i-1)*n+o;return c>0?c+n:c}function wc(e,r){if(!fs(r))return e;let n=0;for(;r.groupIndices[n]<=e+n;)n++;return e+n}function Sc(e,r,n){if(qm(e))return r.groupIndices[e.groupIndex]+1;const s=e.index==="LAST"?n:e.index;let o=wc(s,r);return o=Math.max(0,o,Math.min(n,o)),o}function Jm(e,r,n,s=0){return s>0&&(r=Math.max(r,jc(e,s,sa).offset)),xc(Vm(e,r,n,Ym),Zm)}function Xm(e,[r,n,s,o]){r.length>0&&s("received item sizes",r,et.DEBUG);const a=e.sizeTree;let i=a,c=0;if(n.length>0&&De(a)&&r.length===2){const h=r[0].size,m=r[1].size;i=n.reduce((y,x)=>kt(kt(y,x,h),x+1,m),i)}else[i,c]=Km(i,r);if(i===a)return e;const{lastIndex:d,lastOffset:u,lastSize:p,offsetTree:f}=Lo(e.offsetTree,c,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>kt(h,m,cn(m,f,o)),Tr()),lastIndex:d,lastOffset:u,lastSize:p,offsetTree:f,sizeTree:i}}function Qm(e){return mr(e).map(({k:r,v:n},s,o)=>{const a=o[s+1];return{endIndex:a!==void 0?a.k-1:1/0,size:n,startIndex:r}})}function di(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 Lo(e,r,n,s){let o=e,a=0,i=0,c=0,d=0;if(r!==0){d=Qn(o,r-1,sa),c=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)}else o=[];for(const{start:u,value:p}of Ir(n,r,1/0)){const f=u-a,h=f*i+c+f*s;o.push({index:u,offset:h,size:p}),a=u,c=h,i=p}return{lastIndex:a,lastOffset:c,lastSize:i,offsetTree:o}}function Zm(e){return{index:e.index,value:e}}function ex(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 tx={offsetHeight:"height",offsetWidth:"width"},Ht=Le(([{log:e},{recalcInProgress:r}])=>{const n=Te(),s=Te(),o=dt(s,0),a=Te(),i=Te(),c=oe(0),d=oe([]),u=oe(void 0),p=oe(void 0),f=oe(void 0),h=oe(void 0),m=oe((w,S)=>or(w,tx[S])),y=oe(void 0),x=oe(0),g=Gm(),b=dt(X(n,Re(d,e,x),Ot(Xm,g),Oe()),g),v=dt(X(d,Oe(),Ot((w,S)=>({current:S,prev:w.current}),{current:[],prev:[]}),fe(({prev:w})=>w)),[]);be(X(d,je(w=>w.length>0),Re(b,x),fe(([w,S,N])=>{const R=w.reduce((I,A,$)=>kt(I,A,cn(A,S.offsetTree,N)||$),Tr());return{...S,groupIndices:w,groupOffsetTree:R}})),b),be(X(s,Re(b),je(([w,{lastIndex:S}])=>w<S),fe(([w,{lastIndex:S,lastSize:N}])=>[{endIndex:S,size:N,startIndex:w}])),n),be(u,p);const k=dt(X(u,fe(w=>w===void 0)),!0);be(X(p,je(w=>w!==void 0&&De(He(b).sizeTree)),fe(w=>{const S=He(f),N=He(d).length>0;return S!==void 0&&S!==0?N?[{endIndex:0,size:S,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),n),be(X(h,je(w=>w!==void 0&&w.length>0&&De(He(b).sizeTree)),fe(w=>{const S=[];let N=w[0],R=0;for(let I=1;I<w.length;I++){const A=w[I];A!==N&&(S.push({endIndex:I-1,size:N,startIndex:R}),N=A,R=I)}return S.push({endIndex:w.length-1,size:N,startIndex:R}),S})),n),be(X(d,Re(f,p),je(([,w,S])=>w!==void 0&&S!==void 0),fe(([w,S,N])=>{const R=[];for(let I=0;I<w.length;I++){const A=w[I],$=w[I+1];R.push({startIndex:A,endIndex:A,size:S}),$!==void 0&&R.push({startIndex:A+1,endIndex:$-1,size:N})}return R})),n);const E=jt(X(n,Re(b),Ot(({sizes:w},[S,N])=>({changed:N!==w,sizes:N}),{changed:!1,sizes:g}),fe(w=>w.changed)));Ae(X(c,Ot((w,S)=>({diff:w.prev-S,prev:S}),{diff:0,prev:0}),fe(w=>w.diff)),w=>{const{groupIndices:S}=He(b);if(w>0)Ee(r,!0),Ee(a,w+di(w,S));else if(w<0){const N=He(v);N.length>0&&(w-=di(-w,N)),Ee(i,w)}}),Ae(X(c,Re(e)),([w,S])=>{w<0&&S("`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:c},et.ERROR)});const j=jt(a);be(X(a,Re(b),fe(([w,S])=>{const N=S.groupIndices.length>0,R=[],I=S.lastSize;if(N){const A=an(S.sizeTree,0);let $=0,B=0;for(;$<w;){const L=S.groupIndices[B],P=S.groupIndices.length===B+1?1/0:S.groupIndices[B+1]-L-1;R.push({endIndex:L,size:A,startIndex:L}),R.push({endIndex:L+1+P-1,size:I,startIndex:L+1}),B++,$+=P+1}const C=mr(S.sizeTree);return $!==w&&C.shift(),C.reduce((L,{k:P,v:M})=>{let H=L.ranges;return L.prevSize!==0&&(H=[...L.ranges,{endIndex:P+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:P+w,prevSize:M,ranges:H}},{prevIndex:w,prevSize:0,ranges:R}).ranges}return mr(S.sizeTree).reduce((A,{k:$,v:B})=>({prevIndex:$+w,prevSize:B,ranges:[...A.ranges,{endIndex:$+w-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:I,ranges:[]}).ranges})),n);const T=jt(X(i,Re(b,x),fe(([w,{offsetTree:S},N])=>{const R=-w;return cn(R,S,N)})));return be(X(i,Re(b,x),fe(([w,S,N])=>{if(S.groupIndices.length>0){if(De(S.sizeTree))return S;let I=Tr();const A=He(v);let $=0,B=0,C=0;for(;$<-w;){C=A[B];const L=A[B+1]-C-1;B++,$+=L+1}if(I=mr(S.sizeTree).reduce((L,{k:P,v:M})=>kt(L,Math.max(0,P+w),M),I),$!==-w){const L=an(S.sizeTree,C);I=kt(I,0,L);const P=Dt(S.sizeTree,-w+1)[1];I=kt(I,1,P)}return{...S,sizeTree:I,...Lo(S.offsetTree,0,I,N)}}const R=mr(S.sizeTree).reduce((I,{k:A,v:$})=>kt(I,Math.max(0,A+w),$),Tr());return{...S,sizeTree:R,...Lo(S.offsetTree,0,R,N)}})),b),{beforeUnshiftWith:j,data:y,defaultItemSize:p,firstItemIndex:c,fixedItemSize:u,fixedGroupSize:f,gap:x,groupIndices:d,heightEstimates:h,itemSize:m,listRefresh:E,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:b,statefulTotalCount:o,totalCount:s,trackItemSizes:k,unshiftWith:a}},We(cr,na),{singleton:!0});function rx(e){return e.reduce((r,n)=>(r.groupIndices.push(r.totalCount),r.totalCount+=n+1,r),{groupIndices:[],totalCount:0})}const Cc=Le(([{groupIndices:e,sizes:r,totalCount:n},{headerHeight:s,scrollTop:o}])=>{const a=Te(),i=Te(),c=jt(X(a,fe(rx)));return be(X(c,fe(d=>d.totalCount)),n),be(X(c,fe(d=>d.groupIndices)),e),be(X(qe(o,r,s),je(([d,u])=>fs(u)),fe(([d,u,p])=>Dt(u.groupOffsetTree,Math.max(d-p,0),"v")[0]),Oe(),fe(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},We(Ht,ft)),dr=Le(([{log:e}])=>{const r=oe(!1),n=jt(X(r,je(s=>s),Oe()));return Ae(r,s=>{s&&He(e)("props updated",{},et.DEBUG)}),{didMount:n,propsReady:r}},We(cr),{singleton:!0}),nx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ec(e){const r=typeof e=="number"?{index:e}:e;return r.align||(r.align="start"),(!r.behavior||!nx)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const xn=Le(([{gap:e,listRefresh:r,sizes:n,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:a,footerHeight:i,headerHeight:c,scrollingInProgress:d,scrollTo:u,smoothScrollTargetReached:p,viewportHeight:f},{log:h}])=>{const m=Te(),y=Te(),x=oe(0);let g=null,b=null,v=null;function k(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),b&&(clearTimeout(b),b=null),Ee(d,!1)}return be(X(m,Re(n,f,s,x,c,i,h),Re(e,a,o),fe(([[E,j,T,w,S,N,R,I],A,$,B])=>{const C=Ec(E),{align:L,behavior:P,offset:M}=C,H=w-1,le=Sc(C,j,H);let G=cn(le,j.offsetTree,A)+N;L==="end"?(G+=$+Dt(j.sizeTree,le)[1]-T+B,le===H&&(G+=R)):L==="center"?G+=($+Dt(j.sizeTree,le)[1]-T+B)/2:G-=S,M!==void 0&&M!==0&&(G+=M);const W=Z=>{k(),Z?(I("retrying to scroll to",{location:E},et.DEBUG),Ee(m,E)):(Ee(y,!0),I("list did not change, scroll successful",{},et.DEBUG))};if(k(),P==="smooth"){let Z=!1;v=Ae(r,he=>{Z=Z||he}),g=$t(p,()=>{W(Z)})}else g=$t(X(r,sx(150)),W);return b=setTimeout(()=>{k()},1200),Ee(d,!0),I("scrolling from index to",{behavior:P,index:le,top:G},et.DEBUG),{behavior:P,top:G}})),u),{scrollTargetReached:y,scrollToIndex:m,topListHeight:x}},We(Ht,ft,cr),{singleton:!0});function sx(e){return r=>{const n=setTimeout(()=>{r(!1)},e);return s=>{s&&(r(!0),clearTimeout(n))}}}function oa(e,r){e===0?r():requestAnimationFrame(()=>{oa(e-1,r)})}function aa(e,r){const n=r-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const gn=Le(([{defaultItemSize:e,listRefresh:r,sizes:n},{scrollTop:s},{scrollTargetReached:o,scrollToIndex:a},{didMount:i}])=>{const c=oe(!0),d=oe(0),u=oe(!0);return be(X(i,Re(d),je(([p,f])=>f!==0),zt(!1)),c),be(X(i,Re(d),je(([p,f])=>f!==0),zt(!1)),u),Ae(X(qe(r,i),Re(c,n,e,u),je(([[,p],f,{sizeTree:h},m,y])=>p&&(!De(h)||ea(m))&&!f&&!y),Re(d)),([,p])=>{$t(o,()=>{Ee(u,!0)}),oa(4,()=>{$t(s,()=>{Ee(c,!0)}),Ee(a,p)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:d,scrolledToInitialItem:c}},We(Ht,ft,xn,dr),{singleton:!0});function Nc(e,r){return Math.abs(e-r)<1.01}const dn="up",Zr="down",ox="none",ax={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ix=0,yn=Le(([{footerHeight:e,headerHeight:r,scrollBy:n,scrollContainerState:s,scrollTop:o,viewportHeight:a}])=>{const i=oe(!1),c=oe(!0),d=Te(),u=Te(),p=oe(4),f=oe(ix),h=dt(X(No(X(ke(o),xr(1),zt(!0)),X(ke(o),xr(1),zt(!1),ii(100))),Oe()),!1),m=dt(X(No(X(n,zt(!0)),X(n,zt(!1),ii(200))),Oe()),!1);be(X(qe(ke(o),ke(f)),fe(([v,k])=>v<=k),Oe()),c),be(X(c,Kt(50)),u);const y=jt(X(qe(s,ke(a),ke(r),ke(e),ke(p)),Ot((v,[{scrollHeight:k,scrollTop:E},j,T,w,S])=>{const N=E+j-k>-S,R={scrollHeight:k,scrollTop:E,viewportHeight:j};if(N){let A,$;return E>v.state.scrollTop?(A="SCROLLED_DOWN",$=v.state.scrollTop-E):(A="SIZE_DECREASED",$=v.state.scrollTop-E||v.scrollTopDelta),{atBottom:!0,atBottomBecause:A,scrollTopDelta:$,state:R}}let I;return R.scrollHeight>v.state.scrollHeight?I="SIZE_INCREASED":j<v.state.viewportHeight?I="VIEWPORT_HEIGHT_DECREASING":E<v.state.scrollTop?I="SCROLLING_UPWARDS":I="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:I,state:R}},ax),Oe((v,k)=>v!==void 0&&v.atBottom===k.atBottom))),x=dt(X(s,Ot((v,{scrollHeight:k,scrollTop:E,viewportHeight:j})=>{if(!Nc(v.scrollHeight,k)){const T=k-(E+j)<1;return v.scrollTop!==E&&T?{changed:!0,jump:v.scrollTop-E,scrollHeight:k,scrollTop:E}:{changed:!0,jump:0,scrollHeight:k,scrollTop:E}}return{changed:!1,jump:0,scrollHeight:k,scrollTop:E}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),je(v=>v.changed),fe(v=>v.jump)),0);be(X(y,fe(v=>v.atBottom)),i),be(X(i,Kt(50)),d);const g=oe(Zr);be(X(s,fe(({scrollTop:v})=>v),Oe(),Ot((v,k)=>He(m)?{direction:v.direction,prevScrollTop:k}:{direction:k<v.prevScrollTop?dn:Zr,prevScrollTop:k},{direction:Zr,prevScrollTop:0}),fe(v=>v.direction)),g),be(X(s,Kt(50),zt(ox)),g);const b=oe(0);return be(X(h,je(v=>!v),zt(0)),b),be(X(o,Kt(100),Re(h),je(([v,k])=>k),Ot(([v,k],[E])=>[k,E],[0,0]),fe(([v,k])=>k-v)),b),{atBottomState:y,atBottomStateChange:d,atBottomThreshold:p,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:c,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:b}},We(ft)),un="top",pn="bottom",ui="none";function pi(e,r,n){return typeof e=="number"?n===dn&&r===un||n===Zr&&r===pn?e:0:n===dn?r===un?e.main:e.reverse:r===pn?e.main:e.reverse}function fi(e,r){return typeof e=="number"?e:e[r]??0}const ia=Le(([{deviation:e,fixedHeaderHeight:r,headerHeight:n,scrollTop:s,viewportHeight:o}])=>{const a=Te(),i=oe(0),c=oe(0),d=oe(0),u=dt(X(qe(ke(s),ke(o),ke(n),ke(a,ln),ke(d),ke(i),ke(r),ke(e),ke(c)),fe(([p,f,h,[m,y],x,g,b,v,k])=>{const E=p-v,j=g+b,T=Math.max(h-E,0);let w=ui;const S=fi(k,un),N=fi(k,pn);return m-=v,m+=h+b,y+=h+b,y-=v,m>p+j-S&&(w=dn),y<p-T+f+N&&(w=Zr),w!==ui?[Math.max(E-h-pi(x,un,w)-S,0),E-T-b+f+pi(x,pn,w)+N]:null}),je(p=>p!==null),Oe(ln)),[0,0]);return{increaseViewportBy:c,listBoundary:a,overscan:d,topListHeight:i,visibleRange:u}},We(ft),{singleton:!0});function lx(e,r,n){if(fs(r)){const s=wc(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 Ls={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Kn(e,r,n,s,o,a){const{lastIndex:i,lastOffset:c,lastSize:d}=o;let u=0,p=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];p=x.offset+x.size}const f=n-i,h=c+f*d+(f-1)*s,m=u,y=h-p;return{bottom:p,firstItemIndex:a,items:hi(e,o,a),offsetBottom:y,offsetTop:u,top:m,topItems:hi(r,o,a),topListHeight:r.reduce((x,g)=>g.size+x,0),totalCount:n}}function Rc(e,r,n,s,o,a){let i=0;if(n.groupIndices.length>0)for(const p of n.groupIndices){if(p-i>=e)break;i++}const c=e+i,d=aa(r,c),u=Array.from({length:c}).map((p,f)=>({data:a[f+d],index:f+d,offset:0,size:0}));return Kn(u,[],c,o,n,s)}function hi(e,r,n){if(e.length===0)return[];if(!fs(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=Ir(r.groupOffsetTree,s,o);let c,d=0;for(const u of e){(!c||c.end<u.index)&&(c=i.shift(),d=r.groupIndices.indexOf(c.start));let p;u.index===c.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 mi(e,r){return e===void 0?0:typeof e=="number"?e:e[r]??0}const vr=Le(([{data:e,firstItemIndex:r,gap:n,sizes:s,totalCount:o},a,{listBoundary:i,topListHeight:c,visibleRange:d},{initialTopMostItemIndex:u,scrolledToInitialItem:p},{topListHeight:f},h,{didMount:m},{recalcInProgress:y}])=>{const x=oe([]),g=oe(0),b=Te(),v=oe(0);be(a.topItemsIndexes,x);const k=dt(X(qe(m,y,ke(d,ln),ke(o),ke(s),ke(u),p,ke(x),ke(r),ke(n),ke(v),e),je(([w,S,,N,,,,,,,,R])=>{const I=R!==void 0&&R.length!==N;return w&&!S&&!I}),fe(([,,[w,S],N,R,I,A,$,B,C,L,P])=>{var U,K;const M=R,{offsetTree:H,sizeTree:le}=M,G=He(g);if(N===0)return{...Ls,totalCount:N};if(w===0&&S===0)return G===0?{...Ls,totalCount:N}:Rc(G,I,R,B,C,P||[]);if(De(le))return G>0?null:Kn(lx(aa(I,N),M,P),[],N,C,M,B);const W=[];if($.length>0){const V=$[0],Y=$[$.length-1];let J=0;for(const te of Ir(le,V,Y)){const de=te.value,se=Math.max(te.start,V),ue=Math.min(te.end,Y);for(let F=se;F<=ue;F++)W.push({data:P==null?void 0:P[F],index:F,offset:J,size:de}),J+=de}}if(!A)return Kn([],W,N,C,M,B);const Z=$.length>0?$[$.length-1]+1:0,he=Jm(H,w,S,Z);if(he.length===0)return null;const me=N-1,_=ps([],V=>{for(const Y of he){const J=Y.value;let te=J.offset,de=Y.start;const se=J.size;if(J.offset<w){de+=Math.floor((w-J.offset+C)/(se+C));const F=de-Y.start;te+=F*se+F*C}de<Z&&(te+=(Z-de)*se,de=Z);const ue=Math.min(Y.end,me);for(let F=de;F<=ue&&!(te>=S);F++)V.push({data:P==null?void 0:P[F],index:F,offset:te,size:se}),te+=se+C}}),ne=mi(L,un),D=mi(L,pn);if(_.length>0&&(ne>0||D>0)){const V=_[0],Y=_[_.length-1];if(ne>0&&V.index>Z){const J=Math.min(ne,V.index-Z),te=[];let de=V.offset;for(let se=V.index-1;se>=V.index-J;se--){const ue=((U=Ir(le,se,se)[0])==null?void 0:U.value)??V.size;de-=ue+C,te.unshift({data:P==null?void 0:P[se],index:se,offset:de,size:ue})}_.unshift(...te)}if(D>0&&Y.index<me){const J=Math.min(D,me-Y.index);let te=Y.offset+Y.size+C;for(let de=Y.index+1;de<=Y.index+J;de++){const se=((K=Ir(le,de,de)[0])==null?void 0:K.value)??Y.size;_.push({data:P==null?void 0:P[de],index:de,offset:te,size:se}),te+=se+C}}}return Kn(_,W,N,C,M,B)}),je(w=>w!==null),Oe()),Ls);be(X(e,je(ea),fe(w=>w==null?void 0:w.length)),o),be(X(k,fe(w=>w.topListHeight)),f),be(f,c),be(X(k,fe(w=>[w.top,w.bottom])),i),be(X(k,fe(w=>w.items)),b);const E=jt(X(k,je(({items:w})=>w.length>0),Re(o,e),je(([{items:w},S])=>w[w.length-1].originalIndex===S-1),fe(([,w,S])=>[w-1,S]),Oe(ln),fe(([w])=>w))),j=jt(X(k,Kt(200),je(({items:w,topItems:S})=>w.length>0&&w[0].originalIndex===S.length),fe(({items:w})=>w[0].index),Oe())),T=jt(X(k,je(({items:w})=>w.length>0),fe(({items:w})=>{let S=0,N=w.length-1;for(;w[S].type==="group"&&S<N;)S++;for(;w[N].type==="group"&&N>S;)N--;return{endIndex:w[N].index,startIndex:w[S].index}}),Oe(kc)));return{endReached:E,initialItemCount:g,itemsRendered:b,listState:k,minOverscanItemCount:v,rangeChanged:T,startReached:j,topItemsIndexes:x,...h}},We(Ht,Cc,ia,gn,xn,yn,dr,na),{singleton:!0}),Tc=Le(([{fixedFooterHeight:e,fixedHeaderHeight:r,footerHeight:n,headerHeight:s},{listState:o}])=>{const a=Te(),i=dt(X(qe(n,e,s,r,o),fe(([c,d,u,p,f])=>c+d+u+p+f.offsetBottom+f.bottom)),0);return be(ke(i),a),{totalListHeight:i,totalListHeightChanged:a}},We(ft,vr),{singleton:!0}),cx=Le(([{viewportHeight:e},{totalListHeight:r}])=>{const n=oe(!1),s=dt(X(qe(n,e,r),je(([o])=>o),fe(([,o,a])=>Math.max(0,o-a)),Kt(0),Oe()),0);return{alignToBottom:n,paddingTopAddition:s}},We(ft,Tc),{singleton:!0}),Ic=Le(()=>({context:oe(null)})),dx=({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,Lc=Le(([{gap:e,sizes:r,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:o,headerHeight:a,scrollingInProgress:i,scrollTop:c,viewportHeight:d},{scrollToIndex:u}])=>{const p=Te();return be(X(p,Re(r,d,n,a,o,s,c),Re(e),fe(([[f,h,m,y,x,g,b,v],k])=>{const{calculateViewLocation:E=dx,done:j,...T}=f,w=Sc(f,h,y-1),S=cn(w,h.offsetTree,k)+x+g,N=S+Dt(h.sizeTree,w)[1],R=v+g,I=v+m-b,A=E({itemBottom:N,itemTop:S,locationParams:T,viewportBottom:I,viewportTop:R});return A!==null?j&&$t(X(i,je($=>!$),xr(He(i)?1:2)),j):j==null||j(),A}),je(f=>f!==null)),u),{scrollIntoView:p}},We(Ht,ft,xn,vr,cr),{singleton:!0});function xi(e){return e===!1?!1:e==="smooth"?"smooth":"auto"}const ux=(e,r)=>typeof e=="function"?xi(e(r)):r&&xi(e),px=Le(([{listRefresh:e,totalCount:r,fixedItemSize:n,data:s},{atBottomState:o,isAtBottom:a},{scrollToIndex:i},{scrolledToInitialItem:c},{didMount:d,propsReady:u},{log:p},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const y=oe(!1),x=Te();let g=null;function b(j){Ee(i,{align:"end",behavior:j,index:"LAST"})}Ae(X(qe(X(ke(r),xr(1)),d),Re(ke(y),a,c,f),fe(([[j,T],w,S,N,R])=>{let I=T&&N,A="auto";return I&&(A=ux(w,S||R),I=I&&A!==!1),{followOutputBehavior:A,shouldFollow:I,totalCount:j}}),je(({shouldFollow:j})=>j)),({followOutputBehavior:j,totalCount:T})=>{g!==null&&(g(),g=null),He(n)!==void 0?requestAnimationFrame(()=>{He(p)("following output to ",{totalCount:T},et.DEBUG),b(j)}):g=$t(e,()=>{He(p)("following output to ",{totalCount:T},et.DEBUG),b(j),g=null})});function v(j){const T=$t(o,w=>{j&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&g===null&&(He(p)("scrolling to bottom due to increased size",{},et.DEBUG),b("auto"))});setTimeout(T,100)}Ae(X(qe(ke(y),r,u),je(([j,,T])=>j!==!1&&T),Ot(({value:j},[,T])=>({refreshed:j===T,value:T}),{refreshed:!1,value:0}),je(({refreshed:j})=>j),Re(y,r)),([,j])=>{He(c)&&v(j!==!1)}),Ae(x,()=>{v(He(y)!==!1)}),Ae(qe(ke(y),o),([j,T])=>{j!==!1&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&b("auto")});const k=oe(null),E=Te();return be(No(X(ke(s),fe(j=>(j==null?void 0:j.length)??0)),X(ke(r))),E),Ae(X(qe(X(E,xr(1)),d),Re(ke(k),c,f,h),fe(([[j,T],w,S,N,R])=>T&&S&&(w==null?void 0:w({context:R,totalCount:j,scrollingInProgress:N}))),je(j=>!!j),Kt(0)),j=>{g!==null&&(g(),g=null),He(n)!==void 0?requestAnimationFrame(()=>{He(p)("scrolling into view",{}),Ee(m,j)}):g=$t(e,()=>{He(p)("scrolling into view",{}),Ee(m,j),g=null})}),{autoscrollToBottom:x,followOutput:y,scrollIntoViewOnChange:k}},We(Ht,yn,xn,gn,dr,cr,ft,Ic,Lc)),fx=Le(([{data:e,firstItemIndex:r,gap:n,sizes:s},{initialTopMostItemIndex:o},{initialItemCount:a,listState:i},{didMount:c}])=>(be(X(c,Re(a),je(([,d])=>d!==0),Re(o,s,r,n,e),fe(([[,d],u,p,f,h,m=[]])=>Rc(d,u,p,f,h,m))),i),{}),We(Ht,gn,vr,dr),{singleton:!0}),hx=Le(([{didMount:e},{scrollTo:r},{listState:n}])=>{const s=oe(0);return Ae(X(e,Re(s),je(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{$t(X(n,xr(1),je(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ee(r,o)})})}),{initialScrollTop:s}},We(dr,ft,vr),{singleton:!0}),Ac=Le(([{scrollVelocity:e}])=>{const r=oe(!1),n=Te(),s=oe(!1);return be(X(e,Re(s,r,n),je(([o,a])=>a!==!1&&a!==void 0),fe(([o,a,i,c])=>{const{enter:d,exit:u}=a;if(i){if(u(o,c))return!1}else if(d(o,c))return!0;return i}),Oe()),r),Ae(X(qe(r,e,n),Re(s)),([[o,a,i],c])=>{o&&c!==!1&&c!==void 0&&c.change&&c.change(a,i)}),{isSeeking:r,scrollSeekConfiguration:s,scrollSeekRangeChanged:n,scrollVelocity:e}},We(yn),{singleton:!0}),la=Le(([{scrollContainerState:e,scrollTo:r}])=>{const n=Te(),s=Te(),o=Te(),a=oe(!1),i=oe(void 0);return be(X(qe(n,s),fe(([{scrollTop:c,viewportHeight:d},{offsetTop:u,listHeight:p}])=>({scrollHeight:p,scrollTop:Math.max(0,c-u),viewportHeight:d}))),e),be(X(r,Re(s),fe(([c,{offsetTop:d}])=>({...c,top:c.top+d}))),o),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:s}},We(ft)),mx=Le(([{sizeRanges:e,sizes:r},{headerHeight:n,scrollTop:s},{initialTopMostItemIndex:o},{didMount:a},{useWindowScroll:i,windowScrollContainerState:c,windowViewportRect:d}])=>{const u=Te(),p=oe(void 0),f=oe(null),h=oe(null);return be(c,f),be(d,h),Ae(X(u,Re(r,s,i,f,h,n)),([m,y,x,g,b,v,k])=>{const E=Qm(y.sizeTree);g&&b!==null&&v!==null&&(x=b.scrollTop-v.offsetTop),x-=k,m({ranges:E,scrollTop:x})}),be(X(p,je(ea),fe(xx)),o),be(X(a,Re(p),je(([,m])=>m!==void 0),Oe(),fe(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:p}},We(Ht,ft,gn,dr,la));function xx(e){return{align:"start",index:0,offset:e.scrollTop}}const gx=Le(([{topItemsIndexes:e}])=>{const r=oe(0);return be(X(r,je(n=>n>=0),fe(n=>Array.from({length:n}).map((s,o)=>o))),e),{topItemCount:r}},We(vr));function Pc(e){let r=!1,n;return(()=>(r||(r=!0,n=e()),n))}const yx=Pc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),vx=Le(([{deviation:e,scrollBy:r,scrollingInProgress:n,scrollTop:s},{isAtBottom:o,isScrolling:a,lastJumpDueToItemResize:i,scrollDirection:c},{listState:d},{beforeUnshiftWith:u,gap:p,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:y}])=>{const x=jt(X(d,Re(i),Ot(([,b,v,k],[{bottom:E,items:j,offsetBottom:T,totalCount:w},S])=>{const N=E+T;let R=0;return v===w&&b.length>0&&j.length>0&&(j[0].originalIndex===0&&b[0].originalIndex===0||(R=N-k,R!==0&&(R+=S))),[R,j,w,N]},[0,[],0,0]),je(([b])=>b!==0),Re(s,c,n,o,m,y),je(([,b,v,k,,,E])=>!E&&!k&&b!==0&&v===dn),fe(([[b],,,,,v])=>(v("Upward scrolling compensation",{amount:b},et.DEBUG),b))));function g(b){b>0?(Ee(r,{behavior:"auto",top:-b}),Ee(e,0)):(Ee(e,0),Ee(r,{behavior:"auto",top:-b}))}return Ae(X(x,Re(e,a)),([b,v,k])=>{k&&yx()?Ee(e,v-b):g(-b)}),Ae(X(qe(dt(a,!1),e,y),je(([b,v,k])=>!b&&!k&&v!==0),fe(([b,v])=>v),Kt(1)),g),be(X(f,fe(b=>({top:-b}))),r),Ae(X(u,Re(h,p),fe(([b,{groupIndices:v,lastSize:k,sizeTree:E},j])=>{function T(I){return I*(k+j)}if(v.length===0)return T(b);let w=0;const S=an(E,0);let N=0,R=0;for(;N<b;){N++,w+=S;let I=v.length===R+1?1/0:v[R+1]-v[R]-1;N+I>b&&(w-=S,I=b-N+1),N+=I,w+=T(I),R++}return w})),b=>{Ee(e,b),requestAnimationFrame(()=>{Ee(r,{top:b}),requestAnimationFrame(()=>{Ee(e,0),Ee(y,!1)})})}),{deviation:e}},We(ft,yn,vr,Ht,cr,na)),bx=Le(([e,r,n,s,o,a,i,c,d,u,p])=>({...e,...r,...n,...s,...o,...a,...i,...c,...d,...u,...p}),We(ia,fx,dr,Ac,Tc,hx,cx,la,Lc,cr,Ic)),$c=Le(([{data:e,defaultItemSize:r,firstItemIndex:n,fixedItemSize:s,fixedGroupSize:o,gap:a,groupIndices:i,heightEstimates:c,itemSize:d,sizeRanges:u,sizes:p,statefulTotalCount:f,totalCount:h,trackItemSizes:m},{initialItemFinalLocationReached:y,initialTopMostItemIndex:x,scrolledToInitialItem:g},b,v,k,E,{scrollToIndex:j},T,{topItemCount:w},{groupCounts:S},N])=>{const{listState:R,minOverscanItemCount:I,topItemsIndexes:A,rangeChanged:$,...B}=E;return be($,N.scrollSeekRangeChanged),be(X(N.windowViewportRect,fe(C=>C.visibleHeight)),b.viewportHeight),{data:e,defaultItemHeight:r,firstItemIndex:n,fixedItemHeight:s,fixedGroupHeight:o,gap:a,groupCounts:S,heightEstimates:c,initialItemFinalLocationReached:y,initialTopMostItemIndex:x,scrolledToInitialItem:g,sizeRanges:u,topItemCount:w,topItemsIndexes:A,totalCount:h,...k,groupIndices:i,itemSize:d,listState:R,minOverscanItemCount:I,scrollToIndex:j,statefulTotalCount:f,trackItemSizes:m,rangeChanged:$,...B,...N,...b,sizes:p,...v}},We(Ht,gn,ft,mx,px,vr,xn,vx,gx,Cc,bx));function kx(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 Ln=typeof document<"u"?ve.useLayoutEffect:ve.useEffect;function Mc(e,r,n){const s=Object.keys(r.required||{}),o=Object.keys(r.optional||{}),a=Object.keys(r.methods||{}),i=Object.keys(r.events||{}),c=ve.createContext({});function d(g,b){g.propsReady!==void 0&&Ee(g.propsReady,!1);for(const v of s){const k=g[r.required[v]];Ee(k,b[v])}for(const v of o)if(v in b){const k=g[r.optional[v]];Ee(k,b[v])}g.propsReady!==void 0&&Ee(g.propsReady,!0)}function u(g){return a.reduce((b,v)=>(b[v]=k=>{const E=g[r.methods[v]];Ee(E,k)},b),{})}function p(g){return i.reduce((b,v)=>(b[v]=Fm(g[r.events[v]]),b),{})}const f=ve.forwardRef(function(g,b){const{children:v,...k}=g,[E]=ve.useState(()=>ps(Bm(e),w=>{d(w,k)})),[j]=ve.useState(ai(p,E));Ln(()=>{for(const w of i)w in k&&Ae(j[w],k[w]);return()=>{Object.values(j).map(ta)}},[k,j,E]),Ln(()=>{d(E,k)}),ve.useImperativeHandle(b,oi(u(E)));const T=n;return t.jsx(c.Provider,{value:E,children:n!==void 0?t.jsx(T,{...kx([...s,...o,...i],k),children:v}):v})}),h=g=>{const b=ve.useContext(c);return ve.useCallback(v=>{Ee(b[g],v)},[b,g])},m=g=>{const b=ve.useContext(c)[g],v=ve.useCallback(k=>Ae(b,k),[b]);return ve.useSyncExternalStore(v,()=>He(b),()=>He(b))},y=g=>{const b=ve.useContext(c)[g],[v,k]=ve.useState(ai(He,b));return Ln(()=>Ae(b,E=>{E!==v&&k(oi(E))}),[b,v]),v},x=parseInt(ve.version)>=18?m:y;return{Component:f,useEmitter:(g,b)=>{const v=ve.useContext(c)[g];Ln(()=>Ae(v,b),[b,v])},useEmitterValue:x,usePublisher:h}}const Dc=ve.createContext(void 0),Fc=ve.createContext(void 0),As="-webkit-sticky",gi="sticky",ca=Pc(()=>{if(typeof document>"u")return gi;const e=document.createElement("div");return e.style.position=As,e.style.position===As?As:gi}),zc=typeof document<"u"?ve.useLayoutEffect:ve.useEffect;function Ps(e){return"self"in e}function jx(e){return"body"in e}function Bc(e,r,n,s=zr,o,a){const i=ve.useRef(null),c=ve.useRef(null),d=ve.useRef(null),u=ve.useCallback(h=>{let m,y,x;const g=h.target;if(jx(g)||Ps(g)){const v=Ps(g)?g:g.defaultView;x=a===!0?v.scrollX:v.scrollY,m=a===!0?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,y=a===!0?v.innerWidth:v.innerHeight}else x=a===!0?g.scrollLeft:g.scrollTop,m=a===!0?g.scrollWidth:g.scrollHeight,y=a===!0?g.offsetWidth:g.offsetHeight;const b=()=>{e({scrollHeight:m,scrollTop:Math.max(x,0),viewportHeight:y})};h.suppressFlushSync===!0?b():nf.flushSync(b),c.current!==null&&(x===c.current||x<=0||x===m-y)&&(c.current=null,r(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,r,a]);ve.useEffect(()=>{const h=o||i.current;return s(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{s(null),h.removeEventListener("scroll",u)}},[i,u,n,s,o]);function p(h){const m=i.current;if(!m||(a===!0?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const y=h.behavior==="smooth";let x,g,b;Ps(m)?(g=Math.max(or(m.document.documentElement,a===!0?"width":"height"),a===!0?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),x=a===!0?m.innerWidth:m.innerHeight,b=a===!0?window.scrollX:window.scrollY):(g=m[a===!0?"scrollWidth":"scrollHeight"],x=or(m,a===!0?"width":"height"),b=m[a===!0?"scrollLeft":"scrollTop"]);const v=g-x;if(h.top=Math.ceil(Math.max(Math.min(v,h.top),0)),Nc(x,g)||h.top===b){e({scrollHeight:g,scrollTop:b,viewportHeight:x}),y&&r(!0);return}y?(c.current=h.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,c.current=null,r(!0)},1e3)):c.current=null,a===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},left:h.top}),m.scrollTo(h)}function f(h){a===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},...h.top!==void 0?{left:h.top}:{}}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:p}}function da(e){return e}const wx=Le(()=>{const e=oe(c=>`Item ${c}`),r=oe(c=>`Group ${c}`),n=oe({}),s=oe(da),o=oe("div"),a=oe(zr),i=(c,d=null)=>dt(X(n,fe(u=>u[c]),Oe()),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")}}),Sx=Le(([e,r])=>({...e,...r}),We($c,wx)),Cx=({height:e})=>t.jsx("div",{style:{height:e}}),Ex={overflowAnchor:"none",position:ca(),zIndex:1},_c={overflowAnchor:"none"},Nx={..._c,display:"inline-block",height:"100%"},yi=ve.memo(function({showTopList:e=!1}){const r=Ce("listState"),n=Nt("sizeRanges"),s=Ce("useWindowScroll"),o=Ce("customScrollParent"),a=Nt("windowScrollContainerState"),i=Nt("scrollContainerState"),c=o||s?a:i,d=Ce("itemContent"),u=Ce("context"),p=Ce("groupContent"),f=Ce("trackItemSizes"),h=Ce("itemSize"),m=Ce("log"),y=Nt("gap"),x=Ce("horizontalDirection"),{callbackRef:g}=Wm(n,h,f,e?zr:c,m,y,o,x,Ce("skipAnimationFrameInResizeObserver")),[b,v]=ve.useState(0);ua("deviation",B=>{b!==B&&v(B)});const k=Ce("EmptyPlaceholder"),E=Ce("ScrollSeekPlaceholder")??Cx,j=Ce("ListComponent"),T=Ce("ItemComponent"),w=Ce("GroupComponent"),S=Ce("computeItemKey"),N=Ce("isSeeking"),R=Ce("groupIndices").length>0,I=Ce("alignToBottom"),A=Ce("initialItemFinalLocationReached"),$=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:b!==0?b:I?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:b!==0?b:I?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...A?{}:{visibility:"hidden"}};return!e&&r.totalCount===0&&k!==null&&k!==void 0?t.jsx(k,{...ct(k,u)}):t.jsx(j,{...ct(j,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:$,children:(e?r.topItems:r.items).map(B=>{const C=B.originalIndex,L=S(C+r.firstItemIndex,B.data,u);return N?l.createElement(E,{...ct(E,u),height:B.size,index:B.index,key:L,type:B.type||"item",...B.type==="group"?{}:{groupIndex:B.groupIndex}}):B.type==="group"?l.createElement(w,{...ct(w,u),"data-index":C,"data-item-index":B.index,"data-known-size":B.size,key:L,style:Ex},p(B.index,u)):l.createElement(T,{...ct(T,u),...Lx(T,B.data),"data-index":C,"data-item-group-index":B.groupIndex,"data-item-index":B.index,"data-known-size":B.size,key:L,style:x?Nx:_c},R?d(B.index,B.groupIndex,B.data,u):d(B.index,B.data,u))})})}),Rx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Tx={outline:"none",overflowX:"auto",position:"relative"},hs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:void 0}),Ix={position:ca(),top:0,width:"100%",zIndex:1};function ct(e,r){if(typeof e!="string")return{context:r}}function Lx(e,r){return{item:typeof e=="string"?void 0:r}}const Ax=ve.memo(function(){const e=Ce("HeaderComponent"),r=Nt("headerHeight"),n=Ce("HeaderFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Px=ve.memo(function(){const e=Ce("FooterComponent"),r=Nt("footerHeight"),n=Ce("HeaderFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null});function Oc({useEmitter:e,useEmitterValue:r,usePublisher:n}){return ve.memo(function({children:s,style:o,context:a,...i}){const c=n("scrollContainerState"),d=r("ScrollerComponent"),u=n("smoothScrollTargetReached"),p=r("scrollerRef"),f=r("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:y}=Bc(c,u,d,p,void 0,f);return e("scrollTo",y),e("scrollBy",h),t.jsx(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?Tx:Rx,...o},tabIndex:0,...i,...ct(d,a),children:s})})}function Wc({useEmitter:e,useEmitterValue:r,usePublisher:n}){return ve.memo(function({children:s,style:o,context:a,...i}){const c=n("windowScrollContainerState"),d=r("ScrollerComponent"),u=n("smoothScrollTargetReached"),p=r("totalListHeight"),f=r("deviation"),h=r("customScrollParent"),m=ve.useRef(null),y=r("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:b}=Bc(c,u,d,y,h);return zc(()=>{var v;return g.current=h||((v=m.current)==null?void 0:v.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",b),e("scrollBy",x),t.jsx(d,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...p!==0?{height:p+f}:void 0},...i,...ct(d,a),children:s})})}const $x=({children:e})=>{const r=ve.useContext(Dc),n=Nt("viewportHeight"),s=Nt("fixedItemHeight"),o=Ce("alignToBottom"),a=Ce("horizontalDirection"),i=ve.useMemo(()=>fc(n,d=>or(d,a?"width":"height")),[n,a]),c=yr(i,!0,Ce("skipAnimationFrameInResizeObserver"));return ve.useEffect(()=>{r&&(n(r.viewportHeight),s(r.itemHeight))},[r,n,s]),t.jsx("div",{"data-viewport-type":"element",ref:c,style:hs(o),children:e})},Mx=({children:e})=>{const r=ve.useContext(Dc),n=Nt("windowViewportRect"),s=Nt("fixedItemHeight"),o=Ce("customScrollParent"),a=mc(n,o,Ce("skipAnimationFrameInResizeObserver")),i=Ce("alignToBottom");return ve.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:a,style:hs(i),children:e})},Dx=({children:e})=>{const r=Ce("TopItemListComponent")??"div",n=Ce("headerHeight"),s={...Ix,marginTop:`${n}px`},o=Ce("context");return t.jsx(r,{style:s,...ct(r,o),children:e})},Fx=ve.memo(function(e){const r=Ce("useWindowScroll"),n=Ce("topItemsIndexes").length>0,s=Ce("customScrollParent"),o=Ce("context");return t.jsxs(s||r?_x:Bx,{...e,context:o,children:[n&&t.jsx(Dx,{children:t.jsx(yi,{showTopList:!0})}),t.jsxs(s||r?Mx:$x,{children:[t.jsx(Ax,{}),t.jsx(yi,{}),t.jsx(Px,{})]})]})}),{Component:zx,useEmitter:ua,useEmitterValue:Ce,usePublisher:Nt}=Mc(Sx,{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"}},Fx),Bx=Oc({useEmitter:ua,useEmitterValue:Ce,usePublisher:Nt}),_x=Wc({useEmitter:ua,useEmitterValue:Ce,usePublisher:Nt}),Ox=zx,Wx=Le(()=>{const e=oe(u=>t.jsxs("td",{children:["Item $",u]})),r=oe(null),n=oe(u=>t.jsxs("td",{colSpan:1e3,children:["Group ",u]})),s=oe(null),o=oe(null),a=oe({}),i=oe(da),c=oe(zr),d=(u,p=null)=>dt(X(a,fe(f=>f[u]),Oe()),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:c,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")}});We($c,Wx);ca();const vi={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Ux={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:bi,floor:Zn,max:en,min:$s,round:ki}=Math;function ji(e,r,n){return Array.from({length:r-e+1}).map((s,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Hx(e){return{...Ux,items:e}}function An(e,r){return e!==void 0&&e.width===r.width&&e.height===r.height}function Vx(e,r){return e!==void 0&&e.column===r.column&&e.row===r.row}const Gx=Le(([{increaseViewportBy:e,listBoundary:r,overscan:n,visibleRange:s},{footerHeight:o,headerHeight:a,scrollBy:i,scrollContainerState:c,scrollTo:d,scrollTop:u,smoothScrollTargetReached:p,viewportHeight:f},h,m,{didMount:y,propsReady:x},{customScrollParent:g,useWindowScroll:b,windowScrollContainerState:v,windowScrollTo:k,windowViewportRect:E},j])=>{const T=oe(0),w=oe(0),S=oe(vi),N=oe({height:0,width:0}),R=oe({height:0,width:0}),I=Te(),A=Te(),$=oe(0),B=oe(null),C=oe({column:0,row:0}),L=Te(),P=Te(),M=oe(!1),H=oe(0),le=oe(!0),G=oe(!1),W=oe(!1);Ae(X(y,Re(H),je(([D,U])=>U!==0)),()=>{Ee(le,!1)}),Ae(X(qe(y,le,R,N,H,G),je(([D,U,K,V,,Y])=>D&&!U&&K.height!==0&&V.height!==0&&!Y)),([,,,,D])=>{Ee(G,!0),oa(1,()=>{Ee(I,D)}),$t(X(u),()=>{Ee(r,[0,0]),Ee(le,!0)})}),be(X(P,je(D=>D!=null&&D.scrollTop>0),zt(0)),w),Ae(X(y,Re(P),je(([,D])=>D!=null)),([,D])=>{D&&(Ee(N,D.viewport),Ee(R,D.item),Ee(C,D.gap),D.scrollTop>0&&(Ee(M,!0),$t(X(u,xr(1)),U=>{Ee(M,!1)}),Ee(d,{top:D.scrollTop})))}),be(X(N,fe(({height:D})=>D)),f),be(X(qe(ke(N,An),ke(R,An),ke(C,(D,U)=>D!==void 0&&D.column===U.column&&D.row===U.row),ke(u)),fe(([D,U,K,V])=>({gap:K,item:U,scrollTop:V,viewport:D}))),L),be(X(qe(ke(T),s,ke(C,Vx),ke(R,An),ke(N,An),ke(B),ke(w),ke(M),ke(le),ke(H)),je(([,,,,,,,D])=>!D),fe(([D,[U,K],V,Y,J,te,de,,se,ue])=>{const{column:F,row:q}=V,{height:re,width:Q}=Y,{width:pe}=J;if(de===0&&(D===0||pe===0))return vi;if(Q===0){const Ie=aa(ue,D),ee=Ie+Math.max(de-1,0);return Hx(ji(Ie,ee,te))}const xe=Uc(pe,Q,F);let we,ge;se?U===0&&K===0&&de>0?(we=0,ge=de-1):(we=xe*Zn((U+q)/(re+q)),ge=xe*bi((K+q)/(re+q))-1,ge=$s(D-1,en(ge,xe-1)),we=$s(ge,en(0,we))):(we=0,ge=-1);const Ve=ji(we,ge,te),{bottom:Ye,top:Pe}=wi(J,V,Y,Ve),rt=bi(D/xe),Je=rt*re+(rt-1)*q-Ye;return{bottom:Ye,itemHeight:re,items:Ve,itemWidth:Q,offsetBottom:Je,offsetTop:Pe,top:Pe}})),S),be(X(B,je(D=>D!==null),fe(D=>D.length)),T),be(X(qe(N,R,S,C),je(([D,U,{items:K}])=>K.length>0&&U.height!==0&&D.height!==0),fe(([D,U,{items:K},V])=>{const{bottom:Y,top:J}=wi(D,V,U,K);return[J,Y]}),Oe(ln)),r);const Z=oe(!1);be(X(u,Re(Z),fe(([D,U])=>U||D!==0)),Z);const he=jt(X(qe(S,T),je(([{items:D}])=>D.length>0),Re(Z),je(([[D,U],K])=>{const V=D.items[D.items.length-1].index===U-1;return(K||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===U)&&V}),fe(([[,D]])=>D-1),Oe())),me=jt(X(ke(S),je(({items:D})=>D.length>0&&D[0].index===0),zt(0),Oe())),_=jt(X(ke(S),Re(M),je(([{items:D},U])=>D.length>0&&!U),fe(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),Oe(kc),Kt(0)));be(_,m.scrollSeekRangeChanged),be(X(I,Re(N,R,T,C),fe(([D,U,K,V,Y])=>{const J=Ec(D),{align:te,behavior:de,offset:se}=J;let ue=J.index;ue==="LAST"&&(ue=V-1),ue=en(0,ue,$s(V-1,ue));let F=Ao(U,Y,K,ue);return te==="end"?F=ki(F-U.height+K.height):te==="center"&&(F=ki(F-U.height/2+K.height/2)),se!==void 0&&se!==0&&(F+=se),{behavior:de,top:F}})),d);const ne=dt(X(S,fe(D=>D.offsetBottom+D.bottom)),0);return be(X(E,fe(D=>({height:D.visibleHeight,width:D.visibleWidth}))),N),{customScrollParent:g,data:B,deviation:$,footerHeight:o,gap:C,headerHeight:a,increaseViewportBy:e,initialItemCount:w,itemDimensions:R,overscan:n,restoreStateFrom:P,scrollBy:i,scrollContainerState:c,scrollHeight:A,scrollTo:d,scrollToIndex:I,scrollTop:u,smoothScrollTargetReached:p,totalCount:T,useWindowScroll:b,viewportDimensions:N,windowScrollContainerState:v,windowScrollTo:k,windowViewportRect:E,...m,gridState:S,horizontalDirection:W,initialTopMostItemIndex:H,totalListHeight:ne,...h,endReached:he,propsReady:x,rangeChanged:_,startReached:me,stateChanged:L,stateRestoreInProgress:M,...j}},We(ia,ft,yn,Ac,dr,la,cr));function Uc(e,r,n){return en(1,Zn((e+n)/(Zn(r)+n)))}function wi(e,r,n,s){const{height:o}=n;if(o===void 0||s.length===0)return{bottom:0,top:0};const a=Ao(e,r,n,s[0].index);return{bottom:Ao(e,r,n,s[s.length-1].index)+o,top:a}}function Ao(e,r,n,s){const o=Uc(e.width,n.width,r.column),a=Zn(s/o),i=a*n.height+en(0,a-1)*r.row;return i>0?i+r.row:i}const Kx=Le(()=>{const e=oe(f=>`Item ${f}`),r=oe({}),n=oe(null),s=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),a=oe(da),i=oe("div"),c=oe(zr),d=(f,h=null)=>dt(X(r,fe(m=>m[f]),Oe()),h),u=oe(!1),p=oe(!1);return be(ke(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:c,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),qx=Le(([e,r])=>({...e,...r}),We(Gx,Kx)),Yx=ve.memo(function(){const e=Ue("gridState"),r=Ue("listClassName"),n=Ue("itemClassName"),s=Ue("itemContent"),o=Ue("computeItemKey"),a=Ue("isSeeking"),i=Rt("scrollHeight"),c=Ue("ItemComponent"),d=Ue("ListComponent"),u=Ue("ScrollSeekPlaceholder"),p=Ue("context"),f=Rt("itemDimensions"),h=Rt("gap"),m=Ue("log"),y=Ue("stateRestoreInProgress"),x=Rt("reportReadyState"),g=yr(ve.useMemo(()=>b=>{const v=b.parentElement.parentElement.scrollHeight;i(v);const k=b.firstChild;if(k!==null){const{height:E,width:j}=k.getBoundingClientRect();f({height:E,width:j})}h({column:Si("column-gap",getComputedStyle(b).columnGap,m),row:Si("row-gap",getComputedStyle(b).rowGap,m)})},[i,f,h,m]),!0,!1);return zc(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),y?null:t.jsx(d,{className:r,ref:g,...ct(d,p),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(b=>{const v=o(b.index,b.data,p);return a?t.jsx(u,{...ct(u,p),height:e.itemHeight,index:b.index,width:e.itemWidth},v):l.createElement(c,{...ct(c,p),className:n,"data-index":b.index,key:v},s(b.index,b.data,p))})})}),Jx=ve.memo(function(){const e=Ue("HeaderComponent"),r=Rt("headerHeight"),n=Ue("headerFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,!1),o=Ue("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Xx=ve.memo(function(){const e=Ue("FooterComponent"),r=Rt("footerHeight"),n=Ue("headerFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,!1),o=Ue("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Qx=({children:e})=>{const r=ve.useContext(Fc),n=Rt("itemDimensions"),s=Rt("viewportDimensions"),o=yr(ve.useMemo(()=>a=>{s(a.getBoundingClientRect())},[s]),!0,!1);return ve.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:hs(!1),children:e})},Zx=({children:e})=>{const r=ve.useContext(Fc),n=Rt("windowViewportRect"),s=Rt("itemDimensions"),o=Ue("customScrollParent"),a=mc(n,o,!1);return ve.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:a,style:hs(!1),children:e})},eg=ve.memo(function({...e}){const r=Ue("useWindowScroll"),n=Ue("customScrollParent"),s=n||r?rg:tg,o=n||r?Zx:Qx,a=Ue("context");return t.jsx(s,{...e,...ct(s,a),children:t.jsxs(o,{children:[t.jsx(Jx,{}),t.jsx(Yx,{}),t.jsx(Xx,{})]})})}),{useEmitter:Hc,useEmitterValue:Ue,usePublisher:Rt}=Mc(qx,{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"}},eg),tg=Oc({useEmitter:Hc,useEmitterValue:Ue,usePublisher:Rt}),rg=Wc({useEmitter:Hc,useEmitterValue:Ue,usePublisher:Rt});function Si(e,r,n){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,r,et.WARN),r==="normal"?0:parseInt(r??"0",10)}const ng={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Vc={source:"Own",installed:"Installed"};function sg(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 og(e,r){const n=r?"true":"false";try{localStorage.setItem(e,n)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(e,n)}catch{}}function Ci({origin:e,count:r,filteredCount:n,updateCount:s,children:o}){const a=ng[e],[i,c]=l.useState(()=>sg(a)),d=l.useCallback(()=>{c(h=>{const m=!h;return og(a,m),m})},[a]),u=Vc[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(ig,{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(ag,{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 ag({origin:e,updateCount:r}){const[n,s]=l.useState(!1),o=Vc[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 ig({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 pa(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 lg({value:e,onChange:r,placeholder:n="Filter skills…",validationPattern:s,validationMessage:o="Invalid filter expression"}){const a=l.useRef(null),i=l.useId(),c=!!s&&e.trim()!==""&&!s.test(e);return l.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":c?!0:void 0,"aria-describedby":c?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"}}),c&&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 cg({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 dg({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 ug({skillId:e,trackedForUpdates:r}){let n=null;try{n=l.useContext(tc)}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 pg(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 vn(e){const{version:r,showPrefix:n=!0,size:s="md",source:o,pluginName:a}=e,i=typeof r=="string"?r.trim():"",c=i===""||i==="0.0.0"?"1.0.0":i,d=n&&!c.startsWith("v")?`v${c}`:c,u=s==="sm"?10:12,p=s==="sm"?1:2,f=s==="sm"?5:8,h=o==="registry"||o==="plugin",m=pg(o,c,a),y=e.title??m,x={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&&(x.fontStyle="italic"),t.jsx("span",{"data-testid":e["data-testid"]??"version-badge","data-version":c,"data-version-source":o,title:y,style:x,children:d})}const fg={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 Gc({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 hg({tenantName:e,variant:r="inline"}){const n=fg[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(Gc,{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 mg({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(Gc,{size:11}),r==="tag"?t.jsx("span",{children:"Private"}):null]})}function xg({skill:e,isSelected:r,onSelect:n,onContextMenu:s,dirty:o,repoVisibility:a,repoFullName:i}){const c=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:c,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(vn,{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(mg,{repoFullName:i??null}),e.isSymlink&&t.jsx(cg,{target:e.symlinkTarget??null}),t.jsx(dg,{skill:e}),t.jsx(ug,{skillId:`${e.plugin}/${e.skill}`,trackedForUpdates:e.trackedForUpdates??!0})]})}const tn=l.memo(xg),Kc={platformBaseUrl:"",authMode:"cookie",getAuthHeader:async()=>null},qc=l.createContext(Kc);function gg({value:e,children:r}){const n=l.useMemo(()=>({...Kc,...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(qc.Provider,{value:n,children:r})}function ht(){return l.useContext(qc)}function yg(e,r){const n=e.platformBaseUrl.replace(/\/+$/,""),s=r.startsWith("/")?r:`/${r}`;return`${n}${s}`}const Br=6e4,Ze={profile:()=>"account:profile",repos:()=>"account:repos",tokens:()=>"account:tokens",skills:()=>"account:skills",notifications:()=>"account:notifications",exports:()=>"account:exports"};async function mt(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 c=await e.getAuthHeader();c&&o.set("Authorization",c)}const a=e.authMode==="cookie"?"include":"omit",i=await s(yg(e,r),{...n,headers:o,credentials:a});if(!i.ok){let c="";try{c=await i.text()}catch{}const d=new Error(`Request to ${r} failed (${i.status}): ${c.slice(0,240)}`);throw d.status=i.status,d}if(i.status!==204)return await i.json()}function bn(){const e=ht();return St(Ze.profile(),()=>mt(e,"/api/v1/account/profile"),{ttl:Br})}function Yc(){const e=ht();return l.useCallback(async r=>{const n=await mt(e,"/api/v1/account/profile",{method:"PATCH",body:JSON.stringify(r)});return Be(Ze.profile()),n},[e])}function ms(){const e=ht();return St(Ze.repos(),async()=>vg(await mt(e,"/api/v1/account/repos")),{ttl:Br})}function fa(e){return(e==null?void 0:e.repos)??[]}function vg(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 Jc(){const e=ht();return l.useCallback(async r=>{await mt(e,`/api/v1/account/repos/${r}/resync`,{method:"POST"}),Be(Ze.repos())},[e])}function Xc(){const e=ht();return l.useCallback(async r=>{await mt(e,`/api/v1/account/repos/${r}`,{method:"DELETE"}),Be(Ze.repos())},[e])}function Qc(){const e=ht();return St(Ze.tokens(),async()=>bg(await mt(e,"/api/v1/account/tokens")),{ttl:Br})}function bg(e){return Array.isArray(e)?e:e.tokens??[]}function Zc(){const e=ht();return l.useCallback(async r=>{const n=await mt(e,"/api/v1/account/tokens",{method:"POST",body:JSON.stringify(r)});return Be(Ze.tokens()),n},[e])}function ed(){const e=ht();return l.useCallback(async r=>{await mt(e,`/api/v1/account/tokens/${r}`,{method:"DELETE"}),Be(Ze.tokens())},[e])}function td(){const e=ht();return St(Ze.notifications(),()=>mt(e,"/api/v1/account/notifications"),{ttl:Br})}function rd(){const e=ht();return l.useCallback(async r=>{const n=await mt(e,"/api/v1/account/notifications",{method:"PATCH",body:JSON.stringify(r)});return Be(Ze.notifications()),n},[e])}function kg(){const e=ht();return St(Ze.skills(),()=>mt(e,"/api/v1/account/skills/summary"),{ttl:Br})}function nd(){const e=ht();return St(Ze.exports(),async()=>(await mt(e,"/api/v1/account/export")).exports,{ttl:Br})}function sd(){const e=ht();return l.useCallback(async()=>{await mt(e,"/api/v1/account/sign-out-all",{method:"POST"}),Be(Ze.profile()),Be(Ze.repos()),Be(Ze.tokens()),Be(Ze.notifications()),Be(Ze.skills()),Be(Ze.exports())},[e])}function od(){const e=ht();return l.useCallback(async()=>{const r=await mt(e,"/api/v1/account/export",{method:"POST"});return Be(Ze.exports()),r},[e])}function ad(){const e=ht();return l.useCallback(async r=>{await mt(e,"/api/v1/account/delete",{method:"POST",body:JSON.stringify({confirmHandle:r})})},[e])}function jg(){return{profile:bn(),repos:ms(),tokens:Qc(),skills:kg(),notifications:td(),exports:nd(),updateProfile:Yc(),resyncRepo:Jc(),disconnectRepo:Xc(),createToken:Zc(),revokeToken:ed(),updateNotificationPrefs:rd(),signOutAll:sd(),requestExport:od(),deleteAccount:ad()}}const wg=/^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/?#]+?)(?:\.git)?\/?$/i,Sg=/^git@github\.com:([^/]+)\/([^/?#]+?)(?:\.git)?$/i;function kn(e){if(!e)return null;const r=e.trim(),n=wg.exec(r);if(n)return`${n[1].toLowerCase()}/${n[2].toLowerCase()}`;const s=Sg.exec(r);return s?`${s[1].toLowerCase()}/${s[2].toLowerCase()}`:null}function id(e){const r=new Map;for(const n of e)r.set(n.repoFullName.toLowerCase(),n);return r}function Cg(e,r){const n=kn(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 Eg(e){const{data:r}=ms(),n=l.useMemo(()=>id(fa(r)),[r]);return Cg(e,n)}function ld(){const{data:e,loading:r}=ms(),n=fa(e);return{lookup:l.useMemo(()=>id(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 cd({plugin:e,skills:r,selectedKey:n,onSelect:s,onContextMenu:o,dirtySkillIds:a,repoVisibilityLookup:i}){var p;const c=[...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:c.map(f=>{const h=!!n&&n.plugin===f.plugin&&n.skill===f.skill,m=i?kn(f.repoUrl):null,y=m?i.get(m)??null:null,x=y?y.isPrivate?"private":"public":"unknown";return t.jsx("div",{role:"listitem",children:t.jsx(tn,{skill:f,isSelected:h,onSelect:()=>s(f),onContextMenu:o,dirty:a==null?void 0:a.has(`${f.plugin}/${f.skill}`),repoVisibility:x,repoFullName:(y==null?void 0:y.repoFullName)??null})},`${f.plugin}/${f.skill}`)})})]})}function Ng(e,r){if(!r)return!1;const n=kn(e.repoUrl);if(!n)return!1;const s=r.get(n);return(s==null?void 0:s.isPrivate)===!0}function Rg(e,r){const n=[],s=[];let o=0,a=0;for(const[i,c]of e){const d=[],u=[];for(const p of c)Ng(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 Tg(e){try{const r=localStorage.getItem(e);if(r!=null)return r==="true"}catch{}return!1}function Ig(e,r){try{localStorage.setItem(e,r?"true":"false")}catch{}}function Lg({items:e,agentId:r,sectionName:n,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:c,children:d}){const{privateItems:u,publicItems:p,privateCount:f,publicCount:h}=Rg(e,s);if(f===0||h===0)return t.jsx(t.Fragment,{children:d});const m=`vskill-sidebar-${r}-section-${n}-private-collapsed`,y=`vskill-sidebar-${r}-section-${n}-public-collapsed`;return t.jsxs("div",{"data-testid":"section-privacy-subgroups",children:[t.jsx(Ei,{testId:"sidebar-subgroup-private",storageKey:m,icon:"🔒",label:"Private repos",count:f,items:u,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:c}),t.jsx(Ei,{testId:"sidebar-subgroup-public",storageKey:y,icon:"🌐",label:"Public repos",count:h,items:p,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:c})]})}function Ei({testId:e,storageKey:r,icon:n,label:s,count:o,items:a,repoVisibilityLookup:i,selectedKey:c,onSelect:d,onContextMenu:u,dirtySkillIds:p}){const[f,h]=l.useState(()=>Tg(r)),m=l.useCallback(()=>{h(x=>{const g=!x;return Ig(r,g),g})},[r]),y=`${e}-group`;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","data-testid":e,"aria-expanded":!f,"aria-controls":y,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:y,role:"group",children:a.map(([x,g])=>t.jsx(cd,{plugin:x,skills:g,selectedKey:c,onSelect:d,onContextMenu:u,dirtySkillIds:p,repoVisibilityLookup:i},x))})]})}function Ag(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 Ms({skills:e,pluginName:r,initialCollapsed:n=!1,persistKey:s,renderSkill:o,headerActionSlot:a,forceOpen:i=!1}){var m;const c=r??((m=e[0])==null?void 0:m.pluginName)??"unknown-plugin",[d,u]=l.useState(()=>Ag(s,n)),p=i?!1:d,f=l.useCallback(()=>{u(y=>{const x=!y;if(s&&typeof window<"u")try{window.localStorage.setItem(s,String(x))}catch{}return x})},[s]),h=p?"▸":"▾";return t.jsxs("div",{"data-vskill-plugin-tree":c,role:"group","aria-label":`${c} (${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:c}),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(y=>t.jsx("div",{"data-vskill-plugin-skill":y.pluginNamespace??y.skill,children:o(y)},`${y.pluginNamespace??y.skill}`))})]})}function qn({open:e,title:r,body:n,confirmLabel:s="Confirm",cancelLabel:o="Cancel",variant:a="default",onConfirm:i,onCancel:c}){const d=l.useRef(null),u=l.useRef(null),p=l.useRef(null);if(l.useEffect(()=>{if(e)return p.current=document.activeElement??null,requestAnimationFrame(()=>{var y;(y=u.current)==null||y.focus()}),()=>{var y,x;(x=(y=p.current)==null?void 0:y.focus)==null||x.call(y),p.current=null}},[e]),l.useEffect(()=>{if(!e)return;function y(x){if(x.key==="Escape"){x.preventDefault(),c();return}if(x.key==="Tab"&&d.current){const g=d.current.querySelectorAll("button:not([disabled])");if(g.length===0)return;const b=g[0],v=g[g.length-1];x.shiftKey&&document.activeElement===b?(x.preventDefault(),v.focus()):!x.shiftKey&&document.activeElement===v&&(x.preventDefault(),b.focus())}}return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[e,c]),!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:y=>{y.target===y.currentTarget&&c()},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:c,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 Pg(e){const r=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return r.includes("mac")?"system Trash":r.includes("win")?"Recycle Bin":"Trash"}function Ds(e,r){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function $g({pluginName:e,enabled:r,onAfterAction:n}){const[s,o]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[u,p]=l.useState(!1),f=l.useRef(null);l.useEffect(()=>{if(!s)return;function y(x){f.current&&!f.current.contains(x.target)&&o(!1)}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[s]);async function h(y){i(y),d(null);try{const x=await fetch(`/api/plugins/${encodeURIComponent(e)}/${y}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),g=await x.json().catch(()=>({}));if(!x.ok||!g.ok){const b=g.error??`${y} failed (${x.status})`;d(b),y==="uninstall"&&Ds(`Failed to uninstall ${e}: ${b}`,"error");return}if(y==="uninstall"){const b=g.fallback==="orphan-cache-removed"?`Removed orphaned ${e}`:`Uninstalled ${e}`;Ds(b,"success")}Be("skills"),uc(),n==null||n(),o(!1)}catch(x){const g=x instanceof Error?x.message:String(x);d(g),y==="uninstall"&&Ds(`Failed to uninstall ${e}: ${g}`,"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:y=>{y.stopPropagation(),o(x=>!x)},"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:y=>{y.currentTarget.style.color="var(--text-primary)",y.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:y=>{y.currentTarget.style.color="var(--text-tertiary)",y.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(Fs,{onClick:()=>void h("disable"),disabled:a!==null,busy:a==="disable",label:"Disable",hint:"Keep installed, turn off"}):t.jsx(Fs,{onClick:()=>void h("enable"),disabled:a!==null,busy:a==="enable",label:"Enable",hint:"Activate plugin"}),t.jsx(Fs,{onClick:m,disabled:a!==null,busy:a==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),c&&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:c})]}),t.jsx(qn,{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 Fs({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 Mg=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function Dg({anchorSkillDir:e,candidateLabel:r,initialName:n,initialDescription:s,onConverted:o,onCancel:a}){const[i,c]=l.useState(n),[d,u]=l.useState(s??""),[p,f]=l.useState(!1),[h,m]=l.useState(null),[y,x]=l.useState(null),g=Mg.test(i),b=p||!g,v=l.useCallback(async k=>{if(k.preventDefault(),!b){f(!0),m(null),x(null);try{const E=await ce.convertToPlugin({anchorSkillDir:e,pluginName:i.trim(),description:d.trim()});o({pluginDir:E.pluginDir,manifestPath:E.manifestPath,validation:E.validation})}catch(E){if(E instanceof qt){m(E.message);const j=E.details;j&&typeof j.stderr=="string"&&x(j.stderr)}else m(E instanceof Error?E.message:String(E));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:k=>{k.target===k.currentTarget&&!p&&a()},children:t.jsxs("form",{onSubmit:v,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:k=>c(k.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}}),!g&&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:k=>u(k.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}),y&&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:y})]}),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 Ni({name:e,count:r,className:n,variant:s,collapsed:o,onToggle:a,action:i}){const c=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 ${c}`,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:c,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(Fg,{label:i.label,title:i.title,icon:i.icon,onClick:i.onClick,accent:c})})]});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 Fg({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 zg(){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 Bg(e){const r=e.key.split("+").map(c=>c.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 c of r.slice(0,-1)){const d=c.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 _g(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 Og(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 Po(e,r={}){const{enabled:n=!0,target:s}=r,o=l.useRef([]),a=Array.isArray(e)?e:[e];o.current=a.map(Bg),l.useEffect(()=>{if(!n)return;const i=s??(typeof window<"u"?window:void 0);if(!i)return;function c(d){const u=d,p=_g(u.target);for(const f of o.current){if(!Og(u,f))continue;const h=f.meta||f.ctrl||f.alt;if(!(p&&!f.allowInInputs&&!h)){f.handler(u);return}}}return i.addEventListener("keydown",c),()=>{i.removeEventListener("keydown",c)}},[n,s])}function dd(){const{data:e,loading:r,error:n,revalidate:s}=St("project-github-status",()=>ce.getProjectGitHubStatus());return{status:e,loading:r,error:n,revalidate:s}}function Wg(e){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${e}`)==="true"}catch{return!1}}function Ug({projectRoot:e}){const{status:r,loading:n}=dd();if(n||!r||r.status==="github"||Wg(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 Hg=3e4;async function Vg(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 ud=l.forwardRef(function({folder:r,fetchRepoInfo:n=Vg,pollIntervalMs:s=Hg,tier:o,onUpgradeClick:a,onConnectPrivateClick:i},c){const d=o==="pro"||o==="enterprise"?o:"free",u=d!=="free",[p,f]=l.useState(null),[h,m]=l.useState(!1),[y,x]=l.useState(null),g=l.useRef(n);g.current=n;const b=async()=>{if(!r){f(null);return}m(!0),x(null);try{const v=await g.current(r);f(v)}catch(v){x(v instanceof Error?v.message:String(v))}finally{m(!1)}};return l.useImperativeHandle(c,()=>({refresh:b}),[r]),l.useEffect(()=>{if(!r){f(null);return}let v=!1,k=null;const E=async()=>{if(!v&&!(typeof document<"u"&&document.visibilityState!=="visible"))try{const T=await g.current(r);v||f(T)}catch(T){v||x(T instanceof Error?T.message:String(T))}};E(),k=setInterval(E,s);const j=()=>{typeof document<"u"&&document.visibilityState==="visible"&&E()};return typeof document<"u"&&document.addEventListener("visibilitychange",j),()=>{v=!0,k!==null&&clearInterval(k),typeof document<"u"&&document.removeEventListener("visibilitychange",j)}},[r,s]),r?y?t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"error",style:Ur,children:t.jsxs("span",{style:{color:"var(--color-error, #c0392b)",fontSize:12},children:["Couldn't load repo info: ",y]})}):p?!p.name&&p.sync_state.kind==="no_remote"?t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"not-git",style:Ur,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":d,style:Ur,children:[t.jsx("span",{style:Xg,"data-testid":"repo-name",children:p.name??"Local-only"}),p.branch?t.jsxs("span",{style:Qg,"data-testid":"repo-branch",children:[t.jsx(Kg,{})," ",p.branch]}):null,t.jsx(Jg,{state:p.sync_state}),t.jsx(Gg,{isPrivate:p.is_private,isPaid:u,onUpgradeClick:a,onConnectPrivateClick:i})]}):t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"loading","aria-busy":h||void 0,style:Ur,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:Ur,children:t.jsx("span",{style:{color:"var(--color-muted, #999)",fontSize:12},children:"No project folder selected"})})});function Gg({isPrivate:e,isPaid:r,onUpgradeClick:n,onConnectPrivateClick:s}){return e!==!0?t.jsx(Yg,{isPrivate:e}):r?t.jsxs("span",{style:{..._t,color:"var(--color-private, #b58900)"},"data-testid":"visibility-pill","data-visibility":"private","aria-label":"Private repository",children:[t.jsx($o,{})," private",s?t.jsx("button",{type:"button",onClick:s,"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:ey,children:"Connect"}):null]}):t.jsxs("span",{style:{..._t,color:"var(--color-private, #b58900)"},"data-testid":"visibility-pill","data-visibility":"private-locked","aria-label":"Private repository — Pro feature",children:[t.jsx($o,{})," private",t.jsx("button",{type:"button",onClick:n,"data-testid":"repo-upgrade-chip",title:"Upgrade for private repo connections.","aria-label":"Upgrade to Pro for private repository connections",style:Zg,children:"Pro"})]})}function Kg(){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 $o(){return t.jsxs("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("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function qg(){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 Yg({isPrivate:e}){return e===null?t.jsx("span",{style:{..._t,color:"var(--color-muted, #999)"},"data-testid":"visibility-pill","data-visibility":"unknown",children:"unknown"}):e?t.jsxs("span",{style:{..._t,color:"var(--color-private, #b58900)"},"data-testid":"visibility-pill","data-visibility":"private","aria-label":"Private repository",children:[t.jsx($o,{})," private"]}):t.jsxs("span",{style:{..._t,color:"var(--color-public, #2aa198)"},"data-testid":"visibility-pill","data-visibility":"public","aria-label":"Public repository",children:[t.jsx(qg,{})," public"]})}function Jg({state:e}){return e.kind==="clean"?t.jsx("span",{style:{..._t,color:"var(--color-clean, #859900)"},"data-testid":"sync-state-pill","data-sync":"clean",children:"in sync"}):e.kind==="no_remote"?t.jsx("span",{style:{..._t,color:"var(--color-muted, #999)"},"data-testid":"sync-state-pill","data-sync":"no_remote",children:"no remote"}):e.kind==="dirty"?t.jsxs("span",{style:{..._t,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:{..._t,color:"var(--color-ahead, #268bd2)"},"data-testid":"sync-state-pill","data-sync":"ahead",children:["+",e.count," ahead"]}):t.jsxs("span",{style:{..._t,color:"var(--color-behind, #6c71c4)"},"data-testid":"sync-state-pill","data-sync":"behind",children:["-",e.count," behind"]})}const Ur={display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap",fontSize:12,fontFamily:"var(--font-system, -apple-system, system-ui)"},Xg={fontWeight:500,color:"var(--color-text, #333)"},Qg={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},_t={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},Zg={marginLeft:4,padding:"0px 5px",borderRadius:9999,border:"none",background:"var(--color-pro-bg, #cb4b16)",color:"var(--color-pro-fg, #ffffff)",fontSize:9,fontWeight:600,letterSpacing:.4,textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},ey={marginLeft:4,padding:"0px 6px",borderRadius:9999,border:"1px solid currentColor",background:"transparent",color:"inherit",fontSize:10,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},ty=200;function ry(e){return e.scope==="own"||e.scope==="installed"||e.scope==="global"?e.scope:e.origin==="installed"?"installed":"own"}function ny(e,r){const n={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const i of e){const c=i.scopeV2??(i.scope==="installed"?"available-project":i.scope==="global"?"available-personal":"authoring-project");c==="available-project"?n.availableProject.push(i):c==="available-personal"?n.availablePersonal.push(i):c==="available-plugin"?n.availablePlugin.push(i):c==="authoring-plugin"?n.authoringPlugin.push(i):n.authoringProject.push(i)}function s(i){const c=i.filter(p=>pa(p,r)),d={};for(const p of c){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:c.length,byPlugin:u}}const o=s(n.authoringProject),a=o.byPlugin.filter(([i,c])=>c.length>=2&&i.trim().length>=2).map(([i,c])=>({groupKey:i,skills:c,anchorSkillDir:c[0].dir}));return{availableProject:s(n.availableProject),availablePersonal:s(n.availablePersonal),availablePlugin:s(n.availablePlugin),authoringProject:o,authoringPlugin:s(n.authoringPlugin),authoringCandidatePlugins:a}}function sy(e,r){const n=[],s=[],o=[];for(const i of e){const c=ry(i);c==="global"?o.push(i):c==="installed"?s.push(i):n.push(i)}function a(i){var p;const c=i.filter(f=>pa(f,r)),d={};for(const f of c)(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:c.length,byPlugin:u}}return{own:a(n),installed:a(s),global:a(o)}}function oy(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=>pa(p,r)),c={};for(const p of i)(c[u=p.plugin]||(c[u]=[])).push(p);const d=Object.entries(c).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 ay({skills:e,selectedKey:r,onSelect:n,isLoading:s,error:o,onRetry:a,onContextMenu:i,outdatedByOrigin:c,activeAgentId:d,outdatedByScope:u,topSlot:p,revealSkillId:f,onRevealComplete:h,dirtySkillIds:m,onSkillsChanged:y}){const[x,g]=l.useState(null),b=!!d||e.some(D=>D.scope!==void 0&&D.scope!==null),v=d??"claude-cli",[k,E]=l.useState(""),j=l.useDeferredValue(k),T=l.useMemo(()=>sy(e,j),[e,j]),w=l.useMemo(()=>ny(e,j),[e,j]),S=v==="claude-code",{plugins:N}=Lm(),R=S?{plugins:N??[]}:void 0,I=l.useMemo(()=>{const D=new Map;for(const U of(R==null?void 0:R.plugins)??[]){const K=D.get(U.name);D.set(U.name,!!K||!!U.enabled)}return D},[R==null?void 0:R.plugins]),[A,$]=l.useState(()=>Mo(`vskill-sidebar-${v}-group-available-collapsed`)),[B,C]=l.useState(()=>Mo(`vskill-sidebar-${v}-group-authoring-collapsed`)),L=l.useCallback(D=>{$(D);try{window.localStorage.setItem(`vskill-sidebar-${v}-group-available-collapsed`,String(D))}catch{}},[v]),P=l.useCallback(D=>{C(D);try{window.localStorage.setItem(`vskill-sidebar-${v}-group-authoring-collapsed`,String(D))}catch{}},[v]),{own:M,installed:H}=l.useMemo(()=>oy(e,j),[e,j]),G=T.own.filtered+T.installed.filtered+T.global.filtered>=ty,{lookup:W}=ld(),Z=l.useMemo(()=>{const D=U=>{const K=[];for(const[,V]of U){const Y=[...V].sort((J,te)=>J.skill.localeCompare(te.skill));K.push(...Y)}return K};return b?[...D(T.own.byPlugin),...D(T.installed.byPlugin),...D(T.global.byPlugin)]:[...D(M.byPlugin),...D(H.byPlugin)]},[b,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,M.byPlugin,H.byPlugin]),he=l.useMemo(()=>r?Z.findIndex(D=>D.plugin===r.plugin&&D.skill===r.skill):-1,[Z,r]),me=l.useCallback(D=>{if(Z.length===0)return;const U=he<0?D>0?0:Z.length-1:Math.min(Math.max(he+D,0),Z.length-1);n(Z[U])},[Z,he,n]),_=l.useMemo(()=>{if(!f)return null;const[D,U]=f.split("/");if(!D||!U)return null;const K=e.find(J=>J.plugin===D&&J.skill===U);if(!K)return{plugin:D,skill:U,bucket:null,pluginName:null};const V=K.source==="plugin"?"plugin":"project",Y=V==="plugin"?K.pluginName??D:null;return{plugin:D,skill:U,bucket:V,pluginName:Y}},[f,e]),ne=l.useRef(null);return l.useEffect(()=>{if(!f){ne.current=null;return}if(ne.current===f)return;const D=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/["\\]/g,"\\$&"),U=document.querySelector(`[data-skill-id="${D}"]`);U&&(ne.current=f,U.scrollIntoView({behavior:"smooth",block:"nearest"}),h==null||h())},[f,h,e]),Po([{key:"j",handler:()=>me(1)},{key:"k",handler:()=>me(-1)},{key:"Enter",handler:()=>{he>=0&&n(Z[he])}}],{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(lg,{value:k,onChange:E}),s&&t.jsx(fy,{}),!s&&o&&t.jsx(hy,{error:o,onRetry:a}),!s&&!o&&b&&t.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[t.jsx(Ni,{name:O.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:A,onToggle:L,count:w.availableProject.total+w.availablePersonal.total+w.availablePlugin.total}),!A&&t.jsxs(t.Fragment,{children:[t.jsx(Hr,{label:O.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${v}-available-project-collapsed`,count:w.availableProject.total,filteredCount:k?w.availableProject.filtered:null,updateCount:(u==null?void 0:u.installed)??(c==null?void 0:c.installed),headerRightSlot:S?t.jsx(xy,{projectRoot:v}):null,children:w.availableProject.filtered===0?t.jsx(Ti,{queryActive:!!k,agentId:v}):t.jsx(Vr,{items:w.availableProject.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"available-project"})}),t.jsx(Hr,{label:O.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${v}-available-personal-collapsed`,count:w.availablePersonal.total,filteredCount:k?w.availablePersonal.filtered:null,updateCount:u==null?void 0:u.global,children:w.availablePersonal.filtered===0?t.jsx(ly,{queryActive:!!k,agentId:v}):t.jsx(Vr,{items:w.availablePersonal.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"available-personal"})}),S&&t.jsxs(Hr,{label:O.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${v}-available-plugin-collapsed`,count:w.availablePlugin.total,filteredCount:k?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(cy,{queryActive:!!k,hasInstalled:w.availablePlugin.total>0}):w.availablePlugin.byPlugin.map(([D,U])=>t.jsx(Ms,{pluginName:D,skills:U,persistKey:`vskill-plugin-available-${D}-collapsed`,headerActionSlot:S?t.jsx($g,{pluginName:D,enabled:I.get(D)??!0}):void 0,renderSkill:K=>t.jsx(tn,{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-${D}`))]})]}),t.jsx(py,{}),t.jsx(Ni,{name:O.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:_?!1:B,onToggle:P,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"}}))}}}),(!B||_)&&t.jsxs(t.Fragment,{children:[t.jsx(Hr,{label:O.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${v}-authoring-project-collapsed`,count:w.authoringProject.total,filteredCount:k?w.authoringProject.filtered:null,updateCount:(u==null?void 0:u.own)??(c==null?void 0:c.source),forceOpen:(_==null?void 0:_.bucket)==="project",children:w.authoringProject.filtered===0?t.jsx(Ri,{queryActive:!!k}):t.jsxs(t.Fragment,{children:[w.authoringCandidatePlugins.map(D=>t.jsx(Ms,{pluginName:D.groupKey,skills:D.skills,persistKey:`vskill-candidate-plugin-${D.groupKey}-collapsed`,headerActionSlot:t.jsx("button",{type:"button",onClick:U=>{U.stopPropagation(),g({candidateLabel:D.groupKey,initialName:D.groupKey,anchorSkillDir:D.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(tn,{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-${D.groupKey}`)),t.jsx(Vr,{items:w.authoringProject.byPlugin.filter(([D])=>!w.authoringCandidatePlugins.some(U=>U.groupKey===D)),selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"authoring-project"})]})}),S&&t.jsx(Hr,{label:O.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${v}-authoring-plugin-collapsed`,count:w.authoringPlugin.total,filteredCount:k?w.authoringPlugin.filtered:null,forceOpen:(_==null?void 0:_.bucket)==="plugin",children:w.authoringPlugin.filtered===0?t.jsx(dy,{queryActive:!!k,hasSources:w.authoringPlugin.total>0,candidates:w.authoringCandidatePlugins,onPromote:D=>g({candidateLabel:D.groupKey,initialName:D.groupKey,anchorSkillDir:D.anchorSkillDir})}):w.authoringPlugin.byPlugin.map(([D,U])=>t.jsx(Ms,{pluginName:D,skills:U,persistKey:`vskill-plugin-authoring-${D}-collapsed`,forceOpen:(_==null?void 0:_.bucket)==="plugin"&&_.pluginName===D,renderSkill:K=>t.jsx(tn,{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-${D}`))})]})]}),!s&&!o&&!b&&t.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[t.jsx(Ci,{origin:"source",count:M.total,filteredCount:k?M.filtered:null,updateCount:c==null?void 0:c.source,children:M.filtered===0?t.jsx(Ri,{queryActive:!!k}):t.jsx(Vr,{items:M.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"own"})}),t.jsx(uy,{}),t.jsx(Ci,{origin:"installed",count:H.total,filteredCount:k?H.filtered:null,updateCount:c==null?void 0:c.installed,children:H.filtered===0?t.jsx(Ti,{queryActive:!!k}):t.jsx(Vr,{items:H.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"installed"})})]}),x&&t.jsx(Dg,{anchorSkillDir:x.anchorSkillDir,candidateLabel:x.candidateLabel,initialName:x.initialName,onCancel:()=>g(null),onConverted:D=>{g(null),y==null||y(),D.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 Mo(e){if(typeof window>"u")return!1;try{return window.localStorage.getItem(e)==="true"}catch{return!1}}function Hr({label:e,storageKey:r,count:n,filteredCount:s,updateCount:o,children:a,forceOpen:i=!1,headerRightSlot:c}){const[d,u]=l.useState(()=>Mo(r)),p=i?!1:d,f=l.useCallback(()=>{u(m=>{const y=!m;if(typeof window<"u")try{window.localStorage.setItem(r,String(y))}catch{}return y})},[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":""]})]}),c]}),!p&&t.jsx("div",{style:{paddingLeft:18},children:a})]})}function iy(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 Vr({items:e,selectedKey:r,onSelect:n,onContextMenu:s,useVirtual:o,dirtySkillIds:a,repoVisibilityLookup:i,agentId:c,sectionName:d}){if(o){const p=iy(e);return t.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:t.jsx(Ox,{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,y=!!r&&r.plugin===m.plugin&&r.skill===m.skill,x=i?kn(m.repoUrl):null,g=x?i.get(x)??null:null,b=g?g.isPrivate?"private":"public":"unknown";return t.jsx(tn,{skill:m,isSelected:y,onSelect:()=>n(m),onContextMenu:s,dirty:a==null?void 0:a.has(`${m.plugin}/${m.skill}`),repoVisibility:b,repoFullName:(g==null?void 0:g.repoFullName)??null})}})})}const u=e.map(([p,f])=>t.jsx(cd,{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(Lg,{items:e,agentId:c??"claude-cli",sectionName:d??"section",repoVisibilityLookup:i,selectedKey:r,onSelect:n,onContextMenu:s,dirtySkillIds:a,children:u})})}function Ri({queryActive:e}){return e?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:"No skills yet.",body:t.jsxs(t.Fragment,{children:["Create one with ",t.jsx(Ar,{children:"vskill new"})," or the"," ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ti({queryActive:e,agentId:r}){return e?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:t.jsxs(t.Fragment,{children:["Run ",t.jsx(Ar,{children:"vskill install <skill>"})," to add one."]})})}function ly({queryActive:e,agentId:r}){return e?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:`No global skills for ${r}.`,body:t.jsxs(t.Fragment,{children:["Run ",t.jsx(Ar,{children:"vskill install --global <skill>"})," to add one."]})})}function cy({queryActive:e,hasInstalled:r}){return e&&r?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:"No plugin skills installed yet.",body:t.jsxs(t.Fragment,{children:["Click ",t.jsx(Ar,{children:"Browse marketplaces…"})," above to add one."]})})}function dy({queryActive:e,hasSources:r,candidates:n,onPromote:s}){return e&&r?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsxs(t.Fragment,{children:[t.jsx(Ut,{headline:"No plugin sources in this project.",body:t.jsxs(t.Fragment,{children:["Add ",t.jsx(Ar,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",t.jsx(Ar,{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 Ut({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 Ar({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 uy(){return t.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function py(){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 fy(){return t.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(e=>t.jsx(zg,{},e))})}function hy({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:my(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 my(e){const r=e.split(`
18
+ }`})]})}const Ts="#F25F1C";function Xa(){typeof window>"u"||(window.location.hash="#/")}function rm({onHome:e}){const[r,n]=l.useState(!1),[s,o]=l.useState(!1),a=c=>{c.metaKey||c.ctrlKey||c.shiftKey||c.button!==0||(c.preventDefault(),Xa(),e==null||e())},i=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Xa(),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:Ts}),t.jsx("path",{d:"M9.75 19.4h4.5a2.25 2.25 0 11-4.5 0z",fill:Ts}),t.jsx("circle",{cx:"18.5",cy:"5.5",r:"2.75",fill:Ts,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 Qa=l.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 nm({toast:e,onDismiss:r}){const[n,s]=l.useState(!0),o=l.useRef(null);l.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 sm({toasts:e,onDismiss:r,liveMessage:n,liveAssertiveMessage:s}){return t.jsxs(t.Fragment,{children:[t.jsx(Qa,{politeness:"polite",message:n}),t.jsx(Qa,{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(nm,{toast:o,onDismiss:r})},o.id))})]})}const ic=l.createContext(null);function cs(){const e=l.useContext(ic);if(!e)throw new Error("useToast must be used inside <ToastProvider>.");return e}function om({children:e,maxVisible:r=4,defaultDurationMs:n=4e3}){const[s,o]=l.useState([]),[a,i]=l.useState(""),[c,d]=l.useState(""),u=l.useRef(new Map),p=l.useCallback(g=>{const b=u.current.get(g);b&&(clearTimeout(b),u.current.delete(g)),o(v=>v.filter(k=>k.id!==g))},[]),f=l.useCallback((g,b)=>{if(b<=0)return;const v=setTimeout(()=>{p(g)},b);u.current.set(g,v)},[p]),h=l.useCallback(g=>{const b=g.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,v={id:b,message:g.message,severity:g.severity??"info",durationMs:g.durationMs??n,action:g.action};return o(k=>[...k,v]),v.severity==="error"?d(v.message):i(v.message),f(b,v.durationMs),b},[n,f]),m=l.useCallback(()=>{for(const g of u.current.values())clearTimeout(g);u.current.clear(),o([])},[]);l.useEffect(()=>{function g(b){b.key==="Escape"&&o(v=>{if(v.length===0)return v;const k=v.slice(0,r),E=k[k.length-1],j=u.current.get(E.id);return j&&(clearTimeout(j),u.current.delete(E.id)),v.filter(T=>T.id!==E.id)})}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r]),l.useEffect(()=>()=>{for(const g of u.current.values())clearTimeout(g);u.current.clear()},[]);const y=s.slice(0,r),x=l.useMemo(()=>({toast:h,dismiss:p,clear:m}),[h,p,m]);return t.jsxs(ic.Provider,{value:x,children:[e,t.jsx(sm,{toasts:y,onDismiss:p,liveMessage:a,liveAssertiveMessage:c})]})}function am(){const{data:e,loading:r}=St("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 im=l.lazy(()=>ar(()=>import("./UpdateDropdown-CH05KQXq.js"),__vite__mapDeps([2,3,4,5,6])));function lm(e){switch(e){case"connected":return"connected";case"fallback":return"reconnecting";case"connecting":default:return"connecting"}}function cm(e){switch(e){case"connected":return"var(--status-success-text)";case"fallback":return"var(--color-own)";case"connecting":default:return"var(--text-secondary)"}}function dm(){const{updateCount:e,updates:r,isRefreshingUpdates:n,refreshUpdates:s,selectSkill:o,revealSkill:a,skills:i,updatesById:c,activeAgent:d,updateStreamStatus:u,trackedSkillCount:p}=It(),{toast:f}=cs(),{data:h}=am(),m=(h==null?void 0:h.degraded)===!0,y=l.useId(),x=u??"connecting",g=typeof p=="number"?p:null,b=g===null?!0:g>0,v=l.useMemo(()=>{if(!c||c.size===0)return;const A=new Map;for(const[$,B]of c)B.diffSummary&&A.set($,B.diffSummary);return A.size>0?A:void 0},[c]),[k,E]=l.useState(!1),j=l.useRef(null),T=l.useCallback(()=>E(!1),[]),w=m?"var(--color-own)":e>0?"var(--text-primary)":"var(--text-secondary)",S=e>9?"9+":String(e),N=e===0?"No updates available":`${e} updates available, open summary`,R=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:j,type:"button","data-testid":"update-bell","aria-label":R,"aria-haspopup":"dialog","aria-expanded":k,"aria-describedby":y,title:I,onClick:()=>E(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:S}),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:cm(x),border:"1px solid var(--color-paper)",display:"inline-block",lineHeight:0}})]}),t.jsx("span",{id:y,"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: ${lm(x)}`}),k&&t.jsx(l.Suspense,{fallback:t.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:t.jsx(im,{updates:r,isRefreshing:n,diffSummariesById:v,onRefresh:()=>s(),onSelectSkill:A=>{const $=A.localSkill??A.name.split("/").pop()??"",B=A.localPlugin??"";if(a)a(B,$);else{const L=A.name.split("/"),P=L.length>=2?L[L.length-2]:L[0];o({plugin:P,skill:$,origin:"installed"})}if(!(i??[]).some(L=>L.skill===$&&(B===""||L.plugin===B))){const L=A.installLocations??[];if(L.length>0){const P=d?L.filter(H=>H.agent===d):[],M=d?L.filter(H=>H.agent!==d):L;if(P.length>0&&M.length>0){const H=M.length>=2?`Also installed under ${M.length} other locations.`:`Also installed under ${M[0].agentLabel}.`;f({severity:"info",message:H})}else{const H=L[0].agentLabel;f({severity:"info",message:`Skill installed under ${H} — switch to ${H} to view details.`})}}}T()},onViewAll:()=>{window.location.hash="#/updates",T()},onClose:T,anchorRef:j})})]})}function Za(e){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:e}))}function um(e){return e.source==="project"?O.scopeLabels.sourceProject:e.source==="personal"?O.scopeLabels.sourcePersonal:e.source==="plugin"?O.scopeLabels.sourcePlugin:e.origin==="installed"?O.scopeLabels.sourcePersonal:O.scopeLabels.sourceProject}function pm(e){return e.source==="project"?"var(--status-installed)":e.source==="plugin"?"var(--color-accent-ink)":"var(--status-own)"}function fm({projectName:e,selected:r,onHome:n,projectPickerSlot:s,onRequestCreateSkill:o,findSkillsSlot:a,userDropdownSlot:i,appUpdateSlot:c}){const d=r?um(r):null,u=r?pm(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(rm,{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}),c&&t.jsx("span",{"data-slot":"app-update",style:{display:"inline-flex",flexShrink:0},children:c})]}),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(ei,{segment:"origin",onClick:()=>Za({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:u},children:d}),t.jsx(ti,{}),t.jsx(ei,{segment:"plugin",onClick:()=>Za({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),t.jsx(ti,{}),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(em,{})}),t.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:t.jsx(dm,{})}),i&&t.jsx("span",{"data-slot":"user-dropdown",style:{display:"inline-flex"},children:i})]})]})]})}function ei({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 ti(){return t.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const ds="vskill-theme";function lc(e){return e==="light"||e==="dark"||e==="auto"?e:"auto"}function hm(e,r){return e==="light"||e==="dark"?e:r?"dark":"light"}function mm(e){try{const r=e.getItem(ds);return lc(r)}catch{return"auto"}}function xm(e,r){try{e.setItem(ds,r)}catch{}}function gm(e,r,n){e.dataset.theme=n,e.dataset.themeMode=r}function ym(e){if(!e)return!1;try{return e("(prefers-color-scheme: dark)").matches}catch{return!1}}const cc=l.createContext(null);function vm({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),[c,d]=l.useState(()=>o?mm(o):"auto"),[u,p]=l.useState(()=>ym(a)),f=l.useMemo(()=>hm(c,u),[c,u]);l.useEffect(()=>{i&&gm(i,c,f)},[i,c,f]),l.useEffect(()=>{if(!a)return;const y=a("(prefers-color-scheme: dark)"),x=b=>p(b.matches);if(typeof y.addEventListener=="function")return y.addEventListener("change",x),()=>y.removeEventListener("change",x);const g=y;return g.addListener(x),()=>g.removeListener(x)},[a]),l.useEffect(()=>{if(typeof window>"u")return;const y=x=>{x.key===ds&&d(lc(x.newValue))};return window.addEventListener("storage",y),()=>window.removeEventListener("storage",y)},[]),l.useEffect(()=>{if(!a||!i)return;let y;try{y=a("(prefers-contrast: more)")}catch{return}const x=v=>{v?i.dataset.contrast="more":i.dataset.contrast==="more"&&delete i.dataset.contrast};x(y.matches);const g=v=>x(v.matches);if(typeof y.addEventListener=="function")return y.addEventListener("change",g),()=>y.removeEventListener("change",g);const b=y;return b.addListener(g),()=>b.removeListener(g)},[a,i]);const h=l.useCallback(y=>{d(y),o&&xm(o,y)},[o]),m=l.useMemo(()=>({mode:c,resolvedTheme:f,setTheme:h}),[c,f,h]);return t.jsx(cc.Provider,{value:m,children:s})}function dc(){const e=l.useContext(cc);if(!e)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return e}const ri=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function bm(e){const r=new Map(e.map(s=>[s.id,s])),n=[];for(const s of ri){const o=r.get(s);o&&n.push(o)}for(const s of e)ri.includes(s.id)||n.push(s);return n}function km(e){const[r,n]=l.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${e}px)`).matches);return l.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 jm({providers:e,onOpenSettings:r,onOpenInstallHelp:n}){const s=bm(e),o=km(640),[a,i]=l.useState(!1),c=l.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":O.statusBar.providerSummary(d,s.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:O.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(ni,{p:u,onClick:c},u.id))})]})}return t.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:s.map(d=>t.jsx(ni,{p:d,onClick:c,compact:!0},d.id))})}function ni({p:e,onClick:r,compact:n}){const s=e.available?O.statusBar.unlocked(e.label):e.kind==="cli-install"?O.statusBar.lockedCli(e.label):O.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(Co,{unlocked:e.available,size:10}),!n&&t.jsx("span",{children:e.label})]})}function wm(){try{return typeof localStorage>"u"?null:localStorage.getItem(ds)}catch{return null}}function Sm({projectPath:e,modelName:r,health:n="ok",onPathClick:s,providers:o,onOpenProviderSettings:a,onOpenProviderInstallHelp:i}){const{mode:c,resolvedTheme:d,setTheme:u}=dc(),f=wm()==="auto",h=Cm(c,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(si,{}),t.jsxs("span",{"aria-label":`Health: ${n}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[t.jsx(Em,{color:m}),t.jsx("span",{style:{textTransform:"capitalize"},children:n})]}),o&&o.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(si,{}),t.jsx(jm,{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: ${c} — 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(Nm,{mode:c}),t.jsx("span",{style:{textTransform:"capitalize"},children:c})]})]})}function Cm(e,r,n){return e==="light"?"dark":e==="dark"?"auto":n?"light":r==="light"?"dark":"light"}function Em({color:e}){return t.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:e,display:"inline-block",flexShrink:0}})}function si(){return t.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function Nm({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 Eo=new Set;function uc(){for(const e of Eo)e()}const Rm=5,Tm=1e3,Im=6e4;function Lm(){const[e,r]=l.useState(void 0),[n,s]=l.useState(!1),[o,a]=l.useState(!0),i=l.useRef(0),c=l.useRef(null),d=l.useRef(null),u=l.useRef(!0),p=l.useRef(0),[f,h]=l.useState(0),m=()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},y=l.useCallback(()=>{c.current&&(c.current.abort(),c.current=null)},[]),x=l.useCallback(async()=>{if(!u.current||document.visibilityState==="hidden")return;y();const b=new AbortController;c.current=b;try{const v=await fetch("/api/plugins",{signal:b.signal});if(!u.current)return;const k=await v.json();if(!u.current)return;i.current=0,r(k.plugins??[]),a(!1),s(!1),d.current=setTimeout(()=>{u.current&&h(E=>E+1)},Im)}catch(v){if(!u.current||v instanceof DOMException&&v.name==="AbortError")return;if(i.current+=1,a(!1),i.current>Rm){s(!0);return}const k=Tm*Math.pow(2,i.current-1);d.current=setTimeout(()=>{u.current&&h(E=>E+1)},k)}},[y]);l.useEffect(()=>(u.current=!0,()=>{u.current=!1,m(),y()}),[y]),l.useEffect(()=>{document.visibilityState!=="hidden"&&(m(),x())},[f,x]),l.useEffect(()=>{const b=()=>{document.visibilityState==="hidden"?(m(),y()):(i.current=0,s(!1),h(v=>v+1))};return document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b)}},[y]);const g=l.useCallback(()=>{i.current=0,s(!1),m(),p.current+=1,h(b=>b+1)},[]);return l.useEffect(()=>(Eo.add(g),()=>{Eo.delete(g)}),[g]),{plugins:e,paused:n,loading:o,retry:g}}const us=0,lr=1,Fr=2,pc=4;function oi(e){return()=>e}function Am(e){e()}function fc(e,r){return n=>e(r(n))}function ai(e,r){return()=>e(r)}function Pm(e,r){return n=>e(r,n)}function ea(e){return e!==void 0}function $m(...e){return()=>{e.map(Am)}}function zr(){}function ps(e,r){return r(e),e}function Mm(e,r){return r(e)}function We(...e){return e}function Ae(e,r){return e(lr,r)}function Ee(e,r){e(us,r)}function ta(e){e(Fr)}function He(e){return e(pc)}function be(e,r){return Ae(e,Pm(r,us))}function $t(e,r){const n=e(lr,s=>{n(),r(s)});return n}function ii(e){let r,n;return s=>o=>{r=o,n&&clearTimeout(n),n=setTimeout(()=>{s(r)},e)}}function hc(e,r){return e===r}function Oe(e=hc){let r;return n=>s=>{e(r,s)||(r=s,n(s))}}function je(e){return r=>n=>{e(n)&&r(n)}}function fe(e){return r=>fc(r,e)}function zt(e){return r=>()=>{r(e)}}function X(e,...r){const n=Dm(...r);return((s,o)=>{switch(s){case Fr:ta(e);return;case lr:return Ae(e,n(o))}})}function Ot(e,r){return n=>s=>{n(r=e(r,s))}}function xr(e){return r=>n=>{e>0?e--:r(n)}}function Kt(e){let r=null,n;return s=>o=>{r=o,!n&&(n=setTimeout(()=>{n=void 0,s(r)},e))}}function Re(...e){const r=new Array(e.length);let n=0,s=null;const o=2**e.length-1;return e.forEach((a,i)=>{const c=2**i;Ae(a,d=>{const u=n;n|=c,r[i]=d,u!==o&&n===o&&s&&(s(),s=null)})}),a=>i=>{const c=()=>{a([i].concat(r))};n===o?c():s=c}}function Dm(...e){return r=>e.reduceRight(Mm,r)}function Fm(e){let r,n;const s=()=>r==null?void 0:r();return function(o,a){switch(o){case lr:return a?n===a?void 0:(s(),n=a,r=Ae(e,a),r):(s(),zr);case Fr:s(),n=null;return}}}function oe(e){let r=e;const n=Te();return((s,o)=>{switch(s){case us:r=o;break;case lr:{o(r);break}case pc:return r}return n(s,o)})}function dt(e,r){return ps(oe(r),n=>be(e,n))}function Te(){const e=[];return((r,n)=>{switch(r){case us:e.slice().forEach(s=>{s(n)});return;case Fr:e.splice(0,e.length);return;case lr:return e.push(n),()=>{const s=e.indexOf(n);s>-1&&e.splice(s,1)}}})}function jt(e){return ps(Te(),r=>be(e,r))}function Le(e,r=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:r,id:zm(),singleton:n}}const zm=()=>Symbol();function Bm(e){const r=new Map,n=({constructor:s,dependencies:o,id:a,singleton:i})=>{if(i&&r.has(a))return r.get(a);const c=s(o.map(d=>n(d)));return i&&r.set(a,c),c};return n(e)}function qe(...e){const r=Te(),n=new Array(e.length);let s=0;const o=2**e.length-1;return e.forEach((a,i)=>{const c=2**i;Ae(a,d=>{n[i]=d,s|=c,s===o&&Ee(r,n)})}),function(a,i){switch(a){case Fr:{ta(r);return}case lr:return s===o&&i(n),Ae(r,i)}}}function ke(e,r=hc){return X(e,Oe(r))}function No(...e){return function(r,n){switch(r){case Fr:return;case lr:return $m(...e.map(s=>Ae(s,n)))}}}const et={DEBUG:0,INFO:1,WARN:2,ERROR:3},_m={[et.DEBUG]:"debug",[et.ERROR]:"error",[et.INFO]:"log",[et.WARN]:"warn"},Om=()=>typeof globalThis>"u"?window:globalThis,cr=Le(()=>{const e=oe(et.ERROR);return{log:oe((r,n,s=et.INFO)=>{const o=Om().VIRTUOSO_LOG_LEVEL??He(e);s>=o&&console[_m[s]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,n)}),logLevel:e}},[],{singleton:!0});function yr(e,r,n){return ra(e,r,n).callbackRef}function ra(e,r,n){const s=ve.useRef(null);let o=i=>{};const a=ve.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const c=()=>{const d=i[0].target;d.offsetParent!==null&&e(d)};n?c():requestAnimationFrame(c)}):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 Wm(e,r,n,s,o,a,i,c,d){const u=ve.useCallback(p=>{const f=Um(p.children,r,c?"offsetWidth":"offsetHeight",o);let h=p.parentElement;for(;h.dataset.virtuosoScroller===void 0;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let y;m&&(y=h.ownerDocument.defaultView);const x=i?c?i.scrollLeft:i.scrollTop:m?c?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:c?h.scrollLeft:h.scrollTop,g=i?c?i.scrollWidth:i.scrollHeight:m?c?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:c?h.scrollWidth:h.scrollHeight,b=i?c?i.offsetWidth:i.offsetHeight:m?c?y.innerWidth:y.innerHeight:c?h.offsetWidth:h.offsetHeight;s({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:b}),a==null||a(c?li("column-gap",getComputedStyle(p).columnGap,o):li("row-gap",getComputedStyle(p).rowGap,o)),f!==null&&e(f)},[e,r,o,a,i,s,c]);return ra(u,n,d)}function Um(e,r,n,s){const o=e.length;if(o===0)return null;const a=[];for(let i=0;i<o;i++){const c=e.item(i);if(c.dataset.index===void 0)continue;const d=parseInt(c.dataset.index),u=parseFloat(c.dataset.knownSize),p=r(c,n);if(p===0&&s("Zero-sized element, this should not happen",{child:c},et.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 li(e,r,n){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,r,et.WARN),r==="normal"?0:parseInt(r??"0",10)}function mc(e,r,n){const s=ve.useRef(null),o=ve.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const u=d.getBoundingClientRect(),p=u.width;let f,h;if(r){const m=r.getBoundingClientRect(),y=u.top-m.top;h=m.height-Math.max(0,y),f=y+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}=ra(o,!0,n),c=ve.useCallback(()=>{o(i.current)},[o,i]);return ve.useEffect(()=>{var u;if(r){r.addEventListener("scroll",c);const p=new ResizeObserver(()=>{requestAnimationFrame(c)});return p.observe(r),()=>{r.removeEventListener("scroll",c),p.unobserve(r)}}const d=(u=i.current)==null?void 0:u.ownerDocument.defaultView;return d==null||d.addEventListener("scroll",c),d==null||d.addEventListener("resize",c),()=>{d==null||d.removeEventListener("scroll",c),d==null||d.removeEventListener("resize",c)}},[c,r,i]),a}const ft=Le(()=>{const e=Te(),r=Te(),n=oe(0),s=Te(),o=oe(0),a=Te(),i=Te(),c=oe(0),d=oe(0),u=oe(0),p=oe(0),f=Te(),h=Te(),m=oe(!1),y=oe(!1),x=oe(!1);return be(X(e,fe(({scrollTop:g})=>g)),r),be(X(e,fe(({scrollHeight:g})=>g)),i),be(r,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:d,footerHeight:p,headerHeight:c,horizontalDirection:y,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:r,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:s,statefulScrollTop:o,viewportHeight:a}},[],{singleton:!0}),on={lvl:0};function xc(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:c,value:d}=r(e[i]);a.push({end:c-1,start:s,value:o}),s=c,o=d}return a.push({end:1/0,start:s,value:o}),a}function De(e){return e===on}function an(e,r){if(!De(e))return r===e.k?e.v:r<e.k?an(e.l,r):an(e.r,r)}function Dt(e,r,n="k"){if(De(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 kt(e,r,n){return De(e)?vc(r,n,1):r===e.k?Qe(e,{k:r,v:n}):r<e.k?ci(Qe(e,{l:kt(e.l,r,n)})):ci(Qe(e,{r:kt(e.r,r,n)}))}function Tr(){return on}function Ir(e,r,n){if(De(e))return[];const s=Dt(e,r)[0];return Hm(To(e,s,n))}function Ro(e,r){if(De(e))return on;const{k:n,l:s,r:o}=e;if(r===n){if(De(s))return o;if(De(o))return s;const[a,i]=yc(s);return Gn(Qe(e,{k:a,l:gc(s),v:i}))}return r<n?Gn(Qe(e,{l:Ro(s,r)})):Gn(Qe(e,{r:Ro(o,r)}))}function mr(e){return De(e)?[]:[...mr(e.l),{k:e.k,v:e.v},...mr(e.r)]}function To(e,r,n){if(De(e))return[];const{k:s,l:o,r:a,v:i}=e;let c=[];return s>r&&(c=c.concat(To(o,r,n))),s>=r&&s<=n&&c.push({k:s,v:i}),s<=n&&(c=c.concat(To(a,r,n))),c}function Gn(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(Is(r))return bc(Qe(e,{lvl:n-1}));if(!De(r)&&!De(r.r))return Qe(r.r,{l:Qe(r,{r:r.r.l}),lvl:n,r:Qe(e,{l:r.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}if(Is(e))return Io(Qe(e,{lvl:n-1}));if(!De(s)&&!De(s.l)){const o=s.l,a=Is(o)?s.lvl-1:s.lvl;return Qe(o,{l:Qe(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Io(Qe(s,{l:o.r,lvl:a}))})}throw new Error("Unexpected empty nodes")}function Qe(e,r){return vc(r.k!==void 0?r.k:e.k,r.v!==void 0?r.v:e.v,r.lvl!==void 0?r.lvl:e.lvl,r.l!==void 0?r.l:e.l,r.r!==void 0?r.r:e.r)}function gc(e){return De(e.r)?e.l:Gn(Qe(e,{r:gc(e.r)}))}function Is(e){return De(e)||e.lvl>e.r.lvl}function yc(e){return De(e.r)?[e.k,e.v]:yc(e.r)}function vc(e,r,n,s=on,o=on){return{k:e,l:s,lvl:n,r:o,v:r}}function ci(e){return Io(bc(e))}function bc(e){const{l:r}=e;return!De(r)&&r.lvl===e.lvl?Qe(r,{r:Qe(e,{l:r.r})}):e}function Io(e){const{lvl:r,r:n}=e;return!De(n)&&!De(n.r)&&n.lvl===r&&n.r.lvl===r?Qe(n,{l:Qe(e,{r:n.l}),lvl:r+1}):e}function Hm(e){return xc(e,({k:r,v:n})=>({index:r,value:n}))}function kc(e,r){return!!(e&&e.startIndex===r.startIndex&&e.endIndex===r.endIndex)}function ln(e,r){return!!(e&&e[0]===r[0]&&e[1]===r[1])}const na=Le(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function jc(e,r,n){return e[Qn(e,r,n)]}function Qn(e,r,n,s=0){let o=e.length-1;for(;s<=o;){const a=Math.floor((s+o)/2),i=e[a],c=n(i,r);if(c===0)return a;if(c===-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 Vm(e,r,n,s){const o=Qn(e,r,s),a=Qn(e,n,s,o);return e.slice(o,a+1)}function or(e,r){return Math.round(e.getBoundingClientRect()[r])}function fs(e){return!De(e.groupOffsetTree)}function sa({index:e},r){return r===e?0:r<e?-1:1}function Gm(){return{groupIndices:[],groupOffsetTree:Tr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Tr()}}function Km(e,r){let n=De(e)?0:1/0;for(const s of r){const{endIndex:o,size:a,startIndex:i}=s;if(n=Math.min(n,i),De(e)){e=kt(e,0,a);continue}const c=Ir(e,i-1,o+1);if(c.some(ex(s)))continue;let d=!1,u=!1;for(const{end:p,start:f,value:h}of c)d?(o>=f||a===h)&&(e=Ro(e,f)):(u=h!==a,d=!0),p>o&&o>=f&&h!==a&&(e=kt(e,o+1,h));u&&(e=kt(e,i,a))}return[e,n]}function qm(e){return typeof e.groupIndex<"u"}function Ym({offset:e},r){return r===e?0:r<e?-1:1}function cn(e,r,n){if(r.length===0)return 0;const{index:s,offset:o,size:a}=jc(r,e,sa),i=e-s,c=a*i+(i-1)*n+o;return c>0?c+n:c}function wc(e,r){if(!fs(r))return e;let n=0;for(;r.groupIndices[n]<=e+n;)n++;return e+n}function Sc(e,r,n){if(qm(e))return r.groupIndices[e.groupIndex]+1;const s=e.index==="LAST"?n:e.index;let o=wc(s,r);return o=Math.max(0,o,Math.min(n,o)),o}function Jm(e,r,n,s=0){return s>0&&(r=Math.max(r,jc(e,s,sa).offset)),xc(Vm(e,r,n,Ym),Zm)}function Xm(e,[r,n,s,o]){r.length>0&&s("received item sizes",r,et.DEBUG);const a=e.sizeTree;let i=a,c=0;if(n.length>0&&De(a)&&r.length===2){const h=r[0].size,m=r[1].size;i=n.reduce((y,x)=>kt(kt(y,x,h),x+1,m),i)}else[i,c]=Km(i,r);if(i===a)return e;const{lastIndex:d,lastOffset:u,lastSize:p,offsetTree:f}=Lo(e.offsetTree,c,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>kt(h,m,cn(m,f,o)),Tr()),lastIndex:d,lastOffset:u,lastSize:p,offsetTree:f,sizeTree:i}}function Qm(e){return mr(e).map(({k:r,v:n},s,o)=>{const a=o[s+1];return{endIndex:a!==void 0?a.k-1:1/0,size:n,startIndex:r}})}function di(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 Lo(e,r,n,s){let o=e,a=0,i=0,c=0,d=0;if(r!==0){d=Qn(o,r-1,sa),c=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)}else o=[];for(const{start:u,value:p}of Ir(n,r,1/0)){const f=u-a,h=f*i+c+f*s;o.push({index:u,offset:h,size:p}),a=u,c=h,i=p}return{lastIndex:a,lastOffset:c,lastSize:i,offsetTree:o}}function Zm(e){return{index:e.index,value:e}}function ex(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 tx={offsetHeight:"height",offsetWidth:"width"},Ht=Le(([{log:e},{recalcInProgress:r}])=>{const n=Te(),s=Te(),o=dt(s,0),a=Te(),i=Te(),c=oe(0),d=oe([]),u=oe(void 0),p=oe(void 0),f=oe(void 0),h=oe(void 0),m=oe((w,S)=>or(w,tx[S])),y=oe(void 0),x=oe(0),g=Gm(),b=dt(X(n,Re(d,e,x),Ot(Xm,g),Oe()),g),v=dt(X(d,Oe(),Ot((w,S)=>({current:S,prev:w.current}),{current:[],prev:[]}),fe(({prev:w})=>w)),[]);be(X(d,je(w=>w.length>0),Re(b,x),fe(([w,S,N])=>{const R=w.reduce((I,A,$)=>kt(I,A,cn(A,S.offsetTree,N)||$),Tr());return{...S,groupIndices:w,groupOffsetTree:R}})),b),be(X(s,Re(b),je(([w,{lastIndex:S}])=>w<S),fe(([w,{lastIndex:S,lastSize:N}])=>[{endIndex:S,size:N,startIndex:w}])),n),be(u,p);const k=dt(X(u,fe(w=>w===void 0)),!0);be(X(p,je(w=>w!==void 0&&De(He(b).sizeTree)),fe(w=>{const S=He(f),N=He(d).length>0;return S!==void 0&&S!==0?N?[{endIndex:0,size:S,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),n),be(X(h,je(w=>w!==void 0&&w.length>0&&De(He(b).sizeTree)),fe(w=>{const S=[];let N=w[0],R=0;for(let I=1;I<w.length;I++){const A=w[I];A!==N&&(S.push({endIndex:I-1,size:N,startIndex:R}),N=A,R=I)}return S.push({endIndex:w.length-1,size:N,startIndex:R}),S})),n),be(X(d,Re(f,p),je(([,w,S])=>w!==void 0&&S!==void 0),fe(([w,S,N])=>{const R=[];for(let I=0;I<w.length;I++){const A=w[I],$=w[I+1];R.push({startIndex:A,endIndex:A,size:S}),$!==void 0&&R.push({startIndex:A+1,endIndex:$-1,size:N})}return R})),n);const E=jt(X(n,Re(b),Ot(({sizes:w},[S,N])=>({changed:N!==w,sizes:N}),{changed:!1,sizes:g}),fe(w=>w.changed)));Ae(X(c,Ot((w,S)=>({diff:w.prev-S,prev:S}),{diff:0,prev:0}),fe(w=>w.diff)),w=>{const{groupIndices:S}=He(b);if(w>0)Ee(r,!0),Ee(a,w+di(w,S));else if(w<0){const N=He(v);N.length>0&&(w-=di(-w,N)),Ee(i,w)}}),Ae(X(c,Re(e)),([w,S])=>{w<0&&S("`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:c},et.ERROR)});const j=jt(a);be(X(a,Re(b),fe(([w,S])=>{const N=S.groupIndices.length>0,R=[],I=S.lastSize;if(N){const A=an(S.sizeTree,0);let $=0,B=0;for(;$<w;){const L=S.groupIndices[B],P=S.groupIndices.length===B+1?1/0:S.groupIndices[B+1]-L-1;R.push({endIndex:L,size:A,startIndex:L}),R.push({endIndex:L+1+P-1,size:I,startIndex:L+1}),B++,$+=P+1}const C=mr(S.sizeTree);return $!==w&&C.shift(),C.reduce((L,{k:P,v:M})=>{let H=L.ranges;return L.prevSize!==0&&(H=[...L.ranges,{endIndex:P+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:P+w,prevSize:M,ranges:H}},{prevIndex:w,prevSize:0,ranges:R}).ranges}return mr(S.sizeTree).reduce((A,{k:$,v:B})=>({prevIndex:$+w,prevSize:B,ranges:[...A.ranges,{endIndex:$+w-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:I,ranges:[]}).ranges})),n);const T=jt(X(i,Re(b,x),fe(([w,{offsetTree:S},N])=>{const R=-w;return cn(R,S,N)})));return be(X(i,Re(b,x),fe(([w,S,N])=>{if(S.groupIndices.length>0){if(De(S.sizeTree))return S;let I=Tr();const A=He(v);let $=0,B=0,C=0;for(;$<-w;){C=A[B];const L=A[B+1]-C-1;B++,$+=L+1}if(I=mr(S.sizeTree).reduce((L,{k:P,v:M})=>kt(L,Math.max(0,P+w),M),I),$!==-w){const L=an(S.sizeTree,C);I=kt(I,0,L);const P=Dt(S.sizeTree,-w+1)[1];I=kt(I,1,P)}return{...S,sizeTree:I,...Lo(S.offsetTree,0,I,N)}}const R=mr(S.sizeTree).reduce((I,{k:A,v:$})=>kt(I,Math.max(0,A+w),$),Tr());return{...S,sizeTree:R,...Lo(S.offsetTree,0,R,N)}})),b),{beforeUnshiftWith:j,data:y,defaultItemSize:p,firstItemIndex:c,fixedItemSize:u,fixedGroupSize:f,gap:x,groupIndices:d,heightEstimates:h,itemSize:m,listRefresh:E,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:b,statefulTotalCount:o,totalCount:s,trackItemSizes:k,unshiftWith:a}},We(cr,na),{singleton:!0});function rx(e){return e.reduce((r,n)=>(r.groupIndices.push(r.totalCount),r.totalCount+=n+1,r),{groupIndices:[],totalCount:0})}const Cc=Le(([{groupIndices:e,sizes:r,totalCount:n},{headerHeight:s,scrollTop:o}])=>{const a=Te(),i=Te(),c=jt(X(a,fe(rx)));return be(X(c,fe(d=>d.totalCount)),n),be(X(c,fe(d=>d.groupIndices)),e),be(X(qe(o,r,s),je(([d,u])=>fs(u)),fe(([d,u,p])=>Dt(u.groupOffsetTree,Math.max(d-p,0),"v")[0]),Oe(),fe(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},We(Ht,ft)),dr=Le(([{log:e}])=>{const r=oe(!1),n=jt(X(r,je(s=>s),Oe()));return Ae(r,s=>{s&&He(e)("props updated",{},et.DEBUG)}),{didMount:n,propsReady:r}},We(cr),{singleton:!0}),nx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ec(e){const r=typeof e=="number"?{index:e}:e;return r.align||(r.align="start"),(!r.behavior||!nx)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const xn=Le(([{gap:e,listRefresh:r,sizes:n,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:a,footerHeight:i,headerHeight:c,scrollingInProgress:d,scrollTo:u,smoothScrollTargetReached:p,viewportHeight:f},{log:h}])=>{const m=Te(),y=Te(),x=oe(0);let g=null,b=null,v=null;function k(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),b&&(clearTimeout(b),b=null),Ee(d,!1)}return be(X(m,Re(n,f,s,x,c,i,h),Re(e,a,o),fe(([[E,j,T,w,S,N,R,I],A,$,B])=>{const C=Ec(E),{align:L,behavior:P,offset:M}=C,H=w-1,le=Sc(C,j,H);let G=cn(le,j.offsetTree,A)+N;L==="end"?(G+=$+Dt(j.sizeTree,le)[1]-T+B,le===H&&(G+=R)):L==="center"?G+=($+Dt(j.sizeTree,le)[1]-T+B)/2:G-=S,M!==void 0&&M!==0&&(G+=M);const W=Z=>{k(),Z?(I("retrying to scroll to",{location:E},et.DEBUG),Ee(m,E)):(Ee(y,!0),I("list did not change, scroll successful",{},et.DEBUG))};if(k(),P==="smooth"){let Z=!1;v=Ae(r,he=>{Z=Z||he}),g=$t(p,()=>{W(Z)})}else g=$t(X(r,sx(150)),W);return b=setTimeout(()=>{k()},1200),Ee(d,!0),I("scrolling from index to",{behavior:P,index:le,top:G},et.DEBUG),{behavior:P,top:G}})),u),{scrollTargetReached:y,scrollToIndex:m,topListHeight:x}},We(Ht,ft,cr),{singleton:!0});function sx(e){return r=>{const n=setTimeout(()=>{r(!1)},e);return s=>{s&&(r(!0),clearTimeout(n))}}}function oa(e,r){e===0?r():requestAnimationFrame(()=>{oa(e-1,r)})}function aa(e,r){const n=r-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const gn=Le(([{defaultItemSize:e,listRefresh:r,sizes:n},{scrollTop:s},{scrollTargetReached:o,scrollToIndex:a},{didMount:i}])=>{const c=oe(!0),d=oe(0),u=oe(!0);return be(X(i,Re(d),je(([p,f])=>f!==0),zt(!1)),c),be(X(i,Re(d),je(([p,f])=>f!==0),zt(!1)),u),Ae(X(qe(r,i),Re(c,n,e,u),je(([[,p],f,{sizeTree:h},m,y])=>p&&(!De(h)||ea(m))&&!f&&!y),Re(d)),([,p])=>{$t(o,()=>{Ee(u,!0)}),oa(4,()=>{$t(s,()=>{Ee(c,!0)}),Ee(a,p)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:d,scrolledToInitialItem:c}},We(Ht,ft,xn,dr),{singleton:!0});function Nc(e,r){return Math.abs(e-r)<1.01}const dn="up",Zr="down",ox="none",ax={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ix=0,yn=Le(([{footerHeight:e,headerHeight:r,scrollBy:n,scrollContainerState:s,scrollTop:o,viewportHeight:a}])=>{const i=oe(!1),c=oe(!0),d=Te(),u=Te(),p=oe(4),f=oe(ix),h=dt(X(No(X(ke(o),xr(1),zt(!0)),X(ke(o),xr(1),zt(!1),ii(100))),Oe()),!1),m=dt(X(No(X(n,zt(!0)),X(n,zt(!1),ii(200))),Oe()),!1);be(X(qe(ke(o),ke(f)),fe(([v,k])=>v<=k),Oe()),c),be(X(c,Kt(50)),u);const y=jt(X(qe(s,ke(a),ke(r),ke(e),ke(p)),Ot((v,[{scrollHeight:k,scrollTop:E},j,T,w,S])=>{const N=E+j-k>-S,R={scrollHeight:k,scrollTop:E,viewportHeight:j};if(N){let A,$;return E>v.state.scrollTop?(A="SCROLLED_DOWN",$=v.state.scrollTop-E):(A="SIZE_DECREASED",$=v.state.scrollTop-E||v.scrollTopDelta),{atBottom:!0,atBottomBecause:A,scrollTopDelta:$,state:R}}let I;return R.scrollHeight>v.state.scrollHeight?I="SIZE_INCREASED":j<v.state.viewportHeight?I="VIEWPORT_HEIGHT_DECREASING":E<v.state.scrollTop?I="SCROLLING_UPWARDS":I="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:I,state:R}},ax),Oe((v,k)=>v!==void 0&&v.atBottom===k.atBottom))),x=dt(X(s,Ot((v,{scrollHeight:k,scrollTop:E,viewportHeight:j})=>{if(!Nc(v.scrollHeight,k)){const T=k-(E+j)<1;return v.scrollTop!==E&&T?{changed:!0,jump:v.scrollTop-E,scrollHeight:k,scrollTop:E}:{changed:!0,jump:0,scrollHeight:k,scrollTop:E}}return{changed:!1,jump:0,scrollHeight:k,scrollTop:E}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),je(v=>v.changed),fe(v=>v.jump)),0);be(X(y,fe(v=>v.atBottom)),i),be(X(i,Kt(50)),d);const g=oe(Zr);be(X(s,fe(({scrollTop:v})=>v),Oe(),Ot((v,k)=>He(m)?{direction:v.direction,prevScrollTop:k}:{direction:k<v.prevScrollTop?dn:Zr,prevScrollTop:k},{direction:Zr,prevScrollTop:0}),fe(v=>v.direction)),g),be(X(s,Kt(50),zt(ox)),g);const b=oe(0);return be(X(h,je(v=>!v),zt(0)),b),be(X(o,Kt(100),Re(h),je(([v,k])=>k),Ot(([v,k],[E])=>[k,E],[0,0]),fe(([v,k])=>k-v)),b),{atBottomState:y,atBottomStateChange:d,atBottomThreshold:p,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:c,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:b}},We(ft)),un="top",pn="bottom",ui="none";function pi(e,r,n){return typeof e=="number"?n===dn&&r===un||n===Zr&&r===pn?e:0:n===dn?r===un?e.main:e.reverse:r===pn?e.main:e.reverse}function fi(e,r){return typeof e=="number"?e:e[r]??0}const ia=Le(([{deviation:e,fixedHeaderHeight:r,headerHeight:n,scrollTop:s,viewportHeight:o}])=>{const a=Te(),i=oe(0),c=oe(0),d=oe(0),u=dt(X(qe(ke(s),ke(o),ke(n),ke(a,ln),ke(d),ke(i),ke(r),ke(e),ke(c)),fe(([p,f,h,[m,y],x,g,b,v,k])=>{const E=p-v,j=g+b,T=Math.max(h-E,0);let w=ui;const S=fi(k,un),N=fi(k,pn);return m-=v,m+=h+b,y+=h+b,y-=v,m>p+j-S&&(w=dn),y<p-T+f+N&&(w=Zr),w!==ui?[Math.max(E-h-pi(x,un,w)-S,0),E-T-b+f+pi(x,pn,w)+N]:null}),je(p=>p!==null),Oe(ln)),[0,0]);return{increaseViewportBy:c,listBoundary:a,overscan:d,topListHeight:i,visibleRange:u}},We(ft),{singleton:!0});function lx(e,r,n){if(fs(r)){const s=wc(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 Ls={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Kn(e,r,n,s,o,a){const{lastIndex:i,lastOffset:c,lastSize:d}=o;let u=0,p=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];p=x.offset+x.size}const f=n-i,h=c+f*d+(f-1)*s,m=u,y=h-p;return{bottom:p,firstItemIndex:a,items:hi(e,o,a),offsetBottom:y,offsetTop:u,top:m,topItems:hi(r,o,a),topListHeight:r.reduce((x,g)=>g.size+x,0),totalCount:n}}function Rc(e,r,n,s,o,a){let i=0;if(n.groupIndices.length>0)for(const p of n.groupIndices){if(p-i>=e)break;i++}const c=e+i,d=aa(r,c),u=Array.from({length:c}).map((p,f)=>({data:a[f+d],index:f+d,offset:0,size:0}));return Kn(u,[],c,o,n,s)}function hi(e,r,n){if(e.length===0)return[];if(!fs(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=Ir(r.groupOffsetTree,s,o);let c,d=0;for(const u of e){(!c||c.end<u.index)&&(c=i.shift(),d=r.groupIndices.indexOf(c.start));let p;u.index===c.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 mi(e,r){return e===void 0?0:typeof e=="number"?e:e[r]??0}const vr=Le(([{data:e,firstItemIndex:r,gap:n,sizes:s,totalCount:o},a,{listBoundary:i,topListHeight:c,visibleRange:d},{initialTopMostItemIndex:u,scrolledToInitialItem:p},{topListHeight:f},h,{didMount:m},{recalcInProgress:y}])=>{const x=oe([]),g=oe(0),b=Te(),v=oe(0);be(a.topItemsIndexes,x);const k=dt(X(qe(m,y,ke(d,ln),ke(o),ke(s),ke(u),p,ke(x),ke(r),ke(n),ke(v),e),je(([w,S,,N,,,,,,,,R])=>{const I=R!==void 0&&R.length!==N;return w&&!S&&!I}),fe(([,,[w,S],N,R,I,A,$,B,C,L,P])=>{var U,K;const M=R,{offsetTree:H,sizeTree:le}=M,G=He(g);if(N===0)return{...Ls,totalCount:N};if(w===0&&S===0)return G===0?{...Ls,totalCount:N}:Rc(G,I,R,B,C,P||[]);if(De(le))return G>0?null:Kn(lx(aa(I,N),M,P),[],N,C,M,B);const W=[];if($.length>0){const V=$[0],Y=$[$.length-1];let J=0;for(const te of Ir(le,V,Y)){const de=te.value,se=Math.max(te.start,V),ue=Math.min(te.end,Y);for(let F=se;F<=ue;F++)W.push({data:P==null?void 0:P[F],index:F,offset:J,size:de}),J+=de}}if(!A)return Kn([],W,N,C,M,B);const Z=$.length>0?$[$.length-1]+1:0,he=Jm(H,w,S,Z);if(he.length===0)return null;const me=N-1,_=ps([],V=>{for(const Y of he){const J=Y.value;let te=J.offset,de=Y.start;const se=J.size;if(J.offset<w){de+=Math.floor((w-J.offset+C)/(se+C));const F=de-Y.start;te+=F*se+F*C}de<Z&&(te+=(Z-de)*se,de=Z);const ue=Math.min(Y.end,me);for(let F=de;F<=ue&&!(te>=S);F++)V.push({data:P==null?void 0:P[F],index:F,offset:te,size:se}),te+=se+C}}),ne=mi(L,un),D=mi(L,pn);if(_.length>0&&(ne>0||D>0)){const V=_[0],Y=_[_.length-1];if(ne>0&&V.index>Z){const J=Math.min(ne,V.index-Z),te=[];let de=V.offset;for(let se=V.index-1;se>=V.index-J;se--){const ue=((U=Ir(le,se,se)[0])==null?void 0:U.value)??V.size;de-=ue+C,te.unshift({data:P==null?void 0:P[se],index:se,offset:de,size:ue})}_.unshift(...te)}if(D>0&&Y.index<me){const J=Math.min(D,me-Y.index);let te=Y.offset+Y.size+C;for(let de=Y.index+1;de<=Y.index+J;de++){const se=((K=Ir(le,de,de)[0])==null?void 0:K.value)??Y.size;_.push({data:P==null?void 0:P[de],index:de,offset:te,size:se}),te+=se+C}}}return Kn(_,W,N,C,M,B)}),je(w=>w!==null),Oe()),Ls);be(X(e,je(ea),fe(w=>w==null?void 0:w.length)),o),be(X(k,fe(w=>w.topListHeight)),f),be(f,c),be(X(k,fe(w=>[w.top,w.bottom])),i),be(X(k,fe(w=>w.items)),b);const E=jt(X(k,je(({items:w})=>w.length>0),Re(o,e),je(([{items:w},S])=>w[w.length-1].originalIndex===S-1),fe(([,w,S])=>[w-1,S]),Oe(ln),fe(([w])=>w))),j=jt(X(k,Kt(200),je(({items:w,topItems:S})=>w.length>0&&w[0].originalIndex===S.length),fe(({items:w})=>w[0].index),Oe())),T=jt(X(k,je(({items:w})=>w.length>0),fe(({items:w})=>{let S=0,N=w.length-1;for(;w[S].type==="group"&&S<N;)S++;for(;w[N].type==="group"&&N>S;)N--;return{endIndex:w[N].index,startIndex:w[S].index}}),Oe(kc)));return{endReached:E,initialItemCount:g,itemsRendered:b,listState:k,minOverscanItemCount:v,rangeChanged:T,startReached:j,topItemsIndexes:x,...h}},We(Ht,Cc,ia,gn,xn,yn,dr,na),{singleton:!0}),Tc=Le(([{fixedFooterHeight:e,fixedHeaderHeight:r,footerHeight:n,headerHeight:s},{listState:o}])=>{const a=Te(),i=dt(X(qe(n,e,s,r,o),fe(([c,d,u,p,f])=>c+d+u+p+f.offsetBottom+f.bottom)),0);return be(ke(i),a),{totalListHeight:i,totalListHeightChanged:a}},We(ft,vr),{singleton:!0}),cx=Le(([{viewportHeight:e},{totalListHeight:r}])=>{const n=oe(!1),s=dt(X(qe(n,e,r),je(([o])=>o),fe(([,o,a])=>Math.max(0,o-a)),Kt(0),Oe()),0);return{alignToBottom:n,paddingTopAddition:s}},We(ft,Tc),{singleton:!0}),Ic=Le(()=>({context:oe(null)})),dx=({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,Lc=Le(([{gap:e,sizes:r,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:o,headerHeight:a,scrollingInProgress:i,scrollTop:c,viewportHeight:d},{scrollToIndex:u}])=>{const p=Te();return be(X(p,Re(r,d,n,a,o,s,c),Re(e),fe(([[f,h,m,y,x,g,b,v],k])=>{const{calculateViewLocation:E=dx,done:j,...T}=f,w=Sc(f,h,y-1),S=cn(w,h.offsetTree,k)+x+g,N=S+Dt(h.sizeTree,w)[1],R=v+g,I=v+m-b,A=E({itemBottom:N,itemTop:S,locationParams:T,viewportBottom:I,viewportTop:R});return A!==null?j&&$t(X(i,je($=>!$),xr(He(i)?1:2)),j):j==null||j(),A}),je(f=>f!==null)),u),{scrollIntoView:p}},We(Ht,ft,xn,vr,cr),{singleton:!0});function xi(e){return e===!1?!1:e==="smooth"?"smooth":"auto"}const ux=(e,r)=>typeof e=="function"?xi(e(r)):r&&xi(e),px=Le(([{listRefresh:e,totalCount:r,fixedItemSize:n,data:s},{atBottomState:o,isAtBottom:a},{scrollToIndex:i},{scrolledToInitialItem:c},{didMount:d,propsReady:u},{log:p},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const y=oe(!1),x=Te();let g=null;function b(j){Ee(i,{align:"end",behavior:j,index:"LAST"})}Ae(X(qe(X(ke(r),xr(1)),d),Re(ke(y),a,c,f),fe(([[j,T],w,S,N,R])=>{let I=T&&N,A="auto";return I&&(A=ux(w,S||R),I=I&&A!==!1),{followOutputBehavior:A,shouldFollow:I,totalCount:j}}),je(({shouldFollow:j})=>j)),({followOutputBehavior:j,totalCount:T})=>{g!==null&&(g(),g=null),He(n)!==void 0?requestAnimationFrame(()=>{He(p)("following output to ",{totalCount:T},et.DEBUG),b(j)}):g=$t(e,()=>{He(p)("following output to ",{totalCount:T},et.DEBUG),b(j),g=null})});function v(j){const T=$t(o,w=>{j&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&g===null&&(He(p)("scrolling to bottom due to increased size",{},et.DEBUG),b("auto"))});setTimeout(T,100)}Ae(X(qe(ke(y),r,u),je(([j,,T])=>j!==!1&&T),Ot(({value:j},[,T])=>({refreshed:j===T,value:T}),{refreshed:!1,value:0}),je(({refreshed:j})=>j),Re(y,r)),([,j])=>{He(c)&&v(j!==!1)}),Ae(x,()=>{v(He(y)!==!1)}),Ae(qe(ke(y),o),([j,T])=>{j!==!1&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&b("auto")});const k=oe(null),E=Te();return be(No(X(ke(s),fe(j=>(j==null?void 0:j.length)??0)),X(ke(r))),E),Ae(X(qe(X(E,xr(1)),d),Re(ke(k),c,f,h),fe(([[j,T],w,S,N,R])=>T&&S&&(w==null?void 0:w({context:R,totalCount:j,scrollingInProgress:N}))),je(j=>!!j),Kt(0)),j=>{g!==null&&(g(),g=null),He(n)!==void 0?requestAnimationFrame(()=>{He(p)("scrolling into view",{}),Ee(m,j)}):g=$t(e,()=>{He(p)("scrolling into view",{}),Ee(m,j),g=null})}),{autoscrollToBottom:x,followOutput:y,scrollIntoViewOnChange:k}},We(Ht,yn,xn,gn,dr,cr,ft,Ic,Lc)),fx=Le(([{data:e,firstItemIndex:r,gap:n,sizes:s},{initialTopMostItemIndex:o},{initialItemCount:a,listState:i},{didMount:c}])=>(be(X(c,Re(a),je(([,d])=>d!==0),Re(o,s,r,n,e),fe(([[,d],u,p,f,h,m=[]])=>Rc(d,u,p,f,h,m))),i),{}),We(Ht,gn,vr,dr),{singleton:!0}),hx=Le(([{didMount:e},{scrollTo:r},{listState:n}])=>{const s=oe(0);return Ae(X(e,Re(s),je(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{$t(X(n,xr(1),je(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ee(r,o)})})}),{initialScrollTop:s}},We(dr,ft,vr),{singleton:!0}),Ac=Le(([{scrollVelocity:e}])=>{const r=oe(!1),n=Te(),s=oe(!1);return be(X(e,Re(s,r,n),je(([o,a])=>a!==!1&&a!==void 0),fe(([o,a,i,c])=>{const{enter:d,exit:u}=a;if(i){if(u(o,c))return!1}else if(d(o,c))return!0;return i}),Oe()),r),Ae(X(qe(r,e,n),Re(s)),([[o,a,i],c])=>{o&&c!==!1&&c!==void 0&&c.change&&c.change(a,i)}),{isSeeking:r,scrollSeekConfiguration:s,scrollSeekRangeChanged:n,scrollVelocity:e}},We(yn),{singleton:!0}),la=Le(([{scrollContainerState:e,scrollTo:r}])=>{const n=Te(),s=Te(),o=Te(),a=oe(!1),i=oe(void 0);return be(X(qe(n,s),fe(([{scrollTop:c,viewportHeight:d},{offsetTop:u,listHeight:p}])=>({scrollHeight:p,scrollTop:Math.max(0,c-u),viewportHeight:d}))),e),be(X(r,Re(s),fe(([c,{offsetTop:d}])=>({...c,top:c.top+d}))),o),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:s}},We(ft)),mx=Le(([{sizeRanges:e,sizes:r},{headerHeight:n,scrollTop:s},{initialTopMostItemIndex:o},{didMount:a},{useWindowScroll:i,windowScrollContainerState:c,windowViewportRect:d}])=>{const u=Te(),p=oe(void 0),f=oe(null),h=oe(null);return be(c,f),be(d,h),Ae(X(u,Re(r,s,i,f,h,n)),([m,y,x,g,b,v,k])=>{const E=Qm(y.sizeTree);g&&b!==null&&v!==null&&(x=b.scrollTop-v.offsetTop),x-=k,m({ranges:E,scrollTop:x})}),be(X(p,je(ea),fe(xx)),o),be(X(a,Re(p),je(([,m])=>m!==void 0),Oe(),fe(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:p}},We(Ht,ft,gn,dr,la));function xx(e){return{align:"start",index:0,offset:e.scrollTop}}const gx=Le(([{topItemsIndexes:e}])=>{const r=oe(0);return be(X(r,je(n=>n>=0),fe(n=>Array.from({length:n}).map((s,o)=>o))),e),{topItemCount:r}},We(vr));function Pc(e){let r=!1,n;return(()=>(r||(r=!0,n=e()),n))}const yx=Pc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),vx=Le(([{deviation:e,scrollBy:r,scrollingInProgress:n,scrollTop:s},{isAtBottom:o,isScrolling:a,lastJumpDueToItemResize:i,scrollDirection:c},{listState:d},{beforeUnshiftWith:u,gap:p,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:y}])=>{const x=jt(X(d,Re(i),Ot(([,b,v,k],[{bottom:E,items:j,offsetBottom:T,totalCount:w},S])=>{const N=E+T;let R=0;return v===w&&b.length>0&&j.length>0&&(j[0].originalIndex===0&&b[0].originalIndex===0||(R=N-k,R!==0&&(R+=S))),[R,j,w,N]},[0,[],0,0]),je(([b])=>b!==0),Re(s,c,n,o,m,y),je(([,b,v,k,,,E])=>!E&&!k&&b!==0&&v===dn),fe(([[b],,,,,v])=>(v("Upward scrolling compensation",{amount:b},et.DEBUG),b))));function g(b){b>0?(Ee(r,{behavior:"auto",top:-b}),Ee(e,0)):(Ee(e,0),Ee(r,{behavior:"auto",top:-b}))}return Ae(X(x,Re(e,a)),([b,v,k])=>{k&&yx()?Ee(e,v-b):g(-b)}),Ae(X(qe(dt(a,!1),e,y),je(([b,v,k])=>!b&&!k&&v!==0),fe(([b,v])=>v),Kt(1)),g),be(X(f,fe(b=>({top:-b}))),r),Ae(X(u,Re(h,p),fe(([b,{groupIndices:v,lastSize:k,sizeTree:E},j])=>{function T(I){return I*(k+j)}if(v.length===0)return T(b);let w=0;const S=an(E,0);let N=0,R=0;for(;N<b;){N++,w+=S;let I=v.length===R+1?1/0:v[R+1]-v[R]-1;N+I>b&&(w-=S,I=b-N+1),N+=I,w+=T(I),R++}return w})),b=>{Ee(e,b),requestAnimationFrame(()=>{Ee(r,{top:b}),requestAnimationFrame(()=>{Ee(e,0),Ee(y,!1)})})}),{deviation:e}},We(ft,yn,vr,Ht,cr,na)),bx=Le(([e,r,n,s,o,a,i,c,d,u,p])=>({...e,...r,...n,...s,...o,...a,...i,...c,...d,...u,...p}),We(ia,fx,dr,Ac,Tc,hx,cx,la,Lc,cr,Ic)),$c=Le(([{data:e,defaultItemSize:r,firstItemIndex:n,fixedItemSize:s,fixedGroupSize:o,gap:a,groupIndices:i,heightEstimates:c,itemSize:d,sizeRanges:u,sizes:p,statefulTotalCount:f,totalCount:h,trackItemSizes:m},{initialItemFinalLocationReached:y,initialTopMostItemIndex:x,scrolledToInitialItem:g},b,v,k,E,{scrollToIndex:j},T,{topItemCount:w},{groupCounts:S},N])=>{const{listState:R,minOverscanItemCount:I,topItemsIndexes:A,rangeChanged:$,...B}=E;return be($,N.scrollSeekRangeChanged),be(X(N.windowViewportRect,fe(C=>C.visibleHeight)),b.viewportHeight),{data:e,defaultItemHeight:r,firstItemIndex:n,fixedItemHeight:s,fixedGroupHeight:o,gap:a,groupCounts:S,heightEstimates:c,initialItemFinalLocationReached:y,initialTopMostItemIndex:x,scrolledToInitialItem:g,sizeRanges:u,topItemCount:w,topItemsIndexes:A,totalCount:h,...k,groupIndices:i,itemSize:d,listState:R,minOverscanItemCount:I,scrollToIndex:j,statefulTotalCount:f,trackItemSizes:m,rangeChanged:$,...B,...N,...b,sizes:p,...v}},We(Ht,gn,ft,mx,px,vr,xn,vx,gx,Cc,bx));function kx(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 Ln=typeof document<"u"?ve.useLayoutEffect:ve.useEffect;function Mc(e,r,n){const s=Object.keys(r.required||{}),o=Object.keys(r.optional||{}),a=Object.keys(r.methods||{}),i=Object.keys(r.events||{}),c=ve.createContext({});function d(g,b){g.propsReady!==void 0&&Ee(g.propsReady,!1);for(const v of s){const k=g[r.required[v]];Ee(k,b[v])}for(const v of o)if(v in b){const k=g[r.optional[v]];Ee(k,b[v])}g.propsReady!==void 0&&Ee(g.propsReady,!0)}function u(g){return a.reduce((b,v)=>(b[v]=k=>{const E=g[r.methods[v]];Ee(E,k)},b),{})}function p(g){return i.reduce((b,v)=>(b[v]=Fm(g[r.events[v]]),b),{})}const f=ve.forwardRef(function(g,b){const{children:v,...k}=g,[E]=ve.useState(()=>ps(Bm(e),w=>{d(w,k)})),[j]=ve.useState(ai(p,E));Ln(()=>{for(const w of i)w in k&&Ae(j[w],k[w]);return()=>{Object.values(j).map(ta)}},[k,j,E]),Ln(()=>{d(E,k)}),ve.useImperativeHandle(b,oi(u(E)));const T=n;return t.jsx(c.Provider,{value:E,children:n!==void 0?t.jsx(T,{...kx([...s,...o,...i],k),children:v}):v})}),h=g=>{const b=ve.useContext(c);return ve.useCallback(v=>{Ee(b[g],v)},[b,g])},m=g=>{const b=ve.useContext(c)[g],v=ve.useCallback(k=>Ae(b,k),[b]);return ve.useSyncExternalStore(v,()=>He(b),()=>He(b))},y=g=>{const b=ve.useContext(c)[g],[v,k]=ve.useState(ai(He,b));return Ln(()=>Ae(b,E=>{E!==v&&k(oi(E))}),[b,v]),v},x=parseInt(ve.version)>=18?m:y;return{Component:f,useEmitter:(g,b)=>{const v=ve.useContext(c)[g];Ln(()=>Ae(v,b),[b,v])},useEmitterValue:x,usePublisher:h}}const Dc=ve.createContext(void 0),Fc=ve.createContext(void 0),As="-webkit-sticky",gi="sticky",ca=Pc(()=>{if(typeof document>"u")return gi;const e=document.createElement("div");return e.style.position=As,e.style.position===As?As:gi}),zc=typeof document<"u"?ve.useLayoutEffect:ve.useEffect;function Ps(e){return"self"in e}function jx(e){return"body"in e}function Bc(e,r,n,s=zr,o,a){const i=ve.useRef(null),c=ve.useRef(null),d=ve.useRef(null),u=ve.useCallback(h=>{let m,y,x;const g=h.target;if(jx(g)||Ps(g)){const v=Ps(g)?g:g.defaultView;x=a===!0?v.scrollX:v.scrollY,m=a===!0?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,y=a===!0?v.innerWidth:v.innerHeight}else x=a===!0?g.scrollLeft:g.scrollTop,m=a===!0?g.scrollWidth:g.scrollHeight,y=a===!0?g.offsetWidth:g.offsetHeight;const b=()=>{e({scrollHeight:m,scrollTop:Math.max(x,0),viewportHeight:y})};h.suppressFlushSync===!0?b():nf.flushSync(b),c.current!==null&&(x===c.current||x<=0||x===m-y)&&(c.current=null,r(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,r,a]);ve.useEffect(()=>{const h=o||i.current;return s(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{s(null),h.removeEventListener("scroll",u)}},[i,u,n,s,o]);function p(h){const m=i.current;if(!m||(a===!0?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const y=h.behavior==="smooth";let x,g,b;Ps(m)?(g=Math.max(or(m.document.documentElement,a===!0?"width":"height"),a===!0?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),x=a===!0?m.innerWidth:m.innerHeight,b=a===!0?window.scrollX:window.scrollY):(g=m[a===!0?"scrollWidth":"scrollHeight"],x=or(m,a===!0?"width":"height"),b=m[a===!0?"scrollLeft":"scrollTop"]);const v=g-x;if(h.top=Math.ceil(Math.max(Math.min(v,h.top),0)),Nc(x,g)||h.top===b){e({scrollHeight:g,scrollTop:b,viewportHeight:x}),y&&r(!0);return}y?(c.current=h.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,c.current=null,r(!0)},1e3)):c.current=null,a===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},left:h.top}),m.scrollTo(h)}function f(h){a===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},...h.top!==void 0?{left:h.top}:{}}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:p}}function da(e){return e}const wx=Le(()=>{const e=oe(c=>`Item ${c}`),r=oe(c=>`Group ${c}`),n=oe({}),s=oe(da),o=oe("div"),a=oe(zr),i=(c,d=null)=>dt(X(n,fe(u=>u[c]),Oe()),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")}}),Sx=Le(([e,r])=>({...e,...r}),We($c,wx)),Cx=({height:e})=>t.jsx("div",{style:{height:e}}),Ex={overflowAnchor:"none",position:ca(),zIndex:1},_c={overflowAnchor:"none"},Nx={..._c,display:"inline-block",height:"100%"},yi=ve.memo(function({showTopList:e=!1}){const r=Ce("listState"),n=Nt("sizeRanges"),s=Ce("useWindowScroll"),o=Ce("customScrollParent"),a=Nt("windowScrollContainerState"),i=Nt("scrollContainerState"),c=o||s?a:i,d=Ce("itemContent"),u=Ce("context"),p=Ce("groupContent"),f=Ce("trackItemSizes"),h=Ce("itemSize"),m=Ce("log"),y=Nt("gap"),x=Ce("horizontalDirection"),{callbackRef:g}=Wm(n,h,f,e?zr:c,m,y,o,x,Ce("skipAnimationFrameInResizeObserver")),[b,v]=ve.useState(0);ua("deviation",B=>{b!==B&&v(B)});const k=Ce("EmptyPlaceholder"),E=Ce("ScrollSeekPlaceholder")??Cx,j=Ce("ListComponent"),T=Ce("ItemComponent"),w=Ce("GroupComponent"),S=Ce("computeItemKey"),N=Ce("isSeeking"),R=Ce("groupIndices").length>0,I=Ce("alignToBottom"),A=Ce("initialItemFinalLocationReached"),$=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:b!==0?b:I?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:b!==0?b:I?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...A?{}:{visibility:"hidden"}};return!e&&r.totalCount===0&&k!==null&&k!==void 0?t.jsx(k,{...ct(k,u)}):t.jsx(j,{...ct(j,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:$,children:(e?r.topItems:r.items).map(B=>{const C=B.originalIndex,L=S(C+r.firstItemIndex,B.data,u);return N?l.createElement(E,{...ct(E,u),height:B.size,index:B.index,key:L,type:B.type||"item",...B.type==="group"?{}:{groupIndex:B.groupIndex}}):B.type==="group"?l.createElement(w,{...ct(w,u),"data-index":C,"data-item-index":B.index,"data-known-size":B.size,key:L,style:Ex},p(B.index,u)):l.createElement(T,{...ct(T,u),...Lx(T,B.data),"data-index":C,"data-item-group-index":B.groupIndex,"data-item-index":B.index,"data-known-size":B.size,key:L,style:x?Nx:_c},R?d(B.index,B.groupIndex,B.data,u):d(B.index,B.data,u))})})}),Rx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Tx={outline:"none",overflowX:"auto",position:"relative"},hs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:void 0}),Ix={position:ca(),top:0,width:"100%",zIndex:1};function ct(e,r){if(typeof e!="string")return{context:r}}function Lx(e,r){return{item:typeof e=="string"?void 0:r}}const Ax=ve.memo(function(){const e=Ce("HeaderComponent"),r=Nt("headerHeight"),n=Ce("HeaderFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Px=ve.memo(function(){const e=Ce("FooterComponent"),r=Nt("footerHeight"),n=Ce("HeaderFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null});function Oc({useEmitter:e,useEmitterValue:r,usePublisher:n}){return ve.memo(function({children:s,style:o,context:a,...i}){const c=n("scrollContainerState"),d=r("ScrollerComponent"),u=n("smoothScrollTargetReached"),p=r("scrollerRef"),f=r("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:y}=Bc(c,u,d,p,void 0,f);return e("scrollTo",y),e("scrollBy",h),t.jsx(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?Tx:Rx,...o},tabIndex:0,...i,...ct(d,a),children:s})})}function Wc({useEmitter:e,useEmitterValue:r,usePublisher:n}){return ve.memo(function({children:s,style:o,context:a,...i}){const c=n("windowScrollContainerState"),d=r("ScrollerComponent"),u=n("smoothScrollTargetReached"),p=r("totalListHeight"),f=r("deviation"),h=r("customScrollParent"),m=ve.useRef(null),y=r("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:b}=Bc(c,u,d,y,h);return zc(()=>{var v;return g.current=h||((v=m.current)==null?void 0:v.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",b),e("scrollBy",x),t.jsx(d,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...p!==0?{height:p+f}:void 0},...i,...ct(d,a),children:s})})}const $x=({children:e})=>{const r=ve.useContext(Dc),n=Nt("viewportHeight"),s=Nt("fixedItemHeight"),o=Ce("alignToBottom"),a=Ce("horizontalDirection"),i=ve.useMemo(()=>fc(n,d=>or(d,a?"width":"height")),[n,a]),c=yr(i,!0,Ce("skipAnimationFrameInResizeObserver"));return ve.useEffect(()=>{r&&(n(r.viewportHeight),s(r.itemHeight))},[r,n,s]),t.jsx("div",{"data-viewport-type":"element",ref:c,style:hs(o),children:e})},Mx=({children:e})=>{const r=ve.useContext(Dc),n=Nt("windowViewportRect"),s=Nt("fixedItemHeight"),o=Ce("customScrollParent"),a=mc(n,o,Ce("skipAnimationFrameInResizeObserver")),i=Ce("alignToBottom");return ve.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:a,style:hs(i),children:e})},Dx=({children:e})=>{const r=Ce("TopItemListComponent")??"div",n=Ce("headerHeight"),s={...Ix,marginTop:`${n}px`},o=Ce("context");return t.jsx(r,{style:s,...ct(r,o),children:e})},Fx=ve.memo(function(e){const r=Ce("useWindowScroll"),n=Ce("topItemsIndexes").length>0,s=Ce("customScrollParent"),o=Ce("context");return t.jsxs(s||r?_x:Bx,{...e,context:o,children:[n&&t.jsx(Dx,{children:t.jsx(yi,{showTopList:!0})}),t.jsxs(s||r?Mx:$x,{children:[t.jsx(Ax,{}),t.jsx(yi,{}),t.jsx(Px,{})]})]})}),{Component:zx,useEmitter:ua,useEmitterValue:Ce,usePublisher:Nt}=Mc(Sx,{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"}},Fx),Bx=Oc({useEmitter:ua,useEmitterValue:Ce,usePublisher:Nt}),_x=Wc({useEmitter:ua,useEmitterValue:Ce,usePublisher:Nt}),Ox=zx,Wx=Le(()=>{const e=oe(u=>t.jsxs("td",{children:["Item $",u]})),r=oe(null),n=oe(u=>t.jsxs("td",{colSpan:1e3,children:["Group ",u]})),s=oe(null),o=oe(null),a=oe({}),i=oe(da),c=oe(zr),d=(u,p=null)=>dt(X(a,fe(f=>f[u]),Oe()),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:c,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")}});We($c,Wx);ca();const vi={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Ux={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:bi,floor:Zn,max:en,min:$s,round:ki}=Math;function ji(e,r,n){return Array.from({length:r-e+1}).map((s,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Hx(e){return{...Ux,items:e}}function An(e,r){return e!==void 0&&e.width===r.width&&e.height===r.height}function Vx(e,r){return e!==void 0&&e.column===r.column&&e.row===r.row}const Gx=Le(([{increaseViewportBy:e,listBoundary:r,overscan:n,visibleRange:s},{footerHeight:o,headerHeight:a,scrollBy:i,scrollContainerState:c,scrollTo:d,scrollTop:u,smoothScrollTargetReached:p,viewportHeight:f},h,m,{didMount:y,propsReady:x},{customScrollParent:g,useWindowScroll:b,windowScrollContainerState:v,windowScrollTo:k,windowViewportRect:E},j])=>{const T=oe(0),w=oe(0),S=oe(vi),N=oe({height:0,width:0}),R=oe({height:0,width:0}),I=Te(),A=Te(),$=oe(0),B=oe(null),C=oe({column:0,row:0}),L=Te(),P=Te(),M=oe(!1),H=oe(0),le=oe(!0),G=oe(!1),W=oe(!1);Ae(X(y,Re(H),je(([D,U])=>U!==0)),()=>{Ee(le,!1)}),Ae(X(qe(y,le,R,N,H,G),je(([D,U,K,V,,Y])=>D&&!U&&K.height!==0&&V.height!==0&&!Y)),([,,,,D])=>{Ee(G,!0),oa(1,()=>{Ee(I,D)}),$t(X(u),()=>{Ee(r,[0,0]),Ee(le,!0)})}),be(X(P,je(D=>D!=null&&D.scrollTop>0),zt(0)),w),Ae(X(y,Re(P),je(([,D])=>D!=null)),([,D])=>{D&&(Ee(N,D.viewport),Ee(R,D.item),Ee(C,D.gap),D.scrollTop>0&&(Ee(M,!0),$t(X(u,xr(1)),U=>{Ee(M,!1)}),Ee(d,{top:D.scrollTop})))}),be(X(N,fe(({height:D})=>D)),f),be(X(qe(ke(N,An),ke(R,An),ke(C,(D,U)=>D!==void 0&&D.column===U.column&&D.row===U.row),ke(u)),fe(([D,U,K,V])=>({gap:K,item:U,scrollTop:V,viewport:D}))),L),be(X(qe(ke(T),s,ke(C,Vx),ke(R,An),ke(N,An),ke(B),ke(w),ke(M),ke(le),ke(H)),je(([,,,,,,,D])=>!D),fe(([D,[U,K],V,Y,J,te,de,,se,ue])=>{const{column:F,row:q}=V,{height:re,width:Q}=Y,{width:pe}=J;if(de===0&&(D===0||pe===0))return vi;if(Q===0){const Ie=aa(ue,D),ee=Ie+Math.max(de-1,0);return Hx(ji(Ie,ee,te))}const xe=Uc(pe,Q,F);let we,ge;se?U===0&&K===0&&de>0?(we=0,ge=de-1):(we=xe*Zn((U+q)/(re+q)),ge=xe*bi((K+q)/(re+q))-1,ge=$s(D-1,en(ge,xe-1)),we=$s(ge,en(0,we))):(we=0,ge=-1);const Ve=ji(we,ge,te),{bottom:Ye,top:Pe}=wi(J,V,Y,Ve),rt=bi(D/xe),Je=rt*re+(rt-1)*q-Ye;return{bottom:Ye,itemHeight:re,items:Ve,itemWidth:Q,offsetBottom:Je,offsetTop:Pe,top:Pe}})),S),be(X(B,je(D=>D!==null),fe(D=>D.length)),T),be(X(qe(N,R,S,C),je(([D,U,{items:K}])=>K.length>0&&U.height!==0&&D.height!==0),fe(([D,U,{items:K},V])=>{const{bottom:Y,top:J}=wi(D,V,U,K);return[J,Y]}),Oe(ln)),r);const Z=oe(!1);be(X(u,Re(Z),fe(([D,U])=>U||D!==0)),Z);const he=jt(X(qe(S,T),je(([{items:D}])=>D.length>0),Re(Z),je(([[D,U],K])=>{const V=D.items[D.items.length-1].index===U-1;return(K||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===U)&&V}),fe(([[,D]])=>D-1),Oe())),me=jt(X(ke(S),je(({items:D})=>D.length>0&&D[0].index===0),zt(0),Oe())),_=jt(X(ke(S),Re(M),je(([{items:D},U])=>D.length>0&&!U),fe(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),Oe(kc),Kt(0)));be(_,m.scrollSeekRangeChanged),be(X(I,Re(N,R,T,C),fe(([D,U,K,V,Y])=>{const J=Ec(D),{align:te,behavior:de,offset:se}=J;let ue=J.index;ue==="LAST"&&(ue=V-1),ue=en(0,ue,$s(V-1,ue));let F=Ao(U,Y,K,ue);return te==="end"?F=ki(F-U.height+K.height):te==="center"&&(F=ki(F-U.height/2+K.height/2)),se!==void 0&&se!==0&&(F+=se),{behavior:de,top:F}})),d);const ne=dt(X(S,fe(D=>D.offsetBottom+D.bottom)),0);return be(X(E,fe(D=>({height:D.visibleHeight,width:D.visibleWidth}))),N),{customScrollParent:g,data:B,deviation:$,footerHeight:o,gap:C,headerHeight:a,increaseViewportBy:e,initialItemCount:w,itemDimensions:R,overscan:n,restoreStateFrom:P,scrollBy:i,scrollContainerState:c,scrollHeight:A,scrollTo:d,scrollToIndex:I,scrollTop:u,smoothScrollTargetReached:p,totalCount:T,useWindowScroll:b,viewportDimensions:N,windowScrollContainerState:v,windowScrollTo:k,windowViewportRect:E,...m,gridState:S,horizontalDirection:W,initialTopMostItemIndex:H,totalListHeight:ne,...h,endReached:he,propsReady:x,rangeChanged:_,startReached:me,stateChanged:L,stateRestoreInProgress:M,...j}},We(ia,ft,yn,Ac,dr,la,cr));function Uc(e,r,n){return en(1,Zn((e+n)/(Zn(r)+n)))}function wi(e,r,n,s){const{height:o}=n;if(o===void 0||s.length===0)return{bottom:0,top:0};const a=Ao(e,r,n,s[0].index);return{bottom:Ao(e,r,n,s[s.length-1].index)+o,top:a}}function Ao(e,r,n,s){const o=Uc(e.width,n.width,r.column),a=Zn(s/o),i=a*n.height+en(0,a-1)*r.row;return i>0?i+r.row:i}const Kx=Le(()=>{const e=oe(f=>`Item ${f}`),r=oe({}),n=oe(null),s=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),a=oe(da),i=oe("div"),c=oe(zr),d=(f,h=null)=>dt(X(r,fe(m=>m[f]),Oe()),h),u=oe(!1),p=oe(!1);return be(ke(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:c,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),qx=Le(([e,r])=>({...e,...r}),We(Gx,Kx)),Yx=ve.memo(function(){const e=Ue("gridState"),r=Ue("listClassName"),n=Ue("itemClassName"),s=Ue("itemContent"),o=Ue("computeItemKey"),a=Ue("isSeeking"),i=Rt("scrollHeight"),c=Ue("ItemComponent"),d=Ue("ListComponent"),u=Ue("ScrollSeekPlaceholder"),p=Ue("context"),f=Rt("itemDimensions"),h=Rt("gap"),m=Ue("log"),y=Ue("stateRestoreInProgress"),x=Rt("reportReadyState"),g=yr(ve.useMemo(()=>b=>{const v=b.parentElement.parentElement.scrollHeight;i(v);const k=b.firstChild;if(k!==null){const{height:E,width:j}=k.getBoundingClientRect();f({height:E,width:j})}h({column:Si("column-gap",getComputedStyle(b).columnGap,m),row:Si("row-gap",getComputedStyle(b).rowGap,m)})},[i,f,h,m]),!0,!1);return zc(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),y?null:t.jsx(d,{className:r,ref:g,...ct(d,p),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(b=>{const v=o(b.index,b.data,p);return a?t.jsx(u,{...ct(u,p),height:e.itemHeight,index:b.index,width:e.itemWidth},v):l.createElement(c,{...ct(c,p),className:n,"data-index":b.index,key:v},s(b.index,b.data,p))})})}),Jx=ve.memo(function(){const e=Ue("HeaderComponent"),r=Rt("headerHeight"),n=Ue("headerFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,!1),o=Ue("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Xx=ve.memo(function(){const e=Ue("FooterComponent"),r=Rt("footerHeight"),n=Ue("headerFooterTag"),s=yr(ve.useMemo(()=>a=>{r(or(a,"height"))},[r]),!0,!1),o=Ue("context");return e!=null?t.jsx(n,{ref:s,children:t.jsx(e,{...ct(e,o)})}):null}),Qx=({children:e})=>{const r=ve.useContext(Fc),n=Rt("itemDimensions"),s=Rt("viewportDimensions"),o=yr(ve.useMemo(()=>a=>{s(a.getBoundingClientRect())},[s]),!0,!1);return ve.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:hs(!1),children:e})},Zx=({children:e})=>{const r=ve.useContext(Fc),n=Rt("windowViewportRect"),s=Rt("itemDimensions"),o=Ue("customScrollParent"),a=mc(n,o,!1);return ve.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:a,style:hs(!1),children:e})},eg=ve.memo(function({...e}){const r=Ue("useWindowScroll"),n=Ue("customScrollParent"),s=n||r?rg:tg,o=n||r?Zx:Qx,a=Ue("context");return t.jsx(s,{...e,...ct(s,a),children:t.jsxs(o,{children:[t.jsx(Jx,{}),t.jsx(Yx,{}),t.jsx(Xx,{})]})})}),{useEmitter:Hc,useEmitterValue:Ue,usePublisher:Rt}=Mc(qx,{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"}},eg),tg=Oc({useEmitter:Hc,useEmitterValue:Ue,usePublisher:Rt}),rg=Wc({useEmitter:Hc,useEmitterValue:Ue,usePublisher:Rt});function Si(e,r,n){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,r,et.WARN),r==="normal"?0:parseInt(r??"0",10)}const ng={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Vc={source:"Own",installed:"Installed"};function sg(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 og(e,r){const n=r?"true":"false";try{localStorage.setItem(e,n)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(e,n)}catch{}}function Ci({origin:e,count:r,filteredCount:n,updateCount:s,children:o}){const a=ng[e],[i,c]=l.useState(()=>sg(a)),d=l.useCallback(()=>{c(h=>{const m=!h;return og(a,m),m})},[a]),u=Vc[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(ig,{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(ag,{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 ag({origin:e,updateCount:r}){const[n,s]=l.useState(!1),o=Vc[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 ig({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 pa(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 lg({value:e,onChange:r,placeholder:n="Filter skills…",validationPattern:s,validationMessage:o="Invalid filter expression"}){const a=l.useRef(null),i=l.useId(),c=!!s&&e.trim()!==""&&!s.test(e);return l.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":c?!0:void 0,"aria-describedby":c?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"}}),c&&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 cg({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 dg({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 ug({skillId:e,trackedForUpdates:r}){let n=null;try{n=l.useContext(tc)}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 pg(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 vn(e){const{version:r,showPrefix:n=!0,size:s="md",source:o,pluginName:a}=e,i=typeof r=="string"?r.trim():"",c=i===""||i==="0.0.0"?"1.0.0":i,d=n&&!c.startsWith("v")?`v${c}`:c,u=s==="sm"?10:12,p=s==="sm"?1:2,f=s==="sm"?5:8,h=o==="registry"||o==="plugin",m=pg(o,c,a),y=e.title??m,x={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&&(x.fontStyle="italic"),t.jsx("span",{"data-testid":e["data-testid"]??"version-badge","data-version":c,"data-version-source":o,title:y,style:x,children:d})}const fg={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 Gc({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 hg({tenantName:e,variant:r="inline"}){const n=fg[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(Gc,{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 mg({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(Gc,{size:11}),r==="tag"?t.jsx("span",{children:"Private"}):null]})}function xg({skill:e,isSelected:r,onSelect:n,onContextMenu:s,dirty:o,repoVisibility:a,repoFullName:i}){const c=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:c,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(vn,{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(mg,{repoFullName:i??null}),e.isSymlink&&t.jsx(cg,{target:e.symlinkTarget??null}),t.jsx(dg,{skill:e}),t.jsx(ug,{skillId:`${e.plugin}/${e.skill}`,trackedForUpdates:e.trackedForUpdates??!0})]})}const tn=l.memo(xg),Kc={platformBaseUrl:"",authMode:"cookie",getAuthHeader:async()=>null},qc=l.createContext(Kc);function gg({value:e,children:r}){const n=l.useMemo(()=>({...Kc,...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(qc.Provider,{value:n,children:r})}function ht(){return l.useContext(qc)}function yg(e,r){const n=e.platformBaseUrl.replace(/\/+$/,""),s=r.startsWith("/")?r:`/${r}`;return`${n}${s}`}const Br=6e4,Ze={profile:()=>"account:profile",repos:()=>"account:repos",tokens:()=>"account:tokens",skills:()=>"account:skills",notifications:()=>"account:notifications",exports:()=>"account:exports"};async function mt(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 c=await e.getAuthHeader();c&&o.set("Authorization",c)}const a=e.authMode==="cookie"?"include":"omit",i=await s(yg(e,r),{...n,headers:o,credentials:a});if(!i.ok){let c="";try{c=await i.text()}catch{}const d=new Error(`Request to ${r} failed (${i.status}): ${c.slice(0,240)}`);throw d.status=i.status,d}if(i.status!==204)return await i.json()}function bn(){const e=ht();return St(Ze.profile(),()=>mt(e,"/api/v1/account/profile"),{ttl:Br})}function Yc(){const e=ht();return l.useCallback(async r=>{const n=await mt(e,"/api/v1/account/profile",{method:"PATCH",body:JSON.stringify(r)});return Be(Ze.profile()),n},[e])}function ms(){const e=ht();return St(Ze.repos(),async()=>vg(await mt(e,"/api/v1/account/repos")),{ttl:Br})}function fa(e){return(e==null?void 0:e.repos)??[]}function vg(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 Jc(){const e=ht();return l.useCallback(async r=>{await mt(e,`/api/v1/account/repos/${r}/resync`,{method:"POST"}),Be(Ze.repos())},[e])}function Xc(){const e=ht();return l.useCallback(async r=>{await mt(e,`/api/v1/account/repos/${r}`,{method:"DELETE"}),Be(Ze.repos())},[e])}function Qc(){const e=ht();return St(Ze.tokens(),async()=>bg(await mt(e,"/api/v1/account/tokens")),{ttl:Br})}function bg(e){return Array.isArray(e)?e:e.tokens??[]}function Zc(){const e=ht();return l.useCallback(async r=>{const n=await mt(e,"/api/v1/account/tokens",{method:"POST",body:JSON.stringify(r)});return Be(Ze.tokens()),n},[e])}function ed(){const e=ht();return l.useCallback(async r=>{await mt(e,`/api/v1/account/tokens/${r}`,{method:"DELETE"}),Be(Ze.tokens())},[e])}function td(){const e=ht();return St(Ze.notifications(),()=>mt(e,"/api/v1/account/notifications"),{ttl:Br})}function rd(){const e=ht();return l.useCallback(async r=>{const n=await mt(e,"/api/v1/account/notifications",{method:"PATCH",body:JSON.stringify(r)});return Be(Ze.notifications()),n},[e])}function kg(){const e=ht();return St(Ze.skills(),()=>mt(e,"/api/v1/account/skills/summary"),{ttl:Br})}function nd(){const e=ht();return St(Ze.exports(),async()=>(await mt(e,"/api/v1/account/export")).exports,{ttl:Br})}function sd(){const e=ht();return l.useCallback(async()=>{await mt(e,"/api/v1/account/sign-out-all",{method:"POST"}),Be(Ze.profile()),Be(Ze.repos()),Be(Ze.tokens()),Be(Ze.notifications()),Be(Ze.skills()),Be(Ze.exports())},[e])}function od(){const e=ht();return l.useCallback(async()=>{const r=await mt(e,"/api/v1/account/export",{method:"POST"});return Be(Ze.exports()),r},[e])}function ad(){const e=ht();return l.useCallback(async r=>{await mt(e,"/api/v1/account/delete",{method:"POST",body:JSON.stringify({confirmHandle:r})})},[e])}function jg(){return{profile:bn(),repos:ms(),tokens:Qc(),skills:kg(),notifications:td(),exports:nd(),updateProfile:Yc(),resyncRepo:Jc(),disconnectRepo:Xc(),createToken:Zc(),revokeToken:ed(),updateNotificationPrefs:rd(),signOutAll:sd(),requestExport:od(),deleteAccount:ad()}}const wg=/^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/?#]+?)(?:\.git)?\/?$/i,Sg=/^git@github\.com:([^/]+)\/([^/?#]+?)(?:\.git)?$/i;function kn(e){if(!e)return null;const r=e.trim(),n=wg.exec(r);if(n)return`${n[1].toLowerCase()}/${n[2].toLowerCase()}`;const s=Sg.exec(r);return s?`${s[1].toLowerCase()}/${s[2].toLowerCase()}`:null}function id(e){const r=new Map;for(const n of e)r.set(n.repoFullName.toLowerCase(),n);return r}function Cg(e,r){const n=kn(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 Eg(e){const{data:r}=ms(),n=l.useMemo(()=>id(fa(r)),[r]);return Cg(e,n)}function ld(){const{data:e,loading:r}=ms(),n=fa(e);return{lookup:l.useMemo(()=>id(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 cd({plugin:e,skills:r,selectedKey:n,onSelect:s,onContextMenu:o,dirtySkillIds:a,repoVisibilityLookup:i}){var p;const c=[...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:c.map(f=>{const h=!!n&&n.plugin===f.plugin&&n.skill===f.skill,m=i?kn(f.repoUrl):null,y=m?i.get(m)??null:null,x=y?y.isPrivate?"private":"public":"unknown";return t.jsx("div",{role:"listitem",children:t.jsx(tn,{skill:f,isSelected:h,onSelect:()=>s(f),onContextMenu:o,dirty:a==null?void 0:a.has(`${f.plugin}/${f.skill}`),repoVisibility:x,repoFullName:(y==null?void 0:y.repoFullName)??null})},`${f.plugin}/${f.skill}`)})})]})}function Ng(e,r){if(!r)return!1;const n=kn(e.repoUrl);if(!n)return!1;const s=r.get(n);return(s==null?void 0:s.isPrivate)===!0}function Rg(e,r){const n=[],s=[];let o=0,a=0;for(const[i,c]of e){const d=[],u=[];for(const p of c)Ng(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 Tg(e){try{const r=localStorage.getItem(e);if(r!=null)return r==="true"}catch{}return!1}function Ig(e,r){try{localStorage.setItem(e,r?"true":"false")}catch{}}function Lg({items:e,agentId:r,sectionName:n,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:c,children:d}){const{privateItems:u,publicItems:p,privateCount:f,publicCount:h}=Rg(e,s);if(f===0||h===0)return t.jsx(t.Fragment,{children:d});const m=`vskill-sidebar-${r}-section-${n}-private-collapsed`,y=`vskill-sidebar-${r}-section-${n}-public-collapsed`;return t.jsxs("div",{"data-testid":"section-privacy-subgroups",children:[t.jsx(Ei,{testId:"sidebar-subgroup-private",storageKey:m,icon:"🔒",label:"Private repos",count:f,items:u,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:c}),t.jsx(Ei,{testId:"sidebar-subgroup-public",storageKey:y,icon:"🌐",label:"Public repos",count:h,items:p,repoVisibilityLookup:s,selectedKey:o,onSelect:a,onContextMenu:i,dirtySkillIds:c})]})}function Ei({testId:e,storageKey:r,icon:n,label:s,count:o,items:a,repoVisibilityLookup:i,selectedKey:c,onSelect:d,onContextMenu:u,dirtySkillIds:p}){const[f,h]=l.useState(()=>Tg(r)),m=l.useCallback(()=>{h(x=>{const g=!x;return Ig(r,g),g})},[r]),y=`${e}-group`;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","data-testid":e,"aria-expanded":!f,"aria-controls":y,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:y,role:"group",children:a.map(([x,g])=>t.jsx(cd,{plugin:x,skills:g,selectedKey:c,onSelect:d,onContextMenu:u,dirtySkillIds:p,repoVisibilityLookup:i},x))})]})}function Ag(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 Ms({skills:e,pluginName:r,initialCollapsed:n=!1,persistKey:s,renderSkill:o,headerActionSlot:a,forceOpen:i=!1}){var m;const c=r??((m=e[0])==null?void 0:m.pluginName)??"unknown-plugin",[d,u]=l.useState(()=>Ag(s,n)),p=i?!1:d,f=l.useCallback(()=>{u(y=>{const x=!y;if(s&&typeof window<"u")try{window.localStorage.setItem(s,String(x))}catch{}return x})},[s]),h=p?"▸":"▾";return t.jsxs("div",{"data-vskill-plugin-tree":c,role:"group","aria-label":`${c} (${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:c}),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(y=>t.jsx("div",{"data-vskill-plugin-skill":y.pluginNamespace??y.skill,children:o(y)},`${y.pluginNamespace??y.skill}`))})]})}function qn({open:e,title:r,body:n,confirmLabel:s="Confirm",cancelLabel:o="Cancel",variant:a="default",onConfirm:i,onCancel:c}){const d=l.useRef(null),u=l.useRef(null),p=l.useRef(null);if(l.useEffect(()=>{if(e)return p.current=document.activeElement??null,requestAnimationFrame(()=>{var y;(y=u.current)==null||y.focus()}),()=>{var y,x;(x=(y=p.current)==null?void 0:y.focus)==null||x.call(y),p.current=null}},[e]),l.useEffect(()=>{if(!e)return;function y(x){if(x.key==="Escape"){x.preventDefault(),c();return}if(x.key==="Tab"&&d.current){const g=d.current.querySelectorAll("button:not([disabled])");if(g.length===0)return;const b=g[0],v=g[g.length-1];x.shiftKey&&document.activeElement===b?(x.preventDefault(),v.focus()):!x.shiftKey&&document.activeElement===v&&(x.preventDefault(),b.focus())}}return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[e,c]),!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:y=>{y.target===y.currentTarget&&c()},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:c,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 Pg(e){const r=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return r.includes("mac")?"system Trash":r.includes("win")?"Recycle Bin":"Trash"}function Ds(e,r){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function $g({pluginName:e,enabled:r,onAfterAction:n}){const[s,o]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[u,p]=l.useState(!1),f=l.useRef(null);l.useEffect(()=>{if(!s)return;function y(x){f.current&&!f.current.contains(x.target)&&o(!1)}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[s]);async function h(y){i(y),d(null);try{const x=await fetch(`/api/plugins/${encodeURIComponent(e)}/${y}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),g=await x.json().catch(()=>({}));if(!x.ok||!g.ok){const b=g.error??`${y} failed (${x.status})`;d(b),y==="uninstall"&&Ds(`Failed to uninstall ${e}: ${b}`,"error");return}if(y==="uninstall"){const b=g.fallback==="orphan-cache-removed"?`Removed orphaned ${e}`:`Uninstalled ${e}`;Ds(b,"success")}Be("skills"),uc(),n==null||n(),o(!1)}catch(x){const g=x instanceof Error?x.message:String(x);d(g),y==="uninstall"&&Ds(`Failed to uninstall ${e}: ${g}`,"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:y=>{y.stopPropagation(),o(x=>!x)},"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:y=>{y.currentTarget.style.color="var(--text-primary)",y.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:y=>{y.currentTarget.style.color="var(--text-tertiary)",y.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(Fs,{onClick:()=>void h("disable"),disabled:a!==null,busy:a==="disable",label:"Disable",hint:"Keep installed, turn off"}):t.jsx(Fs,{onClick:()=>void h("enable"),disabled:a!==null,busy:a==="enable",label:"Enable",hint:"Activate plugin"}),t.jsx(Fs,{onClick:m,disabled:a!==null,busy:a==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),c&&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:c})]}),t.jsx(qn,{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 Fs({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 Mg=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function Dg({anchorSkillDir:e,candidateLabel:r,initialName:n,initialDescription:s,onConverted:o,onCancel:a}){const[i,c]=l.useState(n),[d,u]=l.useState(s??""),[p,f]=l.useState(!1),[h,m]=l.useState(null),[y,x]=l.useState(null),g=Mg.test(i),b=p||!g,v=l.useCallback(async k=>{if(k.preventDefault(),!b){f(!0),m(null),x(null);try{const E=await ce.convertToPlugin({anchorSkillDir:e,pluginName:i.trim(),description:d.trim()});o({pluginDir:E.pluginDir,manifestPath:E.manifestPath,validation:E.validation})}catch(E){if(E instanceof qt){m(E.message);const j=E.details;j&&typeof j.stderr=="string"&&x(j.stderr)}else m(E instanceof Error?E.message:String(E));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:k=>{k.target===k.currentTarget&&!p&&a()},children:t.jsxs("form",{onSubmit:v,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:k=>c(k.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}}),!g&&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:k=>u(k.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}),y&&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:y})]}),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 Ni({name:e,count:r,className:n,variant:s,collapsed:o,onToggle:a,action:i}){const c=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 ${c}`,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:c,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(Fg,{label:i.label,title:i.title,icon:i.icon,onClick:i.onClick,accent:c})})]});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 Fg({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 zg(){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 Bg(e){const r=e.key.split("+").map(c=>c.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 c of r.slice(0,-1)){const d=c.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 _g(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 Og(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 Po(e,r={}){const{enabled:n=!0,target:s}=r,o=l.useRef([]),a=Array.isArray(e)?e:[e];o.current=a.map(Bg),l.useEffect(()=>{if(!n)return;const i=s??(typeof window<"u"?window:void 0);if(!i)return;function c(d){const u=d,p=_g(u.target);for(const f of o.current){if(!Og(u,f))continue;const h=f.meta||f.ctrl||f.alt;if(!(p&&!f.allowInInputs&&!h)){f.handler(u);return}}}return i.addEventListener("keydown",c),()=>{i.removeEventListener("keydown",c)}},[n,s])}function dd(){const{data:e,loading:r,error:n,revalidate:s}=St("project-github-status",()=>ce.getProjectGitHubStatus());return{status:e,loading:r,error:n,revalidate:s}}function Wg(e){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${e}`)==="true"}catch{return!1}}function Ug({projectRoot:e}){const{status:r,loading:n}=dd();if(n||!r||r.status==="github"||Wg(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 Hg=3e4;async function Vg(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 ud=l.forwardRef(function({folder:r,fetchRepoInfo:n=Vg,pollIntervalMs:s=Hg,tier:o,onUpgradeClick:a,onConnectPrivateClick:i},c){const d=o==="pro"||o==="enterprise"?o:"free",u=d!=="free",[p,f]=l.useState(null),[h,m]=l.useState(!1),[y,x]=l.useState(null),g=l.useRef(n);g.current=n;const b=async()=>{if(!r){f(null);return}m(!0),x(null);try{const v=await g.current(r);f(v)}catch(v){x(v instanceof Error?v.message:String(v))}finally{m(!1)}};return l.useImperativeHandle(c,()=>({refresh:b}),[r]),l.useEffect(()=>{if(!r){f(null);return}let v=!1,k=null;const E=async()=>{if(!v&&!(typeof document<"u"&&document.visibilityState!=="visible"))try{const T=await g.current(r);v||f(T)}catch(T){v||x(T instanceof Error?T.message:String(T))}};E(),k=setInterval(E,s);const j=()=>{typeof document<"u"&&document.visibilityState==="visible"&&E()};return typeof document<"u"&&document.addEventListener("visibilitychange",j),()=>{v=!0,k!==null&&clearInterval(k),typeof document<"u"&&document.removeEventListener("visibilitychange",j)}},[r,s]),r?y?t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"error",style:Ur,children:t.jsxs("span",{style:{color:"var(--color-error, #c0392b)",fontSize:12},children:["Couldn't load repo info: ",y]})}):p?!p.name&&p.sync_state.kind==="no_remote"?t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"not-git",style:Ur,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":d,style:Ur,children:[t.jsx("span",{style:Xg,"data-testid":"repo-name",children:p.name??"Local-only"}),p.branch?t.jsxs("span",{style:Qg,"data-testid":"repo-branch",children:[t.jsx(Kg,{})," ",p.branch]}):null,t.jsx(Jg,{state:p.sync_state}),t.jsx(Gg,{isPrivate:p.is_private,isPaid:u,onUpgradeClick:a,onConnectPrivateClick:i})]}):t.jsx("div",{"data-testid":"connected-repo-widget","data-state":"loading","aria-busy":h||void 0,style:Ur,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:Ur,children:t.jsx("span",{style:{color:"var(--color-muted, #999)",fontSize:12},children:"No project folder selected"})})});function Gg({isPrivate:e,isPaid:r,onUpgradeClick:n,onConnectPrivateClick:s}){return e!==!0?t.jsx(Yg,{isPrivate:e}):r?t.jsxs("span",{style:{..._t,color:"var(--color-private, #b58900)"},"data-testid":"visibility-pill","data-visibility":"private","aria-label":"Private repository",children:[t.jsx($o,{})," private",s?t.jsx("button",{type:"button",onClick:s,"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:ey,children:"Connect"}):null]}):t.jsxs("span",{style:{..._t,color:"var(--color-private, #b58900)"},"data-testid":"visibility-pill","data-visibility":"private-locked","aria-label":"Private repository — Pro feature",children:[t.jsx($o,{})," private",t.jsx("button",{type:"button",onClick:n,"data-testid":"repo-upgrade-chip",title:"Upgrade for private repo connections.","aria-label":"Upgrade to Pro for private repository connections",style:Zg,children:"Pro"})]})}function Kg(){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 $o(){return t.jsxs("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("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function qg(){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 Yg({isPrivate:e}){return e===null?t.jsx("span",{style:{..._t,color:"var(--color-muted, #999)"},"data-testid":"visibility-pill","data-visibility":"unknown",children:"unknown"}):e?t.jsxs("span",{style:{..._t,color:"var(--color-private, #b58900)"},"data-testid":"visibility-pill","data-visibility":"private","aria-label":"Private repository",children:[t.jsx($o,{})," private"]}):t.jsxs("span",{style:{..._t,color:"var(--color-public, #2aa198)"},"data-testid":"visibility-pill","data-visibility":"public","aria-label":"Public repository",children:[t.jsx(qg,{})," public"]})}function Jg({state:e}){return e.kind==="clean"?t.jsx("span",{style:{..._t,color:"var(--color-clean, #859900)"},"data-testid":"sync-state-pill","data-sync":"clean",children:"in sync"}):e.kind==="no_remote"?t.jsx("span",{style:{..._t,color:"var(--color-muted, #999)"},"data-testid":"sync-state-pill","data-sync":"no_remote",children:"no remote"}):e.kind==="dirty"?t.jsxs("span",{style:{..._t,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:{..._t,color:"var(--color-ahead, #268bd2)"},"data-testid":"sync-state-pill","data-sync":"ahead",children:["+",e.count," ahead"]}):t.jsxs("span",{style:{..._t,color:"var(--color-behind, #6c71c4)"},"data-testid":"sync-state-pill","data-sync":"behind",children:["-",e.count," behind"]})}const Ur={display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap",fontSize:12,fontFamily:"var(--font-system, -apple-system, system-ui)"},Xg={fontWeight:500,color:"var(--color-text, #333)"},Qg={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},_t={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},Zg={marginLeft:4,padding:"0px 5px",borderRadius:9999,border:"none",background:"var(--color-pro-bg, #cb4b16)",color:"var(--color-pro-fg, #ffffff)",fontSize:9,fontWeight:600,letterSpacing:.4,textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},ey={marginLeft:4,padding:"0px 6px",borderRadius:9999,border:"1px solid currentColor",background:"transparent",color:"inherit",fontSize:10,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},ty=200;function ry(e){return e.scope==="own"||e.scope==="installed"||e.scope==="global"?e.scope:e.origin==="installed"?"installed":"own"}function ny(e,r){const n={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const i of e){const c=i.scopeV2??(i.scope==="installed"?"available-project":i.scope==="global"?"available-personal":"authoring-project");c==="available-project"?n.availableProject.push(i):c==="available-personal"?n.availablePersonal.push(i):c==="available-plugin"?n.availablePlugin.push(i):c==="authoring-plugin"?n.authoringPlugin.push(i):n.authoringProject.push(i)}function s(i){const c=i.filter(p=>pa(p,r)),d={};for(const p of c){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:c.length,byPlugin:u}}const o=s(n.authoringProject),a=o.byPlugin.filter(([i,c])=>c.length>=2&&i.trim().length>=2).map(([i,c])=>({groupKey:i,skills:c,anchorSkillDir:c[0].dir}));return{availableProject:s(n.availableProject),availablePersonal:s(n.availablePersonal),availablePlugin:s(n.availablePlugin),authoringProject:o,authoringPlugin:s(n.authoringPlugin),authoringCandidatePlugins:a}}function sy(e,r){const n=[],s=[],o=[];for(const i of e){const c=ry(i);c==="global"?o.push(i):c==="installed"?s.push(i):n.push(i)}function a(i){var p;const c=i.filter(f=>pa(f,r)),d={};for(const f of c)(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:c.length,byPlugin:u}}return{own:a(n),installed:a(s),global:a(o)}}function oy(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=>pa(p,r)),c={};for(const p of i)(c[u=p.plugin]||(c[u]=[])).push(p);const d=Object.entries(c).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 ay({skills:e,selectedKey:r,onSelect:n,isLoading:s,error:o,onRetry:a,onContextMenu:i,outdatedByOrigin:c,activeAgentId:d,outdatedByScope:u,topSlot:p,revealSkillId:f,onRevealComplete:h,dirtySkillIds:m,onSkillsChanged:y}){const[x,g]=l.useState(null),b=!!d||e.some(D=>D.scope!==void 0&&D.scope!==null),v=d??"claude-cli",[k,E]=l.useState(""),j=l.useDeferredValue(k),T=l.useMemo(()=>sy(e,j),[e,j]),w=l.useMemo(()=>ny(e,j),[e,j]),S=v==="claude-code",{plugins:N}=Lm(),R=S?{plugins:N??[]}:void 0,I=l.useMemo(()=>{const D=new Map;for(const U of(R==null?void 0:R.plugins)??[]){const K=D.get(U.name);D.set(U.name,!!K||!!U.enabled)}return D},[R==null?void 0:R.plugins]),[A,$]=l.useState(()=>Mo(`vskill-sidebar-${v}-group-available-collapsed`)),[B,C]=l.useState(()=>Mo(`vskill-sidebar-${v}-group-authoring-collapsed`)),L=l.useCallback(D=>{$(D);try{window.localStorage.setItem(`vskill-sidebar-${v}-group-available-collapsed`,String(D))}catch{}},[v]),P=l.useCallback(D=>{C(D);try{window.localStorage.setItem(`vskill-sidebar-${v}-group-authoring-collapsed`,String(D))}catch{}},[v]),{own:M,installed:H}=l.useMemo(()=>oy(e,j),[e,j]),G=T.own.filtered+T.installed.filtered+T.global.filtered>=ty,{lookup:W}=ld(),Z=l.useMemo(()=>{const D=U=>{const K=[];for(const[,V]of U){const Y=[...V].sort((J,te)=>J.skill.localeCompare(te.skill));K.push(...Y)}return K};return b?[...D(T.own.byPlugin),...D(T.installed.byPlugin),...D(T.global.byPlugin)]:[...D(M.byPlugin),...D(H.byPlugin)]},[b,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,M.byPlugin,H.byPlugin]),he=l.useMemo(()=>r?Z.findIndex(D=>D.plugin===r.plugin&&D.skill===r.skill):-1,[Z,r]),me=l.useCallback(D=>{if(Z.length===0)return;const U=he<0?D>0?0:Z.length-1:Math.min(Math.max(he+D,0),Z.length-1);n(Z[U])},[Z,he,n]),_=l.useMemo(()=>{if(!f)return null;const[D,U]=f.split("/");if(!D||!U)return null;const K=e.find(J=>J.plugin===D&&J.skill===U);if(!K)return{plugin:D,skill:U,bucket:null,pluginName:null};const V=K.source==="plugin"?"plugin":"project",Y=V==="plugin"?K.pluginName??D:null;return{plugin:D,skill:U,bucket:V,pluginName:Y}},[f,e]),ne=l.useRef(null);return l.useEffect(()=>{if(!f){ne.current=null;return}if(ne.current===f)return;const D=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/["\\]/g,"\\$&"),U=document.querySelector(`[data-skill-id="${D}"]`);U&&(ne.current=f,U.scrollIntoView({behavior:"smooth",block:"nearest"}),h==null||h())},[f,h,e]),Po([{key:"j",handler:()=>me(1)},{key:"k",handler:()=>me(-1)},{key:"Enter",handler:()=>{he>=0&&n(Z[he])}}],{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(lg,{value:k,onChange:E}),s&&t.jsx(fy,{}),!s&&o&&t.jsx(hy,{error:o,onRetry:a}),!s&&!o&&b&&t.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[t.jsx(Ni,{name:O.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:A,onToggle:L,count:w.availableProject.total+w.availablePersonal.total+w.availablePlugin.total}),!A&&t.jsxs(t.Fragment,{children:[t.jsx(Hr,{label:O.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${v}-available-project-collapsed`,count:w.availableProject.total,filteredCount:k?w.availableProject.filtered:null,updateCount:(u==null?void 0:u.installed)??(c==null?void 0:c.installed),headerRightSlot:S?t.jsx(xy,{projectRoot:v}):null,children:w.availableProject.filtered===0?t.jsx(Ti,{queryActive:!!k,agentId:v}):t.jsx(Vr,{items:w.availableProject.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"available-project"})}),t.jsx(Hr,{label:O.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${v}-available-personal-collapsed`,count:w.availablePersonal.total,filteredCount:k?w.availablePersonal.filtered:null,updateCount:u==null?void 0:u.global,children:w.availablePersonal.filtered===0?t.jsx(ly,{queryActive:!!k,agentId:v}):t.jsx(Vr,{items:w.availablePersonal.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"available-personal"})}),S&&t.jsxs(Hr,{label:O.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${v}-available-plugin-collapsed`,count:w.availablePlugin.total,filteredCount:k?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(cy,{queryActive:!!k,hasInstalled:w.availablePlugin.total>0}):w.availablePlugin.byPlugin.map(([D,U])=>t.jsx(Ms,{pluginName:D,skills:U,persistKey:`vskill-plugin-available-${D}-collapsed`,headerActionSlot:S?t.jsx($g,{pluginName:D,enabled:I.get(D)??!0}):void 0,renderSkill:K=>t.jsx(tn,{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-${D}`))]})]}),t.jsx(py,{}),t.jsx(Ni,{name:O.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:_?!1:B,onToggle:P,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"}}))}}}),(!B||_)&&t.jsxs(t.Fragment,{children:[t.jsx(Hr,{label:O.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${v}-authoring-project-collapsed`,count:w.authoringProject.total,filteredCount:k?w.authoringProject.filtered:null,updateCount:(u==null?void 0:u.own)??(c==null?void 0:c.source),forceOpen:(_==null?void 0:_.bucket)==="project",children:w.authoringProject.filtered===0?t.jsx(Ri,{queryActive:!!k}):t.jsxs(t.Fragment,{children:[w.authoringCandidatePlugins.map(D=>t.jsx(Ms,{pluginName:D.groupKey,skills:D.skills,persistKey:`vskill-candidate-plugin-${D.groupKey}-collapsed`,headerActionSlot:t.jsx("button",{type:"button",onClick:U=>{U.stopPropagation(),g({candidateLabel:D.groupKey,initialName:D.groupKey,anchorSkillDir:D.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(tn,{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-${D.groupKey}`)),t.jsx(Vr,{items:w.authoringProject.byPlugin.filter(([D])=>!w.authoringCandidatePlugins.some(U=>U.groupKey===D)),selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"authoring-project"})]})}),S&&t.jsx(Hr,{label:O.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${v}-authoring-plugin-collapsed`,count:w.authoringPlugin.total,filteredCount:k?w.authoringPlugin.filtered:null,forceOpen:(_==null?void 0:_.bucket)==="plugin",children:w.authoringPlugin.filtered===0?t.jsx(dy,{queryActive:!!k,hasSources:w.authoringPlugin.total>0,candidates:w.authoringCandidatePlugins,onPromote:D=>g({candidateLabel:D.groupKey,initialName:D.groupKey,anchorSkillDir:D.anchorSkillDir})}):w.authoringPlugin.byPlugin.map(([D,U])=>t.jsx(Ms,{pluginName:D,skills:U,persistKey:`vskill-plugin-authoring-${D}-collapsed`,forceOpen:(_==null?void 0:_.bucket)==="plugin"&&_.pluginName===D,renderSkill:K=>t.jsx(tn,{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-${D}`))})]})]}),!s&&!o&&!b&&t.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[t.jsx(Ci,{origin:"source",count:M.total,filteredCount:k?M.filtered:null,updateCount:c==null?void 0:c.source,children:M.filtered===0?t.jsx(Ri,{queryActive:!!k}):t.jsx(Vr,{items:M.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"own"})}),t.jsx(uy,{}),t.jsx(Ci,{origin:"installed",count:H.total,filteredCount:k?H.filtered:null,updateCount:c==null?void 0:c.installed,children:H.filtered===0?t.jsx(Ti,{queryActive:!!k}):t.jsx(Vr,{items:H.byPlugin,selectedKey:r,onSelect:n,onContextMenu:i,useVirtual:G,dirtySkillIds:m,repoVisibilityLookup:W,agentId:v,sectionName:"installed"})})]}),x&&t.jsx(Dg,{anchorSkillDir:x.anchorSkillDir,candidateLabel:x.candidateLabel,initialName:x.initialName,onCancel:()=>g(null),onConverted:D=>{g(null),y==null||y(),D.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 Mo(e){if(typeof window>"u")return!1;try{return window.localStorage.getItem(e)==="true"}catch{return!1}}function Hr({label:e,storageKey:r,count:n,filteredCount:s,updateCount:o,children:a,forceOpen:i=!1,headerRightSlot:c}){const[d,u]=l.useState(()=>Mo(r)),p=i?!1:d,f=l.useCallback(()=>{u(m=>{const y=!m;if(typeof window<"u")try{window.localStorage.setItem(r,String(y))}catch{}return y})},[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":""]})]}),c]}),!p&&t.jsx("div",{style:{paddingLeft:18},children:a})]})}function iy(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 Vr({items:e,selectedKey:r,onSelect:n,onContextMenu:s,useVirtual:o,dirtySkillIds:a,repoVisibilityLookup:i,agentId:c,sectionName:d}){if(o){const p=iy(e);return t.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:t.jsx(Ox,{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,y=!!r&&r.plugin===m.plugin&&r.skill===m.skill,x=i?kn(m.repoUrl):null,g=x?i.get(x)??null:null,b=g?g.isPrivate?"private":"public":"unknown";return t.jsx(tn,{skill:m,isSelected:y,onSelect:()=>n(m),onContextMenu:s,dirty:a==null?void 0:a.has(`${m.plugin}/${m.skill}`),repoVisibility:b,repoFullName:(g==null?void 0:g.repoFullName)??null})}})})}const u=e.map(([p,f])=>t.jsx(cd,{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(Lg,{items:e,agentId:c??"claude-cli",sectionName:d??"section",repoVisibilityLookup:i,selectedKey:r,onSelect:n,onContextMenu:s,dirtySkillIds:a,children:u})})}function Ri({queryActive:e}){return e?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:"No skills yet.",body:t.jsxs(t.Fragment,{children:["Create one with ",t.jsx(Ar,{children:"vskill new"})," or the"," ",t.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ti({queryActive:e,agentId:r}){return e?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:t.jsxs(t.Fragment,{children:["Run ",t.jsx(Ar,{children:"vskill install <skill>"})," to add one."]})})}function ly({queryActive:e,agentId:r}){return e?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:`No global skills for ${r}.`,body:t.jsxs(t.Fragment,{children:["Run ",t.jsx(Ar,{children:"vskill install --global <skill>"})," to add one."]})})}function cy({queryActive:e,hasInstalled:r}){return e&&r?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsx(Ut,{headline:"No plugin skills installed yet.",body:t.jsxs(t.Fragment,{children:["Click ",t.jsx(Ar,{children:"Browse marketplaces…"})," above to add one."]})})}function dy({queryActive:e,hasSources:r,candidates:n,onPromote:s}){return e&&r?t.jsx(Ut,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):t.jsxs(t.Fragment,{children:[t.jsx(Ut,{headline:"No plugin sources in this project.",body:t.jsxs(t.Fragment,{children:["Add ",t.jsx(Ar,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",t.jsx(Ar,{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 Ut({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 Ar({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 uy(){return t.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function py(){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 fy(){return t.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(e=>t.jsx(zg,{},e))})}function hy({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:my(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 my(e){const r=e.split(`
19
19
  `)[0]??e;return r.length>80?r.slice(0,77)+"…":r}function xy({projectRoot:e}){const{signedIn:r,tier:n}=ec();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(ud,{folder:e,tier:n})}):t.jsx(Ug,{projectRoot:e})}const pd=240,fd=480,hd="vskill-sidebar-width",rn=320;function ha(e){return Number.isFinite(e)?Math.round(Math.max(pd,Math.min(fd,e))):rn}function gy(){try{const e=localStorage.getItem(hd);if(!e)return rn;const r=Number(e);return Number.isFinite(r)?ha(r):rn}catch{return rn}}function yy(e){try{localStorage.setItem(hd,String(ha(e)))}catch{}}function vy({initialWidth:e,onChange:r}){const n=l.useRef({startX:0,startWidth:e,pointerId:null}),s=l.useRef(e);return l.useEffect(()=>{s.current=e},[e]),l.useEffect(()=>{function o(i){if(n.current.pointerId==null||i.pointerId!==n.current.pointerId)return;const c=i.clientX-n.current.startX,d=ha(n.current.startWidth+c);s.current=d,r(d)}function a(i){n.current.pointerId==null||i.pointerId!==n.current.pointerId||(n.current.pointerId=null,yy(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":pd,"aria-valuemax":fd,"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 by=/^[ MADRCU?!]{1,2} +/;function ky(e){return e.replace(by,"")}function jy(e,r){const n=e.endsWith("/")?e:e+"/";return r===e?"":r.startsWith(n)?r.slice(n.length):null}function wy(e,r,n){const s=new Set;if(r.length===0||e.length===0)return s;const o=r.map(a=>ky(a).trim()).filter(a=>a.length>0);for(const a of e){const i=a.dir;if(!i)continue;const c=jy(n,i);if(c===null)continue;const d=`${a.plugin}/${a.skill}`;if(c===""){o.length>0&&s.add(d);continue}const u=c+"/";for(const p of o)if(p===c||p.startsWith(u)){s.add(d);break}}return s}const Sy=5e3;function Cy(e,r,n=Sy){const[s,o]=l.useState([]),a=l.useRef(e);return a.current=e,l.useEffect(()=>{if(!r){o([]);return}let i=!1,c=null;const d=async()=>{try{const p=await ce.gitStatus();i||o(p.paths??[])}catch{i||o([])}i||(c=setTimeout(d,n))};d();const u=()=>{d()};return typeof window<"u"&&window.addEventListener("studio:content-saved",u),()=>{i=!0,c&&clearTimeout(c),typeof window<"u"&&window.removeEventListener("studio:content-saved",u)}},[r,n]),r?wy(a.current,s,r):new Set}function Ey({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 md(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 xd(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]=l.useState([]),[n,s]=l.useState(!1),[o,a]=l.useState(!1),[i,c]=l.useState(null),d=l.useRef(null),u=l.useCallback(async(f,h)=>{r([]),s(!0),a(!1),c(null);const m=new AbortController;d.current=m;try{const y=xd(h),x=await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:y,signal:m.signal});if(!x.ok||!x.body){let E=`HTTP ${x.status}`,j;try{j=await x.json(),j&&typeof j=="object"&&"error"in j&&typeof j.error=="string"&&(E=j.error)}catch{}throw md(x.status,j),new Error(E)}const g=x.body.getReader(),b=new TextDecoder;let v="",k="";for(;;){const{done:E,value:j}=await g.read();if(E)break;v+=b.decode(j,{stream:!0});const T=v.split(`
20
20
  `);v=T.pop()||"";for(const w of T)if(w.startsWith("event: "))k=w.slice(7).trim();else if(w.startsWith("data: ")){try{const S=JSON.parse(w.slice(6)),N={event:k,data:S};k==="done"?(a(!0),r(R=>[...R,N])):r(R=>[...R,N])}catch{}k=""}}}catch(y){y.name!=="AbortError"&&c(y.message)}finally{s(!1),d.current=null}},[]),p=l.useCallback(()=>{var f;(f=d.current)==null||f.abort()},[]);return{events:e,running:n,done:o,error:i,start:u,stop:p}}function Ny(e){const r=l.useRef(e);r.current=e;const[n,s]=l.useState(new Set),o=l.useRef(new Map),a=l.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(y=>{const x=new Set(y);return x.add(u),x});try{const y=xd(f),x=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:y,signal:h.signal});if(!x.ok||!x.body){let E=`HTTP ${x.status}`,j;try{j=await x.json(),j&&typeof j=="object"&&"error"in j&&typeof j.error=="string"&&(E=j.error)}catch{}throw md(x.status,j),new Error(E)}const g=x.body.getReader(),b=new TextDecoder;let v="",k="";for(;;){const{done:E,value:j}=await g.read();if(E)break;v+=b.decode(j,{stream:!0});const T=v.split(`
21
21
  `);v=T.pop()||"";for(const w of T)if(w.startsWith("event: "))k=w.slice(7).trim();else if(w.startsWith("data: ")){try{const S=JSON.parse(w.slice(6)),N={event:k,data:S};r.current.onEvent(u,N)}catch{}k=""}}r.current.onDone(u)}catch(y){y.name!=="AbortError"&&r.current.onError(u,y.message)}finally{s(y=>{const x=new Set(y);return x.delete(u),x}),o.current.delete(u)}},[]),i=l.useCallback(u=>{var p;(p=o.current.get(u))==null||p.abort()},[]),c=l.useCallback(()=>{for(const u of o.current.values())u.abort()},[]),d=n.size>0;return{runningSet:n,startCase:a,stopCase:i,stopAll:c,isAnyCaseRunning:d}}const Ry={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 Ty(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(c=>({assertion_id:c.id,text:c.text,pass:c.pass,reasoning:c.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 Iy(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 Ly(e){if(e==="unit"||e==="integration")return e}function Ay(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 gd=l.createContext(null);function xt(){const e=l.useContext(gd);if(!e)throw new Error("useWorkspace must be used within WorkspaceProvider");return e}function Py({plugin:e,skill:r,origin:n,children:s}){var ue;const o=n==="installed",{config:a}=gr(),[i,c]=l.useReducer(Ty,{...Ry,plugin:e,skill:r}),d=Iy({origin:n},{exists:i.evals!=null,cases:((ue=i.evals)==null?void 0:ue.evals)??[]}),u=d.canEdit,p=d.canRun,f=l.useRef(new Set),h=l.useRef(new Set),m=l.useRef(new Map),y=l.useCallback((F,q)=>{let re=m.current.get(F);re||(re={assertions:[]},m.current.set(F,re)),Ay(re,q),c({type:"UPDATE_INLINE_RESULT",evalId:F,result:{...re,assertions:[...re.assertions]}})},[]),x=l.useCallback(F=>{if(h.current.has(F))return;h.current.add(F);const q=m.current.get(F)??{assertions:[]};c({type:"CASE_RUN_COMPLETE",caseId:F,result:{...q,assertions:[...q.assertions]}}),f.current.has(F)&&(f.current.delete(F),f.current.size===0&&ce.getLatestBenchmark(e,r).then(re=>c({type:"BULK_RUN_COMPLETE",benchmark:re})).catch(()=>c({type:"BULK_RUN_COMPLETE",benchmark:null})))},[e,r]),g=l.useCallback((F,q)=>{h.current.has(F)||(h.current.add(F),c({type:"CASE_RUN_ERROR",caseId:F,error:q}),f.current.has(F)&&(f.current.delete(F),f.current.size===0&&ce.getLatestBenchmark(e,r).then(re=>c({type:"BULK_RUN_COMPLETE",benchmark:re})).catch(()=>c({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[e,r]),{startCase:b,stopCase:v,stopAll:k}=Ny({onEvent:y,onDone:x,onError:g});l.useEffect(()=>()=>{k()},[k]);const E=l.useCallback(async()=>{try{const F=await fetch(`/api/skills/${e}/${r}/activation-history`);if(!F.ok){if(F.status===404){c({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const q=await F.json();c({type:"ACTIVATION_HISTORY_LOADED",runs:q.runs||[]})}catch{}},[e,r]);l.useEffect(()=>{let F=!1;async function q(){try{const[re,Q,pe]=await Promise.allSettled([ce.getSkillDetail(e,r),ce.getEvals(e,r),ce.getLatestBenchmark(e,r)]);if(F)return;let xe=null,we=null;if(Q.status==="fulfilled")xe=Q.value;else{const ge=Q.reason;we=(ge==null?void 0:ge.message)??"Failed to load test cases"}c({type:"INIT_DATA",skillContent:re.status==="fulfilled"?re.value.skillContent:"",evals:xe,evalsError:we,benchmark:pe.status==="fulfilled"?pe.value:null})}catch(re){F||c({type:"SET_ERROR",error:re.message})}}return q(),E(),()=>{F=!0}},[e,r,E]);const j=l.useCallback(async F=>{if(o)return;const q=F??i.skillContent;try{await ce.applyImprovement(e,r,q),F!==void 0&&F!==i.skillContent&&c({type:"SET_CONTENT",content:F}),c({type:"CONTENT_SAVED"})}catch(re){c({type:"SET_ERROR",error:re.message})}},[o,e,r,i.skillContent]),T=l.useCallback(async F=>{if(!o)try{const q=await ce.saveEvals(e,r,F);c({type:"SET_EVALS",evals:q})}catch(q){c({type:"SET_ERROR",error:q.message})}},[o,e,r]),w=l.useCallback((F,q="benchmark")=>{const re=i.caseRunStates.get(F);if((re==null?void 0:re.status)==="running")return;m.current.delete(F),h.current.delete(F),c({type:"CASE_RUN_START",caseId:F,mode:q});const Q=q==="comparison"?{eval_ids:[F]}:q==="baseline"?{mode:"baseline"}:{};if(a!=null&&a.provider&&(Q.provider=a.provider),a!=null&&a.model&&(Q.model=a.model),q==="comparison"){const pe=`/api/skills/${e}/${r}/compare`;b(F,pe,Q)}else{const pe=`/api/skills/${e}/${r}/benchmark/case/${F}`;b(F,pe,Object.keys(Q).length>0?Q:void 0)}},[e,r,i.caseRunStates,b,a]),S=l.useCallback((F="benchmark")=>{var Q;const q=((Q=i.evals)==null?void 0:Q.evals)??[];if(q.length===0)return;const re=q.map(pe=>pe.id);for(const pe of re)m.current.delete(pe),h.current.delete(pe);c({type:"BULK_RUN_START",caseIds:re,mode:F}),f.current=new Set(re);for(const pe of re){const xe=F==="comparison"?{eval_ids:[pe]}:F==="baseline"?{mode:"baseline"}:{};if(a!=null&&a.provider&&(xe.provider=a.provider),a!=null&&a.model&&(xe.model=a.model),F==="comparison")b(pe,`/api/skills/${e}/${r}/compare`,xe);else{const we=`/api/skills/${e}/${r}/benchmark/case/${pe}`;b(pe,we,Object.keys(xe).length>0?xe:void 0)}}},[e,r,i.evals,b,a]),N=l.useCallback(F=>{v(F),c({type:"CASE_RUN_CANCEL",caseId:F}),f.current.delete(F),h.current.add(F)},[v]),R=l.useCallback(()=>{k(),c({type:"CANCEL_ALL"}),f.current.clear()},[k]),I=l.useCallback(async(F,q)=>{c({type:"OPEN_IMPROVE",evalId:F})},[]),A=l.useCallback(async(F,q)=>{try{await ce.applyImprovement(e,r,q),c({type:"SET_CONTENT",content:q}),c({type:"CONTENT_SAVED"}),c({type:"CLOSE_IMPROVE"}),w(F,"benchmark")}catch(re){c({type:"SET_ERROR",error:re.message})}},[e,r,w]),$=zs(),B=l.useRef(null),C=l.useRef(0);l.useEffect(()=>{const F=$.events;for(let q=C.current;q<F.length;q++){const re=F[q],Q=re.data;if(re.event==="progress"&&c({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:Q.phase,message:Q.message}}),re.event==="done"){const pe=Q.improved,xe=Q.reasoning,we=Q.evalChanges??[];c({type:"AI_EDIT_RESULT",improved:pe,reasoning:xe,evalChanges:we})}if(re.event==="error"){const pe=Q;c({type:"AI_EDIT_ERROR",message:pe.description||"Unknown error",classified:pe})}}C.current=F.length},[$.events]),l.useEffect(()=>{$.error&&c({type:"AI_EDIT_ERROR",message:$.error})},[$.error]),l.useEffect(()=>()=>{$.stop()},[$.stop]);const L=l.useCallback(async(F,q,re)=>{o||(C.current=0,c({type:"AI_EDIT_LOADING"}),B.current=$.stop,$.start(`/api/skills/${e}/${r}/improve?sse`,{mode:"instruct",instruction:F,content:i.skillContent,evals:i.evals??{skill_name:r,evals:[]},provider:q,model:re}))},[o,e,r,i.skillContent,i.evals,$]),P=l.useCallback(()=>{$.stop(),c({type:"AI_EDIT_ERROR",message:"Cancelled"})},[$]),M=l.useCallback(async()=>{const F=i.aiEditResult;if(F!=null&&F.improved)try{if(await ce.applyImprovement(e,r,F.improved),c({type:"SET_CONTENT",content:F.improved}),c({type:"CONTENT_SAVED"}),i.aiEditEvalChanges.length>0&&Array.from(i.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:re}=await ar(async()=>{const{mergeEvalChanges:xe}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:xe}},[]),Q=i.evals??{skill_name:r,evals:[]},pe=re(Q,i.aiEditEvalChanges,i.aiEditEvalSelections);try{const xe=await ce.saveEvals(e,r,pe);c({type:"SET_EVALS",evals:xe})}catch(xe){c({type:"SET_EVALS_RETRY",evalsFile:pe}),c({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${xe.message}. You can retry from the AI Edit panel.`});return}}c({type:"CLOSE_AI_EDIT"})}catch(q){c({type:"SET_ERROR",error:q.message})}},[e,r,i.aiEditResult,i.evals,i.aiEditEvalChanges,i.aiEditEvalSelections]),H=l.useCallback(()=>{c({type:"CLOSE_AI_EDIT"})},[]),le=l.useCallback(F=>{c({type:"TOGGLE_EVAL_CHANGE",index:F})},[]),G=l.useCallback(()=>{c({type:"SELECT_ALL_EVAL_CHANGES"})},[]),W=l.useCallback(()=>{c({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),Z=l.useCallback(async()=>{const F=i.aiEditEvalsRetry;if(F)try{const q=await ce.saveEvals(e,r,F);c({type:"SET_EVALS",evals:q}),c({type:"SET_ERROR",error:null}),c({type:"CLOSE_AI_EDIT"})}catch(q){c({type:"SET_ERROR",error:`Retry failed: ${q.message}`})}},[e,r,i.aiEditEvalsRetry]),he=l.useCallback(async()=>{try{const F=await ce.getSkillDetail(e,r);c({type:"SET_CONTENT",content:F.skillContent}),c({type:"CONTENT_SAVED"})}catch{}},[e,r]),me=zs(),_=l.useRef(0);l.useEffect(()=>{const F=me.events;for(let q=_.current;q<F.length;q++){const re=F[q],Q=re.data;if(re.event==="progress"&&c({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:Q.phase,message:Q.message}}),re.event==="done"){const pe=Q;ce.saveEvals(e,r,pe).then(xe=>c({type:"GENERATE_EVALS_DONE",evals:xe})).catch(xe=>c({type:"SET_ERROR",error:xe.message}))}re.event==="error"&&c({type:"GENERATE_EVALS_ERROR",classified:Q})}_.current=F.length},[me.events,e,r]),l.useEffect(()=>{me.error&&c({type:"SET_ERROR",error:me.error})},[me.error]),l.useEffect(()=>()=>{me.stop()},[me.stop]);const ne=l.useCallback(async F=>{if(o)return;_.current=0,c({type:"GENERATE_EVALS_START"});const q={};a!=null&&a.provider&&(q.provider=a.provider),a!=null&&a.model&&(q.model=a.model);const re=Ly(F==null?void 0:F.testType);re&&(q.testType=re),me.start(`/api/skills/${e}/${r}/generate-evals?sse`,Object.keys(q).length>0?q:void 0)},[o,e,r,me,a]),D=zs(),U=l.useRef(0);l.useEffect(()=>()=>{D.stop()},[D.stop]),l.useEffect(()=>{const F=D.events;for(let q=U.current;q<F.length;q++){const re=F[q];if(re.event==="classifying"){const Q=re.data;c({type:"ACTIVATION_CLASSIFYING",index:Q.index,total:Q.total})}if(re.event==="prompt_result"&&c({type:"ACTIVATION_RESULT",result:re.data}),re.event==="done"){K.current&&(clearTimeout(K.current),K.current=null);const Q=re.data;if(Q.error)c({type:"ACTIVATION_ERROR",error:Q.error});else{c({type:"ACTIVATION_DONE",summary:Q});const pe={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:Q.total,summary:{precision:Q.precision,recall:Q.recall,reliability:Q.reliability,tp:Q.tp,tn:Q.tn,fp:Q.fp,fn:Q.fn}};c({type:"ACTIVATION_HISTORY_LOADED",runs:[pe,...i.activationHistory??[]]})}}}U.current=F.length},[D.events,a,i.activationHistory]),l.useEffect(()=>{D.error&&(K.current&&(clearTimeout(K.current),K.current=null),c({type:"ACTIVATION_ERROR",error:D.error}))},[D.error]);const K=l.useRef(null),V=l.useCallback(()=>{K.current&&(clearTimeout(K.current),K.current=null),D.stop(),c({type:"ACTIVATION_CANCEL",totalPrompts:0})},[D]),Y=l.useCallback(F=>{const re=F.trim().split(`
@@ -84,4 +84,4 @@ You are an expert at...
84
84
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
85
85
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
86
86
  }`})]}),document.body)}function ek({rows:e,activeAgentId:r,focusedAgentId:n,onFocus:s}){return e.detected.length===0&&e.notDetected.length===0?t.jsx(iu,{}):t.jsxs(t.Fragment,{children:[e.detected.map(o=>o.kind==="aggregate"?t.jsx(nk,{row:o,onFocus:()=>{var a;return s(((a=o.consumers[0])==null?void 0:a.id)??r??"")}},o.key):t.jsx(rk,{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:O.scopePicker.notDetectedSubheading}),e.notDetected.map(o=>t.jsx(sk,{agent:o.agent},o.key))]})]})}function tk({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=J0(e);return t.jsxs(t.Fragment,{children:[t.jsx(ro,{testId:"agent-scope-section-detected",title:"Detected on this machine",agents:i.detected,emptyHint:"No agents detected on this machine yet.",renderRow:c=>t.jsx(no,{agent:c,focused:c.id===n,active:c.id===s,onClick:()=>o(c.id),kind:"detected"},c.id)}),t.jsx(ro,{testId:"agent-scope-section-available",title:"Available to install",agents:i.available,emptyHint:"All supported agents are detected — nothing left to install here.",renderRow:c=>t.jsx(no,{agent:c,focused:c.id===n,active:!1,onClick:()=>o(c.id),kind:"available",onRequestInstall:a},c.id)}),t.jsx(ro,{testId:"agent-scope-section-cloud",title:"Cloud only (paste required)",agents:i.cloud,emptyHint:"No cloud-only tools available.",renderRow:c=>t.jsx(no,{agent:c,focused:c.id===n,active:!1,onClick:()=>o(c.id),kind:"cloud",onRequestInstall:a},c.id)})]})}function ro({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 no({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)",c=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:c,style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",paddingLeft:16,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c}),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 rk({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 nk({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 sk({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 ok({agent:e,activeAgentId:r,onSwitch:n}){const s=e.id===r,o=e.isRemoteOnly===!0,a=s||o,i=s?"Active":o?"Remote-only":O.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":ik(e.health)})]}),t.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[t.jsx(Bn,{label:O.scopePicker.statsInstalled,value:String(e.installedCount)}),t.jsx(Bn,{label:O.scopePicker.statsGlobal,value:String(e.globalCount)}),t.jsx(Bn,{label:O.scopePicker.statsPlugins,value:String(e.pluginCount??0)}),t.jsx(Bn,{label:O.scopePicker.statsLastSync,value:e.lastSync?ak(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 Bn({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 iu(){return t.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function ak(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 ik(e){switch(e){case"ok":return O.scopePicker.statsHealthOk;case"stale":return O.scopePicker.statsHealthStale;case"missing":return O.scopePicker.statsHealthMissing}}function lk(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 ck({agents:e,activeAgentId:r,onActiveAgentChange:n,onOpenSetup:s}){const[o,a]=l.useState(!1),[i,c]=l.useState(null),d=l.useRef(null),u=l.useMemo(()=>e.find(m=>m.id===r)??e[0]??null,[e,r]),p=l.useMemo(()=>u?u.health==="ok"?"var(--color-ok, #22c55e)":u.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[u]),f=l.useCallback(()=>{var m;a(!1),(m=d.current)==null||m.focus()},[]),h=l.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(Z0,{agents:e,activeAgentId:r,focusedAgentId:i??r,onFocusAgent:c,onSwitch:h,onOpenSetup:m=>{s(m),f()},onClose:f})]})}const lu="vskill-ccode-banner-dismissed",dk=new Set(["claude-cli","claude-code"]);function uk(){try{return sessionStorage.getItem(lu)==="true"}catch{return!1}}function pk(){try{sessionStorage.setItem(lu,"true")}catch{}}function fk({activeAgentId:e}){const[r,n]=l.useState(()=>uk()),s=l.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),o=l.useCallback(()=>{pk(),n(!0)},[]);return!e||!dk.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:[O.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:O.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 hk(){const[e,r]=l.useState(null),[n,s]=l.useState("loading"),[o,a]=l.useState(null),i=l.useCallback(async()=>{try{const c=await ce.getAgents();r(c),s("ready"),a(null)}catch(c){s("error"),a(c.message)}},[]);return l.useEffect(()=>{i()},[i]),l.useEffect(()=>{const c=()=>void i();return window.addEventListener("studio:agent-changed",c),window.addEventListener("studio:project-changed",c),()=>{window.removeEventListener("studio:agent-changed",c),window.removeEventListener("studio:project-changed",c)}},[i]),{status:n,response:e,error:o,refresh:()=>void i()}}const _n="workspace",mk=["skills","agents"];async function xk(){const e=await fetch("/api/workspace");if(!e.ok)throw new Error(`GET /api/workspace failed: ${e.status}`);return await e.json()}class gk extends Error{constructor(r,n,s){super(r),this.name="SwitchProjectError",this.status=n,this.fallbackCommand=s}}async function yk(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 gk(n.error??`POST /api/workspace/active failed: ${r.status}`,r.status,n.fallbackCommand)}return await r.json()}async function vk(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 bk(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 so(){for(const e of mk)Be(e);typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:project-changed"))}function kk(){const{data:e,loading:r,error:n,revalidate:s}=St(_n,xk),o=e,a=o==null?void 0:o.projects.find(u=>u.id===o.activeProjectId),i=l.useCallback(async u=>{const p=await yk(u);return Be(_n),so(),{skillCount:p.skillCount}},[]),c=l.useCallback(async u=>{const p=await vk(u);Be(_n),so();const f=p.projects.find(h=>h.path===u.path);return{id:f==null?void 0:f.id}},[]),d=l.useCallback(async u=>{await bk(u),Be(_n),so()},[]);return{workspace:o,activeProject:a,loading:r,error:n,switchProject:i,addProject:c,removeProject:d,revalidate:s}}function jk(){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 wk({workspace:e,onSwitch:r,onAdd:n,onRemove:s,isPathStale:o}){const[a,i]=l.useState(!1),[c,d]=l.useState(!1),[u,p]=l.useState(""),[f,h]=l.useState(null),[m,y]=l.useState(null),[x,g]=l.useState(null),[b,v]=l.useState(null),[k,E]=l.useState(!1),[j,T]=l.useState(null),w=l.useRef(null);async function S(C){if(j)return!1;T(C.id),h(null);try{const L=await r(C.id),P=L&&typeof L=="object"&&"skillCount"in L?L.skillCount:void 0,M=P!=null?` — ${P} ${P===1?"skill":"skills"}`:"";return window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:`Switched to ${C.name}${M}`,severity:"success"}})),i(!1),!0}catch(L){const P=L&&typeof L=="object"&&"fallbackCommand"in L?L.fallbackCommand:void 0;return v(P??`cd "${C.path}" && npx vskill@latest studio`),g({id:C.id,name:C.name,path:C.path}),!1}finally{T(null)}}async function N(C){const L=R.find(P=>P.path===C);if(L)return S(L);try{const P=await n({path:C}),M=P&&typeof P=="object"?P.id:void 0,H=C.split(/[\\/]/).filter(Boolean).pop()??C;return M?S({id:M,name:H,path:C}):(i(!1),!0)}catch(P){const M=P instanceof Error?P.message:String(P);return/does not exist/i.test(M)?h(`Path not found on disk: ${C}`):/duplicate/i.test(M)?h("That project is already registered."):h(M),d(!0),!1}}const R=(e==null?void 0:e.projects)??[],I=R.find(C=>C.id===(e==null?void 0:e.activeProjectId));l.useEffect(()=>{if(!a)return;function C(L){w.current&&!w.current.contains(L.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),Zl()){try{const{open:C}=await ar(async()=>{const{open:P}=await import("./index-DDNzcrhv.js");return{open:P}},__vite__mapDeps([7,1])),L=await C({directory:!0,multiple:!1,title:"Open project folder"});typeof L=="string"&&L&&await N(L)}catch(C){h(C instanceof Error?C.message:String(C))}return}d(!0)}function B(C){if(C.length<=50)return C;const L=C.split("/");return L.length<=4?C:`${L.slice(0,3).join("/")}/…/${L.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:[R.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."}),R.length>0&&t.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:R.map(C=>{const L=o?o(C.path):!1,P=C.id===(e==null?void 0:e.activeProjectId),M=m===C.id,H=j!==null,le=j===C.id,G=P||le;return t.jsxs("li",{role:"menuitem","data-stale":L?"true":"false","data-switching":le?"true":"false","aria-busy":le||void 0,onMouseEnter:()=>y(C.id),onMouseLeave:()=>y(W=>W===C.id?null:W),onClick:()=>{if(!(L||H)){if(P){i(!1);return}S(C)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:L||H?le?"progress":"not-allowed":"pointer",background:M&&!L&&!H?"var(--surface-2, rgba(0,0,0,0.04))":G?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:L?.5:H&&!le?.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:G?"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:G?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.name}),le?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(jk,{}),"Switching…"]}):P&&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:B(C.path)}),L&&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:W=>{W.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:M?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:W=>{W.currentTarget.style.color="var(--color-error, #b91c1c)",W.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:W=>{W.currentTarget.style.color="var(--text-tertiary)",W.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:c?8:6},children:[!c&&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…"]}),c&&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})]})]})]}),x&&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:()=>{g(null),v(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 ",x.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 "${x.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 "${x.path}" && npx vskill@latest studio`),E(!0),setTimeout(()=>E(!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:k?"Copied!":"Copy command"}),t.jsx("button",{type:"button",onClick:()=>{g(null),v(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 Sk(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 Ck({open:e,projects:r,onSwitch:n,onClose:s}){const[o,a]=l.useState(""),[i,c]=l.useState(0),d=l.useMemo(()=>Sk(r,o),[r,o]);l.useEffect(()=>{e||(a(""),c(0))},[e]),l.useEffect(()=>{i>=d.length&&c(0)},[d.length,i]);const u=p=>{if(p.key==="Escape"){p.preventDefault(),s();return}if(p.key==="ArrowDown"){p.preventDefault(),c(f=>Math.min(f+1,Math.max(d.length-1,0)));return}if(p.key==="ArrowUp"){p.preventDefault(),c(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:()=>c(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 cl=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function Ek({open:e,onClose:r,initialMode:n="standalone",isClaudeCode:s,projectRoot:o,onCreated:a}){const[i,c]=l.useState("destination"),[d,u]=l.useState(n),[p,f]=l.useState(""),[h,m]=l.useState(""),[y,x]=l.useState(""),[g,b]=l.useState([]),[v,k]=l.useState(!1),[E,j]=l.useState(null);if(l.useEffect(()=>{e&&(c("destination"),u(n),f(""),m(""),x(""),j(null))},[e,n]),l.useEffect(()=>{if(!e)return;let C=!0;return fetch("/api/authoring/plugins").then(L=>L.json()).then(L=>{C&&b(L.plugins??[])}).catch(()=>{}),()=>{C=!1}},[e]),l.useEffect(()=>{if(!e)return;function C(L){L.key==="Escape"&&(L.preventDefault(),r())}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[e,r]),!e)return null;const T=g.length>0,w=s&&T,S=s,N=cl.test(p),R=d==="existing-plugin"?h.length>0:cl.test(h),I=!v&&N&&(d==="standalone"||R),A=Nk(o,d,h,p);async function $(){j(null),k(!0);try{const P=new URLSearchParams;P.set("mode",d),P.set("skillName",p),h&&P.set("pluginName",h);const M=await fetch(`/api/authoring/skill-exists?${P.toString()}`),H=await M.json();if(!M.ok){j(H.error??`Check failed: ${M.status}`);return}if(H.exists){j(`Skill '${p}' already exists${H.path?` at ${H.path}`:""}`);return}}catch(P){j(P instanceof Error?P.message:String(P));return}finally{k(!1)}const C=new URLSearchParams;C.set("mode",d),C.set("skillName",p),y.trim()&&C.set("description",y.trim()),h&&C.set("pluginName",h);const L=`#/create?${C.toString()}`;typeof window<"u"&&(window.location.hash=L),r()}async function B(){j(null),k(!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:y.trim()||void 0,pluginName:d==="standalone"?void 0:h})}),L=await C.json();if(!C.ok||!L.ok){j(L.error??`Create failed: ${C.status}`);return}Be("skills"),a==null||a({mode:d,skillName:p,pluginName:L.pluginName??null,skillMdPath:L.skillMdPath}),r()}catch(C){j(C instanceof Error?C.message:String(C))}finally{k(!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(oo,{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(oo,{title:"Add to existing plugin",subtitle:w?`${g.length} plugin source${g.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(oo,{title:"Plugin (multi-skill)",subtitle:S?"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:!S,selected:d==="new-plugin",onClick:()=>S&&u("new-plugin")})]}),i==="details"&&t.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[d==="new-plugin"&&t.jsx(On,{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:Wn(!h||R)})}),d==="existing-plugin"&&t.jsx(On,{label:"Plugin",children:t.jsxs("select",{value:h,onChange:C=>m(C.target.value),style:{...Wn(!0),fontFamily:"var(--font-mono)"},children:[t.jsx("option",{value:"",children:"Select a plugin…"}),g.map(C=>t.jsx("option",{value:C.name,children:C.name},C.path))]})}),t.jsx(On,{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:Wn(!p||N)})}),t.jsx(On,{label:"Description",hint:"One short sentence — shown in frontmatter",children:t.jsx("textarea",{value:y,onChange:C=>x(C.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...Wn(!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,L)=>t.jsx("div",{children:C},L))]}),E&&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:E})]}),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:ao,children:"Cancel"}),i==="destination"&&t.jsx("button",{type:"button",onClick:()=>c("details"),style:dl,children:"Continue →"}),i==="details"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>c("destination"),style:ao,children:"← Back"}),t.jsx("button",{type:"button",onClick:()=>void $(),disabled:!I,style:{...ao,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 B(),disabled:!I,style:{...dl,opacity:I?1:.5,cursor:I?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:v?"Creating…":"Create empty scaffold"})]})]})]})]})}function oo({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 On({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 Wn(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 dl={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"},ao={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 Nk(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 cu(e){return e.trim().toLowerCase()}function Rk(e,r){const n=cu(r);return n?e.filter(s=>s.name.toLowerCase().includes(n)||s.source.toLowerCase().includes(n)):e}function Tk(e,r){const n=cu(r);return n?e.filter(s=>[s.name,s.description??"",s.category??"",s.author??""].join(" ").toLowerCase().includes(n)):e}function Ik({open:e,onClose:r,onInstall:n,onUninstall:s,installedNames:o,privatePlugins:a}){const[i,c]=l.useState(null),[d,u]=l.useState([]),[p,f]=l.useState(null),[h,m]=l.useState(null),[y,x]=l.useState(!1),[g,b]=l.useState(null),[v,k]=l.useState(""),[E,j]=l.useState("");l.useEffect(()=>{p?k(""):j("")},[p]);const T=l.useMemo(()=>Rk(d,v),[d,v]),w=l.useMemo(()=>Tk((h==null?void 0:h.plugins)??[],E),[h,E]);return l.useEffect(()=>{e&&(x(!0),b(null),fetch("/api/plugins/marketplaces").then(S=>S.json()).then(S=>{if(S.error)throw new Error(S.error);u(S.marketplaces??[])}).catch(S=>b(S instanceof Error?S.message:String(S))).finally(()=>x(!1)))},[e]),l.useEffect(()=>{if(!p){m(null);return}x(!0),b(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(p)}`).then(S=>S.json()).then(S=>{if(S.error)throw new Error(S.error);m(S)}).catch(S=>b(S instanceof Error?S.message:String(S))).finally(()=>x(!1))},[p]),l.useEffect(()=>{if(!e)return;function S(N){N.key==="Escape"&&r()}return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[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:[y&&t.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),g&&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:g}),!p&&a&&a.length>0&&t.jsx(Lk,{plugins:a}),!p&&!y&&d.length===0&&!g&&t.jsx(Ak,{}),!p&&d.length>0&&t.jsx(ul,{value:v,onChange:k,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!p&&d.length>0&&T.length===0&&t.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",v,"”."]}),!p&&T.map(S=>t.jsxs("button",{type:"button",onClick:()=>f(S.name),style:$k,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:S.name}),t.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.source})]},S.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(ul,{value:E,onChange:j,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 “",E,"”."]}),w.map(S=>{const N=o.has(S.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:[S.name,S.version&&t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:S.version}),S.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:S.category})]}),S.description&&t.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:S.description})]}),N&&s?t.jsx("button",{type:"button",disabled:i===S.name,onClick:async()=>{c(S.name);try{await s(S.name)}finally{c(null)}},"aria-label":`Uninstall ${S.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===S.name?"wait":"pointer",opacity:i===S.name?.6:1,fontFamily:"inherit"},children:i===S.name?"Uninstalling…":"Uninstall"}):t.jsx("button",{type:"button",disabled:N,onClick:()=>n(S.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"})]})},S.name)})]})]}),!p&&t.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:t.jsx(Pk,{onAdded:()=>{Be("marketplaces"),fetch("/api/plugins/marketplaces").then(S=>S.json()).then(S=>u(S.marketplaces??[]))}})})]})]}):null}function ul({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 Lk({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 Ak(){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 Pk({onAdded:e}){const[r,n]=l.useState(""),[s,o]=l.useState(!1),[a,i]=l.useState(null);async function c(){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"&&c()},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 c(),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 $k={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},io=12;function Mk({job:e,onDone:r}){const[n,s]=l.useState([]),[o,a]=l.useState("running"),[i,c]=l.useState(!1);if(l.useEffect(()=>{if(!e)return;s([]),a("running"),c(!1);const f=new AbortController;let h=[],m="running";return(async()=>{try{const y=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(!y.ok||!y.body){a("failed"),r({ok:!1,code:y.status,lines:[`HTTP ${y.status}`]});return}const x=y.body.getReader(),g=new TextDecoder;let b="";for(;;){const{value:v,done:k}=await x.read();if(k)break;b+=g.decode(v,{stream:!0});const E=b.split(/\n\n/);b=E.pop()??"";for(const j of E){const T=j.match(/^data:\s*(.*)$/m);if(T)try{const w=JSON.parse(T[1]);w.type==="stdout"&&w.line?(h=[...h,w.line].slice(-io),s(h)):w.type==="stderr"&&w.line?(h=[...h,`⚠ ${w.line}`].slice(-io),s(h)):w.type==="done"?(m=w.ok?"ok":"failed",a(m),uc(),Be("skills"),r({ok:w.ok??!1,code:w.code??null,lines:h})):w.type==="error"&&w.error&&(h=[...h,`✘ ${w.error}`].slice(-io),s(h))}catch{}}}m==="running"&&r({ok:!0,code:0,lines:h})}catch(y){if(y.name==="AbortError")return;a("failed"),r({ok:!1,code:null,lines:[...h,y instanceof Error?y.message:String(y)]})}})(),()=>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:()=>c(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(Dk,{}):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(`
87
- `)})]})}function Dk(){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 Fk(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 zk(e){if(typeof navigator<"u"&&navigator.clipboard){await navigator.clipboard.writeText(e);return}throw new Error("Clipboard API unavailable in this environment")}function Bk({agentId:e,agentDisplayName:r,blob:n,pasteInstructionsUrl:s,docsUrl:o,scopeDowngradeWarning:a,onClose:i,writeClipboardImpl:c}){const d=l.useRef(null),[u,p]=l.useState(!1),[f,h]=l.useState(null);l.useEffect(()=>{const y=x=>{x.key==="Escape"&&(x.preventDefault(),i())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[i]);const m=l.useCallback(async()=>{const y=c??zk;try{await y(n),p(!0),h(null)}catch(x){h(x instanceof Error?x.message:String(x))}},[n,c]);return typeof document>"u"?null:Dr.createPortal(t.jsx("div",{"data-testid":"clipboard-export-dialog-backdrop",role:"presentation",onClick:y=>{y.target===y.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 _k(e,r){const n=e.split(/[.-]/).map(o=>Number.parseInt(o,10)),s=r.split(/[.-]/).map(o=>Number.parseInt(o,10));for(let o=0;o<Math.max(n.length,s.length);o++){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(s[o])?s[o]:0;if(a!==i)return a-i}return 0}function Ok(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 c=a.installed&&a.installedAgentTools.includes(e),d=i.installed&&i.installedAgentTools.includes(e);if(!c)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=_k(u,s);return p===0?{kind:"installed-current",version:u}:p<0?{kind:"update-available",installed:u,target:s}:{kind:"newer-installed",installed:u,target:s}}const Wk=Object.freeze({"claude-cli":"claude-code","codex-cli":"codex"});function pl(e){return e?Wk[e]??e:null}function Uk(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 Hk(e){switch(e){case"installed":return"Installed";case"exported":return"Exported";case"skipped":return"Skipped";case"error":return"Error"}}function Ho(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 Vk({skill:e,skillDisplayName:r,scope:n,targetVersion:s,activeAgentId:o,preCheckedAgentIds:a,onClose:i,onSuccess:c,fetchSupportedAgentsImpl:d,installToAgentsImpl:u,startInstallStreamImpl:p,fetchInstallStateImpl:f,removeSkillImpl:h,writeClipboardImpl:m}){var de;const y=l.useRef(null),[x,g]=l.useState("loading"),[b,v]=l.useState([]),[k,E]=l.useState(null),[j,T]=l.useState(new Set),[w,S]=l.useState(null),[N,R]=l.useState({}),[I,A]=l.useState(null),[$,B]=l.useState(0),[C,L]=l.useState(new Set),[P,M]=l.useState([]),[H,le]=l.useState(null),G=l.useRef(null);l.useEffect(()=>{const se=ue=>{ue.key==="Escape"&&(H||(ue.preventDefault(),ue.stopPropagation(),x!=="installing"&&i()))};return document.addEventListener("keydown",se,!0),()=>document.removeEventListener("keydown",se,!0)},[H,x,i]),l.useEffect(()=>{let se=!1;return(d??au)().then(F=>{if(se)return;v(F);const q=new Set,re=pl(o);re&&F.some(Q=>Q.id===re)&&q.add(re);for(const Q of a??[]){const pe=pl(Q);pe&&F.some(xe=>xe.id===pe)&&q.add(pe)}if(q.size===0){const Q=Uk(F);Q&&q.add(Q)}T(q),g("select")}).catch(F=>{se||(E(F instanceof Error?F.message:String(F)),g("error"))}),()=>{se=!0}},[d,o,a]),l.useEffect(()=>()=>{var se;try{(se=G.current)==null||se.close()}catch{}},[]),l.useEffect(()=>{let se=!1;return(f??(F=>ce.getSkillInstallState(F)))(e).then(F=>{se||A(F)},()=>{se||A(null)}),()=>{se=!0}},[e,f,$]);const W=l.useMemo(()=>X0(b),[b]),Z=l.useCallback(se=>{T(ue=>{const F=new Set(ue);return F.has(se)?F.delete(se):F.add(se),F})},[]),he=l.useCallback(()=>{T(()=>{const se=new Set;for(const ue of b)ue.detected&&se.add(ue.id);return se})},[b]),me=l.useCallback(()=>{T(new Set)},[]),_=l.useCallback(()=>{var se;if(x!=="installing"){try{(se=G.current)==null||se.close()}catch{}i()}},[x,i]),ne=l.useCallback(async()=>{if(j.size===0)return;S(null),R({}),g("installing");const se=Array.from(j),ue=u??q0,F=p??Y0;try{const{jobId:q,streamPath:re}=await ue({skill:e,agentIds:se,scope:n});G.current=F(re??q,{onResult:Q=>{R(pe=>({...pe,[Q.agentId]:Q}))},onDone:Q=>{const pe={},xe=Q.success===!1?typeof Q.error=="string"&&Q.error.trim()||"Install failed before any target reported a result.":null;for(const we of se)pe[we]=xe?{agentId:we,status:"error",detail:xe}:{agentId:we,status:"skipped"};if(xe)S(xe);else for(const we of Q.results??[])pe[we.agentId]=we;R(we=>{var Je;const ge={...pe};for(const[Ie,ee]of Object.entries(we))((Je=ge[Ie])==null?void 0:Je.status)==="skipped"&&ee.status!=="skipped"&&(ge[Ie]=ee);if(!Object.values(ge).some(Ie=>Ie.status==="installed"||Ie.status==="exported"||Ie.status==="error")){const Ie="Install finished without writing any selected target.";for(const ee of se)ge[ee]={agentId:ee,status:"error",detail:Ie};S(Ie)}const Pe=Object.values(ge),rt=Pe.filter(Ie=>Ie.status==="exported"&&typeof Ie.blob=="string");return rt.length>0&&(M(rt),le(rt[0]??null)),globalThis.setTimeout(()=>{try{c==null||c(Pe)}catch{}},0),ge}),B(we=>we+1),g("done")},onError:Q=>{S(Q.message),g("error")}})}catch(q){S(q instanceof Error?q.message:String(q)),g("error")}},[j,e,n,u,p,c]),D=l.useCallback(async se=>{const ue=h??Fk;L(F=>{const q=new Set(F);return q.add(se),q});try{const F=await ue({skill:e,agentIds:[se],scope:n});if(typeof window<"u")try{window.dispatchEvent(new CustomEvent("studio:skill-installed",{detail:{skill:e,scope:n}}))}catch{}B(q=>q+1),F.errors.length>0&&S(`Remove failed for ${F.errors[0].agentId}: ${F.errors[0].message}`)}catch(F){S(F instanceof Error?F.message:String(F))}finally{L(F=>{const q=new Set(F);return q.delete(se),q})}},[h,e,n]),U=l.useCallback(()=>{M(se=>{const ue=se.slice(1);return le(ue[0]??null),ue})},[]),K=l.useMemo(()=>b.filter(se=>se.detected).length,[b]);if(typeof document>"u")return null;const V=j.size===0||x==="installing",Y=j.size===0?"Select at least one target":void 0,J=`Install ${r??e} to:`,te=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 Dr.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-testid":"install-targets-modal-backdrop",role:"presentation",onClick:se=>{se.target===se.currentTarget&&_()},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:y,"data-testid":"install-targets-modal",role:"dialog","aria-modal":"true","aria-label":J,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:J}),t.jsx("div",{"data-testid":"install-targets-modal-scope-line",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:te})]}),t.jsx("button",{type:"button","data-testid":"install-targets-modal-close",onClick:_,"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…"}),k&&x==="error"&&b.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: ",k]}),(x==="select"||x==="installing"||x==="done"||x==="error"&&b.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:[j.size," selected · ",K," detected"]}),t.jsxs("div",{style:{display:"flex",gap:"0.375rem"},children:[t.jsx("button",{type:"button","data-testid":"install-targets-select-all-detected",onClick:he,disabled:x==="installing"||K===0,style:fl(),children:"Select all detected"}),t.jsx("button",{type:"button","data-testid":"install-targets-clear",onClick:me,disabled:x==="installing"||j.size===0,style:fl(),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 ",j.size," target",j.size===1?"":"s","…"]}),t.jsx(lo,{testId:"install-targets-section-dropin",title:"Drop-in",description:"Filesystem install — Claude-style SKILL.md drops in unchanged.",agents:W.dropIn,selected:j,results:N,phase:x,onToggle:Z,scope:n,installState:I,targetVersion:s??null,removingAgents:C,onRemove:D}),t.jsx(lo,{testId:"install-targets-section-format-converted",title:"Format-converted",description:"Auto-converted to the tool's native format on install.",agents:W.formatConverted,selected:j,results:N,phase:x,onToggle:Z,scope:n,installState:I,targetVersion:s??null,removingAgents:C,onRemove:D}),t.jsx(lo,{testId:"install-targets-section-cloud",title:"Cloud only (paste required)",description:"No local filesystem — opens a paste-ready blob.",agents:W.cloud,selected:j,results:N,phase:x,onToggle:Z,tierBadge:"T3",pathOverride:"Copy to clipboard",scope:n,installState:I,targetVersion:s??null,removingAgents:C,onRemove:D})]}),x==="done"&&t.jsx(Gk,{results:Object.values(N),agents:b}),(x==="error"||x==="done")&&w&&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:w})]}),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:[t.jsx("button",{type:"button","data-testid":"install-targets-modal-cancel",onClick:_,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:x==="done"?"Close":"Cancel"}),t.jsx("button",{type:"button","data-testid":"install-targets-modal-install",onClick:ne,disabled:V||x==="done","aria-disabled":V||x==="done",title:Y,style:{padding:"0.5rem 1.125rem",borderRadius:6,border:"1px solid var(--text-primary, #191919)",background:V||x==="done"?"var(--bg-surface, #FFFFFF)":"var(--text-primary, #191919)",color:V||x==="done"?"var(--text-secondary, #5A5651)":"var(--bg-surface, #FFFFFF)",cursor:V||x==="done"?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"var(--font-sans)",opacity:V&&x!=="done"?.6:1},children:x==="installing"?"Installing…":x==="done"?"Done":`Install (${j.size})`})]})]})}),H&&t.jsx(Bk,{agentId:H.agentId,agentDisplayName:((de=b.find(se=>se.id===H.agentId))==null?void 0:de.displayName)??H.agentId,blob:H.blob??"",pasteInstructionsUrl:H.pasteInstructionsUrl,docsUrl:H.docsUrl,scopeDowngradeWarning:H.detail&&H.detail.includes("project-scoped")?H.detail:void 0,onClose:U,writeClipboardImpl:m})]}),document.body)}function lo({testId:e,title:r,description:n,agents:s,selected:o,results:a,phase:i,onToggle:c,tierBadge:d,pathOverride:u,scope:p,installState:f,targetVersion:h,removingAgents:m,onRemove:y}){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(x=>{const g=o.has(x.id),b=a[x.id],v=i==="installing"||i==="done",k=u??(p==="project"?x.resolvedLocalDir:x.resolvedGlobalDir),E=Ok(x.id,p,f,h),j=m.has(x.id);return t.jsxs("label",{"data-testid":`install-targets-row-${x.id}`,"data-checked":g?"true":"false","data-detected":x.detected?"true":"false",style:{display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.375rem 0.5rem",borderRadius:4,cursor:v?"default":"pointer",background:g?"color-mix(in srgb, var(--accent-surface) 8%, transparent)":"transparent"},children:[t.jsx("input",{type:"checkbox","data-testid":`install-targets-checkbox-${x.id}`,checked:g,disabled:v,onChange:()=>c(x.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:x.displayName}),!x.detected&&t.jsx("span",{"data-testid":`install-targets-undetected-badge-${x.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(Kk,{agentId:x.id,badge:E,isRemoving:j,onRemove:y})]}),t.jsx("div",{title:k,"data-testid":`install-targets-path-${x.id}`,style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k})]}),b&&t.jsx("span",{"data-testid":`install-targets-status-${x.id}`,"data-status":b.status,style:{fontSize:11,padding:"1px 8px",borderRadius:10,background:`color-mix(in srgb, ${Ho(b.status)} 16%, transparent)`,color:Ho(b.status),fontFamily:"var(--font-mono)"},children:Hk(b.status)})]},x.id)})})]})}function Gk({results:e,agents:r}){return e.length===0?null: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(n=>{const s=r.find(i=>i.id===n.agentId),o=n.status==="installed"?n.path??n.detail:n.status==="exported"?n.detail&&n.detail.includes("project-scoped")?n.detail:"Copied to clipboard":n.status==="error"?n.detail??"Unknown error":n.detail??"",a=n.status==="installed"?"✓":n.status==="exported"?"⧉":n.status==="skipped"?"·":"✗";return t.jsxs("div",{"data-testid":`install-targets-result-row-${n.agentId}`,"data-status":n.status,style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",fontSize:12},children:[t.jsx("span",{"aria-hidden":"true",style:{color:Ho(n.status),fontWeight:600,fontFamily:"var(--font-mono)",width:"0.875rem",flexShrink:0},children:a}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsx("span",{style:{fontWeight:500},children:(s==null?void 0:s.displayName)??n.agentId}),o&&t.jsx("span",{style:{marginLeft:"0.5rem",color:"var(--text-secondary)",fontFamily:"var(--font-mono)",fontSize:11,wordBreak:"break-all"},children:o}),n.status==="exported"&&n.pasteInstructionsUrl&&t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{"data-testid":`install-targets-result-paste-link-${n.agentId}`,href:n.pasteInstructionsUrl,target:"_blank",rel:"noreferrer noopener",style:{fontSize:11,color:"var(--accent-text, var(--text-primary))",textDecoration:"underline"},children:"open paste instructions →"})]})]})]},n.agentId)})]})}function Kk({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 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 v${r.installed} (target v${r.target})`,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 c=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}),c&&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 fl(){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 qk=3e3,Yk={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function hl(e){return e==="anthropic"||e==="openai"||e==="openrouter"}function Jk(){const{toast:e}=cs(),r=l.useRef(new Map),n=l.useCallback(s=>{if(!hl(s.provider))return;const o=Date.now(),a=r.current.get(s.provider)??0;if(o-a<qk)return;r.current.set(s.provider,o);const i=Yk[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 l.useEffect(()=>{function s(o){const a=o.detail;!a||!hl(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 du="vskill.studio.prefs";function uu(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function pu(){const e=uu();if(!e)return{};try{const r=e.getItem(du);if(!r)return{};const n=JSON.parse(r);return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}catch{return{}}}function Xk(e,r){const n=uu();if(n)try{const o={...pu(),[e]:r};n.setItem(du,JSON.stringify(o))}catch{}}function Qk(e,r){const s=pu()[e];return s===void 0?r:s}const ml={open:!1,x:0,y:0,skill:null};function Zk(e,r){return{open:!0,x:e.clientX,y:e.clientY,skill:r}}function Bt(e,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function ej(e){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:e}}))}async function xl(e,r){var n;try{await ce.revealInEditor(e.plugin,e.skill,r),Bt(O.toasts.openingInEditor,"info")}catch(s){if(s instanceof qt){const o=(n=s.details)==null?void 0:n.error;if(s.status===404){Bt(O.toasts.skillNotFound,"error");return}if(s.status===500&&o==="no_editor"){Bt(O.toasts.noEditor,"error");return}}Bt(O.toasts.openFailed,"error")}}async function tj(e,r){var n;switch(e){case"copy-path":try{(n=navigator.clipboard)==null||n.writeText(r.dir)}catch{Bt(O.toasts.permissionDenied,"error");return}Bt(O.toasts.pathCopied,"info");return;case"reveal":case"edit":await xl(r,"SKILL.md");return;case"open":await xl(r);return;case"run-benchmark":Bt(O.toasts.benchmarkQueued,"info");return;case"duplicate":Bt(O.toasts.skillDuplicated,"info");return;case"clone":try{window.dispatchEvent(new CustomEvent("studio:request-clone",{detail:{skill:r}}))}catch{}return;case"update":Bt(O.toasts.skillUpdated,"info");return;case"uninstall":Bt(O.toasts.uninstallNotImplemented,"info");return;case"delete":ej(r);return;default:return}}function rj(e){return e.startsWith("#/create")}function nj(e){return e.startsWith("#/updates")}function fu(e){const[r,n]=l.useState(()=>typeof window<"u"&&e(window.location.hash));return l.useEffect(()=>{function s(){n(e(window.location.hash))}return window.addEventListener("hashchange",s),s(),()=>window.removeEventListener("hashchange",s)},[]),r}function sj(){return fu(rj)}function oj(){return fu(nj)}function aj(){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 ij(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function lj(){const[e,r]=l.useState("⌘⇧K");l.useEffect(()=>{r(aj())},[]);const n=ij();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 cj(){const e=fn(),[r,n]=l.useState(null),[s,o]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(null),[u,p]=l.useState(null),[f,h]=l.useState(!1),m=l.useRef(!1);l.useEffect(()=>{let k=!1;return(async()=>{try{const E=await e.getSignedInUser();k||n(E)}catch{}finally{k||o(!1)}})(),()=>{k=!0}},[e]);const y=l.useRef(null);l.useEffect(()=>{if(!a)return;function k(j){y.current&&(y.current.contains(j.target)||i(!1))}function E(j){j.key==="Escape"&&i(!1)}return document.addEventListener("pointerdown",k),document.addEventListener("keydown",E),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",E)}},[a]);const x=l.useCallback(async k=>{try{if(typeof e.openExternalUrl=="function"){await e.openExternalUrl(k);return}}catch(E){console.warn("open external URL:",E)}window.open(k,"_blank","noopener,noreferrer")},[e]),g=l.useCallback(async()=>{p(null),h(!0),m.current=!1;let k=null;const E=j=>{k=j,p(j)};try{const j=await e.startGithubDeviceFlow();window.__vskillOauthState=j.userCode,d(j),x(j.verificationUri);let T=Math.max(1,j.interval);const w=Date.now()+j.expiresIn*1e3;for(;!m.current&&Date.now()<w&&(await pj(T*1e3,()=>m.current),!m.current);){const S=await e.pollGithubDeviceFlow();if(S.status==="granted"){n(S.user),d(null),h(!1);return}if(S.status!=="pending"){if(S.status==="slow_down"){T=Math.max(T+1,S.newInterval);continue}if(S.status==="denied"){E("Sign-in was denied at GitHub. You can try again.");break}if(S.status==="expired"){E("Sign-in code expired. Try again to get a fresh code.");break}if(S.status==="no-flow"){E("Sign-in state lost. Please retry.");break}E(S.message);break}}!m.current&&!k&&E("Sign-in code expired. Try again to get a fresh code.")}catch(j){E(j instanceof Error?j.message:String(j))}finally{h(!1)}},[e,x]),b=l.useCallback(()=>{m.current=!0,d(null),p(null),h(!1)},[]),v=l.useCallback(async()=>{i(!1);try{await e.signOut()}catch(k){console.warn("sign-out:",k)}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:y,children:[t.jsxs("button",{type:"button","data-slot":"user-chip",onClick:()=>i(k=>!k),"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:k=>{const E=hj(r.login);k.currentTarget.src!==E&&(k.currentTarget.src=E)},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(gl,{label:"View on GitHub",onClick:()=>{x(`https://github.com/${r.login}`),i(!1)}}),t.jsx(gl,{label:"Sign out",onClick:v})]})]}):t.jsxs("div",{"data-slot":"user-dropdown",style:{position:"relative"},ref:y,children:[t.jsxs("button",{type:"button","data-slot":"sign-in-button",onClick:g,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(uj,{size:14}),f?"Signing in…":"Sign in"]}),c&&t.jsx(dj,{response:c,error:u,onCancel:b,onOpenGithub:()=>void x(c.verificationUri),onRetry:g})]})}function dj({response:e,error:r,onCancel:n,onOpenGithub:s,onRetry:o}){const[a,i]=l.useState("idle"),c=l.useRef(null);l.useEffect(()=>()=>{c.current!=null&&window.clearTimeout(c.current)},[]);let d=e.verificationUri;try{const p=new URL(e.verificationUri);d=`${p.host}${p.pathname}`}catch{}const u=l.useCallback(async()=>{c.current!=null&&window.clearTimeout(c.current);try{await fj(e.verificationUri),i("copied"),c.current=window.setTimeout(()=>i("idle"),1500)}catch{i("failed"),c.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 gl({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 uj({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 pj(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 fj(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 hj(e){return`https://github.com/${encodeURIComponent(e)}.png?size=40`}function mj({forcedTone:e}){const{snapshot:r,refreshing:n,forceSync:s}=xa(),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 c=e??xj(o,a);if(!c)return null;const d=l.useCallback(()=>{s(!0)},[s]),u=c==="danger"?"Sign in to refresh your subscription. Some features will be locked until you reconnect.":"Sync to verify your subscription — last synced 7 days ago.";return t.jsxs("div",{role:"status","aria-live":"polite","data-testid":"quota-grace-banner","data-tone":c,style:{...gj,background:c==="danger"?"var(--color-danger-bg, rgba(220, 50, 47, 0.12))":"var(--color-warn-bg, rgba(203, 75, 22, 0.12))",color:c==="danger"?"var(--color-danger, #dc322f)":"var(--color-warn, #cb4b16)",borderColor:c==="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:yj,children:n?"Syncing…":"Sync now"})]})}function xj(e,r){return r?e<=1?"warn":null:"danger"}const gj={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)"},yj={padding:"2px 10px",borderRadius:4,border:"1px solid currentColor",background:"transparent",color:"inherit",cursor:"pointer",fontSize:12,fontWeight:500};function vj({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 bj={green:"#16a34a",amber:"#f59e0b",grey:"#9ca3af",red:"#dc2626"},kj={green:"Synced",amber:"Reauth needed",grey:"Idle",red:"Error"};function jj({repos:e,viewMode:r="table",pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,onConnectNew:i,now:c=new Date}){const d=Sj(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(Cj,{summary:d,onConnectNew:i,showConnectAction:!0}),e.length===0?t.jsx(Ej,{}):t.jsxs(t.Fragment,{children:[u.length>0?t.jsx(yl,{kind:"private",repos:u,viewMode:r,pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,now:c}):null,p.length>0?t.jsx(yl,{kind:"public",repos:p,viewMode:r,pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,now:c}):null]})]})}function yl({kind:e,repos:r,viewMode:n,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:c}){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(wj,{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(Rj,{repos:r,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:c}):t.jsx(Nj,{repos:r,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:c})]})}function wj({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 Sj(e){let r=0,n=0;for(const s of e)s.isPrivate?n++:r++;return{total:e.length,publicCount:r,privateCount:n}}function Cj({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(Vo,{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(Vo,{isPrivate:!0})," ",e.privateCount]})]}),t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.4},children:"Public repositories work on Free. Private repository connections require Pro and GitHub App access."})]}),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 Vo({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 Ej(){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, pick the repos to share, then Skill Studio syncs public repos on Free and private repos on Pro."]})]})}function Nj({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(Kr,{children:"Repository"}),t.jsx(Kr,{align:"right",children:"Skills"}),t.jsx(Kr,{children:"Status"}),t.jsx(Kr,{children:"Last activity"}),t.jsx(Kr,{align:"right",style:{width:48},children:t.jsx("span",{style:{visibility:"hidden"},children:"Actions"})})]})}),t.jsx("tbody",{children:e.map(i=>t.jsx(Tj,{repo:i,pending:r==null?void 0:r[i.repoId],onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a},i.repoId))})]})}function Rj({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(Ij,{repo:i,pending:r==null?void 0:r[i.repoId],onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a},i.repoId))})}function Tj({repo:e,pending:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){const[i,c]=l.useState(!1);return t.jsxs("tr",{"data-testid":`repo-row-${e.repoId}`,style:{borderBottom:"1px solid var(--border-default, #e5e7eb)"},children:[t.jsx(qr,{children:t.jsx(hu,{repo:e})}),t.jsx(qr,{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(qr,{children:t.jsx(mu,{status:e.syncStatus,errorMessage:e.lastErrorMessage})}),t.jsx(qr,{children:t.jsx("span",{style:{color:"var(--text-secondary)"},children:gu(e.lastActivityAt,a)})}),t.jsx(qr,{align:"right",children:t.jsx(xu,{repo:e,pending:r,isOpen:i,onToggle:()=>c(d=>!d),onClose:()=>c(!1),onOpenOnGitHub:n,onResync:s,onDisconnect:o})})]})}function Ij({repo:e,pending:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){const[i,c]=l.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(hu,{repo:e}),t.jsx(xu,{repo:e,pending:r,isOpen:i,onToggle:()=>c(d=>!d),onClose:()=>c(!1),onOpenOnGitHub:n,onResync:s,onDisconnect:o})]}),t.jsx(co,{label:"Skills",children:e.skillsCount===0?"—":String(e.skillsCount)}),t.jsx(co,{label:"Status",children:t.jsx(mu,{status:e.syncStatus,errorMessage:e.lastErrorMessage})}),t.jsx(co,{label:"Last activity",children:gu(e.lastActivityAt,a)})]})}function hu({repo:e}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx(Vo,{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 mu({status:e,errorMessage:r}){const n=bj[e],s=kj[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 co({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:c}){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(uo,{onClick:()=>{a(e),o()},children:"Open on GitHub"}),t.jsx(uo,{disabled:r==="resync",onClick:async()=>{await i(e),o()},children:r==="resync"?"Resyncing…":"Resync now"}),t.jsx(uo,{danger:!0,onClick:async()=>{await c(e),o()},children:"Disconnect"})]})]})}function uo({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 Kr({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 qr({children:e,align:r="left"}){return t.jsx("td",{style:{textAlign:r,padding:"12px 12px",verticalAlign:"middle"},children:e})}function gu(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 c=Math.floor(i/24);if(c<30)return`${c}d ago`;const d=Math.floor(c/30);return d<12?`${d}mo ago`:`${Math.floor(c/365)}y ago`}const po=80,fo=280;function Lj({profile:e,onSubmit:r,saving:n=!1,errorMessage:s=null}){const[o,a]=l.useState(e.displayName),[i,c]=l.useState(e.bio??""),[d,u]=l.useState(e.publicProfile);l.useEffect(()=>{a(e.displayName),c(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>po,h=i.length>fo,m=o.trim().length>0&&!f&&!h;async function y(x){if(x.preventDefault(),!p||!m||n)return;const g={};o!==e.displayName&&(g.displayName=o),i!==(e.bio??"")&&(g.bio=i||null),d!==e.publicProfile&&(g.publicProfile=d),await r(g)}return t.jsxs("form",{"data-testid":"profile-form",onSubmit:y,style:{display:"flex",flexDirection:"column",gap:18,maxWidth:560,fontFamily:"var(--font-sans)"},children:[t.jsx(Aj,{profile:e}),t.jsxs(ho,{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:po+20,disabled:n,onChange:x=>a(x.target.value),style:mo}),t.jsx(vl,{current:o.length,max:po})]}),t.jsx(ho,{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:{...mo,background:"var(--bg-canvas, #f3f4f6)"}})}),t.jsxs(ho,{label:"Public bio",htmlFor:"profile-bio",children:[t.jsx("textarea",{id:"profile-bio","data-testid":"profile-bio",value:i,maxLength:fo+40,rows:3,disabled:n,onChange:x=>c(x.target.value),style:{...mo,fontFamily:"inherit",resize:"vertical"}}),t.jsx(vl,{current:i.length,max:fo})]}),t.jsx(Pj,{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 Aj({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 ho({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 vl({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 Pj({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 mo={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"},$j={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 Mj({tier:e,onUpgradeClick:r,showUpgradeCta:n=!0}){const s=$j[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 Dj=[{value:30,label:"30 days"},{value:90,label:"90 days"},{value:365,label:"1 year"},{value:0,label:"Never"}];function Fj({tokens:e,recentlyCreated:r,onDismissRecentlyCreated:n,onCreate:s,onRevoke:o,pendingRevokeId:a,creating:i=!1,now:c=new Date}){const[d,u]=l.useState(!1),[p,f]=l.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(zj,{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(wr,{children:"Name"}),t.jsx(wr,{children:"Prefix"}),t.jsx(wr,{children:"Scopes"}),t.jsx(wr,{children:"Last used"}),t.jsx(wr,{children:"Created"}),t.jsx(wr,{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(Sr,{children:h.name}),t.jsx(Sr,{children:t.jsxs("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)"},children:[h.prefix,"…"]})}),t.jsx(Sr,{children:h.scopes.join(", ")}),t.jsx(Sr,{children:kl(h.lastUsedAt,c)}),t.jsx(Sr,{children:kl(h.createdAt,c)}),t.jsx(Sr,{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(Bj,{creating:i,onCancel:()=>u(!1),onSubmit:async h=>{await s(h),u(!1)}}),r&&t.jsx(_j,{created:r,onDismiss:()=>n==null?void 0:n()}),p&&t.jsx(Oj,{token:p,pending:a===p.id,onCancel:()=>f(null),onConfirm:async()=>{await o(p),f(null)}})]})}function zj({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 Bj({creating:e,onCancel:r,onSubmit:n}){const[s,o]=l.useState(""),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,p]=l.useState(90),f=s.trim().length>0&&(a||c);return t.jsxs(va,{title:"Generate new token",onDismiss:r,testId:"tokens-generate-modal",children:[t.jsx(xo,{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:jl})}),t.jsx(xo,{label:"Scopes",children:t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(bl,{label:"read",checked:a,disabled:e,onChange:i,testId:"scope-read"}),t.jsx(bl,{label:"write",checked:c,disabled:e,onChange:d,testId:"scope-write"})]})}),t.jsx(xo,{label:"Expiry",children:t.jsx("select",{"data-testid":"token-expiry-select",value:u,disabled:e,onChange:h=>p(Number(h.target.value)),style:jl,children:Dj.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value))})}),t.jsxs(ba,{children:[t.jsx(ka,{onClick:r,disabled:e,children:"Cancel"}),t.jsx(yu,{disabled:!f||e,onClick:()=>{const h=[];a&&h.push("read"),c&&h.push("write"),n({name:s.trim(),scopes:h,expiresInDays:u})},children:e?"Generating…":"Generate"})]})]})}function _j({created:e,onDismiss:r}){const[n,s]=l.useState(!1);async function o(){try{await navigator.clipboard.writeText(e.plaintext),s(!0)}catch{}}return t.jsxs(va,{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(ba,{children:[t.jsx(ka,{onClick:o,children:n?"Copied!":"Copy to clipboard"}),t.jsx(yu,{onClick:r,children:"Done"})]})]})}function Oj({token:e,pending:r,onCancel:n,onConfirm:s}){return t.jsxs(va,{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(ba,{children:[t.jsx(ka,{onClick:n,disabled:r,children:"Cancel"}),t.jsx(Wj,{disabled:r,onClick:()=>void s(),children:r?"Revoking…":"Revoke"})]})]})}function va({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 ba({children:e}){return t.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:e})}function yu({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 ka({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 Wj({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 xo({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 bl({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 wr({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 Sr({children:e,align:r="left"}){return t.jsx("td",{style:{textAlign:r,padding:"12px 12px",verticalAlign:"middle"},children:e})}function kl(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 c=Math.floor(i/30);return c<12?`${c}mo ago`:`${Math.floor(i/365)}y ago`}const jl={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"},Uj=[{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 Hj({prefs:e,onSubmit:r,saving:n=!1,errorMessage:s=null}){const[o,a]=l.useState(()=>wl(e));l.useEffect(()=>{a(wl(e))},[e]);const i=o.weeklyDigest!==e.weeklyDigest||o.commentReplies!==e.commentReplies||o.productUpdates!==e.productUpdates;function c(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:Uj.map(u=>t.jsx(Vj,{meta:u,checked:u.forcedOn?!0:!!o[u.key],disabled:n||!!u.forcedOn,onChange:p=>{u.key!=="securityAlerts"&&c(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 Vj({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 wl(e){return{weeklyDigest:!!e.weeklyDigest,securityAlerts:!0,commentReplies:e.commentReplies??!0,productUpdates:!!e.productUpdates}}function Gj({githubHandle:e,exports:r=[],onSignOutAll:n,onExportRequest:s,onDeleteAccount:o,pending:a,errorMessage:i=null}){const[c,d]=l.useState(!1),[u,p]=l.useState(!1);return t.jsxs("div",{"data-testid":"danger-zone",style:{display:"flex",flexDirection:"column",gap:14,fontFamily:"var(--font-sans)"},children:[t.jsx(go,{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(go,{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(Kj,{exports:r})}),t.jsx(go,{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}),c&&t.jsx(qj,{pending:!!(a!=null&&a.signOutAll),onCancel:()=>d(!1),onConfirm:async()=>{await n(),d(!1)}}),u&&t.jsx(Yj,{githubHandle:e,pending:!!(a!=null&&a.deleteAccount),onCancel:()=>p(!1),onConfirm:async f=>{await o(f),p(!1)}})]})}function go({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 Kj({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:yo,children:"Requested"}),t.jsx("th",{style:yo,children:"Status"}),t.jsx("th",{style:yo,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:vo,children:new Date(r.requestedAt).toLocaleString()}),t.jsx("td",{style:vo,children:r.status}),t.jsx("td",{style:vo,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 qj({pending:e,onCancel:r,onConfirm:n}){return t.jsxs(vu,{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(bu,{children:[t.jsx(ku,{onClick:r,disabled:e,children:"Cancel"}),t.jsx(ju,{disabled:e,onClick:()=>void n(),children:e?"Signing out…":"Sign out everywhere"})]})]})}function Yj({githubHandle:e,pending:r,onCancel:n,onConfirm:s}){const[o,a]=l.useState(""),i=o.trim()===e;return t.jsxs(vu,{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:c=>a(c.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(bu,{children:[t.jsx(ku,{onClick:n,disabled:r,children:"Cancel"}),t.jsx(ju,{disabled:!i||r,onClick:()=>void s(o.trim()),children:r?"Deleting…":"Delete account"})]})]})}function vu({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 bu({children:e}){return t.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:e})}function ku({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 ju({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 yo={textAlign:"left",padding:"8px 10px",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-secondary)"},vo={padding:"8px 10px",color:"var(--text-primary)"},Jj="/api/v1/submissions/stream?mine=1",bo=new Set([...ls,...Zo]);function Xj(e){return!!e&&typeof e=="object"&&typeof e.submissionId=="string"&&typeof e.state=="string"}function Qj(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 Zj(e){return ls.has(e)?"#22C55E":Zo.has(e)?"#EF4444":"#F59E0B"}function ew({openStream:e=ou,notify:r=Jl}={}){const[n,s]=l.useState([]),[o,a]=l.useState({}),[i,c]=l.useState(!0),[d,u]=l.useState(null),[p,f]=l.useState(!1),h=l.useRef(new Set),m=l.useRef(!0),y=l.useCallback(async()=>{c(!0),u(null);try{const g=await ce.getMyQueue();if(!m.current)return;const b=g.submissions??[];s(b),a(g.queuePositions??{}),h.current=new Set(b.map(v=>v.id));for(const v of b)bo.has(v.state)&&Lf(v.id,v.state)}catch(g){if(!m.current)return;u(g instanceof Error?g.message:String(g))}finally{m.current&&c(!1)}},[]),x=l.useCallback(g=>{h.current.has(g.submissionId)&&(s(b=>{let v=!1;const k=b.map(E=>E.id!==g.submissionId?E:(v=!0,{...E,state:g.state,skillName:g.skillName||E.skillName,updatedAt:g.timestamp||E.updatedAt}));return v?k:b}),bo.has(g.state)&&(a(b=>{if(!(g.submissionId in b))return b;const v={...b};return delete v[g.submissionId],v}),Yl(g.submissionId,g.state)&&r(g.submissionId,g.skillName,g.state)))},[r]);return l.useEffect(()=>(m.current=!0,y(),()=>{m.current=!1}),[y]),l.useEffect(()=>{let g=null,b=null,v=0,k=!1;const E=()=>{k||(g=e(Jj,{timeoutMs:6e5,onEvent:T=>{if(k||(f(!0),v=0,!T.data||T.data==="connected"||T.data==="keepalive"))return;let w;try{w=JSON.parse(T.data)}catch{return}Xj(w)&&x(w)},onError:()=>{k||(f(!1),j())},onClose:()=>{k||(f(!1),j())}}))},j=()=>{if(k||b!=null)return;const T=Math.min(1e3*2**v,3e4);v+=1,b=setTimeout(()=>{if(b=null,!k){try{g==null||g.close()}catch{}E()}},T)};return E(),()=>{k=!0,b!=null&&clearTimeout(b);try{g==null||g.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 y(),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(g=>{const b=o[g.id],v=bo.has(g.state);return t.jsxs("tr",{"data-testid":`queue-row-${g.id}`,"data-state":g.state,style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[t.jsx("td",{style:{padding:"6px 8px",fontWeight:600},children:g.skillName}),t.jsx("td",{style:{padding:"6px 8px"},children:t.jsx("span",{"data-testid":`queue-state-${g.id}`,style:{color:Zj(g.state)},children:g.state})}),t.jsx("td",{style:{padding:"6px 8px",fontVariantNumeric:"tabular-nums"},"data-testid":`queue-position-${g.id}`,children:v||b==null?"—":`#${b}`}),t.jsx("td",{style:{padding:"6px 8px",color:"#9CA3AF",fontVariantNumeric:"tabular-nums"},children:Qj(g.updatedAt)})]},g.id)})})]})]})}const tw=[{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 rw({initialTab:e="profile",online:r=!0,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o}){const[a,i]=l.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(nw,{}),!r&&t.jsx(sw,{}),t.jsxs("div",{style:{display:"flex",flex:1,minHeight:0},children:[t.jsx(ow,{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(aw,{tab:a,online:r,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o})})]})]})}function nw(){const{data:e}=bn();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 sw(){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 ow({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:tw.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 aw({tab:e,online:r,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o}){switch(e){case"profile":return t.jsx(iw,{});case"billing":return t.jsx(lw,{onUpgradeClick:o});case"repos":return t.jsx(cw,{online:r,onConnectRepo:n,onOpenRepoOnGitHub:s});case"skills":return t.jsx(dw,{});case"queue":return t.jsx(uw,{});case"tokens":return t.jsx(pw,{});case"notifications":return t.jsx(hw,{});case"danger":return t.jsx(mw,{});default:return null}}function iw(){const{data:e,loading:r,error:n}=bn(),s=Yc(),[o,a]=l.useState(!1),[i,c]=l.useState(null);return r||!e?t.jsx(br,{error:n}):t.jsx(Lj,{profile:e,saving:o,errorMessage:i,onSubmit:async d=>{a(!0),c(null);try{await s(d)}catch(u){c(u instanceof Error?u.message:String(u))}finally{a(!1)}}})}function lw({onUpgradeClick:e}){const{data:r,loading:n,error:s}=bn();return n||!r?t.jsx(br,{error:s}):t.jsx(Mj,{tier:r.tier,onUpgradeClick:e})}function cw({online:e,onConnectRepo:r,onOpenRepoOnGitHub:n}){const{data:s,loading:o,error:a}=ms(),i=Jc(),c=Xc(),[d,u]=l.useState({});return o&&!s?t.jsx(br,{error:a}):t.jsx(jj,{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 c(p.repoId)}finally{u(f=>{const h={...f};return delete h[p.repoId],h})}}}})}function dw(){const{skills:e}=jg();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(Sl,{label:"Public skills",value:e.data.publicCount}),t.jsx(Sl,{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(br,{error:e.error})}function Sl({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 uw(){return t.jsx("section",{"data-testid":"account-queue-tab",style:{display:"flex",flexDirection:"column",gap:12},children:t.jsx(ew,{})})}function pw(){const{data:e,loading:r,error:n}=Qc(),s=Zc(),o=ed(),[a,i]=l.useState(!1),[c,d]=l.useState(null),[u,p]=l.useState(null);return r&&!e?t.jsx(br,{error:n}):n&&!e?t.jsx(fw,{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(Fj,{tokens:e??[],creating:a,pendingRevokeId:c,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 fw({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 hw(){const{data:e,loading:r,error:n}=td(),s=rd(),[o,a]=l.useState(!1),[i,c]=l.useState(null);return r||!e?t.jsx(br,{error:n}):t.jsx(Hj,{prefs:e,saving:o,errorMessage:i,onSubmit:async d=>{a(!0),c(null);try{await s(d)}catch(u){c(u instanceof Error?u.message:String(u))}finally{a(!1)}}})}function mw(){const{data:e}=bn(),{data:r}=nd(),n=sd(),s=od(),o=ad(),[a,i]=l.useState({}),[c,d]=l.useState(null);return e?t.jsx(Gj,{githubHandle:e.githubHandle,exports:r??[],pending:a,errorMessage:c,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(br,{})}function br({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 xw=l.lazy(()=>ar(()=>import("./FindSkillsPalette-BMVKCk6E.js"),__vite__mapDeps([8,5,3,4])).then(e=>({default:e.FindSkillsPalette})));Tf();const gw=l.lazy(()=>ar(()=>import("./SkillDetailPanel-BCJj8p79.js"),__vite__mapDeps([9,3,4,10,5,6])).then(e=>({default:e.SkillDetailPanel}))),yw=l.lazy(()=>ar(()=>import("./CreateSkillPage-ENMve2K8.js"),__vite__mapDeps([11,3,4,5,6])).then(e=>({default:e.CreateSkillPage}))),vw=l.lazy(()=>ar(()=>Promise.resolve().then(()=>m1),void 0).then(e=>({default:e.UpdatesPanel})));function bw(){return t.jsx(lh,{children:t.jsx(rv,{children:t.jsx(oh,{children:t.jsx(om,{children:t.jsx(kw,{children:t.jsxs(y0,{children:[t.jsx(jw,{}),t.jsx(h0,{})]})})})})})})}function kw({children:e}){const[r,n]=l.useState(void 0);return l.useEffect(()=>{let s=!1;if(Zl())return eh().then(o=>{s||n(o)}),()=>{s=!0}},[]),t.jsx(gg,{value:r,children:e})}function jw(){var wa,Sa;const{state:e,selectSkill:r,clearSelection:n,refreshSkills:s,outdatedByOrigin:o,revealSkill:a,clearReveal:i}=It(),{config:c}=gr(),{resolvedTheme:d,setTheme:u}=dc(),{toast:p}=cs(),[f,h]=l.useState(()=>gy()),[m]=l.useState(!0),[y,x]=l.useState(!1),[g,b]=l.useState(!1),[v,k]=l.useState(!1),[E,j]=l.useState(()=>typeof window>"u"?"overview":Uo(window.location.search).tab),[T,w]=l.useState(()=>{if(typeof window>"u")return"";const z=Uo(window.location.search);return z.mode?z.mode:z.view?z.view:ru(z.tab,window.location.search)}),S=l.useCallback(z=>{j(ae=>(ae!==z&&w(nn(z)),z))},[]);l.useEffect(()=>{if(typeof window>"u")return;const z=()=>{const ae=new URLSearchParams(window.location.search),ie=ae.get("tab"),at=ae.get("panel"),_e=ns(ie)??ns(at);if(!_e)return;const Ft=new URLSearchParams(window.location.search);Ft.delete("panel"),Ft.delete("sub"),_e.tab==="overview"?Ft.delete("tab"):Ft.set("tab",_e.tab),Ft.delete("mode"),Ft.delete("view"),_e.mode&&Ft.set("mode",_e.mode),_e.view&&Ft.set("view",_e.view);const Pt=Ft.toString(),Ca=`${window.location.pathname}${Pt?"?"+Pt:""}${window.location.hash}`,wu=`${window.location.pathname}${window.location.search}${window.location.hash}`;Ca!==wu&&window.history.replaceState(null,"",Ca),j(_e.tab),_e.mode?w(_e.mode):_e.view?w(_e.view):w(nn(_e.tab))};return z(),window.addEventListener("popstate",z),()=>window.removeEventListener("popstate",z)},[]),l.useEffect(()=>{if(typeof window>"u")return;const z=new URLSearchParams(window.location.search);z.delete("panel"),z.delete("sub"),E==="overview"?z.delete("tab"):z.set("tab",E),z.delete("mode"),z.delete("view"),!(T===nn(E))&&T&&(E==="run"?z.set("mode",T):E==="history"&&z.set("view",T));const ie=z.toString(),at=`${window.location.pathname}${ie?"?"+ie:""}${window.location.hash}`,_e=`${window.location.pathname}${window.location.search}${window.location.hash}`;at!==_e&&window.history.replaceState(null,"",at)},[E,T]);const[N,R]=l.useState(ml),I=l.useCallback((z,ae)=>{R(Zk(z,ae))},[]),A=hk(),[$,B]=l.useState(()=>Qk("activeAgent",null)),C=l.useCallback(z=>{B(z),Xk("activeAgent",z),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:z}}))},[]);l.useEffect(()=>{var z;!$&&((z=A.response)!=null&&z.suggested)&&C(A.response.suggested)},[$,(wa=A.response)==null?void 0:wa.suggested,C]);const L=l.useMemo(()=>A.response?lk(A.response):[],[A.response]),{workspace:P,switchProject:M,addProject:H,removeProject:le,activeProject:G}=kk(),[W,Z]=l.useState(!1);l.useEffect(()=>{Y.current=(G==null?void 0:G.path)??null},[G==null?void 0:G.path]);const[he,me]=l.useState(!1),[_,ne]=l.useState("standalone"),[D,U]=l.useState(!1),[K,V]=l.useState(null),Y=l.useRef(null),J=Sd(),te=fn(),de=l.useCallback(z=>{te.openExternalUrl(z).catch(()=>{typeof window<"u"&&window.open(z,"_blank","noopener,noreferrer")})},[te]),se=l.useCallback(async(z="standalone")=>{ne(z),me(!0)},[]);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;se((ie==null?void 0:ie.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",z),()=>window.removeEventListener("studio:request-create-skill",z)},[se]),l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;V(ie!=null&&ie.repoName?{repoName:ie.repoName}:null),U(!0)}return window.addEventListener("studio:request-paywall",z),()=>window.removeEventListener("studio:request-paywall",z)},[]);const[ue,F]=l.useState(!1),[q,re]=l.useState(null),[Q,pe]=l.useState(null);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;!ie||typeof ie.skill!="string"||ie.skill.length===0||pe({skill:ie.skill,skillDisplayName:ie.skillDisplayName,scope:ie.scope==="project"?"project":"user",activeAgentId:ie.activeAgentId,preCheckedAgentIds:ie.preCheckedAgentIds})}return window.addEventListener("studio:open-install-targets-modal",z),()=>window.removeEventListener("studio:open-install-targets-modal",z)},[]);const[xe,we]=l.useState(null);l.useEffect(()=>{function z(){F(!0)}return window.addEventListener("studio:open-marketplace",z),()=>window.removeEventListener("studio:open-marketplace",z)},[]);const ge=l.useMemo(()=>{const z=new Set;for(const ae of e.skills)ae.source==="plugin"&&ae.pluginName&&z.add(ae.pluginName);return z},[e.skills]),{lookup:Ve}=ld(),Ye=l.useMemo(()=>{const z=new Map;for(const ae of e.skills){const ie=kn(ae.repoUrl);if(!ie)continue;const at=Ve.get(ie);if(!at||!at.isPrivate)continue;const _e=ae.pluginName??ae.plugin;z.has(_e)||z.set(_e,{name:_e,repoFullName:at.repoFullName})}return Array.from(z.values())},[e.skills,Ve]);Po([{key:"p",meta:!0,handler:z=>{var ie;const ae=typeof document<"u"?document.activeElement:null;ae&&ae.tagName==="INPUT"||((ie=z==null?void 0:z.preventDefault)==null||ie.call(z),Z(at=>!at))}}],{enabled:!0});const Pe=V0(),rt=Pe.open;l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.provider&&rt(ie.provider)}return window.addEventListener("studio:open-setup-drawer",z),()=>window.removeEventListener("studio:open-setup-drawer",z)},[rt]);const Je=l.useCallback(()=>{R(ml)},[]);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.message&&p({message:ie.message,severity:ie.severity??"info"})}return window.addEventListener("studio:toast",z),()=>window.removeEventListener("studio:toast",z)},[p]),Jk();const[Ie,ee]=l.useState(!1),[Fe,Ke]=l.useState(void 0);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;Ke(ie==null?void 0:ie.provider),ee(!0)}return window.addEventListener("studio:open-settings",z),()=>window.removeEventListener("studio:open-settings",z)},[]),l.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${f}px`)},[f]),l.useEffect(()=>{function z(){s()}return window.addEventListener("studio:content-saved",z),()=>window.removeEventListener("studio:content-saved",z)},[s]);const[$e,nt]=l.useState(null),[it,Ct]=l.useState(()=>new Set),Vt=l.useRef(!1),Et=l.useMemo(()=>Pg(),[]),st=l.useCallback(z=>`${z.plugin}/${z.skill}`,[]),yt=l.useCallback(z=>{Ct(ae=>{const ie=new Set(ae);return ie.add(st(z)),ie})},[st]),vt=l.useCallback(z=>{Ct(ae=>{const ie=new Set(ae);return ie.delete(st(z)),ie})},[st]),Lt=il({delayMs:1e4,onCommit:z=>{s(),vt(z)},onFailure:(z,ae)=>{vt(z),p({message:`Couldn't delete ${z.skill}: ${ae.message}`,severity:"error",durationMs:0,action:{label:O.actions.retry,onInvoke:()=>{yt(z),Lt.enqueueDelete(z)}}})}});l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.skill&&nt(ie.skill)}return window.addEventListener("studio:request-delete",z),()=>window.removeEventListener("studio:request-delete",z)},[]);const[Ne,Se]=l.useState(null);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.skill&&Se(ie.skill)}return window.addEventListener("studio:request-clone",z),()=>window.removeEventListener("studio:request-clone",z)},[]);const[ze,ot]=l.useState(null),Xt=il({delayMs:250,apiCall:(z,ae)=>api.uninstallSkill(z,ae),onCommit:z=>{s(),vt(z)},onFailure:(z,ae)=>{var ie;if(vt(z),ae instanceof qt&&((ie=ae.details)==null?void 0:ie.code)==="not-installed"){p({message:`${z.skill} is a source-authored skill — use Delete instead`,severity:"info",durationMs:4e3});return}p({message:`Couldn't uninstall ${z.skill}: ${ae.message}`,severity:"error",durationMs:0,action:{label:O.actions.retry,onInvoke:()=>{yt(z),Xt.enqueueDelete(z)}}})}});l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.skill&&ot(ie.skill)}return window.addEventListener("studio:request-uninstall",z),()=>window.removeEventListener("studio:request-uninstall",z)},[]);const At=l.useCallback(async z=>{await Promise.all([Lt.flushBySkillName(z),Xt.flushBySkillName(z)])},[Lt,Xt]),ys=l.useMemo(()=>({flushBySkillName:At}),[At]),vs=l.useCallback(()=>{const z=ze;if(ot(null),!z)return;const ae={plugin:z.plugin,skill:z.skill};yt(ae),Xt.enqueueDelete(ae),p({message:`Uninstalled ${z.skill}. Sent to your ${Et}.`,severity:"info",durationMs:4e3})},[ze,yt,Xt,p,Et]),_r=l.useCallback(()=>{ot(null)},[]),Gt=l.useCallback(()=>{const z=$e;if(nt(null),!z)return;const ae={plugin:z.plugin,skill:z.skill};yt(ae),Lt.enqueueDelete(ae);const ie=Vt.current?"":`Sent to your ${Et}. Open Trash to restore. `;Vt.current=!0,p({message:`${ie}Deleted ${z.skill}`,severity:"info",durationMs:1e4,action:{label:O.actions.undo,onInvoke:()=>{Lt.cancelDelete(st(ae)),vt(ae)}}})},[$e,yt,vt,Lt,p,Et,st]),kr=l.useCallback(()=>{nt(null)},[]),Qt=l.useMemo(()=>e.skills.filter(z=>!it.has(st(z))),[e.skills,it,st]),Sn=Cy(Qt,(G==null?void 0:G.path)??null),Xe=l.useMemo(()=>e.selectedSkill?e.skills.find(z=>z.plugin===e.selectedSkill.plugin&&z.skill===e.selectedSkill.skill)??null:null,[e.skills,e.selectedSkill]),Me=l.useRef(null);l.useEffect(()=>{if(!Xe||typeof window>"u"||new URLSearchParams(window.location.search).get("tab")||!(Xe.origin==="installed"))return;const ie=`${Xe.plugin}/${Xe.skill}`;Me.current!==ie&&(Me.current=ie,E==="overview"&&j("source"))},[Xe==null?void 0:Xe.plugin,Xe==null?void 0:Xe.skill,Xe==null?void 0:Xe.origin]);const ur=l.useCallback(z=>{r({plugin:z.plugin,skill:z.skill,origin:z.origin,source:z.source})},[r]),Zt=l.useMemo(()=>{if(!e.selectedSkill)return"";const z=e.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${e.selectedSkill.skill} (${z})`},[e.selectedSkill]),[Cn,lt]=l.useState(null);Po([{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:()=>x(z=>!z)},{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(z=>!z)},{key:"ctrl+b",handler:()=>b(z=>!z)}]);const ja=sj(),er=oj(),bs=v?t.jsx(rw,{online:typeof navigator>"u"?!0:navigator.onLine!==!1,onConnectRepo:()=>{de("https://verified-skill.com/account/repos/connect")},onOpenRepoOnGitHub:de,onUpgradeClick:()=>{de(Cd)}}):er?t.jsx(l.Suspense,{fallback:t.jsx("div",{style:{padding:40},children:"Loading…"}),children:t.jsx(vw,{})}):ja?t.jsx(l.Suspense,{fallback:t.jsx("div",{style:{padding:40},children:"Loading…"}),children:t.jsx(yw,{})}):t.jsx(o0,{selectedSkillInfo:Xe,activeDetailTab:E,onDetailTabChange:S,activeDetailSub:T,onDetailSubChange:w,allSkills:e.skills,onSelectSkill:ur});return t.jsxs(Gd.Provider,{value:ys,children:[t.jsx(ch,{sidebarWidth:f,sidebarHidden:g||e.isMobile&&e.mobileView==="detail",banner:t.jsx(Ey,{connected:m}),liveMessage:Zt,topRail:t.jsx(fm,{projectName:(c==null?void 0:c.projectName)??null,selected:e.selectedSkill,onHome:n,onRequestCreateSkill:()=>se("standalone"),projectPickerSlot:P&&P.projects.length>0?t.jsx(wk,{workspace:P,onSwitch:M,onAdd:H,onRemove:le}):void 0,findSkillsSlot:t.jsx(lj,{}),appUpdateSlot:t.jsx(b0,{}),userDropdownSlot:t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[t.jsx(mj,{}),t.jsx(cj,{})]})}),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(ay,{skills:Qt,selectedKey:e.selectedSkill?{plugin:e.selectedSkill.plugin,skill:e.selectedSkill.skill}:null,onSelect:z=>{k(!1),ur(z)},isLoading:e.skillsLoading,error:e.skillsError??null,onRetry:s,onContextMenu:I,outdatedByOrigin:o,activeAgentId:$,revealSkillId:e.revealSkillId,onRevealComplete:i,dirtySkillIds:Sn,onSkillsChanged:s,topSlot:t.jsxs(t.Fragment,{children:[A.status==="ready"&&L.length>0?t.jsxs(t.Fragment,{children:[t.jsx(ck,{agents:L,activeAgentId:$,onActiveAgentChange:C,onOpenSetup:z=>Pe.open(z)}),t.jsx(fk,{activeAgentId:$})]}):null,G!=null&&G.path?t.jsx(ud,{folder:G.path,tier:J.tier,onUpgradeClick:()=>{try{window.dispatchEvent(new CustomEvent("studio:request-paywall",{detail:{repoName:G.path}}))}catch{}}}):null]})})}),t.jsx("div",{style:{borderTop:"1px solid var(--border-default, rgba(128,128,128,0.25))",padding:"6px 0"},children:t.jsx(vj,{active:v,onClick:()=>k(z=>!z)})})]}),resizeHandle:t.jsx(vy,{initialWidth:f??rn,onChange:h}),main:bs,statusBar:t.jsx(Sm,{projectPath:(c==null?void 0:c.root)??null,modelName:(c==null?void 0:c.model)??null,health:c!=null&&c.error?"degraded":"ok",providers:(Sa=c==null?void 0:c.providers)==null?void 0:Sa.map(z=>{const ae=z.id;return{id:ae,label:z.label,available:z.available,kind:ae==="ollama"||ae==="lm-studio"?"start-service":ae==="anthropic"||ae==="openrouter"?"api-key":"cli-install"}})})}),t.jsx(j0,{open:y,onClose:()=>x(!1)}),t.jsx(B0,{open:Pe.isOpen,providerKey:Pe.providerKey,onClose:Pe.close}),t.jsx(S0,{state:N,onClose:Je,onAction:(z,ae)=>tj(z,ae)}),t.jsx(l.Suspense,{fallback:null,children:t.jsx(xw,{onSelect:z=>{const ae=z.name.split("/");ae.length===3&&lt({owner:ae[0],repo:ae[1],slug:ae[2],displayName:z.displayName??z.name})}})}),Cn&&t.jsx(l.Suspense,{fallback:null,children:t.jsx(gw,{selectedSkill:Cn,activeAgentId:$,onClose:()=>lt(null)})}),t.jsx(Ck,{open:W,projects:(P==null?void 0:P.projects)??[],onSwitch:z=>{M(z)},onClose:()=>Z(!1)}),t.jsx(Ek,{open:he,onClose:()=>me(!1),initialMode:_,isClaudeCode:$==="claude-code",projectRoot:(G==null?void 0:G.path)??(c==null?void 0:c.projectName)??"",onCreated:z=>{s(),setTimeout(()=>{a(z.pluginName??"",z.skillName)},500),te.quotaReportCount(Qt.length+1)}}),t.jsx(Ik,{open:ue,onClose:()=>F(!1),installedNames:ge,privatePlugins:Ye,onInstall:(z,ae)=>{re({plugin:z,marketplace:ae,ref:`${z}@${ae}`}),F(!1)},onUninstall:async z=>{if(await new Promise(ie=>{we({plugin:z,resolve:ie})}))try{const ie=await fetch(`/api/plugins/${encodeURIComponent(z)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),at=await ie.json().catch(()=>({}));if(!ie.ok||!at.ok){p({message:at.error??`Uninstall failed (${ie.status})`,severity:"error"});return}const _e=at.fallback==="orphan-cache-removed"?`Removed orphaned ${z}.`:`Uninstalled ${z}.`;p({message:_e,severity:"success"}),s()}catch(ie){p({message:ie instanceof Error?ie.message:String(ie),severity:"error"})}}}),t.jsx(ac,{open:Ie,onClose:()=>ee(!1),initialProvider:Fe,onToast:z=>p({message:z,severity:"info"})}),t.jsx(Mk,{job:q,onDone:z=>{z.ok&&(s(),setTimeout(()=>re(null),3e3))}}),Q&&t.jsx(Vk,{skill:Q.skill,skillDisplayName:Q.skillDisplayName,scope:Q.scope,activeAgentId:Q.activeAgentId===void 0?$:Q.activeAgentId,preCheckedAgentIds:Q.preCheckedAgentIds,onClose:()=>pe(null),onSuccess:z=>{s();const ae=z.filter(Pt=>Pt.status==="installed").length,ie=z.filter(Pt=>Pt.status==="exported").length,at=z.find(Pt=>Pt.status==="error"),_e=Q.skillDisplayName??Q.skill;at?p({message:at.detail||`Could not install ${_e}.`,severity:"error"}):ie>0?p({message:`Installed ${_e}; ${ie} target${ie===1?"":"s"} need paste.`,severity:"info"}):ae>0&&p({message:`Installed ${_e} to ${ae} target${ae===1?"":"s"}.`,severity:"success"}),z.some(Pt=>Pt.status==="error"||Pt.status==="exported")||pe(null)}}),t.jsx(qn,{open:$e!==null,title:$e?`Delete "${$e.skill}"?`:"",body:`It will be sent to your ${Et}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Gt,onCancel:kr}),t.jsx(qn,{open:ze!==null,title:ze?`Uninstall "${ze.skill}"?`:"",body:`It will be sent to your ${Et} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:vs,onCancel:_r}),t.jsx(qn,{open:xe!==null,title:xe?`Uninstall ${xe.plugin}?`:"",body:xe?`This removes the ${xe.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{xe==null||xe.resolve(!0),we(null)},onCancel:()=>{xe==null||xe.resolve(!1),we(null)}}),t.jsx(Ed,{open:D,skillName:(K==null?void 0:K.repoName)??void 0,onClose:()=>{U(!1),V(null)},onProceed:()=>{V(null)}}),Ne&&t.jsx(E0,{skill:Ne,onCloned:z=>{p({message:O.toasts.cloneSucceeded,severity:"info"}),Se(null);try{window.dispatchEvent(new CustomEvent("studio:skills-changed",{detail:z}))}catch{}s()},onCancel:()=>Se(null)})]})}const Cl="vskill.migrations.scope-rename.v1",ww={own:"authoring-project",installed:"available-project",global:"available-personal"},Sw=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function Cw(e){if(e.getItem(Cl)==="done")return;const r=[];for(let n=0;n<e.length;n++){const s=e.key(n);if(!s)continue;const o=s.match(Sw);if(!o)continue;const[,a,i]=o,c=ww[i];if(!c)continue;const d=e.getItem(s);d!==null&&r.push({oldKey:s,newKey:`vskill-sidebar-${a}-${c}-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(Cl,"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{Cw(window.localStorage)}catch{}Eu.createRoot(document.getElementById("root")).render(t.jsx(l.StrictMode,{children:t.jsx(Kp,{children:t.jsx(vm,{children:t.jsx(bw,{})})})}));export{gs as E,Vk as I,Wl as L,wn as P,u1 as S,Tw as T,ce as a,It as b,l1 as c,a1 as d,jn as e,cs as f,Qk as g,Vd as h,ou as o,pu as r,Rr as t,gr as u,Xk as w};
87
+ `)})]})}function Dk(){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 Fk(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 zk(e){if(typeof navigator<"u"&&navigator.clipboard){await navigator.clipboard.writeText(e);return}throw new Error("Clipboard API unavailable in this environment")}function Bk({agentId:e,agentDisplayName:r,blob:n,pasteInstructionsUrl:s,docsUrl:o,scopeDowngradeWarning:a,onClose:i,writeClipboardImpl:c}){const d=l.useRef(null),[u,p]=l.useState(!1),[f,h]=l.useState(null);l.useEffect(()=>{const y=x=>{x.key==="Escape"&&(x.preventDefault(),i())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[i]);const m=l.useCallback(async()=>{const y=c??zk;try{await y(n),p(!0),h(null)}catch(x){h(x instanceof Error?x.message:String(x))}},[n,c]);return typeof document>"u"?null:Dr.createPortal(t.jsx("div",{"data-testid":"clipboard-export-dialog-backdrop",role:"presentation",onClick:y=>{y.target===y.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 _k(e,r){const n=e.split(/[.-]/).map(o=>Number.parseInt(o,10)),s=r.split(/[.-]/).map(o=>Number.parseInt(o,10));for(let o=0;o<Math.max(n.length,s.length);o++){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(s[o])?s[o]:0;if(a!==i)return a-i}return 0}function Ok(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 c=a.installed&&a.installedAgentTools.includes(e),d=i.installed&&i.installedAgentTools.includes(e);if(!c)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=_k(u,s);return p===0?{kind:"installed-current",version:u}:p<0?{kind:"update-available",installed:u,target:s}:{kind:"newer-installed",installed:u,target:s}}const Wk=Object.freeze({"claude-cli":"claude-code","codex-cli":"codex"});function pl(e){return e?Wk[e]??e:null}function Uk(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 Hk(e){switch(e){case"installed":return"Installed";case"exported":return"Exported";case"skipped":return"Skipped";case"error":return"Error"}}function Ho(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 Vk({skill:e,skillDisplayName:r,scope:n,targetVersion:s,activeAgentId:o,preCheckedAgentIds:a,onClose:i,onSuccess:c,fetchSupportedAgentsImpl:d,installToAgentsImpl:u,startInstallStreamImpl:p,fetchInstallStateImpl:f,removeSkillImpl:h,writeClipboardImpl:m}){var de;const y=l.useRef(null),[x,g]=l.useState("loading"),[b,v]=l.useState([]),[k,E]=l.useState(null),[j,T]=l.useState(new Set),[w,S]=l.useState(null),[N,R]=l.useState({}),[I,A]=l.useState(null),[$,B]=l.useState(0),[C,L]=l.useState(new Set),[P,M]=l.useState([]),[H,le]=l.useState(null),G=l.useRef(null);l.useEffect(()=>{const se=ue=>{ue.key==="Escape"&&(H||(ue.preventDefault(),ue.stopPropagation(),x!=="installing"&&i()))};return document.addEventListener("keydown",se,!0),()=>document.removeEventListener("keydown",se,!0)},[H,x,i]),l.useEffect(()=>{let se=!1;return(d??au)().then(F=>{if(se)return;v(F);const q=new Set,re=pl(o);re&&F.some(Q=>Q.id===re)&&q.add(re);for(const Q of a??[]){const pe=pl(Q);pe&&F.some(xe=>xe.id===pe)&&q.add(pe)}if(q.size===0){const Q=Uk(F);Q&&q.add(Q)}T(q),g("select")}).catch(F=>{se||(E(F instanceof Error?F.message:String(F)),g("error"))}),()=>{se=!0}},[d,o,a]),l.useEffect(()=>()=>{var se;try{(se=G.current)==null||se.close()}catch{}},[]),l.useEffect(()=>{let se=!1;return(f??(F=>ce.getSkillInstallState(F)))(e).then(F=>{se||A(F)},()=>{se||A(null)}),()=>{se=!0}},[e,f,$]);const W=l.useMemo(()=>X0(b),[b]),Z=l.useCallback(se=>{T(ue=>{const F=new Set(ue);return F.has(se)?F.delete(se):F.add(se),F})},[]),he=l.useCallback(()=>{T(()=>{const se=new Set;for(const ue of b)ue.detected&&se.add(ue.id);return se})},[b]),me=l.useCallback(()=>{T(new Set)},[]),_=l.useCallback(()=>{var se;if(x!=="installing"){try{(se=G.current)==null||se.close()}catch{}i()}},[x,i]),ne=l.useCallback(async()=>{if(j.size===0)return;S(null),R({}),g("installing");const se=Array.from(j),ue=u??q0,F=p??Y0;try{const{jobId:q,streamPath:re}=await ue({skill:e,agentIds:se,scope:n});G.current=F(re??q,{onResult:Q=>{R(pe=>({...pe,[Q.agentId]:Q}))},onDone:Q=>{const pe={},xe=Q.success===!1?typeof Q.error=="string"&&Q.error.trim()||"Install failed before any target reported a result.":null;for(const we of se)pe[we]=xe?{agentId:we,status:"error",detail:xe}:{agentId:we,status:"skipped"};if(xe)S(xe);else for(const we of Q.results??[])pe[we.agentId]=we;R(we=>{var Je;const ge={...pe};for(const[Ie,ee]of Object.entries(we))((Je=ge[Ie])==null?void 0:Je.status)==="skipped"&&ee.status!=="skipped"&&(ge[Ie]=ee);if(!Object.values(ge).some(Ie=>Ie.status==="installed"||Ie.status==="exported"||Ie.status==="error")){const Ie="Install finished without writing any selected target.";for(const ee of se)ge[ee]={agentId:ee,status:"error",detail:Ie};S(Ie)}const Pe=Object.values(ge),rt=Pe.filter(Ie=>Ie.status==="exported"&&typeof Ie.blob=="string");return rt.length>0&&(M(rt),le(rt[0]??null)),globalThis.setTimeout(()=>{try{c==null||c(Pe)}catch{}},0),ge}),B(we=>we+1),g("done")},onError:Q=>{S(Q.message),g("error")}})}catch(q){S(q instanceof Error?q.message:String(q)),g("error")}},[j,e,n,u,p,c]),D=l.useCallback(async se=>{const ue=h??Fk;L(F=>{const q=new Set(F);return q.add(se),q});try{const F=await ue({skill:e,agentIds:[se],scope:n});if(typeof window<"u")try{window.dispatchEvent(new CustomEvent("studio:skill-installed",{detail:{skill:e,scope:n}}))}catch{}B(q=>q+1),F.errors.length>0&&S(`Remove failed for ${F.errors[0].agentId}: ${F.errors[0].message}`)}catch(F){S(F instanceof Error?F.message:String(F))}finally{L(F=>{const q=new Set(F);return q.delete(se),q})}},[h,e,n]),U=l.useCallback(()=>{M(se=>{const ue=se.slice(1);return le(ue[0]??null),ue})},[]),K=l.useMemo(()=>b.filter(se=>se.detected).length,[b]);if(typeof document>"u")return null;const V=j.size===0||x==="installing",Y=j.size===0?"Select at least one target":void 0,J=`Install ${r??e} to:`,te=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 Dr.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-testid":"install-targets-modal-backdrop",role:"presentation",onClick:se=>{se.target===se.currentTarget&&_()},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:y,"data-testid":"install-targets-modal",role:"dialog","aria-modal":"true","aria-label":J,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:J}),t.jsx("div",{"data-testid":"install-targets-modal-scope-line",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:te})]}),t.jsx("button",{type:"button","data-testid":"install-targets-modal-close",onClick:_,"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…"}),k&&x==="error"&&b.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: ",k]}),(x==="select"||x==="installing"||x==="done"||x==="error"&&b.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:[j.size," selected · ",K," detected"]}),t.jsxs("div",{style:{display:"flex",gap:"0.375rem"},children:[t.jsx("button",{type:"button","data-testid":"install-targets-select-all-detected",onClick:he,disabled:x==="installing"||K===0,style:fl(),children:"Select all detected"}),t.jsx("button",{type:"button","data-testid":"install-targets-clear",onClick:me,disabled:x==="installing"||j.size===0,style:fl(),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 ",j.size," target",j.size===1?"":"s","…"]}),t.jsx(lo,{testId:"install-targets-section-dropin",title:"Drop-in",description:"Filesystem install — Claude-style SKILL.md drops in unchanged.",agents:W.dropIn,selected:j,results:N,phase:x,onToggle:Z,scope:n,installState:I,targetVersion:s??null,removingAgents:C,onRemove:D}),t.jsx(lo,{testId:"install-targets-section-format-converted",title:"Format-converted",description:"Auto-converted to the tool's native format on install.",agents:W.formatConverted,selected:j,results:N,phase:x,onToggle:Z,scope:n,installState:I,targetVersion:s??null,removingAgents:C,onRemove:D}),t.jsx(lo,{testId:"install-targets-section-cloud",title:"Cloud only (paste required)",description:"No local filesystem — opens a paste-ready blob.",agents:W.cloud,selected:j,results:N,phase:x,onToggle:Z,tierBadge:"T3",pathOverride:"Copy to clipboard",scope:n,installState:I,targetVersion:s??null,removingAgents:C,onRemove:D})]}),x==="done"&&t.jsx(Gk,{results:Object.values(N),agents:b}),(x==="error"||x==="done")&&w&&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:w})]}),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:[t.jsx("button",{type:"button","data-testid":"install-targets-modal-cancel",onClick:_,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:x==="done"?"Close":"Cancel"}),t.jsx("button",{type:"button","data-testid":"install-targets-modal-install",onClick:ne,disabled:V||x==="done","aria-disabled":V||x==="done",title:Y,style:{padding:"0.5rem 1.125rem",borderRadius:6,border:"1px solid var(--text-primary, #191919)",background:V||x==="done"?"var(--bg-surface, #FFFFFF)":"var(--text-primary, #191919)",color:V||x==="done"?"var(--text-secondary, #5A5651)":"var(--bg-surface, #FFFFFF)",cursor:V||x==="done"?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"var(--font-sans)",opacity:V&&x!=="done"?.6:1},children:x==="installing"?"Installing…":x==="done"?"Done":`Install (${j.size})`})]})]})}),H&&t.jsx(Bk,{agentId:H.agentId,agentDisplayName:((de=b.find(se=>se.id===H.agentId))==null?void 0:de.displayName)??H.agentId,blob:H.blob??"",pasteInstructionsUrl:H.pasteInstructionsUrl,docsUrl:H.docsUrl,scopeDowngradeWarning:H.detail&&H.detail.includes("project-scoped")?H.detail:void 0,onClose:U,writeClipboardImpl:m})]}),document.body)}function lo({testId:e,title:r,description:n,agents:s,selected:o,results:a,phase:i,onToggle:c,tierBadge:d,pathOverride:u,scope:p,installState:f,targetVersion:h,removingAgents:m,onRemove:y}){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(x=>{const g=o.has(x.id),b=a[x.id],v=i==="installing"||i==="done",k=u??(p==="project"?x.resolvedLocalDir:x.resolvedGlobalDir),E=Ok(x.id,p,f,h),j=m.has(x.id);return t.jsxs("label",{"data-testid":`install-targets-row-${x.id}`,"data-checked":g?"true":"false","data-detected":x.detected?"true":"false",style:{display:"flex",alignItems:"center",gap:"0.625rem",padding:"0.375rem 0.5rem",borderRadius:4,cursor:v?"default":"pointer",background:g?"color-mix(in srgb, var(--accent-surface) 8%, transparent)":"transparent"},children:[t.jsx("input",{type:"checkbox","data-testid":`install-targets-checkbox-${x.id}`,checked:g,disabled:v,onChange:()=>c(x.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:x.displayName}),!x.detected&&t.jsx("span",{"data-testid":`install-targets-undetected-badge-${x.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(Kk,{agentId:x.id,badge:E,isRemoving:j,onRemove:y})]}),t.jsx("div",{title:k,"data-testid":`install-targets-path-${x.id}`,style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k})]}),b&&t.jsx("span",{"data-testid":`install-targets-status-${x.id}`,"data-status":b.status,style:{fontSize:11,padding:"1px 8px",borderRadius:10,background:`color-mix(in srgb, ${Ho(b.status)} 16%, transparent)`,color:Ho(b.status),fontFamily:"var(--font-mono)"},children:Hk(b.status)})]},x.id)})})]})}function Gk({results:e,agents:r}){return e.length===0?null: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(n=>{const s=r.find(i=>i.id===n.agentId),o=n.status==="installed"?n.path??n.detail:n.status==="exported"?n.detail&&n.detail.includes("project-scoped")?n.detail:"Copied to clipboard":n.status==="error"?n.detail??"Unknown error":n.detail??"",a=n.status==="installed"?"✓":n.status==="exported"?"⧉":n.status==="skipped"?"·":"✗";return t.jsxs("div",{"data-testid":`install-targets-result-row-${n.agentId}`,"data-status":n.status,style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",fontSize:12},children:[t.jsx("span",{"aria-hidden":"true",style:{color:Ho(n.status),fontWeight:600,fontFamily:"var(--font-mono)",width:"0.875rem",flexShrink:0},children:a}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsx("span",{style:{fontWeight:500},children:(s==null?void 0:s.displayName)??n.agentId}),o&&t.jsx("span",{style:{marginLeft:"0.5rem",color:"var(--text-secondary)",fontFamily:"var(--font-mono)",fontSize:11,wordBreak:"break-all"},children:o}),n.status==="exported"&&n.pasteInstructionsUrl&&t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{"data-testid":`install-targets-result-paste-link-${n.agentId}`,href:n.pasteInstructionsUrl,target:"_blank",rel:"noreferrer noopener",style:{fontSize:11,color:"var(--accent-text, var(--text-primary))",textDecoration:"underline"},children:"open paste instructions →"})]})]})]},n.agentId)})]})}function Kk({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 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 v${r.installed} (target v${r.target})`,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 c=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}),c&&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 fl(){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 qk=3e3,Yk={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function hl(e){return e==="anthropic"||e==="openai"||e==="openrouter"}function Jk(){const{toast:e}=cs(),r=l.useRef(new Map),n=l.useCallback(s=>{if(!hl(s.provider))return;const o=Date.now(),a=r.current.get(s.provider)??0;if(o-a<qk)return;r.current.set(s.provider,o);const i=Yk[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 l.useEffect(()=>{function s(o){const a=o.detail;!a||!hl(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 du="vskill.studio.prefs";function uu(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function pu(){const e=uu();if(!e)return{};try{const r=e.getItem(du);if(!r)return{};const n=JSON.parse(r);return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}catch{return{}}}function Xk(e,r){const n=uu();if(n)try{const o={...pu(),[e]:r};n.setItem(du,JSON.stringify(o))}catch{}}function Qk(e,r){const s=pu()[e];return s===void 0?r:s}const ml={open:!1,x:0,y:0,skill:null};function Zk(e,r){return{open:!0,x:e.clientX,y:e.clientY,skill:r}}function Bt(e,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:e,severity:r}}))}function ej(e){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:e}}))}async function xl(e,r){var n;try{await ce.revealInEditor(e.plugin,e.skill,r),Bt(O.toasts.openingInEditor,"info")}catch(s){if(s instanceof qt){const o=(n=s.details)==null?void 0:n.error;if(s.status===404){Bt(O.toasts.skillNotFound,"error");return}if(s.status===500&&o==="no_editor"){Bt(O.toasts.noEditor,"error");return}}Bt(O.toasts.openFailed,"error")}}async function tj(e,r){var n;switch(e){case"copy-path":try{(n=navigator.clipboard)==null||n.writeText(r.dir)}catch{Bt(O.toasts.permissionDenied,"error");return}Bt(O.toasts.pathCopied,"info");return;case"reveal":case"edit":await xl(r,"SKILL.md");return;case"open":await xl(r);return;case"run-benchmark":Bt(O.toasts.benchmarkQueued,"info");return;case"duplicate":Bt(O.toasts.skillDuplicated,"info");return;case"clone":try{window.dispatchEvent(new CustomEvent("studio:request-clone",{detail:{skill:r}}))}catch{}return;case"update":Bt(O.toasts.skillUpdated,"info");return;case"uninstall":Bt(O.toasts.uninstallNotImplemented,"info");return;case"delete":ej(r);return;default:return}}function rj(e){return e.startsWith("#/create")}function nj(e){return e.startsWith("#/updates")}function fu(e){const[r,n]=l.useState(()=>typeof window<"u"&&e(window.location.hash));return l.useEffect(()=>{function s(){n(e(window.location.hash))}return window.addEventListener("hashchange",s),s(),()=>window.removeEventListener("hashchange",s)},[]),r}function sj(){return fu(rj)}function oj(){return fu(nj)}function aj(){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 ij(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function lj(){const[e,r]=l.useState("⌘⇧K");l.useEffect(()=>{r(aj())},[]);const n=ij();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 cj(){const e=fn(),[r,n]=l.useState(null),[s,o]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(null),[u,p]=l.useState(null),[f,h]=l.useState(!1),m=l.useRef(!1);l.useEffect(()=>{let k=!1;return(async()=>{try{const E=await e.getSignedInUser();k||n(E)}catch{}finally{k||o(!1)}})(),()=>{k=!0}},[e]);const y=l.useRef(null);l.useEffect(()=>{if(!a)return;function k(j){y.current&&(y.current.contains(j.target)||i(!1))}function E(j){j.key==="Escape"&&i(!1)}return document.addEventListener("pointerdown",k),document.addEventListener("keydown",E),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",E)}},[a]);const x=l.useCallback(async k=>{try{if(typeof e.openExternalUrl=="function"){await e.openExternalUrl(k);return}}catch(E){console.warn("open external URL:",E)}window.open(k,"_blank","noopener,noreferrer")},[e]),g=l.useCallback(async()=>{p(null),h(!0),m.current=!1;let k=null;const E=j=>{k=j,p(j)};try{const j=await e.startGithubDeviceFlow();window.__vskillOauthState=j.userCode,d(j),x(j.verificationUri);let T=Math.max(1,j.interval);const w=Date.now()+j.expiresIn*1e3;for(;!m.current&&Date.now()<w&&(await pj(T*1e3,()=>m.current),!m.current);){const S=await e.pollGithubDeviceFlow();if(S.status==="granted"){n(S.user),d(null),h(!1);return}if(S.status!=="pending"){if(S.status==="slow_down"){T=Math.max(T+1,S.newInterval);continue}if(S.status==="denied"){E("Sign-in was denied at GitHub. You can try again.");break}if(S.status==="expired"){E("Sign-in code expired. Try again to get a fresh code.");break}if(S.status==="no-flow"){E("Sign-in state lost. Please retry.");break}E(S.message);break}}!m.current&&!k&&E("Sign-in code expired. Try again to get a fresh code.")}catch(j){E(j instanceof Error?j.message:String(j))}finally{h(!1)}},[e,x]),b=l.useCallback(()=>{m.current=!0,d(null),p(null),h(!1)},[]),v=l.useCallback(async()=>{i(!1);try{await e.signOut()}catch(k){console.warn("sign-out:",k)}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:y,children:[t.jsxs("button",{type:"button","data-slot":"user-chip",onClick:()=>i(k=>!k),"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:k=>{const E=hj(r.login);k.currentTarget.src!==E&&(k.currentTarget.src=E)},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(gl,{label:"View on GitHub",onClick:()=>{x(`https://github.com/${r.login}`),i(!1)}}),t.jsx(gl,{label:"Sign out",onClick:v})]})]}):t.jsxs("div",{"data-slot":"user-dropdown",style:{position:"relative"},ref:y,children:[t.jsxs("button",{type:"button","data-slot":"sign-in-button",onClick:g,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(uj,{size:14}),f?"Signing in…":"Sign in"]}),c&&t.jsx(dj,{response:c,error:u,onCancel:b,onOpenGithub:()=>void x(c.verificationUri),onRetry:g})]})}function dj({response:e,error:r,onCancel:n,onOpenGithub:s,onRetry:o}){const[a,i]=l.useState("idle"),c=l.useRef(null);l.useEffect(()=>()=>{c.current!=null&&window.clearTimeout(c.current)},[]);let d=e.verificationUri;try{const p=new URL(e.verificationUri);d=`${p.host}${p.pathname}`}catch{}const u=l.useCallback(async()=>{c.current!=null&&window.clearTimeout(c.current);try{await fj(e.verificationUri),i("copied"),c.current=window.setTimeout(()=>i("idle"),1500)}catch{i("failed"),c.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 gl({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 uj({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 pj(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 fj(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 hj(e){return`https://github.com/${encodeURIComponent(e)}.png?size=40`}function mj({forcedTone:e}){const{snapshot:r,refreshing:n,forceSync:s}=xa(),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 c=e??xj(o,a);if(!c)return null;const d=l.useCallback(()=>{s(!0)},[s]),u=c==="danger"?"Sign in to refresh your subscription. Some features will be locked until you reconnect.":"Sync to verify your subscription — last synced 7 days ago.";return t.jsxs("div",{role:"status","aria-live":"polite","data-testid":"quota-grace-banner","data-tone":c,style:{...gj,background:c==="danger"?"var(--color-danger-bg, rgba(220, 50, 47, 0.12))":"var(--color-warn-bg, rgba(203, 75, 22, 0.12))",color:c==="danger"?"var(--color-danger, #dc322f)":"var(--color-warn, #cb4b16)",borderColor:c==="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:yj,children:n?"Syncing…":"Sync now"})]})}function xj(e,r){return r?e<=1?"warn":null:"danger"}const gj={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)"},yj={padding:"2px 10px",borderRadius:4,border:"1px solid currentColor",background:"transparent",color:"inherit",cursor:"pointer",fontSize:12,fontWeight:500};function vj({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 bj={green:"#16a34a",amber:"#f59e0b",grey:"#9ca3af",red:"#dc2626"},kj={green:"Synced",amber:"Reauth needed",grey:"Idle",red:"Error"};function jj({repos:e,viewMode:r="table",pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,onConnectNew:i,now:c=new Date}){const d=Sj(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(Cj,{summary:d,onConnectNew:i,showConnectAction:!0}),e.length===0?t.jsx(Ej,{}):t.jsxs(t.Fragment,{children:[u.length>0?t.jsx(yl,{kind:"private",repos:u,viewMode:r,pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,now:c}):null,p.length>0?t.jsx(yl,{kind:"public",repos:p,viewMode:r,pendingActions:n,onOpenOnGitHub:s,onResync:o,onDisconnect:a,now:c}):null]})]})}function yl({kind:e,repos:r,viewMode:n,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:c}){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(wj,{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(Rj,{repos:r,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:c}):t.jsx(Nj,{repos:r,pendingActions:s,onOpenOnGitHub:o,onResync:a,onDisconnect:i,now:c})]})}function wj({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 Sj(e){let r=0,n=0;for(const s of e)s.isPrivate?n++:r++;return{total:e.length,publicCount:r,privateCount:n}}function Cj({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(Vo,{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(Vo,{isPrivate:!0})," ",e.privateCount]})]}),t.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.4},children:"Public repositories work on Free. Private repository connections require Pro and GitHub App access."})]}),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 Vo({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 Ej(){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, pick the repos to share, then Skill Studio syncs public repos on Free and private repos on Pro."]})]})}function Nj({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(Kr,{children:"Repository"}),t.jsx(Kr,{align:"right",children:"Skills"}),t.jsx(Kr,{children:"Status"}),t.jsx(Kr,{children:"Last activity"}),t.jsx(Kr,{align:"right",style:{width:48},children:t.jsx("span",{style:{visibility:"hidden"},children:"Actions"})})]})}),t.jsx("tbody",{children:e.map(i=>t.jsx(Tj,{repo:i,pending:r==null?void 0:r[i.repoId],onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a},i.repoId))})]})}function Rj({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(Ij,{repo:i,pending:r==null?void 0:r[i.repoId],onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a},i.repoId))})}function Tj({repo:e,pending:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){const[i,c]=l.useState(!1);return t.jsxs("tr",{"data-testid":`repo-row-${e.repoId}`,style:{borderBottom:"1px solid var(--border-default, #e5e7eb)"},children:[t.jsx(qr,{children:t.jsx(hu,{repo:e})}),t.jsx(qr,{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(qr,{children:t.jsx(mu,{status:e.syncStatus,errorMessage:e.lastErrorMessage})}),t.jsx(qr,{children:t.jsx("span",{style:{color:"var(--text-secondary)"},children:gu(e.lastActivityAt,a)})}),t.jsx(qr,{align:"right",children:t.jsx(xu,{repo:e,pending:r,isOpen:i,onToggle:()=>c(d=>!d),onClose:()=>c(!1),onOpenOnGitHub:n,onResync:s,onDisconnect:o})})]})}function Ij({repo:e,pending:r,onOpenOnGitHub:n,onResync:s,onDisconnect:o,now:a}){const[i,c]=l.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(hu,{repo:e}),t.jsx(xu,{repo:e,pending:r,isOpen:i,onToggle:()=>c(d=>!d),onClose:()=>c(!1),onOpenOnGitHub:n,onResync:s,onDisconnect:o})]}),t.jsx(co,{label:"Skills",children:e.skillsCount===0?"—":String(e.skillsCount)}),t.jsx(co,{label:"Status",children:t.jsx(mu,{status:e.syncStatus,errorMessage:e.lastErrorMessage})}),t.jsx(co,{label:"Last activity",children:gu(e.lastActivityAt,a)})]})}function hu({repo:e}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx(Vo,{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 mu({status:e,errorMessage:r}){const n=bj[e],s=kj[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 co({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:c}){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(uo,{onClick:()=>{a(e),o()},children:"Open on GitHub"}),t.jsx(uo,{disabled:r==="resync",onClick:async()=>{await i(e),o()},children:r==="resync"?"Resyncing…":"Resync now"}),t.jsx(uo,{danger:!0,onClick:async()=>{await c(e),o()},children:"Disconnect"})]})]})}function uo({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 Kr({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 qr({children:e,align:r="left"}){return t.jsx("td",{style:{textAlign:r,padding:"12px 12px",verticalAlign:"middle"},children:e})}function gu(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 c=Math.floor(i/24);if(c<30)return`${c}d ago`;const d=Math.floor(c/30);return d<12?`${d}mo ago`:`${Math.floor(c/365)}y ago`}const po=80,fo=280;function Lj({profile:e,onSubmit:r,saving:n=!1,errorMessage:s=null}){const[o,a]=l.useState(e.displayName),[i,c]=l.useState(e.bio??""),[d,u]=l.useState(e.publicProfile);l.useEffect(()=>{a(e.displayName),c(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>po,h=i.length>fo,m=o.trim().length>0&&!f&&!h;async function y(x){if(x.preventDefault(),!p||!m||n)return;const g={};o!==e.displayName&&(g.displayName=o),i!==(e.bio??"")&&(g.bio=i||null),d!==e.publicProfile&&(g.publicProfile=d),await r(g)}return t.jsxs("form",{"data-testid":"profile-form",onSubmit:y,style:{display:"flex",flexDirection:"column",gap:18,maxWidth:560,fontFamily:"var(--font-sans)"},children:[t.jsx(Aj,{profile:e}),t.jsxs(ho,{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:po+20,disabled:n,onChange:x=>a(x.target.value),style:mo}),t.jsx(vl,{current:o.length,max:po})]}),t.jsx(ho,{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:{...mo,background:"var(--bg-canvas, #f3f4f6)"}})}),t.jsxs(ho,{label:"Public bio",htmlFor:"profile-bio",children:[t.jsx("textarea",{id:"profile-bio","data-testid":"profile-bio",value:i,maxLength:fo+40,rows:3,disabled:n,onChange:x=>c(x.target.value),style:{...mo,fontFamily:"inherit",resize:"vertical"}}),t.jsx(vl,{current:i.length,max:fo})]}),t.jsx(Pj,{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 Aj({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 ho({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 vl({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 Pj({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 mo={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"},$j={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 Mj({tier:e,onUpgradeClick:r,showUpgradeCta:n=!0}){const s=$j[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 Dj=[{value:30,label:"30 days"},{value:90,label:"90 days"},{value:365,label:"1 year"},{value:0,label:"Never"}];function Fj({tokens:e,recentlyCreated:r,onDismissRecentlyCreated:n,onCreate:s,onRevoke:o,pendingRevokeId:a,creating:i=!1,now:c=new Date}){const[d,u]=l.useState(!1),[p,f]=l.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(zj,{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(wr,{children:"Name"}),t.jsx(wr,{children:"Prefix"}),t.jsx(wr,{children:"Scopes"}),t.jsx(wr,{children:"Last used"}),t.jsx(wr,{children:"Created"}),t.jsx(wr,{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(Sr,{children:h.name}),t.jsx(Sr,{children:t.jsxs("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)"},children:[h.prefix,"…"]})}),t.jsx(Sr,{children:h.scopes.join(", ")}),t.jsx(Sr,{children:kl(h.lastUsedAt,c)}),t.jsx(Sr,{children:kl(h.createdAt,c)}),t.jsx(Sr,{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(Bj,{creating:i,onCancel:()=>u(!1),onSubmit:async h=>{await s(h),u(!1)}}),r&&t.jsx(_j,{created:r,onDismiss:()=>n==null?void 0:n()}),p&&t.jsx(Oj,{token:p,pending:a===p.id,onCancel:()=>f(null),onConfirm:async()=>{await o(p),f(null)}})]})}function zj({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 Bj({creating:e,onCancel:r,onSubmit:n}){const[s,o]=l.useState(""),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,p]=l.useState(90),f=s.trim().length>0&&(a||c);return t.jsxs(va,{title:"Generate new token",onDismiss:r,testId:"tokens-generate-modal",children:[t.jsx(xo,{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:jl})}),t.jsx(xo,{label:"Scopes",children:t.jsxs("div",{style:{display:"flex",gap:16},children:[t.jsx(bl,{label:"read",checked:a,disabled:e,onChange:i,testId:"scope-read"}),t.jsx(bl,{label:"write",checked:c,disabled:e,onChange:d,testId:"scope-write"})]})}),t.jsx(xo,{label:"Expiry",children:t.jsx("select",{"data-testid":"token-expiry-select",value:u,disabled:e,onChange:h=>p(Number(h.target.value)),style:jl,children:Dj.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value))})}),t.jsxs(ba,{children:[t.jsx(ka,{onClick:r,disabled:e,children:"Cancel"}),t.jsx(yu,{disabled:!f||e,onClick:()=>{const h=[];a&&h.push("read"),c&&h.push("write"),n({name:s.trim(),scopes:h,expiresInDays:u})},children:e?"Generating…":"Generate"})]})]})}function _j({created:e,onDismiss:r}){const[n,s]=l.useState(!1);async function o(){try{await navigator.clipboard.writeText(e.plaintext),s(!0)}catch{}}return t.jsxs(va,{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(ba,{children:[t.jsx(ka,{onClick:o,children:n?"Copied!":"Copy to clipboard"}),t.jsx(yu,{onClick:r,children:"Done"})]})]})}function Oj({token:e,pending:r,onCancel:n,onConfirm:s}){return t.jsxs(va,{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(ba,{children:[t.jsx(ka,{onClick:n,disabled:r,children:"Cancel"}),t.jsx(Wj,{disabled:r,onClick:()=>void s(),children:r?"Revoking…":"Revoke"})]})]})}function va({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 ba({children:e}){return t.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:e})}function yu({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 ka({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 Wj({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 xo({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 bl({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 wr({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 Sr({children:e,align:r="left"}){return t.jsx("td",{style:{textAlign:r,padding:"12px 12px",verticalAlign:"middle"},children:e})}function kl(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 c=Math.floor(i/30);return c<12?`${c}mo ago`:`${Math.floor(i/365)}y ago`}const jl={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"},Uj=[{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 Hj({prefs:e,onSubmit:r,saving:n=!1,errorMessage:s=null}){const[o,a]=l.useState(()=>wl(e));l.useEffect(()=>{a(wl(e))},[e]);const i=o.weeklyDigest!==e.weeklyDigest||o.commentReplies!==e.commentReplies||o.productUpdates!==e.productUpdates;function c(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:Uj.map(u=>t.jsx(Vj,{meta:u,checked:u.forcedOn?!0:!!o[u.key],disabled:n||!!u.forcedOn,onChange:p=>{u.key!=="securityAlerts"&&c(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 Vj({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 wl(e){return{weeklyDigest:!!e.weeklyDigest,securityAlerts:!0,commentReplies:e.commentReplies??!0,productUpdates:!!e.productUpdates}}function Gj({githubHandle:e,exports:r=[],onSignOutAll:n,onExportRequest:s,onDeleteAccount:o,pending:a,errorMessage:i=null}){const[c,d]=l.useState(!1),[u,p]=l.useState(!1);return t.jsxs("div",{"data-testid":"danger-zone",style:{display:"flex",flexDirection:"column",gap:14,fontFamily:"var(--font-sans)"},children:[t.jsx(go,{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(go,{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(Kj,{exports:r})}),t.jsx(go,{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}),c&&t.jsx(qj,{pending:!!(a!=null&&a.signOutAll),onCancel:()=>d(!1),onConfirm:async()=>{await n(),d(!1)}}),u&&t.jsx(Yj,{githubHandle:e,pending:!!(a!=null&&a.deleteAccount),onCancel:()=>p(!1),onConfirm:async f=>{await o(f),p(!1)}})]})}function go({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 Kj({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:yo,children:"Requested"}),t.jsx("th",{style:yo,children:"Status"}),t.jsx("th",{style:yo,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:vo,children:new Date(r.requestedAt).toLocaleString()}),t.jsx("td",{style:vo,children:r.status}),t.jsx("td",{style:vo,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 qj({pending:e,onCancel:r,onConfirm:n}){return t.jsxs(vu,{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(bu,{children:[t.jsx(ku,{onClick:r,disabled:e,children:"Cancel"}),t.jsx(ju,{disabled:e,onClick:()=>void n(),children:e?"Signing out…":"Sign out everywhere"})]})]})}function Yj({githubHandle:e,pending:r,onCancel:n,onConfirm:s}){const[o,a]=l.useState(""),i=o.trim()===e;return t.jsxs(vu,{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:c=>a(c.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(bu,{children:[t.jsx(ku,{onClick:n,disabled:r,children:"Cancel"}),t.jsx(ju,{disabled:!i||r,onClick:()=>void s(o.trim()),children:r?"Deleting…":"Delete account"})]})]})}function vu({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 bu({children:e}){return t.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:e})}function ku({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 ju({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 yo={textAlign:"left",padding:"8px 10px",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-secondary)"},vo={padding:"8px 10px",color:"var(--text-primary)"},Jj="/api/v1/submissions/stream?mine=1",bo=new Set([...ls,...Zo]);function Xj(e){return!!e&&typeof e=="object"&&typeof e.submissionId=="string"&&typeof e.state=="string"}function Qj(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 Zj(e){return ls.has(e)?"#22C55E":Zo.has(e)?"#EF4444":"#F59E0B"}function ew({openStream:e=ou,notify:r=Jl}={}){const[n,s]=l.useState([]),[o,a]=l.useState({}),[i,c]=l.useState(!0),[d,u]=l.useState(null),[p,f]=l.useState(!1),h=l.useRef(new Set),m=l.useRef(!0),y=l.useCallback(async()=>{c(!0),u(null);try{const g=await ce.getMyQueue();if(!m.current)return;const b=g.submissions??[];s(b),a(g.queuePositions??{}),h.current=new Set(b.map(v=>v.id));for(const v of b)bo.has(v.state)&&Lf(v.id,v.state)}catch(g){if(!m.current)return;u(g instanceof Error?g.message:String(g))}finally{m.current&&c(!1)}},[]),x=l.useCallback(g=>{h.current.has(g.submissionId)&&(s(b=>{let v=!1;const k=b.map(E=>E.id!==g.submissionId?E:(v=!0,{...E,state:g.state,skillName:g.skillName||E.skillName,updatedAt:g.timestamp||E.updatedAt}));return v?k:b}),bo.has(g.state)&&(a(b=>{if(!(g.submissionId in b))return b;const v={...b};return delete v[g.submissionId],v}),Yl(g.submissionId,g.state)&&r(g.submissionId,g.skillName,g.state)))},[r]);return l.useEffect(()=>(m.current=!0,y(),()=>{m.current=!1}),[y]),l.useEffect(()=>{let g=null,b=null,v=0,k=!1;const E=()=>{k||(g=e(Jj,{timeoutMs:6e5,onEvent:T=>{if(k||(f(!0),v=0,!T.data||T.data==="connected"||T.data==="keepalive"))return;let w;try{w=JSON.parse(T.data)}catch{return}Xj(w)&&x(w)},onError:()=>{k||(f(!1),j())},onClose:()=>{k||(f(!1),j())}}))},j=()=>{if(k||b!=null)return;const T=Math.min(1e3*2**v,3e4);v+=1,b=setTimeout(()=>{if(b=null,!k){try{g==null||g.close()}catch{}E()}},T)};return E(),()=>{k=!0,b!=null&&clearTimeout(b);try{g==null||g.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 y(),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(g=>{const b=o[g.id],v=bo.has(g.state);return t.jsxs("tr",{"data-testid":`queue-row-${g.id}`,"data-state":g.state,style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[t.jsx("td",{style:{padding:"6px 8px",fontWeight:600},children:g.skillName}),t.jsx("td",{style:{padding:"6px 8px"},children:t.jsx("span",{"data-testid":`queue-state-${g.id}`,style:{color:Zj(g.state)},children:g.state})}),t.jsx("td",{style:{padding:"6px 8px",fontVariantNumeric:"tabular-nums"},"data-testid":`queue-position-${g.id}`,children:v||b==null?"—":`#${b}`}),t.jsx("td",{style:{padding:"6px 8px",color:"#9CA3AF",fontVariantNumeric:"tabular-nums"},children:Qj(g.updatedAt)})]},g.id)})})]})]})}const tw=[{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 rw({initialTab:e="profile",online:r=!0,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o}){const[a,i]=l.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(nw,{}),!r&&t.jsx(sw,{}),t.jsxs("div",{style:{display:"flex",flex:1,minHeight:0},children:[t.jsx(ow,{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(aw,{tab:a,online:r,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o})})]})]})}function nw(){const{data:e}=bn();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 sw(){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 ow({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:tw.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 aw({tab:e,online:r,onConnectRepo:n,onOpenRepoOnGitHub:s,onUpgradeClick:o}){switch(e){case"profile":return t.jsx(iw,{});case"billing":return t.jsx(lw,{onUpgradeClick:o});case"repos":return t.jsx(cw,{online:r,onConnectRepo:n,onOpenRepoOnGitHub:s});case"skills":return t.jsx(dw,{});case"queue":return t.jsx(uw,{});case"tokens":return t.jsx(pw,{});case"notifications":return t.jsx(hw,{});case"danger":return t.jsx(mw,{});default:return null}}function iw(){const{data:e,loading:r,error:n}=bn(),s=Yc(),[o,a]=l.useState(!1),[i,c]=l.useState(null);return r||!e?t.jsx(br,{error:n}):t.jsx(Lj,{profile:e,saving:o,errorMessage:i,onSubmit:async d=>{a(!0),c(null);try{await s(d)}catch(u){c(u instanceof Error?u.message:String(u))}finally{a(!1)}}})}function lw({onUpgradeClick:e}){const{data:r,loading:n,error:s}=bn();return n||!r?t.jsx(br,{error:s}):t.jsx(Mj,{tier:r.tier,onUpgradeClick:e})}function cw({online:e,onConnectRepo:r,onOpenRepoOnGitHub:n}){const{data:s,loading:o,error:a}=ms(),i=Jc(),c=Xc(),[d,u]=l.useState({});return o&&!s?t.jsx(br,{error:a}):t.jsx(jj,{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 c(p.repoId)}finally{u(f=>{const h={...f};return delete h[p.repoId],h})}}}})}function dw(){const{skills:e}=jg();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(Sl,{label:"Public skills",value:e.data.publicCount}),t.jsx(Sl,{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(br,{error:e.error})}function Sl({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 uw(){return t.jsx("section",{"data-testid":"account-queue-tab",style:{display:"flex",flexDirection:"column",gap:12},children:t.jsx(ew,{})})}function pw(){const{data:e,loading:r,error:n}=Qc(),s=Zc(),o=ed(),[a,i]=l.useState(!1),[c,d]=l.useState(null),[u,p]=l.useState(null);return r&&!e?t.jsx(br,{error:n}):n&&!e?t.jsx(fw,{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(Fj,{tokens:e??[],creating:a,pendingRevokeId:c,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 fw({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 hw(){const{data:e,loading:r,error:n}=td(),s=rd(),[o,a]=l.useState(!1),[i,c]=l.useState(null);return r||!e?t.jsx(br,{error:n}):t.jsx(Hj,{prefs:e,saving:o,errorMessage:i,onSubmit:async d=>{a(!0),c(null);try{await s(d)}catch(u){c(u instanceof Error?u.message:String(u))}finally{a(!1)}}})}function mw(){const{data:e}=bn(),{data:r}=nd(),n=sd(),s=od(),o=ad(),[a,i]=l.useState({}),[c,d]=l.useState(null);return e?t.jsx(Gj,{githubHandle:e.githubHandle,exports:r??[],pending:a,errorMessage:c,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(br,{})}function br({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 xw=l.lazy(()=>ar(()=>import("./FindSkillsPalette-D_qkIke-.js"),__vite__mapDeps([8,5,3,4])).then(e=>({default:e.FindSkillsPalette})));Tf();const gw=l.lazy(()=>ar(()=>import("./SkillDetailPanel-DMkcBtBv.js"),__vite__mapDeps([9,3,4,10,5,6])).then(e=>({default:e.SkillDetailPanel}))),yw=l.lazy(()=>ar(()=>import("./CreateSkillPage-DXOVLzCp.js"),__vite__mapDeps([11,3,4,5,6])).then(e=>({default:e.CreateSkillPage}))),vw=l.lazy(()=>ar(()=>Promise.resolve().then(()=>m1),void 0).then(e=>({default:e.UpdatesPanel})));function bw(){return t.jsx(lh,{children:t.jsx(rv,{children:t.jsx(oh,{children:t.jsx(om,{children:t.jsx(kw,{children:t.jsxs(y0,{children:[t.jsx(jw,{}),t.jsx(h0,{})]})})})})})})}function kw({children:e}){const[r,n]=l.useState(void 0);return l.useEffect(()=>{let s=!1;if(Zl())return eh().then(o=>{s||n(o)}),()=>{s=!0}},[]),t.jsx(gg,{value:r,children:e})}function jw(){var wa,Sa;const{state:e,selectSkill:r,clearSelection:n,refreshSkills:s,outdatedByOrigin:o,revealSkill:a,clearReveal:i}=It(),{config:c}=gr(),{resolvedTheme:d,setTheme:u}=dc(),{toast:p}=cs(),[f,h]=l.useState(()=>gy()),[m]=l.useState(!0),[y,x]=l.useState(!1),[g,b]=l.useState(!1),[v,k]=l.useState(!1),[E,j]=l.useState(()=>typeof window>"u"?"overview":Uo(window.location.search).tab),[T,w]=l.useState(()=>{if(typeof window>"u")return"";const z=Uo(window.location.search);return z.mode?z.mode:z.view?z.view:ru(z.tab,window.location.search)}),S=l.useCallback(z=>{j(ae=>(ae!==z&&w(nn(z)),z))},[]);l.useEffect(()=>{if(typeof window>"u")return;const z=()=>{const ae=new URLSearchParams(window.location.search),ie=ae.get("tab"),at=ae.get("panel"),_e=ns(ie)??ns(at);if(!_e)return;const Ft=new URLSearchParams(window.location.search);Ft.delete("panel"),Ft.delete("sub"),_e.tab==="overview"?Ft.delete("tab"):Ft.set("tab",_e.tab),Ft.delete("mode"),Ft.delete("view"),_e.mode&&Ft.set("mode",_e.mode),_e.view&&Ft.set("view",_e.view);const Pt=Ft.toString(),Ca=`${window.location.pathname}${Pt?"?"+Pt:""}${window.location.hash}`,wu=`${window.location.pathname}${window.location.search}${window.location.hash}`;Ca!==wu&&window.history.replaceState(null,"",Ca),j(_e.tab),_e.mode?w(_e.mode):_e.view?w(_e.view):w(nn(_e.tab))};return z(),window.addEventListener("popstate",z),()=>window.removeEventListener("popstate",z)},[]),l.useEffect(()=>{if(typeof window>"u")return;const z=new URLSearchParams(window.location.search);z.delete("panel"),z.delete("sub"),E==="overview"?z.delete("tab"):z.set("tab",E),z.delete("mode"),z.delete("view"),!(T===nn(E))&&T&&(E==="run"?z.set("mode",T):E==="history"&&z.set("view",T));const ie=z.toString(),at=`${window.location.pathname}${ie?"?"+ie:""}${window.location.hash}`,_e=`${window.location.pathname}${window.location.search}${window.location.hash}`;at!==_e&&window.history.replaceState(null,"",at)},[E,T]);const[N,R]=l.useState(ml),I=l.useCallback((z,ae)=>{R(Zk(z,ae))},[]),A=hk(),[$,B]=l.useState(()=>Qk("activeAgent",null)),C=l.useCallback(z=>{B(z),Xk("activeAgent",z),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:z}}))},[]);l.useEffect(()=>{var z;!$&&((z=A.response)!=null&&z.suggested)&&C(A.response.suggested)},[$,(wa=A.response)==null?void 0:wa.suggested,C]);const L=l.useMemo(()=>A.response?lk(A.response):[],[A.response]),{workspace:P,switchProject:M,addProject:H,removeProject:le,activeProject:G}=kk(),[W,Z]=l.useState(!1);l.useEffect(()=>{Y.current=(G==null?void 0:G.path)??null},[G==null?void 0:G.path]);const[he,me]=l.useState(!1),[_,ne]=l.useState("standalone"),[D,U]=l.useState(!1),[K,V]=l.useState(null),Y=l.useRef(null),J=Sd(),te=fn(),de=l.useCallback(z=>{te.openExternalUrl(z).catch(()=>{typeof window<"u"&&window.open(z,"_blank","noopener,noreferrer")})},[te]),se=l.useCallback(async(z="standalone")=>{ne(z),me(!0)},[]);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;se((ie==null?void 0:ie.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",z),()=>window.removeEventListener("studio:request-create-skill",z)},[se]),l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;V(ie!=null&&ie.repoName?{repoName:ie.repoName}:null),U(!0)}return window.addEventListener("studio:request-paywall",z),()=>window.removeEventListener("studio:request-paywall",z)},[]);const[ue,F]=l.useState(!1),[q,re]=l.useState(null),[Q,pe]=l.useState(null);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;!ie||typeof ie.skill!="string"||ie.skill.length===0||pe({skill:ie.skill,skillDisplayName:ie.skillDisplayName,scope:ie.scope==="project"?"project":"user",activeAgentId:ie.activeAgentId,preCheckedAgentIds:ie.preCheckedAgentIds})}return window.addEventListener("studio:open-install-targets-modal",z),()=>window.removeEventListener("studio:open-install-targets-modal",z)},[]);const[xe,we]=l.useState(null);l.useEffect(()=>{function z(){F(!0)}return window.addEventListener("studio:open-marketplace",z),()=>window.removeEventListener("studio:open-marketplace",z)},[]);const ge=l.useMemo(()=>{const z=new Set;for(const ae of e.skills)ae.source==="plugin"&&ae.pluginName&&z.add(ae.pluginName);return z},[e.skills]),{lookup:Ve}=ld(),Ye=l.useMemo(()=>{const z=new Map;for(const ae of e.skills){const ie=kn(ae.repoUrl);if(!ie)continue;const at=Ve.get(ie);if(!at||!at.isPrivate)continue;const _e=ae.pluginName??ae.plugin;z.has(_e)||z.set(_e,{name:_e,repoFullName:at.repoFullName})}return Array.from(z.values())},[e.skills,Ve]);Po([{key:"p",meta:!0,handler:z=>{var ie;const ae=typeof document<"u"?document.activeElement:null;ae&&ae.tagName==="INPUT"||((ie=z==null?void 0:z.preventDefault)==null||ie.call(z),Z(at=>!at))}}],{enabled:!0});const Pe=V0(),rt=Pe.open;l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.provider&&rt(ie.provider)}return window.addEventListener("studio:open-setup-drawer",z),()=>window.removeEventListener("studio:open-setup-drawer",z)},[rt]);const Je=l.useCallback(()=>{R(ml)},[]);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.message&&p({message:ie.message,severity:ie.severity??"info"})}return window.addEventListener("studio:toast",z),()=>window.removeEventListener("studio:toast",z)},[p]),Jk();const[Ie,ee]=l.useState(!1),[Fe,Ke]=l.useState(void 0);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;Ke(ie==null?void 0:ie.provider),ee(!0)}return window.addEventListener("studio:open-settings",z),()=>window.removeEventListener("studio:open-settings",z)},[]),l.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${f}px`)},[f]),l.useEffect(()=>{function z(){s()}return window.addEventListener("studio:content-saved",z),()=>window.removeEventListener("studio:content-saved",z)},[s]);const[$e,nt]=l.useState(null),[it,Ct]=l.useState(()=>new Set),Vt=l.useRef(!1),Et=l.useMemo(()=>Pg(),[]),st=l.useCallback(z=>`${z.plugin}/${z.skill}`,[]),yt=l.useCallback(z=>{Ct(ae=>{const ie=new Set(ae);return ie.add(st(z)),ie})},[st]),vt=l.useCallback(z=>{Ct(ae=>{const ie=new Set(ae);return ie.delete(st(z)),ie})},[st]),Lt=il({delayMs:1e4,onCommit:z=>{s(),vt(z)},onFailure:(z,ae)=>{vt(z),p({message:`Couldn't delete ${z.skill}: ${ae.message}`,severity:"error",durationMs:0,action:{label:O.actions.retry,onInvoke:()=>{yt(z),Lt.enqueueDelete(z)}}})}});l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.skill&&nt(ie.skill)}return window.addEventListener("studio:request-delete",z),()=>window.removeEventListener("studio:request-delete",z)},[]);const[Ne,Se]=l.useState(null);l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.skill&&Se(ie.skill)}return window.addEventListener("studio:request-clone",z),()=>window.removeEventListener("studio:request-clone",z)},[]);const[ze,ot]=l.useState(null),Xt=il({delayMs:250,apiCall:(z,ae)=>api.uninstallSkill(z,ae),onCommit:z=>{s(),vt(z)},onFailure:(z,ae)=>{var ie;if(vt(z),ae instanceof qt&&((ie=ae.details)==null?void 0:ie.code)==="not-installed"){p({message:`${z.skill} is a source-authored skill — use Delete instead`,severity:"info",durationMs:4e3});return}p({message:`Couldn't uninstall ${z.skill}: ${ae.message}`,severity:"error",durationMs:0,action:{label:O.actions.retry,onInvoke:()=>{yt(z),Xt.enqueueDelete(z)}}})}});l.useEffect(()=>{function z(ae){if(!(ae instanceof CustomEvent))return;const ie=ae.detail;ie!=null&&ie.skill&&ot(ie.skill)}return window.addEventListener("studio:request-uninstall",z),()=>window.removeEventListener("studio:request-uninstall",z)},[]);const At=l.useCallback(async z=>{await Promise.all([Lt.flushBySkillName(z),Xt.flushBySkillName(z)])},[Lt,Xt]),ys=l.useMemo(()=>({flushBySkillName:At}),[At]),vs=l.useCallback(()=>{const z=ze;if(ot(null),!z)return;const ae={plugin:z.plugin,skill:z.skill};yt(ae),Xt.enqueueDelete(ae),p({message:`Uninstalled ${z.skill}. Sent to your ${Et}.`,severity:"info",durationMs:4e3})},[ze,yt,Xt,p,Et]),_r=l.useCallback(()=>{ot(null)},[]),Gt=l.useCallback(()=>{const z=$e;if(nt(null),!z)return;const ae={plugin:z.plugin,skill:z.skill};yt(ae),Lt.enqueueDelete(ae);const ie=Vt.current?"":`Sent to your ${Et}. Open Trash to restore. `;Vt.current=!0,p({message:`${ie}Deleted ${z.skill}`,severity:"info",durationMs:1e4,action:{label:O.actions.undo,onInvoke:()=>{Lt.cancelDelete(st(ae)),vt(ae)}}})},[$e,yt,vt,Lt,p,Et,st]),kr=l.useCallback(()=>{nt(null)},[]),Qt=l.useMemo(()=>e.skills.filter(z=>!it.has(st(z))),[e.skills,it,st]),Sn=Cy(Qt,(G==null?void 0:G.path)??null),Xe=l.useMemo(()=>e.selectedSkill?e.skills.find(z=>z.plugin===e.selectedSkill.plugin&&z.skill===e.selectedSkill.skill)??null:null,[e.skills,e.selectedSkill]),Me=l.useRef(null);l.useEffect(()=>{if(!Xe||typeof window>"u"||new URLSearchParams(window.location.search).get("tab")||!(Xe.origin==="installed"))return;const ie=`${Xe.plugin}/${Xe.skill}`;Me.current!==ie&&(Me.current=ie,E==="overview"&&j("source"))},[Xe==null?void 0:Xe.plugin,Xe==null?void 0:Xe.skill,Xe==null?void 0:Xe.origin]);const ur=l.useCallback(z=>{r({plugin:z.plugin,skill:z.skill,origin:z.origin,source:z.source})},[r]),Zt=l.useMemo(()=>{if(!e.selectedSkill)return"";const z=e.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${e.selectedSkill.skill} (${z})`},[e.selectedSkill]),[Cn,lt]=l.useState(null);Po([{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:()=>x(z=>!z)},{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(z=>!z)},{key:"ctrl+b",handler:()=>b(z=>!z)}]);const ja=sj(),er=oj(),bs=v?t.jsx(rw,{online:typeof navigator>"u"?!0:navigator.onLine!==!1,onConnectRepo:()=>{de("https://verified-skill.com/account/repos/connect")},onOpenRepoOnGitHub:de,onUpgradeClick:()=>{de(Cd)}}):er?t.jsx(l.Suspense,{fallback:t.jsx("div",{style:{padding:40},children:"Loading…"}),children:t.jsx(vw,{})}):ja?t.jsx(l.Suspense,{fallback:t.jsx("div",{style:{padding:40},children:"Loading…"}),children:t.jsx(yw,{})}):t.jsx(o0,{selectedSkillInfo:Xe,activeDetailTab:E,onDetailTabChange:S,activeDetailSub:T,onDetailSubChange:w,allSkills:e.skills,onSelectSkill:ur});return t.jsxs(Gd.Provider,{value:ys,children:[t.jsx(ch,{sidebarWidth:f,sidebarHidden:g||e.isMobile&&e.mobileView==="detail",banner:t.jsx(Ey,{connected:m}),liveMessage:Zt,topRail:t.jsx(fm,{projectName:(c==null?void 0:c.projectName)??null,selected:e.selectedSkill,onHome:n,onRequestCreateSkill:()=>se("standalone"),projectPickerSlot:P&&P.projects.length>0?t.jsx(wk,{workspace:P,onSwitch:M,onAdd:H,onRemove:le}):void 0,findSkillsSlot:t.jsx(lj,{}),appUpdateSlot:t.jsx(b0,{}),userDropdownSlot:t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[t.jsx(mj,{}),t.jsx(cj,{})]})}),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(ay,{skills:Qt,selectedKey:e.selectedSkill?{plugin:e.selectedSkill.plugin,skill:e.selectedSkill.skill}:null,onSelect:z=>{k(!1),ur(z)},isLoading:e.skillsLoading,error:e.skillsError??null,onRetry:s,onContextMenu:I,outdatedByOrigin:o,activeAgentId:$,revealSkillId:e.revealSkillId,onRevealComplete:i,dirtySkillIds:Sn,onSkillsChanged:s,topSlot:t.jsxs(t.Fragment,{children:[A.status==="ready"&&L.length>0?t.jsxs(t.Fragment,{children:[t.jsx(ck,{agents:L,activeAgentId:$,onActiveAgentChange:C,onOpenSetup:z=>Pe.open(z)}),t.jsx(fk,{activeAgentId:$})]}):null,G!=null&&G.path?t.jsx(ud,{folder:G.path,tier:J.tier,onUpgradeClick:()=>{try{window.dispatchEvent(new CustomEvent("studio:request-paywall",{detail:{repoName:G.path}}))}catch{}}}):null]})})}),t.jsx("div",{style:{borderTop:"1px solid var(--border-default, rgba(128,128,128,0.25))",padding:"6px 0"},children:t.jsx(vj,{active:v,onClick:()=>k(z=>!z)})})]}),resizeHandle:t.jsx(vy,{initialWidth:f??rn,onChange:h}),main:bs,statusBar:t.jsx(Sm,{projectPath:(c==null?void 0:c.root)??null,modelName:(c==null?void 0:c.model)??null,health:c!=null&&c.error?"degraded":"ok",providers:(Sa=c==null?void 0:c.providers)==null?void 0:Sa.map(z=>{const ae=z.id;return{id:ae,label:z.label,available:z.available,kind:ae==="ollama"||ae==="lm-studio"?"start-service":ae==="anthropic"||ae==="openrouter"?"api-key":"cli-install"}})})}),t.jsx(j0,{open:y,onClose:()=>x(!1)}),t.jsx(B0,{open:Pe.isOpen,providerKey:Pe.providerKey,onClose:Pe.close}),t.jsx(S0,{state:N,onClose:Je,onAction:(z,ae)=>tj(z,ae)}),t.jsx(l.Suspense,{fallback:null,children:t.jsx(xw,{onSelect:z=>{const ae=z.name.split("/");ae.length===3&&lt({owner:ae[0],repo:ae[1],slug:ae[2],displayName:z.displayName??z.name})}})}),Cn&&t.jsx(l.Suspense,{fallback:null,children:t.jsx(gw,{selectedSkill:Cn,activeAgentId:$,onClose:()=>lt(null)})}),t.jsx(Ck,{open:W,projects:(P==null?void 0:P.projects)??[],onSwitch:z=>{M(z)},onClose:()=>Z(!1)}),t.jsx(Ek,{open:he,onClose:()=>me(!1),initialMode:_,isClaudeCode:$==="claude-code",projectRoot:(G==null?void 0:G.path)??(c==null?void 0:c.projectName)??"",onCreated:z=>{s(),setTimeout(()=>{a(z.pluginName??"",z.skillName)},500),te.quotaReportCount(Qt.length+1)}}),t.jsx(Ik,{open:ue,onClose:()=>F(!1),installedNames:ge,privatePlugins:Ye,onInstall:(z,ae)=>{re({plugin:z,marketplace:ae,ref:`${z}@${ae}`}),F(!1)},onUninstall:async z=>{if(await new Promise(ie=>{we({plugin:z,resolve:ie})}))try{const ie=await fetch(`/api/plugins/${encodeURIComponent(z)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),at=await ie.json().catch(()=>({}));if(!ie.ok||!at.ok){p({message:at.error??`Uninstall failed (${ie.status})`,severity:"error"});return}const _e=at.fallback==="orphan-cache-removed"?`Removed orphaned ${z}.`:`Uninstalled ${z}.`;p({message:_e,severity:"success"}),s()}catch(ie){p({message:ie instanceof Error?ie.message:String(ie),severity:"error"})}}}),t.jsx(ac,{open:Ie,onClose:()=>ee(!1),initialProvider:Fe,onToast:z=>p({message:z,severity:"info"})}),t.jsx(Mk,{job:q,onDone:z=>{z.ok&&(s(),setTimeout(()=>re(null),3e3))}}),Q&&t.jsx(Vk,{skill:Q.skill,skillDisplayName:Q.skillDisplayName,scope:Q.scope,activeAgentId:Q.activeAgentId===void 0?$:Q.activeAgentId,preCheckedAgentIds:Q.preCheckedAgentIds,onClose:()=>pe(null),onSuccess:z=>{s();const ae=z.filter(Pt=>Pt.status==="installed").length,ie=z.filter(Pt=>Pt.status==="exported").length,at=z.find(Pt=>Pt.status==="error"),_e=Q.skillDisplayName??Q.skill;at?p({message:at.detail||`Could not install ${_e}.`,severity:"error"}):ie>0?p({message:`Installed ${_e}; ${ie} target${ie===1?"":"s"} need paste.`,severity:"info"}):ae>0&&p({message:`Installed ${_e} to ${ae} target${ae===1?"":"s"}.`,severity:"success"}),z.some(Pt=>Pt.status==="error"||Pt.status==="exported")||pe(null)}}),t.jsx(qn,{open:$e!==null,title:$e?`Delete "${$e.skill}"?`:"",body:`It will be sent to your ${Et}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Gt,onCancel:kr}),t.jsx(qn,{open:ze!==null,title:ze?`Uninstall "${ze.skill}"?`:"",body:`It will be sent to your ${Et} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:vs,onCancel:_r}),t.jsx(qn,{open:xe!==null,title:xe?`Uninstall ${xe.plugin}?`:"",body:xe?`This removes the ${xe.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{xe==null||xe.resolve(!0),we(null)},onCancel:()=>{xe==null||xe.resolve(!1),we(null)}}),t.jsx(Ed,{open:D,skillName:(K==null?void 0:K.repoName)??void 0,onClose:()=>{U(!1),V(null)},onProceed:()=>{V(null)}}),Ne&&t.jsx(E0,{skill:Ne,onCloned:z=>{p({message:O.toasts.cloneSucceeded,severity:"info"}),Se(null);try{window.dispatchEvent(new CustomEvent("studio:skills-changed",{detail:z}))}catch{}s()},onCancel:()=>Se(null)})]})}const Cl="vskill.migrations.scope-rename.v1",ww={own:"authoring-project",installed:"available-project",global:"available-personal"},Sw=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function Cw(e){if(e.getItem(Cl)==="done")return;const r=[];for(let n=0;n<e.length;n++){const s=e.key(n);if(!s)continue;const o=s.match(Sw);if(!o)continue;const[,a,i]=o,c=ww[i];if(!c)continue;const d=e.getItem(s);d!==null&&r.push({oldKey:s,newKey:`vskill-sidebar-${a}-${c}-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(Cl,"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{Cw(window.localStorage)}catch{}Eu.createRoot(document.getElementById("root")).render(t.jsx(l.StrictMode,{children:t.jsx(Kp,{children:t.jsx(vm,{children:t.jsx(bw,{})})})}));export{gs as E,Vk as I,Wl as L,wn as P,u1 as S,Tw as T,ce as a,It as b,l1 as c,a1 as d,jn as e,cs as f,Qk as g,Vd as h,ou as o,pu as r,Rr as t,gr as u,Xk as w};