vskill 0.5.147 → 0.5.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents.json +1 -1
- package/dist/eval-ui/assets/{CommandPalette-B8LrurKZ.js → CommandPalette-Blw7hYAt.js} +1 -1
- package/dist/eval-ui/assets/{CreateSkillPage-BLare8vh.js → CreateSkillPage-7StSKG-p.js} +1 -1
- package/dist/eval-ui/assets/{FindSkillsPalette-Cqg3Q3ba.js → FindSkillsPalette-DO65wBaE.js} +2 -2
- package/dist/eval-ui/assets/{SearchPaletteCore-BsdvjlSP.js → SearchPaletteCore-lW3fmDF8.js} +1 -1
- package/dist/eval-ui/assets/{SkillDetailPanel-BaJNm33W.js → SkillDetailPanel-DnDhg7z9.js} +1 -1
- package/dist/eval-ui/assets/{UpdateDropdown-DI7OhaV-.js → UpdateDropdown-DSgTqcY2.js} +1 -1
- package/dist/eval-ui/assets/{index-7xEjXp20.js → index-BaSdAiau.js} +4 -4
- package/dist/eval-ui/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-DSgTqcY2.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-Blw7hYAt.js","assets/FindSkillsPalette-DO65wBaE.js","assets/SkillDetailPanel-DnDhg7z9.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-7StSKG-p.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
/* empty css */(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))i(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function Nv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yd={exports:{}},Ds={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -62,7 +62,7 @@ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}
|
|
|
62
62
|
`);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let E={};try{E=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const C={type:h,...E};a==null||a(C),C.type==="done"&&(x=C),C.type==="error"&&(m=C)}h=""}}if(m){const y=new _l(m.message,500);throw y.code=m.code,y}if(!x)throw new _l("Transfer stream ended without 'done' event",500);return x}function TS(t,a){if(!t||!a)return!1;const s=/^(\d+)\.(\d+)\.(\d+)/,i=t.match(s),c=a.match(s);if(!i||!c)return!1;const[,u,d,h]=i.map(Number),[,x,m,y]=c.map(Number);return u!==x?u>x:d!==m?d>m:h>=y}function RS(t,a){if(!a.length)return t;const s=new Map,i=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(i.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=i.get(c.skill),!u)return c;const d=u.updateAvailable&&!TS(c.version,u.latest),h={...c,updateAvailable:d,currentVersion:u.installed,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(h.trackedForUpdates=u.trackedForUpdates);const x=qv({frontmatterVersion:h.version??null,registryCurrentVersion:h.currentVersion??null,pluginVersion:h.pluginVersion??null,installedCurrentVersion:h.currentVersion??null,preferInstalled:!0});return h.resolvedVersion=x.version,h.versionSource=x.versionSource,h})}const $o=new Map,Ua=new Map,Hs=new Map;function On(t){$o.delete(t),Ua.delete(t);const a=Hs.get(t);if(a)for(const s of a)s()}function Ga(t,a,s={}){const{ttl:i=3e4,enabled:c=!0}=s,[,u]=p.useState(0),[d,h]=p.useState(void 0),[x,m]=p.useState(0),y=p.useRef(!0),v=p.useRef(t);v.current=t;const b=()=>{h(void 0),On(t),m(C=>C+1)};p.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]),p.useEffect(()=>{if(!c)return;const C=()=>{y.current&&m(k=>k+1)};return Hs.has(t)||Hs.set(t,new Set),Hs.get(t).add(C),()=>{var k;(k=Hs.get(t))==null||k.delete(C)}},[t,c]),p.useEffect(()=>{if(!c)return;const C=$o.get(t);if(!(!C||Date.now()-C.fetchedAt>i))return;if(Ua.has(t)){const M=Ua.get(t),_=()=>{y.current&&v.current===t&&u(D=>D+1)};M.subscribers.push(_);return}const N={promise:Promise.resolve(),subscribers:[]},T=a().then(M=>{$o.set(t,{data:M,fetchedAt:Date.now()}),Ua.delete(t),y.current&&v.current===t&&(h(void 0),u(_=>_+1));for(const _ of N.subscribers)_()},M=>{Ua.delete(t);const _=M instanceof Error?M:new Error(String(M));y.current&&v.current===t&&(h(_),u(D=>D+1));for(const D of N.subscribers)D()});N.promise=T,Ua.set(t,N)},[t,a,i,c,x]);const S=$o.get(t),E=c&&!S&&!d&&Ua.has(t);return{data:S==null?void 0:S.data,loading:E,error:d,revalidate:b}}function AS(t){const[a,s]=p.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return p.useEffect(()=>{const i=window.matchMedia(t);s(i.matches);const c=u=>s(u.matches);return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[t]),a}const MS=500,sf="vskill.updates.seenLastId";function LS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(sf)}catch{return null}}function Ad(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(sf):window.localStorage.setItem(sf,t)}catch{}}function zS(){let t=new Map;const a=new Set,s=new Set,i=[];let c=LS();c&&(s.add(c),i.push(c));function u(){t=new Map(t);for(const h of Array.from(a))h()}function d(h){if(!s.has(h)){if(s.add(h),i.push(h),i.length>MS){const x=i.shift();x&&s.delete(x)}c=h,Ad(h)}}return{getSnapshot(){return t},subscribe(h){return a.add(h),()=>{a.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),i.length=0,c=null,Ad(null)},mergeBulk(h){if(h.length!==0){for(const x of h)t.set(x.skillId,x);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),i.length=0,c=null,Ad(null),u()}}}const Ia=zS(),DS=3e5,_S=500,OS=15e3,BS=6e4,IS=6e4,$S="/api/v1/skills/stream";function rg(t){const a=new Map;for(const s of t){const i=s.name.split("/").pop()||s.name;a.set(i,s)}return a}function ag(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function US(t){if(!t||typeof t!="object")return!1;const a=t;return a.type==="skill.updated"&&typeof a.eventId=="string"&&typeof a.skillId=="string"&&typeof a.version=="string"}function HS(t){const a=(t==null?void 0:t.intervalMs)??DS,s=(t==null?void 0:t.debounceMs)??_S,i=(t==null?void 0:t.timeoutMs)??OS,c=(t==null?void 0:t.staleAfterMs)??BS,u=(t==null?void 0:t.disconnectFallbackMs)??IS,d=(t==null?void 0:t.streamUrlBase)??$S,h=p.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),x=p.useMemo(()=>{const L=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return L.length===0?"":[...L].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[m,y]=p.useState([]),[v,b]=p.useState(()=>new Map),[S,E]=p.useState(0),[C,k]=p.useState(!1),[N,T]=p.useState(null),[M,_]=p.useState(null),D=p.useRef(null),V=p.useRef(null),w=p.useRef(null),B=p.useRef(null),z=p.useRef(!0),[O,$]=p.useState(()=>h?"connecting":"fallback"),Y=p.useRef(O);Y.current=O;const X=p.useSyncExternalStore(L=>Ia.subscribe(L),()=>Ia.getSnapshot(),()=>Ia.getSnapshot()),ne=X.size,H=p.useCallback(async()=>{k(!0);const L=new AbortController,W=setTimeout(()=>L.abort(),i);try{const ee=await Promise.race([Se.getSkillUpdates(),new Promise((q,oe)=>{L.signal.addEventListener("abort",()=>{oe(new Error("TIMEOUT"))})})]);if(ee==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(ee),b(rg(ee)),E(ag(ee)),V.current=Date.now(),T(V.current),_(null)}catch(ee){if(!z.current)return;_(ee instanceof Error?ee:new Error(String(ee)))}finally{clearTimeout(W),z.current&&k(!1)}},[i]),A=p.useCallback(()=>{if(D.current)return D.current;const L=H().finally(()=>{D.current=null});return D.current=L,L},[H]),I=p.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{A()},a))},[a,A]),G=p.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);p.useEffect(()=>{z.current=!0,(V.current==null||Date.now()-V.current>c)&&A(),(typeof document>"u"||document.visibilityState!=="hidden")&&I();const ee=()=>{if(B.current&&(clearTimeout(B.current),B.current=null),document.visibilityState==="hidden"){G();return}B.current=setTimeout(()=>{B.current=null,(V.current==null||Date.now()-V.current>c)&&A(),I()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",ee),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",ee),B.current&&clearTimeout(B.current),G()}},[]);const U=p.useCallback(async L=>{if(L.length!==0)try{const W=await Se.checkSkillUpdates(L);if(!z.current||W.length===0)return;const ee=Date.now(),q=W.filter(Q=>Q.skillId&&Q.eventId&&Q.version).map(Q=>({skillId:Q.skillId,version:Q.version,eventId:Q.eventId,publishedAt:Q.publishedAt,diffSummary:Q.diffSummary,receivedAt:ee}));q.length>0&&Ia.mergeBulk(q);const oe=W.filter(Q=>typeof Q.trackedForUpdates=="boolean"||typeof Q.updateAvailable=="boolean").map(Q=>({name:Q.name??Q.skillId,installed:Q.installed??"",latest:Q.latest??null,updateAvailable:Q.updateAvailable??!1,trackedForUpdates:typeof Q.trackedForUpdates=="boolean"?Q.trackedForUpdates:void 0}));oe.length>0&&y(Q=>{const ye=new Map;for(const Me of Q)ye.set(Me.name.split("/").pop()||Me.name,Me);let ce=0;for(const Me of oe){const Ae=Me.name.split("/").pop()||Me.name,ze=ye.get(Ae);if(ze){const Ge={...ze};ze.trackedForUpdates===void 0&&Me.trackedForUpdates!==void 0&&(Ge.trackedForUpdates=Me.trackedForUpdates),ye.set(Ae,Ge)}else ye.set(Ae,{name:Me.name,installed:Me.installed??"",latest:Me.latest??null,updateAvailable:Me.updateAvailable??!1,trackedForUpdates:Me.trackedForUpdates}),ce+=1}if(ce===0&&ye.size===Q.length)return Q;const je=[...ye.values()];return b(rg(je)),E(ag(je)),je})}catch{}},[]);p.useEffect(()=>{const L=h||x;if(!L){$("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){$("fallback");return}$("connecting");const W=L.split(","),ee=`${d}?skills=${encodeURIComponent(L)}`;let q=null,oe=null,Q=null;const ye=()=>{oe==null&&(oe=setTimeout(()=>{oe=null,z.current&&Y.current!=="connected"&&$("fallback")},u))},ce=()=>{oe!=null&&(clearTimeout(oe),oe=null)};ye();const je=1e3,Me=()=>{z.current&&Q==null&&(Q=setTimeout(()=>{if(Q=null,!!z.current&&!(q&&q.readyState!==EventSource.CLOSED)){if(q)try{q.close()}catch{}Ge()}},je))},Ae=se=>{if(!z.current)return;let de;try{de=JSON.parse(se.data)}catch{return}if(!US(de)||Ia.ingest(de)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const be=`${de.skillId} updated to ${de.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:be,severity:"info",skillId:de.skillId,version:de.version,eventId:de.eventId}}))}},ze=()=>{z.current&&(Ia.clearSeen(),U(W))},Ge=()=>{z.current&&(q=new EventSource(ee),q.onopen=()=>{z.current&&(ce(),$("connected"))},q.onerror=()=>{z.current&&(ye(),q&&q.readyState===EventSource.CLOSED&&Me())},q.onmessage=Ae,q.addEventListener("gone",ze))};return Ge(),()=>{if(ce(),Q!=null&&(clearTimeout(Q),Q=null),q){try{q.removeEventListener("gone",ze)}catch{}try{q.close()}catch{}}}},[h,x,d,u,U]),p.useEffect(()=>{if(!x)return;const L=x.split(",");U(L)},[x,U]);const ae=p.useCallback(L=>{Ia.dismiss(L)},[]);return{updates:m,updatesMap:v,updateCount:S,isRefreshing:C,lastFetchAt:N,error:M,refresh:A,updatesById:X,pushUpdateCount:ne,status:O,dismiss:ae}}function PS(t){const a=[];for(const s of t){const i=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!i&&!c)continue;const u={};i&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const VS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function FS(t,a){switch(a.type){case"SELECT_SKILL":return{...t,selectedSkill:a.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:a.mode,selectedSkill:a.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:a.query};case"SET_SKILLS":return{...t,skills:a.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:a.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:a.loading};case"SET_MOBILE":return{...t,isMobile:a.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:a.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:a.skill,revealSkillId:`${a.skill.plugin}/${a.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Yv=p.createContext(null),Kv=Yv;function ir(){const t=p.useContext(Kv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function GS({children:t}){const[a,s]=p.useReducer(FS,VS),i=AS("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=p.useState(()=>{try{const U=window.localStorage.getItem("vskill.studio.prefs");if(!U)return null;const ae=JSON.parse(U);return typeof ae.activeAgent=="string"?ae.activeAgent:null}catch{return null}}),[d,h]=p.useState(c!==null);p.useEffect(()=>{function U(ae){if(!(ae instanceof CustomEvent))return;const L=ae.detail;L!=null&&L.agentId&&(u(L.agentId),h(!0))}return window.addEventListener("studio:agent-changed",U),()=>window.removeEventListener("studio:agent-changed",U)},[]),p.useEffect(()=>{if(d)return;let U=!1;return Se.getAgents().then(ae=>{if(U)return;const L=(ae==null?void 0:ae.suggested)??"claude-code";u(W=>W??L),h(!0)}).catch(()=>{U||(u(ae=>ae??"claude-code"),h(!0))}),()=>{U=!0}},[d]);const x=p.useCallback(()=>{if(!d||!c)return Promise.resolve();s({type:"SET_SKILLS_LOADING",loading:!0});const U={agent:c};return Se.getSkills(U).then(ae=>{s({type:"SET_SKILLS",skills:ae});const W=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(W){const[,ee,q]=W,oe=ae.find(Q=>Q.plugin===ee&&Q.skill===q);oe&&s({type:"SELECT_SKILL",skill:{plugin:ee,skill:q,origin:oe.origin}})}}).catch(ae=>s({type:"SET_SKILLS_ERROR",error:ae.message}))},[c,d]);p.useEffect(()=>{x()},[x]);const m=p.useCallback(U=>{s({type:"SELECT_SKILL",skill:U}),window.location.hash=`/skills/${U.plugin}/${U.skill}`},[]),y=p.useRef(a.skills);p.useEffect(()=>{y.current=a.skills},[a.skills]);const v=p.useCallback((U,ae)=>{const L=y.current,W=U?L.find(oe=>oe.plugin===U&&oe.skill===ae):L.find(oe=>oe.skill===ae&&oe.source!=="plugin");if(!U&&!W){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${ae}" not yet in state — skipping reveal`);return}const ee=(W==null?void 0:W.plugin)??U,q=(W==null?void 0:W.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:ee,skill:ae,origin:q}}),window.location.hash=`/skills/${ee}/${ae}`},[]),b=p.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=p.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),E=p.useCallback(U=>{s({type:"SET_MODE",mode:U})},[]),C=p.useCallback(U=>{s({type:"SET_SEARCH",query:U})},[]),k=p.useCallback(U=>{s({type:"SET_MOBILE_VIEW",view:U})},[]),N=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=p.useRef(new Map),M=p.useRef(""),_=p.useRef(!1),[D,V]=p.useState(""),w=p.useMemo(()=>a.skills.map(U=>`${U.plugin}/${U.skill}`),[a.skills]),B=p.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=HS({skillIds:B,trackingSkillIds:w}),O=p.useRef("");p.useEffect(()=>{const U=a.skills.filter(q=>q.origin==="installed");if(U.length===0){V(""),O.current="";return}const ae=new Map;for(const q of z.updates)ae.set(q.name.split("/").pop()||q.name,q);const L=U.map(q=>{const oe=ae.get(q.skill),Q=q.currentVersion??(oe==null?void 0:oe.installed)??q.version??q.pluginVersion??"1.0.0";return{plugin:q.plugin,skill:q.skill,name:(oe==null?void 0:oe.name)??q.skill,currentVersion:Q}}),W=L.map(q=>`${q.plugin}/${q.skill}@${q.currentVersion}#${q.name}`).sort().join("|");if(W===O.current)return;O.current=W;let ee=!1;return Se.resolveInstalledSkillIds(L).then(q=>{if(ee)return;const ye=[...PS(q).flatMap(ce=>[ce.uuid,ce.slug].filter(Boolean))].sort().join(",");ye!==M.current&&(M.current=ye,T.current=new Map(q.map(ce=>[`${ce.plugin}/${ce.skill}`,{uuid:ce.uuid,slug:ce.slug}])),V(ye))}).catch(q=>{if(ee||(O.current=""),!_.current){_.current=!0;const oe=q instanceof Error?q.message:String(q);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",oe)}}),()=>{ee=!0}},[a.skills,z.updates]);const $=p.useMemo(()=>{const U=a.skills.map(ae=>{if(!ae.updateAvailable&&ae.latestVersion===void 0&&ae.trackedForUpdates===void 0)return ae;const L={...ae};return delete L.updateAvailable,delete L.currentVersion,delete L.latestVersion,delete L.trackedForUpdates,L});return RS(U,z.updates)},[a.skills,z.updates]),Y=p.useMemo(()=>{const U={source:0,installed:0};for(const ae of $)ae.updateAvailable&&(U[ae.origin]+=1);return U},[$]),X=p.useMemo(()=>({...a,skills:$}),[a,$]),ne=z.updateCount,H=z.refresh,A=z.isRefreshing,I=p.useCallback((U,ae)=>{H(),x(),On(`versions/${U}/${ae}`),z.dismiss(`${U}/${ae}`)},[H,x,z]),G=p.useMemo(()=>({state:X,selectSkill:m,clearSelection:S,setMode:E,setSearch:C,setMobileView:k,refreshSkills:x,updateCount:ne,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:Y,isRefreshingUpdates:A,refreshUpdates:H,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss,activeAgent:c,onSkillUpdated:I}),[X,m,S,E,C,k,x,ne,N,z.updates,Y,A,H,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss,c,I]);return r.jsx(Kv.Provider,{value:G,children:t})}const WS={config:null,loading:!0};function qS(t,a){switch(a.type){case"SET_CONFIG":return{config:a.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Xv=p.createContext(null);function Wa(){const t=p.useContext(Xv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function YS({children:t}){const[a,s]=p.useReducer(qS,WS),i=p.useCallback(()=>{Se.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{i()},[i]);const c=p.useCallback(async(d,h)=>{const x=await Se.setConfig(d,h);return s({type:"SET_CONFIG",config:x}),x},[]),u=p.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:i}),[a,c,i]);return r.jsx(Xv.Provider,{value:u,children:t})}function KS({topRail:t,sidebar:a,main:s,statusBar:i,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:x=!1}){const m={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:x?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:m,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:y,children:[!x&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!x&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:i}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const lg=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],XS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},QS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},ZS={"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"},JS={"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 e2(t,a){var h,x;const s=XS[t.id]??null,i=QS[t.id]??null,c=s?!!((h=a==null?void 0:a.wrapperFolders)!=null&&h[s]):!1,u=i?!!((x=a==null?void 0:a.binaries)!=null&&x[i]):!0,d=t.models.map(m=>({id:m.id,displayName:m.label,billingMode:JS[t.id]??"per-token",...m.pricing?{pricing:m.pricing}:{},...m.resolvedId?{resolvedId:m.resolvedId}:{}}));return{id:t.id,displayName:t2(t.id,t.label),wrapperFolder:s,wrapperFolderPresent:c,binaryAvailable:u,endpointReachable:t.id==="ollama"||t.id==="lm-studio"?t.available:null,available:t.available,ctaType:t.available?null:ZS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function t2(t,a){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??a}function n2(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of lg){const c=a.get(i);c&&s.push(c)}for(const i of t)lg.includes(i.id)||s.push(i);return s}function r2(t){const[a,s]=p.useState(null),[i,c]=p.useState("loading"),[u,d]=p.useState(null),[h,x]=p.useState(null),m=p.useRef(null),y=p.useRef(0),v=p.useRef(t==null?void 0:t.onStaleCatalog),b=p.useRef(t==null?void 0:t.onSetActiveError);p.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=p.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const M=await T.json(),_=n2((M.providers||[]).map(D=>e2(D,M.detection)));s({agents:_,activeAgent:M.provider??null,activeModel:M.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);p.useEffect(()=>{S()},[S]);const E=p.useCallback(async()=>{var M;const T=Date.now();if(!(T-y.current<5*6e4))try{const _=await fetch("/api/openrouter/models");if(!_.ok){_.status!==400&&x(`OpenRouter catalog fetch failed (${_.status})`);return}const D=await _.json();y.current=T,x(null),s(B=>{if(!B)return B;const z=B.agents.map(O=>{if(O.id!=="openrouter")return O;const $=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...O,models:$,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...B,agents:z}});const V=D.ageSec??0;(D.stale===!0||V>600)&&((M=v.current)==null||M.call(v,"openrouter",V*1e3))}catch(_){x(`OpenRouter catalog unreachable: ${_.message}`)}},[]),C=p.useCallback(T=>{m.current=T,T==="openrouter"&&E()},[E]),k=p.useCallback(()=>{y.current=0,S()},[S]),N=p.useCallback(async(T,M)=>{var V,w;let _;try{_=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:M})})}catch(B){(V=b.current)==null||V.call(b,`Network error while setting ${T}: ${B.message}`);return}if(_.ok){s(B=>B&&{...B,activeAgent:T,activeModel:M});return}let D=`Failed to set ${T} (${_.status})`;try{const B=await _.json();B&&typeof B.error=="string"&&(D=B.error)}catch{}(w=b.current)==null||w.call(b,D)},[]);return{status:i,catalog:a,error:u,openRouterError:h,focusAgent:C,refresh:k,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function Md({variant:t,label:a,onActivate:s,installUrl:i,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&i){window.open(i,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return r.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":a,...c?{title:c}:{},children:a})}function of({unlocked:t=!1,size:a=10}){return t?r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const a2={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <skill> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,a)=>`${t} of ${a}`},l2={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"},s2={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:t=>`Couldn't load SKILL.md for ${t}.`,loadErrorBody:"Check the file path and your workspace permissions.",openInEditor:"Open in editor",copyPath:"Copy path",copyConfigSnippet:"Copy config snippet",depNotInstalledTooltip:"Not installed",missingValue:"—",announceViewingOwn:t=>`Viewing ${t} (Own)`,announceViewingInstalled:t=>`Viewing ${t} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},i2={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},o2={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"},c2={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"},u2={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},d2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},f2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},p2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},m2={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},h2={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)."}},x2={subscriptionBilling:"· subscription",free:"· free"},g2={title:"Settings",sectionApiKeys:"API Keys",banner:"Keys are stored locally on this device only. Never synced, never committed to git, never transmitted off-device except to the provider's own API.",storagePath:t=>`Keys stored at ${t} · protected by file permissions (0600 on macOS/Linux)`,storagePathFallback:"Keys stored locally on this device.",copyPath:"Copy path",pathCopied:"Path copied.",show:"Show",hide:"Hide",paste:"Paste",save:"Save",remove:"Remove",removeConfirm:t=>`Remove ${t} API key?`,keyStoredAt:t=>`Key stored locally — updated ${t}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:t=>`This doesn't look like a typical ${t} key. Save anyway?`,keySaved:t=>`${t} API key saved (local only, never synced)`,keyRemoved:t=>`${t} API key removed`},v2={providersLabel:"Providers",providerSummary:(t,a)=>`${t}/${a} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},y2={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsPlugins:"Plugins",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},b2={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:t=>`No skills installed for ${t} in this project — run vskill install.`,emptyGlobal:t=>`No global skills for ${t} — run vskill install --global.`},j2={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"},S2={title:t=>`Set up ${t}`,close:"Close",copy:"Copy",copied:"Copied",requiredEnv:"Required env vars",getKey:"Get a key",installRun:"Install & run",learnMore:"Learn more",fallbackTitle:"No setup guide available",fallbackBody:"We don't ship a setup guide for this provider yet."},k2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},w2={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"}},re={sidebar:a2,shell:l2,detail:s2,actions:i2,palette:o2,shortcuts:c2,toasts:u2,connection:d2,forms:f2,errors:p2,picker:m2,providers:h2,models:x2,settings:g2,statusBar:v2,scopePicker:y2,scopeSection:b2,claudeCodeLabel:j2,setupDrawer:S2,setupProviders:w2,scopeLabels:k2},C2=new Set(["claude-cli","claude-code"]);function sg(t){return C2.has(t)}const ig=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function E2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:i,onSelect:c,onOpenSettings:u}){const d=t.filter(x=>ig.has(x.id)),h=t.filter(x=>!ig.has(x.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(x=>r.jsx(og,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id)),h.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(x=>r.jsx(og,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id))]})}function og({agent:t,isActive:a,isFocused:s,onFocus:i,onSelect:c,onOpenSettings:u}){const{providers:d}=re,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},x={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},m=sg(t.id),y={minHeight:36,height:m?"auto":36,padding:m?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>i(t.id),onFocus:()=>i(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),sg(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:re.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:re.claudeCodeLabel.compactLabel})]}),r.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?r.jsx(of,{unlocked:!0,size:10}):r.jsx(of,{size:10})}),a&&r.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:re.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(Md,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&x[t.id]&&r.jsx(Md,{variant:"cli-install",label:x[t.id].label,installUrl:x[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(Md,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function N2(t,a,s,i){const d=t>=80,h=p.useRef(null),[x,m]=p.useState(0),y=p.useCallback(S=>{m(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=p.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(x/a)-4),E=Math.ceil(s/a)+8,C=Math.min(t,S+E);return{visibleStart:S,visibleEnd:C}},[d,x,a,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*a,offsetTop:v*a,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Qv=44,T2=352,R2=60,cg=480;function A2(t){var u,d;const a=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return a?`${a} ctx ${re.models.subscriptionBilling}`:re.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,i=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${i.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function M2(t,a){if(!a)return t;const s=a.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function L2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>x(u),R2);return()=>clearTimeout(b)},[u]),p.useEffect(()=>{t.id==="openrouter"&&t.available&&m.current&&m.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:cg,padding:20,display:"flex",flexDirection:"column",gap:12},children:[r.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:re.providers.openrouter.emptyCardBody}),r.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:re.providers.openrouter.addKeyCta})]});const y=p.useMemo(()=>M2(t.models,h),[t.models,h]),v=N2(y.length,Qv,T2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:cg,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&r.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:r.jsx("input",{ref:m,type:"text",placeholder:re.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":re.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?r.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[r.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:re.picker.noMatches(h)}),r.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:re.picker.clearSearch})]}):y.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:re.picker.noModelsYet}):r.jsx("div",{...v.containerProps,children:r.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const E=v.visibleStart+S;return r.jsx(D2,{model:b,isActive:b.id===a,isFocused:s===E,onSelect:()=>i(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function z2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function D2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=A2(t),d=z2(t.id,c,t.resolvedId),h=d!==null,x=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",m=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:i,title:t.id,style:{width:"100%",minHeight:Qv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:x,borderLeft:m,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[r.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&r.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const ug={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function _2(){const[t,a]=p.useState(null),[s,i]=p.useState(!0),[c,u]=p.useState(null),d=p.useCallback(async()=>{i(!0);try{const m=await fetch("/api/settings/keys");if(!m.ok)throw new Error(`GET /api/settings/keys returned ${m.status}`);const y=await m.json();a({...ug,...y}),u(null)}catch(m){u(m.message),a(ug)}finally{i(!1)}},[]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async(m,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:m,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),x=p.useCallback(async m=>{const y=await fetch(`/api/settings/keys/${m}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${m} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:x,refresh:d}}function O2({onMigrated:t,fetchImpl:a}){const[s,i]=p.useState({kind:"loading"}),c=a??globalThis.fetch,u=p.useCallback(async()=>{var m;try{const y=await c("/api/settings/migration-status");if(!y.ok){i({kind:"hidden"});return}const v=await y.json();v.pending&&(((m=v.darwinKeys)==null?void 0:m.length)??0)>0?i({kind:"visible",darwinKeys:v.darwinKeys??[]}):i({kind:"hidden"})}catch{i({kind:"hidden"})}},[c]);p.useEffect(()=>{u()},[u]);const d=p.useCallback(async()=>{i({kind:"working"});try{const m=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!m.ok){i({kind:"error",message:`Migration failed (${m.status})`});return}const y=await m.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(m){i({kind:"error",message:m.message})}},[c,u,t]),h=p.useCallback(async()=>{i({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:Ld,children:"Retry"})]});const x=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:x,"data-testid":"migration-migrate",style:{...Ld,background:"var(--accent, var(--color-accent))",color:"white",opacity:x?.6:1},children:x?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...Ld,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Ld={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},B2=[{id:"anthropic",name:re.providers.anthropic.name,keyIssuanceUrl:re.providers.anthropic.keyIssuanceUrl,prefix:re.providers.anthropic.keyPrefix,placeholder:`Paste ${re.providers.anthropic.name} key`},{id:"openai",name:re.providers.openai.name,keyIssuanceUrl:re.providers.openai.keyIssuanceUrl,prefix:re.providers.openai.keyPrefix,placeholder:re.providers.openai.pastePlaceholder},{id:"openrouter",name:re.providers.openrouter.name,keyIssuanceUrl:re.providers.openrouter.keyIssuanceUrl,prefix:re.providers.openrouter.keyPrefix,placeholder:`Paste ${re.providers.openrouter.name} key`}];function I2(t){const a=Date.now()-new Date(t).getTime();return a<6e4?"just now":a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:new Date(t).toLocaleString()}function Zv({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:h}=_2(),x=p.useRef(null),m=p.useRef(null),[y,v]=p.useState(null);p.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const E=await fetch("/api/settings/storage-path");if(!E.ok)throw new Error(`GET /api/settings/storage-path returned ${E.status}`);const C=await E.json();S||v(C.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),p.useEffect(()=>{if(!t)return;const S=document.activeElement,E=setTimeout(()=>{var N;const C=s?`input[data-provider="${s}"]`:"input[data-provider]",k=(N=x.current)==null?void 0:N.querySelector(C);k==null||k.focus()},0);return()=>{var C;clearTimeout(E),(C=S==null?void 0:S.focus)==null||C.call(S)}},[t,s]),p.useEffect(()=>{if(!t)return;const S=E=>{if(E.key==="Escape"){E.preventDefault(),a();return}if(E.key==="Tab"&&x.current){const C=x.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(C.length===0)return;const k=C[0],N=C[C.length-1];E.shiftKey&&document.activeElement===k?(E.preventDefault(),N.focus()):!E.shiftKey&&document.activeElement===N&&(E.preventDefault(),k.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=p.useCallback(async()=>{var S,E;if(y)try{await((E=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:E.call(S,y)),i==null||i(re.settings.pathCopied)}catch{}},[i,y]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:x,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:re.settings.title}),r.jsx(O2,{onMigrated:()=>{h()}}),r.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:re.settings.banner}),r.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[r.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:re.settings.sectionApiKeys}),B2.map(S=>r.jsx($2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async E=>{const C=await u(S.id,E);return i==null||i(re.settings.keySaved(S.name)),C},onRemove:async()=>{await d(S.id),i==null||i(re.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?m:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:y?re.settings.storagePath(y):re.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Ha,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:re.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function $2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:x}){const[m,y]=p.useState(""),[v,b]=p.useState(!1),[S,E]=p.useState(!1),[C,k]=p.useState(!1),[N,T]=p.useState(null),M=m.trim(),_=M.length===0,D=M.length>0&&!M.startsWith(i),V=p.useCallback(async()=>{if(_)return;E(!0);const z=M;y("");try{const O=await d(z);O.warning?T(O.warning):T(null)}finally{E(!1)}},[_,d,M]),w=p.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const O=await navigator.clipboard.readText();y(O)}catch{}},[]),B=p.useCallback(async()=>{k(!1),await h()},[h]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:x,type:v?"text":"password",value:m,onChange:z=>{y(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!v),style:Ha,children:v?re.settings.hide:re.settings.show}),r.jsx("button",{type:"button",onClick:w,style:Ha,children:re.settings.paste})]}),D&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:dg,children:re.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:dg,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:V,disabled:_||S,"data-testid":`save-${t}`,style:{...Ha,background:_?"var(--surface-2)":"var(--accent, var(--color-accent))",color:_?"var(--text-muted)":"white",cursor:_?"not-allowed":"pointer"},children:re.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:C?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:re.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:B,"data-testid":`remove-confirm-${t}`,style:{...Ha,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>k(!1),style:Ha,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>k(!0),"data-testid":`remove-${t}`,style:{...Ha,color:"var(--text-muted)"},children:re.settings.remove})}),r.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?re.settings.keyStoredAt(I2(u.updatedAt)):re.settings.noKey})]})]})}const Ha={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},dg={fontSize:11,color:"var(--warning, var(--text-muted))"};function U2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function H2({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=r2({onStaleCatalog:(O,$)=>{const Y=Math.round($/6e4);t==null||t(`Using cached ${O} catalog (${Y} min old)`)},onSetActiveError:O=>t==null?void 0:t(O)}),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,y]=p.useState(),[v,b]=p.useState(null),[S,E]=p.useState("agents"),[C,k]=p.useState(0),N=p.useRef(null);p.useRef(null),p.useEffect(()=>{var O;s&&!v&&b(s.activeAgent??((O=s.agents[0])==null?void 0:O.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],M=p.useMemo(()=>T.find(O=>O.id===v)??T[0],[T,v]);p.useEffect(()=>{k(0)},[v]);const _=p.useCallback(()=>{var O;d(!0),E("agents"),b((s==null?void 0:s.activeAgent)??((O=T[0])==null?void 0:O.id)??null),k(0)},[s,T]),D=p.useCallback(()=>{var O;d(!1),(O=N.current)==null||O.focus()},[]);p.useEffect(()=>{const O=$=>{var X;if(!($.metaKey||$.ctrlKey)||$.key.toLowerCase()!=="k")return;const Y=(X=document.activeElement)==null?void 0:X.tagName;Y==="INPUT"||Y==="TEXTAREA"||($.preventDefault(),d(ne=>!ne))};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[]),p.useEffect(()=>{if(!u)return;const O=Y=>{if(Y.key==="Escape"){Y.preventDefault(),D();return}if(Y.key==="ArrowDown"){Y.preventDefault(),$(1);return}if(Y.key==="ArrowUp"){Y.preventDefault(),$(-1);return}if(Y.key==="ArrowRight"&&S==="agents"){Y.preventDefault(),E("models"),k(X=>{const ne=((M==null?void 0:M.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,ne)))});return}if(Y.key==="ArrowLeft"&&S==="models"){Y.preventDefault(),E("agents");return}if(Y.key==="Enter"){if(Y.preventDefault(),S==="agents"&&M)E("models"),k(0);else if(S==="models"&&M){const X=Math.max(0,Math.min(M.models.length-1,C)),ne=M.models[X];ne&&(c(M.id,ne.id),D())}return}};function $(Y){if(S==="agents"){const X=T.findIndex(H=>H.id===v),ne=T[Math.max(0,Math.min(T.length-1,X+Y))];ne&&(b(ne.id),i(ne.id));return}if(S==="models"&&M){const X=M.models.length;if(X===0)return;k(ne=>{const H=ne+Y;return Math.max(0,Math.min(X-1,H))})}}return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[u,S,T,v,M,C,D,i,c]);const V=p.useCallback(O=>{y(O==="anthropic"||O==="openrouter"?O:void 0),x(!0),d(!1)},[]),w=T.find(O=>O.id===(s==null?void 0:s.activeAgent)),B=w==null?void 0:w.models.find(O=>O.id===(s==null?void 0:s.activeModel)),z=p.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const O=(w==null?void 0:w.displayName)??"Agent",$=(B==null?void 0:B.displayName)??s.activeModel??"Model";return`${O} · ${$}`},[a,s,w,B]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():_(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:z})]}),u&&typeof document<"u"&&tc.createPortal(r.jsxs(P2,{reducedMotion:U2(),onClickOutside:D,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(E2,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:O=>{b(O),i(O)},onSelect:O=>{b(O),i(O),E("models")},onOpenSettings:V}),M&&r.jsx(L2,{agent:M,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?C:-1,onSelect:O=>{c(M.id,O),D()},onOpenSettings:V})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>V(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:re.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:re.picker.footerHint})]})]}),document.body),r.jsx(Zv,{open:h,onClose:()=>x(!1),initialProvider:m,onToast:t})]})}function P2({children:t,reducedMotion:a,onClickOutside:s}){const i=p.useRef(null);return p.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:i,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
63
63
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
64
64
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
65
|
-
}`})]})}function fg(){typeof window>"u"||(window.location.hash="#/")}function V2({onHome:t}){const[a,s]=p.useState(!1),[i,c]=p.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),fg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),fg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:i?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const pg=p.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function F2({toast:t,onDismiss:a}){const[s,i]=p.useState(!0),c=p.useRef(null);p.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function G2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(pg,{politeness:"polite",message:s}),r.jsx(pg,{politeness:"assertive",message:i}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(F2,{toast:c,onDismiss:a})},c.id))})]})}const Jv=p.createContext(null);function nc(){const t=p.useContext(Jv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function W2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=p.useState([]),[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(new Map),y=p.useCallback(k=>{const N=m.current.get(k);N&&(clearTimeout(N),m.current.delete(k)),c(T=>T.filter(M=>M.id!==k))},[]),v=p.useCallback((k,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(k)},N);m.current.set(k,T)},[y]),b=p.useCallback(k=>{const N=k.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:k.message,severity:k.severity??"info",durationMs:k.durationMs??s,action:k.action};return c(M=>[...M,T]),T.severity==="error"?x(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=p.useCallback(()=>{for(const k of m.current.values())clearTimeout(k);m.current.clear(),c([])},[]);p.useEffect(()=>{function k(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const M=T.slice(0,a),_=M[M.length-1],D=m.current.get(_.id);return D&&(clearTimeout(D),m.current.delete(_.id)),T.filter(V=>V.id!==_.id)})}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[a]),p.useEffect(()=>()=>{for(const k of m.current.values())clearTimeout(k);m.current.clear()},[]);const E=i.slice(0,a),C=p.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(Jv.Provider,{value:C,children:[t,r.jsx(G2,{toasts:E,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function q2(){const{data:t,loading:a}=Ga("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const Y2=p.lazy(()=>Fa(()=>import("./UpdateDropdown-DI7OhaV-.js"),__vite__mapDeps([0,1])));function K2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:h,activeAgent:x}=ir(),{toast:m}=nc(),{data:y}=q2(),v=(y==null?void 0:y.degraded)===!0,b=p.useMemo(()=>{if(!h||h.size===0)return;const V=new Map;for(const[w,B]of h)B.diffSummary&&V.set(w,B.diffSummary);return V.size>0?V:void 0},[h]),[S,E]=p.useState(!1),C=p.useRef(null),k=p.useCallback(()=>E(!1),[]),N=v?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),M=t===0?"No updates available":`${t} updates available, open summary`,_=v?`${M} — platform crawler degraded`:M,D=v?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:C,type:"button","data-testid":"update-bell","aria-label":_,"aria-haspopup":"dialog","aria-expanded":S,title:D,onClick:()=>E(V=>!V),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||v?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:T})]}),S&&r.jsx(p.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(Y2,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:V=>{const w=V.localSkill??V.name.split("/").pop()??"",B=V.localPlugin??"";if(u)u(B,w);else{const O=V.name.split("/"),$=O.length>=2?O[O.length-2]:O[0];c({plugin:$,skill:w,origin:"installed"})}if(!(d??[]).some(O=>O.skill===w&&(B===""||O.plugin===B))){const O=V.installLocations??[];if(O.length>0){const $=x?O.filter(X=>X.agent===x):[],Y=x?O.filter(X=>X.agent!==x):O;if($.length>0&&Y.length>0){const X=Y.length>=2?`Also installed under ${Y.length} other locations.`:`Also installed under ${Y[0].agentLabel}.`;m({severity:"info",message:X})}else{const X=O[0].agentLabel;m({severity:"info",message:`Skill installed under ${X} — switch to ${X} to view details.`})}}}k()},onViewAll:()=>{window.location.hash="#/updates",k()},onClose:k,anchorRef:C})})]})}function mg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function X2({projectName:t,selected:a,onOpenPalette:s,onHome:i,projectPickerSlot:c,onRequestCreateSkill:u,findSkillsSlot:d}){const h=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(V2,{onHome:i}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&h&&r.jsxs(r.Fragment,{children:[r.jsx(hg,{segment:"origin",onClick:()=>mg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:h}),r.jsx(xg,{}),r.jsx(hg,{segment:"plugin",onClick:()=>mg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(xg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[d,u&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(H2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(K2,{})}),r.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:r.jsx("span",{children:"⌘K"})})]})]})}function hg({segment:t,onClick:a,style:s,children:i}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:i})}function xg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const rc="vskill-theme";function ey(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function Q2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function Z2(t){try{const a=t.getItem(rc);return ey(a)}catch{return"auto"}}function J2(t,a){try{t.setItem(rc,a)}catch{}}function ek(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function tk(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const ty=p.createContext(null);function nk({storage:t,matchMedia:a,target:s,children:i}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,x]=p.useState(()=>c?Z2(c):"auto"),[m,y]=p.useState(()=>tk(u)),v=p.useMemo(()=>Q2(h,m),[h,m]);p.useEffect(()=>{d&&ek(d,h,v)},[d,h,v]),p.useEffect(()=>{if(!u)return;const E=u("(prefers-color-scheme: dark)"),C=N=>y(N.matches);if(typeof E.addEventListener=="function")return E.addEventListener("change",C),()=>E.removeEventListener("change",C);const k=E;return k.addListener(C),()=>k.removeListener(C)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const E=C=>{C.key===rc&&x(ey(C.newValue))};return window.addEventListener("storage",E),()=>window.removeEventListener("storage",E)},[]),p.useEffect(()=>{if(!u||!d)return;let E;try{E=u("(prefers-contrast: more)")}catch{return}const C=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};C(E.matches);const k=T=>C(T.matches);if(typeof E.addEventListener=="function")return E.addEventListener("change",k),()=>E.removeEventListener("change",k);const N=E;return N.addListener(k),()=>N.removeListener(k)},[u,d]);const b=p.useCallback(E=>{x(E),c&&J2(c,E)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(ty.Provider,{value:S,children:i})}function ny(){const t=p.useContext(ty);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const gg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function rk(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of gg){const c=a.get(i);c&&s.push(c)}for(const i of t)gg.includes(i.id)||s.push(i);return s}function ak(t){const[a,s]=p.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return p.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function lk({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=rk(t),c=ak(640),[u,d]=p.useState(!1),h=p.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=i.filter(m=>m.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":re.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:re.statusBar.providerSummary(x,i.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:i.map(m=>r.jsx(vg,{p:m,onClick:h},m.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(x=>r.jsx(vg,{p:x,onClick:h,compact:!0},x.id))})}function vg({p:t,onClick:a,compact:s}){const i=t.available?re.statusBar.unlocked(t.label):t.kind==="cli-install"?re.statusBar.lockedCli(t.label):re.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(of,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function sk(){try{return typeof localStorage>"u"?null:localStorage.getItem(rc)}catch{return null}}function ik({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:x,setTheme:m}=ny(),v=sk()==="auto",b=ok(h,x,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(yg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(ck,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(yg,{}),r.jsx(lk,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>m(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[r.jsx(uk,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function ok(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function ck({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function yg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function uk({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const cf=new Set;function ry(){for(const t of cf)t()}const dk=5,fk=1e3,pk=6e4;function mk(){const[t,a]=p.useState(void 0),[s,i]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),h=p.useRef(null),x=p.useRef(null),m=p.useRef(!0),y=p.useRef(0),[v,b]=p.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},E=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),C=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;E();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!m.current)return;const M=await T.json();if(!m.current)return;d.current=0,a(M.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{m.current&&b(_=>_+1)},pk)}catch(T){if(!m.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>dk){i(!0);return}const M=fk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{m.current&&b(_=>_+1)},M)}},[E]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),E()}),[E]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),C())},[v,C]),p.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),E()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[E]);const k=p.useCallback(()=>{d.current=0,i(!1),S(),y.current+=1,b(N=>N+1)},[]);return p.useEffect(()=>(cf.add(k),()=>{cf.delete(k)}),[k]),{plugins:t,paused:s,loading:c,retry:k}}const ac=0,ga=1,Pl=2,ay=4;function bg(t){return()=>t}function hk(t){t()}function ly(t,a){return s=>t(a(s))}function jg(t,a){return()=>t(a)}function xk(t,a){return s=>t(a,s)}function Lf(t){return t!==void 0}function gk(...t){return()=>{t.map(hk)}}function Vl(){}function lc(t,a){return a(t),t}function vk(t,a){return a(t)}function Et(...t){return t}function ct(t,a){return t(ga,a)}function Ve(t,a){t(ac,a)}function zf(t){t(Pl)}function Mt(t){return t(ay)}function Re(t,a){return ct(t,xk(a,ac))}function ar(t,a){const s=t(ga,i=>{s(),a(i)});return s}function Sg(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function sy(t,a){return t===a}function Ct(t=sy){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function Ie(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>ly(a,t)}function mr(t){return a=>()=>{a(t)}}function he(t,...a){const s=yk(...a);return((i,c)=>{switch(i){case Pl:zf(t);return;case ga:return ct(t,s(c))}})}function hr(t,a){return s=>i=>{s(a=t(a,i))}}function Va(t){return a=>s=>{t>0?t--:a(s)}}function Br(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function Fe(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;ct(u,x=>{const m=s;s|=h,a[d]=x,m!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():i=h}}function yk(...t){return a=>t.reduceRight(vk,a)}function bk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ga:return u?s===u?void 0:(i(),s=u,a=ct(t,u),a):(i(),Vl);case Pl:i(),s=null;return}}}function ge(t){let a=t;const s=tt();return((i,c)=>{switch(i){case ac:a=c;break;case ga:{c(a);break}case ay:return a}return s(i,c)})}function un(t,a){return lc(ge(a),s=>Re(t,s))}function tt(){const t=[];return((a,s)=>{switch(a){case ac:t.slice().forEach(i=>{i(s)});return;case Pl:t.splice(0,t.length);return;case ga:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function Bn(t){return lc(tt(),a=>Re(t,a))}function st(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:jk(),singleton:s}}const jk=()=>Symbol();function Sk(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=i(c.map(x=>s(x)));return d&&a.set(u,h),h};return s(t)}function Ft(...t){const a=tt(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;ct(u,x=>{s[d]=x,i|=h,i===c&&Ve(a,s)})}),function(u,d){switch(u){case Pl:{zf(a);return}case ga:return i===c&&d(s),ct(a,d)}}}function Be(t,a=sy){return he(t,Ct(a))}function uf(...t){return function(a,s){switch(a){case Pl:return;case ga:return gk(...t.map(i=>ct(i,s)))}}}const Yt={DEBUG:0,INFO:1,WARN:2,ERROR:3},kk={[Yt.DEBUG]:"debug",[Yt.ERROR]:"error",[Yt.INFO]:"log",[Yt.WARN]:"warn"},wk=()=>typeof globalThis>"u"?window:globalThis,va=st(()=>{const t=ge(Yt.ERROR);return{log:ge((a,s,i=Yt.INFO)=>{const c=wk().VIRTUOSO_LOG_LEVEL??Mt(t);i>=c&&console[kk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function qa(t,a,s){return Df(t,a,s).callbackRef}function Df(t,a,s){const i=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function Ck(t,a,s,i,c,u,d,h,x){const m=Te.useCallback(y=>{const v=Ek(y.children,a,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let E;S&&(E=b.ownerDocument.defaultView);const C=d?h?d.scrollLeft:d.scrollTop:S?h?E.scrollX||E.document.documentElement.scrollLeft:E.scrollY||E.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,k=d?h?d.scrollWidth:d.scrollHeight:S?h?E.document.documentElement.scrollWidth:E.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?E.innerWidth:E.innerHeight:h?b.offsetWidth:b.offsetHeight;i({scrollHeight:k,scrollTop:Math.max(C,0),viewportHeight:N}),u==null||u(h?kg("column-gap",getComputedStyle(y).columnGap,c):kg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,i,h]);return Df(m,s,x)}function Ek(t,a,s,i){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const x=parseInt(h.dataset.index),m=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&i("Zero-sized element, this should not happen",{child:h},Yt.ERROR),y===m)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==x-1?u.push({endIndex:x,size:y,startIndex:x}):u[u.length-1].endIndex++}return u}function kg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Yt.WARN),a==="normal"?0:parseInt(a??"0",10)}function iy(t,a,s){const i=Te.useRef(null),c=Te.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const m=x.getBoundingClientRect(),y=m.width;let v,b;if(a){const S=a.getBoundingClientRect(),E=m.top-S.top;b=S.height-Math.max(0,E),v=E+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),v=m.top+S.scrollY}i.current={listHeight:m.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Df(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var m;if(a){a.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(a),()=>{a.removeEventListener("scroll",h),y.unobserve(a)}}const x=(m=d.current)==null?void 0:m.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",h),x==null||x.addEventListener("resize",h),()=>{x==null||x.removeEventListener("scroll",h),x==null||x.removeEventListener("resize",h)}},[h,a,d]),u}const hn=st(()=>{const t=tt(),a=tt(),s=ge(0),i=tt(),c=ge(0),u=tt(),d=tt(),h=ge(0),x=ge(0),m=ge(0),y=ge(0),v=tt(),b=tt(),S=ge(!1),E=ge(!1),C=ge(!1);return Re(he(t,we(({scrollTop:k})=>k)),a),Re(he(t,we(({scrollHeight:k})=>k)),d),Re(a,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:x,footerHeight:y,headerHeight:h,horizontalDirection:E,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:C,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Ks={lvl:0};function oy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:x}=a(t[d]);u.push({end:h-1,start:i,value:c}),i=h,c=x}return u.push({end:1/0,start:i,value:c}),u}function gt(t){return t===Ks}function Xs(t,a){if(!gt(t))return a===t.k?t.v:a<t.k?Xs(t.l,a):Xs(t.r,a)}function sr(t,a,s="k"){if(gt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=sr(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return sr(t.l,a,s)}function _n(t,a,s){return gt(t)?dy(a,s,1):a===t.k?qt(t,{k:a,v:s}):a<t.k?wg(qt(t,{l:_n(t.l,a,s)})):wg(qt(t,{r:_n(t.r,a,s)}))}function Ol(){return Ks}function Bl(t,a,s){if(gt(t))return[];const i=sr(t,a)[0];return Nk(ff(t,i,s))}function df(t,a){if(gt(t))return Ks;const{k:s,l:i,r:c}=t;if(a===s){if(gt(i))return c;if(gt(c))return i;const[u,d]=uy(i);return Uo(qt(t,{k:u,l:cy(i),v:d}))}return a<s?Uo(qt(t,{l:df(i,a)})):Uo(qt(t,{r:df(c,a)}))}function Pa(t){return gt(t)?[]:[...Pa(t.l),{k:t.k,v:t.v},...Pa(t.r)]}function ff(t,a,s){if(gt(t))return[];const{k:i,l:c,r:u,v:d}=t;let h=[];return i>a&&(h=h.concat(ff(c,a,s))),i>=a&&i<=s&&h.push({k:i,v:d}),i<=s&&(h=h.concat(ff(u,a,s))),h}function Uo(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(zd(a))return fy(qt(t,{lvl:s-1}));if(!gt(a)&&!gt(a.r))return qt(a.r,{l:qt(a,{r:a.r.l}),lvl:s,r:qt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(zd(t))return pf(qt(t,{lvl:s-1}));if(!gt(i)&&!gt(i.l)){const c=i.l,u=zd(c)?i.lvl-1:i.lvl;return qt(c,{l:qt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:pf(qt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function qt(t,a){return dy(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function cy(t){return gt(t.r)?t.l:Uo(qt(t,{r:cy(t.r)}))}function zd(t){return gt(t)||t.lvl>t.r.lvl}function uy(t){return gt(t.r)?[t.k,t.v]:uy(t.r)}function dy(t,a,s,i=Ks,c=Ks){return{k:t,l:i,lvl:s,r:c,v:a}}function wg(t){return pf(fy(t))}function fy(t){const{l:a}=t;return!gt(a)&&a.lvl===t.lvl?qt(a,{r:qt(t,{l:a.r})}):t}function pf(t){const{lvl:a,r:s}=t;return!gt(s)&&!gt(s.r)&&s.lvl===a&&s.r.lvl===a?qt(s,{l:qt(t,{r:s.l}),lvl:a+1}):t}function Nk(t){return oy(t,({k:a,v:s})=>({index:a,value:s}))}function py(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Qs(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const _f=st(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function my(t,a,s){return t[Go(t,a,s)]}function Go(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Tk(t,a,s,i){const c=Go(t,a,i),u=Go(t,s,i,c);return t.slice(c,u+1)}function ha(t,a){return Math.round(t.getBoundingClientRect()[a])}function sc(t){return!gt(t.groupOffsetTree)}function Of({index:t},a){return a===t?0:a<t?-1:1}function Rk(){return{groupIndices:[],groupOffsetTree:Ol(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ol()}}function Ak(t,a){let s=gt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),gt(t)){t=_n(t,0,u);continue}const h=Bl(t,d-1,c+1);if(h.some(Bk(i)))continue;let x=!1,m=!1;for(const{end:y,start:v,value:b}of h)x?(c>=v||u===b)&&(t=df(t,v)):(m=b!==u,x=!0),y>c&&c>=v&&b!==u&&(t=_n(t,c+1,b));m&&(t=_n(t,d,u))}return[t,s]}function Mk(t){return typeof t.groupIndex<"u"}function Lk({offset:t},a){return a===t?0:a<t?-1:1}function Zs(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=my(a,t,Of),d=t-i,h=u*d+(d-1)*s+c;return h>0?h+s:h}function hy(t,a){if(!sc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function xy(t,a,s){if(Mk(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=hy(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function zk(t,a,s,i=0){return i>0&&(a=Math.max(a,my(t,i,Of).offset)),oy(Tk(t,a,s,Lk),Ok)}function Dk(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Yt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&>(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((E,C)=>_n(_n(E,C,b),C+1,S),d)}else[d,h]=Ak(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:m,lastSize:y,offsetTree:v}=mf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>_n(b,S,Zs(S,v,c)),Ol()),lastIndex:x,lastOffset:m,lastSize:y,offsetTree:v,sizeTree:d}}function _k(t){return Pa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Cg(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function mf(t,a,s,i){let c=t,u=0,d=0,h=0,x=0;if(a!==0){x=Go(c,a-1,Of),h=c[x].offset;const m=sr(s,a-1);u=m[0],d=m[1],c.length&&c[x].size===sr(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:m,value:y}of Bl(s,a,1/0)){const v=m-u,b=v*d+h+v*i;c.push({index:m,offset:b,size:y}),u=m,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function Ok(t){return{index:t.index,value:t}}function Bk(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Ik={offsetHeight:"height",offsetWidth:"width"},vr=st(([{log:t},{recalcInProgress:a}])=>{const s=tt(),i=tt(),c=un(i,0),u=tt(),d=tt(),h=ge(0),x=ge([]),m=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),S=ge((w,B)=>ha(w,Ik[B])),E=ge(void 0),C=ge(0),k=Rk(),N=un(he(s,Fe(x,t,C),hr(Dk,k),Ct()),k),T=un(he(x,Ct(),hr((w,B)=>({current:B,prev:w.current}),{current:[],prev:[]}),we(({prev:w})=>w)),[]);Re(he(x,Ie(w=>w.length>0),Fe(N,C),we(([w,B,z])=>{const O=w.reduce(($,Y,X)=>_n($,Y,Zs(Y,B.offsetTree,z)||X),Ol());return{...B,groupIndices:w,groupOffsetTree:O}})),N),Re(he(i,Fe(N),Ie(([w,{lastIndex:B}])=>w<B),we(([w,{lastIndex:B,lastSize:z}])=>[{endIndex:B,size:z,startIndex:w}])),s),Re(m,y);const M=un(he(m,we(w=>w===void 0)),!0);Re(he(y,Ie(w=>w!==void 0&>(Mt(N).sizeTree)),we(w=>{const B=Mt(v),z=Mt(x).length>0;return B!==void 0&&B!==0?z?[{endIndex:0,size:B,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(he(b,Ie(w=>w!==void 0&&w.length>0&>(Mt(N).sizeTree)),we(w=>{const B=[];let z=w[0],O=0;for(let $=1;$<w.length;$++){const Y=w[$];Y!==z&&(B.push({endIndex:$-1,size:z,startIndex:O}),z=Y,O=$)}return B.push({endIndex:w.length-1,size:z,startIndex:O}),B})),s),Re(he(x,Fe(v,y),Ie(([,w,B])=>w!==void 0&&B!==void 0),we(([w,B,z])=>{const O=[];for(let $=0;$<w.length;$++){const Y=w[$],X=w[$+1];O.push({startIndex:Y,endIndex:Y,size:B}),X!==void 0&&O.push({startIndex:Y+1,endIndex:X-1,size:z})}return O})),s);const _=Bn(he(s,Fe(N),hr(({sizes:w},[B,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:k}),we(w=>w.changed)));ct(he(h,hr((w,B)=>({diff:w.prev-B,prev:B}),{diff:0,prev:0}),we(w=>w.diff)),w=>{const{groupIndices:B}=Mt(N);if(w>0)Ve(a,!0),Ve(u,w+Cg(w,B));else if(w<0){const z=Mt(T);z.length>0&&(w-=Cg(-w,z)),Ve(d,w)}}),ct(he(h,Fe(t)),([w,B])=>{w<0&&B("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Yt.ERROR)});const D=Bn(u);Re(he(u,Fe(N),we(([w,B])=>{const z=B.groupIndices.length>0,O=[],$=B.lastSize;if(z){const Y=Xs(B.sizeTree,0);let X=0,ne=0;for(;X<w;){const A=B.groupIndices[ne],I=B.groupIndices.length===ne+1?1/0:B.groupIndices[ne+1]-A-1;O.push({endIndex:A,size:Y,startIndex:A}),O.push({endIndex:A+1+I-1,size:$,startIndex:A+1}),ne++,X+=I+1}const H=Pa(B.sizeTree);return X!==w&&H.shift(),H.reduce((A,{k:I,v:G})=>{let U=A.ranges;return A.prevSize!==0&&(U=[...A.ranges,{endIndex:I+w-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:I+w,prevSize:G,ranges:U}},{prevIndex:w,prevSize:0,ranges:O}).ranges}return Pa(B.sizeTree).reduce((Y,{k:X,v:ne})=>({prevIndex:X+w,prevSize:ne,ranges:[...Y.ranges,{endIndex:X+w-1,size:Y.prevSize,startIndex:Y.prevIndex}]}),{prevIndex:0,prevSize:$,ranges:[]}).ranges})),s);const V=Bn(he(d,Fe(N,C),we(([w,{offsetTree:B},z])=>{const O=-w;return Zs(O,B,z)})));return Re(he(d,Fe(N,C),we(([w,B,z])=>{if(B.groupIndices.length>0){if(gt(B.sizeTree))return B;let $=Ol();const Y=Mt(T);let X=0,ne=0,H=0;for(;X<-w;){H=Y[ne];const A=Y[ne+1]-H-1;ne++,X+=A+1}if($=Pa(B.sizeTree).reduce((A,{k:I,v:G})=>_n(A,Math.max(0,I+w),G),$),X!==-w){const A=Xs(B.sizeTree,H);$=_n($,0,A);const I=sr(B.sizeTree,-w+1)[1];$=_n($,1,I)}return{...B,sizeTree:$,...mf(B.offsetTree,0,$,z)}}const O=Pa(B.sizeTree).reduce(($,{k:Y,v:X})=>_n($,Math.max(0,Y+w),X),Ol());return{...B,sizeTree:O,...mf(B.offsetTree,0,O,z)}})),N),{beforeUnshiftWith:D,data:E,defaultItemSize:y,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:v,gap:C,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:_,shiftWith:d,shiftWithOffset:V,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:M,unshiftWith:u}},Et(va,_f),{singleton:!0});function $k(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const gy=st(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=tt(),d=tt(),h=Bn(he(u,we($k)));return Re(he(h,we(x=>x.totalCount)),s),Re(he(h,we(x=>x.groupIndices)),t),Re(he(Ft(c,a,i),Ie(([x,m])=>sc(m)),we(([x,m,y])=>sr(m.groupOffsetTree,Math.max(x-y,0),"v")[0]),Ct(),we(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},Et(vr,hn)),ya=st(([{log:t}])=>{const a=ge(!1),s=Bn(he(a,Ie(i=>i),Ct()));return ct(a,i=>{i&&Mt(t)("props updated",{},Yt.DEBUG)}),{didMount:s,propsReady:a}},Et(va),{singleton:!0}),Uk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function vy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!Uk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ai=st(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:x,scrollTo:m,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=tt(),E=tt(),C=ge(0);let k=null,N=null,T=null;function M(){k!==null&&(k(),k=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Ve(x,!1)}return Re(he(S,Fe(s,v,i,C,h,d,b),Fe(t,u,c),we(([[_,D,V,w,B,z,O,$],Y,X,ne])=>{const H=vy(_),{align:A,behavior:I,offset:G}=H,U=w-1,ae=xy(H,D,U);let L=Zs(ae,D.offsetTree,Y)+z;A==="end"?(L+=X+sr(D.sizeTree,ae)[1]-V+ne,ae===U&&(L+=O)):A==="center"?L+=(X+sr(D.sizeTree,ae)[1]-V+ne)/2:L-=B,G!==void 0&&G!==0&&(L+=G);const W=ee=>{M(),ee?($("retrying to scroll to",{location:_},Yt.DEBUG),Ve(S,_)):(Ve(E,!0),$("list did not change, scroll successful",{},Yt.DEBUG))};if(M(),I==="smooth"){let ee=!1;T=ct(a,q=>{ee=ee||q}),k=ar(y,()=>{W(ee)})}else k=ar(he(a,Hk(150)),W);return N=setTimeout(()=>{M()},1200),Ve(x,!0),$("scrolling from index to",{behavior:I,index:ae,top:L},Yt.DEBUG),{behavior:I,top:L}})),m),{scrollTargetReached:E,scrollToIndex:S,topListHeight:C}},Et(vr,hn,va),{singleton:!0});function Hk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Bf(t,a){t===0?a():requestAnimationFrame(()=>{Bf(t-1,a)})}function If(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const li=st(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),x=ge(0),m=ge(!0);return Re(he(d,Fe(x),Ie(([y,v])=>v!==0),mr(!1)),h),Re(he(d,Fe(x),Ie(([y,v])=>v!==0),mr(!1)),m),ct(he(Ft(a,d),Fe(h,s,t,m),Ie(([[,y],v,{sizeTree:b},S,E])=>y&&(!gt(b)||Lf(S))&&!v&&!E),Fe(x)),([,y])=>{ar(c,()=>{Ve(m,!0)}),Bf(4,()=>{ar(i,()=>{Ve(h,!0)}),Ve(u,y)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:x,scrolledToInitialItem:h}},Et(vr,hn,ai,ya),{singleton:!0});function yy(t,a){return Math.abs(t-a)<1.01}const Js="up",Gs="down",Pk="none",Vk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Fk=0,si=st(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),x=tt(),m=tt(),y=ge(4),v=ge(Fk),b=un(he(uf(he(Be(c),Va(1),mr(!0)),he(Be(c),Va(1),mr(!1),Sg(100))),Ct()),!1),S=un(he(uf(he(s,mr(!0)),he(s,mr(!1),Sg(200))),Ct()),!1);Re(he(Ft(Be(c),Be(v)),we(([T,M])=>T<=M),Ct()),h),Re(he(h,Br(50)),m);const E=Bn(he(Ft(i,Be(u),Be(a),Be(t),Be(y)),hr((T,[{scrollHeight:M,scrollTop:_},D,V,w,B])=>{const z=_+D-M>-B,O={scrollHeight:M,scrollTop:_,viewportHeight:D};if(z){let Y,X;return _>T.state.scrollTop?(Y="SCROLLED_DOWN",X=T.state.scrollTop-_):(Y="SIZE_DECREASED",X=T.state.scrollTop-_||T.scrollTopDelta),{atBottom:!0,atBottomBecause:Y,scrollTopDelta:X,state:O}}let $;return O.scrollHeight>T.state.scrollHeight?$="SIZE_INCREASED":D<T.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":_<T.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:O}},Vk),Ct((T,M)=>T!==void 0&&T.atBottom===M.atBottom))),C=un(he(i,hr((T,{scrollHeight:M,scrollTop:_,viewportHeight:D})=>{if(!yy(T.scrollHeight,M)){const V=M-(_+D)<1;return T.scrollTop!==_&&V?{changed:!0,jump:T.scrollTop-_,scrollHeight:M,scrollTop:_}:{changed:!0,jump:0,scrollHeight:M,scrollTop:_}}return{changed:!1,jump:0,scrollHeight:M,scrollTop:_}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(T=>T.changed),we(T=>T.jump)),0);Re(he(E,we(T=>T.atBottom)),d),Re(he(d,Br(50)),x);const k=ge(Gs);Re(he(i,we(({scrollTop:T})=>T),Ct(),hr((T,M)=>Mt(S)?{direction:T.direction,prevScrollTop:M}:{direction:M<T.prevScrollTop?Js:Gs,prevScrollTop:M},{direction:Gs,prevScrollTop:0}),we(T=>T.direction)),k),Re(he(i,Br(50),mr(Pk)),k);const N=ge(0);return Re(he(b,Ie(T=>!T),mr(0)),N),Re(he(c,Br(100),Fe(b),Ie(([T,M])=>M),hr(([T,M],[_])=>[M,_],[0,0]),we(([T,M])=>M-T)),N),{atBottomState:E,atBottomStateChange:x,atBottomThreshold:y,atTopStateChange:m,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:C,scrollDirection:k,scrollVelocity:N}},Et(hn)),ei="top",ti="bottom",Eg="none";function Ng(t,a,s){return typeof t=="number"?s===Js&&a===ei||s===Gs&&a===ti?t:0:s===Js?a===ei?t.main:t.reverse:a===ti?t.main:t.reverse}function Tg(t,a){return typeof t=="number"?t:t[a]??0}const $f=st(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=tt(),d=ge(0),h=ge(0),x=ge(0),m=un(he(Ft(Be(i),Be(c),Be(s),Be(u,Qs),Be(x),Be(d),Be(a),Be(t),Be(h)),we(([y,v,b,[S,E],C,k,N,T,M])=>{const _=y-T,D=k+N,V=Math.max(b-_,0);let w=Eg;const B=Tg(M,ei),z=Tg(M,ti);return S-=T,S+=b+N,E+=b+N,E-=T,S>y+D-B&&(w=Js),E<y-V+v+z&&(w=Gs),w!==Eg?[Math.max(_-b-Ng(C,ei,w)-B,0),_-V-N+v+Ng(C,ti,w)+z]:null}),Ie(y=>y!==null),Ct(Qs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:x,topListHeight:d,visibleRange:m}},Et(hn),{singleton:!0});function Gk(t,a,s){if(sc(a)){const i=hy(t,a);return[{index:sr(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const Dd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ho(t,a,s,i,c,u){const{lastIndex:d,lastOffset:h,lastSize:x}=c;let m=0,y=0;if(t.length>0){m=t[0].offset;const C=t[t.length-1];y=C.offset+C.size}const v=s-d,b=h+v*x+(v-1)*i,S=m,E=b-y;return{bottom:y,firstItemIndex:u,items:Rg(t,c,u),offsetBottom:E,offsetTop:m,top:S,topItems:Rg(a,c,u),topListHeight:a.reduce((C,k)=>k.size+C,0),totalCount:s}}function by(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,x=If(a,h),m=Array.from({length:h}).map((y,v)=>({data:u[v+x],index:v+x,offset:0,size:0}));return Ho(m,[],h,c,s,i)}function Rg(t,a,s){if(t.length===0)return[];if(!sc(a))return t.map(m=>({...m,index:m.index+s,originalIndex:m.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Bl(a.groupOffsetTree,i,c);let h,x=0;for(const m of t){(!h||h.end<m.index)&&(h=d.shift(),x=a.groupIndices.indexOf(h.start));let y;m.index===h.start?y={index:x,type:"group"}:y={groupIndex:x,index:m.index-(x+1)+s},u.push({...y,data:m.data,offset:m.offset,originalIndex:m.index,size:m.size})}return u}function Ag(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Ya=st(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:x},{initialTopMostItemIndex:m,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:E}])=>{const C=ge([]),k=ge(0),N=tt(),T=ge(0);Re(u.topItemsIndexes,C);const M=un(he(Ft(S,E,Be(x,Qs),Be(c),Be(i),Be(m),y,Be(C),Be(a),Be(s),Be(T),t),Ie(([w,B,,z,,,,,,,,O])=>{const $=O!==void 0&&O.length!==z;return w&&!B&&!$}),we(([,,[w,B],z,O,$,Y,X,ne,H,A,I])=>{var je,Me;const G=O,{offsetTree:U,sizeTree:ae}=G,L=Mt(k);if(z===0)return{...Dd,totalCount:z};if(w===0&&B===0)return L===0?{...Dd,totalCount:z}:by(L,$,O,ne,H,I||[]);if(gt(ae))return L>0?null:Ho(Gk(If($,z),G,I),[],z,H,G,ne);const W=[];if(X.length>0){const Ae=X[0],ze=X[X.length-1];let Ge=0;for(const se of Bl(ae,Ae,ze)){const de=se.value,me=Math.max(se.start,Ae),ve=Math.min(se.end,ze);for(let be=me;be<=ve;be++)W.push({data:I==null?void 0:I[be],index:be,offset:Ge,size:de}),Ge+=de}}if(!Y)return Ho([],W,z,H,G,ne);const ee=X.length>0?X[X.length-1]+1:0,q=zk(U,w,B,ee);if(q.length===0)return null;const oe=z-1,Q=lc([],Ae=>{for(const ze of q){const Ge=ze.value;let se=Ge.offset,de=ze.start;const me=Ge.size;if(Ge.offset<w){de+=Math.floor((w-Ge.offset+H)/(me+H));const be=de-ze.start;se+=be*me+be*H}de<ee&&(se+=(ee-de)*me,de=ee);const ve=Math.min(ze.end,oe);for(let be=de;be<=ve&&!(se>=B);be++)Ae.push({data:I==null?void 0:I[be],index:be,offset:se,size:me}),se+=me+H}}),ye=Ag(A,ei),ce=Ag(A,ti);if(Q.length>0&&(ye>0||ce>0)){const Ae=Q[0],ze=Q[Q.length-1];if(ye>0&&Ae.index>ee){const Ge=Math.min(ye,Ae.index-ee),se=[];let de=Ae.offset;for(let me=Ae.index-1;me>=Ae.index-Ge;me--){const ve=((je=Bl(ae,me,me)[0])==null?void 0:je.value)??Ae.size;de-=ve+H,se.unshift({data:I==null?void 0:I[me],index:me,offset:de,size:ve})}Q.unshift(...se)}if(ce>0&&ze.index<oe){const Ge=Math.min(ce,oe-ze.index);let se=ze.offset+ze.size+H;for(let de=ze.index+1;de<=ze.index+Ge;de++){const me=((Me=Bl(ae,de,de)[0])==null?void 0:Me.value)??ze.size;Q.push({data:I==null?void 0:I[de],index:de,offset:se,size:me}),se+=me+H}}}return Ho(Q,W,z,H,G,ne)}),Ie(w=>w!==null),Ct()),Dd);Re(he(t,Ie(Lf),we(w=>w==null?void 0:w.length)),c),Re(he(M,we(w=>w.topListHeight)),v),Re(v,h),Re(he(M,we(w=>[w.top,w.bottom])),d),Re(he(M,we(w=>w.items)),N);const _=Bn(he(M,Ie(({items:w})=>w.length>0),Fe(c,t),Ie(([{items:w},B])=>w[w.length-1].originalIndex===B-1),we(([,w,B])=>[w-1,B]),Ct(Qs),we(([w])=>w))),D=Bn(he(M,Br(200),Ie(({items:w,topItems:B})=>w.length>0&&w[0].originalIndex===B.length),we(({items:w})=>w[0].index),Ct())),V=Bn(he(M,Ie(({items:w})=>w.length>0),we(({items:w})=>{let B=0,z=w.length-1;for(;w[B].type==="group"&&B<z;)B++;for(;w[z].type==="group"&&z>B;)z--;return{endIndex:w[z].index,startIndex:w[B].index}}),Ct(py)));return{endReached:_,initialItemCount:k,itemsRendered:N,listState:M,minOverscanItemCount:T,rangeChanged:V,startReached:D,topItemsIndexes:C,...b}},Et(vr,gy,$f,li,ai,si,ya,_f),{singleton:!0}),jy=st(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=tt(),d=un(he(Ft(s,t,i,a,c),we(([h,x,m,y,v])=>h+x+m+y+v.offsetBottom+v.bottom)),0);return Re(Be(d),u),{totalListHeight:d,totalListHeightChanged:u}},Et(hn,Ya),{singleton:!0}),Wk=st(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),i=un(he(Ft(s,t,a),Ie(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),Br(0),Ct()),0);return{alignToBottom:s,paddingTopAddition:i}},Et(hn,jy),{singleton:!0}),Sy=st(()=>({context:ge(null)})),qk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,ky=st(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:x},{scrollToIndex:m}])=>{const y=tt();return Re(he(y,Fe(a,x,s,u,c,i,h),Fe(t),we(([[v,b,S,E,C,k,N,T],M])=>{const{calculateViewLocation:_=qk,done:D,...V}=v,w=xy(v,b,E-1),B=Zs(w,b.offsetTree,M)+C+k,z=B+sr(b.sizeTree,w)[1],O=T+k,$=T+S-N,Y=_({itemBottom:z,itemTop:B,locationParams:V,viewportBottom:$,viewportTop:O});return Y!==null?D&&ar(he(d,Ie(X=>!X),Va(Mt(d)?1:2)),D):D==null||D(),Y}),Ie(v=>v!==null)),m),{scrollIntoView:y}},Et(vr,hn,ai,Ya,va),{singleton:!0});function Mg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const Yk=(t,a)=>typeof t=="function"?Mg(t(a)):a&&Mg(t),Kk=st(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:x,propsReady:m},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const E=ge(!1),C=tt();let k=null;function N(D){Ve(d,{align:"end",behavior:D,index:"LAST"})}ct(he(Ft(he(Be(a),Va(1)),x),Fe(Be(E),u,h,v),we(([[D,V],w,B,z,O])=>{let $=V&&z,Y="auto";return $&&(Y=Yk(w,B||O),$=$&&Y!==!1),{followOutputBehavior:Y,shouldFollow:$,totalCount:D}}),Ie(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:V})=>{k!==null&&(k(),k=null),Mt(s)!==void 0?requestAnimationFrame(()=>{Mt(y)("following output to ",{totalCount:V},Yt.DEBUG),N(D)}):k=ar(t,()=>{Mt(y)("following output to ",{totalCount:V},Yt.DEBUG),N(D),k=null})});function T(D){const V=ar(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&k===null&&(Mt(y)("scrolling to bottom due to increased size",{},Yt.DEBUG),N("auto"))});setTimeout(V,100)}ct(he(Ft(Be(E),a,m),Ie(([D,,V])=>D!==!1&&V),hr(({value:D},[,V])=>({refreshed:D===V,value:V}),{refreshed:!1,value:0}),Ie(({refreshed:D})=>D),Fe(E,a)),([,D])=>{Mt(h)&&T(D!==!1)}),ct(C,()=>{T(Mt(E)!==!1)}),ct(Ft(Be(E),c),([D,V])=>{D!==!1&&!V.atBottom&&V.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const M=ge(null),_=tt();return Re(uf(he(Be(i),we(D=>(D==null?void 0:D.length)??0)),he(Be(a))),_),ct(he(Ft(he(_,Va(1)),x),Fe(Be(M),h,v,b),we(([[D,V],w,B,z,O])=>V&&B&&(w==null?void 0:w({context:O,totalCount:D,scrollingInProgress:z}))),Ie(D=>!!D),Br(0)),D=>{k!==null&&(k(),k=null),Mt(s)!==void 0?requestAnimationFrame(()=>{Mt(y)("scrolling into view",{}),Ve(S,D)}):k=ar(t,()=>{Mt(y)("scrolling into view",{}),Ve(S,D),k=null})}),{autoscrollToBottom:C,followOutput:E,scrollIntoViewOnChange:M}},Et(vr,si,ai,li,ya,va,hn,Sy,ky)),Xk=st(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(he(h,Fe(u),Ie(([,x])=>x!==0),Fe(c,i,a,s,t),we(([[,x],m,y,v,b,S=[]])=>by(x,m,y,v,b,S))),d),{}),Et(vr,li,Ya,ya),{singleton:!0}),Qk=st(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ge(0);return ct(he(t,Fe(i),Ie(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{ar(he(s,Va(1),Ie(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Ve(a,c)})})}),{initialScrollTop:i}},Et(ya,hn,Ya),{singleton:!0}),wy=st(([{scrollVelocity:t}])=>{const a=ge(!1),s=tt(),i=ge(!1);return Re(he(t,Fe(i,a,s),Ie(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,h])=>{const{enter:x,exit:m}=u;if(d){if(m(c,h))return!1}else if(x(c,h))return!0;return d}),Ct()),a),ct(he(Ft(a,t,s),Fe(i)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},Et(si),{singleton:!0}),Uf=st(([{scrollContainerState:t,scrollTo:a}])=>{const s=tt(),i=tt(),c=tt(),u=ge(!1),d=ge(void 0);return Re(he(Ft(s,i),we(([{scrollTop:h,viewportHeight:x},{offsetTop:m,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-m),viewportHeight:x}))),t),Re(he(a,Fe(i),we(([h,{offsetTop:x}])=>({...h,top:h.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Et(hn)),Zk=st(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:x}])=>{const m=tt(),y=ge(void 0),v=ge(null),b=ge(null);return Re(h,v),Re(x,b),ct(he(m,Fe(a,i,d,v,b,s)),([S,E,C,k,N,T,M])=>{const _=_k(E.sizeTree);k&&N!==null&&T!==null&&(C=N.scrollTop-T.offsetTop),C-=M,S({ranges:_,scrollTop:C})}),Re(he(y,Ie(Lf),we(Jk)),c),Re(he(u,Fe(y),Ie(([,S])=>S!==void 0),Ct(),we(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:y}},Et(vr,hn,li,ya,Uf));function Jk(t){return{align:"start",index:0,offset:t.scrollTop}}const ew=st(([{topItemsIndexes:t}])=>{const a=ge(0);return Re(he(a,Ie(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Et(Ya));function Cy(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const tw=Cy(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),nw=st(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:x},{beforeUnshiftWith:m,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:E}])=>{const C=Bn(he(x,Fe(d),hr(([,N,T,M],[{bottom:_,items:D,offsetBottom:V,totalCount:w},B])=>{const z=_+V;let O=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(O=z-M,O!==0&&(O+=B))),[O,D,w,z]},[0,[],0,0]),Ie(([N])=>N!==0),Fe(i,h,s,c,S,E),Ie(([,N,T,M,,,_])=>!_&&!M&&N!==0&&T===Js),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Yt.DEBUG),N))));function k(N){N>0?(Ve(a,{behavior:"auto",top:-N}),Ve(t,0)):(Ve(t,0),Ve(a,{behavior:"auto",top:-N}))}return ct(he(C,Fe(t,u)),([N,T,M])=>{M&&tw()?Ve(t,T-N):k(-N)}),ct(he(Ft(un(u,!1),t,E),Ie(([N,T,M])=>!N&&!M&&T!==0),we(([N,T])=>T),Br(1)),k),Re(he(v,we(N=>({top:-N}))),a),ct(he(m,Fe(b,y),we(([N,{groupIndices:T,lastSize:M,sizeTree:_},D])=>{function V($){return $*(M+D)}if(T.length===0)return V(N);let w=0;const B=Xs(_,0);let z=0,O=0;for(;z<N;){z++,w+=B;let $=T.length===O+1?1/0:T[O+1]-T[O]-1;z+$>N&&(w-=B,$=N-z+1),z+=$,w+=V($),O++}return w})),N=>{Ve(t,N),requestAnimationFrame(()=>{Ve(a,{top:N}),requestAnimationFrame(()=>{Ve(t,0),Ve(E,!1)})})}),{deviation:t}},Et(hn,si,Ya,vr,va,_f)),rw=st(([t,a,s,i,c,u,d,h,x,m,y])=>({...t,...a,...s,...i,...c,...u,...d,...h,...x,...m,...y}),Et($f,Xk,ya,wy,jy,Qk,Wk,Uf,ky,va,Sy)),Ey=st(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:x,sizeRanges:m,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:E,initialTopMostItemIndex:C,scrolledToInitialItem:k},N,T,M,_,{scrollToIndex:D},V,{topItemCount:w},{groupCounts:B},z])=>{const{listState:O,minOverscanItemCount:$,topItemsIndexes:Y,rangeChanged:X,...ne}=_;return Re(X,z.scrollSeekRangeChanged),Re(he(z.windowViewportRect,we(H=>H.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:B,heightEstimates:h,initialItemFinalLocationReached:E,initialTopMostItemIndex:C,scrolledToInitialItem:k,sizeRanges:m,topItemCount:w,topItemsIndexes:Y,totalCount:b,...M,groupIndices:d,itemSize:x,listState:O,minOverscanItemCount:$,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...ne,...z,...N,sizes:y,...T}},Et(vr,li,hn,Zk,Kk,Ya,ai,nw,ew,gy,rw));function aw(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const Eo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Ny(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Te.createContext({});function x(k,N){k.propsReady!==void 0&&Ve(k.propsReady,!1);for(const T of i){const M=k[a.required[T]];Ve(M,N[T])}for(const T of c)if(T in N){const M=k[a.optional[T]];Ve(M,N[T])}k.propsReady!==void 0&&Ve(k.propsReady,!0)}function m(k){return u.reduce((N,T)=>(N[T]=M=>{const _=k[a.methods[T]];Ve(_,M)},N),{})}function y(k){return d.reduce((N,T)=>(N[T]=bk(k[a.events[T]]),N),{})}const v=Te.forwardRef(function(k,N){const{children:T,...M}=k,[_]=Te.useState(()=>lc(Sk(t),w=>{x(w,M)})),[D]=Te.useState(jg(y,_));Eo(()=>{for(const w of d)w in M&&ct(D[w],M[w]);return()=>{Object.values(D).map(zf)}},[M,D,_]),Eo(()=>{x(_,M)}),Te.useImperativeHandle(N,bg(m(_)));const V=s;return r.jsx(h.Provider,{value:_,children:s!==void 0?r.jsx(V,{...aw([...i,...c,...d],M),children:T}):T})}),b=k=>{const N=Te.useContext(h);return Te.useCallback(T=>{Ve(N[k],T)},[N,k])},S=k=>{const N=Te.useContext(h)[k],T=Te.useCallback(M=>ct(N,M),[N]);return Te.useSyncExternalStore(T,()=>Mt(N),()=>Mt(N))},E=k=>{const N=Te.useContext(h)[k],[T,M]=Te.useState(jg(Mt,N));return Eo(()=>ct(N,_=>{_!==T&&M(bg(_))}),[N,T]),T},C=parseInt(Te.version)>=18?S:E;return{Component:v,useEmitter:(k,N)=>{const T=Te.useContext(h)[k];Eo(()=>ct(T,N),[N,T])},useEmitterValue:C,usePublisher:b}}const Ty=Te.createContext(void 0),Ry=Te.createContext(void 0),_d="-webkit-sticky",Lg="sticky",Hf=Cy(()=>{if(typeof document>"u")return Lg;const t=document.createElement("div");return t.style.position=_d,t.style.position===_d?_d:Lg}),Ay=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Od(t){return"self"in t}function lw(t){return"body"in t}function My(t,a,s,i=Vl,c,u){const d=Te.useRef(null),h=Te.useRef(null),x=Te.useRef(null),m=Te.useCallback(b=>{let S,E,C;const k=b.target;if(lw(k)||Od(k)){const T=Od(k)?k:k.defaultView;C=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,E=u===!0?T.innerWidth:T.innerHeight}else C=u===!0?k.scrollLeft:k.scrollTop,S=u===!0?k.scrollWidth:k.scrollHeight,E=u===!0?k.offsetWidth:k.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(C,0),viewportHeight:E})};b.suppressFlushSync===!0?N():yS.flushSync(N),h.current!==null&&(C===h.current||C<=0||C===S-E)&&(h.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Te.useEffect(()=>{const b=c||d.current;return i(c||d.current),m({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",m,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",m)}},[d,m,s,i,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const E=b.behavior==="smooth";let C,k,N;Od(S)?(k=Math.max(ha(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),C=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(k=S[u===!0?"scrollWidth":"scrollHeight"],C=ha(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=k-C;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),yy(C,k)||b.top===N){t({scrollHeight:k,scrollTop:N,viewportHeight:C}),E&&a(!0);return}E?(h.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Pf(t){return t}const sw=st(()=>{const t=ge(h=>`Item ${h}`),a=ge(h=>`Group ${h}`),s=ge({}),i=ge(Pf),c=ge("div"),u=ge(Vl),d=(h,x=null)=>un(he(s,we(m=>m[h]),Ct()),x);return{components:s,computeItemKey:i,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),iw=st(([t,a])=>({...t,...a}),Et(Ey,sw)),ow=({height:t})=>r.jsx("div",{style:{height:t}}),cw={overflowAnchor:"none",position:Hf(),zIndex:1},Ly={overflowAnchor:"none"},uw={...Ly,display:"inline-block",height:"100%"},zg=Te.memo(function({showTopList:t=!1}){const a=Ue("listState"),s=Zn("sizeRanges"),i=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Zn("windowScrollContainerState"),d=Zn("scrollContainerState"),h=c||i?u:d,x=Ue("itemContent"),m=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),E=Zn("gap"),C=Ue("horizontalDirection"),{callbackRef:k}=Ck(s,b,v,t?Vl:h,S,E,c,C,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Vf("deviation",ne=>{N!==ne&&T(ne)});const M=Ue("EmptyPlaceholder"),_=Ue("ScrollSeekPlaceholder")??ow,D=Ue("ListComponent"),V=Ue("ItemComponent"),w=Ue("GroupComponent"),B=Ue("computeItemKey"),z=Ue("isSeeking"),O=Ue("groupIndices").length>0,$=Ue("alignToBottom"),Y=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...C?{display:"inline-block",height:"100%",marginLeft:N!==0?N:$?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:$?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...Y?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&M!==null&&M!==void 0?r.jsx(M,{...cn(M,m)}):r.jsx(D,{...cn(D,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:k,style:X,children:(t?a.topItems:a.items).map(ne=>{const H=ne.originalIndex,A=B(H+a.firstItemIndex,ne.data,m);return z?p.createElement(_,{...cn(_,m),height:ne.size,index:ne.index,key:A,type:ne.type||"item",...ne.type==="group"?{}:{groupIndex:ne.groupIndex}}):ne.type==="group"?p.createElement(w,{...cn(w,m),"data-index":H,"data-item-index":ne.index,"data-known-size":ne.size,key:A,style:cw},y(ne.index,m)):p.createElement(V,{...cn(V,m),...mw(V,ne.data),"data-index":H,"data-item-group-index":ne.groupIndex,"data-item-index":ne.index,"data-known-size":ne.size,key:A,style:C?uw:Ly},O?x(ne.index,ne.groupIndex,ne.data,m):x(ne.index,ne.data,m))})})}),dw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},fw={outline:"none",overflowX:"auto",position:"relative"},ic=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),pw={position:Hf(),top:0,width:"100%",zIndex:1};function cn(t,a){if(typeof t!="string")return{context:a}}function mw(t,a){return{item:typeof t=="string"?void 0:a}}const hw=Te.memo(function(){const t=Ue("HeaderComponent"),a=Zn("headerHeight"),s=Ue("HeaderFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null}),xw=Te.memo(function(){const t=Ue("FooterComponent"),a=Zn("footerHeight"),s=Ue("HeaderFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null});function zy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:i,style:c,context:u,...d}){const h=s("scrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:E}=My(h,m,x,y,void 0,v);return t("scrollTo",E),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?fw:dw,...c},tabIndex:0,...d,...cn(x,u),children:i})})}function Dy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:i,style:c,context:u,...d}){const h=s("windowScrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Te.useRef(null),E=a("scrollerRef"),{scrollByCallback:C,scrollerRef:k,scrollToCallback:N}=My(h,m,x,E,b);return Ay(()=>{var T;return k.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{k.current=null}},[k,b]),t("windowScrollTo",N),t("scrollBy",C),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...cn(x,u),children:i})})}const gw=({children:t})=>{const a=Te.useContext(Ty),s=Zn("viewportHeight"),i=Zn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>ly(s,x=>ha(x,u?"width":"height")),[s,u]),h=qa(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:ic(c),children:t})},vw=({children:t})=>{const a=Te.useContext(Ty),s=Zn("windowViewportRect"),i=Zn("fixedItemHeight"),c=Ue("customScrollParent"),u=iy(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:ic(d),children:t})},yw=({children:t})=>{const a=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),i={...pw,marginTop:`${s}px`},c=Ue("context");return r.jsx(a,{style:i,...cn(a,c),children:t})},bw=Te.memo(function(t){const a=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,i=Ue("customScrollParent"),c=Ue("context");return r.jsxs(i||a?kw:Sw,{...t,context:c,children:[s&&r.jsx(yw,{children:r.jsx(zg,{showTopList:!0})}),r.jsxs(i||a?vw:gw,{children:[r.jsx(hw,{}),r.jsx(zg,{}),r.jsx(xw,{})]})]})}),{Component:jw,useEmitter:Vf,useEmitterValue:Ue,usePublisher:Zn}=Ny(iw,{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"}},bw),Sw=zy({useEmitter:Vf,useEmitterValue:Ue,usePublisher:Zn}),kw=Dy({useEmitter:Vf,useEmitterValue:Ue,usePublisher:Zn}),ww=jw,Cw=st(()=>{const t=ge(m=>r.jsxs("td",{children:["Item $",m]})),a=ge(null),s=ge(m=>r.jsxs("td",{colSpan:1e3,children:["Group ",m]})),i=ge(null),c=ge(null),u=ge({}),d=ge(Pf),h=ge(Vl),x=(m,y=null)=>un(he(u,we(v=>v[m]),Ct()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});Et(Ey,Cw);Hf();const Dg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Ew={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_g,floor:Wo,max:Ws,min:Bd,round:Og}=Math;function Bg(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Nw(t){return{...Ew,items:t}}function No(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Tw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Rw=st(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:x,scrollTop:m,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:E,propsReady:C},{customScrollParent:k,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:M,windowViewportRect:_},D])=>{const V=ge(0),w=ge(0),B=ge(Dg),z=ge({height:0,width:0}),O=ge({height:0,width:0}),$=tt(),Y=tt(),X=ge(0),ne=ge(null),H=ge({column:0,row:0}),A=tt(),I=tt(),G=ge(!1),U=ge(0),ae=ge(!0),L=ge(!1),W=ge(!1);ct(he(E,Fe(U),Ie(([ce,je])=>je!==0)),()=>{Ve(ae,!1)}),ct(he(Ft(E,ae,O,z,U,L),Ie(([ce,je,Me,Ae,,ze])=>ce&&!je&&Me.height!==0&&Ae.height!==0&&!ze)),([,,,,ce])=>{Ve(L,!0),Bf(1,()=>{Ve($,ce)}),ar(he(m),()=>{Ve(a,[0,0]),Ve(ae,!0)})}),Re(he(I,Ie(ce=>ce!=null&&ce.scrollTop>0),mr(0)),w),ct(he(E,Fe(I),Ie(([,ce])=>ce!=null)),([,ce])=>{ce&&(Ve(z,ce.viewport),Ve(O,ce.item),Ve(H,ce.gap),ce.scrollTop>0&&(Ve(G,!0),ar(he(m,Va(1)),je=>{Ve(G,!1)}),Ve(x,{top:ce.scrollTop})))}),Re(he(z,we(({height:ce})=>ce)),v),Re(he(Ft(Be(z,No),Be(O,No),Be(H,(ce,je)=>ce!==void 0&&ce.column===je.column&&ce.row===je.row),Be(m)),we(([ce,je,Me,Ae])=>({gap:Me,item:je,scrollTop:Ae,viewport:ce}))),A),Re(he(Ft(Be(V),i,Be(H,Tw),Be(O,No),Be(z,No),Be(ne),Be(w),Be(G),Be(ae),Be(U)),Ie(([,,,,,,,ce])=>!ce),we(([ce,[je,Me],Ae,ze,Ge,se,de,,me,ve])=>{const{column:be,row:Xe}=Ae,{height:pt,width:vt}=ze,{width:$t}=Ge;if(de===0&&(ce===0||$t===0))return Dg;if(vt===0){const it=If(ve,ce),bt=it+Math.max(de-1,0);return Nw(Bg(it,bt,se))}const Nt=_y($t,vt,be);let qe,Lt;me?je===0&&Me===0&&de>0?(qe=0,Lt=de-1):(qe=Nt*Wo((je+Xe)/(pt+Xe)),Lt=Nt*_g((Me+Xe)/(pt+Xe))-1,Lt=Bd(ce-1,Ws(Lt,Nt-1)),qe=Bd(Lt,Ws(0,qe))):(qe=0,Lt=-1);const jt=Bg(qe,Lt,se),{bottom:ut,top:Xt}=Ig(Ge,Ae,ze,jt),xe=_g(ce/Nt),nt=xe*pt+(xe-1)*Xe-ut;return{bottom:ut,itemHeight:pt,items:jt,itemWidth:vt,offsetBottom:nt,offsetTop:Xt,top:Xt}})),B),Re(he(ne,Ie(ce=>ce!==null),we(ce=>ce.length)),V),Re(he(Ft(z,O,B,H),Ie(([ce,je,{items:Me}])=>Me.length>0&&je.height!==0&&ce.height!==0),we(([ce,je,{items:Me},Ae])=>{const{bottom:ze,top:Ge}=Ig(ce,Ae,je,Me);return[Ge,ze]}),Ct(Qs)),a);const ee=ge(!1);Re(he(m,Fe(ee),we(([ce,je])=>je||ce!==0)),ee);const q=Bn(he(Ft(B,V),Ie(([{items:ce}])=>ce.length>0),Fe(ee),Ie(([[ce,je],Me])=>{const Ae=ce.items[ce.items.length-1].index===je-1;return(Me||ce.bottom>0&&ce.itemHeight>0&&ce.offsetBottom===0&&ce.items.length===je)&&Ae}),we(([[,ce]])=>ce-1),Ct())),oe=Bn(he(Be(B),Ie(({items:ce})=>ce.length>0&&ce[0].index===0),mr(0),Ct())),Q=Bn(he(Be(B),Fe(G),Ie(([{items:ce},je])=>ce.length>0&&!je),we(([{items:ce}])=>({endIndex:ce[ce.length-1].index,startIndex:ce[0].index})),Ct(py),Br(0)));Re(Q,S.scrollSeekRangeChanged),Re(he($,Fe(z,O,V,H),we(([ce,je,Me,Ae,ze])=>{const Ge=vy(ce),{align:se,behavior:de,offset:me}=Ge;let ve=Ge.index;ve==="LAST"&&(ve=Ae-1),ve=Ws(0,ve,Bd(Ae-1,ve));let be=hf(je,ze,Me,ve);return se==="end"?be=Og(be-je.height+Me.height):se==="center"&&(be=Og(be-je.height/2+Me.height/2)),me!==void 0&&me!==0&&(be+=me),{behavior:de,top:be}})),x);const ye=un(he(B,we(ce=>ce.offsetBottom+ce.bottom)),0);return Re(he(_,we(ce=>({height:ce.visibleHeight,width:ce.visibleWidth}))),z),{customScrollParent:k,data:ne,deviation:X,footerHeight:c,gap:H,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:O,overscan:s,restoreStateFrom:I,scrollBy:d,scrollContainerState:h,scrollHeight:Y,scrollTo:x,scrollToIndex:$,scrollTop:m,smoothScrollTargetReached:y,totalCount:V,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:M,windowViewportRect:_,...S,gridState:B,horizontalDirection:W,initialTopMostItemIndex:U,totalListHeight:ye,...b,endReached:q,propsReady:C,rangeChanged:Q,startReached:oe,stateChanged:A,stateRestoreInProgress:G,...D}},Et($f,hn,si,wy,ya,Uf,va));function _y(t,a,s){return Ws(1,Wo((t+s)/(Wo(a)+s)))}function Ig(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=hf(t,a,s,i[0].index);return{bottom:hf(t,a,s,i[i.length-1].index)+c,top:u}}function hf(t,a,s,i){const c=_y(t.width,s.width,a.column),u=Wo(i/c),d=u*s.height+Ws(0,u-1)*a.row;return d>0?d+a.row:d}const Aw=st(()=>{const t=ge(v=>`Item ${v}`),a=ge({}),s=ge(null),i=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Pf),d=ge("div"),h=ge(Vl),x=(v,b=null)=>un(he(a,we(S=>S[v]),Ct()),b),m=ge(!1),y=ge(!1);return Re(Be(y),m),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:m,reportReadyState:y,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),Mw=st(([t,a])=>({...t,...a}),Et(Rw,Aw)),Lw=Te.memo(function(){const t=At("gridState"),a=At("listClassName"),s=At("itemClassName"),i=At("itemContent"),c=At("computeItemKey"),u=At("isSeeking"),d=Jn("scrollHeight"),h=At("ItemComponent"),x=At("ListComponent"),m=At("ScrollSeekPlaceholder"),y=At("context"),v=Jn("itemDimensions"),b=Jn("gap"),S=At("log"),E=At("stateRestoreInProgress"),C=Jn("reportReadyState"),k=qa(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const M=N.firstChild;if(M!==null){const{height:_,width:D}=M.getBoundingClientRect();v({height:_,width:D})}b({column:$g("column-gap",getComputedStyle(N).columnGap,S),row:$g("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return Ay(()=>{t.itemHeight>0&&t.itemWidth>0&&C(!0)},[t]),E?null:r.jsx(x,{className:a,ref:k,...cn(x,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?r.jsx(m,{...cn(m,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):p.createElement(h,{...cn(h,y),className:s,"data-index":N.index,key:T},i(N.index,N.data,y))})})}),zw=Te.memo(function(){const t=At("HeaderComponent"),a=Jn("headerHeight"),s=At("headerFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null}),Dw=Te.memo(function(){const t=At("FooterComponent"),a=Jn("footerHeight"),s=At("headerFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null}),_w=({children:t})=>{const a=Te.useContext(Ry),s=Jn("itemDimensions"),i=Jn("viewportDimensions"),c=qa(Te.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Te.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:ic(!1),children:t})},Ow=({children:t})=>{const a=Te.useContext(Ry),s=Jn("windowViewportRect"),i=Jn("itemDimensions"),c=At("customScrollParent"),u=iy(s,c,!1);return Te.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:ic(!1),children:t})},Bw=Te.memo(function({...t}){const a=At("useWindowScroll"),s=At("customScrollParent"),i=s||a?$w:Iw,c=s||a?Ow:_w,u=At("context");return r.jsx(i,{...t,...cn(i,u),children:r.jsxs(c,{children:[r.jsx(zw,{}),r.jsx(Lw,{}),r.jsx(Dw,{})]})})}),{useEmitter:Oy,useEmitterValue:At,usePublisher:Jn}=Ny(Mw,{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"}},Bw),Iw=zy({useEmitter:Oy,useEmitterValue:At,usePublisher:Jn}),$w=Dy({useEmitter:Oy,useEmitterValue:At,usePublisher:Jn});function $g(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Yt.WARN),a==="normal"?0:parseInt(a??"0",10)}const Uw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},By={source:"Own",installed:"Installed"};function Hw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function Pw(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Ug({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=Uw[t],[d,h]=p.useState(()=>Hw(u)),x=p.useCallback(()=>{h(b=>{const S=!b;return Pw(u,S),S})},[u]),m=By[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:x,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(Fw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:m}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),i!=null&&i>0&&r.jsx(Vw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Vw({origin:t,updateCount:a}){const[s,i]=p.useState(!1),c=By[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>i(!0),onBlur:()=>i(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Fw({collapsed:t}){return r.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Ff(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Gw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=p.useRef(null),d=p.useId(),h=!!i&&t.trim()!==""&&!i.test(t);return p.useEffect(()=>{function x(m){var b;if(m.key!=="/")return;const y=m.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(m.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function Ww({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function qw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function Yw({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(Yv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Kw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ii(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",h=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!h.startsWith("v")?`v${h}`:h,m=i==="sm"?10:12,y=i==="sm"?1:2,v=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=Kw(c,h,u),E=t.title??S,C={display:"inline-flex",alignItems:"center",padding:`${y}px ${v}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:m,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(C.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":h,"data-version-source":c,title:E,style:C,children:x})}function Xw({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(d,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(ii,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(Ww,{target:t.symlinkTarget??null}),r.jsx(qw,{skill:t}),r.jsx(Yw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const qo=p.memo(Xw);function Qw({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){const d=[...a].sort((h,x)=>h.skill.localeCompare(x.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:d.map(h=>{const x=!!s&&s.plugin===h.plugin&&s.skill===h.skill;return r.jsx("div",{role:"listitem",children:r.jsx(qo,{skill:h,isSelected:x,onSelect:()=>i(h),onContextMenu:c,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})},`${h.plugin}/${h.skill}`)})})]})}function Zw(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function Hg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,m]=p.useState(()=>Zw(i,s)),y=d?!1:x,v=p.useCallback(()=>{m(E=>{const C=!E;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(C))}catch{}return C})},[i]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(E=>r.jsx("div",{"data-vskill-plugin-skill":E.pluginNamespace??E.skill,children:c(E)},`${E.pluginNamespace??E.skill}`))})]})}function Po({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const x=p.useRef(null),m=p.useRef(null),y=p.useRef(null);if(p.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var E;(E=m.current)==null||E.focus()}),()=>{var E,C;(C=(E=y.current)==null?void 0:E.focus)==null||C.call(E),y.current=null}},[t]),p.useEffect(()=>{if(!t)return;function E(C){if(C.key==="Escape"){C.preventDefault(),h();return}if(C.key==="Tab"&&x.current){const k=x.current.querySelectorAll("button:not([disabled])");if(k.length===0)return;const N=k[0],T=k[k.length-1];C.shiftKey&&document.activeElement===N?(C.preventDefault(),T.focus()):!C.shiftKey&&document.activeElement===T&&(C.preventDefault(),N.focus())}}return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[t,h]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:E=>{E.target===E.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:m,type:"button","data-testid":"confirm-dialog-cancel",onClick:h,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:i})]})]})})}function Jw(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Id(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function eC({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=p.useState(!1),[u,d]=p.useState(null),[h,x]=p.useState(null),[m,y]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{if(!i)return;function E(C){v.current&&!v.current.contains(C.target)&&c(!1)}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[i]);async function b(E){d(E),x(null);try{const C=await fetch(`/api/plugins/${encodeURIComponent(t)}/${E}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),k=await C.json().catch(()=>({}));if(!C.ok||!k.ok){const N=k.error??`${E} failed (${C.status})`;x(N),E==="uninstall"&&Id(`Failed to uninstall ${t}: ${N}`,"error");return}if(E==="uninstall"){const N=k.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Id(N,"success")}On("skills"),ry(),s==null||s(),c(!1)}catch(C){const k=C instanceof Error?C.message:String(C);x(k),E==="uninstall"&&Id(`Failed to uninstall ${t}: ${k}`,"error")}finally{d(null)}}function S(){y(!0)}return r.jsxs("div",{ref:v,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:E=>{E.stopPropagation(),c(C=>!C)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:E=>{E.currentTarget.style.color="var(--text-primary)",E.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:E=>{E.currentTarget.style.color="var(--text-tertiary)",E.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx($d,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx($d,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx($d,{onClick:S,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]}),r.jsx(Po,{open:m,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{y(!1),c(!1)},onConfirm:()=>{y(!1),b("uninstall")}})]})}function $d({onClick:t,disabled:a,busy:s,label:i,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Pg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const h=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=i==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",m=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:x,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:m?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[m&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(tC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return m?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function tC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function nC(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function rC(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const x=h.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?i=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function aC(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function lC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function xf(t,a={}){const{enabled:s=!0,target:i}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(rC),p.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function h(x){const m=x,y=aC(m.target);for(const v of c.current){if(!lC(m,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(m);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,i])}function Iy(){const{data:t,loading:a,error:s,revalidate:i}=Ga("project-github-status",()=>Se.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function sC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function iC({projectRoot:t}){const{status:a,loading:s}=Iy();if(s||!a||a.status==="github"||sC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const oC=200;function cC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function uC(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function i(c){const u=c.filter(x=>Ff(x,a)),d={};for(const x of u){const m=x.pluginName??x.plugin;(d[m]||(d[m]=[])).push(x)}const h=Object.entries(d).sort((x,m)=>x[0].localeCompare(m[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:i(s.authoringProject),authoringPlugin:i(s.authoringPlugin)}}function dC(t,a){const s=[],i=[],c=[];for(const d of t){const h=cC(d);h==="global"?c.push(d):h==="installed"?i.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Ff(v,a)),x={};for(const v of h)(x[y=v.plugin]||(x[y]=[])).push(v);const m=Object.entries(x).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(i),global:u(c)}}function fC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var m;const d=u.filter(y=>Ff(y,a)),h={};for(const y of d)(h[m=y.plugin]||(h[m]=[])).push(y);const x=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function pC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:x,outdatedByScope:m,topSlot:y,revealSkillId:v,onRevealComplete:b,dirtySkillIds:S}){const E=!!x||t.some(q=>q.scope!==void 0&&q.scope!==null),C=x??"claude-cli",[k,N]=p.useState(""),T=p.useDeferredValue(k),M=p.useMemo(()=>dC(t,T),[t,T]),_=p.useMemo(()=>uC(t,T),[t,T]),D=C==="claude-code",{plugins:V}=mk(),w=D?{plugins:V??[]}:void 0,B=p.useMemo(()=>{const q=new Map;for(const oe of(w==null?void 0:w.plugins)??[]){const Q=q.get(oe.name);q.set(oe.name,!!Q||!!oe.enabled)}return q},[w==null?void 0:w.plugins]),[z,O]=p.useState(()=>gf(`vskill-sidebar-${C}-group-available-collapsed`)),[$,Y]=p.useState(()=>gf(`vskill-sidebar-${C}-group-authoring-collapsed`)),X=p.useCallback(q=>{O(q);try{window.localStorage.setItem(`vskill-sidebar-${C}-group-available-collapsed`,String(q))}catch{}},[C]),ne=p.useCallback(q=>{Y(q);try{window.localStorage.setItem(`vskill-sidebar-${C}-group-authoring-collapsed`,String(q))}catch{}},[C]),{own:H,installed:A}=p.useMemo(()=>fC(t,T),[t,T]),G=M.own.filtered+M.installed.filtered+M.global.filtered>=oC,U=p.useMemo(()=>{const q=oe=>{const Q=[];for(const[,ye]of oe){const ce=[...ye].sort((je,Me)=>je.skill.localeCompare(Me.skill));Q.push(...ce)}return Q};return E?[...q(M.own.byPlugin),...q(M.installed.byPlugin),...q(M.global.byPlugin)]:[...q(H.byPlugin),...q(A.byPlugin)]},[E,M.own.byPlugin,M.installed.byPlugin,M.global.byPlugin,H.byPlugin,A.byPlugin]),ae=p.useMemo(()=>a?U.findIndex(q=>q.plugin===a.plugin&&q.skill===a.skill):-1,[U,a]),L=p.useCallback(q=>{if(U.length===0)return;const oe=ae<0?q>0?0:U.length-1:Math.min(Math.max(ae+q,0),U.length-1);s(U[oe])},[U,ae,s]),W=p.useMemo(()=>{if(!v)return null;const[q,oe]=v.split("/");if(!q||!oe)return null;const Q=t.find(je=>je.plugin===q&&je.skill===oe);if(!Q)return{plugin:q,skill:oe,bucket:null,pluginName:null};const ye=Q.source==="plugin"?"plugin":"project",ce=ye==="plugin"?Q.pluginName??q:null;return{plugin:q,skill:oe,bucket:ye,pluginName:ce}},[v,t]),ee=p.useRef(null);return p.useEffect(()=>{if(!v){ee.current=null;return}if(ee.current===v)return;const q=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),oe=document.querySelector(`[data-skill-id="${q}"]`);oe&&(ee.current=v,oe.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),xf([{key:"j",handler:()=>L(1)},{key:"k",handler:()=>L(-1)},{key:"Enter",handler:()=>{ae>=0&&s(U[ae])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(Gw,{value:k,onChange:N}),i&&r.jsx(bC,{}),!i&&c&&r.jsx(jC,{error:c,onRetry:u}),!i&&!c&&E&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Pg,{name:re.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:z,onToggle:X,count:_.availableProject.total+_.availablePersonal.total+_.availablePlugin.total}),!z&&r.jsxs(r.Fragment,{children:[r.jsx(Bs,{label:re.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${C}-available-project-collapsed`,count:_.availableProject.total,filteredCount:k?_.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),headerRightSlot:D?r.jsx(iC,{projectRoot:C}):null,children:_.availableProject.filtered===0?r.jsx(Fg,{queryActive:!!k,agentId:C}):r.jsx(Is,{items:_.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),r.jsx(Bs,{label:re.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${C}-available-personal-collapsed`,count:_.availablePersonal.total,filteredCount:k?_.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:_.availablePersonal.filtered===0?r.jsx(hC,{queryActive:!!k,agentId:C}):r.jsx(Is,{items:_.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),D&&r.jsxs(Bs,{label:re.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${C}-available-plugin-collapsed`,count:_.availablePlugin.total,filteredCount:k?_.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),_.availablePlugin.filtered===0?r.jsx(xC,{queryActive:!!k,hasInstalled:_.availablePlugin.total>0}):_.availablePlugin.byPlugin.map(([q,oe])=>r.jsx(Hg,{pluginName:q,skills:oe,persistKey:`vskill-plugin-available-${q}-collapsed`,headerActionSlot:D?r.jsx(eC,{pluginName:q,enabled:B.get(q)??!0}):void 0,renderSkill:Q=>r.jsx(qo,{skill:Q,isSelected:(a==null?void 0:a.plugin)===Q.plugin&&(a==null?void 0:a.skill)===Q.skill,onSelect:()=>s(Q),onContextMenu:d,dirty:S==null?void 0:S.has(`${Q.plugin}/${Q.skill}`)})},`available-${q}`))]})]}),r.jsx(yC,{}),r.jsx(Pg,{name:re.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:W?!1:$,onToggle:ne,count:_.authoringProject.total+_.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!$||W)&&r.jsxs(r.Fragment,{children:[r.jsx(Bs,{label:re.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${C}-authoring-project-collapsed`,count:_.authoringProject.total,filteredCount:k?_.authoringProject.filtered:null,updateCount:(m==null?void 0:m.own)??(h==null?void 0:h.source),forceOpen:(W==null?void 0:W.bucket)==="project",children:_.authoringProject.filtered===0?r.jsx(Vg,{queryActive:!!k}):r.jsx(Is,{items:_.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),D&&r.jsx(Bs,{label:re.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${C}-authoring-plugin-collapsed`,count:_.authoringPlugin.total,filteredCount:k?_.authoringPlugin.filtered:null,forceOpen:(W==null?void 0:W.bucket)==="plugin",children:_.authoringPlugin.filtered===0?r.jsx(gC,{queryActive:!!k,hasSources:_.authoringPlugin.total>0}):_.authoringPlugin.byPlugin.map(([q,oe])=>r.jsx(Hg,{pluginName:q,skills:oe,persistKey:`vskill-plugin-authoring-${q}-collapsed`,forceOpen:(W==null?void 0:W.bucket)==="plugin"&&W.pluginName===q,renderSkill:Q=>r.jsx(qo,{skill:Q,isSelected:(a==null?void 0:a.plugin)===Q.plugin&&(a==null?void 0:a.skill)===Q.skill,onSelect:()=>s(Q),onContextMenu:d,dirty:S==null?void 0:S.has(`${Q.plugin}/${Q.skill}`)})},`authoring-${q}`))})]})]}),!i&&!c&&!E&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ug,{origin:"source",count:H.total,filteredCount:k?H.filtered:null,updateCount:h==null?void 0:h.source,children:H.filtered===0?r.jsx(Vg,{queryActive:!!k}):r.jsx(Is,{items:H.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),r.jsx(vC,{}),r.jsx(Ug,{origin:"installed",count:A.total,filteredCount:k?A.filtered:null,updateCount:h==null?void 0:h.installed,children:A.filtered===0?r.jsx(Fg,{queryActive:!!k}):r.jsx(Is,{items:A.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})})]})]})}function gf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Bs({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:h}){const[x,m]=p.useState(()=>gf(a)),y=d?!1:x,v=p.useCallback(()=>{m(S=>{const E=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(E))}catch{}return E})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:y?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),h]}),!y&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function mC(t){const a=[];for(const[s,i]of t){const c=[...i].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Is({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=mC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(ww,{overscan:4,totalCount:d.length,itemContent:h=>{const x=d[h];if(!x)return null;if(x.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const m=x.skill,y=!!a&&a.plugin===m.plugin&&a.skill===m.skill;return r.jsx(qo,{skill:m,isSelected:y,onSelect:()=>s(m),onContextMenu:i,dirty:u==null?void 0:u.has(`${m.plugin}/${m.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,h])=>r.jsx(Qw,{plugin:d,skills:h,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Vg({queryActive:t}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(oi,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Fg({queryActive:t,agentId:a}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(oi,{children:"vskill install <skill>"})," to add one."]})})}function hC({queryActive:t,agentId:a}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(oi,{children:"vskill install --global <skill>"})," to add one."]})})}function xC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx(oi,{children:"Browse marketplaces…"})," above to add one."]})})}function gC({queryActive:t,hasSources:a}){return t&&a?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx(oi,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one."]})})}function gr({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function oi({children:t}){return r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function vC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function yC(){return r.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function bC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(nC,{},t))})}function jC({error:t,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:SC(t)}),r.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),a&&r.jsx("button",{type:"button",onClick:a,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function SC(t){const a=t.split(`
|
|
65
|
+
}`})]})}function fg(){typeof window>"u"||(window.location.hash="#/")}function V2({onHome:t}){const[a,s]=p.useState(!1),[i,c]=p.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),fg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),fg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:i?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const pg=p.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function F2({toast:t,onDismiss:a}){const[s,i]=p.useState(!0),c=p.useRef(null);p.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function G2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(pg,{politeness:"polite",message:s}),r.jsx(pg,{politeness:"assertive",message:i}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(F2,{toast:c,onDismiss:a})},c.id))})]})}const Jv=p.createContext(null);function nc(){const t=p.useContext(Jv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function W2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=p.useState([]),[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(new Map),y=p.useCallback(k=>{const N=m.current.get(k);N&&(clearTimeout(N),m.current.delete(k)),c(T=>T.filter(M=>M.id!==k))},[]),v=p.useCallback((k,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(k)},N);m.current.set(k,T)},[y]),b=p.useCallback(k=>{const N=k.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:k.message,severity:k.severity??"info",durationMs:k.durationMs??s,action:k.action};return c(M=>[...M,T]),T.severity==="error"?x(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=p.useCallback(()=>{for(const k of m.current.values())clearTimeout(k);m.current.clear(),c([])},[]);p.useEffect(()=>{function k(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const M=T.slice(0,a),_=M[M.length-1],D=m.current.get(_.id);return D&&(clearTimeout(D),m.current.delete(_.id)),T.filter(V=>V.id!==_.id)})}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[a]),p.useEffect(()=>()=>{for(const k of m.current.values())clearTimeout(k);m.current.clear()},[]);const E=i.slice(0,a),C=p.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(Jv.Provider,{value:C,children:[t,r.jsx(G2,{toasts:E,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function q2(){const{data:t,loading:a}=Ga("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const Y2=p.lazy(()=>Fa(()=>import("./UpdateDropdown-DSgTqcY2.js"),__vite__mapDeps([0,1])));function K2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:h,activeAgent:x}=ir(),{toast:m}=nc(),{data:y}=q2(),v=(y==null?void 0:y.degraded)===!0,b=p.useMemo(()=>{if(!h||h.size===0)return;const V=new Map;for(const[w,B]of h)B.diffSummary&&V.set(w,B.diffSummary);return V.size>0?V:void 0},[h]),[S,E]=p.useState(!1),C=p.useRef(null),k=p.useCallback(()=>E(!1),[]),N=v?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),M=t===0?"No updates available":`${t} updates available, open summary`,_=v?`${M} — platform crawler degraded`:M,D=v?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:C,type:"button","data-testid":"update-bell","aria-label":_,"aria-haspopup":"dialog","aria-expanded":S,title:D,onClick:()=>E(V=>!V),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||v?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:T})]}),S&&r.jsx(p.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(Y2,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:V=>{const w=V.localSkill??V.name.split("/").pop()??"",B=V.localPlugin??"";if(u)u(B,w);else{const O=V.name.split("/"),$=O.length>=2?O[O.length-2]:O[0];c({plugin:$,skill:w,origin:"installed"})}if(!(d??[]).some(O=>O.skill===w&&(B===""||O.plugin===B))){const O=V.installLocations??[];if(O.length>0){const $=x?O.filter(X=>X.agent===x):[],Y=x?O.filter(X=>X.agent!==x):O;if($.length>0&&Y.length>0){const X=Y.length>=2?`Also installed under ${Y.length} other locations.`:`Also installed under ${Y[0].agentLabel}.`;m({severity:"info",message:X})}else{const X=O[0].agentLabel;m({severity:"info",message:`Skill installed under ${X} — switch to ${X} to view details.`})}}}k()},onViewAll:()=>{window.location.hash="#/updates",k()},onClose:k,anchorRef:C})})]})}function mg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function X2({projectName:t,selected:a,onOpenPalette:s,onHome:i,projectPickerSlot:c,onRequestCreateSkill:u,findSkillsSlot:d}){const h=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(V2,{onHome:i}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&h&&r.jsxs(r.Fragment,{children:[r.jsx(hg,{segment:"origin",onClick:()=>mg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:h}),r.jsx(xg,{}),r.jsx(hg,{segment:"plugin",onClick:()=>mg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(xg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[d,u&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(H2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(K2,{})}),r.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:r.jsx("span",{children:"⌘K"})})]})]})}function hg({segment:t,onClick:a,style:s,children:i}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:i})}function xg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const rc="vskill-theme";function ey(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function Q2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function Z2(t){try{const a=t.getItem(rc);return ey(a)}catch{return"auto"}}function J2(t,a){try{t.setItem(rc,a)}catch{}}function ek(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function tk(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const ty=p.createContext(null);function nk({storage:t,matchMedia:a,target:s,children:i}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,x]=p.useState(()=>c?Z2(c):"auto"),[m,y]=p.useState(()=>tk(u)),v=p.useMemo(()=>Q2(h,m),[h,m]);p.useEffect(()=>{d&&ek(d,h,v)},[d,h,v]),p.useEffect(()=>{if(!u)return;const E=u("(prefers-color-scheme: dark)"),C=N=>y(N.matches);if(typeof E.addEventListener=="function")return E.addEventListener("change",C),()=>E.removeEventListener("change",C);const k=E;return k.addListener(C),()=>k.removeListener(C)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const E=C=>{C.key===rc&&x(ey(C.newValue))};return window.addEventListener("storage",E),()=>window.removeEventListener("storage",E)},[]),p.useEffect(()=>{if(!u||!d)return;let E;try{E=u("(prefers-contrast: more)")}catch{return}const C=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};C(E.matches);const k=T=>C(T.matches);if(typeof E.addEventListener=="function")return E.addEventListener("change",k),()=>E.removeEventListener("change",k);const N=E;return N.addListener(k),()=>N.removeListener(k)},[u,d]);const b=p.useCallback(E=>{x(E),c&&J2(c,E)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(ty.Provider,{value:S,children:i})}function ny(){const t=p.useContext(ty);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const gg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function rk(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of gg){const c=a.get(i);c&&s.push(c)}for(const i of t)gg.includes(i.id)||s.push(i);return s}function ak(t){const[a,s]=p.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return p.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function lk({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=rk(t),c=ak(640),[u,d]=p.useState(!1),h=p.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=i.filter(m=>m.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":re.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:re.statusBar.providerSummary(x,i.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:i.map(m=>r.jsx(vg,{p:m,onClick:h},m.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(x=>r.jsx(vg,{p:x,onClick:h,compact:!0},x.id))})}function vg({p:t,onClick:a,compact:s}){const i=t.available?re.statusBar.unlocked(t.label):t.kind==="cli-install"?re.statusBar.lockedCli(t.label):re.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(of,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function sk(){try{return typeof localStorage>"u"?null:localStorage.getItem(rc)}catch{return null}}function ik({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:x,setTheme:m}=ny(),v=sk()==="auto",b=ok(h,x,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(yg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(ck,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(yg,{}),r.jsx(lk,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>m(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[r.jsx(uk,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function ok(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function ck({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function yg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function uk({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const cf=new Set;function ry(){for(const t of cf)t()}const dk=5,fk=1e3,pk=6e4;function mk(){const[t,a]=p.useState(void 0),[s,i]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),h=p.useRef(null),x=p.useRef(null),m=p.useRef(!0),y=p.useRef(0),[v,b]=p.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},E=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),C=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;E();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!m.current)return;const M=await T.json();if(!m.current)return;d.current=0,a(M.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{m.current&&b(_=>_+1)},pk)}catch(T){if(!m.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>dk){i(!0);return}const M=fk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{m.current&&b(_=>_+1)},M)}},[E]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),E()}),[E]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),C())},[v,C]),p.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),E()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[E]);const k=p.useCallback(()=>{d.current=0,i(!1),S(),y.current+=1,b(N=>N+1)},[]);return p.useEffect(()=>(cf.add(k),()=>{cf.delete(k)}),[k]),{plugins:t,paused:s,loading:c,retry:k}}const ac=0,ga=1,Pl=2,ay=4;function bg(t){return()=>t}function hk(t){t()}function ly(t,a){return s=>t(a(s))}function jg(t,a){return()=>t(a)}function xk(t,a){return s=>t(a,s)}function Lf(t){return t!==void 0}function gk(...t){return()=>{t.map(hk)}}function Vl(){}function lc(t,a){return a(t),t}function vk(t,a){return a(t)}function Et(...t){return t}function ct(t,a){return t(ga,a)}function Ve(t,a){t(ac,a)}function zf(t){t(Pl)}function Mt(t){return t(ay)}function Re(t,a){return ct(t,xk(a,ac))}function ar(t,a){const s=t(ga,i=>{s(),a(i)});return s}function Sg(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function sy(t,a){return t===a}function Ct(t=sy){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function Ie(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>ly(a,t)}function mr(t){return a=>()=>{a(t)}}function he(t,...a){const s=yk(...a);return((i,c)=>{switch(i){case Pl:zf(t);return;case ga:return ct(t,s(c))}})}function hr(t,a){return s=>i=>{s(a=t(a,i))}}function Va(t){return a=>s=>{t>0?t--:a(s)}}function Br(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function Fe(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;ct(u,x=>{const m=s;s|=h,a[d]=x,m!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():i=h}}function yk(...t){return a=>t.reduceRight(vk,a)}function bk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ga:return u?s===u?void 0:(i(),s=u,a=ct(t,u),a):(i(),Vl);case Pl:i(),s=null;return}}}function ge(t){let a=t;const s=tt();return((i,c)=>{switch(i){case ac:a=c;break;case ga:{c(a);break}case ay:return a}return s(i,c)})}function un(t,a){return lc(ge(a),s=>Re(t,s))}function tt(){const t=[];return((a,s)=>{switch(a){case ac:t.slice().forEach(i=>{i(s)});return;case Pl:t.splice(0,t.length);return;case ga:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function Bn(t){return lc(tt(),a=>Re(t,a))}function st(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:jk(),singleton:s}}const jk=()=>Symbol();function Sk(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=i(c.map(x=>s(x)));return d&&a.set(u,h),h};return s(t)}function Ft(...t){const a=tt(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;ct(u,x=>{s[d]=x,i|=h,i===c&&Ve(a,s)})}),function(u,d){switch(u){case Pl:{zf(a);return}case ga:return i===c&&d(s),ct(a,d)}}}function Be(t,a=sy){return he(t,Ct(a))}function uf(...t){return function(a,s){switch(a){case Pl:return;case ga:return gk(...t.map(i=>ct(i,s)))}}}const Yt={DEBUG:0,INFO:1,WARN:2,ERROR:3},kk={[Yt.DEBUG]:"debug",[Yt.ERROR]:"error",[Yt.INFO]:"log",[Yt.WARN]:"warn"},wk=()=>typeof globalThis>"u"?window:globalThis,va=st(()=>{const t=ge(Yt.ERROR);return{log:ge((a,s,i=Yt.INFO)=>{const c=wk().VIRTUOSO_LOG_LEVEL??Mt(t);i>=c&&console[kk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function qa(t,a,s){return Df(t,a,s).callbackRef}function Df(t,a,s){const i=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function Ck(t,a,s,i,c,u,d,h,x){const m=Te.useCallback(y=>{const v=Ek(y.children,a,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let E;S&&(E=b.ownerDocument.defaultView);const C=d?h?d.scrollLeft:d.scrollTop:S?h?E.scrollX||E.document.documentElement.scrollLeft:E.scrollY||E.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,k=d?h?d.scrollWidth:d.scrollHeight:S?h?E.document.documentElement.scrollWidth:E.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?E.innerWidth:E.innerHeight:h?b.offsetWidth:b.offsetHeight;i({scrollHeight:k,scrollTop:Math.max(C,0),viewportHeight:N}),u==null||u(h?kg("column-gap",getComputedStyle(y).columnGap,c):kg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,i,h]);return Df(m,s,x)}function Ek(t,a,s,i){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const x=parseInt(h.dataset.index),m=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&i("Zero-sized element, this should not happen",{child:h},Yt.ERROR),y===m)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==x-1?u.push({endIndex:x,size:y,startIndex:x}):u[u.length-1].endIndex++}return u}function kg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Yt.WARN),a==="normal"?0:parseInt(a??"0",10)}function iy(t,a,s){const i=Te.useRef(null),c=Te.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const m=x.getBoundingClientRect(),y=m.width;let v,b;if(a){const S=a.getBoundingClientRect(),E=m.top-S.top;b=S.height-Math.max(0,E),v=E+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),v=m.top+S.scrollY}i.current={listHeight:m.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Df(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var m;if(a){a.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(a),()=>{a.removeEventListener("scroll",h),y.unobserve(a)}}const x=(m=d.current)==null?void 0:m.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",h),x==null||x.addEventListener("resize",h),()=>{x==null||x.removeEventListener("scroll",h),x==null||x.removeEventListener("resize",h)}},[h,a,d]),u}const hn=st(()=>{const t=tt(),a=tt(),s=ge(0),i=tt(),c=ge(0),u=tt(),d=tt(),h=ge(0),x=ge(0),m=ge(0),y=ge(0),v=tt(),b=tt(),S=ge(!1),E=ge(!1),C=ge(!1);return Re(he(t,we(({scrollTop:k})=>k)),a),Re(he(t,we(({scrollHeight:k})=>k)),d),Re(a,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:x,footerHeight:y,headerHeight:h,horizontalDirection:E,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:C,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Ks={lvl:0};function oy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:x}=a(t[d]);u.push({end:h-1,start:i,value:c}),i=h,c=x}return u.push({end:1/0,start:i,value:c}),u}function gt(t){return t===Ks}function Xs(t,a){if(!gt(t))return a===t.k?t.v:a<t.k?Xs(t.l,a):Xs(t.r,a)}function sr(t,a,s="k"){if(gt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=sr(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return sr(t.l,a,s)}function _n(t,a,s){return gt(t)?dy(a,s,1):a===t.k?qt(t,{k:a,v:s}):a<t.k?wg(qt(t,{l:_n(t.l,a,s)})):wg(qt(t,{r:_n(t.r,a,s)}))}function Ol(){return Ks}function Bl(t,a,s){if(gt(t))return[];const i=sr(t,a)[0];return Nk(ff(t,i,s))}function df(t,a){if(gt(t))return Ks;const{k:s,l:i,r:c}=t;if(a===s){if(gt(i))return c;if(gt(c))return i;const[u,d]=uy(i);return Uo(qt(t,{k:u,l:cy(i),v:d}))}return a<s?Uo(qt(t,{l:df(i,a)})):Uo(qt(t,{r:df(c,a)}))}function Pa(t){return gt(t)?[]:[...Pa(t.l),{k:t.k,v:t.v},...Pa(t.r)]}function ff(t,a,s){if(gt(t))return[];const{k:i,l:c,r:u,v:d}=t;let h=[];return i>a&&(h=h.concat(ff(c,a,s))),i>=a&&i<=s&&h.push({k:i,v:d}),i<=s&&(h=h.concat(ff(u,a,s))),h}function Uo(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(zd(a))return fy(qt(t,{lvl:s-1}));if(!gt(a)&&!gt(a.r))return qt(a.r,{l:qt(a,{r:a.r.l}),lvl:s,r:qt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(zd(t))return pf(qt(t,{lvl:s-1}));if(!gt(i)&&!gt(i.l)){const c=i.l,u=zd(c)?i.lvl-1:i.lvl;return qt(c,{l:qt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:pf(qt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function qt(t,a){return dy(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function cy(t){return gt(t.r)?t.l:Uo(qt(t,{r:cy(t.r)}))}function zd(t){return gt(t)||t.lvl>t.r.lvl}function uy(t){return gt(t.r)?[t.k,t.v]:uy(t.r)}function dy(t,a,s,i=Ks,c=Ks){return{k:t,l:i,lvl:s,r:c,v:a}}function wg(t){return pf(fy(t))}function fy(t){const{l:a}=t;return!gt(a)&&a.lvl===t.lvl?qt(a,{r:qt(t,{l:a.r})}):t}function pf(t){const{lvl:a,r:s}=t;return!gt(s)&&!gt(s.r)&&s.lvl===a&&s.r.lvl===a?qt(s,{l:qt(t,{r:s.l}),lvl:a+1}):t}function Nk(t){return oy(t,({k:a,v:s})=>({index:a,value:s}))}function py(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Qs(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const _f=st(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function my(t,a,s){return t[Go(t,a,s)]}function Go(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Tk(t,a,s,i){const c=Go(t,a,i),u=Go(t,s,i,c);return t.slice(c,u+1)}function ha(t,a){return Math.round(t.getBoundingClientRect()[a])}function sc(t){return!gt(t.groupOffsetTree)}function Of({index:t},a){return a===t?0:a<t?-1:1}function Rk(){return{groupIndices:[],groupOffsetTree:Ol(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ol()}}function Ak(t,a){let s=gt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),gt(t)){t=_n(t,0,u);continue}const h=Bl(t,d-1,c+1);if(h.some(Bk(i)))continue;let x=!1,m=!1;for(const{end:y,start:v,value:b}of h)x?(c>=v||u===b)&&(t=df(t,v)):(m=b!==u,x=!0),y>c&&c>=v&&b!==u&&(t=_n(t,c+1,b));m&&(t=_n(t,d,u))}return[t,s]}function Mk(t){return typeof t.groupIndex<"u"}function Lk({offset:t},a){return a===t?0:a<t?-1:1}function Zs(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=my(a,t,Of),d=t-i,h=u*d+(d-1)*s+c;return h>0?h+s:h}function hy(t,a){if(!sc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function xy(t,a,s){if(Mk(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=hy(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function zk(t,a,s,i=0){return i>0&&(a=Math.max(a,my(t,i,Of).offset)),oy(Tk(t,a,s,Lk),Ok)}function Dk(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Yt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&>(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((E,C)=>_n(_n(E,C,b),C+1,S),d)}else[d,h]=Ak(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:m,lastSize:y,offsetTree:v}=mf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>_n(b,S,Zs(S,v,c)),Ol()),lastIndex:x,lastOffset:m,lastSize:y,offsetTree:v,sizeTree:d}}function _k(t){return Pa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Cg(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function mf(t,a,s,i){let c=t,u=0,d=0,h=0,x=0;if(a!==0){x=Go(c,a-1,Of),h=c[x].offset;const m=sr(s,a-1);u=m[0],d=m[1],c.length&&c[x].size===sr(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:m,value:y}of Bl(s,a,1/0)){const v=m-u,b=v*d+h+v*i;c.push({index:m,offset:b,size:y}),u=m,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function Ok(t){return{index:t.index,value:t}}function Bk(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Ik={offsetHeight:"height",offsetWidth:"width"},vr=st(([{log:t},{recalcInProgress:a}])=>{const s=tt(),i=tt(),c=un(i,0),u=tt(),d=tt(),h=ge(0),x=ge([]),m=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),S=ge((w,B)=>ha(w,Ik[B])),E=ge(void 0),C=ge(0),k=Rk(),N=un(he(s,Fe(x,t,C),hr(Dk,k),Ct()),k),T=un(he(x,Ct(),hr((w,B)=>({current:B,prev:w.current}),{current:[],prev:[]}),we(({prev:w})=>w)),[]);Re(he(x,Ie(w=>w.length>0),Fe(N,C),we(([w,B,z])=>{const O=w.reduce(($,Y,X)=>_n($,Y,Zs(Y,B.offsetTree,z)||X),Ol());return{...B,groupIndices:w,groupOffsetTree:O}})),N),Re(he(i,Fe(N),Ie(([w,{lastIndex:B}])=>w<B),we(([w,{lastIndex:B,lastSize:z}])=>[{endIndex:B,size:z,startIndex:w}])),s),Re(m,y);const M=un(he(m,we(w=>w===void 0)),!0);Re(he(y,Ie(w=>w!==void 0&>(Mt(N).sizeTree)),we(w=>{const B=Mt(v),z=Mt(x).length>0;return B!==void 0&&B!==0?z?[{endIndex:0,size:B,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(he(b,Ie(w=>w!==void 0&&w.length>0&>(Mt(N).sizeTree)),we(w=>{const B=[];let z=w[0],O=0;for(let $=1;$<w.length;$++){const Y=w[$];Y!==z&&(B.push({endIndex:$-1,size:z,startIndex:O}),z=Y,O=$)}return B.push({endIndex:w.length-1,size:z,startIndex:O}),B})),s),Re(he(x,Fe(v,y),Ie(([,w,B])=>w!==void 0&&B!==void 0),we(([w,B,z])=>{const O=[];for(let $=0;$<w.length;$++){const Y=w[$],X=w[$+1];O.push({startIndex:Y,endIndex:Y,size:B}),X!==void 0&&O.push({startIndex:Y+1,endIndex:X-1,size:z})}return O})),s);const _=Bn(he(s,Fe(N),hr(({sizes:w},[B,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:k}),we(w=>w.changed)));ct(he(h,hr((w,B)=>({diff:w.prev-B,prev:B}),{diff:0,prev:0}),we(w=>w.diff)),w=>{const{groupIndices:B}=Mt(N);if(w>0)Ve(a,!0),Ve(u,w+Cg(w,B));else if(w<0){const z=Mt(T);z.length>0&&(w-=Cg(-w,z)),Ve(d,w)}}),ct(he(h,Fe(t)),([w,B])=>{w<0&&B("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Yt.ERROR)});const D=Bn(u);Re(he(u,Fe(N),we(([w,B])=>{const z=B.groupIndices.length>0,O=[],$=B.lastSize;if(z){const Y=Xs(B.sizeTree,0);let X=0,ne=0;for(;X<w;){const A=B.groupIndices[ne],I=B.groupIndices.length===ne+1?1/0:B.groupIndices[ne+1]-A-1;O.push({endIndex:A,size:Y,startIndex:A}),O.push({endIndex:A+1+I-1,size:$,startIndex:A+1}),ne++,X+=I+1}const H=Pa(B.sizeTree);return X!==w&&H.shift(),H.reduce((A,{k:I,v:G})=>{let U=A.ranges;return A.prevSize!==0&&(U=[...A.ranges,{endIndex:I+w-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:I+w,prevSize:G,ranges:U}},{prevIndex:w,prevSize:0,ranges:O}).ranges}return Pa(B.sizeTree).reduce((Y,{k:X,v:ne})=>({prevIndex:X+w,prevSize:ne,ranges:[...Y.ranges,{endIndex:X+w-1,size:Y.prevSize,startIndex:Y.prevIndex}]}),{prevIndex:0,prevSize:$,ranges:[]}).ranges})),s);const V=Bn(he(d,Fe(N,C),we(([w,{offsetTree:B},z])=>{const O=-w;return Zs(O,B,z)})));return Re(he(d,Fe(N,C),we(([w,B,z])=>{if(B.groupIndices.length>0){if(gt(B.sizeTree))return B;let $=Ol();const Y=Mt(T);let X=0,ne=0,H=0;for(;X<-w;){H=Y[ne];const A=Y[ne+1]-H-1;ne++,X+=A+1}if($=Pa(B.sizeTree).reduce((A,{k:I,v:G})=>_n(A,Math.max(0,I+w),G),$),X!==-w){const A=Xs(B.sizeTree,H);$=_n($,0,A);const I=sr(B.sizeTree,-w+1)[1];$=_n($,1,I)}return{...B,sizeTree:$,...mf(B.offsetTree,0,$,z)}}const O=Pa(B.sizeTree).reduce(($,{k:Y,v:X})=>_n($,Math.max(0,Y+w),X),Ol());return{...B,sizeTree:O,...mf(B.offsetTree,0,O,z)}})),N),{beforeUnshiftWith:D,data:E,defaultItemSize:y,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:v,gap:C,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:_,shiftWith:d,shiftWithOffset:V,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:M,unshiftWith:u}},Et(va,_f),{singleton:!0});function $k(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const gy=st(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=tt(),d=tt(),h=Bn(he(u,we($k)));return Re(he(h,we(x=>x.totalCount)),s),Re(he(h,we(x=>x.groupIndices)),t),Re(he(Ft(c,a,i),Ie(([x,m])=>sc(m)),we(([x,m,y])=>sr(m.groupOffsetTree,Math.max(x-y,0),"v")[0]),Ct(),we(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},Et(vr,hn)),ya=st(([{log:t}])=>{const a=ge(!1),s=Bn(he(a,Ie(i=>i),Ct()));return ct(a,i=>{i&&Mt(t)("props updated",{},Yt.DEBUG)}),{didMount:s,propsReady:a}},Et(va),{singleton:!0}),Uk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function vy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!Uk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ai=st(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:x,scrollTo:m,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=tt(),E=tt(),C=ge(0);let k=null,N=null,T=null;function M(){k!==null&&(k(),k=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Ve(x,!1)}return Re(he(S,Fe(s,v,i,C,h,d,b),Fe(t,u,c),we(([[_,D,V,w,B,z,O,$],Y,X,ne])=>{const H=vy(_),{align:A,behavior:I,offset:G}=H,U=w-1,ae=xy(H,D,U);let L=Zs(ae,D.offsetTree,Y)+z;A==="end"?(L+=X+sr(D.sizeTree,ae)[1]-V+ne,ae===U&&(L+=O)):A==="center"?L+=(X+sr(D.sizeTree,ae)[1]-V+ne)/2:L-=B,G!==void 0&&G!==0&&(L+=G);const W=ee=>{M(),ee?($("retrying to scroll to",{location:_},Yt.DEBUG),Ve(S,_)):(Ve(E,!0),$("list did not change, scroll successful",{},Yt.DEBUG))};if(M(),I==="smooth"){let ee=!1;T=ct(a,q=>{ee=ee||q}),k=ar(y,()=>{W(ee)})}else k=ar(he(a,Hk(150)),W);return N=setTimeout(()=>{M()},1200),Ve(x,!0),$("scrolling from index to",{behavior:I,index:ae,top:L},Yt.DEBUG),{behavior:I,top:L}})),m),{scrollTargetReached:E,scrollToIndex:S,topListHeight:C}},Et(vr,hn,va),{singleton:!0});function Hk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Bf(t,a){t===0?a():requestAnimationFrame(()=>{Bf(t-1,a)})}function If(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const li=st(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),x=ge(0),m=ge(!0);return Re(he(d,Fe(x),Ie(([y,v])=>v!==0),mr(!1)),h),Re(he(d,Fe(x),Ie(([y,v])=>v!==0),mr(!1)),m),ct(he(Ft(a,d),Fe(h,s,t,m),Ie(([[,y],v,{sizeTree:b},S,E])=>y&&(!gt(b)||Lf(S))&&!v&&!E),Fe(x)),([,y])=>{ar(c,()=>{Ve(m,!0)}),Bf(4,()=>{ar(i,()=>{Ve(h,!0)}),Ve(u,y)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:x,scrolledToInitialItem:h}},Et(vr,hn,ai,ya),{singleton:!0});function yy(t,a){return Math.abs(t-a)<1.01}const Js="up",Gs="down",Pk="none",Vk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Fk=0,si=st(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),x=tt(),m=tt(),y=ge(4),v=ge(Fk),b=un(he(uf(he(Be(c),Va(1),mr(!0)),he(Be(c),Va(1),mr(!1),Sg(100))),Ct()),!1),S=un(he(uf(he(s,mr(!0)),he(s,mr(!1),Sg(200))),Ct()),!1);Re(he(Ft(Be(c),Be(v)),we(([T,M])=>T<=M),Ct()),h),Re(he(h,Br(50)),m);const E=Bn(he(Ft(i,Be(u),Be(a),Be(t),Be(y)),hr((T,[{scrollHeight:M,scrollTop:_},D,V,w,B])=>{const z=_+D-M>-B,O={scrollHeight:M,scrollTop:_,viewportHeight:D};if(z){let Y,X;return _>T.state.scrollTop?(Y="SCROLLED_DOWN",X=T.state.scrollTop-_):(Y="SIZE_DECREASED",X=T.state.scrollTop-_||T.scrollTopDelta),{atBottom:!0,atBottomBecause:Y,scrollTopDelta:X,state:O}}let $;return O.scrollHeight>T.state.scrollHeight?$="SIZE_INCREASED":D<T.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":_<T.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:O}},Vk),Ct((T,M)=>T!==void 0&&T.atBottom===M.atBottom))),C=un(he(i,hr((T,{scrollHeight:M,scrollTop:_,viewportHeight:D})=>{if(!yy(T.scrollHeight,M)){const V=M-(_+D)<1;return T.scrollTop!==_&&V?{changed:!0,jump:T.scrollTop-_,scrollHeight:M,scrollTop:_}:{changed:!0,jump:0,scrollHeight:M,scrollTop:_}}return{changed:!1,jump:0,scrollHeight:M,scrollTop:_}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(T=>T.changed),we(T=>T.jump)),0);Re(he(E,we(T=>T.atBottom)),d),Re(he(d,Br(50)),x);const k=ge(Gs);Re(he(i,we(({scrollTop:T})=>T),Ct(),hr((T,M)=>Mt(S)?{direction:T.direction,prevScrollTop:M}:{direction:M<T.prevScrollTop?Js:Gs,prevScrollTop:M},{direction:Gs,prevScrollTop:0}),we(T=>T.direction)),k),Re(he(i,Br(50),mr(Pk)),k);const N=ge(0);return Re(he(b,Ie(T=>!T),mr(0)),N),Re(he(c,Br(100),Fe(b),Ie(([T,M])=>M),hr(([T,M],[_])=>[M,_],[0,0]),we(([T,M])=>M-T)),N),{atBottomState:E,atBottomStateChange:x,atBottomThreshold:y,atTopStateChange:m,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:C,scrollDirection:k,scrollVelocity:N}},Et(hn)),ei="top",ti="bottom",Eg="none";function Ng(t,a,s){return typeof t=="number"?s===Js&&a===ei||s===Gs&&a===ti?t:0:s===Js?a===ei?t.main:t.reverse:a===ti?t.main:t.reverse}function Tg(t,a){return typeof t=="number"?t:t[a]??0}const $f=st(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=tt(),d=ge(0),h=ge(0),x=ge(0),m=un(he(Ft(Be(i),Be(c),Be(s),Be(u,Qs),Be(x),Be(d),Be(a),Be(t),Be(h)),we(([y,v,b,[S,E],C,k,N,T,M])=>{const _=y-T,D=k+N,V=Math.max(b-_,0);let w=Eg;const B=Tg(M,ei),z=Tg(M,ti);return S-=T,S+=b+N,E+=b+N,E-=T,S>y+D-B&&(w=Js),E<y-V+v+z&&(w=Gs),w!==Eg?[Math.max(_-b-Ng(C,ei,w)-B,0),_-V-N+v+Ng(C,ti,w)+z]:null}),Ie(y=>y!==null),Ct(Qs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:x,topListHeight:d,visibleRange:m}},Et(hn),{singleton:!0});function Gk(t,a,s){if(sc(a)){const i=hy(t,a);return[{index:sr(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const Dd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ho(t,a,s,i,c,u){const{lastIndex:d,lastOffset:h,lastSize:x}=c;let m=0,y=0;if(t.length>0){m=t[0].offset;const C=t[t.length-1];y=C.offset+C.size}const v=s-d,b=h+v*x+(v-1)*i,S=m,E=b-y;return{bottom:y,firstItemIndex:u,items:Rg(t,c,u),offsetBottom:E,offsetTop:m,top:S,topItems:Rg(a,c,u),topListHeight:a.reduce((C,k)=>k.size+C,0),totalCount:s}}function by(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,x=If(a,h),m=Array.from({length:h}).map((y,v)=>({data:u[v+x],index:v+x,offset:0,size:0}));return Ho(m,[],h,c,s,i)}function Rg(t,a,s){if(t.length===0)return[];if(!sc(a))return t.map(m=>({...m,index:m.index+s,originalIndex:m.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Bl(a.groupOffsetTree,i,c);let h,x=0;for(const m of t){(!h||h.end<m.index)&&(h=d.shift(),x=a.groupIndices.indexOf(h.start));let y;m.index===h.start?y={index:x,type:"group"}:y={groupIndex:x,index:m.index-(x+1)+s},u.push({...y,data:m.data,offset:m.offset,originalIndex:m.index,size:m.size})}return u}function Ag(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Ya=st(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:x},{initialTopMostItemIndex:m,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:E}])=>{const C=ge([]),k=ge(0),N=tt(),T=ge(0);Re(u.topItemsIndexes,C);const M=un(he(Ft(S,E,Be(x,Qs),Be(c),Be(i),Be(m),y,Be(C),Be(a),Be(s),Be(T),t),Ie(([w,B,,z,,,,,,,,O])=>{const $=O!==void 0&&O.length!==z;return w&&!B&&!$}),we(([,,[w,B],z,O,$,Y,X,ne,H,A,I])=>{var je,Me;const G=O,{offsetTree:U,sizeTree:ae}=G,L=Mt(k);if(z===0)return{...Dd,totalCount:z};if(w===0&&B===0)return L===0?{...Dd,totalCount:z}:by(L,$,O,ne,H,I||[]);if(gt(ae))return L>0?null:Ho(Gk(If($,z),G,I),[],z,H,G,ne);const W=[];if(X.length>0){const Ae=X[0],ze=X[X.length-1];let Ge=0;for(const se of Bl(ae,Ae,ze)){const de=se.value,me=Math.max(se.start,Ae),ve=Math.min(se.end,ze);for(let be=me;be<=ve;be++)W.push({data:I==null?void 0:I[be],index:be,offset:Ge,size:de}),Ge+=de}}if(!Y)return Ho([],W,z,H,G,ne);const ee=X.length>0?X[X.length-1]+1:0,q=zk(U,w,B,ee);if(q.length===0)return null;const oe=z-1,Q=lc([],Ae=>{for(const ze of q){const Ge=ze.value;let se=Ge.offset,de=ze.start;const me=Ge.size;if(Ge.offset<w){de+=Math.floor((w-Ge.offset+H)/(me+H));const be=de-ze.start;se+=be*me+be*H}de<ee&&(se+=(ee-de)*me,de=ee);const ve=Math.min(ze.end,oe);for(let be=de;be<=ve&&!(se>=B);be++)Ae.push({data:I==null?void 0:I[be],index:be,offset:se,size:me}),se+=me+H}}),ye=Ag(A,ei),ce=Ag(A,ti);if(Q.length>0&&(ye>0||ce>0)){const Ae=Q[0],ze=Q[Q.length-1];if(ye>0&&Ae.index>ee){const Ge=Math.min(ye,Ae.index-ee),se=[];let de=Ae.offset;for(let me=Ae.index-1;me>=Ae.index-Ge;me--){const ve=((je=Bl(ae,me,me)[0])==null?void 0:je.value)??Ae.size;de-=ve+H,se.unshift({data:I==null?void 0:I[me],index:me,offset:de,size:ve})}Q.unshift(...se)}if(ce>0&&ze.index<oe){const Ge=Math.min(ce,oe-ze.index);let se=ze.offset+ze.size+H;for(let de=ze.index+1;de<=ze.index+Ge;de++){const me=((Me=Bl(ae,de,de)[0])==null?void 0:Me.value)??ze.size;Q.push({data:I==null?void 0:I[de],index:de,offset:se,size:me}),se+=me+H}}}return Ho(Q,W,z,H,G,ne)}),Ie(w=>w!==null),Ct()),Dd);Re(he(t,Ie(Lf),we(w=>w==null?void 0:w.length)),c),Re(he(M,we(w=>w.topListHeight)),v),Re(v,h),Re(he(M,we(w=>[w.top,w.bottom])),d),Re(he(M,we(w=>w.items)),N);const _=Bn(he(M,Ie(({items:w})=>w.length>0),Fe(c,t),Ie(([{items:w},B])=>w[w.length-1].originalIndex===B-1),we(([,w,B])=>[w-1,B]),Ct(Qs),we(([w])=>w))),D=Bn(he(M,Br(200),Ie(({items:w,topItems:B})=>w.length>0&&w[0].originalIndex===B.length),we(({items:w})=>w[0].index),Ct())),V=Bn(he(M,Ie(({items:w})=>w.length>0),we(({items:w})=>{let B=0,z=w.length-1;for(;w[B].type==="group"&&B<z;)B++;for(;w[z].type==="group"&&z>B;)z--;return{endIndex:w[z].index,startIndex:w[B].index}}),Ct(py)));return{endReached:_,initialItemCount:k,itemsRendered:N,listState:M,minOverscanItemCount:T,rangeChanged:V,startReached:D,topItemsIndexes:C,...b}},Et(vr,gy,$f,li,ai,si,ya,_f),{singleton:!0}),jy=st(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=tt(),d=un(he(Ft(s,t,i,a,c),we(([h,x,m,y,v])=>h+x+m+y+v.offsetBottom+v.bottom)),0);return Re(Be(d),u),{totalListHeight:d,totalListHeightChanged:u}},Et(hn,Ya),{singleton:!0}),Wk=st(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),i=un(he(Ft(s,t,a),Ie(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),Br(0),Ct()),0);return{alignToBottom:s,paddingTopAddition:i}},Et(hn,jy),{singleton:!0}),Sy=st(()=>({context:ge(null)})),qk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,ky=st(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:x},{scrollToIndex:m}])=>{const y=tt();return Re(he(y,Fe(a,x,s,u,c,i,h),Fe(t),we(([[v,b,S,E,C,k,N,T],M])=>{const{calculateViewLocation:_=qk,done:D,...V}=v,w=xy(v,b,E-1),B=Zs(w,b.offsetTree,M)+C+k,z=B+sr(b.sizeTree,w)[1],O=T+k,$=T+S-N,Y=_({itemBottom:z,itemTop:B,locationParams:V,viewportBottom:$,viewportTop:O});return Y!==null?D&&ar(he(d,Ie(X=>!X),Va(Mt(d)?1:2)),D):D==null||D(),Y}),Ie(v=>v!==null)),m),{scrollIntoView:y}},Et(vr,hn,ai,Ya,va),{singleton:!0});function Mg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const Yk=(t,a)=>typeof t=="function"?Mg(t(a)):a&&Mg(t),Kk=st(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:x,propsReady:m},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const E=ge(!1),C=tt();let k=null;function N(D){Ve(d,{align:"end",behavior:D,index:"LAST"})}ct(he(Ft(he(Be(a),Va(1)),x),Fe(Be(E),u,h,v),we(([[D,V],w,B,z,O])=>{let $=V&&z,Y="auto";return $&&(Y=Yk(w,B||O),$=$&&Y!==!1),{followOutputBehavior:Y,shouldFollow:$,totalCount:D}}),Ie(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:V})=>{k!==null&&(k(),k=null),Mt(s)!==void 0?requestAnimationFrame(()=>{Mt(y)("following output to ",{totalCount:V},Yt.DEBUG),N(D)}):k=ar(t,()=>{Mt(y)("following output to ",{totalCount:V},Yt.DEBUG),N(D),k=null})});function T(D){const V=ar(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&k===null&&(Mt(y)("scrolling to bottom due to increased size",{},Yt.DEBUG),N("auto"))});setTimeout(V,100)}ct(he(Ft(Be(E),a,m),Ie(([D,,V])=>D!==!1&&V),hr(({value:D},[,V])=>({refreshed:D===V,value:V}),{refreshed:!1,value:0}),Ie(({refreshed:D})=>D),Fe(E,a)),([,D])=>{Mt(h)&&T(D!==!1)}),ct(C,()=>{T(Mt(E)!==!1)}),ct(Ft(Be(E),c),([D,V])=>{D!==!1&&!V.atBottom&&V.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const M=ge(null),_=tt();return Re(uf(he(Be(i),we(D=>(D==null?void 0:D.length)??0)),he(Be(a))),_),ct(he(Ft(he(_,Va(1)),x),Fe(Be(M),h,v,b),we(([[D,V],w,B,z,O])=>V&&B&&(w==null?void 0:w({context:O,totalCount:D,scrollingInProgress:z}))),Ie(D=>!!D),Br(0)),D=>{k!==null&&(k(),k=null),Mt(s)!==void 0?requestAnimationFrame(()=>{Mt(y)("scrolling into view",{}),Ve(S,D)}):k=ar(t,()=>{Mt(y)("scrolling into view",{}),Ve(S,D),k=null})}),{autoscrollToBottom:C,followOutput:E,scrollIntoViewOnChange:M}},Et(vr,si,ai,li,ya,va,hn,Sy,ky)),Xk=st(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(he(h,Fe(u),Ie(([,x])=>x!==0),Fe(c,i,a,s,t),we(([[,x],m,y,v,b,S=[]])=>by(x,m,y,v,b,S))),d),{}),Et(vr,li,Ya,ya),{singleton:!0}),Qk=st(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ge(0);return ct(he(t,Fe(i),Ie(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{ar(he(s,Va(1),Ie(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Ve(a,c)})})}),{initialScrollTop:i}},Et(ya,hn,Ya),{singleton:!0}),wy=st(([{scrollVelocity:t}])=>{const a=ge(!1),s=tt(),i=ge(!1);return Re(he(t,Fe(i,a,s),Ie(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,h])=>{const{enter:x,exit:m}=u;if(d){if(m(c,h))return!1}else if(x(c,h))return!0;return d}),Ct()),a),ct(he(Ft(a,t,s),Fe(i)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},Et(si),{singleton:!0}),Uf=st(([{scrollContainerState:t,scrollTo:a}])=>{const s=tt(),i=tt(),c=tt(),u=ge(!1),d=ge(void 0);return Re(he(Ft(s,i),we(([{scrollTop:h,viewportHeight:x},{offsetTop:m,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-m),viewportHeight:x}))),t),Re(he(a,Fe(i),we(([h,{offsetTop:x}])=>({...h,top:h.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Et(hn)),Zk=st(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:x}])=>{const m=tt(),y=ge(void 0),v=ge(null),b=ge(null);return Re(h,v),Re(x,b),ct(he(m,Fe(a,i,d,v,b,s)),([S,E,C,k,N,T,M])=>{const _=_k(E.sizeTree);k&&N!==null&&T!==null&&(C=N.scrollTop-T.offsetTop),C-=M,S({ranges:_,scrollTop:C})}),Re(he(y,Ie(Lf),we(Jk)),c),Re(he(u,Fe(y),Ie(([,S])=>S!==void 0),Ct(),we(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:y}},Et(vr,hn,li,ya,Uf));function Jk(t){return{align:"start",index:0,offset:t.scrollTop}}const ew=st(([{topItemsIndexes:t}])=>{const a=ge(0);return Re(he(a,Ie(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Et(Ya));function Cy(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const tw=Cy(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),nw=st(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:x},{beforeUnshiftWith:m,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:E}])=>{const C=Bn(he(x,Fe(d),hr(([,N,T,M],[{bottom:_,items:D,offsetBottom:V,totalCount:w},B])=>{const z=_+V;let O=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(O=z-M,O!==0&&(O+=B))),[O,D,w,z]},[0,[],0,0]),Ie(([N])=>N!==0),Fe(i,h,s,c,S,E),Ie(([,N,T,M,,,_])=>!_&&!M&&N!==0&&T===Js),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Yt.DEBUG),N))));function k(N){N>0?(Ve(a,{behavior:"auto",top:-N}),Ve(t,0)):(Ve(t,0),Ve(a,{behavior:"auto",top:-N}))}return ct(he(C,Fe(t,u)),([N,T,M])=>{M&&tw()?Ve(t,T-N):k(-N)}),ct(he(Ft(un(u,!1),t,E),Ie(([N,T,M])=>!N&&!M&&T!==0),we(([N,T])=>T),Br(1)),k),Re(he(v,we(N=>({top:-N}))),a),ct(he(m,Fe(b,y),we(([N,{groupIndices:T,lastSize:M,sizeTree:_},D])=>{function V($){return $*(M+D)}if(T.length===0)return V(N);let w=0;const B=Xs(_,0);let z=0,O=0;for(;z<N;){z++,w+=B;let $=T.length===O+1?1/0:T[O+1]-T[O]-1;z+$>N&&(w-=B,$=N-z+1),z+=$,w+=V($),O++}return w})),N=>{Ve(t,N),requestAnimationFrame(()=>{Ve(a,{top:N}),requestAnimationFrame(()=>{Ve(t,0),Ve(E,!1)})})}),{deviation:t}},Et(hn,si,Ya,vr,va,_f)),rw=st(([t,a,s,i,c,u,d,h,x,m,y])=>({...t,...a,...s,...i,...c,...u,...d,...h,...x,...m,...y}),Et($f,Xk,ya,wy,jy,Qk,Wk,Uf,ky,va,Sy)),Ey=st(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:x,sizeRanges:m,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:E,initialTopMostItemIndex:C,scrolledToInitialItem:k},N,T,M,_,{scrollToIndex:D},V,{topItemCount:w},{groupCounts:B},z])=>{const{listState:O,minOverscanItemCount:$,topItemsIndexes:Y,rangeChanged:X,...ne}=_;return Re(X,z.scrollSeekRangeChanged),Re(he(z.windowViewportRect,we(H=>H.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:B,heightEstimates:h,initialItemFinalLocationReached:E,initialTopMostItemIndex:C,scrolledToInitialItem:k,sizeRanges:m,topItemCount:w,topItemsIndexes:Y,totalCount:b,...M,groupIndices:d,itemSize:x,listState:O,minOverscanItemCount:$,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...ne,...z,...N,sizes:y,...T}},Et(vr,li,hn,Zk,Kk,Ya,ai,nw,ew,gy,rw));function aw(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const Eo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Ny(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Te.createContext({});function x(k,N){k.propsReady!==void 0&&Ve(k.propsReady,!1);for(const T of i){const M=k[a.required[T]];Ve(M,N[T])}for(const T of c)if(T in N){const M=k[a.optional[T]];Ve(M,N[T])}k.propsReady!==void 0&&Ve(k.propsReady,!0)}function m(k){return u.reduce((N,T)=>(N[T]=M=>{const _=k[a.methods[T]];Ve(_,M)},N),{})}function y(k){return d.reduce((N,T)=>(N[T]=bk(k[a.events[T]]),N),{})}const v=Te.forwardRef(function(k,N){const{children:T,...M}=k,[_]=Te.useState(()=>lc(Sk(t),w=>{x(w,M)})),[D]=Te.useState(jg(y,_));Eo(()=>{for(const w of d)w in M&&ct(D[w],M[w]);return()=>{Object.values(D).map(zf)}},[M,D,_]),Eo(()=>{x(_,M)}),Te.useImperativeHandle(N,bg(m(_)));const V=s;return r.jsx(h.Provider,{value:_,children:s!==void 0?r.jsx(V,{...aw([...i,...c,...d],M),children:T}):T})}),b=k=>{const N=Te.useContext(h);return Te.useCallback(T=>{Ve(N[k],T)},[N,k])},S=k=>{const N=Te.useContext(h)[k],T=Te.useCallback(M=>ct(N,M),[N]);return Te.useSyncExternalStore(T,()=>Mt(N),()=>Mt(N))},E=k=>{const N=Te.useContext(h)[k],[T,M]=Te.useState(jg(Mt,N));return Eo(()=>ct(N,_=>{_!==T&&M(bg(_))}),[N,T]),T},C=parseInt(Te.version)>=18?S:E;return{Component:v,useEmitter:(k,N)=>{const T=Te.useContext(h)[k];Eo(()=>ct(T,N),[N,T])},useEmitterValue:C,usePublisher:b}}const Ty=Te.createContext(void 0),Ry=Te.createContext(void 0),_d="-webkit-sticky",Lg="sticky",Hf=Cy(()=>{if(typeof document>"u")return Lg;const t=document.createElement("div");return t.style.position=_d,t.style.position===_d?_d:Lg}),Ay=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Od(t){return"self"in t}function lw(t){return"body"in t}function My(t,a,s,i=Vl,c,u){const d=Te.useRef(null),h=Te.useRef(null),x=Te.useRef(null),m=Te.useCallback(b=>{let S,E,C;const k=b.target;if(lw(k)||Od(k)){const T=Od(k)?k:k.defaultView;C=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,E=u===!0?T.innerWidth:T.innerHeight}else C=u===!0?k.scrollLeft:k.scrollTop,S=u===!0?k.scrollWidth:k.scrollHeight,E=u===!0?k.offsetWidth:k.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(C,0),viewportHeight:E})};b.suppressFlushSync===!0?N():yS.flushSync(N),h.current!==null&&(C===h.current||C<=0||C===S-E)&&(h.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Te.useEffect(()=>{const b=c||d.current;return i(c||d.current),m({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",m,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",m)}},[d,m,s,i,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const E=b.behavior==="smooth";let C,k,N;Od(S)?(k=Math.max(ha(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),C=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(k=S[u===!0?"scrollWidth":"scrollHeight"],C=ha(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=k-C;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),yy(C,k)||b.top===N){t({scrollHeight:k,scrollTop:N,viewportHeight:C}),E&&a(!0);return}E?(h.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Pf(t){return t}const sw=st(()=>{const t=ge(h=>`Item ${h}`),a=ge(h=>`Group ${h}`),s=ge({}),i=ge(Pf),c=ge("div"),u=ge(Vl),d=(h,x=null)=>un(he(s,we(m=>m[h]),Ct()),x);return{components:s,computeItemKey:i,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),iw=st(([t,a])=>({...t,...a}),Et(Ey,sw)),ow=({height:t})=>r.jsx("div",{style:{height:t}}),cw={overflowAnchor:"none",position:Hf(),zIndex:1},Ly={overflowAnchor:"none"},uw={...Ly,display:"inline-block",height:"100%"},zg=Te.memo(function({showTopList:t=!1}){const a=Ue("listState"),s=Zn("sizeRanges"),i=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Zn("windowScrollContainerState"),d=Zn("scrollContainerState"),h=c||i?u:d,x=Ue("itemContent"),m=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),E=Zn("gap"),C=Ue("horizontalDirection"),{callbackRef:k}=Ck(s,b,v,t?Vl:h,S,E,c,C,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Vf("deviation",ne=>{N!==ne&&T(ne)});const M=Ue("EmptyPlaceholder"),_=Ue("ScrollSeekPlaceholder")??ow,D=Ue("ListComponent"),V=Ue("ItemComponent"),w=Ue("GroupComponent"),B=Ue("computeItemKey"),z=Ue("isSeeking"),O=Ue("groupIndices").length>0,$=Ue("alignToBottom"),Y=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...C?{display:"inline-block",height:"100%",marginLeft:N!==0?N:$?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:$?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...Y?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&M!==null&&M!==void 0?r.jsx(M,{...cn(M,m)}):r.jsx(D,{...cn(D,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:k,style:X,children:(t?a.topItems:a.items).map(ne=>{const H=ne.originalIndex,A=B(H+a.firstItemIndex,ne.data,m);return z?p.createElement(_,{...cn(_,m),height:ne.size,index:ne.index,key:A,type:ne.type||"item",...ne.type==="group"?{}:{groupIndex:ne.groupIndex}}):ne.type==="group"?p.createElement(w,{...cn(w,m),"data-index":H,"data-item-index":ne.index,"data-known-size":ne.size,key:A,style:cw},y(ne.index,m)):p.createElement(V,{...cn(V,m),...mw(V,ne.data),"data-index":H,"data-item-group-index":ne.groupIndex,"data-item-index":ne.index,"data-known-size":ne.size,key:A,style:C?uw:Ly},O?x(ne.index,ne.groupIndex,ne.data,m):x(ne.index,ne.data,m))})})}),dw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},fw={outline:"none",overflowX:"auto",position:"relative"},ic=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),pw={position:Hf(),top:0,width:"100%",zIndex:1};function cn(t,a){if(typeof t!="string")return{context:a}}function mw(t,a){return{item:typeof t=="string"?void 0:a}}const hw=Te.memo(function(){const t=Ue("HeaderComponent"),a=Zn("headerHeight"),s=Ue("HeaderFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null}),xw=Te.memo(function(){const t=Ue("FooterComponent"),a=Zn("footerHeight"),s=Ue("HeaderFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null});function zy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:i,style:c,context:u,...d}){const h=s("scrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:E}=My(h,m,x,y,void 0,v);return t("scrollTo",E),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?fw:dw,...c},tabIndex:0,...d,...cn(x,u),children:i})})}function Dy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:i,style:c,context:u,...d}){const h=s("windowScrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Te.useRef(null),E=a("scrollerRef"),{scrollByCallback:C,scrollerRef:k,scrollToCallback:N}=My(h,m,x,E,b);return Ay(()=>{var T;return k.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{k.current=null}},[k,b]),t("windowScrollTo",N),t("scrollBy",C),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...cn(x,u),children:i})})}const gw=({children:t})=>{const a=Te.useContext(Ty),s=Zn("viewportHeight"),i=Zn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>ly(s,x=>ha(x,u?"width":"height")),[s,u]),h=qa(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:ic(c),children:t})},vw=({children:t})=>{const a=Te.useContext(Ty),s=Zn("windowViewportRect"),i=Zn("fixedItemHeight"),c=Ue("customScrollParent"),u=iy(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:ic(d),children:t})},yw=({children:t})=>{const a=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),i={...pw,marginTop:`${s}px`},c=Ue("context");return r.jsx(a,{style:i,...cn(a,c),children:t})},bw=Te.memo(function(t){const a=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,i=Ue("customScrollParent"),c=Ue("context");return r.jsxs(i||a?kw:Sw,{...t,context:c,children:[s&&r.jsx(yw,{children:r.jsx(zg,{showTopList:!0})}),r.jsxs(i||a?vw:gw,{children:[r.jsx(hw,{}),r.jsx(zg,{}),r.jsx(xw,{})]})]})}),{Component:jw,useEmitter:Vf,useEmitterValue:Ue,usePublisher:Zn}=Ny(iw,{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"}},bw),Sw=zy({useEmitter:Vf,useEmitterValue:Ue,usePublisher:Zn}),kw=Dy({useEmitter:Vf,useEmitterValue:Ue,usePublisher:Zn}),ww=jw,Cw=st(()=>{const t=ge(m=>r.jsxs("td",{children:["Item $",m]})),a=ge(null),s=ge(m=>r.jsxs("td",{colSpan:1e3,children:["Group ",m]})),i=ge(null),c=ge(null),u=ge({}),d=ge(Pf),h=ge(Vl),x=(m,y=null)=>un(he(u,we(v=>v[m]),Ct()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});Et(Ey,Cw);Hf();const Dg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Ew={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_g,floor:Wo,max:Ws,min:Bd,round:Og}=Math;function Bg(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Nw(t){return{...Ew,items:t}}function No(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Tw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Rw=st(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:x,scrollTop:m,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:E,propsReady:C},{customScrollParent:k,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:M,windowViewportRect:_},D])=>{const V=ge(0),w=ge(0),B=ge(Dg),z=ge({height:0,width:0}),O=ge({height:0,width:0}),$=tt(),Y=tt(),X=ge(0),ne=ge(null),H=ge({column:0,row:0}),A=tt(),I=tt(),G=ge(!1),U=ge(0),ae=ge(!0),L=ge(!1),W=ge(!1);ct(he(E,Fe(U),Ie(([ce,je])=>je!==0)),()=>{Ve(ae,!1)}),ct(he(Ft(E,ae,O,z,U,L),Ie(([ce,je,Me,Ae,,ze])=>ce&&!je&&Me.height!==0&&Ae.height!==0&&!ze)),([,,,,ce])=>{Ve(L,!0),Bf(1,()=>{Ve($,ce)}),ar(he(m),()=>{Ve(a,[0,0]),Ve(ae,!0)})}),Re(he(I,Ie(ce=>ce!=null&&ce.scrollTop>0),mr(0)),w),ct(he(E,Fe(I),Ie(([,ce])=>ce!=null)),([,ce])=>{ce&&(Ve(z,ce.viewport),Ve(O,ce.item),Ve(H,ce.gap),ce.scrollTop>0&&(Ve(G,!0),ar(he(m,Va(1)),je=>{Ve(G,!1)}),Ve(x,{top:ce.scrollTop})))}),Re(he(z,we(({height:ce})=>ce)),v),Re(he(Ft(Be(z,No),Be(O,No),Be(H,(ce,je)=>ce!==void 0&&ce.column===je.column&&ce.row===je.row),Be(m)),we(([ce,je,Me,Ae])=>({gap:Me,item:je,scrollTop:Ae,viewport:ce}))),A),Re(he(Ft(Be(V),i,Be(H,Tw),Be(O,No),Be(z,No),Be(ne),Be(w),Be(G),Be(ae),Be(U)),Ie(([,,,,,,,ce])=>!ce),we(([ce,[je,Me],Ae,ze,Ge,se,de,,me,ve])=>{const{column:be,row:Xe}=Ae,{height:pt,width:vt}=ze,{width:$t}=Ge;if(de===0&&(ce===0||$t===0))return Dg;if(vt===0){const it=If(ve,ce),bt=it+Math.max(de-1,0);return Nw(Bg(it,bt,se))}const Nt=_y($t,vt,be);let qe,Lt;me?je===0&&Me===0&&de>0?(qe=0,Lt=de-1):(qe=Nt*Wo((je+Xe)/(pt+Xe)),Lt=Nt*_g((Me+Xe)/(pt+Xe))-1,Lt=Bd(ce-1,Ws(Lt,Nt-1)),qe=Bd(Lt,Ws(0,qe))):(qe=0,Lt=-1);const jt=Bg(qe,Lt,se),{bottom:ut,top:Xt}=Ig(Ge,Ae,ze,jt),xe=_g(ce/Nt),nt=xe*pt+(xe-1)*Xe-ut;return{bottom:ut,itemHeight:pt,items:jt,itemWidth:vt,offsetBottom:nt,offsetTop:Xt,top:Xt}})),B),Re(he(ne,Ie(ce=>ce!==null),we(ce=>ce.length)),V),Re(he(Ft(z,O,B,H),Ie(([ce,je,{items:Me}])=>Me.length>0&&je.height!==0&&ce.height!==0),we(([ce,je,{items:Me},Ae])=>{const{bottom:ze,top:Ge}=Ig(ce,Ae,je,Me);return[Ge,ze]}),Ct(Qs)),a);const ee=ge(!1);Re(he(m,Fe(ee),we(([ce,je])=>je||ce!==0)),ee);const q=Bn(he(Ft(B,V),Ie(([{items:ce}])=>ce.length>0),Fe(ee),Ie(([[ce,je],Me])=>{const Ae=ce.items[ce.items.length-1].index===je-1;return(Me||ce.bottom>0&&ce.itemHeight>0&&ce.offsetBottom===0&&ce.items.length===je)&&Ae}),we(([[,ce]])=>ce-1),Ct())),oe=Bn(he(Be(B),Ie(({items:ce})=>ce.length>0&&ce[0].index===0),mr(0),Ct())),Q=Bn(he(Be(B),Fe(G),Ie(([{items:ce},je])=>ce.length>0&&!je),we(([{items:ce}])=>({endIndex:ce[ce.length-1].index,startIndex:ce[0].index})),Ct(py),Br(0)));Re(Q,S.scrollSeekRangeChanged),Re(he($,Fe(z,O,V,H),we(([ce,je,Me,Ae,ze])=>{const Ge=vy(ce),{align:se,behavior:de,offset:me}=Ge;let ve=Ge.index;ve==="LAST"&&(ve=Ae-1),ve=Ws(0,ve,Bd(Ae-1,ve));let be=hf(je,ze,Me,ve);return se==="end"?be=Og(be-je.height+Me.height):se==="center"&&(be=Og(be-je.height/2+Me.height/2)),me!==void 0&&me!==0&&(be+=me),{behavior:de,top:be}})),x);const ye=un(he(B,we(ce=>ce.offsetBottom+ce.bottom)),0);return Re(he(_,we(ce=>({height:ce.visibleHeight,width:ce.visibleWidth}))),z),{customScrollParent:k,data:ne,deviation:X,footerHeight:c,gap:H,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:O,overscan:s,restoreStateFrom:I,scrollBy:d,scrollContainerState:h,scrollHeight:Y,scrollTo:x,scrollToIndex:$,scrollTop:m,smoothScrollTargetReached:y,totalCount:V,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:M,windowViewportRect:_,...S,gridState:B,horizontalDirection:W,initialTopMostItemIndex:U,totalListHeight:ye,...b,endReached:q,propsReady:C,rangeChanged:Q,startReached:oe,stateChanged:A,stateRestoreInProgress:G,...D}},Et($f,hn,si,wy,ya,Uf,va));function _y(t,a,s){return Ws(1,Wo((t+s)/(Wo(a)+s)))}function Ig(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=hf(t,a,s,i[0].index);return{bottom:hf(t,a,s,i[i.length-1].index)+c,top:u}}function hf(t,a,s,i){const c=_y(t.width,s.width,a.column),u=Wo(i/c),d=u*s.height+Ws(0,u-1)*a.row;return d>0?d+a.row:d}const Aw=st(()=>{const t=ge(v=>`Item ${v}`),a=ge({}),s=ge(null),i=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Pf),d=ge("div"),h=ge(Vl),x=(v,b=null)=>un(he(a,we(S=>S[v]),Ct()),b),m=ge(!1),y=ge(!1);return Re(Be(y),m),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:m,reportReadyState:y,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),Mw=st(([t,a])=>({...t,...a}),Et(Rw,Aw)),Lw=Te.memo(function(){const t=At("gridState"),a=At("listClassName"),s=At("itemClassName"),i=At("itemContent"),c=At("computeItemKey"),u=At("isSeeking"),d=Jn("scrollHeight"),h=At("ItemComponent"),x=At("ListComponent"),m=At("ScrollSeekPlaceholder"),y=At("context"),v=Jn("itemDimensions"),b=Jn("gap"),S=At("log"),E=At("stateRestoreInProgress"),C=Jn("reportReadyState"),k=qa(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const M=N.firstChild;if(M!==null){const{height:_,width:D}=M.getBoundingClientRect();v({height:_,width:D})}b({column:$g("column-gap",getComputedStyle(N).columnGap,S),row:$g("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return Ay(()=>{t.itemHeight>0&&t.itemWidth>0&&C(!0)},[t]),E?null:r.jsx(x,{className:a,ref:k,...cn(x,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?r.jsx(m,{...cn(m,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):p.createElement(h,{...cn(h,y),className:s,"data-index":N.index,key:T},i(N.index,N.data,y))})})}),zw=Te.memo(function(){const t=At("HeaderComponent"),a=Jn("headerHeight"),s=At("headerFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null}),Dw=Te.memo(function(){const t=At("FooterComponent"),a=Jn("footerHeight"),s=At("headerFooterTag"),i=qa(Te.useMemo(()=>u=>{a(ha(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...cn(t,c)})}):null}),_w=({children:t})=>{const a=Te.useContext(Ry),s=Jn("itemDimensions"),i=Jn("viewportDimensions"),c=qa(Te.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Te.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:ic(!1),children:t})},Ow=({children:t})=>{const a=Te.useContext(Ry),s=Jn("windowViewportRect"),i=Jn("itemDimensions"),c=At("customScrollParent"),u=iy(s,c,!1);return Te.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:ic(!1),children:t})},Bw=Te.memo(function({...t}){const a=At("useWindowScroll"),s=At("customScrollParent"),i=s||a?$w:Iw,c=s||a?Ow:_w,u=At("context");return r.jsx(i,{...t,...cn(i,u),children:r.jsxs(c,{children:[r.jsx(zw,{}),r.jsx(Lw,{}),r.jsx(Dw,{})]})})}),{useEmitter:Oy,useEmitterValue:At,usePublisher:Jn}=Ny(Mw,{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"}},Bw),Iw=zy({useEmitter:Oy,useEmitterValue:At,usePublisher:Jn}),$w=Dy({useEmitter:Oy,useEmitterValue:At,usePublisher:Jn});function $g(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Yt.WARN),a==="normal"?0:parseInt(a??"0",10)}const Uw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},By={source:"Own",installed:"Installed"};function Hw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function Pw(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Ug({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=Uw[t],[d,h]=p.useState(()=>Hw(u)),x=p.useCallback(()=>{h(b=>{const S=!b;return Pw(u,S),S})},[u]),m=By[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:x,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(Fw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:m}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),i!=null&&i>0&&r.jsx(Vw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Vw({origin:t,updateCount:a}){const[s,i]=p.useState(!1),c=By[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>i(!0),onBlur:()=>i(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Fw({collapsed:t}){return r.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Ff(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Gw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=p.useRef(null),d=p.useId(),h=!!i&&t.trim()!==""&&!i.test(t);return p.useEffect(()=>{function x(m){var b;if(m.key!=="/")return;const y=m.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(m.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function Ww({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function qw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function Yw({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(Yv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Kw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ii(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",h=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!h.startsWith("v")?`v${h}`:h,m=i==="sm"?10:12,y=i==="sm"?1:2,v=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=Kw(c,h,u),E=t.title??S,C={display:"inline-flex",alignItems:"center",padding:`${y}px ${v}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:m,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(C.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":h,"data-version-source":c,title:E,style:C,children:x})}function Xw({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(d,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(ii,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(Ww,{target:t.symlinkTarget??null}),r.jsx(qw,{skill:t}),r.jsx(Yw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const qo=p.memo(Xw);function Qw({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){const d=[...a].sort((h,x)=>h.skill.localeCompare(x.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:d.map(h=>{const x=!!s&&s.plugin===h.plugin&&s.skill===h.skill;return r.jsx("div",{role:"listitem",children:r.jsx(qo,{skill:h,isSelected:x,onSelect:()=>i(h),onContextMenu:c,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})},`${h.plugin}/${h.skill}`)})})]})}function Zw(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function Hg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,m]=p.useState(()=>Zw(i,s)),y=d?!1:x,v=p.useCallback(()=>{m(E=>{const C=!E;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(C))}catch{}return C})},[i]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(E=>r.jsx("div",{"data-vskill-plugin-skill":E.pluginNamespace??E.skill,children:c(E)},`${E.pluginNamespace??E.skill}`))})]})}function Po({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const x=p.useRef(null),m=p.useRef(null),y=p.useRef(null);if(p.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var E;(E=m.current)==null||E.focus()}),()=>{var E,C;(C=(E=y.current)==null?void 0:E.focus)==null||C.call(E),y.current=null}},[t]),p.useEffect(()=>{if(!t)return;function E(C){if(C.key==="Escape"){C.preventDefault(),h();return}if(C.key==="Tab"&&x.current){const k=x.current.querySelectorAll("button:not([disabled])");if(k.length===0)return;const N=k[0],T=k[k.length-1];C.shiftKey&&document.activeElement===N?(C.preventDefault(),T.focus()):!C.shiftKey&&document.activeElement===T&&(C.preventDefault(),N.focus())}}return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!0)},[t,h]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:E=>{E.target===E.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:m,type:"button","data-testid":"confirm-dialog-cancel",onClick:h,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:i})]})]})})}function Jw(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Id(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function eC({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=p.useState(!1),[u,d]=p.useState(null),[h,x]=p.useState(null),[m,y]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{if(!i)return;function E(C){v.current&&!v.current.contains(C.target)&&c(!1)}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[i]);async function b(E){d(E),x(null);try{const C=await fetch(`/api/plugins/${encodeURIComponent(t)}/${E}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),k=await C.json().catch(()=>({}));if(!C.ok||!k.ok){const N=k.error??`${E} failed (${C.status})`;x(N),E==="uninstall"&&Id(`Failed to uninstall ${t}: ${N}`,"error");return}if(E==="uninstall"){const N=k.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Id(N,"success")}On("skills"),ry(),s==null||s(),c(!1)}catch(C){const k=C instanceof Error?C.message:String(C);x(k),E==="uninstall"&&Id(`Failed to uninstall ${t}: ${k}`,"error")}finally{d(null)}}function S(){y(!0)}return r.jsxs("div",{ref:v,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:E=>{E.stopPropagation(),c(C=>!C)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:E=>{E.currentTarget.style.color="var(--text-primary)",E.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:E=>{E.currentTarget.style.color="var(--text-tertiary)",E.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx($d,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx($d,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx($d,{onClick:S,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]}),r.jsx(Po,{open:m,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{y(!1),c(!1)},onConfirm:()=>{y(!1),b("uninstall")}})]})}function $d({onClick:t,disabled:a,busy:s,label:i,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Pg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const h=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=i==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",m=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:x,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:m?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[m&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(tC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return m?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function tC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function nC(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function rC(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const x=h.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?i=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function aC(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function lC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function xf(t,a={}){const{enabled:s=!0,target:i}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(rC),p.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function h(x){const m=x,y=aC(m.target);for(const v of c.current){if(!lC(m,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(m);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,i])}function Iy(){const{data:t,loading:a,error:s,revalidate:i}=Ga("project-github-status",()=>Se.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function sC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function iC({projectRoot:t}){const{status:a,loading:s}=Iy();if(s||!a||a.status==="github"||sC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const oC=200;function cC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function uC(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function i(c){const u=c.filter(x=>Ff(x,a)),d={};for(const x of u){const m=x.pluginName??x.plugin;(d[m]||(d[m]=[])).push(x)}const h=Object.entries(d).sort((x,m)=>x[0].localeCompare(m[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:i(s.authoringProject),authoringPlugin:i(s.authoringPlugin)}}function dC(t,a){const s=[],i=[],c=[];for(const d of t){const h=cC(d);h==="global"?c.push(d):h==="installed"?i.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Ff(v,a)),x={};for(const v of h)(x[y=v.plugin]||(x[y]=[])).push(v);const m=Object.entries(x).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(i),global:u(c)}}function fC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var m;const d=u.filter(y=>Ff(y,a)),h={};for(const y of d)(h[m=y.plugin]||(h[m]=[])).push(y);const x=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function pC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:x,outdatedByScope:m,topSlot:y,revealSkillId:v,onRevealComplete:b,dirtySkillIds:S}){const E=!!x||t.some(q=>q.scope!==void 0&&q.scope!==null),C=x??"claude-cli",[k,N]=p.useState(""),T=p.useDeferredValue(k),M=p.useMemo(()=>dC(t,T),[t,T]),_=p.useMemo(()=>uC(t,T),[t,T]),D=C==="claude-code",{plugins:V}=mk(),w=D?{plugins:V??[]}:void 0,B=p.useMemo(()=>{const q=new Map;for(const oe of(w==null?void 0:w.plugins)??[]){const Q=q.get(oe.name);q.set(oe.name,!!Q||!!oe.enabled)}return q},[w==null?void 0:w.plugins]),[z,O]=p.useState(()=>gf(`vskill-sidebar-${C}-group-available-collapsed`)),[$,Y]=p.useState(()=>gf(`vskill-sidebar-${C}-group-authoring-collapsed`)),X=p.useCallback(q=>{O(q);try{window.localStorage.setItem(`vskill-sidebar-${C}-group-available-collapsed`,String(q))}catch{}},[C]),ne=p.useCallback(q=>{Y(q);try{window.localStorage.setItem(`vskill-sidebar-${C}-group-authoring-collapsed`,String(q))}catch{}},[C]),{own:H,installed:A}=p.useMemo(()=>fC(t,T),[t,T]),G=M.own.filtered+M.installed.filtered+M.global.filtered>=oC,U=p.useMemo(()=>{const q=oe=>{const Q=[];for(const[,ye]of oe){const ce=[...ye].sort((je,Me)=>je.skill.localeCompare(Me.skill));Q.push(...ce)}return Q};return E?[...q(M.own.byPlugin),...q(M.installed.byPlugin),...q(M.global.byPlugin)]:[...q(H.byPlugin),...q(A.byPlugin)]},[E,M.own.byPlugin,M.installed.byPlugin,M.global.byPlugin,H.byPlugin,A.byPlugin]),ae=p.useMemo(()=>a?U.findIndex(q=>q.plugin===a.plugin&&q.skill===a.skill):-1,[U,a]),L=p.useCallback(q=>{if(U.length===0)return;const oe=ae<0?q>0?0:U.length-1:Math.min(Math.max(ae+q,0),U.length-1);s(U[oe])},[U,ae,s]),W=p.useMemo(()=>{if(!v)return null;const[q,oe]=v.split("/");if(!q||!oe)return null;const Q=t.find(je=>je.plugin===q&&je.skill===oe);if(!Q)return{plugin:q,skill:oe,bucket:null,pluginName:null};const ye=Q.source==="plugin"?"plugin":"project",ce=ye==="plugin"?Q.pluginName??q:null;return{plugin:q,skill:oe,bucket:ye,pluginName:ce}},[v,t]),ee=p.useRef(null);return p.useEffect(()=>{if(!v){ee.current=null;return}if(ee.current===v)return;const q=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),oe=document.querySelector(`[data-skill-id="${q}"]`);oe&&(ee.current=v,oe.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),xf([{key:"j",handler:()=>L(1)},{key:"k",handler:()=>L(-1)},{key:"Enter",handler:()=>{ae>=0&&s(U[ae])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(Gw,{value:k,onChange:N}),i&&r.jsx(bC,{}),!i&&c&&r.jsx(jC,{error:c,onRetry:u}),!i&&!c&&E&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Pg,{name:re.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:z,onToggle:X,count:_.availableProject.total+_.availablePersonal.total+_.availablePlugin.total}),!z&&r.jsxs(r.Fragment,{children:[r.jsx(Bs,{label:re.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${C}-available-project-collapsed`,count:_.availableProject.total,filteredCount:k?_.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),headerRightSlot:D?r.jsx(iC,{projectRoot:C}):null,children:_.availableProject.filtered===0?r.jsx(Fg,{queryActive:!!k,agentId:C}):r.jsx(Is,{items:_.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),r.jsx(Bs,{label:re.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${C}-available-personal-collapsed`,count:_.availablePersonal.total,filteredCount:k?_.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:_.availablePersonal.filtered===0?r.jsx(hC,{queryActive:!!k,agentId:C}):r.jsx(Is,{items:_.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),D&&r.jsxs(Bs,{label:re.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${C}-available-plugin-collapsed`,count:_.availablePlugin.total,filteredCount:k?_.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),_.availablePlugin.filtered===0?r.jsx(xC,{queryActive:!!k,hasInstalled:_.availablePlugin.total>0}):_.availablePlugin.byPlugin.map(([q,oe])=>r.jsx(Hg,{pluginName:q,skills:oe,persistKey:`vskill-plugin-available-${q}-collapsed`,headerActionSlot:D?r.jsx(eC,{pluginName:q,enabled:B.get(q)??!0}):void 0,renderSkill:Q=>r.jsx(qo,{skill:Q,isSelected:(a==null?void 0:a.plugin)===Q.plugin&&(a==null?void 0:a.skill)===Q.skill,onSelect:()=>s(Q),onContextMenu:d,dirty:S==null?void 0:S.has(`${Q.plugin}/${Q.skill}`)})},`available-${q}`))]})]}),r.jsx(yC,{}),r.jsx(Pg,{name:re.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:W?!1:$,onToggle:ne,count:_.authoringProject.total+_.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!$||W)&&r.jsxs(r.Fragment,{children:[r.jsx(Bs,{label:re.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${C}-authoring-project-collapsed`,count:_.authoringProject.total,filteredCount:k?_.authoringProject.filtered:null,updateCount:(m==null?void 0:m.own)??(h==null?void 0:h.source),forceOpen:(W==null?void 0:W.bucket)==="project",children:_.authoringProject.filtered===0?r.jsx(Vg,{queryActive:!!k}):r.jsx(Is,{items:_.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),D&&r.jsx(Bs,{label:re.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${C}-authoring-plugin-collapsed`,count:_.authoringPlugin.total,filteredCount:k?_.authoringPlugin.filtered:null,forceOpen:(W==null?void 0:W.bucket)==="plugin",children:_.authoringPlugin.filtered===0?r.jsx(gC,{queryActive:!!k,hasSources:_.authoringPlugin.total>0}):_.authoringPlugin.byPlugin.map(([q,oe])=>r.jsx(Hg,{pluginName:q,skills:oe,persistKey:`vskill-plugin-authoring-${q}-collapsed`,forceOpen:(W==null?void 0:W.bucket)==="plugin"&&W.pluginName===q,renderSkill:Q=>r.jsx(qo,{skill:Q,isSelected:(a==null?void 0:a.plugin)===Q.plugin&&(a==null?void 0:a.skill)===Q.skill,onSelect:()=>s(Q),onContextMenu:d,dirty:S==null?void 0:S.has(`${Q.plugin}/${Q.skill}`)})},`authoring-${q}`))})]})]}),!i&&!c&&!E&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ug,{origin:"source",count:H.total,filteredCount:k?H.filtered:null,updateCount:h==null?void 0:h.source,children:H.filtered===0?r.jsx(Vg,{queryActive:!!k}):r.jsx(Is,{items:H.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})}),r.jsx(vC,{}),r.jsx(Ug,{origin:"installed",count:A.total,filteredCount:k?A.filtered:null,updateCount:h==null?void 0:h.installed,children:A.filtered===0?r.jsx(Fg,{queryActive:!!k}):r.jsx(Is,{items:A.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:G,dirtySkillIds:S})})]})]})}function gf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Bs({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:h}){const[x,m]=p.useState(()=>gf(a)),y=d?!1:x,v=p.useCallback(()=>{m(S=>{const E=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(E))}catch{}return E})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:y?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),h]}),!y&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function mC(t){const a=[];for(const[s,i]of t){const c=[...i].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Is({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=mC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(ww,{overscan:4,totalCount:d.length,itemContent:h=>{const x=d[h];if(!x)return null;if(x.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const m=x.skill,y=!!a&&a.plugin===m.plugin&&a.skill===m.skill;return r.jsx(qo,{skill:m,isSelected:y,onSelect:()=>s(m),onContextMenu:i,dirty:u==null?void 0:u.has(`${m.plugin}/${m.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,h])=>r.jsx(Qw,{plugin:d,skills:h,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Vg({queryActive:t}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(oi,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Fg({queryActive:t,agentId:a}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(oi,{children:"vskill install <skill>"})," to add one."]})})}function hC({queryActive:t,agentId:a}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(oi,{children:"vskill install --global <skill>"})," to add one."]})})}function xC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx(oi,{children:"Browse marketplaces…"})," above to add one."]})})}function gC({queryActive:t,hasSources:a}){return t&&a?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx(oi,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one."]})})}function gr({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function oi({children:t}){return r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function vC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function yC(){return r.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function bC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(nC,{},t))})}function jC({error:t,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:SC(t)}),r.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),a&&r.jsx("button",{type:"button",onClick:a,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function SC(t){const a=t.split(`
|
|
66
66
|
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const $y=240,Uy=480,Hy="vskill-sidebar-width",qs=320;function Gf(t){return Number.isFinite(t)?Math.round(Math.max($y,Math.min(Uy,t))):qs}function kC(){try{const t=localStorage.getItem(Hy);if(!t)return qs;const a=Number(t);return Number.isFinite(a)?Gf(a):qs}catch{return qs}}function wC(t){try{localStorage.setItem(Hy,String(Gf(t)))}catch{}}function CC({initialWidth:t,onChange:a}){const s=p.useRef({startX:0,startWidth:t,pointerId:null}),i=p.useRef(t);return p.useEffect(()=>{i.current=t},[t]),p.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,x=Gf(s.current.startWidth+h);i.current=x,a(x)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,wC(i.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":$y,"aria-valuemax":Uy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=i.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}const EC=/^[ MADRCU?!]{1,2} +/;function NC(t){return t.replace(EC,"")}function TC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function RC(t,a,s){const i=new Set;if(a.length===0||t.length===0)return i;const c=a.map(u=>NC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const h=TC(s,d);if(h===null)continue;const x=`${u.plugin}/${u.skill}`;if(h===""){c.length>0&&i.add(x);continue}const m=h+"/";for(const y of c)if(y===h||y.startsWith(m)){i.add(x);break}}return i}const AC=5e3;function MC(t,a,s=AC){const[i,c]=p.useState([]),u=p.useRef(t);return u.current=t,p.useEffect(()=>{if(!a){c([]);return}let d=!1,h=null;const x=async()=>{try{const y=await Se.gitStatus();d||c(y.paths??[])}catch{d||c([])}d||(h=setTimeout(x,s))};x();const m=()=>{x()};return typeof window<"u"&&window.addEventListener("studio:content-saved",m),()=>{d=!0,h&&clearTimeout(h),typeof window<"u"&&window.removeEventListener("studio:content-saved",m)}},[a,s]),a?RC(u.current,i,a):new Set}function LC({connected:t,hint:a,onRetry:s}){return t?null:r.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),r.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&r.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),r.jsx("div",{style:{flex:1}}),s&&r.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function Py(t,a){if(t!==401||typeof window>"u"||!a||typeof a!="object")return;const s=a;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function Vy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);try{const s=new WeakSet;return JSON.stringify(t,(i,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Ud(){const[t,a]=p.useState([]),[s,i]=p.useState(!1),[c,u]=p.useState(!1),[d,h]=p.useState(null),x=p.useRef(null),m=p.useCallback(async(v,b)=>{a([]),i(!0),u(!1),h(null);const S=new AbortController;x.current=S;try{const E=Vy(b),C=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:E,signal:S.signal});if(!C.ok||!C.body){let _=`HTTP ${C.status}`,D;try{D=await C.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(_=D.error)}catch{}throw Py(C.status,D),new Error(_)}const k=C.body.getReader(),N=new TextDecoder;let T="",M="";for(;;){const{done:_,value:D}=await k.read();if(_)break;T+=N.decode(D,{stream:!0});const V=T.split(`
|
|
67
67
|
`);T=V.pop()||"";for(const w of V)if(w.startsWith("event: "))M=w.slice(7).trim();else if(w.startsWith("data: ")){try{const B=JSON.parse(w.slice(6)),z={event:M,data:B};M==="done"?(u(!0),a(O=>[...O,z])):a(O=>[...O,z])}catch{}M=""}}}catch(E){E.name!=="AbortError"&&h(E.message)}finally{i(!1),x.current=null}},[]),y=p.useCallback(()=>{var v;(v=x.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:m,stop:y}}function zC(t){const a=p.useRef(t);a.current=t;const[s,i]=p.useState(new Set),c=p.useRef(new Map),u=p.useCallback(async(m,y,v)=>{var S;(S=c.current.get(m))==null||S.abort();const b=new AbortController;c.current.set(m,b),i(E=>{const C=new Set(E);return C.add(m),C});try{const E=Vy(v),C=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:E,signal:b.signal});if(!C.ok||!C.body){let _=`HTTP ${C.status}`,D;try{D=await C.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(_=D.error)}catch{}throw Py(C.status,D),new Error(_)}const k=C.body.getReader(),N=new TextDecoder;let T="",M="";for(;;){const{done:_,value:D}=await k.read();if(_)break;T+=N.decode(D,{stream:!0});const V=T.split(`
|
|
68
68
|
`);T=V.pop()||"";for(const w of V)if(w.startsWith("event: "))M=w.slice(7).trim();else if(w.startsWith("data: ")){try{const B=JSON.parse(w.slice(6)),z={event:M,data:B};a.current.onEvent(m,z)}catch{}M=""}}a.current.onDone(m)}catch(E){E.name!=="AbortError"&&a.current.onError(m,E.message)}finally{i(E=>{const C=new Set(E);return C.delete(m),C}),c.current.delete(m)}},[]),d=p.useCallback(m=>{var y;(y=c.current.get(m))==null||y.abort()},[]),h=p.useCallback(()=>{for(const m of c.current.values())m.abort()},[]),x=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:x}}const DC={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 _C(t,a){var s,i;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((i=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:i.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":{const c=a.prompts===t.activationPromptsCanonical;return{...t,activationPrompts:a.prompts,activationPromptsSource:c?t.activationPromptsSource:t.activationPromptsSource===null||t.activationPromptsSource==="skill-md"||t.activationPromptsSource==="ai-generated"?"user-typed":t.activationPromptsSource}}case"SET_PROMPTS_SOURCE":return{...t,activationPromptsSource:a.source,activationPromptsCanonical:a.canonical??t.activationPromptsCanonical};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:a.error};case"SAVE_TEST_CASES_START":return{...t,savingTestCases:!0,savingTestCasesError:null,savingTestCasesSuccess:null};case"SAVE_TEST_CASES_SUCCESS":return{...t,savingTestCases:!1,savingTestCasesSuccess:`Saved ${a.count} test case${a.count===1?"":"s"} to SKILL.md`,activationPromptsSource:"skill-md",activationPromptsCanonical:t.activationPrompts};case"SAVE_TEST_CASES_ERROR":return{...t,savingTestCases:!1,savingTestCasesError:a.error};case"CLEAR_SAVE_TEST_CASES_FEEDBACK":return{...t,savingTestCasesSuccess:null,savingTestCasesError:null};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function OC(t){if(t==="unit"||t==="integration")return t}function BC(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.event==="assertion_result"){const i={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===i.assertion_id)||t.assertions.push(i)}a.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const Fy=p.createContext(null);function $n(){const t=p.useContext(Fy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function IC({plugin:t,skill:a,origin:s,children:i}){const c=s==="installed",[u,d]=p.useReducer(_C,{...DC,plugin:t,skill:a}),h=p.useRef(new Set),x=p.useRef(new Set),m=p.useRef(new Map),y=p.useCallback((se,de)=>{let me=m.current.get(se);me||(me={assertions:[]},m.current.set(se,me)),BC(me,de),d({type:"UPDATE_INLINE_RESULT",evalId:se,result:{...me,assertions:[...me.assertions]}})},[]),v=p.useCallback(se=>{if(x.current.has(se))return;x.current.add(se);const de=m.current.get(se)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:se,result:{...de,assertions:[...de.assertions]}}),h.current.has(se)&&(h.current.delete(se),h.current.size===0&&Se.getLatestBenchmark(t,a).then(me=>d({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=p.useCallback((se,de)=>{x.current.has(se)||(x.current.add(se),d({type:"CASE_RUN_ERROR",caseId:se,error:de}),h.current.has(se)&&(h.current.delete(se),h.current.size===0&&Se.getLatestBenchmark(t,a).then(me=>d({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:E,stopAll:C}=zC({onEvent:y,onDone:v,onError:b});p.useEffect(()=>()=>{C()},[C]);const k=p.useCallback(async()=>{try{const se=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!se.ok){if(se.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const de=await se.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:de.runs||[]})}catch{}},[t,a]);p.useEffect(()=>{let se=!1;async function de(){try{const[me,ve,be]=await Promise.allSettled([Se.getSkillDetail(t,a),Se.getEvals(t,a),Se.getLatestBenchmark(t,a)]);if(se)return;let Xe=null,pt=null;if(ve.status==="fulfilled")Xe=ve.value;else{const vt=ve.reason;pt=(vt==null?void 0:vt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:me.status==="fulfilled"?me.value.skillContent:"",evals:Xe,evalsError:pt,benchmark:be.status==="fulfilled"?be.value:null})}catch(me){se||d({type:"SET_ERROR",error:me.message})}}return de(),k(),()=>{se=!0}},[t,a,k]);const N=p.useCallback(async se=>{if(c)return;const de=se??u.skillContent;try{await Se.applyImprovement(t,a,de),se!==void 0&&se!==u.skillContent&&d({type:"SET_CONTENT",content:se}),d({type:"CONTENT_SAVED"})}catch(me){d({type:"SET_ERROR",error:me.message})}},[c,t,a,u.skillContent]),T=p.useCallback(async se=>{if(!c)try{const de=await Se.saveEvals(t,a,se);d({type:"SET_EVALS",evals:de})}catch(de){d({type:"SET_ERROR",error:de.message})}},[c,t,a]),M=p.useCallback((se,de="benchmark")=>{if(c)return;const me=u.caseRunStates.get(se);if((me==null?void 0:me.status)!=="running")if(m.current.delete(se),x.current.delete(se),d({type:"CASE_RUN_START",caseId:se,mode:de}),de==="comparison"){const ve=`/api/skills/${t}/${a}/compare`;S(se,ve,{eval_ids:[se]})}else{const ve=`/api/skills/${t}/${a}/benchmark/case/${se}`;S(se,ve,de==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),_=p.useCallback((se="benchmark")=>{var ve;if(c)return;const de=((ve=u.evals)==null?void 0:ve.evals)??[];if(de.length===0)return;const me=de.map(be=>be.id);for(const be of me)m.current.delete(be),x.current.delete(be);d({type:"BULK_RUN_START",caseIds:me,mode:se}),h.current=new Set(me);for(const be of me)if(se==="comparison")S(be,`/api/skills/${t}/${a}/compare`,{eval_ids:[be]});else{const Xe=`/api/skills/${t}/${a}/benchmark/case/${be}`;S(be,Xe,se==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),D=p.useCallback(se=>{E(se),d({type:"CASE_RUN_CANCEL",caseId:se}),h.current.delete(se),x.current.add(se)},[E]),V=p.useCallback(()=>{C(),d({type:"CANCEL_ALL"}),h.current.clear()},[C]),w=p.useCallback(async(se,de)=>{d({type:"OPEN_IMPROVE",evalId:se})},[]),B=p.useCallback(async(se,de)=>{try{await Se.applyImprovement(t,a,de),d({type:"SET_CONTENT",content:de}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),M(se,"benchmark")}catch(me){d({type:"SET_ERROR",error:me.message})}},[t,a,M]),z=Ud(),O=p.useRef(null),$=p.useRef(0);p.useEffect(()=>{const se=z.events;for(let de=$.current;de<se.length;de++){const me=se[de],ve=me.data;if(me.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:ve.phase,message:ve.message}}),me.event==="done"){const be=ve.improved,Xe=ve.reasoning,pt=ve.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:be,reasoning:Xe,evalChanges:pt})}if(me.event==="error"){const be=ve;d({type:"AI_EDIT_ERROR",message:be.description||"Unknown error",classified:be})}}$.current=se.length},[z.events]),p.useEffect(()=>{z.error&&d({type:"AI_EDIT_ERROR",message:z.error})},[z.error]),p.useEffect(()=>()=>{z.stop()},[z.stop]);const Y=p.useCallback(async(se,de,me)=>{c||($.current=0,d({type:"AI_EDIT_LOADING"}),O.current=z.stop,z.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:se,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:de,model:me}))},[c,t,a,u.skillContent,u.evals,z]),X=p.useCallback(()=>{z.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[z]),ne=p.useCallback(async()=>{const se=u.aiEditResult;if(se!=null&&se.improved)try{if(await Se.applyImprovement(t,a,se.improved),d({type:"SET_CONTENT",content:se.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:me}=await Fa(async()=>{const{mergeEvalChanges:Xe}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Xe}},[]),ve=u.evals??{skill_name:a,evals:[]},be=me(ve,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Xe=await Se.saveEvals(t,a,be);d({type:"SET_EVALS",evals:Xe})}catch(Xe){d({type:"SET_EVALS_RETRY",evalsFile:be}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Xe.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(de){d({type:"SET_ERROR",error:de.message})}},[t,a,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),H=p.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),A=p.useCallback(se=>{d({type:"TOGGLE_EVAL_CHANGE",index:se})},[]),I=p.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),G=p.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),U=p.useCallback(async()=>{const se=u.aiEditEvalsRetry;if(se)try{const de=await Se.saveEvals(t,a,se);d({type:"SET_EVALS",evals:de}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(de){d({type:"SET_ERROR",error:`Retry failed: ${de.message}`})}},[t,a,u.aiEditEvalsRetry]),ae=p.useCallback(async()=>{try{const se=await Se.getSkillDetail(t,a);d({type:"SET_CONTENT",content:se.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:L}=Wa(),W=Ud(),ee=p.useRef(0);p.useEffect(()=>{const se=W.events;for(let de=ee.current;de<se.length;de++){const me=se[de],ve=me.data;if(me.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:ve.phase,message:ve.message}}),me.event==="done"){const be=ve;Se.saveEvals(t,a,be).then(Xe=>d({type:"GENERATE_EVALS_DONE",evals:Xe})).catch(Xe=>d({type:"SET_ERROR",error:Xe.message}))}me.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:ve})}ee.current=se.length},[W.events,t,a]),p.useEffect(()=>{W.error&&d({type:"SET_ERROR",error:W.error})},[W.error]),p.useEffect(()=>()=>{W.stop()},[W.stop]);const q=p.useCallback(async se=>{if(c)return;ee.current=0,d({type:"GENERATE_EVALS_START"});const de={};L!=null&&L.provider&&(de.provider=L.provider),L!=null&&L.model&&(de.model=L.model);const me=OC(se==null?void 0:se.testType);me&&(de.testType=me),W.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(de).length>0?de:void 0)},[c,t,a,W,L]),oe=Ud(),Q=p.useRef(0);p.useEffect(()=>()=>{oe.stop()},[oe.stop]),p.useEffect(()=>{const se=oe.events;for(let de=Q.current;de<se.length;de++){const me=se[de];if(me.event==="classifying"){const ve=me.data;d({type:"ACTIVATION_CLASSIFYING",index:ve.index,total:ve.total})}if(me.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:me.data}),me.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const ve=me.data;if(ve.error)d({type:"ACTIVATION_ERROR",error:ve.error});else{d({type:"ACTIVATION_DONE",summary:ve});const be={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(L==null?void 0:L.model)||"unknown",provider:(L==null?void 0:L.provider)||"unknown",promptCount:ve.total,summary:{precision:ve.precision,recall:ve.recall,reliability:ve.reliability,tp:ve.tp,tn:ve.tn,fp:ve.fp,fn:ve.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[be,...u.activationHistory??[]]})}}}Q.current=se.length},[oe.events,L,u.activationHistory]),p.useEffect(()=>{oe.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:oe.error}))},[oe.error]);const ye=p.useRef(null),ce=p.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),oe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[oe]),je=p.useCallback(se=>{const me=se.trim().split(`
|
|
@@ -108,7 +108,7 @@ What edge cases should I test?
|
|
|
108
108
|
Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...pa,minHeight:"120px"},onKeyDown:i=>{i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.preventDefault(),s.handleGenerate())}}),r.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&r.jsx(ci,{entries:s.aiProgress,isRunning:!0}),s.aiError&&r.jsx("div",{children:s.aiClassifiedError?r.jsx(uc,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):r.jsxs("div",{children:[r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.aiError}),r.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?r.jsx("button",{onClick:s.handleCancelGenerate,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:"var(--surface-3)",color:"var(--text-secondary)",border:"none",cursor:"pointer"},children:"Cancel Generation"}):r.jsxs("button",{onClick:s.handleGenerate,disabled:!s.aiPrompt.trim(),className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:s.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:s.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:s.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[r.jsx(Xd,{size:14}),"Generate"]}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",r.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),r.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(i=>r.jsx("button",{onClick:()=>{s.setSelectedLayout(i.layout),s.setPlugin(i.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===i.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===i.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===i.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:i.label},i.layout))})]}),s.selectedLayout!==3&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),r.jsxs("select",{value:s.plugin,onChange:i=>{s.setPlugin(i.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:pa,children:[s.availablePlugins.map(i=>r.jsx("option",{value:i,children:i},i)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&r.jsx("input",{type:"text",value:s.newPlugin,onChange:i=>s.setNewPlugin(Qo(i.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:pa})]}),r.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&r.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),r.jsxs("span",{children:["Plugins detected (",r.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),r.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("input",{type:"text",value:s.name,onChange:i=>s.setName(Qo(i.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:pa})]}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("textarea",{value:s.description,onChange:i=>s.setDescription(i.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...pa,minHeight:"72px"}})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsxs("select",{value:s.model,onChange:i=>s.setModel(i.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:pa,children:[r.jsx("option",{value:"",children:"Any"}),r.jsx("option",{value:"opus",children:"Opus"}),r.jsx("option",{value:"sonnet",children:"Sonnet"}),r.jsx("option",{value:"haiku",children:"Haiku"})]})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),r.jsx("input",{type:"text",value:s.allowedTools,onChange:i=>s.setAllowedTools(i.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:pa})]})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"}),r.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),r.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),r.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(i=>r.jsxs("button",{onClick:()=>s.setBodyViewMode(i),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===i?"var(--surface-4)":"transparent",color:s.bodyViewMode===i?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===i?600:400,border:"none",cursor:"pointer"},children:[i==="write"?r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 18 22 12 16 6"}),r.jsx("polyline",{points:"8 6 2 12 8 18"})]}):r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),r.jsx("span",{children:i==="write"?"Write":"Preview"})]},i))})]}),s.bodyViewMode==="write"?r.jsx("textarea",{value:s.body,onChange:i=>s.setBody(i.target.value),placeholder:`# /my-skill
|
|
109
109
|
|
|
110
110
|
You are an expert at...
|
|
111
|
-
`,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...pa,minHeight:"150px"}}):s.body.trim()?r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:oc(s.body)}}):r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),r.jsx(ON,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function fv(){return r.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),r.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),r.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function Fs({variant:t,message:a,onRetry:s}){const{setMode:i,setSearch:c}=ir(),[u,d]=p.useState(!1);return t==="no-selection"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(fv,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?r.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:r.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),r.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),r.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),r.jsxs("button",{onClick:()=>i("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="no-project-skills"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in","data-testid":"empty-state-no-project-skills",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(fv,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[15px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No skills installed for this project yet."}),r.jsx("p",{className:"text-[12px] mb-5",style:{color:"var(--text-tertiary)",maxWidth:360,textAlign:"center"},children:"Browse the marketplace to install one, or author a new skill from scratch."}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("button",{type:"button","data-testid":"empty-state-browse-marketplaces",onClick:()=>{window.dispatchEvent(new CustomEvent("studio:open-marketplace"))},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},"aria-label":"Browse marketplaces",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("circle",{cx:"9",cy:"21",r:"1"}),r.jsx("circle",{cx:"20",cy:"21",r:"1"}),r.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]}),"Browse marketplaces"]}),r.jsxs("button",{type:"button","data-testid":"empty-state-create-skill",onClick:()=>i("create"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-primary)",border:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer"},"aria-label":"Create new skill",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create new skill"]})]})]}):t==="error"?r.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:r.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[r.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:a||"Failed to load skill data"}),s&&r.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):r.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[r.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),r.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function IN(t,a){const[s,i]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>i?"minor":"patch"}const $N={major:{bg:"var(--red-muted)",text:"var(--red)"},minor:{bg:"var(--yellow-muted)",text:"var(--yellow)"},patch:{bg:"var(--green-muted)",text:"var(--green)"}};function fb(){const[t,a]=p.useState([]),[s,i]=p.useState(!0),[c,u]=p.useState(new Set),[d,h]=p.useState(new Map),[x,m]=p.useState(!1),[y,v]=p.useState(new Set),[b,S]=p.useState(new Map),[E,C]=p.useState(null),[k,N]=p.useState(null),[T,M]=p.useState(!1),_=p.useCallback(async()=>{i(!0);try{const $=await Se.getSkillUpdates();a($.filter(Y=>Y.updateAvailable))}catch{a([])}finally{i(!1)}},[]);p.useEffect(()=>{_()},[_]);const D=p.useMemo(()=>t.filter($=>!$.pinned),[t]),V=p.useCallback($=>{u(Y=>{const X=new Set(Y);return X.has($)?X.delete($):X.add($),X})},[]),w=p.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map($=>$.name)))},[c,D]),B=p.useCallback(()=>{const $=[...c];if(!$.length)return;m(!0),h(new Map($.map(X=>[X,{skill:X,status:"pending"}])));const Y=Se.startBatchUpdate($);Y.addEventListener("progress",X=>{try{const ne=JSON.parse(X.data);h(H=>new Map(H).set(ne.skill,ne))}catch{}}),Y.addEventListener("done",X=>{Y.close(),m(!1);try{const ne=JSON.parse(X.data);C(`Updated ${ne.updated??0} skills, ${ne.failed??0} failed`),setTimeout(()=>C(null),5e3)}catch{}_()}),Y.addEventListener("error",()=>{Y.close(),m(!1),C("Batch update failed"),setTimeout(()=>C(null),5e3)})},[c,_]),z=p.useCallback(async $=>{const Y=$.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],ne=Y[Y.length-1];v(H=>new Set(H).add($.name)),S(H=>{const A=new Map(H);return A.delete($.name),A});try{const H=await Se.postSkillUpdate(X,ne);if(H.ok)_();else{const A=`Update failed (HTTP ${H.status}): ${H.body}`;S(I=>new Map(I).set($.name,A)),C(`Couldn't update ${ne} — HTTP ${H.status}`),setTimeout(()=>C(null),5e3)}}catch(H){const A=H instanceof Error?H.message:"Network error";S(I=>new Map(I).set($.name,A)),C(`Couldn't update ${ne} — ${A}`),setTimeout(()=>C(null),5e3)}finally{v(H=>{const A=new Set(H);return A.delete($.name),A})}},[_]),O=p.useCallback(async $=>{if(!$.latest)return;const Y=$.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],ne=Y[Y.length-1];M(!0);try{const H=await Se.getVersionDiff(X,ne,$.installed,$.latest);N({skill:$,diff:H})}catch{N(null)}finally{M(!1)}},[]);return s?r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[r.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-16 rounded-lg"}),r.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?r.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[r.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),r.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),r.jsx("button",{onClick:_,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[E&&r.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:E}),r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:_,className:"btn btn-ghost text-[12px]",disabled:x,children:"Refresh"}),r.jsx("button",{onClick:B,disabled:c.size===0||x,className:"btn btn-primary text-[12px]",children:x?"Updating...":`Update Selected (${c.size})`})]})]}),r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsxs("button",{onClick:w,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===D.length&&D.length>0?"var(--accent)":"var(--border-default)",background:c.size===D.length&&D.length>0?"var(--accent)":"transparent"},children:c.size===D.length&&D.length>0&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),r.jsx("div",{className:"space-y-2",children:t.map($=>{const Y=$.name.split("/").pop()||$.name,X=$.latest?IN($.installed,$.latest):"patch",ne=$N[X],H=!!$.pinned,A=y.has($.name),I=d.get($.name),G=c.has($.name);return r.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:H?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!H&&V($.name),disabled:H,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:H?"not-allowed":"pointer"},children:r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:G?"var(--accent)":"var(--border-default)",background:G?"var(--accent)":"transparent",opacity:H?.4:1},children:G&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:Y}),H&&r.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),r.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:ne.bg,color:ne.text},children:X})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[$.installed," → ",$.latest||"?",H&&` (pinned at ${$.pinnedVersion||$.installed})`]})]}),I&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:I.status==="done"?"var(--green-muted)":I.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:I.status==="done"?"var(--green)":I.status==="error"?"var(--red)":"var(--yellow)"},children:[I.status,I.error&&`: ${I.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>O($),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),r.jsx("button",{onClick:()=>z($),disabled:H||A||x,title:H?"Pinned — unpin from CLI to update":"",className:`btn ${H?"btn-ghost":"btn-primary"} text-[11px]`,children:A?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(I==null?void 0:I.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},$.name)})}),k&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>N(null),children:r.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:$=>$.stopPropagation(),children:[r.jsx("div",{className:"mb-2 flex justify-end",children:r.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(Wf,{contentDiff:k.diff.contentDiff,fromLabel:k.diff.from,toLabel:k.diff.to,diffSummary:k.diff.diffSummary,renderContext:"inline"})]})})]})}const UN=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:fb},Symbol.toStringTag,{value:"Module"}));function HN(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function PN(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function VN(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;if(!a.includes("://")){const[s]=a.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(a),i=s.hostname.toLowerCase();if(i!=="github.com"&&i!=="www.github.com"&&i!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function pb(t){const{author:a,repoUrl:s}=t,i=VN(s??null),c=a&&a.trim()!==""?a:i??"—",[u,d]=p.useState(!1),h=p.useCallback(async()=>{var x;try{await((x=navigator.clipboard)==null?void 0:x.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return i?r.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${i}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!a||a.trim()===""?r.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function FN(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function GN(t,a){const s=FN(t),i=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return i?`${s}/blob/HEAD/${i}`:`${s}/blob/HEAD/`}function pv(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function mb(t){const{repoUrl:a,skillPath:s,absolutePath:i}=t,[c,u]=p.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),h=s?pv(s):i?pv(i):"source",x=p.useCallback(async()=>{var v;const y=i??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[i,s]);if(d){const y=GN(a,s);return r.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!i&&!s)return r.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const m=i??s??"";return r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${m}`,onClick:x,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function mv(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function hb(t){return t.skill?qN({skill:t.skill}):KN({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function WN(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),i=t.slice(t.length-(a-12-1));return`${s}…${i}`}function qN({skill:t}){const[a,s]=p.useState(!1),i=(t.sourcePath??t.dir)||"—",c=p.useCallback(async()=>{var h;try{await((h=navigator.clipboard)==null?void 0:h.writeText(i)),s(!0),setTimeout(()=>s(!1),1500),mv(re.toasts.pathCopied,"info")}catch{mv(re.toasts.permissionDenied,"error")}},[i]),u=t.origin==="installed"?"Project":"Skills",d=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[r.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[r.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${u}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:d}}),u]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[r.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(ii,{version:t.resolvedVersion??t.version??null,source:t.versionSource,pluginName:t.pluginName??null})}),t.pluginName&&t.pluginVersion&&r.jsxs("span",{"data-testid":"detail-header-plugin-chip",title:`This skill ships in plugin ${t.pluginName} v${t.pluginVersion}. The plugin version is independent of this skill's own version track.`,style:{display:"inline-flex",alignItems:"baseline",gap:4,fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-tertiary)",padding:"2px 6px",borderRadius:4,background:"var(--surface-1, transparent)",border:"1px solid var(--border-subtle, transparent)",whiteSpace:"nowrap"},children:[r.jsx("span",{children:"from"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:t.pluginName}),r.jsx("span",{"aria-hidden":"true",children:"@"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",color:"var(--text-secondary)"},children:t.pluginVersion})]}),t.origin==="source"&&r.jsx("button",{type:"button","data-testid":"detail-header-delete","aria-label":"Delete skill",title:"Delete skill",onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:t.plugin,skill:t.skill,dir:t.dir??"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:4,borderRadius:4},onMouseEnter:h=>{h.currentTarget.style.color="var(--red)"},onMouseLeave:h=>{h.currentTarget.style.color="var(--text-tertiary)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]}),r.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(pb,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(mb,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(YN,{skill:t}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:i,"aria-label":`Copy path ${i} to clipboard`,onClick:c,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:WN(i)}),r.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:c,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[r.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),a?"Copied":"Copy"]})]})]})}function YN({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let i="";switch(a){case"symlinked":i=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":i="Copied (independent)";break;case"authored":i="Authored";break;default:return null}return r.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[r.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:i})]})}function KN({state:t,isReadOnly:a,onDelete:s}){const{plugin:i,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:x,regressions:m,iterationCount:y}=t,v=Array.from(x.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,T)=>N+T.assertions.length,0))??0,E=(u==null?void 0:u.evals.length)??0,C=HN(b),k=PN(b);return r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[r.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[r.jsx("span",{style:{color:"var(--text-tertiary)"},children:i}),r.jsx(XN,{}),r.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),a&&r.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&r.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&r.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s&&r.jsx("button",{disabled:v,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:i,skill:c,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(QN,{})}),m.length>0&&r.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),m.length," regression",m.length>1?"s":""]}),y>0&&r.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),r.jsx("span",{className:"pill",style:{background:k,color:C},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[E," case",E!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function XN(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function QN(){return r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),r.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),r.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function ma(t){const{title:a,label:s,value:i,subtitle:c,description:u,linkLabel:d,children:h,onClick:x}=t,m=a??s??"",y=typeof x=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x==null||x())};return r.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>x==null?void 0:x():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[m?r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:m}):null,r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(i)}),c?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?r.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?r.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:d}):null]})}const ZN="Benchmarks are the aggregated score of this skill's evals (evals.yaml) run against its tests (tests/). Each test case produces a verdict; the benchmark is the mean pass rate.";function JN(t){const{onNavigate:a}=t,[s,i]=p.useState(t.open??!1),c=p.useCallback(()=>i(!1),[]);p.useEffect(()=>{if(!s)return;const d=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=p.useCallback(d=>{a==null||a(d),i(!1)},[a]);return r.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>i(d=>!d),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&r.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[r.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:ZN}),r.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:Qd,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Qd,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Qd,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Qd={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function eT(t){return`gh repo create ${t.trim()||"<repo-name>"} --public --source=. --remote=origin --push`}const tT="Add a GitHub remote: `gh repo create --public --source=.` (replace existing origin if needed).";function nT({value:t}){const[a,s]=p.useState(!1),i=p.useCallback(async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1500)}catch{}},[t]);return r.jsx("button",{type:"button","data-testid":"publish-status-copy","aria-label":"Copy GitHub setup command",onClick:i,style:{fontSize:11,padding:"3px 8px",borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",background:"var(--surface-2)",color:"var(--text-primary)",cursor:"pointer"},children:a?"Copied":"Copy"})}function hv({tone:t,label:a}){const s=t==="ok"?"color-mix(in srgb, var(--color-ok, #22c55e) 18%, transparent)":"color-mix(in srgb, var(--color-own, #f59e0b) 18%, transparent)",i=t==="ok"?"var(--color-ok, #22c55e)":"var(--color-own, #f59e0b)";return r.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:999,fontSize:11,fontWeight:500,color:i,background:s},children:a})}function rT(t={}){const{status:a,loading:s}=Iy();if(s||!a)return null;if(a.status==="github")return r.jsxs("div",{"data-testid":"publish-status-row","data-status":"github",style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsx(hv,{tone:"ok",label:"Publish-ready"}),r.jsxs("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:["GitHub origin: ",a.githubOrigin]}),r.jsx("div",{style:{marginLeft:"auto"},children:r.jsx(Xy,{remoteUrl:a.githubOrigin??"",provider:t.provider,model:t.model})})]});const i=a.status==="no-git"?eT(t.projectBasename??""):tT;return r.jsxs("div",{"data-testid":"publish-status-row","data-status":a.status,style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx(hv,{tone:"warn",label:a.status==="no-git"?"No GitHub repo yet":"Origin is not GitHub"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Connect GitHub to publish your skills."})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[r.jsx("code",{"data-testid":"publish-status-command",style:{flex:1,minWidth:0,padding:"6px 10px",borderRadius:4,background:"var(--surface-2)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:i}),r.jsx(nT,{value:i})]})]})}function xv({children:t}){return r.jsx("h3",{style:{fontFamily:"var(--font-sans)",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:"var(--text-tertiary)",margin:"0 0 8px"},children:t})}function aT({plugin:t,skill:a}){return r.jsxs("aside",{"data-testid":"skill-overview-rightrail",style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsxs("section",{"data-testid":"overview-rightrail-setup",children:[r.jsx(xv,{children:"Setup"}),r.jsx(cb,{plugin:t,skill:a})]}),r.jsxs("section",{"data-testid":"overview-rightrail-credentials",children:[r.jsx(xv,{children:"Credentials"}),r.jsx(wf,{plugin:t,skill:a})]})]})}function lT(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const a=t/1024;if(a<1024)return a>=10?`${Math.round(a)} KB`:`${a.toFixed(1).replace(/\.0$/,"")} KB`;const s=a/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function Us(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.getTime(),i=Math.floor(s/1e3);if(i<60)return"just now";const c=Math.floor(i/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const d=Math.floor(u/24);if(d<30)return`${d} day${d===1?"":"s"} ago`;const h=Math.floor(d/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const x=Math.floor(h/12);return`${x} year${x===1?"":"s"} ago`}function sT(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function iT(t){const a=t.installMethod;if(!a)return null;const s=a==="authored"?"Authored":a==="copied"?"Copied":"Symlinked";return r.jsx("span",{"data-testid":"overview-install-method",style:{display:"inline-flex",alignItems:"center",padding:"1px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:10,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:.4},children:s})}function oT(t){var v,b;const{skill:a,onNavigate:s,activationsCount:i=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(cT(a.homepage)?a.homepage??null:null),x=((v=a.mcpDeps)==null?void 0:v.length)??0,m=((b=a.deps)==null?void 0:b.length)??0,y=r.jsxs("div",{"data-testid":"skill-overview-main",style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:a.skill}),r.jsx(ii,{version:a.resolvedVersion??a.version??null,source:a.versionSource,pluginName:a.pluginName??null}),iT(a)]}),r.jsxs("div",{"data-testid":"skill-overview-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(pb,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(mb,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Us(a.lastModified)]}):null]})]}),r.jsx(rT,{}),r.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[r.jsx(ma,{title:"Benchmark",value:sT(a),subtitle:a.lastBenchmark?Us(a.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:r.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:r.jsx(JN,{onNavigate:s})})}),r.jsx(ma,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(ma,{title:"Activations",value:i,subtitle:c?`Last: ${Us(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(ma,{title:"Last run",value:Us(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(ma,{title:"MCP deps",value:x,subtitle:x>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ma,{title:"Skill deps",value:m,subtitle:m>0&&a.deps?a.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ma,{title:"Size",value:lT(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(ma,{title:"Last modified",value:Us(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]});return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 280px",gap:16,padding:16,alignItems:"start"},children:[y,r.jsx(aT,{plugin:a.plugin,skill:a.skill})]})}function cT(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function uT({skill:t}){const{onSkillUpdated:a}=ir(),{toast:s}=nc(),[i,c]=p.useState("idle"),[u,d]=p.useState(null),[h,x]=p.useState(!1),[m,y]=p.useState(null),[v,b]=p.useState(!1),S=p.useRef(null),E=p.useCallback(async()=>{if(!t||i==="updating")return;const T=new AbortController;S.current=T,c("updating"),d(null);try{const M=await Se.postSkillUpdate(t.plugin,t.skill,T.signal);if(M.ok)c("done"),a(t.plugin,t.skill),s({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const _=`Update failed (HTTP ${M.status}): ${M.body}`;c("idle"),d(_),s({message:`Couldn't update ${t.skill} — HTTP ${M.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}}catch(M){if(M instanceof DOMException&&M.name==="AbortError")return;const _=M instanceof Error?M.message:"Network error";c("idle"),d(_),s({message:`Couldn't update ${t.skill} — ${_}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}finally{S.current===T&&(S.current=null)}},[t,i,a,s]);if(p.useEffect(()=>{if(!h||m!=null||!t||!t.latestVersion)return;let T=!1;return b(!0),Se.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(M=>{T||y(M)}).catch(()=>{T||y(null)}).finally(()=>{T||b(!1)}),()=>{T=!0}},[h,m,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),p.useEffect(()=>()=>{var T;(T=S.current)==null||T.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,k=i==="updating"?"Updating…":C?`Update to ${C}`:"Update",N=i==="updating";return r.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{E()},disabled:N,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:k}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>x(T=>!T),disabled:N||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:h?"Hide changelog":"Preview changelog"})]}),i==="updating"&&r.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),u&&i!=="updating"&&r.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:u}),h&&C&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[v&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!v&&m&&r.jsx(Wf,{contentDiff:m.contentDiff,fromLabel:m.from,toLabel:m.to,diffSummary:m.diffSummary??void 0,renderContext:"inline"}),!v&&!m&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const dT=3e4;function fT({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:i=!1}){const c=ir(),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[,m]=p.useState(0),y=p.useRef(null),v=p.useRef(null),b=`${t}/${a}`,S=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const C=setInterval(()=>m(k=>(k+1)%1e6),250);return()=>clearInterval(C)},[u]),p.useEffect(()=>{if(!u||!S)return;const C=v.current??0;S.receivedAt<C||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),x(!1),v.current=null)},[u,S]),p.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||i)return null;const E=async()=>{if(!u){x(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),x(!0),y.current=null,v.current=null},dT);try{await Se.rescanSkill(t,a)}catch{y.current&&(clearTimeout(y.current),y.current=null),d(!1),v.current=null}}};return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx("button",{type:"button","data-testid":"check-now-button",onClick:E,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&r.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}function pT({tabs:t,active:a,onChange:s,parentTabId:i}){return r.jsx("div",{role:"tablist","aria-label":`${i} sub-sections`,"data-testid":`detail-subtab-bar-${i}`,style:{display:"flex",alignItems:"stretch",gap:2,borderBottom:"1px solid var(--border-subtle, var(--border-default))",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:t.map(c=>{const u=c.id===a;return r.jsx("button",{type:"button",role:"tab","aria-selected":u,tabIndex:u?0:-1,id:`detail-subtab-${i}-${c.id}`,"data-testid":`detail-subtab-${i}-${c.id}`,onClick:()=>s(c.id),style:{background:"transparent",border:"none",borderBottom:u?"2px solid var(--text-primary)":"2px solid transparent",padding:"6px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:12,fontWeight:u?500:400,color:u?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:c.label},c.id)})})}const mT=[{id:"overview",label:"Overview"},{id:"editor",label:"Edit",visibleWhen:({isReadOnly:t})=>!t},{id:"tests",label:"Tests",visibleWhen:({isReadOnly:t})=>!t},{id:"run",label:"Run",visibleWhen:({isReadOnly:t})=>!t},{id:"activation",label:"Trigger"},{id:"versions",label:"Versions"}],hT=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"];function xT(t){return typeof t=="string"&&hT.includes(t)}function xb(t){return mT.filter(a=>a.visibleWhen?a.visibleWhen({isReadOnly:t}):!0)}function gv(){if(typeof window>"u")return"overview";const a=new URLSearchParams(window.location.search).get("panel");return a==="trigger"?"activation":xT(a)?a:"overview"}const gT=new Set(["history","leaderboard","deps"]);function gb(t,a){return!a||new Set(xb(!0).map(i=>i.id)).has(t)||gT.has(t)?t:"overview"}const Il={run:[{id:"run",label:"Run"},{id:"history",label:"History"},{id:"models",label:"Models"}],activation:[{id:"run",label:"Run"},{id:"history",label:"History"}]};function vT(t){const a=Il[t];return a&&a.length>0?a[0].id:""}function yT(t,a){const s=Il[t];if(!s)return"";const c=new URLSearchParams(a).get("sub");return c&&s.some(u=>u.id===c)?c:s[0].id}function Zd(){const{state:t,setMobileView:a}=ir();return t.isMobile?r.jsxs("button",{onClick:()=>a("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function bT(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return jT(t);const{state:a,selectSkill:s,setMode:i,refreshSkills:c}=ir(),[u,d]=p.useState(typeof window<"u"?window.location.hash:"");if(p.useEffect(()=>{const m=()=>d(window.location.hash);return window.addEventListener("hashchange",m),()=>window.removeEventListener("hashchange",m)},[]),u==="#/updates")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Zd,{}),r.jsx(fb,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Zd,{}),r.jsx(BN,{onCreated:async(m,y)=>{i("browse"),await c(),s({plugin:m,skill:y,origin:"source"})},onCancel:()=>i("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(Fs,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(Fs,{variant:"no-skills"}):!a.skillsLoading&&a.skills.length>0&&!a.skills.some(m=>m.scopeV2==="available-project")?r.jsx(Fs,{variant:"no-project-skills"}):r.jsx(Fs,{variant:"no-selection"});const h=a.selectedSkill,x=a.skills.find(m=>m.plugin===h.plugin&&m.skill===h.skill)??null;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx(Zd,{}),r.jsx(ST,{skillInfo:x,allSkills:a.skills,onSelectSkill:m=>s(m)})]})}function jT(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return wT();if(t.loadError)return CT(a,t.loadError);const i=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return vb(a,s,t.onDetailTabChange,"",void 0,i)}function ST({skillInfo:t,allSkills:a,onSelectSkill:s}){const[i,c]=p.useState(gv()),[u,d]=p.useState(()=>yT(gv(),typeof window<"u"?window.location.search:""));p.useEffect(()=>{if(!t||!(t.origin==="installed"))return;const m=gb(i,!0);m!==i&&(c(m),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:"This skill is read-only — workbench tabs are hidden.",severity:"info"}})))},[t,i]),p.useEffect(()=>{d(vT(i))},[i]),p.useEffect(()=>{if(typeof window>"u")return;const x=new URLSearchParams(window.location.search);i==="overview"?x.delete("panel"):x.set("panel",i==="activation"?"trigger":i);const m=Il[i];m&&u&&u!==m[0].id?x.set("sub",u):x.delete("sub");const y=x.toString(),v=`${window.location.pathname}${y?"?"+y:""}${window.location.hash}`;window.history.replaceState(null,"",v)},[i,u]);const h=p.useMemo(()=>t?vb(t,i,c,u,d,{}):r.jsx(Fs,{variant:"no-selection"}),[t,i,u,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:h})}function kT(t,a,s){const i=xb(s);return r.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:i.map(({id:c,label:u})=>{const d=c===t;return r.jsx("button",{type:"button",role:"tab","aria-selected":d,tabIndex:d?0:-1,id:`detail-tab-${c}`,"aria-controls":`detail-panel-${c}`,"data-testid":`detail-tab-${c}`,onClick:()=>a==null?void 0:a(c),style:{background:"transparent",border:"none",borderBottom:d?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:d?500:400,color:d?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:u},c)})})}function wT(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,color:"var(--text-primary)",margin:0,marginBottom:8},children:"Select a skill to view details"}),r.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-secondary)",margin:0,maxWidth:420,textAlign:"center"},children:"Choose a skill from the sidebar — its frontmatter, filesystem info, and benchmark status will appear here."})]})}function CT(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[hb({skill:t}),r.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[r.jsxs("h3",{style:{fontFamily:"var(--font-serif)",fontSize:15,fontWeight:500,color:"var(--text-primary)",margin:"0 0 8px"},children:["Couldn't load SKILL.md for ",t.skill]}),r.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:a})]})]})}function ET({active:t,sub:a}){return t==="editor"?r.jsx(AE,{}):t==="tests"?r.jsx(BE,{}):t==="run"?a==="history"?r.jsx(uv,{}):a==="models"?r.jsx(dv,{}):r.jsx(QE,{}):t==="activation"?r.jsx(nN,{}):t==="history"?r.jsx(uv,{}):t==="leaderboard"?r.jsx(dv,{}):t==="deps"?r.jsx(RN,{}):t==="versions"?r.jsx(XC,{}):null}function NT({active:t}){const{state:a,dispatch:s}=$n();return p.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function vb(t,a,s,i="",c,u){var v;const d=t.origin==="installed",h=gb(a,d),x=b=>{s==null||s(b)},m=r.jsx(oT,{skill:t,onNavigate:x,repoUrl:t.homepage??null}),y=u!=null?r.jsxs(IC,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(NT,{active:h}),r.jsx(ET,{active:h,sub:i})]},`${t.plugin}/${t.skill}`):r.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",h," view."]});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[r.jsx("div",{style:{padding:16,paddingBottom:12},children:hb({skill:t})}),r.jsx(uT,{skill:t}),t.origin==="installed"&&r.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{style:{flex:1,minWidth:0},children:"This is an installed copy of the skill. Editing, generating tests, and running evals are disabled. Open the source skill to make changes."}),t.trackedForUpdates&&r.jsx("button",{type:"button","data-testid":"uninstall-button","aria-label":`Uninstall ${t.skill}`,onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-uninstall",{detail:{skill:{plugin:t.plugin,skill:t.skill,dir:t.dir??"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"installed"}}}))},style:{flexShrink:0,marginLeft:8,padding:"3px 10px",fontSize:11,fontWeight:500,fontFamily:"var(--font-sans)",color:"var(--text-primary)",background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:4,cursor:"pointer"},children:"Uninstall"})]}),t.origin==="installed"&&t.scopeV2!=="available-plugin"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(fT,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),kT(h,s,d),Il[h]&&r.jsx(pT,{parentTabId:h,tabs:Il[h],active:i||(((v=Il[h][0])==null?void 0:v.id)??""),onChange:c??(()=>{})}),r.jsx("div",{role:"tabpanel",id:`detail-panel-${h}`,"aria-labelledby":`detail-tab-${h}`,"data-testid":`detail-panel-${h}`,style:{flex:1,minHeight:0,overflow:"auto"},children:h==="overview"?m:y})]})}function TT(){const{updateCount:t,state:a,dismissUpdateNotification:s}=ir(),i=t>0&&!a.updateNotificationDismissed;return p.useEffect(()=>{if(!i)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[i,s]),i?r.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[r.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),r.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),r.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const RT=[{name:re.shortcuts.groupNavigation,items:[{keys:"/",label:re.shortcuts.search},{keys:"j",label:re.shortcuts.moveDown},{keys:"k",label:re.shortcuts.moveUp},{keys:"Enter",label:re.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:re.shortcuts.groupActions,items:[{keys:"⌘K",label:re.shortcuts.openPalette},{keys:"?",label:re.shortcuts.openShortcuts},{keys:"⌘B",label:re.shortcuts.toggleSidebar},{keys:"E",label:re.actions.edit}]},{name:re.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:re.shortcuts.toggleTheme}]}];function AT({open:t,onClose:a,groups:s=RT,title:i=re.shortcuts.title}){const c=p.useRef(null),u=p.useRef(null);return p.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var h,x;(x=(h=c.current)==null?void 0:h.focus)==null||x.call(h),c.current=null}},[t]),p.useEffect(()=>{if(!t)return;function d(h){var x;if(h.key==="Escape"){h.preventDefault(),a();return}h.key==="Tab"&&(h.preventDefault(),(x=u.current)==null||x.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,a]),t?r.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:d=>{d.target===d.currentTarget&&a()},children:r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:i}),r.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:a,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(d=>r.jsxs("section",{style:{marginBottom:12},children:[r.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),r.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[r.jsx("span",{children:h.label}),r.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${d.name}:${h.keys}`))})]},d.name))]})}):null}function MT(t){const a=re.actions,s=[{action:"open",label:a.open},{action:"copy-path",label:a.copyPath},{action:"reveal",label:a.revealInEditor},{action:"run-benchmark",label:a.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:a.edit},{action:"duplicate",label:a.duplicate},{action:"delete",label:a.delete}];const i=[...s];return t.updateAvailable&&i.push({action:"update",label:a.update}),i.push({action:"uninstall",label:a.uninstall}),i.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),i}function LT({state:t,onClose:a,onAction:s,itemsOverride:i}){const c=p.useRef(null),u=p.useRef(null),[d,h]=p.useState(0),x=p.useMemo(()=>t.skill?i??MT(t.skill):[],[t.skill,i]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+x.length*28;let E=t.x,C=t.y;return E+b+v>window.innerWidth&&(E=Math.max(v,t.x-b)),C+S+v>window.innerHeight&&(C=Math.max(v,t.y-S)),{left:E,top:C}},[t.x,t.y,x.length]);p.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,b;(b=(v=u.current)==null?void 0:v.focus)==null||b.call(v),u.current=null}},[t.open]);const y=p.useCallback(()=>{if(!t.skill)return;const v=x[d];!v||v.disabled||(s(v.action,t.skill),a())},[x,d,t.skill,s,a]);return p.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),a();return}if(S.key==="ArrowDown"){S.preventDefault(),h(E=>Math.min(E+1,Math.max(x.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(E=>Math.max(E-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||a())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,a,x.length,y]),!t.open||!t.skill?null:r.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:m.left,top:m.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:x.map((v,b)=>r.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{v.disabled||(s(v.action,t.skill),a())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}const vv=t=>`${t.plugin}/${t.skill}`;function yv(t){const a=(t==null?void 0:t.delayMs)??1e4,s=t==null?void 0:t.onCommit,i=t==null?void 0:t.onFailure,c=(t==null?void 0:t.apiCall)??Se.deleteSkill.bind(Se),u=p.useRef(s),d=p.useRef(i),h=p.useRef(c);u.current=s,d.current=i,h.current=c;const x=p.useRef(new Map),[,m]=p.useState(0),y=p.useCallback(()=>m(k=>k+1),[]),v=p.useCallback(async k=>{var N,T;try{await h.current(k.skill.plugin,k.skill.skill),(N=u.current)==null||N.call(u,k.skill)}catch(M){(T=d.current)==null||T.call(d,k.skill,M)}finally{x.current.delete(vv(k.skill)),y()}},[y]),b=p.useCallback(k=>{const N=vv(k),T=x.current.get(N);T!=null&&T.timeoutId&&clearTimeout(T.timeoutId);const M={skill:k,timeoutId:null};M.timeoutId=setTimeout(()=>{M.timeoutId=null,v(M)},a),x.current.set(N,M),y()},[a,v,y]),S=p.useCallback(k=>{const N=x.current.get(k);N&&(N.timeoutId&&clearTimeout(N.timeoutId),x.current.delete(k),y())},[y]),E=p.useCallback(async()=>{const k=Array.from(x.current.values());for(const N of k)N.timeoutId&&(clearTimeout(N.timeoutId),N.timeoutId=null);await Promise.all(k.map(N=>v(N)))},[v]),C=p.useCallback(k=>x.current.has(k),[]);return p.useEffect(()=>{const k=()=>{E()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[E]),p.useEffect(()=>{const k=x.current;return()=>{for(const N of k.values())N.timeoutId&&clearTimeout(N.timeoutId);k.clear()}},[]),{enqueueDelete:b,cancelDelete:S,flushPending:E,isPending:C}}const zT={"anthropic-api":{name:re.setupProviders.anthropic.name,description:re.setupProviders.anthropic.description,envVars:re.setupProviders.anthropic.envVars,keyUrl:re.setupProviders.anthropic.keyUrl,learnMoreUrl:re.setupProviders.anthropic.learnMoreUrl},openai:{name:re.setupProviders.openai.name,description:re.setupProviders.openai.description,envVars:re.setupProviders.openai.envVars,keyUrl:re.setupProviders.openai.keyUrl,learnMoreUrl:re.setupProviders.openai.learnMoreUrl},openrouter:{name:re.setupProviders.openrouter.name,description:re.setupProviders.openrouter.description,envVars:re.setupProviders.openrouter.envVars,keyUrl:re.setupProviders.openrouter.keyUrl,learnMoreUrl:re.setupProviders.openrouter.learnMoreUrl},gemini:{name:re.setupProviders.gemini.name,description:re.setupProviders.gemini.description,envVars:re.setupProviders.gemini.envVars,keyUrl:re.setupProviders.gemini.keyUrl,learnMoreUrl:re.setupProviders.gemini.learnMoreUrl},ollama:{name:re.setupProviders.ollama.name,description:re.setupProviders.ollama.description,envVars:re.setupProviders.ollama.envVars,install:[re.setupProviders.ollama.installCmd],start:[re.setupProviders.ollama.startCmd],pullExample:re.setupProviders.ollama.pullExample,learnMoreUrl:re.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:re.setupProviders.lmStudio.name,description:re.setupProviders.lmStudio.description,envVars:re.setupProviders.lmStudio.envVars,install:[re.setupProviders.lmStudio.installCmd],start:[re.setupProviders.lmStudio.startCmd],pullExample:re.setupProviders.lmStudio.pullExample,learnMoreUrl:re.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:re.setupProviders.claudeCode.name,description:re.setupProviders.claudeCode.description,envVars:[],notes:[re.setupProviders.claudeCode.loginHint,re.claudeCodeLabel.compactLabel],learnMoreUrl:re.setupProviders.claudeCode.learnMoreUrl}};function DT(t){return t?zT[t]??null:null}function _T({open:t,providerKey:a,onClose:s}){const i=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const d=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),p.useEffect(()=>{if(!t)return;const d=i.current;if(!d)return;const h=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=DT(a),u=(c==null?void 0:c.name)??re.setupDrawer.fallbackTitle;return tc.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),r.jsxs("div",{"data-testid":"setup-drawer",ref:i,role:"dialog","aria-modal":"true","aria-label":re.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsx(OT,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(BT,{content:c}):r.jsx(IT,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
|
|
111
|
+
`,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...pa,minHeight:"150px"}}):s.body.trim()?r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:oc(s.body)}}):r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),r.jsx(ON,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function fv(){return r.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),r.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),r.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function Fs({variant:t,message:a,onRetry:s}){const{setMode:i,setSearch:c}=ir(),[u,d]=p.useState(!1);return t==="no-selection"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(fv,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?r.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:r.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),r.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),r.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),r.jsxs("button",{onClick:()=>i("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="no-project-skills"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in","data-testid":"empty-state-no-project-skills",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(fv,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[15px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No skills installed for this project yet."}),r.jsx("p",{className:"text-[12px] mb-5",style:{color:"var(--text-tertiary)",maxWidth:360,textAlign:"center"},children:"Browse the marketplace to install one, or author a new skill from scratch."}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("button",{type:"button","data-testid":"empty-state-browse-marketplaces",onClick:()=>{window.dispatchEvent(new CustomEvent("studio:open-marketplace"))},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},"aria-label":"Browse marketplaces",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("circle",{cx:"9",cy:"21",r:"1"}),r.jsx("circle",{cx:"20",cy:"21",r:"1"}),r.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]}),"Browse marketplaces"]}),r.jsxs("button",{type:"button","data-testid":"empty-state-create-skill",onClick:()=>i("create"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-primary)",border:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer"},"aria-label":"Create new skill",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create new skill"]})]})]}):t==="error"?r.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:r.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[r.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:a||"Failed to load skill data"}),s&&r.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):r.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[r.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),r.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function IN(t,a){const[s,i]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>i?"minor":"patch"}const $N={major:{bg:"var(--red-muted)",text:"var(--red)"},minor:{bg:"var(--yellow-muted)",text:"var(--yellow)"},patch:{bg:"var(--green-muted)",text:"var(--green)"}};function fb(){const[t,a]=p.useState([]),[s,i]=p.useState(!0),[c,u]=p.useState(new Set),[d,h]=p.useState(new Map),[x,m]=p.useState(!1),[y,v]=p.useState(new Set),[b,S]=p.useState(new Map),[E,C]=p.useState(null),[k,N]=p.useState(null),[T,M]=p.useState(!1),_=p.useCallback(async()=>{i(!0);try{const $=await Se.getSkillUpdates();a($.filter(Y=>Y.updateAvailable))}catch{a([])}finally{i(!1)}},[]);p.useEffect(()=>{_()},[_]);const D=p.useMemo(()=>t.filter($=>!$.pinned),[t]),V=p.useCallback($=>{u(Y=>{const X=new Set(Y);return X.has($)?X.delete($):X.add($),X})},[]),w=p.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map($=>$.name)))},[c,D]),B=p.useCallback(()=>{const $=[...c];if(!$.length)return;m(!0),h(new Map($.map(X=>[X,{skill:X,status:"pending"}])));const Y=Se.startBatchUpdate($);Y.addEventListener("progress",X=>{try{const ne=JSON.parse(X.data);h(H=>new Map(H).set(ne.skill,ne))}catch{}}),Y.addEventListener("done",X=>{Y.close(),m(!1);try{const ne=JSON.parse(X.data);C(`Updated ${ne.updated??0} skills, ${ne.failed??0} failed`),setTimeout(()=>C(null),5e3)}catch{}_()}),Y.addEventListener("error",()=>{Y.close(),m(!1),C("Batch update failed"),setTimeout(()=>C(null),5e3)})},[c,_]),z=p.useCallback(async $=>{const Y=$.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],ne=Y[Y.length-1];v(H=>new Set(H).add($.name)),S(H=>{const A=new Map(H);return A.delete($.name),A});try{const H=await Se.postSkillUpdate(X,ne);if(H.ok)_();else{const A=`Update failed (HTTP ${H.status}): ${H.body}`;S(I=>new Map(I).set($.name,A)),C(`Couldn't update ${ne} — HTTP ${H.status}`),setTimeout(()=>C(null),5e3)}}catch(H){const A=H instanceof Error?H.message:"Network error";S(I=>new Map(I).set($.name,A)),C(`Couldn't update ${ne} — ${A}`),setTimeout(()=>C(null),5e3)}finally{v(H=>{const A=new Set(H);return A.delete($.name),A})}},[_]),O=p.useCallback(async $=>{if(!$.latest)return;const Y=$.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],ne=Y[Y.length-1];M(!0);try{const H=await Se.getVersionDiff(X,ne,$.installed,$.latest);N({skill:$,diff:H})}catch{N(null)}finally{M(!1)}},[]);return s?r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[r.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-16 rounded-lg"}),r.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?r.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[r.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),r.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),r.jsx("button",{onClick:_,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[E&&r.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:E}),r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:_,className:"btn btn-ghost text-[12px]",disabled:x,children:"Refresh"}),r.jsx("button",{onClick:B,disabled:c.size===0||x,className:"btn btn-primary text-[12px]",children:x?"Updating...":`Update Selected (${c.size})`})]})]}),r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsxs("button",{onClick:w,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===D.length&&D.length>0?"var(--accent)":"var(--border-default)",background:c.size===D.length&&D.length>0?"var(--accent)":"transparent"},children:c.size===D.length&&D.length>0&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),r.jsx("div",{className:"space-y-2",children:t.map($=>{const Y=$.name.split("/").pop()||$.name,X=$.latest?IN($.installed,$.latest):"patch",ne=$N[X],H=!!$.pinned,A=y.has($.name),I=d.get($.name),G=c.has($.name);return r.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:H?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!H&&V($.name),disabled:H,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:H?"not-allowed":"pointer"},children:r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:G?"var(--accent)":"var(--border-default)",background:G?"var(--accent)":"transparent",opacity:H?.4:1},children:G&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:Y}),H&&r.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),r.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:ne.bg,color:ne.text},children:X})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[$.installed," → ",$.latest||"?",H&&` (pinned at ${$.pinnedVersion||$.installed})`]})]}),I&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:I.status==="done"?"var(--green-muted)":I.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:I.status==="done"?"var(--green)":I.status==="error"?"var(--red)":"var(--yellow)"},children:[I.status,I.error&&`: ${I.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>O($),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),r.jsx("button",{onClick:()=>z($),disabled:H||A||x,title:H?"Pinned — unpin from CLI to update":"",className:`btn ${H?"btn-ghost":"btn-primary"} text-[11px]`,children:A?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(I==null?void 0:I.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},$.name)})}),k&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>N(null),children:r.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:$=>$.stopPropagation(),children:[r.jsx("div",{className:"mb-2 flex justify-end",children:r.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(Wf,{contentDiff:k.diff.contentDiff,fromLabel:k.diff.from,toLabel:k.diff.to,diffSummary:k.diff.diffSummary,renderContext:"inline"})]})})]})}const UN=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:fb},Symbol.toStringTag,{value:"Module"}));function HN(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function PN(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function VN(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;if(!a.includes("://")){const[s]=a.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(a),i=s.hostname.toLowerCase();if(i!=="github.com"&&i!=="www.github.com"&&i!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function pb(t){const{author:a,repoUrl:s}=t,i=VN(s??null),c=a&&a.trim()!==""?a:i??"—",[u,d]=p.useState(!1),h=p.useCallback(async()=>{var x;try{await((x=navigator.clipboard)==null?void 0:x.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return i?r.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${i}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!a||a.trim()===""?r.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function FN(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function GN(t,a){const s=FN(t),i=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return i?`${s}/blob/HEAD/${i}`:`${s}/blob/HEAD/`}function pv(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function mb(t){const{repoUrl:a,skillPath:s,absolutePath:i}=t,[c,u]=p.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),h=s?pv(s):i?pv(i):"source",x=p.useCallback(async()=>{var v;const y=i??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[i,s]);if(d){const y=GN(a,s);return r.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!i&&!s)return r.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const m=i??s??"";return r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${m}`,onClick:x,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function mv(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function hb(t){return t.skill?qN({skill:t.skill}):KN({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function WN(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),i=t.slice(t.length-(a-12-1));return`${s}…${i}`}function qN({skill:t}){const[a,s]=p.useState(!1),i=(t.sourcePath??t.dir)||"—",c=p.useCallback(async()=>{var h;try{await((h=navigator.clipboard)==null?void 0:h.writeText(i)),s(!0),setTimeout(()=>s(!1),1500),mv(re.toasts.pathCopied,"info")}catch{mv(re.toasts.permissionDenied,"error")}},[i]),u=t.origin==="installed"?"Project":"Skills",d=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[r.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[r.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${u}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:d}}),u]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[r.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(ii,{version:t.resolvedVersion??t.version??null,source:t.versionSource,pluginName:t.pluginName??null})}),t.pluginName&&t.pluginVersion&&r.jsxs("span",{"data-testid":"detail-header-plugin-chip",title:`This skill ships in plugin ${t.pluginName} v${t.pluginVersion}. The plugin version is independent of this skill's own version track.`,style:{display:"inline-flex",alignItems:"baseline",gap:4,fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-tertiary)",padding:"2px 6px",borderRadius:4,background:"var(--surface-1, transparent)",border:"1px solid var(--border-subtle, transparent)",whiteSpace:"nowrap"},children:[r.jsx("span",{children:"from"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:t.pluginName}),r.jsx("span",{"aria-hidden":"true",children:"@"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",color:"var(--text-secondary)"},children:t.pluginVersion})]}),t.origin==="source"&&r.jsx("button",{type:"button","data-testid":"detail-header-delete","aria-label":"Delete skill",title:"Delete skill",onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))},className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:4,borderRadius:4},onMouseEnter:h=>{h.currentTarget.style.color="var(--red)"},onMouseLeave:h=>{h.currentTarget.style.color="var(--text-tertiary)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]}),r.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(pb,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(mb,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(YN,{skill:t}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:i,"aria-label":`Copy path ${i} to clipboard`,onClick:c,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:WN(i)}),r.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:c,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[r.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),a?"Copied":"Copy"]})]})]})}function YN({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let i="";switch(a){case"symlinked":i=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":i="Copied (independent)";break;case"authored":i="Authored";break;default:return null}return r.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[r.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:i})]})}function KN({state:t,isReadOnly:a,onDelete:s}){const{plugin:i,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:x,regressions:m,iterationCount:y}=t,v=Array.from(x.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,T)=>N+T.assertions.length,0))??0,E=(u==null?void 0:u.evals.length)??0,C=HN(b),k=PN(b);return r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[r.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[r.jsx("span",{style:{color:"var(--text-tertiary)"},children:i}),r.jsx(XN,{}),r.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),a&&r.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&r.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&r.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s&&r.jsx("button",{disabled:v,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:i,skill:c,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(QN,{})}),m.length>0&&r.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),m.length," regression",m.length>1?"s":""]}),y>0&&r.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),r.jsx("span",{className:"pill",style:{background:k,color:C},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[E," case",E!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function XN(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function QN(){return r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),r.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),r.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function ma(t){const{title:a,label:s,value:i,subtitle:c,description:u,linkLabel:d,children:h,onClick:x}=t,m=a??s??"",y=typeof x=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x==null||x())};return r.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>x==null?void 0:x():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[m?r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:m}):null,r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(i)}),c?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?r.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?r.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:d}):null]})}const ZN="Benchmarks are the aggregated score of this skill's evals (evals.yaml) run against its tests (tests/). Each test case produces a verdict; the benchmark is the mean pass rate.";function JN(t){const{onNavigate:a}=t,[s,i]=p.useState(t.open??!1),c=p.useCallback(()=>i(!1),[]);p.useEffect(()=>{if(!s)return;const d=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=p.useCallback(d=>{a==null||a(d),i(!1)},[a]);return r.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>i(d=>!d),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&r.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[r.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:ZN}),r.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:Qd,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Qd,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Qd,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Qd={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function eT(t){return`gh repo create ${t.trim()||"<repo-name>"} --public --source=. --remote=origin --push`}const tT="Add a GitHub remote: `gh repo create --public --source=.` (replace existing origin if needed).";function nT({value:t}){const[a,s]=p.useState(!1),i=p.useCallback(async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1500)}catch{}},[t]);return r.jsx("button",{type:"button","data-testid":"publish-status-copy","aria-label":"Copy GitHub setup command",onClick:i,style:{fontSize:11,padding:"3px 8px",borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",background:"var(--surface-2)",color:"var(--text-primary)",cursor:"pointer"},children:a?"Copied":"Copy"})}function hv({tone:t,label:a}){const s=t==="ok"?"color-mix(in srgb, var(--color-ok, #22c55e) 18%, transparent)":"color-mix(in srgb, var(--color-own, #f59e0b) 18%, transparent)",i=t==="ok"?"var(--color-ok, #22c55e)":"var(--color-own, #f59e0b)";return r.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:999,fontSize:11,fontWeight:500,color:i,background:s},children:a})}function rT(t={}){const{status:a,loading:s}=Iy();if(s||!a)return null;if(a.status==="github")return r.jsxs("div",{"data-testid":"publish-status-row","data-status":"github",style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsx(hv,{tone:"ok",label:"Publish-ready"}),r.jsxs("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:["GitHub origin: ",a.githubOrigin]}),r.jsx("div",{style:{marginLeft:"auto"},children:r.jsx(Xy,{remoteUrl:a.githubOrigin??"",provider:t.provider,model:t.model})})]});const i=a.status==="no-git"?eT(t.projectBasename??""):tT;return r.jsxs("div",{"data-testid":"publish-status-row","data-status":a.status,style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx(hv,{tone:"warn",label:a.status==="no-git"?"No GitHub repo yet":"Origin is not GitHub"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Connect GitHub to publish your skills."})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[r.jsx("code",{"data-testid":"publish-status-command",style:{flex:1,minWidth:0,padding:"6px 10px",borderRadius:4,background:"var(--surface-2)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:i}),r.jsx(nT,{value:i})]})]})}function xv({children:t}){return r.jsx("h3",{style:{fontFamily:"var(--font-sans)",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:"var(--text-tertiary)",margin:"0 0 8px"},children:t})}function aT({plugin:t,skill:a}){return r.jsxs("aside",{"data-testid":"skill-overview-rightrail",style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsxs("section",{"data-testid":"overview-rightrail-setup",children:[r.jsx(xv,{children:"Setup"}),r.jsx(cb,{plugin:t,skill:a})]}),r.jsxs("section",{"data-testid":"overview-rightrail-credentials",children:[r.jsx(xv,{children:"Credentials"}),r.jsx(wf,{plugin:t,skill:a})]})]})}function lT(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const a=t/1024;if(a<1024)return a>=10?`${Math.round(a)} KB`:`${a.toFixed(1).replace(/\.0$/,"")} KB`;const s=a/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function Us(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.getTime(),i=Math.floor(s/1e3);if(i<60)return"just now";const c=Math.floor(i/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const d=Math.floor(u/24);if(d<30)return`${d} day${d===1?"":"s"} ago`;const h=Math.floor(d/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const x=Math.floor(h/12);return`${x} year${x===1?"":"s"} ago`}function sT(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function iT(t){const a=t.installMethod;if(!a)return null;const s=a==="authored"?"Authored":a==="copied"?"Copied":"Symlinked";return r.jsx("span",{"data-testid":"overview-install-method",style:{display:"inline-flex",alignItems:"center",padding:"1px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:10,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:.4},children:s})}function oT(t){var v,b;const{skill:a,onNavigate:s,activationsCount:i=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(cT(a.homepage)?a.homepage??null:null),x=((v=a.mcpDeps)==null?void 0:v.length)??0,m=((b=a.deps)==null?void 0:b.length)??0,y=r.jsxs("div",{"data-testid":"skill-overview-main",style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:a.skill}),r.jsx(ii,{version:a.resolvedVersion??a.version??null,source:a.versionSource,pluginName:a.pluginName??null}),iT(a)]}),r.jsxs("div",{"data-testid":"skill-overview-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(pb,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(mb,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Us(a.lastModified)]}):null]})]}),r.jsx(rT,{}),r.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[r.jsx(ma,{title:"Benchmark",value:sT(a),subtitle:a.lastBenchmark?Us(a.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:r.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:r.jsx(JN,{onNavigate:s})})}),r.jsx(ma,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(ma,{title:"Activations",value:i,subtitle:c?`Last: ${Us(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(ma,{title:"Last run",value:Us(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(ma,{title:"MCP deps",value:x,subtitle:x>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ma,{title:"Skill deps",value:m,subtitle:m>0&&a.deps?a.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ma,{title:"Size",value:lT(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(ma,{title:"Last modified",value:Us(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]});return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 280px",gap:16,padding:16,alignItems:"start"},children:[y,r.jsx(aT,{plugin:a.plugin,skill:a.skill})]})}function cT(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function uT({skill:t}){const{onSkillUpdated:a}=ir(),{toast:s}=nc(),[i,c]=p.useState("idle"),[u,d]=p.useState(null),[h,x]=p.useState(!1),[m,y]=p.useState(null),[v,b]=p.useState(!1),S=p.useRef(null),E=p.useCallback(async()=>{if(!t||i==="updating")return;const T=new AbortController;S.current=T,c("updating"),d(null);try{const M=await Se.postSkillUpdate(t.plugin,t.skill,T.signal);if(M.ok)c("done"),a(t.plugin,t.skill),s({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const _=`Update failed (HTTP ${M.status}): ${M.body}`;c("idle"),d(_),s({message:`Couldn't update ${t.skill} — HTTP ${M.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}}catch(M){if(M instanceof DOMException&&M.name==="AbortError")return;const _=M instanceof Error?M.message:"Network error";c("idle"),d(_),s({message:`Couldn't update ${t.skill} — ${_}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}finally{S.current===T&&(S.current=null)}},[t,i,a,s]);if(p.useEffect(()=>{if(!h||m!=null||!t||!t.latestVersion)return;let T=!1;return b(!0),Se.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(M=>{T||y(M)}).catch(()=>{T||y(null)}).finally(()=>{T||b(!1)}),()=>{T=!0}},[h,m,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),p.useEffect(()=>()=>{var T;(T=S.current)==null||T.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,k=i==="updating"?"Updating…":C?`Update to ${C}`:"Update",N=i==="updating";return r.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{E()},disabled:N,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:k}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>x(T=>!T),disabled:N||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:h?"Hide changelog":"Preview changelog"})]}),i==="updating"&&r.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),u&&i!=="updating"&&r.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:u}),h&&C&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[v&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!v&&m&&r.jsx(Wf,{contentDiff:m.contentDiff,fromLabel:m.from,toLabel:m.to,diffSummary:m.diffSummary??void 0,renderContext:"inline"}),!v&&!m&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const dT=3e4;function fT({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:i=!1}){const c=ir(),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[,m]=p.useState(0),y=p.useRef(null),v=p.useRef(null),b=`${t}/${a}`,S=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const C=setInterval(()=>m(k=>(k+1)%1e6),250);return()=>clearInterval(C)},[u]),p.useEffect(()=>{if(!u||!S)return;const C=v.current??0;S.receivedAt<C||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),x(!1),v.current=null)},[u,S]),p.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||i)return null;const E=async()=>{if(!u){x(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),x(!0),y.current=null,v.current=null},dT);try{await Se.rescanSkill(t,a)}catch{y.current&&(clearTimeout(y.current),y.current=null),d(!1),v.current=null}}};return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx("button",{type:"button","data-testid":"check-now-button",onClick:E,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&r.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}function pT({tabs:t,active:a,onChange:s,parentTabId:i}){return r.jsx("div",{role:"tablist","aria-label":`${i} sub-sections`,"data-testid":`detail-subtab-bar-${i}`,style:{display:"flex",alignItems:"stretch",gap:2,borderBottom:"1px solid var(--border-subtle, var(--border-default))",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:t.map(c=>{const u=c.id===a;return r.jsx("button",{type:"button",role:"tab","aria-selected":u,tabIndex:u?0:-1,id:`detail-subtab-${i}-${c.id}`,"data-testid":`detail-subtab-${i}-${c.id}`,onClick:()=>s(c.id),style:{background:"transparent",border:"none",borderBottom:u?"2px solid var(--text-primary)":"2px solid transparent",padding:"6px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:12,fontWeight:u?500:400,color:u?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:c.label},c.id)})})}const mT=[{id:"overview",label:"Overview"},{id:"editor",label:"Edit",visibleWhen:({isReadOnly:t})=>!t},{id:"tests",label:"Tests",visibleWhen:({isReadOnly:t})=>!t},{id:"run",label:"Run",visibleWhen:({isReadOnly:t})=>!t},{id:"activation",label:"Trigger"},{id:"versions",label:"Versions"}],hT=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"];function xT(t){return typeof t=="string"&&hT.includes(t)}function xb(t){return mT.filter(a=>a.visibleWhen?a.visibleWhen({isReadOnly:t}):!0)}function gv(){if(typeof window>"u")return"overview";const a=new URLSearchParams(window.location.search).get("panel");return a==="trigger"?"activation":xT(a)?a:"overview"}const gT=new Set(["history","leaderboard","deps"]);function gb(t,a){return!a||new Set(xb(!0).map(i=>i.id)).has(t)||gT.has(t)?t:"overview"}const Il={run:[{id:"run",label:"Run"},{id:"history",label:"History"},{id:"models",label:"Models"}],activation:[{id:"run",label:"Run"},{id:"history",label:"History"}]};function vT(t){const a=Il[t];return a&&a.length>0?a[0].id:""}function yT(t,a){const s=Il[t];if(!s)return"";const c=new URLSearchParams(a).get("sub");return c&&s.some(u=>u.id===c)?c:s[0].id}function Zd(){const{state:t,setMobileView:a}=ir();return t.isMobile?r.jsxs("button",{onClick:()=>a("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function bT(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return jT(t);const{state:a,selectSkill:s,setMode:i,refreshSkills:c}=ir(),[u,d]=p.useState(typeof window<"u"?window.location.hash:"");if(p.useEffect(()=>{const m=()=>d(window.location.hash);return window.addEventListener("hashchange",m),()=>window.removeEventListener("hashchange",m)},[]),u==="#/updates")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Zd,{}),r.jsx(fb,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Zd,{}),r.jsx(BN,{onCreated:async(m,y)=>{i("browse"),await c(),s({plugin:m,skill:y,origin:"source"})},onCancel:()=>i("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(Fs,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(Fs,{variant:"no-skills"}):!a.skillsLoading&&a.skills.length>0&&!a.skills.some(m=>m.scopeV2==="available-project")?r.jsx(Fs,{variant:"no-project-skills"}):r.jsx(Fs,{variant:"no-selection"});const h=a.selectedSkill,x=a.skills.find(m=>m.plugin===h.plugin&&m.skill===h.skill)??null;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx(Zd,{}),r.jsx(ST,{skillInfo:x,allSkills:a.skills,onSelectSkill:m=>s(m)})]})}function jT(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return wT();if(t.loadError)return CT(a,t.loadError);const i=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return vb(a,s,t.onDetailTabChange,"",void 0,i)}function ST({skillInfo:t,allSkills:a,onSelectSkill:s}){const[i,c]=p.useState(gv()),[u,d]=p.useState(()=>yT(gv(),typeof window<"u"?window.location.search:""));p.useEffect(()=>{if(!t||!(t.origin==="installed"))return;const m=gb(i,!0);m!==i&&(c(m),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:"This skill is read-only — workbench tabs are hidden.",severity:"info"}})))},[t,i]),p.useEffect(()=>{d(vT(i))},[i]),p.useEffect(()=>{if(typeof window>"u")return;const x=new URLSearchParams(window.location.search);i==="overview"?x.delete("panel"):x.set("panel",i==="activation"?"trigger":i);const m=Il[i];m&&u&&u!==m[0].id?x.set("sub",u):x.delete("sub");const y=x.toString(),v=`${window.location.pathname}${y?"?"+y:""}${window.location.hash}`;window.history.replaceState(null,"",v)},[i,u]);const h=p.useMemo(()=>t?vb(t,i,c,u,d,{}):r.jsx(Fs,{variant:"no-selection"}),[t,i,u,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:h})}function kT(t,a,s){const i=xb(s);return r.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:i.map(({id:c,label:u})=>{const d=c===t;return r.jsx("button",{type:"button",role:"tab","aria-selected":d,tabIndex:d?0:-1,id:`detail-tab-${c}`,"aria-controls":`detail-panel-${c}`,"data-testid":`detail-tab-${c}`,onClick:()=>a==null?void 0:a(c),style:{background:"transparent",border:"none",borderBottom:d?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:d?500:400,color:d?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:u},c)})})}function wT(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,color:"var(--text-primary)",margin:0,marginBottom:8},children:"Select a skill to view details"}),r.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-secondary)",margin:0,maxWidth:420,textAlign:"center"},children:"Choose a skill from the sidebar — its frontmatter, filesystem info, and benchmark status will appear here."})]})}function CT(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[hb({skill:t}),r.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[r.jsxs("h3",{style:{fontFamily:"var(--font-serif)",fontSize:15,fontWeight:500,color:"var(--text-primary)",margin:"0 0 8px"},children:["Couldn't load SKILL.md for ",t.skill]}),r.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:a})]})]})}function ET({active:t,sub:a}){return t==="editor"?r.jsx(AE,{}):t==="tests"?r.jsx(BE,{}):t==="run"?a==="history"?r.jsx(uv,{}):a==="models"?r.jsx(dv,{}):r.jsx(QE,{}):t==="activation"?r.jsx(nN,{}):t==="history"?r.jsx(uv,{}):t==="leaderboard"?r.jsx(dv,{}):t==="deps"?r.jsx(RN,{}):t==="versions"?r.jsx(XC,{}):null}function NT({active:t}){const{state:a,dispatch:s}=$n();return p.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function vb(t,a,s,i="",c,u){var v;const d=t.origin==="installed",h=gb(a,d),x=b=>{s==null||s(b)},m=r.jsx(oT,{skill:t,onNavigate:x,repoUrl:t.homepage??null}),y=u!=null?r.jsxs(IC,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(NT,{active:h}),r.jsx(ET,{active:h,sub:i})]},`${t.plugin}/${t.skill}`):r.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",h," view."]});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[r.jsx("div",{style:{padding:16,paddingBottom:12},children:hb({skill:t})}),r.jsx(uT,{skill:t}),t.origin==="installed"&&r.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{style:{flex:1,minWidth:0},children:"This is an installed copy of the skill. Editing, generating tests, and running evals are disabled. Open the source skill to make changes."}),t.trackedForUpdates&&r.jsx("button",{type:"button","data-testid":"uninstall-button","aria-label":`Uninstall ${t.skill}`,onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-uninstall",{detail:{skill:{plugin:t.plugin,skill:t.skill,dir:t.dir??"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"installed"}}}))},style:{flexShrink:0,marginLeft:8,padding:"3px 10px",fontSize:11,fontWeight:500,fontFamily:"var(--font-sans)",color:"var(--text-primary)",background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:4,cursor:"pointer"},children:"Uninstall"})]}),t.origin==="installed"&&t.scopeV2!=="available-plugin"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(fT,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),kT(h,s,d),Il[h]&&r.jsx(pT,{parentTabId:h,tabs:Il[h],active:i||(((v=Il[h][0])==null?void 0:v.id)??""),onChange:c??(()=>{})}),r.jsx("div",{role:"tabpanel",id:`detail-panel-${h}`,"aria-labelledby":`detail-tab-${h}`,"data-testid":`detail-panel-${h}`,style:{flex:1,minHeight:0,overflow:"auto"},children:h==="overview"?m:y})]})}function TT(){const{updateCount:t,state:a,dismissUpdateNotification:s}=ir(),i=t>0&&!a.updateNotificationDismissed;return p.useEffect(()=>{if(!i)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[i,s]),i?r.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[r.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),r.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),r.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const RT=[{name:re.shortcuts.groupNavigation,items:[{keys:"/",label:re.shortcuts.search},{keys:"j",label:re.shortcuts.moveDown},{keys:"k",label:re.shortcuts.moveUp},{keys:"Enter",label:re.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:re.shortcuts.groupActions,items:[{keys:"⌘K",label:re.shortcuts.openPalette},{keys:"?",label:re.shortcuts.openShortcuts},{keys:"⌘B",label:re.shortcuts.toggleSidebar},{keys:"E",label:re.actions.edit}]},{name:re.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:re.shortcuts.toggleTheme}]}];function AT({open:t,onClose:a,groups:s=RT,title:i=re.shortcuts.title}){const c=p.useRef(null),u=p.useRef(null);return p.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var h,x;(x=(h=c.current)==null?void 0:h.focus)==null||x.call(h),c.current=null}},[t]),p.useEffect(()=>{if(!t)return;function d(h){var x;if(h.key==="Escape"){h.preventDefault(),a();return}h.key==="Tab"&&(h.preventDefault(),(x=u.current)==null||x.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,a]),t?r.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:d=>{d.target===d.currentTarget&&a()},children:r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:i}),r.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:a,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(d=>r.jsxs("section",{style:{marginBottom:12},children:[r.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),r.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[r.jsx("span",{children:h.label}),r.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${d.name}:${h.keys}`))})]},d.name))]})}):null}function MT(t){const a=re.actions,s=[{action:"open",label:a.open},{action:"copy-path",label:a.copyPath},{action:"reveal",label:a.revealInEditor},{action:"run-benchmark",label:a.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:a.edit},{action:"duplicate",label:a.duplicate},{action:"delete",label:a.delete}];const i=[...s];return t.updateAvailable&&i.push({action:"update",label:a.update}),i.push({action:"uninstall",label:a.uninstall}),i.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),i}function LT({state:t,onClose:a,onAction:s,itemsOverride:i}){const c=p.useRef(null),u=p.useRef(null),[d,h]=p.useState(0),x=p.useMemo(()=>t.skill?i??MT(t.skill):[],[t.skill,i]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+x.length*28;let E=t.x,C=t.y;return E+b+v>window.innerWidth&&(E=Math.max(v,t.x-b)),C+S+v>window.innerHeight&&(C=Math.max(v,t.y-S)),{left:E,top:C}},[t.x,t.y,x.length]);p.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,b;(b=(v=u.current)==null?void 0:v.focus)==null||b.call(v),u.current=null}},[t.open]);const y=p.useCallback(()=>{if(!t.skill)return;const v=x[d];!v||v.disabled||(s(v.action,t.skill),a())},[x,d,t.skill,s,a]);return p.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),a();return}if(S.key==="ArrowDown"){S.preventDefault(),h(E=>Math.min(E+1,Math.max(x.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(E=>Math.max(E-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||a())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,a,x.length,y]),!t.open||!t.skill?null:r.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:m.left,top:m.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:x.map((v,b)=>r.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{v.disabled||(s(v.action,t.skill),a())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}const vv=t=>`${t.plugin}/${t.skill}`;function yv(t){const a=(t==null?void 0:t.delayMs)??1e4,s=t==null?void 0:t.onCommit,i=t==null?void 0:t.onFailure,c=(t==null?void 0:t.apiCall)??Se.deleteSkill.bind(Se),u=p.useRef(s),d=p.useRef(i),h=p.useRef(c);u.current=s,d.current=i,h.current=c;const x=p.useRef(new Map),[,m]=p.useState(0),y=p.useCallback(()=>m(k=>k+1),[]),v=p.useCallback(async k=>{var N,T;try{await h.current(k.skill.plugin,k.skill.skill),(N=u.current)==null||N.call(u,k.skill)}catch(M){(T=d.current)==null||T.call(d,k.skill,M)}finally{x.current.delete(vv(k.skill)),y()}},[y]),b=p.useCallback(k=>{const N=vv(k),T=x.current.get(N);T!=null&&T.timeoutId&&clearTimeout(T.timeoutId);const M={skill:k,timeoutId:null};M.timeoutId=setTimeout(()=>{M.timeoutId=null,v(M)},a),x.current.set(N,M),y()},[a,v,y]),S=p.useCallback(k=>{const N=x.current.get(k);N&&(N.timeoutId&&clearTimeout(N.timeoutId),x.current.delete(k),y())},[y]),E=p.useCallback(async()=>{const k=Array.from(x.current.values());for(const N of k)N.timeoutId&&(clearTimeout(N.timeoutId),N.timeoutId=null);await Promise.all(k.map(N=>v(N)))},[v]),C=p.useCallback(k=>x.current.has(k),[]);return p.useEffect(()=>{const k=()=>{E()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[E]),p.useEffect(()=>{const k=x.current;return()=>{for(const N of k.values())N.timeoutId&&clearTimeout(N.timeoutId);k.clear()}},[]),{enqueueDelete:b,cancelDelete:S,flushPending:E,isPending:C}}const zT={"anthropic-api":{name:re.setupProviders.anthropic.name,description:re.setupProviders.anthropic.description,envVars:re.setupProviders.anthropic.envVars,keyUrl:re.setupProviders.anthropic.keyUrl,learnMoreUrl:re.setupProviders.anthropic.learnMoreUrl},openai:{name:re.setupProviders.openai.name,description:re.setupProviders.openai.description,envVars:re.setupProviders.openai.envVars,keyUrl:re.setupProviders.openai.keyUrl,learnMoreUrl:re.setupProviders.openai.learnMoreUrl},openrouter:{name:re.setupProviders.openrouter.name,description:re.setupProviders.openrouter.description,envVars:re.setupProviders.openrouter.envVars,keyUrl:re.setupProviders.openrouter.keyUrl,learnMoreUrl:re.setupProviders.openrouter.learnMoreUrl},gemini:{name:re.setupProviders.gemini.name,description:re.setupProviders.gemini.description,envVars:re.setupProviders.gemini.envVars,keyUrl:re.setupProviders.gemini.keyUrl,learnMoreUrl:re.setupProviders.gemini.learnMoreUrl},ollama:{name:re.setupProviders.ollama.name,description:re.setupProviders.ollama.description,envVars:re.setupProviders.ollama.envVars,install:[re.setupProviders.ollama.installCmd],start:[re.setupProviders.ollama.startCmd],pullExample:re.setupProviders.ollama.pullExample,learnMoreUrl:re.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:re.setupProviders.lmStudio.name,description:re.setupProviders.lmStudio.description,envVars:re.setupProviders.lmStudio.envVars,install:[re.setupProviders.lmStudio.installCmd],start:[re.setupProviders.lmStudio.startCmd],pullExample:re.setupProviders.lmStudio.pullExample,learnMoreUrl:re.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:re.setupProviders.claudeCode.name,description:re.setupProviders.claudeCode.description,envVars:[],notes:[re.setupProviders.claudeCode.loginHint,re.claudeCodeLabel.compactLabel],learnMoreUrl:re.setupProviders.claudeCode.learnMoreUrl}};function DT(t){return t?zT[t]??null:null}function _T({open:t,providerKey:a,onClose:s}){const i=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const d=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),p.useEffect(()=>{if(!t)return;const d=i.current;if(!d)return;const h=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=DT(a),u=(c==null?void 0:c.name)??re.setupDrawer.fallbackTitle;return tc.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),r.jsxs("div",{"data-testid":"setup-drawer",ref:i,role:"dialog","aria-modal":"true","aria-label":re.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsx(OT,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(BT,{content:c}):r.jsx(IT,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
|
|
112
112
|
from { transform: translateX(100%); }
|
|
113
113
|
to { transform: translateX(0); }
|
|
114
114
|
}
|
|
@@ -119,4 +119,4 @@ You are an expert at...
|
|
|
119
119
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
120
120
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
121
121
|
}`})]}),document.body)}function FT({agent:t,focused:a,active:s,onClick:i}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:i,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount,"·",t.pluginCount??0]})]})}function GT({row:t,onFocus:a}){return r.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:a,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),r.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function WT({agent:t}){const a=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return r.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:a,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),r.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&r.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function qT({agent:t,activeAgentId:a,onSwitch:s}){const i=t.id===a,c=t.isRemoteOnly===!0,u=i||c,d=i?"Active":c?"Remote-only":re.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":KT(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(zo,{label:re.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(zo,{label:re.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(zo,{label:re.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),r.jsx(zo,{label:re.scopePicker.statsLastSync,value:t.lastSync?YT(t.lastSync):"—"})]}),r.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function zo({label:t,value:a}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:a})]})}function bv(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function YT(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const i=Math.round(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const c=Math.round(i/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function KT(t){switch(t){case"ok":return re.scopePicker.statsHealthOk;case"stale":return re.scopePicker.statsHealthStale;case"missing":return re.scopePicker.statsHealthMissing}}function XT(t){const a=new Map;for(const s of t.sharedFolders??[])for(const i of s.consumers)a.set(i,s);return t.agents.map(s=>{const i=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,pluginCount:s.pluginSkillCount??0,lastSync:s.lastSync,health:s.health,sharedFolderGroup:i?i.consumers:void 0,sharedFolderPath:i?i.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function QT({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:i}){const[c,u]=p.useState(!1),[d,h]=p.useState(null),x=p.useRef(null),m=p.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),y=p.useMemo(()=>m?m.health==="ok"?"var(--color-ok, #22c55e)":m.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[m]),v=p.useCallback(()=>{var S;u(!1),(S=x.current)==null||S.focus()},[]),b=p.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:x,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(m==null?void 0:m.displayName)??"Select agent"}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(m==null?void 0:m.installedCount)??0," · ",(m==null?void 0:m.globalCount)??0," · ",(m==null?void 0:m.pluginCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(VT,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{i(S),v()},onClose:v})]})}const yb="vskill-ccode-banner-dismissed",ZT=new Set(["claude-cli","claude-code"]);function JT(){try{return sessionStorage.getItem(yb)==="true"}catch{return!1}}function eR(){try{sessionStorage.setItem(yb,"true")}catch{}}function tR({activeAgentId:t}){const[a,s]=p.useState(()=>JT()),i=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{eR(),s(!0)},[]);return!t||!ZT.has(t)||a?null:r.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[re.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:i,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:re.claudeCodeLabel.learnMore})]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function nR(){const[t,a]=p.useState(null),[s,i]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const h=await Se.getAgents();a(h),i("ready"),u(null)}catch(h){i("error"),u(h.message)}},[]);return p.useEffect(()=>{d()},[d]),p.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Do="workspace",rR=["skills","agents"];async function aR(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function lR(t){const a=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${a.status}`)}return await a.json()}async function sR(t){const a=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${a.status}`)}return await a.json()}async function iR(t){const a=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${a.status}`)}return await a.json()}function ef(){for(const t of rR)On(t)}function oR(){const{data:t,loading:a,error:s,revalidate:i}=Ga(Do,aR),c=t,u=c==null?void 0:c.projects.find(m=>m.id===c.activeProjectId),d=p.useCallback(async m=>{await lR(m),On(Do),ef()},[]),h=p.useCallback(async m=>{await sR(m),On(Do),ef()},[]),x=p.useCallback(async m=>{await iR(m),On(Do),ef()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:x,revalidate:i}}function cR({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,y]=p.useState(""),[v,b]=p.useState(null),[S,E]=p.useState(null),[C,k]=p.useState(null),[N,T]=p.useState(!1),M=p.useRef(null),_=(t==null?void 0:t.projects)??[],D=_.find(z=>z.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function z(O){M.current&&!M.current.contains(O.target)&&(d(!1),x(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function V(){b(null);const z=m.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),y(""),x(!1)}catch(O){const $=O instanceof Error?O.message:String(O);/does not exist/i.test($)?b(`Path not found on disk: ${z}`):/Duplicate/i.test($)?b("That project is already registered."):b($)}}async function w(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),x(!0)}catch{}else x(!0)}function B(z){if(z.length<=50)return z;const O=z.split("/");return O.length<=4?z:`${O.slice(0,3).join("/")}/…/${O.slice(-2).join("/")}`}return r.jsxs("div",{ref:M,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(D==null?void 0:D.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(D==null?void 0:D.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D?D.name:"No project"}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&r.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[_.length===0&&r.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),_.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:_.map(z=>{const O=c?c(z.path):!1,$=z.id===(t==null?void 0:t.activeProjectId),Y=S===z.id;return r.jsxs("li",{role:"menuitem","data-stale":O?"true":"false",onMouseEnter:()=>E(z.id),onMouseLeave:()=>E(X=>X===z.id?null:X),onClick:()=>{if(!O){if($){d(!1);return}k(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:O?"not-allowed":"pointer",background:Y&&!O?"var(--surface-2, rgba(0,0,0,0.04))":$?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:O?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:$?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:$?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),$&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B(z.path)}),O&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:X=>{X.stopPropagation(),i(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:Y?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&r.jsxs("button",{type:"button",onClick:()=>void w(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:m,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&V(),z.key==="Escape"&&(x(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{x(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>void V(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),C&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>k(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",C.name]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),r.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${C.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${C.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),r.jsx("button",{type:"button",onClick:()=>k(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function uR(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(i=>{const c=`${i.name} ${i.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function dR({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=p.useState(""),[d,h]=p.useState(0),x=p.useMemo(()=>uR(a,c),[a,c]);p.useEffect(()=>{t||(u(""),h(0))},[t]),p.useEffect(()=>{d>=x.length&&h(0)},[x.length,d]);const m=y=>{if(y.key==="Escape"){y.preventDefault(),i();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(x.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=x[d];v&&(s(v.id),i())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:i}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:m,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[x.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),x.map((y,v)=>r.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),i()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:y.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const jv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function fR({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,h]=p.useState("destination"),[x,m]=p.useState(s),[y,v]=p.useState(""),[b,S]=p.useState(""),[E,C]=p.useState(""),[k,N]=p.useState([]),[T,M]=p.useState(!1),[_,D]=p.useState(null);if(p.useEffect(()=>{t&&(h("destination"),m(s),v(""),S(""),C(""),D(null))},[t,s]),p.useEffect(()=>{if(!t)return;let H=!0;return fetch("/api/authoring/plugins").then(A=>A.json()).then(A=>{H&&N(A.plugins??[])}).catch(()=>{}),()=>{H=!1}},[t]),p.useEffect(()=>{if(!t)return;function H(A){A.key==="Escape"&&(A.preventDefault(),a())}return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[t,a]),!t)return null;const V=k.length>0,w=i&&V,B=i,z=jv.test(y),O=x==="existing-plugin"?b.length>0:jv.test(b),$=!T&&z&&(x==="standalone"||O),Y=pR(c,x,b,y);async function X(){D(null),M(!0);try{const I=new URLSearchParams;I.set("mode",x),I.set("skillName",y),b&&I.set("pluginName",b);const G=await fetch(`/api/authoring/skill-exists?${I.toString()}`),U=await G.json();if(!G.ok){D(U.error??`Check failed: ${G.status}`);return}if(U.exists){D(`Skill '${y}' already exists${U.path?` at ${U.path}`:""}`);return}}catch(I){D(I instanceof Error?I.message:String(I));return}finally{M(!1)}const H=new URLSearchParams;H.set("mode",x),H.set("skillName",y),E.trim()&&H.set("description",E.trim()),b&&H.set("pluginName",b);const A=`#/create?${H.toString()}`;typeof window<"u"&&(window.location.hash=A),a()}async function ne(){D(null),M(!0);try{const H=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,skillName:y,description:E.trim()||void 0,pluginName:x==="standalone"?void 0:b})}),A=await H.json();if(!H.ok||!A.ok){D(A.error??`Create failed: ${H.status}`);return}On("skills"),u==null||u({mode:x,skillName:y,pluginName:A.pluginName??null,skillMdPath:A.skillMdPath}),a()}catch(H){D(H instanceof Error?H.message:String(H))}finally{M(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(tf,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:x==="standalone",onClick:()=>m("standalone")}),r.jsx(tf,{title:"Add to existing plugin",subtitle:w?`${k.length} plugin source${k.length===1?"":"s"} in this project`:i?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:x==="existing-plugin",onClick:()=>w&&m("existing-plugin")}),r.jsx(tf,{title:"New plugin",subtitle:B?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!B,selected:x==="new-plugin",onClick:()=>B&&m("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[x==="new-plugin"&&r.jsx(_o,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:H=>S(H.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:Oo(!b||O)})}),x==="existing-plugin"&&r.jsx(_o,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:H=>S(H.target.value),style:{...Oo(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),k.map(H=>r.jsx("option",{value:H.name,children:H.name},H.path))]})}),r.jsx(_o,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:H=>v(H.target.value.trim()),placeholder:"my-new-skill",autoFocus:x!=="new-plugin",style:Oo(!y||z)})}),r.jsx(_o,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:E,onChange:H=>C(H.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...Oo(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),Y&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),Y.map((H,A)=>r.jsx("div",{children:H},A))]}),_&&r.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:_})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[r.jsx("button",{type:"button",onClick:a,style:nf,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:Sv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:nf,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!$,style:{...nf,opacity:$?1:.5,cursor:$?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void ne(),disabled:!$,style:{...Sv,opacity:$?1:.5,cursor:$?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function tf({title:t,subtitle:a,description:s,icon:i,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:i}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function _o({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function Oo(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const Sv={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"},nf={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 pR(t,a,s,i){const c=i||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function bb(t){return t.trim().toLowerCase()}function mR(t,a){const s=bb(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function hR(t,a){const s=bb(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function xR({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=p.useState(null),[h,x]=p.useState([]),[m,y]=p.useState(null),[v,b]=p.useState(null),[S,E]=p.useState(!1),[C,k]=p.useState(null),[N,T]=p.useState(""),[M,_]=p.useState("");p.useEffect(()=>{m?T(""):_("")},[m]);const D=p.useMemo(()=>mR(h,N),[h,N]),V=p.useMemo(()=>hR((v==null?void 0:v.plugins)??[],M),[v,M]);return p.useEffect(()=>{t&&(E(!0),k(null),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);x(w.marketplaces??[])}).catch(w=>k(w instanceof Error?w.message:String(w))).finally(()=>E(!1)))},[t]),p.useEffect(()=>{if(!m){b(null);return}E(!0),k(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(m)}`).then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);b(w)}).catch(w=>k(w instanceof Error?w.message:String(w))).finally(()=>E(!1))},[m]),p.useEffect(()=>{if(!t)return;function w(B){B.key==="Escape"&&a()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[m&&r.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:m?(v==null?void 0:v.name)??m:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),C&&r.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:C}),!m&&!S&&h.length===0&&!C&&r.jsx(gR,{}),!m&&h.length>0&&r.jsx(kv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!m&&h.length>0&&D.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!m&&D.map(w=>r.jsxs("button",{type:"button",onClick:()=>y(w.name),style:yR,onMouseEnter:B=>{B.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:w.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.source})]},w.name)),m&&v&&r.jsxs(r.Fragment,{children:[v.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&r.jsx(kv,{value:M,onChange:_,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&V.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",M,"”."]}),V.map(w=>{const B=c.has(w.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[w.name,w.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:w.version}),w.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:w.category})]}),w.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:w.description})]}),B&&i?r.jsx("button",{type:"button",disabled:u===w.name,onClick:async()=>{d(w.name);try{await i(w.name)}finally{d(null)}},"aria-label":`Uninstall ${w.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===w.name?"wait":"pointer",opacity:u===w.name?.6:1,fontFamily:"inherit"},children:u===w.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:B,onClick:()=>s(w.name,m),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:B?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:B?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:B?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:B?"default":"pointer",fontFamily:"inherit",boxShadow:B?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:B?"Installed":"Install"})]})},w.name)})]})]}),!m&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(vR,{onAdded:()=>{On("marketplaces"),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>x(w.marketplaces??[]))}})})]})]}):null}function kv({value:t,onChange:a,placeholder:s,ariaLabel:i,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":i,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function gR(){return r.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",r.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[r.jsx("li",{children:r.jsx("code",{children:"anthropics/claude-plugins-official"})}),r.jsx("li",{children:r.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function vR({onAdded:t}){const[a,s]=p.useState(""),[i,c]=p.useState(!1),[u,d]=p.useState(null);async function h(){const x=a.trim();if(x){c(!0),d(null);try{const m=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x})}),y=await m.json().catch(()=>({}));if(!m.ok||!y.ok){d(y.error??`Add failed (${m.status})`);return}s(""),t()}catch(m){d(m instanceof Error?m.message:String(m))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:i,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void h(),disabled:i||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:i||!a.trim()?"not-allowed":"pointer",opacity:i||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:i?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const yR={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},rf=12;function bR({job:t,onDone:a}){const[s,i]=p.useState([]),[c,u]=p.useState("running"),[d,h]=p.useState(!1);if(p.useEffect(()=>{if(!t)return;i([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const E=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!E.ok||!E.body){u("failed"),a({ok:!1,code:E.status,lines:[`HTTP ${E.status}`]});return}const C=E.body.getReader(),k=new TextDecoder;let N="";for(;;){const{value:T,done:M}=await C.read();if(M)break;N+=k.decode(T,{stream:!0});const _=N.split(/\n\n/);N=_.pop()??"";for(const D of _){const V=D.match(/^data:\s*(.*)$/m);if(V)try{const w=JSON.parse(V[1]);w.type==="stdout"&&w.line?(b=[...b,w.line].slice(-rf),i(b)):w.type==="stderr"&&w.line?(b=[...b,`⚠ ${w.line}`].slice(-rf),i(b)):w.type==="done"?(S=w.ok?"ok":"failed",u(S),ry(),On("skills"),a({ok:w.ok??!1,code:w.code??null,lines:b})):w.type==="error"&&w.error&&(b=[...b,`✘ ${w.error}`].slice(-rf),i(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(E){if(E.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,E instanceof Error?E.message:String(E)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const x=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",m=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${x}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:x,width:16,textAlign:"center"},children:c==="running"?r.jsx(jR,{}):m}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
|
|
122
|
-
`)})]})}function jR(){return r.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const SR=3e3,kR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function wv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function wR(){const{toast:t}=nc(),a=p.useRef(new Map),s=p.useCallback(i=>{if(!wv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<SR)return;a.current.set(i.provider,c);const d=kR[i.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:i.provider}}))}}})},[t]);return p.useEffect(()=>{function i(c){const u=c.detail;!u||!wv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const jb="vskill.studio.prefs";function Sb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function kb(){const t=Sb();if(!t)return{};try{const a=t.getItem(jb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function CR(t,a){const s=Sb();if(s)try{const c={...kb(),[t]:a};s.setItem(jb,JSON.stringify(c))}catch{}}function ER(t,a){const i=kb()[t];return i===void 0?a:i}const Cv={open:!1,x:0,y:0,skill:null};function NR(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function $a(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function TR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function RR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{$a(re.toasts.permissionDenied,"error");return}$a(re.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":$a(re.actions.editPlaceholder,"info");return;case"run-benchmark":$a(re.toasts.benchmarkQueued,"info");return;case"duplicate":$a(re.toasts.skillDuplicated,"info");return;case"update":$a(re.toasts.skillUpdated,"info");return;case"uninstall":$a(re.actions.editPlaceholder,"info");return;case"delete":TR(a);return;default:return}}function AR(t){return t.startsWith("#/create")}function MR(t){return t.startsWith("#/updates")}function wb(t){const[a,s]=p.useState(()=>typeof window<"u"&&t(window.location.hash));return p.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function LR(){return wb(AR)}function zR(){return wb(MR)}function DR(){var i,c;if(typeof navigator>"u")return"⌘⇧K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function _R(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function OR(){const[t,a]=p.useState("⌘⇧K");p.useEffect(()=>{a(DR())},[]);const s=_R();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const BR=p.lazy(()=>Fa(()=>import("./CommandPalette-B8LrurKZ.js"),__vite__mapDeps([2,1]))),IR=p.lazy(()=>Fa(()=>import("./FindSkillsPalette-Cqg3Q3ba.js"),__vite__mapDeps([3,1])).then(t=>({default:t.FindSkillsPalette}))),$R=p.lazy(()=>Fa(()=>import("./SkillDetailPanel-BaJNm33W.js"),__vite__mapDeps([4,5,1])).then(t=>({default:t.SkillDetailPanel}))),UR=p.lazy(()=>Fa(()=>import("./CreateSkillPage-BLare8vh.js"),__vite__mapDeps([6,1])).then(t=>({default:t.CreateSkillPage}))),HR=p.lazy(()=>Fa(()=>Promise.resolve().then(()=>UN),void 0).then(t=>({default:t.UpdatesPanel})));function PR(){return r.jsx(YS,{children:r.jsx(GS,{children:r.jsxs(W2,{children:[r.jsx(VR,{}),r.jsx(TT,{})]})})})}function VR(){var en,Ka;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=ir(),{config:h}=Wa(),{mode:x,resolvedTheme:m,setTheme:y}=ny(),{toast:v}=nc(),[b,S]=p.useState(()=>kC()),[E]=p.useState(!0),[C,k]=p.useState(!1),[N,T]=p.useState(!1),[M,_]=p.useState(!1),[D,V]=p.useState("overview"),[w,B]=p.useState(Cv),z=p.useCallback((ie,ke)=>{B(NR(ie,ke))},[]),O=nR(),[$,Y]=p.useState(()=>ER("activeAgent",null)),X=p.useCallback(ie=>{Y(ie),CR("activeAgent",ie),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ie}}))},[]);p.useEffect(()=>{var ie;!$&&((ie=O.response)!=null&&ie.suggested)&&X(O.response.suggested)},[$,(en=O.response)==null?void 0:en.suggested,X]);const ne=p.useMemo(()=>O.response?XT(O.response):[],[O.response]),{workspace:H,switchProject:A,addProject:I,removeProject:G,activeProject:U}=oR(),[ae,L]=p.useState(!1),[W,ee]=p.useState(!1),[q,oe]=p.useState("standalone"),Q=p.useCallback((ie="standalone")=>{oe(ie),ee(!0)},[]);p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Q((Ne==null?void 0:Ne.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ie),()=>window.removeEventListener("studio:request-create-skill",ie)},[Q]);const[ye,ce]=p.useState(!1),[je,Me]=p.useState(null),[Ae,ze]=p.useState(null);p.useEffect(()=>{function ie(){ce(!0)}return window.addEventListener("studio:open-marketplace",ie),()=>window.removeEventListener("studio:open-marketplace",ie)},[]);const Ge=p.useMemo(()=>{const ie=new Set;for(const ke of t.skills)ke.source==="plugin"&&ke.pluginName&&ie.add(ke.pluginName);return ie},[t.skills]);xf([{key:"p",meta:!0,handler:ie=>{var Ne;const ke=typeof document<"u"?document.activeElement:null;ke&&ke.tagName==="INPUT"||((Ne=ie==null?void 0:ie.preventDefault)==null||Ne.call(ie),L(vn=>!vn))}}],{enabled:!0});const se=HT(),de=se.open;p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.provider&&de(Ne.provider)}return window.addEventListener("studio:open-setup-drawer",ie),()=>window.removeEventListener("studio:open-setup-drawer",ie)},[de]);const me=p.useCallback(()=>{B(Cv)},[]);p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.message&&v({message:Ne.message,severity:Ne.severity??"info"})}return window.addEventListener("studio:toast",ie),()=>window.removeEventListener("studio:toast",ie)},[v]),wR();const[ve,be]=p.useState(!1),[Xe,pt]=p.useState(void 0);p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;pt(Ne==null?void 0:Ne.provider),be(!0)}return window.addEventListener("studio:open-settings",ie),()=>window.removeEventListener("studio:open-settings",ie)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]),p.useEffect(()=>{function ie(){i()}return window.addEventListener("studio:content-saved",ie),()=>window.removeEventListener("studio:content-saved",ie)},[i]);const[vt,$t]=p.useState(null),[Nt,qe]=p.useState(()=>new Set),Lt=p.useRef(!1),jt=p.useMemo(()=>Jw(),[]),ut=p.useCallback(ie=>`${ie.plugin}/${ie.skill}`,[]),Xt=p.useCallback(ie=>{qe(ke=>{const Ne=new Set(ke);return Ne.add(ut(ie)),Ne})},[ut]),xe=p.useCallback(ie=>{qe(ke=>{const Ne=new Set(ke);return Ne.delete(ut(ie)),Ne})},[ut]),nt=yv({delayMs:1e4,onCommit:ie=>{i(),xe(ie)},onFailure:(ie,ke)=>{xe(ie),v({message:`Couldn't delete ${ie.skill}: ${ke.message}`,severity:"error",durationMs:0,action:{label:re.actions.retry,onInvoke:()=>{Xt(ie),nt.enqueueDelete(ie)}}})}});p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.skill&&$t(Ne.skill)}return window.addEventListener("studio:request-delete",ie),()=>window.removeEventListener("studio:request-delete",ie)},[]);const[it,bt]=p.useState(null),Tt=yv({delayMs:1e4,apiCall:(ie,ke)=>api.uninstallSkill(ie,ke),onCommit:ie=>{i(),xe(ie)},onFailure:(ie,ke)=>{xe(ie),v({message:`Couldn't uninstall ${ie.skill}: ${ke.message}`,severity:"error",durationMs:0,action:{label:re.actions.retry,onInvoke:()=>{Xt(ie),Tt.enqueueDelete(ie)}}})}});p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.skill&&bt(Ne.skill)}return window.addEventListener("studio:request-uninstall",ie),()=>window.removeEventListener("studio:request-uninstall",ie)},[]);const Je=p.useCallback(()=>{const ie=it;if(bt(null),!ie)return;const ke={plugin:ie.plugin,skill:ie.skill};Xt(ke),Tt.enqueueDelete(ke),v({message:`Uninstalled ${ie.skill}. Sent to your ${jt}.`,severity:"info",durationMs:1e4,action:{label:re.actions.undo,onInvoke:()=>{Tt.cancelDelete(ut(ke)),xe(ke)}}})},[it,Xt,xe,Tt,v,jt,ut]),xn=p.useCallback(()=>{bt(null)},[]),Gt=p.useCallback(()=>{const ie=vt;if($t(null),!ie)return;const ke={plugin:ie.plugin,skill:ie.skill};Xt(ke),nt.enqueueDelete(ke);const Ne=Lt.current?"":`Sent to your ${jt}. Open Trash to restore. `;Lt.current=!0,v({message:`${Ne}Deleted ${ie.skill}`,severity:"info",durationMs:1e4,action:{label:re.actions.undo,onInvoke:()=>{nt.cancelDelete(ut(ke)),xe(ke)}}})},[vt,Xt,xe,nt,v,jt,ut]),dn=p.useCallback(()=>{$t(null)},[]),sn=p.useMemo(()=>t.skills.filter(ie=>!Nt.has(ut(ie))),[t.skills,Nt,ut]),or=MC(sn,(U==null?void 0:U.path)??null),Cn=p.useMemo(()=>t.selectedSkill?t.skills.find(ie=>ie.plugin===t.selectedSkill.plugin&&ie.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Un=p.useCallback(ie=>{a({plugin:ie.plugin,skill:ie.skill,origin:ie.origin})},[a]),En=p.useMemo(()=>{if(!t.selectedSkill)return"";const ie=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ie})`},[t.selectedSkill]),St=p.useMemo(()=>[{id:"switch-theme",label:re.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(x==="light"?"dark":x==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>_(ie=>!ie)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>i()}],[x,y,i]),[_e,We]=p.useState(null);xf([{key:"cmd+k",handler:()=>k(ie=>!ie)},{key:"ctrl+k",handler:()=>k(ie=>!ie)},{key:"cmd+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>T(ie=>!ie)},{key:"cmd+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"cmd+b",handler:()=>_(ie=>!ie)},{key:"ctrl+b",handler:()=>_(ie=>!ie)},{key:"e",handler:()=>v({message:re.actions.editPlaceholder,severity:"info"})}]);const Nn=LR(),Ur=zR()?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(HR,{})}):Nn?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(UR,{})}):r.jsx(bT,{selectedSkillInfo:Cn,activeDetailTab:D,onDetailTabChange:V,allSkills:t.skills,onSelectSkill:Un});return r.jsxs(r.Fragment,{children:[r.jsx(KS,{sidebarWidth:b,sidebarHidden:M||t.isMobile&&t.mobileView==="detail",banner:r.jsx(LC,{connected:E}),liveMessage:En,topRail:r.jsx(X2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>k(!0),onHome:s,onRequestCreateSkill:()=>Q("standalone"),projectPickerSlot:H&&H.projects.length>0?r.jsx(cR,{workspace:H,onSwitch:A,onAdd:I,onRemove:G}):void 0,findSkillsSlot:r.jsx(OR,{})}),sidebar:r.jsx(pC,{skills:sn,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Un,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:z,outdatedByOrigin:c,activeAgentId:$,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:or,topSlot:O.status==="ready"&&ne.length>0?r.jsxs(r.Fragment,{children:[r.jsx(QT,{agents:ne,activeAgentId:$,onActiveAgentChange:X,onOpenSetup:ie=>se.open(ie)}),r.jsx(tR,{activeAgentId:$})]}):null}),resizeHandle:r.jsx(CC,{initialWidth:b??qs,onChange:S}),main:Ur,statusBar:r.jsx(ik,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Ka=h==null?void 0:h.providers)==null?void 0:Ka.map(ie=>{const ke=ie.id;return{id:ke,label:ie.label,available:ie.available,kind:ke==="ollama"||ke==="lm-studio"?"start-service":ke==="anthropic"||ke==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(AT,{open:N,onClose:()=>T(!1)}),r.jsx(_T,{open:se.isOpen,providerKey:se.providerKey,onClose:se.close}),r.jsx(LT,{state:w,onClose:me,onAction:(ie,ke)=>RR(ie,ke)}),C&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(BR,{open:C,onClose:()=>k(!1),commands:St})}),r.jsx(p.Suspense,{fallback:null,children:r.jsx(IR,{onSelect:ie=>{const ke=ie.name.split("/");ke.length===3&&We({owner:ke[0],repo:ke[1],slug:ke[2],displayName:ie.displayName??ie.name})}})}),_e&&r.jsx(p.Suspense,{fallback:null,children:r.jsx($R,{selectedSkill:_e,onClose:()=>We(null)})}),r.jsx(dR,{open:ae,projects:(H==null?void 0:H.projects)??[],onSwitch:ie=>{A(ie)},onClose:()=>L(!1)}),r.jsx(fR,{open:W,onClose:()=>ee(!1),initialMode:q,isClaudeCode:$==="claude-code",projectRoot:(U==null?void 0:U.path)??(h==null?void 0:h.projectName)??"",onCreated:ie=>{i(),setTimeout(()=>{u(ie.pluginName??"",ie.skillName)},500)}}),r.jsx(xR,{open:ye,onClose:()=>ce(!1),installedNames:Ge,onInstall:(ie,ke)=>{Me({plugin:ie,marketplace:ke,ref:`${ie}@${ke}`}),ce(!1)},onUninstall:async ie=>{if(await new Promise(Ne=>{ze({plugin:ie,resolve:Ne})}))try{const Ne=await fetch(`/api/plugins/${encodeURIComponent(ie)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),vn=await Ne.json().catch(()=>({}));if(!Ne.ok||!vn.ok){v({message:vn.error??`Uninstall failed (${Ne.status})`,severity:"error"});return}const cr=vn.fallback==="orphan-cache-removed"?`Removed orphaned ${ie}.`:`Uninstalled ${ie}.`;v({message:cr,severity:"success"}),i()}catch(Ne){v({message:Ne instanceof Error?Ne.message:String(Ne),severity:"error"})}}}),r.jsx(Zv,{open:ve,onClose:()=>be(!1),initialProvider:Xe,onToast:ie=>v({message:ie,severity:"info"})}),r.jsx(bR,{job:je,onDone:ie=>{ie.ok&&(i(),setTimeout(()=>Me(null),3e3))}}),r.jsx(Po,{open:vt!==null,title:vt?`Delete "${vt.skill}"?`:"",body:`It will be sent to your ${jt}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Gt,onCancel:dn}),r.jsx(Po,{open:it!==null,title:it?`Uninstall "${it.skill}"?`:"",body:`It will be sent to your ${jt} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:Je,onCancel:xn}),r.jsx(Po,{open:Ae!==null,title:Ae?`Uninstall ${Ae.plugin}?`:"",body:Ae?`This removes the ${Ae.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ae==null||Ae.resolve(!0),ze(null)},onCancel:()=>{Ae==null||Ae.resolve(!1),ze(null)}})]})}const Ev="vskill.migrations.scope-rename.v1",FR={own:"authoring-project",installed:"available-project",global:"available-personal"},GR=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function WR(t){if(t.getItem(Ev)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(GR);if(!c)continue;const[,u,d]=c,h=FR[d];if(!h)continue;const x=t.getItem(i);x!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:x})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(Ev,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{WR(window.localStorage)}catch{}P0.createRoot(document.getElementById("root")).render(r.jsx(p.StrictMode,{children:r.jsx(cS,{children:r.jsx(nk,{children:r.jsx(PR,{})})})}));export{uc as E,Gv as L,ci as P,Te as R,ON as S,YR as T,Fa as _,Wa as a,kb as b,zN as c,oc as d,nc as e,ir as f,ER as g,Se as h,Gy as i,r as j,p as r,re as s,Qo as t,wj as u,CR as w};
|
|
122
|
+
`)})]})}function jR(){return r.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const SR=3e3,kR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function wv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function wR(){const{toast:t}=nc(),a=p.useRef(new Map),s=p.useCallback(i=>{if(!wv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<SR)return;a.current.set(i.provider,c);const d=kR[i.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:i.provider}}))}}})},[t]);return p.useEffect(()=>{function i(c){const u=c.detail;!u||!wv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const jb="vskill.studio.prefs";function Sb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function kb(){const t=Sb();if(!t)return{};try{const a=t.getItem(jb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function CR(t,a){const s=Sb();if(s)try{const c={...kb(),[t]:a};s.setItem(jb,JSON.stringify(c))}catch{}}function ER(t,a){const i=kb()[t];return i===void 0?a:i}const Cv={open:!1,x:0,y:0,skill:null};function NR(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function $a(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function TR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function RR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{$a(re.toasts.permissionDenied,"error");return}$a(re.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":$a(re.actions.editPlaceholder,"info");return;case"run-benchmark":$a(re.toasts.benchmarkQueued,"info");return;case"duplicate":$a(re.toasts.skillDuplicated,"info");return;case"update":$a(re.toasts.skillUpdated,"info");return;case"uninstall":$a(re.actions.editPlaceholder,"info");return;case"delete":TR(a);return;default:return}}function AR(t){return t.startsWith("#/create")}function MR(t){return t.startsWith("#/updates")}function wb(t){const[a,s]=p.useState(()=>typeof window<"u"&&t(window.location.hash));return p.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function LR(){return wb(AR)}function zR(){return wb(MR)}function DR(){var i,c;if(typeof navigator>"u")return"⌘⇧K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function _R(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function OR(){const[t,a]=p.useState("⌘⇧K");p.useEffect(()=>{a(DR())},[]);const s=_R();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const BR=p.lazy(()=>Fa(()=>import("./CommandPalette-Blw7hYAt.js"),__vite__mapDeps([2,1]))),IR=p.lazy(()=>Fa(()=>import("./FindSkillsPalette-DO65wBaE.js"),__vite__mapDeps([3,1])).then(t=>({default:t.FindSkillsPalette}))),$R=p.lazy(()=>Fa(()=>import("./SkillDetailPanel-DnDhg7z9.js"),__vite__mapDeps([4,5,1])).then(t=>({default:t.SkillDetailPanel}))),UR=p.lazy(()=>Fa(()=>import("./CreateSkillPage-7StSKG-p.js"),__vite__mapDeps([6,1])).then(t=>({default:t.CreateSkillPage}))),HR=p.lazy(()=>Fa(()=>Promise.resolve().then(()=>UN),void 0).then(t=>({default:t.UpdatesPanel})));function PR(){return r.jsx(YS,{children:r.jsx(GS,{children:r.jsxs(W2,{children:[r.jsx(VR,{}),r.jsx(TT,{})]})})})}function VR(){var en,Ka;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=ir(),{config:h}=Wa(),{mode:x,resolvedTheme:m,setTheme:y}=ny(),{toast:v}=nc(),[b,S]=p.useState(()=>kC()),[E]=p.useState(!0),[C,k]=p.useState(!1),[N,T]=p.useState(!1),[M,_]=p.useState(!1),[D,V]=p.useState("overview"),[w,B]=p.useState(Cv),z=p.useCallback((ie,ke)=>{B(NR(ie,ke))},[]),O=nR(),[$,Y]=p.useState(()=>ER("activeAgent",null)),X=p.useCallback(ie=>{Y(ie),CR("activeAgent",ie),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ie}}))},[]);p.useEffect(()=>{var ie;!$&&((ie=O.response)!=null&&ie.suggested)&&X(O.response.suggested)},[$,(en=O.response)==null?void 0:en.suggested,X]);const ne=p.useMemo(()=>O.response?XT(O.response):[],[O.response]),{workspace:H,switchProject:A,addProject:I,removeProject:G,activeProject:U}=oR(),[ae,L]=p.useState(!1),[W,ee]=p.useState(!1),[q,oe]=p.useState("standalone"),Q=p.useCallback((ie="standalone")=>{oe(ie),ee(!0)},[]);p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Q((Ne==null?void 0:Ne.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ie),()=>window.removeEventListener("studio:request-create-skill",ie)},[Q]);const[ye,ce]=p.useState(!1),[je,Me]=p.useState(null),[Ae,ze]=p.useState(null);p.useEffect(()=>{function ie(){ce(!0)}return window.addEventListener("studio:open-marketplace",ie),()=>window.removeEventListener("studio:open-marketplace",ie)},[]);const Ge=p.useMemo(()=>{const ie=new Set;for(const ke of t.skills)ke.source==="plugin"&&ke.pluginName&&ie.add(ke.pluginName);return ie},[t.skills]);xf([{key:"p",meta:!0,handler:ie=>{var Ne;const ke=typeof document<"u"?document.activeElement:null;ke&&ke.tagName==="INPUT"||((Ne=ie==null?void 0:ie.preventDefault)==null||Ne.call(ie),L(vn=>!vn))}}],{enabled:!0});const se=HT(),de=se.open;p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.provider&&de(Ne.provider)}return window.addEventListener("studio:open-setup-drawer",ie),()=>window.removeEventListener("studio:open-setup-drawer",ie)},[de]);const me=p.useCallback(()=>{B(Cv)},[]);p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.message&&v({message:Ne.message,severity:Ne.severity??"info"})}return window.addEventListener("studio:toast",ie),()=>window.removeEventListener("studio:toast",ie)},[v]),wR();const[ve,be]=p.useState(!1),[Xe,pt]=p.useState(void 0);p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;pt(Ne==null?void 0:Ne.provider),be(!0)}return window.addEventListener("studio:open-settings",ie),()=>window.removeEventListener("studio:open-settings",ie)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]),p.useEffect(()=>{function ie(){i()}return window.addEventListener("studio:content-saved",ie),()=>window.removeEventListener("studio:content-saved",ie)},[i]);const[vt,$t]=p.useState(null),[Nt,qe]=p.useState(()=>new Set),Lt=p.useRef(!1),jt=p.useMemo(()=>Jw(),[]),ut=p.useCallback(ie=>`${ie.plugin}/${ie.skill}`,[]),Xt=p.useCallback(ie=>{qe(ke=>{const Ne=new Set(ke);return Ne.add(ut(ie)),Ne})},[ut]),xe=p.useCallback(ie=>{qe(ke=>{const Ne=new Set(ke);return Ne.delete(ut(ie)),Ne})},[ut]),nt=yv({delayMs:1e4,onCommit:ie=>{i(),xe(ie)},onFailure:(ie,ke)=>{xe(ie),v({message:`Couldn't delete ${ie.skill}: ${ke.message}`,severity:"error",durationMs:0,action:{label:re.actions.retry,onInvoke:()=>{Xt(ie),nt.enqueueDelete(ie)}}})}});p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.skill&&$t(Ne.skill)}return window.addEventListener("studio:request-delete",ie),()=>window.removeEventListener("studio:request-delete",ie)},[]);const[it,bt]=p.useState(null),Tt=yv({delayMs:1e4,apiCall:(ie,ke)=>api.uninstallSkill(ie,ke),onCommit:ie=>{i(),xe(ie)},onFailure:(ie,ke)=>{xe(ie),v({message:`Couldn't uninstall ${ie.skill}: ${ke.message}`,severity:"error",durationMs:0,action:{label:re.actions.retry,onInvoke:()=>{Xt(ie),Tt.enqueueDelete(ie)}}})}});p.useEffect(()=>{function ie(ke){if(!(ke instanceof CustomEvent))return;const Ne=ke.detail;Ne!=null&&Ne.skill&&bt(Ne.skill)}return window.addEventListener("studio:request-uninstall",ie),()=>window.removeEventListener("studio:request-uninstall",ie)},[]);const Je=p.useCallback(()=>{const ie=it;if(bt(null),!ie)return;const ke={plugin:ie.plugin,skill:ie.skill};Xt(ke),Tt.enqueueDelete(ke),v({message:`Uninstalled ${ie.skill}. Sent to your ${jt}.`,severity:"info",durationMs:1e4,action:{label:re.actions.undo,onInvoke:()=>{Tt.cancelDelete(ut(ke)),xe(ke)}}})},[it,Xt,xe,Tt,v,jt,ut]),xn=p.useCallback(()=>{bt(null)},[]),Gt=p.useCallback(()=>{const ie=vt;if($t(null),!ie)return;const ke={plugin:ie.plugin,skill:ie.skill};Xt(ke),nt.enqueueDelete(ke);const Ne=Lt.current?"":`Sent to your ${jt}. Open Trash to restore. `;Lt.current=!0,v({message:`${Ne}Deleted ${ie.skill}`,severity:"info",durationMs:1e4,action:{label:re.actions.undo,onInvoke:()=>{nt.cancelDelete(ut(ke)),xe(ke)}}})},[vt,Xt,xe,nt,v,jt,ut]),dn=p.useCallback(()=>{$t(null)},[]),sn=p.useMemo(()=>t.skills.filter(ie=>!Nt.has(ut(ie))),[t.skills,Nt,ut]),or=MC(sn,(U==null?void 0:U.path)??null),Cn=p.useMemo(()=>t.selectedSkill?t.skills.find(ie=>ie.plugin===t.selectedSkill.plugin&&ie.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Un=p.useCallback(ie=>{a({plugin:ie.plugin,skill:ie.skill,origin:ie.origin})},[a]),En=p.useMemo(()=>{if(!t.selectedSkill)return"";const ie=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ie})`},[t.selectedSkill]),St=p.useMemo(()=>[{id:"switch-theme",label:re.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(x==="light"?"dark":x==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>_(ie=>!ie)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>i()}],[x,y,i]),[_e,We]=p.useState(null);xf([{key:"cmd+k",handler:()=>k(ie=>!ie)},{key:"ctrl+k",handler:()=>k(ie=>!ie)},{key:"cmd+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>T(ie=>!ie)},{key:"cmd+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"cmd+b",handler:()=>_(ie=>!ie)},{key:"ctrl+b",handler:()=>_(ie=>!ie)},{key:"e",handler:()=>v({message:re.actions.editPlaceholder,severity:"info"})}]);const Nn=LR(),Ur=zR()?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(HR,{})}):Nn?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(UR,{})}):r.jsx(bT,{selectedSkillInfo:Cn,activeDetailTab:D,onDetailTabChange:V,allSkills:t.skills,onSelectSkill:Un});return r.jsxs(r.Fragment,{children:[r.jsx(KS,{sidebarWidth:b,sidebarHidden:M||t.isMobile&&t.mobileView==="detail",banner:r.jsx(LC,{connected:E}),liveMessage:En,topRail:r.jsx(X2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>k(!0),onHome:s,onRequestCreateSkill:()=>Q("standalone"),projectPickerSlot:H&&H.projects.length>0?r.jsx(cR,{workspace:H,onSwitch:A,onAdd:I,onRemove:G}):void 0,findSkillsSlot:r.jsx(OR,{})}),sidebar:r.jsx(pC,{skills:sn,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Un,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:z,outdatedByOrigin:c,activeAgentId:$,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:or,topSlot:O.status==="ready"&&ne.length>0?r.jsxs(r.Fragment,{children:[r.jsx(QT,{agents:ne,activeAgentId:$,onActiveAgentChange:X,onOpenSetup:ie=>se.open(ie)}),r.jsx(tR,{activeAgentId:$})]}):null}),resizeHandle:r.jsx(CC,{initialWidth:b??qs,onChange:S}),main:Ur,statusBar:r.jsx(ik,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Ka=h==null?void 0:h.providers)==null?void 0:Ka.map(ie=>{const ke=ie.id;return{id:ke,label:ie.label,available:ie.available,kind:ke==="ollama"||ke==="lm-studio"?"start-service":ke==="anthropic"||ke==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(AT,{open:N,onClose:()=>T(!1)}),r.jsx(_T,{open:se.isOpen,providerKey:se.providerKey,onClose:se.close}),r.jsx(LT,{state:w,onClose:me,onAction:(ie,ke)=>RR(ie,ke)}),C&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(BR,{open:C,onClose:()=>k(!1),commands:St})}),r.jsx(p.Suspense,{fallback:null,children:r.jsx(IR,{onSelect:ie=>{const ke=ie.name.split("/");ke.length===3&&We({owner:ke[0],repo:ke[1],slug:ke[2],displayName:ie.displayName??ie.name})}})}),_e&&r.jsx(p.Suspense,{fallback:null,children:r.jsx($R,{selectedSkill:_e,onClose:()=>We(null)})}),r.jsx(dR,{open:ae,projects:(H==null?void 0:H.projects)??[],onSwitch:ie=>{A(ie)},onClose:()=>L(!1)}),r.jsx(fR,{open:W,onClose:()=>ee(!1),initialMode:q,isClaudeCode:$==="claude-code",projectRoot:(U==null?void 0:U.path)??(h==null?void 0:h.projectName)??"",onCreated:ie=>{i(),setTimeout(()=>{u(ie.pluginName??"",ie.skillName)},500)}}),r.jsx(xR,{open:ye,onClose:()=>ce(!1),installedNames:Ge,onInstall:(ie,ke)=>{Me({plugin:ie,marketplace:ke,ref:`${ie}@${ke}`}),ce(!1)},onUninstall:async ie=>{if(await new Promise(Ne=>{ze({plugin:ie,resolve:Ne})}))try{const Ne=await fetch(`/api/plugins/${encodeURIComponent(ie)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),vn=await Ne.json().catch(()=>({}));if(!Ne.ok||!vn.ok){v({message:vn.error??`Uninstall failed (${Ne.status})`,severity:"error"});return}const cr=vn.fallback==="orphan-cache-removed"?`Removed orphaned ${ie}.`:`Uninstalled ${ie}.`;v({message:cr,severity:"success"}),i()}catch(Ne){v({message:Ne instanceof Error?Ne.message:String(Ne),severity:"error"})}}}),r.jsx(Zv,{open:ve,onClose:()=>be(!1),initialProvider:Xe,onToast:ie=>v({message:ie,severity:"info"})}),r.jsx(bR,{job:je,onDone:ie=>{ie.ok&&(i(),setTimeout(()=>Me(null),3e3))}}),r.jsx(Po,{open:vt!==null,title:vt?`Delete "${vt.skill}"?`:"",body:`It will be sent to your ${jt}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Gt,onCancel:dn}),r.jsx(Po,{open:it!==null,title:it?`Uninstall "${it.skill}"?`:"",body:`It will be sent to your ${jt} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:Je,onCancel:xn}),r.jsx(Po,{open:Ae!==null,title:Ae?`Uninstall ${Ae.plugin}?`:"",body:Ae?`This removes the ${Ae.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ae==null||Ae.resolve(!0),ze(null)},onCancel:()=>{Ae==null||Ae.resolve(!1),ze(null)}})]})}const Ev="vskill.migrations.scope-rename.v1",FR={own:"authoring-project",installed:"available-project",global:"available-personal"},GR=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function WR(t){if(t.getItem(Ev)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(GR);if(!c)continue;const[,u,d]=c,h=FR[d];if(!h)continue;const x=t.getItem(i);x!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:x})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(Ev,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{WR(window.localStorage)}catch{}P0.createRoot(document.getElementById("root")).render(r.jsx(p.StrictMode,{children:r.jsx(cS,{children:r.jsx(nk,{children:r.jsx(PR,{})})})}));export{uc as E,Gv as L,ci as P,Te as R,ON as S,YR as T,Fa as _,Wa as a,kb as b,zN as c,oc as d,nc as e,ir as f,ER as g,Se as h,Gy as i,r as j,p as r,re as s,Qo as t,wj as u,CR as w};
|