vskill 0.5.124 → 0.5.125
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-server/api-routes.js +13 -1
- package/dist/eval-server/api-routes.js.map +1 -1
- package/dist/eval-server/platform-proxy.d.ts +0 -5
- package/dist/eval-server/platform-proxy.js +16 -3
- package/dist/eval-server/platform-proxy.js.map +1 -1
- package/dist/eval-ui/assets/{CommandPalette-DVR-q8QQ.js → CommandPalette-C6JeUs8n.js} +1 -1
- package/dist/eval-ui/assets/{CreateSkillPage-CZUWGR8T.js → CreateSkillPage-DbC_X2Lt.js} +1 -1
- package/dist/eval-ui/assets/{UpdateDropdown-Dw9BDVCE.js → UpdateDropdown-D0ZXWKht.js} +1 -1
- package/dist/eval-ui/assets/index-CF39Yje6.css +1 -0
- package/dist/eval-ui/assets/{index-wMMBDDYG.js → index-D3mRy1uV.js} +3 -3
- package/dist/eval-ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/eval-ui/assets/index-C0lGF333.css +0 -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-D0ZXWKht.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-C6JeUs8n.js","assets/CreateSkillPage-DbC_X2Lt.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"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function sv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var cd={exports:{}},Ts={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -62,7 +62,7 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
|
|
|
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 k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};a==null||a(E),E.type==="done"&&(g=E),E.type==="error"&&(p=E)}h=""}}if(p){const y=new Bs(p.message,500);throw y.code=p.code,y}if(!g)throw new Bs("Transfer stream ended without 'done' event",500);return g}function Zj(t,a){if(!a.length)return t;const s=new Map,o=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};return typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates),d})}function Jj(t){const[a,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),a}const eS=500,Kd="vskill.updates.seenLastId";function tS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Kd)}catch{return null}}function bd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Kd):window.localStorage.setItem(Kd,t)}catch{}}function nS(){let t=new Map;const a=new Set,s=new Set,o=[];let c=tS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(a))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>eS){const g=o.shift();g&&s.delete(g)}c=h,bd(h)}}return{getSnapshot(){return t},subscribe(h){return a.add(h),()=>{a.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,bd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,bd(null),u()}}}const Da=nS(),rS=3e5,aS=500,lS=15e3,sS=6e4,iS=6e4,oS="/api/v1/skills/stream";function Gx(t){const a=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;a.set(o,s)}return a}function Wx(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function cS(t){if(!t||typeof t!="object")return!1;const a=t;return a.type==="skill.updated"&&typeof a.eventId=="string"&&typeof a.skillId=="string"&&typeof a.version=="string"}function uS(t){const a=(t==null?void 0:t.intervalMs)??rS,s=(t==null?void 0:t.debounceMs)??aS,o=(t==null?void 0:t.timeoutMs)??lS,c=(t==null?void 0:t.staleAfterMs)??sS,u=(t==null?void 0:t.disconnectFallbackMs)??iS,d=(t==null?void 0:t.streamUrlBase)??oS,h=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=m.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[p,y]=m.useState([]),[v,b]=m.useState(()=>new Map),[S,k]=m.useState(0),[E,C]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),D=m.useRef(null),F=m.useRef(null),w=m.useRef(null),O=m.useRef(null),z=m.useRef(!0),[U,H]=m.useState(()=>h?"connecting":"fallback"),q=m.useRef(U);q.current=U;const X=m.useSyncExternalStore(M=>Da.subscribe(M),()=>Da.getSnapshot(),()=>Da.getSnapshot()),J=X.size,$=m.useCallback(async()=>{C(!0);const M=new AbortController,Y=setTimeout(()=>M.abort(),o);try{const G=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{M.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(G==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(G),b(Gx(G)),k(Wx(G)),F.current=Date.now(),T(F.current),B(null)}catch(G){if(!z.current)return;B(G instanceof Error?G:new Error(String(G)))}finally{clearTimeout(Y),z.current&&C(!1)}},[o]),L=m.useCallback(()=>{if(D.current)return D.current;const M=$().finally(()=>{D.current=null});return D.current=M,M},[$]),_=m.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{L()},a))},[a,L]),I=m.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);m.useEffect(()=>{z.current=!0,(F.current==null||Date.now()-F.current>c)&&L(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const G=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){I();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&L(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",G),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",G),O.current&&clearTimeout(O.current),I()}},[]);const V=m.useCallback(async M=>{if(M.length!==0)try{const Y=await Ce.checkSkillUpdates(M);if(!z.current||Y.length===0)return;const G=Date.now(),te=Y.filter(ie=>ie.skillId&&ie.eventId&&ie.version).map(ie=>({skillId:ie.skillId,version:ie.version,eventId:ie.eventId,publishedAt:ie.publishedAt,diffSummary:ie.diffSummary,receivedAt:G}));te.length>0&&Da.mergeBulk(te);const fe=Y.filter(ie=>typeof ie.trackedForUpdates=="boolean"||typeof ie.updateAvailable=="boolean").map(ie=>({name:ie.name??ie.skillId,installed:ie.installed??"",latest:ie.latest??null,updateAvailable:ie.updateAvailable??!1,trackedForUpdates:typeof ie.trackedForUpdates=="boolean"?ie.trackedForUpdates:void 0}));fe.length>0&&y(ie=>{const ye=new Map;for(const Ae of ie)ye.set(Ae.name.split("/").pop()||Ae.name,Ae);let de=0;for(const Ae of fe){const _e=Ae.name.split("/").pop()||Ae.name,ae=ye.get(_e);if(ae){const he={...ae};ae.trackedForUpdates===void 0&&Ae.trackedForUpdates!==void 0&&(he.trackedForUpdates=Ae.trackedForUpdates),ye.set(_e,he)}else ye.set(_e,{name:Ae.name,installed:Ae.installed??"",latest:Ae.latest??null,updateAvailable:Ae.updateAvailable??!1,trackedForUpdates:Ae.trackedForUpdates}),de+=1}if(de===0&&ye.size===ie.length)return ie;const Se=[...ye.values()];return b(Gx(Se)),k(Wx(Se)),Se})}catch{}},[]);m.useEffect(()=>{const M=h||g;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const Y=M.split(","),G=`${d}?skills=${encodeURIComponent(M)}`;let te=null,fe=null,ie=null;const ye=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,z.current&&q.current!=="connected"&&H("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ye();const Se=1e3,Ae=()=>{z.current&&ie==null&&(ie=setTimeout(()=>{if(ie=null,!!z.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},Se))},_e=pe=>{if(!z.current)return;let ge;try{ge=JSON.parse(pe.data)}catch{return}if(!cS(ge)||Da.ingest(ge)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${ge.skillId} updated to ${ge.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId}}))}},ae=()=>{z.current&&(Da.clearSeen(),V(Y))},he=()=>{z.current&&(te=new EventSource(G),te.onopen=()=>{z.current&&(de(),H("connected"))},te.onerror=()=>{z.current&&(ye(),te&&te.readyState===EventSource.CLOSED&&Ae())},te.onmessage=_e,te.addEventListener("gone",ae))};return he(),()=>{if(de(),ie!=null&&(clearTimeout(ie),ie=null),te){try{te.removeEventListener("gone",ae)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),m.useEffect(()=>{if(!g)return;const M=g.split(",");V(M)},[g,V]);const se=m.useCallback(M=>{Da.dismiss(M)},[]);return{updates:p,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:L,updatesById:X,pushUpdateCount:J,status:U,dismiss:se}}function dS(t){const a=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const fS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function pS(t,a){switch(a.type){case"SELECT_SKILL":return{...t,selectedSkill:a.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:a.mode,selectedSkill:a.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:a.query};case"SET_SKILLS":return{...t,skills:a.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:a.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:a.loading};case"SET_MOBILE":return{...t,isMobile:a.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:a.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:a.skill,revealSkillId:`${a.skill.plugin}/${a.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Ev=m.createContext(null),Nv=Ev;function er(){const t=m.useContext(Nv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function mS({children:t}){const[a,s]=m.useReducer(pS,fS),o=Jj("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=m.useState(()=>{try{const I=window.localStorage.getItem("vskill.studio.prefs");if(!I)return null;const V=JSON.parse(I);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=m.useState(c!==null);m.useEffect(()=>{function I(V){if(!(V instanceof CustomEvent))return;const se=V.detail;se!=null&&se.agentId&&(u(se.agentId),h(!0))}return window.addEventListener("studio:agent-changed",I),()=>window.removeEventListener("studio:agent-changed",I)},[]),m.useEffect(()=>{if(d)return;let I=!1;return Ce.getAgents().then(V=>{if(I)return;const se=(V==null?void 0:V.suggested)??"claude-code";u(M=>M??se),h(!0)}).catch(()=>{I||(u(V=>V??"claude-code"),h(!0))}),()=>{I=!0}},[d]);const g=m.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const I={agent:c};Ce.getSkills(I).then(V=>{s({type:"SET_SKILLS",skills:V});const M=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(M){const[,Y,G]=M,te=V.find(fe=>fe.plugin===Y&&fe.skill===G);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:G,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);m.useEffect(()=>{g()},[g]);const p=m.useCallback(I=>{s({type:"SELECT_SKILL",skill:I}),window.location.hash=`/skills/${I.plugin}/${I.skill}`},[]),y=m.useRef(a.skills);m.useEffect(()=>{y.current=a.skills},[a.skills]);const v=m.useCallback((I,V)=>{const se=y.current,M=I?se.find(te=>te.plugin===I&&te.skill===V):se.find(te=>te.skill===V&&te.source!=="plugin");if(!I&&!M){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(M==null?void 0:M.plugin)??I,G=(M==null?void 0:M.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:G}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=m.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=m.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=m.useCallback(I=>{s({type:"SET_MODE",mode:I})},[]),E=m.useCallback(I=>{s({type:"SET_SEARCH",query:I})},[]),C=m.useCallback(I=>{s({type:"SET_MOBILE_VIEW",view:I})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[D,F]=m.useState(""),w=m.useMemo(()=>a.skills.map(I=>`${I.plugin}/${I.skill}`),[a.skills]),O=m.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=uS({skillIds:O,trackingSkillIds:w}),U=m.useRef("");m.useEffect(()=>{const I=a.skills.filter(G=>G.origin==="installed");if(I.length===0){F(""),U.current="";return}const V=new Map;for(const G of z.updates)V.set(G.name.split("/").pop()||G.name,G);const se=I.map(G=>{const te=V.get(G.skill),fe=G.currentVersion??(te==null?void 0:te.installed)??G.version??G.pluginVersion??"0.0.0";return{plugin:G.plugin,skill:G.skill,name:(te==null?void 0:te.name)??G.skill,currentVersion:fe}}),M=se.map(G=>`${G.plugin}/${G.skill}@${G.currentVersion}#${G.name}`).sort().join("|");if(M===U.current)return;U.current=M;let Y=!1;return Ce.resolveInstalledSkillIds(se).then(G=>{if(Y)return;const ie=[...dS(G).flatMap(ye=>[ye.uuid,ye.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(G.map(ye=>[`${ye.plugin}/${ye.skill}`,{uuid:ye.uuid,slug:ye.slug}])),F(ie))}).catch(G=>{if(Y||(U.current=""),!B.current){B.current=!0;const te=G instanceof Error?G.message:String(G);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[a.skills,z.updates]);const H=m.useMemo(()=>{const I=a.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const se={...V};return delete se.updateAvailable,delete se.currentVersion,delete se.latestVersion,delete se.trackedForUpdates,se});return Zj(I,z.updates)},[a.skills,z.updates]),q=m.useMemo(()=>{const I={source:0,installed:0};for(const V of H)V.updateAvailable&&(I[V.origin]+=1);return I},[H]),X=m.useMemo(()=>({...a,skills:H}),[a,H]),J=z.updateCount,$=z.refresh,L=z.isRefreshing,_=m.useMemo(()=>({state:X,selectSkill:p,clearSelection:S,setMode:k,setSearch:E,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:L,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss}),[X,p,S,k,E,C,g,J,N,z.updates,q,L,$,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss]);return r.jsx(Nv.Provider,{value:_,children:t})}const hS={config:null,loading:!0};function xS(t,a){switch(a.type){case"SET_CONFIG":return{config:a.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Tv=m.createContext(null);function Ha(){const t=m.useContext(Tv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function gS({children:t}){const[a,s]=m.useReducer(xS,hS),o=m.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{o()},[o]);const c=m.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=m.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:o}),[a,c,o]);return r.jsx(Tv.Provider,{value:u,children:t})}function vS({topRail:t,sidebar:a,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const p={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:p,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:y,children:[!g&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!g&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const qx=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],yS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},bS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},jS={"claude-cli":"cli-install",anthropic:"api-key",openai:"api-key",openrouter:"api-key",cursor:"cli-install","codex-cli":"cli-install","gemini-cli":"cli-install",copilot:"cli-install",zed:"cli-install",ollama:"start-service","lm-studio":"start-service"},SS={"claude-cli":"subscription",anthropic:"per-token",openai:"per-token",openrouter:"per-token",cursor:"subscription","codex-cli":"subscription","gemini-cli":"subscription",copilot:"subscription",zed:"subscription",ollama:"free","lm-studio":"free"};function kS(t,a){var h,g;const s=yS[t.id]??null,o=bS[t.id]??null,c=s?!!((h=a==null?void 0:a.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=a==null?void 0:a.binaries)!=null&&g[o]):!0,d=t.models.map(p=>({id:p.id,displayName:p.label,billingMode:SS[t.id]??"per-token",...p.pricing?{pricing:p.pricing}:{},...p.resolvedId?{resolvedId:p.resolvedId}:{}}));return{id:t.id,displayName:wS(t.id,t.label),wrapperFolder:s,wrapperFolderPresent:c,binaryAvailable:u,endpointReachable:t.id==="ollama"||t.id==="lm-studio"?t.available:null,available:t.available,ctaType:t.available?null:jS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function wS(t,a){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??a}function CS(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of qx){const c=a.get(o);c&&s.push(c)}for(const o of t)qx.includes(o.id)||s.push(o);return s}function ES(t){const[a,s]=m.useState(null),[o,c]=m.useState("loading"),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null),y=m.useRef(0),v=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=m.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=CS((A.providers||[]).map(D=>kS(D,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const k=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const D=await B.json();y.current=T,g(null),s(O=>{if(!O)return O;const z=O.agents.map(U=>{if(U.id!=="openrouter")return U;const H=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:H,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...O,agents:z}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((A=v.current)==null||A.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=m.useCallback(T=>{p.current=T,T==="openrouter"&&k()},[k]),C=m.useCallback(()=>{y.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var F,w;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let D=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(D=O.error)}catch{}(w=b.current)==null||w.call(b,D)},[]);return{status:o,catalog:a,error:u,openRouterError:h,focusAgent:E,refresh:C,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function jd({variant:t,label:a,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return r.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":a,...c?{title:c}:{},children:a})}function Xd({unlocked:t=!1,size:a=10}){return t?r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const NS={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <skill> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,a)=>`${t} of ${a}`},TS={appTitle:"Skill Studio",commandPaletteButtonLabel:"Open command palette",commandPaletteHint:"⌘K",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},RS={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:t=>`Couldn't load SKILL.md for ${t}.`,loadErrorBody:"Check the file path and your workspace permissions.",openInEditor:"Open in editor",copyPath:"Copy path",copyConfigSnippet:"Copy config snippet",depNotInstalledTooltip:"Not installed",missingValue:"—",announceViewingOwn:t=>`Viewing ${t} (Own)`,announceViewingInstalled:t=>`Viewing ${t} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},AS={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},MS={inputPlaceholder:"Type a command or search",emptyResults:"No matches. Try a different query.",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",actionSelectSkill:"Select skill",actionRunBenchmark:"Run benchmark",actionSwitchTheme:"Switch theme",actionNewSkill:"New skill",closeLabel:"Close palette"},LS={title:"Keyboard shortcuts",closeLabel:"Close shortcuts",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",search:"Focus search",moveDown:"Move selection down",moveUp:"Move selection up",openSelected:"Open selected skill",openPalette:"Open command palette",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},zS={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},DS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},_S={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},OS={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},BS={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},IS={claudeCli:{name:"Claude Code",caption:"Delegates to the `claude` CLI — your existing Claude Code session handles quota.",missingBinary:"Claude Code not found. Install it: `npm install -g @anthropic-ai/claude-code`. Or choose a provider with an API key.",installCta:"Install Claude Code →",installUrl:"https://docs.claude.com/en/docs/claude-code"},anthropic:{name:"Anthropic API",caption:"Direct access via your Anthropic API key.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.claude.com/settings/keys",keyPrefix:"sk-ant-"},openai:{name:"OpenAI",caption:"GPT-4, GPT-5, and the o-series reasoning models.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.openai.com/api-keys",keyPrefix:"sk-",pastePlaceholder:"Paste OpenAI API key (sk-proj-...)"},openrouter:{name:"OpenRouter",caption:"300+ models from every major vendor.",addKeyCta:"Add API key →",emptyCardBody:"Add your OpenRouter API key to browse 300+ models",keyIssuanceUrl:"https://openrouter.ai/settings/keys",keyPrefix:"sk-or-"},cursor:{name:"Cursor",caption:"Cursor IDE composer.",installCta:"Install Cursor →"},codexCli:{name:"Codex CLI",caption:"OpenAI Codex CLI.",installCta:"Install Codex CLI →"},geminiCli:{name:"Gemini CLI",caption:"Google Gemini CLI.",installCta:"Install Gemini CLI →"},copilot:{name:"GitHub Copilot",caption:"GitHub Copilot CLI.",installCta:"Install Copilot →"},zed:{name:"Zed",caption:"Zed editor.",installCta:"Install Zed →"},ollama:{name:"Ollama",caption:"Local models, free.",startServiceCta:"Start service →"},lmStudio:{name:"LM Studio",caption:"Local models, free.",startServiceCta:"Start LM Studio server →",startServiceTooltip:"Open LM Studio → Developer tab → Start Server (default port 1234)."}},US={subscriptionBilling:"· subscription",free:"· free"},HS={title:"Settings",sectionApiKeys:"API Keys",banner:"Keys are stored locally on this device only. Never synced, never committed to git, never transmitted off-device except to the provider's own API.",storagePath:t=>`Keys stored at ${t} · protected by file permissions (0600 on macOS/Linux)`,storagePathFallback:"Keys stored locally on this device.",copyPath:"Copy path",pathCopied:"Path copied.",show:"Show",hide:"Hide",paste:"Paste",save:"Save",remove:"Remove",removeConfirm:t=>`Remove ${t} API key?`,keyStoredAt:t=>`Key stored locally — updated ${t}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:t=>`This doesn't look like a typical ${t} key. Save anyway?`,keySaved:t=>`${t} API key saved (local only, never synced)`,keyRemoved:t=>`${t} API key removed`},$S={providersLabel:"Providers",providerSummary:(t,a)=>`${t}/${a} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},VS={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},PS={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:t=>`No skills installed for ${t} in this project — run vskill install.`,emptyGlobal:t=>`No global skills for ${t} — run vskill install --global.`},FS={compactLabel:"Uses your Claude Code session · overflow billed at API rates",tooltip:"vSkill delegates to the `claude` CLI — your existing Claude Code session handles quota. If you've enabled extra usage in your account settings, excess runs at standard API rates. Run /usage in Claude Code or visit claude.com Settings → Usage to see remaining quota — vskill can't display it directly.",firstUseBanner:"Claude Code uses your existing session. No API key needed — vskill just runs the official claude binary on your behalf.",learnMore:"Learn more"},GS={title:t=>`Set up ${t}`,close:"Close",copy:"Copy",copied:"Copied",requiredEnv:"Required env vars",getKey:"Get a key",installRun:"Install & run",learnMore:"Learn more",fallbackTitle:"No setup guide available",fallbackBody:"We don't ship a setup guide for this provider yet."},WS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},qS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:NS,shell:TS,detail:RS,actions:AS,palette:MS,shortcuts:LS,toasts:zS,connection:DS,forms:_S,errors:OS,picker:BS,providers:IS,models:US,settings:HS,statusBar:$S,scopePicker:VS,scopeSection:PS,claudeCodeLabel:FS,setupDrawer:GS,setupProviders:qS,scopeLabels:WS},YS=new Set(["claude-cli","claude-code"]);function Yx(t){return YS.has(t)}const Kx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function KS({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Kx.has(g.id)),h=t.filter(g=>!Kx.has(g.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>r.jsx(Xx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>r.jsx(Xx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Xx({agent:t,isActive:a,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},p=Yx(t.id),y={minHeight:36,height:p?"auto":36,padding:p?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),Yx(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),r.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?r.jsx(Xd,{unlocked:!0,size:10}):r.jsx(Xd,{size:10})}),a&&r.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(jd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&r.jsx(jd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(jd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function XS(t,a,s,o){const d=t>=80,h=m.useRef(null),[g,p]=m.useState(0),y=m.useCallback(S=>{p(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/a)-4),k=Math.ceil(s/a)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[d,g,a,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*a,offsetTop:v*a,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Rv=44,QS=352,ZS=60,Qx=480;function JS(t){var u,d;const a=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return a?`${a} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function e2(t,a){if(!a)return t;const s=a.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function t2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>g(u),ZS);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&p.current&&p.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Qx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[r.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),r.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=m.useMemo(()=>e2(t.models,h),[t.models,h]),v=XS(y.length,Rv,QS);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Qx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&r.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:r.jsx("input",{ref:p,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?r.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[r.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),r.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):r.jsx("div",{...v.containerProps,children:r.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return r.jsx(r2,{model:b,isActive:b.id===a,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function n2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function r2({model:t,isActive:a,isFocused:s,onSelect:o,resolvedModel:c}){const u=JS(t),d=n2(t.id,c,t.resolvedId),h=d!==null,g=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",p=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Rv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:p,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[r.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&r.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Zx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function a2(){const[t,a]=m.useState(null),[s,o]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{o(!0);try{const p=await fetch("/api/settings/keys");if(!p.ok)throw new Error(`GET /api/settings/keys returned ${p.status}`);const y=await p.json();a({...Zx,...y}),u(null)}catch(p){u(p.message),a(Zx)}finally{o(!1)}},[]);m.useEffect(()=>{d()},[d]);const h=m.useCallback(async(p,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=m.useCallback(async p=>{const y=await fetch(`/api/settings/keys/${p}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${p} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function l2({onMigrated:t,fetchImpl:a}){const[s,o]=m.useState({kind:"loading"}),c=a??globalThis.fetch,u=m.useCallback(async()=>{var p;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((p=v.darwinKeys)==null?void 0:p.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{o({kind:"working"});try{const p=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!p.ok){o({kind:"error",message:`Migration failed (${p.status})`});return}const y=await p.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(p){o({kind:"error",message:p.message})}},[c,u,t]),h=m.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:Sd,children:"Retry"})]});const g=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...Sd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...Sd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Sd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},s2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function i2(t){const a=Date.now()-new Date(t).getTime();return a<6e4?"just now":a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:new Date(t).toLocaleString()}function Av({open:t,onClose:a,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=a2(),g=m.useRef(null),p=m.useRef(null),[y,v]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(E);C==null||C.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),a();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const C=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=m.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),r.jsx(l2,{onMigrated:()=>{h()}}),r.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),r.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[r.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),s2.map(S=>r.jsx(o2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?p:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Oa,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function o2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[p,y]=m.useState(""),[v,b]=m.useState(!1),[S,k]=m.useState(!1),[E,C]=m.useState(!1),[N,T]=m.useState(null),A=p.trim(),B=A.length===0,D=A.length>0&&!A.startsWith(o),F=m.useCallback(async()=>{if(B)return;k(!0);const z=A;y("");try{const U=await d(z);U.warning?T(U.warning):T(null)}finally{k(!1)}},[B,d,A]),w=m.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const U=await navigator.clipboard.readText();y(U)}catch{}},[]),O=m.useCallback(async()=>{C(!1),await h()},[h]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:g,type:v?"text":"password",value:p,onChange:z=>{y(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!v),style:Oa,children:v?ne.settings.hide:ne.settings.show}),r.jsx("button",{type:"button",onClick:w,style:Oa,children:ne.settings.paste})]}),D&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Jx,children:ne.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:Jx,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Oa,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Oa,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>C(!1),style:Oa,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Oa,color:"var(--text-muted)"},children:ne.settings.remove})}),r.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(i2(u.updatedAt)):ne.settings.noKey})]})]})}const Oa={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Jx={fontSize:11,color:"var(--warning, var(--text-muted))"};function c2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function u2({onToast:t}){const{status:a,catalog:s,focusAgent:o,setActive:c}=ES({onStaleCatalog:(U,H)=>{const q=Math.round(H/6e4);t==null||t(`Using cached ${U} catalog (${q} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(),[v,b]=m.useState(null),[S,k]=m.useState("agents"),[E,C]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var U;s&&!v&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(U=>U.id===v)??T[0],[T,v]);m.useEffect(()=>{C(0)},[v]);const B=m.useCallback(()=>{var U;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((U=T[0])==null?void 0:U.id)??null),C(0)},[s,T]),D=m.useCallback(()=>{var U;d(!1),(U=N.current)==null||U.focus()},[]);m.useEffect(()=>{const U=H=>{var X;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(H.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),m.useEffect(()=>{if(!u)return;const U=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),H(1);return}if(q.key==="ArrowUp"){q.preventDefault(),H(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)k("models"),C(0);else if(S==="models"&&A){const X=Math.max(0,Math.min(A.models.length-1,E)),J=A.models[X];J&&(c(A.id,J.id),D())}return}};function H(q){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&A){const X=A.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,T,v,A,E,D,o,c]);const F=m.useCallback(U=>{y(U==="anthropic"||U==="openrouter"?U:void 0),g(!0),d(!1)},[]),w=T.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=w==null?void 0:w.models.find(U=>U.id===(s==null?void 0:s.activeModel)),z=m.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const U=(w==null?void 0:w.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${H}`},[a,s,w,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:z})]}),u&&typeof document<"u"&&Go.createPortal(r.jsxs(d2,{reducedMotion:c2(),onClickOutside:D,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(KS,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),k("models")},onOpenSettings:F}),A&&r.jsx(t2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:U=>{c(A.id,U),D()},onOpenSettings:F})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),r.jsx(Av,{open:h,onClose:()=>g(!1),initialProvider:p,onToast:t})]})}function d2({children:t,reducedMotion:a,onClickOutside:s}){const o=m.useRef(null);return m.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
63
63
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
64
64
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
65
|
-
}`})]})}function eg(){typeof window>"u"||(window.location.hash="#/")}function f2({onHome:t}){const[a,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),eg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),eg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const p2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",m2=m.lazy(()=>Qs(()=>import("./UpdateDropdown-Dw9BDVCE.js"),__vite__mapDeps([0,1])));function h2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=er(),d=m.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,C]of u)C.diffSummary&&k.set(E,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=t===0?"No updates available":`${t} updates available, open summary`;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[r.jsx("img",{src:p2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(m2,{updates:a,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),C=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function tg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function x2({projectName:t,selected:a,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(f2,{onHome:o}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&d&&r.jsxs(r.Fragment,{children:[r.jsx(ng,{segment:"origin",onClick:()=>tg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),r.jsx(rg,{}),r.jsx(ng,{segment:"plugin",onClick:()=>tg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(rg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(u2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(h2,{})}),r.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:r.jsx("span",{children:"⌘K"})})]})]})}function ng({segment:t,onClick:a,style:s,children:o}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function rg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Wo="vskill-theme";function Mv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function g2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function v2(t){try{const a=t.getItem(Wo);return Mv(a)}catch{return"auto"}}function y2(t,a){try{t.setItem(Wo,a)}catch{}}function b2(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function j2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Lv=m.createContext(null);function S2({storage:t,matchMedia:a,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?v2(c):"auto"),[p,y]=m.useState(()=>j2(u)),v=m.useMemo(()=>g2(h,p),[h,p]);m.useEffect(()=>{d&&b2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Wo&&g(Mv(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=m.useCallback(k=>{g(k),c&&y2(c,k)},[c]),S=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(Lv.Provider,{value:S,children:o})}function zv(){const t=m.useContext(Lv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function k2(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=a.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function w2(t){const[a,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),a}function C2({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const o=k2(t),c=w2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?a==null||a(g.id):s==null||s(g.id)},[a,s]);if(c){const g=o.filter(p=>p.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>r.jsx(lg,{p,onClick:h},p.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>r.jsx(lg,{p:g,onClick:h,compact:!0},g.id))})}function lg({p:t,onClick:a,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(Xd,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function E2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Wo)}catch{return null}}function N2({projectPath:t,modelName:a,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=zv(),v=E2()==="auto",b=T2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(sg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(R2,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(sg,{}),r.jsx(C2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[r.jsx(A2,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function T2(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function R2({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function sg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function A2({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Qd=new Set;function Dv(){for(const t of Qd)t()}const M2=5,L2=1e3,z2=6e4;function D2(){const[t,a]=m.useState(void 0),[s,o]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),h=m.useRef(null),g=m.useRef(null),p=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=m.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=m.useCallback(async()=>{if(!p.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!p.current)return;const A=await T.json();if(!p.current)return;d.current=0,a(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{p.current&&b(B=>B+1)},z2)}catch(T){if(!p.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>M2){o(!0);return}const A=L2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{p.current&&b(B=>B+1)},A)}},[k]);m.useEffect(()=>(p.current=!0,()=>{p.current=!1,S(),k()}),[k]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=m.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(Qd.add(C),()=>{Qd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const qo=0,ca=1,_l=2,_v=4;function ig(t){return()=>t}function _2(t){t()}function Ov(t,a){return s=>t(a(s))}function og(t,a){return()=>t(a)}function O2(t,a){return s=>t(a,s)}function yf(t){return t!==void 0}function B2(...t){return()=>{t.map(_2)}}function Ol(){}function Yo(t,a){return a(t),t}function I2(t,a){return a(t)}function jt(...t){return t}function rt(t,a){return t(ca,a)}function Pe(t,a){t(qo,a)}function bf(t){t(_l)}function wt(t){return t(_v)}function Re(t,a){return rt(t,O2(a,qo))}function Qn(t,a){const s=t(ca,o=>{s(),a(o)});return s}function cg(t){let a,s;return o=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{o(a)},t)}}function Bv(t,a){return t===a}function bt(t=Bv){let a;return s=>o=>{t(a,o)||(a=o,s(o))}}function De(t){return a=>s=>{t(s)&&a(s)}}function ke(t){return a=>Ov(a,t)}function ir(t){return a=>()=>{a(t)}}function me(t,...a){const s=U2(...a);return((o,c)=>{switch(o){case _l:bf(t);return;case ca:return rt(t,s(c))}})}function or(t,a){return s=>o=>{s(a=t(a,o))}}function Ua(t){return a=>s=>{t>0?t--:a(s)}}function Ar(t){let a=null,s;return o=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,o(a)},t))}}function Fe(...t){const a=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,g=>{const p=s;s|=h,a[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():o=h}}function U2(...t){return a=>t.reduceRight(I2,a)}function H2(t){let a,s;const o=()=>a==null?void 0:a();return function(c,u){switch(c){case ca:return u?s===u?void 0:(o(),s=u,a=rt(t,u),a):(o(),Ol);case _l:o(),s=null;return}}}function ve(t){let a=t;const s=Xe();return((o,c)=>{switch(o){case qo:a=c;break;case ca:{c(a);break}case _v:return a}return s(o,c)})}function nn(t,a){return Yo(ve(a),s=>Re(t,s))}function Xe(){const t=[];return((a,s)=>{switch(a){case qo:t.slice().forEach(o=>{o(s)});return;case _l:t.splice(0,t.length);return;case ca:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return Yo(Xe(),a=>Re(t,a))}function et(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:$2(),singleton:s}}const $2=()=>Symbol();function V2(t){const a=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=o(c.map(g=>s(g)));return d&&a.set(u,h),h};return s(t)}function Ut(...t){const a=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,g=>{s[d]=g,o|=h,o===c&&Pe(a,s)})}),function(u,d){switch(u){case _l:{bf(a);return}case ca:return o===c&&d(s),rt(a,d)}}}function ze(t,a=Bv){return me(t,bt(a))}function Zd(...t){return function(a,s){switch(a){case _l:return;case ca:return B2(...t.map(o=>rt(o,s)))}}}const Pt={DEBUG:0,INFO:1,WARN:2,ERROR:3},P2={[Pt.DEBUG]:"debug",[Pt.ERROR]:"error",[Pt.INFO]:"log",[Pt.WARN]:"warn"},F2=()=>typeof globalThis>"u"?window:globalThis,ua=et(()=>{const t=ve(Pt.ERROR);return{log:ve((a,s,o=Pt.INFO)=>{const c=F2().VIRTUOSO_LOG_LEVEL??wt(t);o>=c&&console[P2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function $a(t,a,s){return jf(t,a,s).callbackRef}function jf(t,a,s){const o=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function G2(t,a,s,o,c,u,d,h,g){const p=Te.useCallback(y=>{const v=W2(y.children,a,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?ug("column-gap",getComputedStyle(y).columnGap,c):ug("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,o,h]);return jf(p,s,g)}function W2(t,a,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Pt.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function ug(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Pt.WARN),a==="normal"?0:parseInt(a??"0",10)}function Iv(t,a,s){const o=Te.useRef(null),c=Te.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(a){const S=a.getBoundingClientRect(),k=p.top-S.top;b=S.height-Math.max(0,k),v=k+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,p.top),v=p.top+S.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,a]),{callbackRef:u,ref:d}=jf(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var p;if(a){a.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(a),()=>{a.removeEventListener("scroll",h),y.unobserve(a)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,a,d]),u}const cn=et(()=>{const t=Xe(),a=Xe(),s=ve(0),o=Xe(),c=ve(0),u=Xe(),d=Xe(),h=ve(0),g=ve(0),p=ve(0),y=ve(0),v=Xe(),b=Xe(),S=ve(!1),k=ve(!1),E=ve(!1);return Re(me(t,ke(({scrollTop:C})=>C)),a),Re(me(t,ke(({scrollHeight:C})=>C)),d),Re(a,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Vs={lvl:0};function Uv(t,a){const s=t.length;if(s===0)return[];let{index:o,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=a(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ft(t){return t===Vs}function Ps(t,a){if(!ft(t))return a===t.k?t.v:a<t.k?Ps(t.l,a):Ps(t.r,a)}function Jn(t,a,s="k"){if(ft(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const o=Jn(t.r,a,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,a,s)}function En(t,a,s){return ft(t)?Vv(a,s,1):a===t.k?Vt(t,{k:a,v:s}):a<t.k?dg(Vt(t,{l:En(t.l,a,s)})):dg(Vt(t,{r:En(t.r,a,s)}))}function Rl(){return Vs}function Al(t,a,s){if(ft(t))return[];const o=Jn(t,a)[0];return q2(ef(t,o,s))}function Jd(t,a){if(ft(t))return Vs;const{k:s,l:o,r:c}=t;if(a===s){if(ft(o))return c;if(ft(c))return o;const[u,d]=$v(o);return Mo(Vt(t,{k:u,l:Hv(o),v:d}))}return a<s?Mo(Vt(t,{l:Jd(o,a)})):Mo(Vt(t,{r:Jd(c,a)}))}function Ia(t){return ft(t)?[]:[...Ia(t.l),{k:t.k,v:t.v},...Ia(t.r)]}function ef(t,a,s){if(ft(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>a&&(h=h.concat(ef(c,a,s))),o>=a&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(ef(u,a,s))),h}function Mo(t){const{l:a,lvl:s,r:o}=t;if(o.lvl>=s-1&&a.lvl>=s-1)return t;if(s>o.lvl+1){if(kd(a))return Pv(Vt(t,{lvl:s-1}));if(!ft(a)&&!ft(a.r))return Vt(a.r,{l:Vt(a,{r:a.r.l}),lvl:s,r:Vt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(kd(t))return tf(Vt(t,{lvl:s-1}));if(!ft(o)&&!ft(o.l)){const c=o.l,u=kd(c)?o.lvl-1:o.lvl;return Vt(c,{l:Vt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:tf(Vt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Vt(t,a){return Vv(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function Hv(t){return ft(t.r)?t.l:Mo(Vt(t,{r:Hv(t.r)}))}function kd(t){return ft(t)||t.lvl>t.r.lvl}function $v(t){return ft(t.r)?[t.k,t.v]:$v(t.r)}function Vv(t,a,s,o=Vs,c=Vs){return{k:t,l:o,lvl:s,r:c,v:a}}function dg(t){return tf(Pv(t))}function Pv(t){const{l:a}=t;return!ft(a)&&a.lvl===t.lvl?Vt(a,{r:Vt(t,{l:a.r})}):t}function tf(t){const{lvl:a,r:s}=t;return!ft(s)&&!ft(s.r)&&s.lvl===a&&s.r.lvl===a?Vt(s,{l:Vt(t,{r:s.l}),lvl:a+1}):t}function q2(t){return Uv(t,({k:a,v:s})=>({index:a,value:s}))}function Fv(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Fs(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Sf=et(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function Gv(t,a,s){return t[Bo(t,a,s)]}function Bo(t,a,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Y2(t,a,s,o){const c=Bo(t,a,o),u=Bo(t,s,o,c);return t.slice(c,u+1)}function ia(t,a){return Math.round(t.getBoundingClientRect()[a])}function Ko(t){return!ft(t.groupOffsetTree)}function kf({index:t},a){return a===t?0:a<t?-1:1}function K2(){return{groupIndices:[],groupOffsetTree:Rl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rl()}}function X2(t,a){let s=ft(t)?0:1/0;for(const o of a){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ft(t)){t=En(t,0,u);continue}const h=Al(t,d-1,c+1);if(h.some(rk(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Jd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));p&&(t=En(t,d,u))}return[t,s]}function Q2(t){return typeof t.groupIndex<"u"}function Z2({offset:t},a){return a===t?0:a<t?-1:1}function Gs(t,a,s){if(a.length===0)return 0;const{index:o,offset:c,size:u}=Gv(a,t,kf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Wv(t,a){if(!Ko(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function qv(t,a,s){if(Q2(t))return a.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Wv(o,a);return c=Math.max(0,c,Math.min(s,c)),c}function J2(t,a,s,o=0){return o>0&&(a=Math.max(a,Gv(t,o,kf).offset)),Uv(Y2(t,a,s,Z2),nk)}function ek(t,[a,s,o,c]){a.length>0&&o("received item sizes",a,Pt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ft(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=X2(d,a);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=nf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,Gs(S,v,c)),Rl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function tk(t){return Ia(t).map(({k:a,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function fg(t,a){let s=0,o=0;for(;s<t;)s+=a[o+1]-a[o]-1,o++;return o-(s===t?0:1)}function nf(t,a,s,o){let c=t,u=0,d=0,h=0,g=0;if(a!==0){g=Bo(c,a-1,kf),h=c[g].offset;const p=Jn(s,a-1);u=p[0],d=p[1],c.length&&c[g].size===Jn(s,a)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of Al(s,a,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function nk(t){return{index:t.index,value:t}}function rk(t){const{endIndex:a,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===a||c.end===1/0)&&c.value===s}const ak={offsetHeight:"height",offsetWidth:"width"},ur=et(([{log:t},{recalcInProgress:a}])=>{const s=Xe(),o=Xe(),c=nn(o,0),u=Xe(),d=Xe(),h=ve(0),g=ve([]),p=ve(void 0),y=ve(void 0),v=ve(void 0),b=ve(void 0),S=ve((w,O)=>ia(w,ak[O])),k=ve(void 0),E=ve(0),C=K2(),N=nn(me(s,Fe(g,t,E),or(ek,C),bt()),C),T=nn(me(g,bt(),or((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Re(me(g,De(w=>w.length>0),Fe(N,E),ke(([w,O,z])=>{const U=w.reduce((H,q,X)=>En(H,q,Gs(q,O.offsetTree,z)||X),Rl());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Re(me(o,Fe(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:w}])),s),Re(p,y);const A=nn(me(p,ke(w=>w===void 0)),!0);Re(me(y,De(w=>w!==void 0&&ft(wt(N).sizeTree)),ke(w=>{const O=wt(v),z=wt(g).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(me(b,De(w=>w!==void 0&&w.length>0&&ft(wt(N).sizeTree)),ke(w=>{const O=[];let z=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==z&&(O.push({endIndex:H-1,size:z,startIndex:U}),z=q,U=H)}return O.push({endIndex:w.length-1,size:z,startIndex:U}),O})),s),Re(me(g,Fe(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,z])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:z})}return U})),s);const B=Nn(me(s,Fe(N),or(({sizes:w},[O,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:C}),ke(w=>w.changed)));rt(me(h,or((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=wt(N);if(w>0)Pe(a,!0),Pe(u,w+fg(w,O));else if(w<0){const z=wt(T);z.length>0&&(w-=fg(-w,z)),Pe(d,w)}}),rt(me(h,Fe(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Pt.ERROR)});const D=Nn(u);Re(me(u,Fe(N),ke(([w,O])=>{const z=O.groupIndices.length>0,U=[],H=O.lastSize;if(z){const q=Ps(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ia(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ia(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Fe(N,E),ke(([w,{offsetTree:O},z])=>{const U=-w;return Gs(U,O,z)})));return Re(me(d,Fe(N,E),ke(([w,O,z])=>{if(O.groupIndices.length>0){if(ft(O.sizeTree))return O;let H=Rl();const q=wt(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ia(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Ps(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...nf(O.offsetTree,0,H,z)}}const U=Ia(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Rl());return{...O,sizeTree:U,...nf(O.offsetTree,0,U,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},jt(ua,Sf),{singleton:!0});function lk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const Yv=et(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),d=Xe(),h=Nn(me(u,ke(lk)));return Re(me(h,ke(g=>g.totalCount)),s),Re(me(h,ke(g=>g.groupIndices)),t),Re(me(Ut(c,a,o),De(([g,p])=>Ko(p)),ke(([g,p,y])=>Jn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),bt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},jt(ur,cn)),da=et(([{log:t}])=>{const a=ve(!1),s=Nn(me(a,De(o=>o),bt()));return rt(a,o=>{o&&wt(t)("props updated",{},Pt.DEBUG)}),{didMount:s,propsReady:a}},jt(ua),{singleton:!0}),sk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Kv(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!sk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const Zs=et(([{gap:t,listRefresh:a,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Xe(),k=Xe(),E=ve(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Pe(g,!1)}return Re(me(S,Fe(s,v,o,E,h,d,b),Fe(t,u,c),ke(([[B,D,F,w,O,z,U,H],q,X,J])=>{const $=Kv(B),{align:L,behavior:_,offset:I}=$,V=w-1,se=qv($,D,V);let M=Gs(se,D.offsetTree,q)+z;L==="end"?(M+=X+Jn(D.sizeTree,se)[1]-F+J,se===V&&(M+=U)):L==="center"?M+=(X+Jn(D.sizeTree,se)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=G=>{A(),G?(H("retrying to scroll to",{location:B},Pt.DEBUG),Pe(S,B)):(Pe(k,!0),H("list did not change, scroll successful",{},Pt.DEBUG))};if(A(),_==="smooth"){let G=!1;T=rt(a,te=>{G=G||te}),C=Qn(y,()=>{Y(G)})}else C=Qn(me(a,ik(150)),Y);return N=setTimeout(()=>{A()},1200),Pe(g,!0),H("scrolling from index to",{behavior:_,index:se,top:M},Pt.DEBUG),{behavior:_,top:M}})),p),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},jt(ur,cn,ua),{singleton:!0});function ik(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return o=>{o&&(a(!0),clearTimeout(s))}}}function wf(t,a){t===0?a():requestAnimationFrame(()=>{wf(t-1,a)})}function Cf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Js=et(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ve(!0),g=ve(0),p=ve(!0);return Re(me(d,Fe(g),De(([y,v])=>v!==0),ir(!1)),h),Re(me(d,Fe(g),De(([y,v])=>v!==0),ir(!1)),p),rt(me(Ut(a,d),Fe(h,s,t,p),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!ft(b)||yf(S))&&!v&&!k),Fe(g)),([,y])=>{Qn(c,()=>{Pe(p,!0)}),wf(4,()=>{Qn(o,()=>{Pe(h,!0)}),Pe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},jt(ur,cn,Zs,da),{singleton:!0});function Xv(t,a){return Math.abs(t-a)<1.01}const Ws="up",Is="down",ok="none",ck={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},uk=0,ei=et(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ve(!1),h=ve(!0),g=Xe(),p=Xe(),y=ve(4),v=ve(uk),b=nn(me(Zd(me(ze(c),Ua(1),ir(!0)),me(ze(c),Ua(1),ir(!1),cg(100))),bt()),!1),S=nn(me(Zd(me(s,ir(!0)),me(s,ir(!1),cg(200))),bt()),!1);Re(me(Ut(ze(c),ze(v)),ke(([T,A])=>T<=A),bt()),h),Re(me(h,Ar(50)),p);const k=Nn(me(Ut(o,ze(u),ze(a),ze(t),ze(y)),or((T,[{scrollHeight:A,scrollTop:B},D,F,w,O])=>{const z=B+D-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":D<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},ck),bt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=nn(me(o,or((T,{scrollHeight:A,scrollTop:B,viewportHeight:D})=>{if(!Xv(T.scrollHeight,A)){const F=A-(B+D)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Re(me(k,ke(T=>T.atBottom)),d),Re(me(d,Ar(50)),g);const C=ve(Is);Re(me(o,ke(({scrollTop:T})=>T),bt(),or((T,A)=>wt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Ws:Is,prevScrollTop:A},{direction:Is,prevScrollTop:0}),ke(T=>T.direction)),C),Re(me(o,Ar(50),ir(ok)),C);const N=ve(0);return Re(me(b,De(T=>!T),ir(0)),N),Re(me(c,Ar(100),Fe(b),De(([T,A])=>A),or(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},jt(cn)),qs="top",Ys="bottom",pg="none";function mg(t,a,s){return typeof t=="number"?s===Ws&&a===qs||s===Is&&a===Ys?t:0:s===Ws?a===qs?t.main:t.reverse:a===Ys?t.main:t.reverse}function hg(t,a){return typeof t=="number"?t:t[a]??0}const Ef=et(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),d=ve(0),h=ve(0),g=ve(0),p=nn(me(Ut(ze(o),ze(c),ze(s),ze(u,Fs),ze(g),ze(d),ze(a),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,D=C+N,F=Math.max(b-B,0);let w=pg;const O=hg(A,qs),z=hg(A,Ys);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+D-O&&(w=Ws),k<y-F+v+z&&(w=Is),w!==pg?[Math.max(B-b-mg(E,qs,w)-O,0),B-F-N+v+mg(E,Ys,w)+z]:null}),De(y=>y!==null),bt(Fs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},jt(cn),{singleton:!0});function dk(t,a,s){if(Ko(a)){const o=Wv(t,a);return[{index:Jn(a.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const wd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Lo(t,a,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=p,k=b-y;return{bottom:y,firstItemIndex:u,items:xg(t,c,u),offsetBottom:k,offsetTop:p,top:S,topItems:xg(a,c,u),topListHeight:a.reduce((E,C)=>C.size+E,0),totalCount:s}}function Qv(t,a,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=Cf(a,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Lo(p,[],h,c,s,o)}function xg(t,a,s){if(t.length===0)return[];if(!Ko(a))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Al(a.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=a.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function gg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Va=et(([{data:t,firstItemIndex:a,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ve([]),C=ve(0),N=Xe(),T=ve(0);Re(u.topItemsIndexes,E);const A=nn(me(Ut(S,k,ze(g,Fs),ze(c),ze(o),ze(p),y,ze(E),ze(a),ze(s),ze(T),t),De(([w,O,,z,,,,,,,,U])=>{const H=U!==void 0&&U.length!==z;return w&&!O&&!H}),ke(([,,[w,O],z,U,H,q,X,J,$,L,_])=>{var Se,Ae;const I=U,{offsetTree:V,sizeTree:se}=I,M=wt(C);if(z===0)return{...wd,totalCount:z};if(w===0&&O===0)return M===0?{...wd,totalCount:z}:Qv(M,H,U,J,$,_||[]);if(ft(se))return M>0?null:Lo(dk(Cf(H,z),I,_),[],z,$,I,J);const Y=[];if(X.length>0){const _e=X[0],ae=X[X.length-1];let he=0;for(const pe of Al(se,_e,ae)){const ge=pe.value,je=Math.max(pe.start,_e),Be=Math.min(pe.end,ae);for(let Oe=je;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:ge}),he+=ge}}if(!q)return Lo([],Y,z,$,I,J);const G=X.length>0?X[X.length-1]+1:0,te=J2(V,w,O,G);if(te.length===0)return null;const fe=z-1,ie=Yo([],_e=>{for(const ae of te){const he=ae.value;let pe=he.offset,ge=ae.start;const je=he.size;if(he.offset<w){ge+=Math.floor((w-he.offset+$)/(je+$));const Oe=ge-ae.start;pe+=Oe*je+Oe*$}ge<G&&(pe+=(G-ge)*je,ge=G);const Be=Math.min(ae.end,fe);for(let Oe=ge;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:je}),pe+=je+$}}),ye=gg(L,qs),de=gg(L,Ys);if(ie.length>0&&(ye>0||de>0)){const _e=ie[0],ae=ie[ie.length-1];if(ye>0&&_e.index>G){const he=Math.min(ye,_e.index-G),pe=[];let ge=_e.offset;for(let je=_e.index-1;je>=_e.index-he;je--){const Be=((Se=Al(se,je,je)[0])==null?void 0:Se.value)??_e.size;ge-=Be+$,pe.unshift({data:_==null?void 0:_[je],index:je,offset:ge,size:Be})}ie.unshift(...pe)}if(de>0&&ae.index<fe){const he=Math.min(de,fe-ae.index);let pe=ae.offset+ae.size+$;for(let ge=ae.index+1;ge<=ae.index+he;ge++){const je=((Ae=Al(se,ge,ge)[0])==null?void 0:Ae.value)??ae.size;ie.push({data:_==null?void 0:_[ge],index:ge,offset:pe,size:je}),pe+=je+$}}}return Lo(ie,Y,z,$,I,J)}),De(w=>w!==null),bt()),wd);Re(me(t,De(yf),ke(w=>w==null?void 0:w.length)),c),Re(me(A,ke(w=>w.topListHeight)),v),Re(v,h),Re(me(A,ke(w=>[w.top,w.bottom])),d),Re(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Fe(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),bt(Fs),ke(([w])=>w))),D=Nn(me(A,Ar(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),bt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,z=w.length-1;for(;w[O].type==="group"&&O<z;)O++;for(;w[z].type==="group"&&z>O;)z--;return{endIndex:w[z].index,startIndex:w[O].index}}),bt(Fv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:D,topItemsIndexes:E,...b}},jt(ur,Yv,Ef,Js,Zs,ei,da,Sf),{singleton:!0}),Zv=et(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),d=nn(me(Ut(s,t,o,a,c),ke(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Re(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},jt(cn,Va),{singleton:!0}),fk=et(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ve(!1),o=nn(me(Ut(s,t,a),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Ar(0),bt()),0);return{alignToBottom:s,paddingTopAddition:o}},jt(cn,Zv),{singleton:!0}),Jv=et(()=>({context:ve(null)})),pk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,ey=et(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Xe();return Re(me(y,Fe(a,g,s,u,c,o,h),Fe(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=pk,done:D,...F}=v,w=qv(v,b,k-1),O=Gs(w,b.offsetTree,A)+E+C,z=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:z,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?D&&Qn(me(d,De(X=>!X),Ua(wt(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),p),{scrollIntoView:y}},jt(ur,cn,Zs,Va,ua),{singleton:!0});function vg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const mk=(t,a)=>typeof t=="function"?vg(t(a)):a&&vg(t),hk=et(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ve(!1),E=Xe();let C=null;function N(D){Pe(d,{align:"end",behavior:D,index:"LAST"})}rt(me(Ut(me(ze(a),Ua(1)),g),Fe(ze(k),u,h,v),ke(([[D,F],w,O,z,U])=>{let H=F&&z,q="auto";return H&&(q=mk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D)}):C=Qn(t,()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D),C=null})});function T(D){const F=Qn(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(wt(y)("scrolling to bottom due to increased size",{},Pt.DEBUG),N("auto"))});setTimeout(F,100)}rt(me(Ut(ze(k),a,p),De(([D,,F])=>D!==!1&&F),or(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Fe(k,a)),([,D])=>{wt(h)&&T(D!==!1)}),rt(E,()=>{T(wt(k)!==!1)}),rt(Ut(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ve(null),B=Xe();return Re(Zd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(a))),B),rt(me(Ut(me(B,Ua(1)),g),Fe(ze(A),h,v,b),ke(([[D,F],w,O,z,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Ar(0)),D=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("scrolling into view",{}),Pe(S,D)}):C=Qn(t,()=>{wt(y)("scrolling into view",{}),Pe(S,D),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},jt(ur,ei,Zs,Js,da,ua,cn,Jv,ey)),xk=et(([{data:t,firstItemIndex:a,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(me(h,Fe(u),De(([,g])=>g!==0),Fe(c,o,a,s,t),ke(([[,g],p,y,v,b,S=[]])=>Qv(g,p,y,v,b,S))),d),{}),jt(ur,Js,Va,da),{singleton:!0}),gk=et(([{didMount:t},{scrollTo:a},{listState:s}])=>{const o=ve(0);return rt(me(t,Fe(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ua(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(a,c)})})}),{initialScrollTop:o}},jt(da,cn,Va),{singleton:!0}),ty=et(([{scrollVelocity:t}])=>{const a=ve(!1),s=Xe(),o=ve(!1);return Re(me(t,Fe(o,a,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),bt()),a),rt(me(Ut(a,t,s),Fe(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},jt(ei),{singleton:!0}),Nf=et(([{scrollContainerState:t,scrollTo:a}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ve(!1),d=ve(void 0);return Re(me(Ut(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Re(me(a,Fe(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},jt(cn)),vk=et(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Xe(),y=ve(void 0),v=ve(null),b=ve(null);return Re(h,v),Re(g,b),rt(me(p,Fe(a,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=tk(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Re(me(y,De(yf),ke(yk)),c),Re(me(u,Fe(y),De(([,S])=>S!==void 0),bt(),ke(([,S])=>S.ranges)),t),{getState:p,restoreStateFrom:y}},jt(ur,cn,Js,da,Nf));function yk(t){return{align:"start",index:0,offset:t.scrollTop}}const bk=et(([{topItemsIndexes:t}])=>{const a=ve(0);return Re(me(a,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:a}},jt(Va));function ny(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const jk=ny(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sk=et(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Fe(d),or(([,N,T,A],[{bottom:B,items:D,offsetBottom:F,totalCount:w},O])=>{const z=B+F;let U=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(U=z-A,U!==0&&(U+=O))),[U,D,w,z]},[0,[],0,0]),De(([N])=>N!==0),Fe(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Ws),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Pt.DEBUG),N))));function C(N){N>0?(Pe(a,{behavior:"auto",top:-N}),Pe(t,0)):(Pe(t,0),Pe(a,{behavior:"auto",top:-N}))}return rt(me(E,Fe(t,u)),([N,T,A])=>{A&&jk()?Pe(t,T-N):C(-N)}),rt(me(Ut(nn(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Ar(1)),C),Re(me(v,ke(N=>({top:-N}))),a),rt(me(p,Fe(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},D])=>{function F(H){return H*(A+D)}if(T.length===0)return F(N);let w=0;const O=Ps(B,0);let z=0,U=0;for(;z<N;){z++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;z+H>N&&(w-=O,H=N-z+1),z+=H,w+=F(H),U++}return w})),N=>{Pe(t,N),requestAnimationFrame(()=>{Pe(a,{top:N}),requestAnimationFrame(()=>{Pe(t,0),Pe(k,!1)})})}),{deviation:t}},jt(cn,ei,Va,ur,ua,Sf)),kk=et(([t,a,s,o,c,u,d,h,g,p,y])=>({...t,...a,...s,...o,...c,...u,...d,...h,...g,...p,...y}),jt(Ef,xk,da,ty,Zv,gk,fk,Nf,ey,ua,Jv)),ry=et(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:D},F,{topItemCount:w},{groupCounts:O},z])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Re(X,z.scrollSeekRangeChanged),Re(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:p,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...T}},jt(ur,Js,cn,vk,hk,Va,Zs,Sk,bk,Yv,kk));function wk(t,a){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(o,d)||(s[d]=a[d]);return s}const yo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function ay(t,a,s){const o=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Te.createContext({});function g(C,N){C.propsReady!==void 0&&Pe(C.propsReady,!1);for(const T of o){const A=C[a.required[T]];Pe(A,N[T])}for(const T of c)if(T in N){const A=C[a.optional[T]];Pe(A,N[T])}C.propsReady!==void 0&&Pe(C.propsReady,!0)}function p(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[a.methods[T]];Pe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=H2(C[a.events[T]]),N),{})}const v=Te.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Te.useState(()=>Yo(V2(t),w=>{g(w,A)})),[D]=Te.useState(og(y,B));yo(()=>{for(const w of d)w in A&&rt(D[w],A[w]);return()=>{Object.values(D).map(bf)}},[A,D,B]),yo(()=>{g(B,A)}),Te.useImperativeHandle(N,ig(p(B)));const F=s;return r.jsx(h.Provider,{value:B,children:s!==void 0?r.jsx(F,{...wk([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Te.useContext(h);return Te.useCallback(T=>{Pe(N[C],T)},[N,C])},S=C=>{const N=Te.useContext(h)[C],T=Te.useCallback(A=>rt(N,A),[N]);return Te.useSyncExternalStore(T,()=>wt(N),()=>wt(N))},k=C=>{const N=Te.useContext(h)[C],[T,A]=Te.useState(og(wt,N));return yo(()=>rt(N,B=>{B!==T&&A(ig(B))}),[N,T]),T},E=parseInt(Te.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Te.useContext(h)[C];yo(()=>rt(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const ly=Te.createContext(void 0),sy=Te.createContext(void 0),Cd="-webkit-sticky",yg="sticky",Tf=ny(()=>{if(typeof document>"u")return yg;const t=document.createElement("div");return t.style.position=Cd,t.style.position===Cd?Cd:yg}),iy=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Ed(t){return"self"in t}function Ck(t){return"body"in t}function oy(t,a,s,o=Ol,c,u){const d=Te.useRef(null),h=Te.useRef(null),g=Te.useRef(null),p=Te.useCallback(b=>{let S,k,E;const C=b.target;if(Ck(C)||Ed(C)){const T=Ed(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Fj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,a(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,a,u]);Te.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Ed(S)?(C=Math.max(ia(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ia(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Xv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&a(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Rf(t){return t}const Ek=et(()=>{const t=ve(h=>`Item ${h}`),a=ve(h=>`Group ${h}`),s=ve({}),o=ve(Rf),c=ve("div"),u=ve(Ol),d=(h,g=null)=>nn(me(s,ke(p=>p[h]),bt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),Nk=et(([t,a])=>({...t,...a}),jt(ry,Ek)),Tk=({height:t})=>r.jsx("div",{style:{height:t}}),Rk={overflowAnchor:"none",position:Tf(),zIndex:1},cy={overflowAnchor:"none"},Ak={...cy,display:"inline-block",height:"100%"},bg=Te.memo(function({showTopList:t=!1}){const a=Ue("listState"),s=Pn("sizeRanges"),o=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=Ue("itemContent"),p=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),k=Pn("gap"),E=Ue("horizontalDirection"),{callbackRef:C}=G2(s,b,v,t?Ol:h,S,k,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Af("deviation",J=>{N!==J&&T(J)});const A=Ue("EmptyPlaceholder"),B=Ue("ScrollSeekPlaceholder")??Tk,D=Ue("ListComponent"),F=Ue("ItemComponent"),w=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),U=Ue("groupIndices").length>0,H=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...tn(A,p)}):r.jsx(D,{...tn(D,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?a.topItems:a.items).map(J=>{const $=J.originalIndex,L=O($+a.firstItemIndex,J.data,p);return z?m.createElement(B,{...tn(B,p),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?m.createElement(w,{...tn(w,p),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:Rk},y(J.index,p)):m.createElement(F,{...tn(F,p),...Dk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Ak:cy},U?g(J.index,J.groupIndex,J.data,p):g(J.index,J.data,p))})})}),Mk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Lk={outline:"none",overflowX:"auto",position:"relative"},Xo=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),zk={position:Tf(),top:0,width:"100%",zIndex:1};function tn(t,a){if(typeof t!="string")return{context:a}}function Dk(t,a){return{item:typeof t=="string"?void 0:a}}const _k=Te.memo(function(){const t=Ue("HeaderComponent"),a=Pn("headerHeight"),s=Ue("HeaderFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),Ok=Te.memo(function(){const t=Ue("FooterComponent"),a=Pn("footerHeight"),s=Ue("HeaderFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null});function uy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=a("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=oy(h,p,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),r.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Lk:Mk,...c},tabIndex:0,...d,...tn(g,u),children:o})})}function dy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=a("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Te.useRef(null),k=a("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=oy(h,p,g,k,b);return iy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...tn(g,u),children:o})})}const Bk=({children:t})=>{const a=Te.useContext(ly),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>Ov(s,g=>ia(g,u?"width":"height")),[s,u]),h=$a(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{a&&(s(a.viewportHeight),o(a.itemHeight))},[a,s,o]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:Xo(c),children:t})},Ik=({children:t})=>{const a=Te.useContext(ly),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=Ue("customScrollParent"),u=Iv(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{a&&(o(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,o]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:Xo(d),children:t})},Uk=({children:t})=>{const a=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),o={...zk,marginTop:`${s}px`},c=Ue("context");return r.jsx(a,{style:o,...tn(a,c),children:t})},Hk=Te.memo(function(t){const a=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,o=Ue("customScrollParent"),c=Ue("context");return r.jsxs(o||a?Pk:Vk,{...t,context:c,children:[s&&r.jsx(Uk,{children:r.jsx(bg,{showTopList:!0})}),r.jsxs(o||a?Ik:Bk,{children:[r.jsx(_k,{}),r.jsx(bg,{}),r.jsx(Ok,{})]})]})}),{Component:$k,useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}=ay(Nk,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Hk),Vk=uy({useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}),Pk=dy({useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}),Fk=$k,Gk=et(()=>{const t=ve(p=>r.jsxs("td",{children:["Item $",p]})),a=ve(null),s=ve(p=>r.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ve(null),c=ve(null),u=ve({}),d=ve(Rf),h=ve(Ol),g=(p,y=null)=>nn(me(u,ke(v=>v[p]),bt()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});jt(ry,Gk);Tf();const jg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Wk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Sg,floor:Io,max:Us,min:Nd,round:kg}=Math;function wg(t,a,s){return Array.from({length:a-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function qk(t){return{...Wk,items:t}}function bo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Yk(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Kk=et(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},D])=>{const F=ve(0),w=ve(0),O=ve(jg),z=ve({height:0,width:0}),U=ve({height:0,width:0}),H=Xe(),q=Xe(),X=ve(0),J=ve(null),$=ve({column:0,row:0}),L=Xe(),_=Xe(),I=ve(!1),V=ve(0),se=ve(!0),M=ve(!1),Y=ve(!1);rt(me(k,Fe(V),De(([de,Se])=>Se!==0)),()=>{Pe(se,!1)}),rt(me(Ut(k,se,U,z,V,M),De(([de,Se,Ae,_e,,ae])=>de&&!Se&&Ae.height!==0&&_e.height!==0&&!ae)),([,,,,de])=>{Pe(M,!0),wf(1,()=>{Pe(H,de)}),Qn(me(p),()=>{Pe(a,[0,0]),Pe(se,!0)})}),Re(me(_,De(de=>de!=null&&de.scrollTop>0),ir(0)),w),rt(me(k,Fe(_),De(([,de])=>de!=null)),([,de])=>{de&&(Pe(z,de.viewport),Pe(U,de.item),Pe($,de.gap),de.scrollTop>0&&(Pe(I,!0),Qn(me(p,Ua(1)),Se=>{Pe(I,!1)}),Pe(g,{top:de.scrollTop})))}),Re(me(z,ke(({height:de})=>de)),v),Re(me(Ut(ze(z,bo),ze(U,bo),ze($,(de,Se)=>de!==void 0&&de.column===Se.column&&de.row===Se.row),ze(p)),ke(([de,Se,Ae,_e])=>({gap:Ae,item:Se,scrollTop:_e,viewport:de}))),L),Re(me(Ut(ze(F),o,ze($,Yk),ze(U,bo),ze(z,bo),ze(J),ze(w),ze(I),ze(se),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[Se,Ae],_e,ae,he,pe,ge,,je,Be])=>{const{column:Oe,row:at}=_e,{height:Nt,width:ht}=ae,{width:Dt}=he;if(ge===0&&(de===0||Dt===0))return jg;if(ht===0){const Gt=Cf(Be,de),rn=Gt+Math.max(ge-1,0);return qk(wg(Gt,rn,pe))}const Tt=fy(Dt,ht,Oe);let Qe,tt;je?Se===0&&Ae===0&&ge>0?(Qe=0,tt=ge-1):(Qe=Tt*Io((Se+at)/(Nt+at)),tt=Tt*Sg((Ae+at)/(Nt+at))-1,tt=Nd(de-1,Us(tt,Tt-1)),Qe=Nd(tt,Us(0,Qe))):(Qe=0,tt=-1);const be=wg(Qe,tt,pe),{bottom:pt,top:Ct}=Cg(he,_e,ae,be),Yt=Sg(de/Tt),un=Yt*Nt+(Yt-1)*at-pt;return{bottom:pt,itemHeight:Nt,items:be,itemWidth:ht,offsetBottom:un,offsetTop:Ct,top:Ct}})),O),Re(me(J,De(de=>de!==null),ke(de=>de.length)),F),Re(me(Ut(z,U,O,$),De(([de,Se,{items:Ae}])=>Ae.length>0&&Se.height!==0&&de.height!==0),ke(([de,Se,{items:Ae},_e])=>{const{bottom:ae,top:he}=Cg(de,_e,Se,Ae);return[he,ae]}),bt(Fs)),a);const G=ve(!1);Re(me(p,Fe(G),ke(([de,Se])=>Se||de!==0)),G);const te=Nn(me(Ut(O,F),De(([{items:de}])=>de.length>0),Fe(G),De(([[de,Se],Ae])=>{const _e=de.items[de.items.length-1].index===Se-1;return(Ae||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===Se)&&_e}),ke(([[,de]])=>de-1),bt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ir(0),bt())),ie=Nn(me(ze(O),Fe(I),De(([{items:de},Se])=>de.length>0&&!Se),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),bt(Fv),Ar(0)));Re(ie,S.scrollSeekRangeChanged),Re(me(H,Fe(z,U,F,$),ke(([de,Se,Ae,_e,ae])=>{const he=Kv(de),{align:pe,behavior:ge,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=Us(0,Be,Nd(_e-1,Be));let Oe=rf(Se,ae,Ae,Be);return pe==="end"?Oe=kg(Oe-Se.height+Ae.height):pe==="center"&&(Oe=kg(Oe-Se.height/2+Ae.height/2)),je!==void 0&&je!==0&&(Oe+=je),{behavior:ge,top:Oe}})),g);const ye=nn(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Re(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ye,...b,endReached:te,propsReady:E,rangeChanged:ie,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...D}},jt(Ef,cn,ei,ty,da,Nf,ua));function fy(t,a,s){return Us(1,Io((t+s)/(Io(a)+s)))}function Cg(t,a,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=rf(t,a,s,o[0].index);return{bottom:rf(t,a,s,o[o.length-1].index)+c,top:u}}function rf(t,a,s,o){const c=fy(t.width,s.width,a.column),u=Io(o/c),d=u*s.height+Us(0,u-1)*a.row;return d>0?d+a.row:d}const Xk=et(()=>{const t=ve(v=>`Item ${v}`),a=ve({}),s=ve(null),o=ve("virtuoso-grid-item"),c=ve("virtuoso-grid-list"),u=ve(Rf),d=ve("div"),h=ve(Ol),g=(v,b=null)=>nn(me(a,ke(S=>S[v]),bt()),b),p=ve(!1),y=ve(!1);return Re(ze(y),p),{components:a,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Qk=et(([t,a])=>({...t,...a}),jt(Kk,Xk)),Zk=Te.memo(function(){const t=kt("gridState"),a=kt("listClassName"),s=kt("itemClassName"),o=kt("itemContent"),c=kt("computeItemKey"),u=kt("isSeeking"),d=Fn("scrollHeight"),h=kt("ItemComponent"),g=kt("ListComponent"),p=kt("ScrollSeekPlaceholder"),y=kt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=kt("log"),k=kt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=$a(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:D}=A.getBoundingClientRect();v({height:B,width:D})}b({column:Eg("column-gap",getComputedStyle(N).columnGap,S),row:Eg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return iy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:r.jsx(g,{className:a,ref:C,...tn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?r.jsx(p,{...tn(p,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(h,{...tn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),Jk=Te.memo(function(){const t=kt("HeaderComponent"),a=Fn("headerHeight"),s=kt("headerFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=kt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),ew=Te.memo(function(){const t=kt("FooterComponent"),a=Fn("footerHeight"),s=kt("headerFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=kt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),tw=({children:t})=>{const a=Te.useContext(sy),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=$a(Te.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Te.useEffect(()=>{a&&(o({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,o,s]),r.jsx("div",{ref:c,style:Xo(!1),children:t})},nw=({children:t})=>{const a=Te.useContext(sy),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=kt("customScrollParent"),u=Iv(s,c,!1);return Te.useEffect(()=>{a&&(o({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,o]),r.jsx("div",{ref:u,style:Xo(!1),children:t})},rw=Te.memo(function({...t}){const a=kt("useWindowScroll"),s=kt("customScrollParent"),o=s||a?lw:aw,c=s||a?nw:tw,u=kt("context");return r.jsx(o,{...t,...tn(o,u),children:r.jsxs(c,{children:[r.jsx(Jk,{}),r.jsx(Zk,{}),r.jsx(ew,{})]})})}),{useEmitter:py,useEmitterValue:kt,usePublisher:Fn}=ay(Qk,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},rw),aw=uy({useEmitter:py,useEmitterValue:kt,usePublisher:Fn}),lw=dy({useEmitter:py,useEmitterValue:kt,usePublisher:Fn});function Eg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Pt.WARN),a==="normal"?0:parseInt(a??"0",10)}const sw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},my={source:"Own",installed:"Installed"};function iw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function ow(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Ng({origin:t,count:a,filteredCount:s,updateCount:o,children:c}){const u=sw[t],[d,h]=m.useState(()=>iw(u)),g=m.useCallback(()=>{h(b=>{const S=!b;return ow(u,S),S})},[u]),p=my[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(uw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),o!=null&&o>0&&r.jsx(cw,{origin:t,updateCount:o})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function cw({origin:t,updateCount:a}){const[s,o]=m.useState(!1),c=my[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function uw({collapsed:t}){return r.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Mf(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function dw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>a(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(a(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function fw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function pw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function mw({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(Ev)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ti(t){const{version:a,showPrefix:s=!0,size:o="md"}=t;if(!a||typeof a!="string"||a.trim()==="")return null;const c=s&&!a.startsWith("v")?`v${a}`:a,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":a,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function hw({skill:t,isSelected:a,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&r.jsx(ti,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(fw,{target:t.symlinkTarget??null}),r.jsx(pw,{skill:t}),r.jsx(mw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Uo=m.memo(hw);function xw({plugin:t,skills:a,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...a].sort((d,h)=>d.skill.localeCompare(h.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Uo,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function gw(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function Tg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>gw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>r.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const zo=new Map,Ba=new Map,_s=new Map;function Tn(t){zo.delete(t),Ba.delete(t);const a=_s.get(t);if(a)for(const s of a)s()}function ni(t,a,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>Tn(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return _s.has(t)||_s.set(t,new Set),_s.get(t).add(b),()=>{var S;(S=_s.get(t))==null||S.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=zo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Ba.has(t)){const C=Ba.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=a().then(C=>{zo.set(t,{data:C,fetchedAt:Date.now()}),Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Ba.set(t,k)},[t,a,o,c]);const p=zo.get(t),y=c&&!p&&Ba.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}function vw({pluginName:t,enabled:a,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),Dv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return r.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Td,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Td,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Td,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Td({onClick:t,disabled:a,busy:s,label:o,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Rg({name:t,count:a,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[p&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(yw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function yw({label:t,title:a,icon:s,onClick:o,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function bw(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function jw(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function Sw(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function kw(t,a){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||o!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function af(t,a={}){const{enabled:s=!0,target:o}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(jw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=Sw(p.target);for(const v of c.current){if(!kw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const ww=200;function Cw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Ew(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Mf(g,a)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Nw(t,a){const s=[],o=[],c=[];for(const d of t){const h=Cw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Mf(v,a)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function Tw(t,a){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Mf(y,a)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Rw({skills:t,selectedKey:a,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(G=>G.scope!==void 0&&G.scope!==null),k=g??"claude-cli",[E,C]=m.useState(""),N=m.useDeferredValue(E),T=m.useMemo(()=>Nw(t,N),[t,N]),A=m.useMemo(()=>Ew(t,N),[t,N]),B=k==="claude-code",{plugins:D}=D2(),F=B?{plugins:D??[]}:void 0,w=m.useMemo(()=>{const G=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=G.get(te.name);G.set(te.name,!!fe||!!te.enabled)}return G},[F==null?void 0:F.plugins]),[O,z]=m.useState(()=>lf(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=m.useState(()=>lf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=m.useCallback(G=>{z(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(G))}catch{}},[k]),X=m.useCallback(G=>{H(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(G))}catch{}},[k]),{own:J,installed:$}=m.useMemo(()=>Tw(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=ww,I=m.useMemo(()=>{const G=te=>{const fe=[];for(const[,ie]of te){const ye=[...ie].sort((de,Se)=>de.skill.localeCompare(Se.skill));fe.push(...ye)}return fe};return S?[...G(T.own.byPlugin),...G(T.installed.byPlugin),...G(T.global.byPlugin)]:[...G(J.byPlugin),...G($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=m.useMemo(()=>a?I.findIndex(G=>G.plugin===a.plugin&&G.skill===a.skill):-1,[I,a]),se=m.useCallback(G=>{if(I.length===0)return;const te=V<0?G>0?0:I.length-1:Math.min(Math.max(V+G,0),I.length-1);s(I[te])},[I,V,s]),M=m.useMemo(()=>{if(!v)return null;const[G,te]=v.split("/");if(!G||!te)return null;const fe=t.find(de=>de.plugin===G&&de.skill===te);if(!fe)return{plugin:G,skill:te,bucket:null,pluginName:null};const ie=fe.source==="plugin"?"plugin":"project",ye=ie==="plugin"?fe.pluginName??G:null;return{plugin:G,skill:te,bucket:ie,pluginName:ye}},[v,t]),Y=m.useRef(null);return m.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const G=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${G}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>se(1)},{key:"k",handler:()=>se(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(dw,{value:E,onChange:C}),o&&r.jsx(Dw,{}),!o&&c&&r.jsx(_w,{error:c,onRetry:u}),!o&&!c&&S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Rg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&r.jsxs(r.Fragment,{children:[r.jsx(Ms,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?r.jsx(Mg,{queryActive:!!E,agentId:k}):r.jsx(Ls,{items:A.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Ms,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:A.availablePersonal.filtered===0?r.jsx(Mw,{queryActive:!!E,agentId:k}):r.jsx(Ls,{items:A.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsxs(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?r.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-available-${G}-collapsed`,headerActionSlot:B?r.jsx(vw,{pluginName:G,enabled:w.get(G)??!0}):void 0,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${G}`))]})]}),r.jsx(zw,{}),r.jsx(Rg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&r.jsxs(r.Fragment,{children:[r.jsx(Ms,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ls,{items:A.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsx(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?r.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",r.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-authoring-${G}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===G,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${G}`))})]})]}),!o&&!c&&!S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ng,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ls,{items:J.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Lw,{}),r.jsx(Ng,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?r.jsx(Mg,{queryActive:!!E}):r.jsx(Ls,{items:$.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function lf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ms({label:t,storageKey:a,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>lf(a)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(a,String(S))}catch{}return S})},[a]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function Aw(t){const a=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Ls({items:t,selectedKey:a,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Aw(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Fk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!a&&a.plugin===g.plugin&&a.skill===g.skill;return r.jsx(Uo,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>r.jsx(xw,{plugin:u,skills:d,selectedKey:a,onSelect:s,onContextMenu:o},u))})}function Ag({queryActive:t}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Lf,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Mg({queryActive:t,agentId:a}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install <skill>"})," to add one."]})})}function Mw({queryActive:t,agentId:a}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install --global <skill>"})," to add one."]})})}function Ml({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function Lf({children:t}){return r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function Lw(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function zw(){return r.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function Dw(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(bw,{},t))})}function _w({error:t,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:Ow(t)}),r.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),a&&r.jsx("button",{type:"button",onClick:a,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function Ow(t){const a=t.split(`
|
|
65
|
+
}`})]})}function eg(){typeof window>"u"||(window.location.hash="#/")}function f2({onHome:t}){const[a,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),eg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),eg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const p2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",m2=m.lazy(()=>Qs(()=>import("./UpdateDropdown-D0ZXWKht.js"),__vite__mapDeps([0,1])));function h2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=er(),d=m.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,C]of u)C.diffSummary&&k.set(E,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=t===0?"No updates available":`${t} updates available, open summary`;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[r.jsx("img",{src:p2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(m2,{updates:a,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),C=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function tg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function x2({projectName:t,selected:a,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(f2,{onHome:o}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&d&&r.jsxs(r.Fragment,{children:[r.jsx(ng,{segment:"origin",onClick:()=>tg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),r.jsx(rg,{}),r.jsx(ng,{segment:"plugin",onClick:()=>tg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(rg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(u2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(h2,{})}),r.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:r.jsx("span",{children:"⌘K"})})]})]})}function ng({segment:t,onClick:a,style:s,children:o}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function rg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Wo="vskill-theme";function Mv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function g2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function v2(t){try{const a=t.getItem(Wo);return Mv(a)}catch{return"auto"}}function y2(t,a){try{t.setItem(Wo,a)}catch{}}function b2(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function j2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Lv=m.createContext(null);function S2({storage:t,matchMedia:a,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?v2(c):"auto"),[p,y]=m.useState(()=>j2(u)),v=m.useMemo(()=>g2(h,p),[h,p]);m.useEffect(()=>{d&&b2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Wo&&g(Mv(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=m.useCallback(k=>{g(k),c&&y2(c,k)},[c]),S=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(Lv.Provider,{value:S,children:o})}function zv(){const t=m.useContext(Lv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function k2(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=a.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function w2(t){const[a,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),a}function C2({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const o=k2(t),c=w2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?a==null||a(g.id):s==null||s(g.id)},[a,s]);if(c){const g=o.filter(p=>p.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>r.jsx(lg,{p,onClick:h},p.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>r.jsx(lg,{p:g,onClick:h,compact:!0},g.id))})}function lg({p:t,onClick:a,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(Xd,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function E2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Wo)}catch{return null}}function N2({projectPath:t,modelName:a,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=zv(),v=E2()==="auto",b=T2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(sg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(R2,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(sg,{}),r.jsx(C2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[r.jsx(A2,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function T2(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function R2({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function sg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function A2({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Qd=new Set;function Dv(){for(const t of Qd)t()}const M2=5,L2=1e3,z2=6e4;function D2(){const[t,a]=m.useState(void 0),[s,o]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),h=m.useRef(null),g=m.useRef(null),p=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=m.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=m.useCallback(async()=>{if(!p.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!p.current)return;const A=await T.json();if(!p.current)return;d.current=0,a(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{p.current&&b(B=>B+1)},z2)}catch(T){if(!p.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>M2){o(!0);return}const A=L2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{p.current&&b(B=>B+1)},A)}},[k]);m.useEffect(()=>(p.current=!0,()=>{p.current=!1,S(),k()}),[k]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=m.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(Qd.add(C),()=>{Qd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const qo=0,ca=1,_l=2,_v=4;function ig(t){return()=>t}function _2(t){t()}function Ov(t,a){return s=>t(a(s))}function og(t,a){return()=>t(a)}function O2(t,a){return s=>t(a,s)}function yf(t){return t!==void 0}function B2(...t){return()=>{t.map(_2)}}function Ol(){}function Yo(t,a){return a(t),t}function I2(t,a){return a(t)}function jt(...t){return t}function rt(t,a){return t(ca,a)}function Pe(t,a){t(qo,a)}function bf(t){t(_l)}function wt(t){return t(_v)}function Re(t,a){return rt(t,O2(a,qo))}function Qn(t,a){const s=t(ca,o=>{s(),a(o)});return s}function cg(t){let a,s;return o=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{o(a)},t)}}function Bv(t,a){return t===a}function bt(t=Bv){let a;return s=>o=>{t(a,o)||(a=o,s(o))}}function De(t){return a=>s=>{t(s)&&a(s)}}function ke(t){return a=>Ov(a,t)}function ir(t){return a=>()=>{a(t)}}function me(t,...a){const s=U2(...a);return((o,c)=>{switch(o){case _l:bf(t);return;case ca:return rt(t,s(c))}})}function or(t,a){return s=>o=>{s(a=t(a,o))}}function Ua(t){return a=>s=>{t>0?t--:a(s)}}function Ar(t){let a=null,s;return o=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,o(a)},t))}}function Fe(...t){const a=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,g=>{const p=s;s|=h,a[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():o=h}}function U2(...t){return a=>t.reduceRight(I2,a)}function H2(t){let a,s;const o=()=>a==null?void 0:a();return function(c,u){switch(c){case ca:return u?s===u?void 0:(o(),s=u,a=rt(t,u),a):(o(),Ol);case _l:o(),s=null;return}}}function ve(t){let a=t;const s=Xe();return((o,c)=>{switch(o){case qo:a=c;break;case ca:{c(a);break}case _v:return a}return s(o,c)})}function nn(t,a){return Yo(ve(a),s=>Re(t,s))}function Xe(){const t=[];return((a,s)=>{switch(a){case qo:t.slice().forEach(o=>{o(s)});return;case _l:t.splice(0,t.length);return;case ca:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return Yo(Xe(),a=>Re(t,a))}function et(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:$2(),singleton:s}}const $2=()=>Symbol();function V2(t){const a=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=o(c.map(g=>s(g)));return d&&a.set(u,h),h};return s(t)}function Ut(...t){const a=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;rt(u,g=>{s[d]=g,o|=h,o===c&&Pe(a,s)})}),function(u,d){switch(u){case _l:{bf(a);return}case ca:return o===c&&d(s),rt(a,d)}}}function ze(t,a=Bv){return me(t,bt(a))}function Zd(...t){return function(a,s){switch(a){case _l:return;case ca:return B2(...t.map(o=>rt(o,s)))}}}const Pt={DEBUG:0,INFO:1,WARN:2,ERROR:3},P2={[Pt.DEBUG]:"debug",[Pt.ERROR]:"error",[Pt.INFO]:"log",[Pt.WARN]:"warn"},F2=()=>typeof globalThis>"u"?window:globalThis,ua=et(()=>{const t=ve(Pt.ERROR);return{log:ve((a,s,o=Pt.INFO)=>{const c=F2().VIRTUOSO_LOG_LEVEL??wt(t);o>=c&&console[P2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function $a(t,a,s){return jf(t,a,s).callbackRef}function jf(t,a,s){const o=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function G2(t,a,s,o,c,u,d,h,g){const p=Te.useCallback(y=>{const v=W2(y.children,a,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?ug("column-gap",getComputedStyle(y).columnGap,c):ug("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,o,h]);return jf(p,s,g)}function W2(t,a,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Pt.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function ug(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Pt.WARN),a==="normal"?0:parseInt(a??"0",10)}function Iv(t,a,s){const o=Te.useRef(null),c=Te.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(a){const S=a.getBoundingClientRect(),k=p.top-S.top;b=S.height-Math.max(0,k),v=k+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,p.top),v=p.top+S.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,a]),{callbackRef:u,ref:d}=jf(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var p;if(a){a.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(a),()=>{a.removeEventListener("scroll",h),y.unobserve(a)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,a,d]),u}const cn=et(()=>{const t=Xe(),a=Xe(),s=ve(0),o=Xe(),c=ve(0),u=Xe(),d=Xe(),h=ve(0),g=ve(0),p=ve(0),y=ve(0),v=Xe(),b=Xe(),S=ve(!1),k=ve(!1),E=ve(!1);return Re(me(t,ke(({scrollTop:C})=>C)),a),Re(me(t,ke(({scrollHeight:C})=>C)),d),Re(a,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Vs={lvl:0};function Uv(t,a){const s=t.length;if(s===0)return[];let{index:o,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=a(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ft(t){return t===Vs}function Ps(t,a){if(!ft(t))return a===t.k?t.v:a<t.k?Ps(t.l,a):Ps(t.r,a)}function Jn(t,a,s="k"){if(ft(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const o=Jn(t.r,a,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,a,s)}function En(t,a,s){return ft(t)?Vv(a,s,1):a===t.k?Vt(t,{k:a,v:s}):a<t.k?dg(Vt(t,{l:En(t.l,a,s)})):dg(Vt(t,{r:En(t.r,a,s)}))}function Rl(){return Vs}function Al(t,a,s){if(ft(t))return[];const o=Jn(t,a)[0];return q2(ef(t,o,s))}function Jd(t,a){if(ft(t))return Vs;const{k:s,l:o,r:c}=t;if(a===s){if(ft(o))return c;if(ft(c))return o;const[u,d]=$v(o);return Mo(Vt(t,{k:u,l:Hv(o),v:d}))}return a<s?Mo(Vt(t,{l:Jd(o,a)})):Mo(Vt(t,{r:Jd(c,a)}))}function Ia(t){return ft(t)?[]:[...Ia(t.l),{k:t.k,v:t.v},...Ia(t.r)]}function ef(t,a,s){if(ft(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>a&&(h=h.concat(ef(c,a,s))),o>=a&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(ef(u,a,s))),h}function Mo(t){const{l:a,lvl:s,r:o}=t;if(o.lvl>=s-1&&a.lvl>=s-1)return t;if(s>o.lvl+1){if(kd(a))return Pv(Vt(t,{lvl:s-1}));if(!ft(a)&&!ft(a.r))return Vt(a.r,{l:Vt(a,{r:a.r.l}),lvl:s,r:Vt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(kd(t))return tf(Vt(t,{lvl:s-1}));if(!ft(o)&&!ft(o.l)){const c=o.l,u=kd(c)?o.lvl-1:o.lvl;return Vt(c,{l:Vt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:tf(Vt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Vt(t,a){return Vv(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function Hv(t){return ft(t.r)?t.l:Mo(Vt(t,{r:Hv(t.r)}))}function kd(t){return ft(t)||t.lvl>t.r.lvl}function $v(t){return ft(t.r)?[t.k,t.v]:$v(t.r)}function Vv(t,a,s,o=Vs,c=Vs){return{k:t,l:o,lvl:s,r:c,v:a}}function dg(t){return tf(Pv(t))}function Pv(t){const{l:a}=t;return!ft(a)&&a.lvl===t.lvl?Vt(a,{r:Vt(t,{l:a.r})}):t}function tf(t){const{lvl:a,r:s}=t;return!ft(s)&&!ft(s.r)&&s.lvl===a&&s.r.lvl===a?Vt(s,{l:Vt(t,{r:s.l}),lvl:a+1}):t}function q2(t){return Uv(t,({k:a,v:s})=>({index:a,value:s}))}function Fv(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Fs(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const Sf=et(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function Gv(t,a,s){return t[Bo(t,a,s)]}function Bo(t,a,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Y2(t,a,s,o){const c=Bo(t,a,o),u=Bo(t,s,o,c);return t.slice(c,u+1)}function ia(t,a){return Math.round(t.getBoundingClientRect()[a])}function Ko(t){return!ft(t.groupOffsetTree)}function kf({index:t},a){return a===t?0:a<t?-1:1}function K2(){return{groupIndices:[],groupOffsetTree:Rl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rl()}}function X2(t,a){let s=ft(t)?0:1/0;for(const o of a){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ft(t)){t=En(t,0,u);continue}const h=Al(t,d-1,c+1);if(h.some(rk(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Jd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));p&&(t=En(t,d,u))}return[t,s]}function Q2(t){return typeof t.groupIndex<"u"}function Z2({offset:t},a){return a===t?0:a<t?-1:1}function Gs(t,a,s){if(a.length===0)return 0;const{index:o,offset:c,size:u}=Gv(a,t,kf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Wv(t,a){if(!Ko(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function qv(t,a,s){if(Q2(t))return a.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Wv(o,a);return c=Math.max(0,c,Math.min(s,c)),c}function J2(t,a,s,o=0){return o>0&&(a=Math.max(a,Gv(t,o,kf).offset)),Uv(Y2(t,a,s,Z2),nk)}function ek(t,[a,s,o,c]){a.length>0&&o("received item sizes",a,Pt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ft(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=X2(d,a);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=nf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,Gs(S,v,c)),Rl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function tk(t){return Ia(t).map(({k:a,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function fg(t,a){let s=0,o=0;for(;s<t;)s+=a[o+1]-a[o]-1,o++;return o-(s===t?0:1)}function nf(t,a,s,o){let c=t,u=0,d=0,h=0,g=0;if(a!==0){g=Bo(c,a-1,kf),h=c[g].offset;const p=Jn(s,a-1);u=p[0],d=p[1],c.length&&c[g].size===Jn(s,a)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of Al(s,a,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function nk(t){return{index:t.index,value:t}}function rk(t){const{endIndex:a,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===a||c.end===1/0)&&c.value===s}const ak={offsetHeight:"height",offsetWidth:"width"},ur=et(([{log:t},{recalcInProgress:a}])=>{const s=Xe(),o=Xe(),c=nn(o,0),u=Xe(),d=Xe(),h=ve(0),g=ve([]),p=ve(void 0),y=ve(void 0),v=ve(void 0),b=ve(void 0),S=ve((w,O)=>ia(w,ak[O])),k=ve(void 0),E=ve(0),C=K2(),N=nn(me(s,Fe(g,t,E),or(ek,C),bt()),C),T=nn(me(g,bt(),or((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Re(me(g,De(w=>w.length>0),Fe(N,E),ke(([w,O,z])=>{const U=w.reduce((H,q,X)=>En(H,q,Gs(q,O.offsetTree,z)||X),Rl());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Re(me(o,Fe(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:w}])),s),Re(p,y);const A=nn(me(p,ke(w=>w===void 0)),!0);Re(me(y,De(w=>w!==void 0&&ft(wt(N).sizeTree)),ke(w=>{const O=wt(v),z=wt(g).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(me(b,De(w=>w!==void 0&&w.length>0&&ft(wt(N).sizeTree)),ke(w=>{const O=[];let z=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==z&&(O.push({endIndex:H-1,size:z,startIndex:U}),z=q,U=H)}return O.push({endIndex:w.length-1,size:z,startIndex:U}),O})),s),Re(me(g,Fe(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,z])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:z})}return U})),s);const B=Nn(me(s,Fe(N),or(({sizes:w},[O,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:C}),ke(w=>w.changed)));rt(me(h,or((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=wt(N);if(w>0)Pe(a,!0),Pe(u,w+fg(w,O));else if(w<0){const z=wt(T);z.length>0&&(w-=fg(-w,z)),Pe(d,w)}}),rt(me(h,Fe(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Pt.ERROR)});const D=Nn(u);Re(me(u,Fe(N),ke(([w,O])=>{const z=O.groupIndices.length>0,U=[],H=O.lastSize;if(z){const q=Ps(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ia(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ia(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Fe(N,E),ke(([w,{offsetTree:O},z])=>{const U=-w;return Gs(U,O,z)})));return Re(me(d,Fe(N,E),ke(([w,O,z])=>{if(O.groupIndices.length>0){if(ft(O.sizeTree))return O;let H=Rl();const q=wt(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ia(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Ps(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...nf(O.offsetTree,0,H,z)}}const U=Ia(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Rl());return{...O,sizeTree:U,...nf(O.offsetTree,0,U,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},jt(ua,Sf),{singleton:!0});function lk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const Yv=et(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),d=Xe(),h=Nn(me(u,ke(lk)));return Re(me(h,ke(g=>g.totalCount)),s),Re(me(h,ke(g=>g.groupIndices)),t),Re(me(Ut(c,a,o),De(([g,p])=>Ko(p)),ke(([g,p,y])=>Jn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),bt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},jt(ur,cn)),da=et(([{log:t}])=>{const a=ve(!1),s=Nn(me(a,De(o=>o),bt()));return rt(a,o=>{o&&wt(t)("props updated",{},Pt.DEBUG)}),{didMount:s,propsReady:a}},jt(ua),{singleton:!0}),sk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Kv(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!sk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const Zs=et(([{gap:t,listRefresh:a,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Xe(),k=Xe(),E=ve(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Pe(g,!1)}return Re(me(S,Fe(s,v,o,E,h,d,b),Fe(t,u,c),ke(([[B,D,F,w,O,z,U,H],q,X,J])=>{const $=Kv(B),{align:L,behavior:_,offset:I}=$,V=w-1,se=qv($,D,V);let M=Gs(se,D.offsetTree,q)+z;L==="end"?(M+=X+Jn(D.sizeTree,se)[1]-F+J,se===V&&(M+=U)):L==="center"?M+=(X+Jn(D.sizeTree,se)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=G=>{A(),G?(H("retrying to scroll to",{location:B},Pt.DEBUG),Pe(S,B)):(Pe(k,!0),H("list did not change, scroll successful",{},Pt.DEBUG))};if(A(),_==="smooth"){let G=!1;T=rt(a,te=>{G=G||te}),C=Qn(y,()=>{Y(G)})}else C=Qn(me(a,ik(150)),Y);return N=setTimeout(()=>{A()},1200),Pe(g,!0),H("scrolling from index to",{behavior:_,index:se,top:M},Pt.DEBUG),{behavior:_,top:M}})),p),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},jt(ur,cn,ua),{singleton:!0});function ik(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return o=>{o&&(a(!0),clearTimeout(s))}}}function wf(t,a){t===0?a():requestAnimationFrame(()=>{wf(t-1,a)})}function Cf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Js=et(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ve(!0),g=ve(0),p=ve(!0);return Re(me(d,Fe(g),De(([y,v])=>v!==0),ir(!1)),h),Re(me(d,Fe(g),De(([y,v])=>v!==0),ir(!1)),p),rt(me(Ut(a,d),Fe(h,s,t,p),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!ft(b)||yf(S))&&!v&&!k),Fe(g)),([,y])=>{Qn(c,()=>{Pe(p,!0)}),wf(4,()=>{Qn(o,()=>{Pe(h,!0)}),Pe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},jt(ur,cn,Zs,da),{singleton:!0});function Xv(t,a){return Math.abs(t-a)<1.01}const Ws="up",Is="down",ok="none",ck={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},uk=0,ei=et(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ve(!1),h=ve(!0),g=Xe(),p=Xe(),y=ve(4),v=ve(uk),b=nn(me(Zd(me(ze(c),Ua(1),ir(!0)),me(ze(c),Ua(1),ir(!1),cg(100))),bt()),!1),S=nn(me(Zd(me(s,ir(!0)),me(s,ir(!1),cg(200))),bt()),!1);Re(me(Ut(ze(c),ze(v)),ke(([T,A])=>T<=A),bt()),h),Re(me(h,Ar(50)),p);const k=Nn(me(Ut(o,ze(u),ze(a),ze(t),ze(y)),or((T,[{scrollHeight:A,scrollTop:B},D,F,w,O])=>{const z=B+D-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":D<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},ck),bt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=nn(me(o,or((T,{scrollHeight:A,scrollTop:B,viewportHeight:D})=>{if(!Xv(T.scrollHeight,A)){const F=A-(B+D)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Re(me(k,ke(T=>T.atBottom)),d),Re(me(d,Ar(50)),g);const C=ve(Is);Re(me(o,ke(({scrollTop:T})=>T),bt(),or((T,A)=>wt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Ws:Is,prevScrollTop:A},{direction:Is,prevScrollTop:0}),ke(T=>T.direction)),C),Re(me(o,Ar(50),ir(ok)),C);const N=ve(0);return Re(me(b,De(T=>!T),ir(0)),N),Re(me(c,Ar(100),Fe(b),De(([T,A])=>A),or(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},jt(cn)),qs="top",Ys="bottom",pg="none";function mg(t,a,s){return typeof t=="number"?s===Ws&&a===qs||s===Is&&a===Ys?t:0:s===Ws?a===qs?t.main:t.reverse:a===Ys?t.main:t.reverse}function hg(t,a){return typeof t=="number"?t:t[a]??0}const Ef=et(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),d=ve(0),h=ve(0),g=ve(0),p=nn(me(Ut(ze(o),ze(c),ze(s),ze(u,Fs),ze(g),ze(d),ze(a),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,D=C+N,F=Math.max(b-B,0);let w=pg;const O=hg(A,qs),z=hg(A,Ys);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+D-O&&(w=Ws),k<y-F+v+z&&(w=Is),w!==pg?[Math.max(B-b-mg(E,qs,w)-O,0),B-F-N+v+mg(E,Ys,w)+z]:null}),De(y=>y!==null),bt(Fs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},jt(cn),{singleton:!0});function dk(t,a,s){if(Ko(a)){const o=Wv(t,a);return[{index:Jn(a.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const wd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Lo(t,a,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=p,k=b-y;return{bottom:y,firstItemIndex:u,items:xg(t,c,u),offsetBottom:k,offsetTop:p,top:S,topItems:xg(a,c,u),topListHeight:a.reduce((E,C)=>C.size+E,0),totalCount:s}}function Qv(t,a,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=Cf(a,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Lo(p,[],h,c,s,o)}function xg(t,a,s){if(t.length===0)return[];if(!Ko(a))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Al(a.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=a.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function gg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Va=et(([{data:t,firstItemIndex:a,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ve([]),C=ve(0),N=Xe(),T=ve(0);Re(u.topItemsIndexes,E);const A=nn(me(Ut(S,k,ze(g,Fs),ze(c),ze(o),ze(p),y,ze(E),ze(a),ze(s),ze(T),t),De(([w,O,,z,,,,,,,,U])=>{const H=U!==void 0&&U.length!==z;return w&&!O&&!H}),ke(([,,[w,O],z,U,H,q,X,J,$,L,_])=>{var Se,Ae;const I=U,{offsetTree:V,sizeTree:se}=I,M=wt(C);if(z===0)return{...wd,totalCount:z};if(w===0&&O===0)return M===0?{...wd,totalCount:z}:Qv(M,H,U,J,$,_||[]);if(ft(se))return M>0?null:Lo(dk(Cf(H,z),I,_),[],z,$,I,J);const Y=[];if(X.length>0){const _e=X[0],ae=X[X.length-1];let he=0;for(const pe of Al(se,_e,ae)){const ge=pe.value,je=Math.max(pe.start,_e),Be=Math.min(pe.end,ae);for(let Oe=je;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:ge}),he+=ge}}if(!q)return Lo([],Y,z,$,I,J);const G=X.length>0?X[X.length-1]+1:0,te=J2(V,w,O,G);if(te.length===0)return null;const fe=z-1,ie=Yo([],_e=>{for(const ae of te){const he=ae.value;let pe=he.offset,ge=ae.start;const je=he.size;if(he.offset<w){ge+=Math.floor((w-he.offset+$)/(je+$));const Oe=ge-ae.start;pe+=Oe*je+Oe*$}ge<G&&(pe+=(G-ge)*je,ge=G);const Be=Math.min(ae.end,fe);for(let Oe=ge;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:je}),pe+=je+$}}),ye=gg(L,qs),de=gg(L,Ys);if(ie.length>0&&(ye>0||de>0)){const _e=ie[0],ae=ie[ie.length-1];if(ye>0&&_e.index>G){const he=Math.min(ye,_e.index-G),pe=[];let ge=_e.offset;for(let je=_e.index-1;je>=_e.index-he;je--){const Be=((Se=Al(se,je,je)[0])==null?void 0:Se.value)??_e.size;ge-=Be+$,pe.unshift({data:_==null?void 0:_[je],index:je,offset:ge,size:Be})}ie.unshift(...pe)}if(de>0&&ae.index<fe){const he=Math.min(de,fe-ae.index);let pe=ae.offset+ae.size+$;for(let ge=ae.index+1;ge<=ae.index+he;ge++){const je=((Ae=Al(se,ge,ge)[0])==null?void 0:Ae.value)??ae.size;ie.push({data:_==null?void 0:_[ge],index:ge,offset:pe,size:je}),pe+=je+$}}}return Lo(ie,Y,z,$,I,J)}),De(w=>w!==null),bt()),wd);Re(me(t,De(yf),ke(w=>w==null?void 0:w.length)),c),Re(me(A,ke(w=>w.topListHeight)),v),Re(v,h),Re(me(A,ke(w=>[w.top,w.bottom])),d),Re(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Fe(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),bt(Fs),ke(([w])=>w))),D=Nn(me(A,Ar(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),bt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,z=w.length-1;for(;w[O].type==="group"&&O<z;)O++;for(;w[z].type==="group"&&z>O;)z--;return{endIndex:w[z].index,startIndex:w[O].index}}),bt(Fv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:D,topItemsIndexes:E,...b}},jt(ur,Yv,Ef,Js,Zs,ei,da,Sf),{singleton:!0}),Zv=et(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),d=nn(me(Ut(s,t,o,a,c),ke(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Re(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},jt(cn,Va),{singleton:!0}),fk=et(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ve(!1),o=nn(me(Ut(s,t,a),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Ar(0),bt()),0);return{alignToBottom:s,paddingTopAddition:o}},jt(cn,Zv),{singleton:!0}),Jv=et(()=>({context:ve(null)})),pk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,ey=et(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Xe();return Re(me(y,Fe(a,g,s,u,c,o,h),Fe(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=pk,done:D,...F}=v,w=qv(v,b,k-1),O=Gs(w,b.offsetTree,A)+E+C,z=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:z,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?D&&Qn(me(d,De(X=>!X),Ua(wt(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),p),{scrollIntoView:y}},jt(ur,cn,Zs,Va,ua),{singleton:!0});function vg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const mk=(t,a)=>typeof t=="function"?vg(t(a)):a&&vg(t),hk=et(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ve(!1),E=Xe();let C=null;function N(D){Pe(d,{align:"end",behavior:D,index:"LAST"})}rt(me(Ut(me(ze(a),Ua(1)),g),Fe(ze(k),u,h,v),ke(([[D,F],w,O,z,U])=>{let H=F&&z,q="auto";return H&&(q=mk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D)}):C=Qn(t,()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D),C=null})});function T(D){const F=Qn(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(wt(y)("scrolling to bottom due to increased size",{},Pt.DEBUG),N("auto"))});setTimeout(F,100)}rt(me(Ut(ze(k),a,p),De(([D,,F])=>D!==!1&&F),or(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Fe(k,a)),([,D])=>{wt(h)&&T(D!==!1)}),rt(E,()=>{T(wt(k)!==!1)}),rt(Ut(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ve(null),B=Xe();return Re(Zd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(a))),B),rt(me(Ut(me(B,Ua(1)),g),Fe(ze(A),h,v,b),ke(([[D,F],w,O,z,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Ar(0)),D=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("scrolling into view",{}),Pe(S,D)}):C=Qn(t,()=>{wt(y)("scrolling into view",{}),Pe(S,D),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},jt(ur,ei,Zs,Js,da,ua,cn,Jv,ey)),xk=et(([{data:t,firstItemIndex:a,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(me(h,Fe(u),De(([,g])=>g!==0),Fe(c,o,a,s,t),ke(([[,g],p,y,v,b,S=[]])=>Qv(g,p,y,v,b,S))),d),{}),jt(ur,Js,Va,da),{singleton:!0}),gk=et(([{didMount:t},{scrollTo:a},{listState:s}])=>{const o=ve(0);return rt(me(t,Fe(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ua(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(a,c)})})}),{initialScrollTop:o}},jt(da,cn,Va),{singleton:!0}),ty=et(([{scrollVelocity:t}])=>{const a=ve(!1),s=Xe(),o=ve(!1);return Re(me(t,Fe(o,a,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),bt()),a),rt(me(Ut(a,t,s),Fe(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},jt(ei),{singleton:!0}),Nf=et(([{scrollContainerState:t,scrollTo:a}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ve(!1),d=ve(void 0);return Re(me(Ut(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Re(me(a,Fe(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},jt(cn)),vk=et(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Xe(),y=ve(void 0),v=ve(null),b=ve(null);return Re(h,v),Re(g,b),rt(me(p,Fe(a,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=tk(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Re(me(y,De(yf),ke(yk)),c),Re(me(u,Fe(y),De(([,S])=>S!==void 0),bt(),ke(([,S])=>S.ranges)),t),{getState:p,restoreStateFrom:y}},jt(ur,cn,Js,da,Nf));function yk(t){return{align:"start",index:0,offset:t.scrollTop}}const bk=et(([{topItemsIndexes:t}])=>{const a=ve(0);return Re(me(a,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:a}},jt(Va));function ny(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const jk=ny(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sk=et(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Fe(d),or(([,N,T,A],[{bottom:B,items:D,offsetBottom:F,totalCount:w},O])=>{const z=B+F;let U=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(U=z-A,U!==0&&(U+=O))),[U,D,w,z]},[0,[],0,0]),De(([N])=>N!==0),Fe(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Ws),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Pt.DEBUG),N))));function C(N){N>0?(Pe(a,{behavior:"auto",top:-N}),Pe(t,0)):(Pe(t,0),Pe(a,{behavior:"auto",top:-N}))}return rt(me(E,Fe(t,u)),([N,T,A])=>{A&&jk()?Pe(t,T-N):C(-N)}),rt(me(Ut(nn(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Ar(1)),C),Re(me(v,ke(N=>({top:-N}))),a),rt(me(p,Fe(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},D])=>{function F(H){return H*(A+D)}if(T.length===0)return F(N);let w=0;const O=Ps(B,0);let z=0,U=0;for(;z<N;){z++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;z+H>N&&(w-=O,H=N-z+1),z+=H,w+=F(H),U++}return w})),N=>{Pe(t,N),requestAnimationFrame(()=>{Pe(a,{top:N}),requestAnimationFrame(()=>{Pe(t,0),Pe(k,!1)})})}),{deviation:t}},jt(cn,ei,Va,ur,ua,Sf)),kk=et(([t,a,s,o,c,u,d,h,g,p,y])=>({...t,...a,...s,...o,...c,...u,...d,...h,...g,...p,...y}),jt(Ef,xk,da,ty,Zv,gk,fk,Nf,ey,ua,Jv)),ry=et(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:D},F,{topItemCount:w},{groupCounts:O},z])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Re(X,z.scrollSeekRangeChanged),Re(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:p,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...T}},jt(ur,Js,cn,vk,hk,Va,Zs,Sk,bk,Yv,kk));function wk(t,a){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(o,d)||(s[d]=a[d]);return s}const yo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function ay(t,a,s){const o=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Te.createContext({});function g(C,N){C.propsReady!==void 0&&Pe(C.propsReady,!1);for(const T of o){const A=C[a.required[T]];Pe(A,N[T])}for(const T of c)if(T in N){const A=C[a.optional[T]];Pe(A,N[T])}C.propsReady!==void 0&&Pe(C.propsReady,!0)}function p(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[a.methods[T]];Pe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=H2(C[a.events[T]]),N),{})}const v=Te.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Te.useState(()=>Yo(V2(t),w=>{g(w,A)})),[D]=Te.useState(og(y,B));yo(()=>{for(const w of d)w in A&&rt(D[w],A[w]);return()=>{Object.values(D).map(bf)}},[A,D,B]),yo(()=>{g(B,A)}),Te.useImperativeHandle(N,ig(p(B)));const F=s;return r.jsx(h.Provider,{value:B,children:s!==void 0?r.jsx(F,{...wk([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Te.useContext(h);return Te.useCallback(T=>{Pe(N[C],T)},[N,C])},S=C=>{const N=Te.useContext(h)[C],T=Te.useCallback(A=>rt(N,A),[N]);return Te.useSyncExternalStore(T,()=>wt(N),()=>wt(N))},k=C=>{const N=Te.useContext(h)[C],[T,A]=Te.useState(og(wt,N));return yo(()=>rt(N,B=>{B!==T&&A(ig(B))}),[N,T]),T},E=parseInt(Te.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Te.useContext(h)[C];yo(()=>rt(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const ly=Te.createContext(void 0),sy=Te.createContext(void 0),Cd="-webkit-sticky",yg="sticky",Tf=ny(()=>{if(typeof document>"u")return yg;const t=document.createElement("div");return t.style.position=Cd,t.style.position===Cd?Cd:yg}),iy=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Ed(t){return"self"in t}function Ck(t){return"body"in t}function oy(t,a,s,o=Ol,c,u){const d=Te.useRef(null),h=Te.useRef(null),g=Te.useRef(null),p=Te.useCallback(b=>{let S,k,E;const C=b.target;if(Ck(C)||Ed(C)){const T=Ed(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Fj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,a(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,a,u]);Te.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Ed(S)?(C=Math.max(ia(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ia(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Xv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&a(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Rf(t){return t}const Ek=et(()=>{const t=ve(h=>`Item ${h}`),a=ve(h=>`Group ${h}`),s=ve({}),o=ve(Rf),c=ve("div"),u=ve(Ol),d=(h,g=null)=>nn(me(s,ke(p=>p[h]),bt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),Nk=et(([t,a])=>({...t,...a}),jt(ry,Ek)),Tk=({height:t})=>r.jsx("div",{style:{height:t}}),Rk={overflowAnchor:"none",position:Tf(),zIndex:1},cy={overflowAnchor:"none"},Ak={...cy,display:"inline-block",height:"100%"},bg=Te.memo(function({showTopList:t=!1}){const a=Ue("listState"),s=Pn("sizeRanges"),o=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=Ue("itemContent"),p=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),k=Pn("gap"),E=Ue("horizontalDirection"),{callbackRef:C}=G2(s,b,v,t?Ol:h,S,k,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Af("deviation",J=>{N!==J&&T(J)});const A=Ue("EmptyPlaceholder"),B=Ue("ScrollSeekPlaceholder")??Tk,D=Ue("ListComponent"),F=Ue("ItemComponent"),w=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),U=Ue("groupIndices").length>0,H=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...tn(A,p)}):r.jsx(D,{...tn(D,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?a.topItems:a.items).map(J=>{const $=J.originalIndex,L=O($+a.firstItemIndex,J.data,p);return z?m.createElement(B,{...tn(B,p),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?m.createElement(w,{...tn(w,p),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:Rk},y(J.index,p)):m.createElement(F,{...tn(F,p),...Dk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Ak:cy},U?g(J.index,J.groupIndex,J.data,p):g(J.index,J.data,p))})})}),Mk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Lk={outline:"none",overflowX:"auto",position:"relative"},Xo=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),zk={position:Tf(),top:0,width:"100%",zIndex:1};function tn(t,a){if(typeof t!="string")return{context:a}}function Dk(t,a){return{item:typeof t=="string"?void 0:a}}const _k=Te.memo(function(){const t=Ue("HeaderComponent"),a=Pn("headerHeight"),s=Ue("HeaderFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),Ok=Te.memo(function(){const t=Ue("FooterComponent"),a=Pn("footerHeight"),s=Ue("HeaderFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null});function uy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=a("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=oy(h,p,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),r.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Lk:Mk,...c},tabIndex:0,...d,...tn(g,u),children:o})})}function dy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=a("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Te.useRef(null),k=a("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=oy(h,p,g,k,b);return iy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...tn(g,u),children:o})})}const Bk=({children:t})=>{const a=Te.useContext(ly),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>Ov(s,g=>ia(g,u?"width":"height")),[s,u]),h=$a(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{a&&(s(a.viewportHeight),o(a.itemHeight))},[a,s,o]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:Xo(c),children:t})},Ik=({children:t})=>{const a=Te.useContext(ly),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=Ue("customScrollParent"),u=Iv(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{a&&(o(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,o]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:Xo(d),children:t})},Uk=({children:t})=>{const a=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),o={...zk,marginTop:`${s}px`},c=Ue("context");return r.jsx(a,{style:o,...tn(a,c),children:t})},Hk=Te.memo(function(t){const a=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,o=Ue("customScrollParent"),c=Ue("context");return r.jsxs(o||a?Pk:Vk,{...t,context:c,children:[s&&r.jsx(Uk,{children:r.jsx(bg,{showTopList:!0})}),r.jsxs(o||a?Ik:Bk,{children:[r.jsx(_k,{}),r.jsx(bg,{}),r.jsx(Ok,{})]})]})}),{Component:$k,useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}=ay(Nk,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Hk),Vk=uy({useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}),Pk=dy({useEmitter:Af,useEmitterValue:Ue,usePublisher:Pn}),Fk=$k,Gk=et(()=>{const t=ve(p=>r.jsxs("td",{children:["Item $",p]})),a=ve(null),s=ve(p=>r.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ve(null),c=ve(null),u=ve({}),d=ve(Rf),h=ve(Ol),g=(p,y=null)=>nn(me(u,ke(v=>v[p]),bt()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});jt(ry,Gk);Tf();const jg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Wk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Sg,floor:Io,max:Us,min:Nd,round:kg}=Math;function wg(t,a,s){return Array.from({length:a-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function qk(t){return{...Wk,items:t}}function bo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Yk(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Kk=et(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},D])=>{const F=ve(0),w=ve(0),O=ve(jg),z=ve({height:0,width:0}),U=ve({height:0,width:0}),H=Xe(),q=Xe(),X=ve(0),J=ve(null),$=ve({column:0,row:0}),L=Xe(),_=Xe(),I=ve(!1),V=ve(0),se=ve(!0),M=ve(!1),Y=ve(!1);rt(me(k,Fe(V),De(([de,Se])=>Se!==0)),()=>{Pe(se,!1)}),rt(me(Ut(k,se,U,z,V,M),De(([de,Se,Ae,_e,,ae])=>de&&!Se&&Ae.height!==0&&_e.height!==0&&!ae)),([,,,,de])=>{Pe(M,!0),wf(1,()=>{Pe(H,de)}),Qn(me(p),()=>{Pe(a,[0,0]),Pe(se,!0)})}),Re(me(_,De(de=>de!=null&&de.scrollTop>0),ir(0)),w),rt(me(k,Fe(_),De(([,de])=>de!=null)),([,de])=>{de&&(Pe(z,de.viewport),Pe(U,de.item),Pe($,de.gap),de.scrollTop>0&&(Pe(I,!0),Qn(me(p,Ua(1)),Se=>{Pe(I,!1)}),Pe(g,{top:de.scrollTop})))}),Re(me(z,ke(({height:de})=>de)),v),Re(me(Ut(ze(z,bo),ze(U,bo),ze($,(de,Se)=>de!==void 0&&de.column===Se.column&&de.row===Se.row),ze(p)),ke(([de,Se,Ae,_e])=>({gap:Ae,item:Se,scrollTop:_e,viewport:de}))),L),Re(me(Ut(ze(F),o,ze($,Yk),ze(U,bo),ze(z,bo),ze(J),ze(w),ze(I),ze(se),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[Se,Ae],_e,ae,he,pe,ge,,je,Be])=>{const{column:Oe,row:at}=_e,{height:Nt,width:ht}=ae,{width:Dt}=he;if(ge===0&&(de===0||Dt===0))return jg;if(ht===0){const Gt=Cf(Be,de),rn=Gt+Math.max(ge-1,0);return qk(wg(Gt,rn,pe))}const Tt=fy(Dt,ht,Oe);let Qe,tt;je?Se===0&&Ae===0&&ge>0?(Qe=0,tt=ge-1):(Qe=Tt*Io((Se+at)/(Nt+at)),tt=Tt*Sg((Ae+at)/(Nt+at))-1,tt=Nd(de-1,Us(tt,Tt-1)),Qe=Nd(tt,Us(0,Qe))):(Qe=0,tt=-1);const be=wg(Qe,tt,pe),{bottom:pt,top:Ct}=Cg(he,_e,ae,be),Yt=Sg(de/Tt),un=Yt*Nt+(Yt-1)*at-pt;return{bottom:pt,itemHeight:Nt,items:be,itemWidth:ht,offsetBottom:un,offsetTop:Ct,top:Ct}})),O),Re(me(J,De(de=>de!==null),ke(de=>de.length)),F),Re(me(Ut(z,U,O,$),De(([de,Se,{items:Ae}])=>Ae.length>0&&Se.height!==0&&de.height!==0),ke(([de,Se,{items:Ae},_e])=>{const{bottom:ae,top:he}=Cg(de,_e,Se,Ae);return[he,ae]}),bt(Fs)),a);const G=ve(!1);Re(me(p,Fe(G),ke(([de,Se])=>Se||de!==0)),G);const te=Nn(me(Ut(O,F),De(([{items:de}])=>de.length>0),Fe(G),De(([[de,Se],Ae])=>{const _e=de.items[de.items.length-1].index===Se-1;return(Ae||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===Se)&&_e}),ke(([[,de]])=>de-1),bt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ir(0),bt())),ie=Nn(me(ze(O),Fe(I),De(([{items:de},Se])=>de.length>0&&!Se),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),bt(Fv),Ar(0)));Re(ie,S.scrollSeekRangeChanged),Re(me(H,Fe(z,U,F,$),ke(([de,Se,Ae,_e,ae])=>{const he=Kv(de),{align:pe,behavior:ge,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=Us(0,Be,Nd(_e-1,Be));let Oe=rf(Se,ae,Ae,Be);return pe==="end"?Oe=kg(Oe-Se.height+Ae.height):pe==="center"&&(Oe=kg(Oe-Se.height/2+Ae.height/2)),je!==void 0&&je!==0&&(Oe+=je),{behavior:ge,top:Oe}})),g);const ye=nn(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Re(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ye,...b,endReached:te,propsReady:E,rangeChanged:ie,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...D}},jt(Ef,cn,ei,ty,da,Nf,ua));function fy(t,a,s){return Us(1,Io((t+s)/(Io(a)+s)))}function Cg(t,a,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=rf(t,a,s,o[0].index);return{bottom:rf(t,a,s,o[o.length-1].index)+c,top:u}}function rf(t,a,s,o){const c=fy(t.width,s.width,a.column),u=Io(o/c),d=u*s.height+Us(0,u-1)*a.row;return d>0?d+a.row:d}const Xk=et(()=>{const t=ve(v=>`Item ${v}`),a=ve({}),s=ve(null),o=ve("virtuoso-grid-item"),c=ve("virtuoso-grid-list"),u=ve(Rf),d=ve("div"),h=ve(Ol),g=(v,b=null)=>nn(me(a,ke(S=>S[v]),bt()),b),p=ve(!1),y=ve(!1);return Re(ze(y),p),{components:a,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Qk=et(([t,a])=>({...t,...a}),jt(Kk,Xk)),Zk=Te.memo(function(){const t=kt("gridState"),a=kt("listClassName"),s=kt("itemClassName"),o=kt("itemContent"),c=kt("computeItemKey"),u=kt("isSeeking"),d=Fn("scrollHeight"),h=kt("ItemComponent"),g=kt("ListComponent"),p=kt("ScrollSeekPlaceholder"),y=kt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=kt("log"),k=kt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=$a(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:D}=A.getBoundingClientRect();v({height:B,width:D})}b({column:Eg("column-gap",getComputedStyle(N).columnGap,S),row:Eg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return iy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:r.jsx(g,{className:a,ref:C,...tn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?r.jsx(p,{...tn(p,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(h,{...tn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),Jk=Te.memo(function(){const t=kt("HeaderComponent"),a=Fn("headerHeight"),s=kt("headerFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=kt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),ew=Te.memo(function(){const t=kt("FooterComponent"),a=Fn("footerHeight"),s=kt("headerFooterTag"),o=$a(Te.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=kt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...tn(t,c)})}):null}),tw=({children:t})=>{const a=Te.useContext(sy),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=$a(Te.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Te.useEffect(()=>{a&&(o({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,o,s]),r.jsx("div",{ref:c,style:Xo(!1),children:t})},nw=({children:t})=>{const a=Te.useContext(sy),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=kt("customScrollParent"),u=Iv(s,c,!1);return Te.useEffect(()=>{a&&(o({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,o]),r.jsx("div",{ref:u,style:Xo(!1),children:t})},rw=Te.memo(function({...t}){const a=kt("useWindowScroll"),s=kt("customScrollParent"),o=s||a?lw:aw,c=s||a?nw:tw,u=kt("context");return r.jsx(o,{...t,...tn(o,u),children:r.jsxs(c,{children:[r.jsx(Jk,{}),r.jsx(Zk,{}),r.jsx(ew,{})]})})}),{useEmitter:py,useEmitterValue:kt,usePublisher:Fn}=ay(Qk,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},rw),aw=uy({useEmitter:py,useEmitterValue:kt,usePublisher:Fn}),lw=dy({useEmitter:py,useEmitterValue:kt,usePublisher:Fn});function Eg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Pt.WARN),a==="normal"?0:parseInt(a??"0",10)}const sw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},my={source:"Own",installed:"Installed"};function iw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function ow(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Ng({origin:t,count:a,filteredCount:s,updateCount:o,children:c}){const u=sw[t],[d,h]=m.useState(()=>iw(u)),g=m.useCallback(()=>{h(b=>{const S=!b;return ow(u,S),S})},[u]),p=my[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(uw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),o!=null&&o>0&&r.jsx(cw,{origin:t,updateCount:o})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function cw({origin:t,updateCount:a}){const[s,o]=m.useState(!1),c=my[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function uw({collapsed:t}){return r.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Mf(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function dw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>a(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(a(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function fw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function pw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function mw({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(Ev)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ti(t){const{version:a,showPrefix:s=!0,size:o="md"}=t;if(!a||typeof a!="string"||a.trim()==="")return null;const c=s&&!a.startsWith("v")?`v${a}`:a,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":a,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function hw({skill:t,isSelected:a,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&r.jsx(ti,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(fw,{target:t.symlinkTarget??null}),r.jsx(pw,{skill:t}),r.jsx(mw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Uo=m.memo(hw);function xw({plugin:t,skills:a,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...a].sort((d,h)=>d.skill.localeCompare(h.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Uo,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function gw(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function Tg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>gw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>r.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const zo=new Map,Ba=new Map,_s=new Map;function Tn(t){zo.delete(t),Ba.delete(t);const a=_s.get(t);if(a)for(const s of a)s()}function ni(t,a,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>Tn(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return _s.has(t)||_s.set(t,new Set),_s.get(t).add(b),()=>{var S;(S=_s.get(t))==null||S.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=zo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Ba.has(t)){const C=Ba.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=a().then(C=>{zo.set(t,{data:C,fetchedAt:Date.now()}),Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Ba.set(t,k)},[t,a,o,c]);const p=zo.get(t),y=c&&!p&&Ba.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}function vw({pluginName:t,enabled:a,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),Dv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return r.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Td,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Td,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Td,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Td({onClick:t,disabled:a,busy:s,label:o,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Rg({name:t,count:a,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[p&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(yw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function yw({label:t,title:a,icon:s,onClick:o,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function bw(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function jw(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function Sw(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function kw(t,a){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||o!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function af(t,a={}){const{enabled:s=!0,target:o}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(jw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=Sw(p.target);for(const v of c.current){if(!kw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const ww=200;function Cw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Ew(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Mf(g,a)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Nw(t,a){const s=[],o=[],c=[];for(const d of t){const h=Cw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Mf(v,a)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function Tw(t,a){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Mf(y,a)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Rw({skills:t,selectedKey:a,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(G=>G.scope!==void 0&&G.scope!==null),k=g??"claude-cli",[E,C]=m.useState(""),N=m.useDeferredValue(E),T=m.useMemo(()=>Nw(t,N),[t,N]),A=m.useMemo(()=>Ew(t,N),[t,N]),B=k==="claude-code",{plugins:D}=D2(),F=B?{plugins:D??[]}:void 0,w=m.useMemo(()=>{const G=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=G.get(te.name);G.set(te.name,!!fe||!!te.enabled)}return G},[F==null?void 0:F.plugins]),[O,z]=m.useState(()=>lf(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=m.useState(()=>lf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=m.useCallback(G=>{z(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(G))}catch{}},[k]),X=m.useCallback(G=>{H(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(G))}catch{}},[k]),{own:J,installed:$}=m.useMemo(()=>Tw(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=ww,I=m.useMemo(()=>{const G=te=>{const fe=[];for(const[,ie]of te){const ye=[...ie].sort((de,Se)=>de.skill.localeCompare(Se.skill));fe.push(...ye)}return fe};return S?[...G(T.own.byPlugin),...G(T.installed.byPlugin),...G(T.global.byPlugin)]:[...G(J.byPlugin),...G($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=m.useMemo(()=>a?I.findIndex(G=>G.plugin===a.plugin&&G.skill===a.skill):-1,[I,a]),se=m.useCallback(G=>{if(I.length===0)return;const te=V<0?G>0?0:I.length-1:Math.min(Math.max(V+G,0),I.length-1);s(I[te])},[I,V,s]),M=m.useMemo(()=>{if(!v)return null;const[G,te]=v.split("/");if(!G||!te)return null;const fe=t.find(de=>de.plugin===G&&de.skill===te);if(!fe)return{plugin:G,skill:te,bucket:null,pluginName:null};const ie=fe.source==="plugin"?"plugin":"project",ye=ie==="plugin"?fe.pluginName??G:null;return{plugin:G,skill:te,bucket:ie,pluginName:ye}},[v,t]),Y=m.useRef(null);return m.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const G=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${G}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>se(1)},{key:"k",handler:()=>se(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(dw,{value:E,onChange:C}),o&&r.jsx(Dw,{}),!o&&c&&r.jsx(_w,{error:c,onRetry:u}),!o&&!c&&S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Rg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&r.jsxs(r.Fragment,{children:[r.jsx(Ms,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?r.jsx(Mg,{queryActive:!!E,agentId:k}):r.jsx(Ls,{items:A.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Ms,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:A.availablePersonal.filtered===0?r.jsx(Mw,{queryActive:!!E,agentId:k}):r.jsx(Ls,{items:A.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsxs(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?r.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-available-${G}-collapsed`,headerActionSlot:B?r.jsx(vw,{pluginName:G,enabled:w.get(G)??!0}):void 0,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${G}`))]})]}),r.jsx(zw,{}),r.jsx(Rg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&r.jsxs(r.Fragment,{children:[r.jsx(Ms,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ls,{items:A.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsx(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?r.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",r.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([G,te])=>r.jsx(Tg,{pluginName:G,skills:te,persistKey:`vskill-plugin-authoring-${G}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===G,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${G}`))})]})]}),!o&&!c&&!S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ng,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?r.jsx(Ag,{queryActive:!!E}):r.jsx(Ls,{items:J.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Lw,{}),r.jsx(Ng,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?r.jsx(Mg,{queryActive:!!E}):r.jsx(Ls,{items:$.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function lf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ms({label:t,storageKey:a,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>lf(a)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(a,String(S))}catch{}return S})},[a]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function Aw(t){const a=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Ls({items:t,selectedKey:a,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Aw(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Fk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!a&&a.plugin===g.plugin&&a.skill===g.skill;return r.jsx(Uo,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>r.jsx(xw,{plugin:u,skills:d,selectedKey:a,onSelect:s,onContextMenu:o},u))})}function Ag({queryActive:t}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Lf,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Mg({queryActive:t,agentId:a}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install <skill>"})," to add one."]})})}function Mw({queryActive:t,agentId:a}){return t?r.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(Ml,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Lf,{children:"vskill install --global <skill>"})," to add one."]})})}function Ml({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function Lf({children:t}){return r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function Lw(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function zw(){return r.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function Dw(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(bw,{},t))})}function _w({error:t,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:Ow(t)}),r.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),a&&r.jsx("button",{type:"button",onClick:a,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function Ow(t){const a=t.split(`
|
|
66
66
|
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const hy=240,xy=480,gy="vskill-sidebar-width",Hs=320;function zf(t){return Number.isFinite(t)?Math.round(Math.max(hy,Math.min(xy,t))):Hs}function Bw(){try{const t=localStorage.getItem(gy);if(!t)return Hs;const a=Number(t);return Number.isFinite(a)?zf(a):Hs}catch{return Hs}}function Iw(t){try{localStorage.setItem(gy,String(zf(t)))}catch{}}function Uw({initialWidth:t,onChange:a}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),o=m.useRef(t);return m.useEffect(()=>{o.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=zf(s.current.startWidth+h);o.current=g,a(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,Iw(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":hy,"aria-valuemax":xy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Hw({connected:t,hint:a,onRetry:s}){return t?null:r.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),r.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&r.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),r.jsx("div",{style:{flex:1}}),s&&r.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function vy(t,a){if(t!==401||typeof window>"u"||!a||typeof a!="object")return;const s=a;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function yy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Rd(){const[t,a]=m.useState([]),[s,o]=m.useState(!1),[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useCallback(async(v,b)=>{a([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=yy(b),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw vy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
|
|
67
67
|
`);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};A==="done"?(u(!0),a(U=>[...U,z])):a(U=>[...U,z])}catch{}A=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=m.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:p,stop:y}}function $w(t){const a=m.useRef(t);a.current=t;const[s,o]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(p,y,v)=>{var S;(S=c.current.get(p))==null||S.abort();const b=new AbortController;c.current.set(p,b),o(k=>{const E=new Set(k);return E.add(p),E});try{const k=yy(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw vy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
|
|
68
68
|
`);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};a.current.onEvent(p,z)}catch{}A=""}}a.current.onDone(p)}catch(k){k.name!=="AbortError"&&a.current.onError(p,k.message)}finally{o(k=>{const E=new Set(k);return E.delete(p),E}),c.current.delete(p)}},[]),d=m.useCallback(p=>{var y;(y=c.current.get(p))==null||y.abort()},[]),h=m.useCallback(()=>{for(const p of c.current.values())p.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const Vw={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function Pw(t,a){var s,o;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:a.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:a.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function Fw(t){if(t==="unit"||t==="integration")return t}function Gw(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}a.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const by=m.createContext(null);function An(){const t=m.useContext(by);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Ww({plugin:t,skill:a,origin:s,children:o}){const c=s==="installed",[u,d]=m.useReducer(Pw,{...Vw,plugin:t,skill:a}),h=m.useRef(new Set),g=m.useRef(new Set),p=m.useRef(new Map),y=m.useCallback((ae,he)=>{let pe=p.current.get(ae);pe||(pe={assertions:[]},p.current.set(ae,pe)),Gw(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:ae,result:{...pe,assertions:[...pe.assertions]}})},[]),v=m.useCallback(ae=>{if(g.current.has(ae))return;g.current.add(ae);const he=p.current.get(ae)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:ae,result:{...he,assertions:[...he.assertions]}}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=m.useCallback((ae,he)=>{g.current.has(ae)||(g.current.add(ae),d({type:"CASE_RUN_ERROR",caseId:ae,error:he}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:k,stopAll:E}=$w({onEvent:y,onDone:v,onError:b});m.useEffect(()=>()=>{E()},[E]);const C=m.useCallback(async()=>{try{const ae=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!ae.ok){if(ae.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await ae.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,a]);m.useEffect(()=>{let ae=!1;async function he(){try{const[pe,ge,je]=await Promise.allSettled([Ce.getSkillDetail(t,a),Ce.getEvals(t,a),Ce.getLatestBenchmark(t,a)]);if(ae)return;let Be=null,Oe=null;if(ge.status==="fulfilled")Be=ge.value;else{const at=ge.reason;Oe=(at==null?void 0:at.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:je.status==="fulfilled"?je.value:null})}catch(pe){ae||d({type:"SET_ERROR",error:pe.message})}}return he(),C(),()=>{ae=!0}},[t,a,C]);const N=m.useCallback(async()=>{if(!c)try{await Ce.applyImprovement(t,a,u.skillContent),d({type:"CONTENT_SAVED"})}catch(ae){d({type:"SET_ERROR",error:ae.message})}},[c,t,a,u.skillContent]),T=m.useCallback(async ae=>{if(!c)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,a]),A=m.useCallback((ae,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(ae);if((pe==null?void 0:pe.status)!=="running")if(p.current.delete(ae),g.current.delete(ae),d({type:"CASE_RUN_START",caseId:ae,mode:he}),he==="comparison"){const ge=`/api/skills/${t}/${a}/compare`;S(ae,ge,{eval_ids:[ae]})}else{const ge=`/api/skills/${t}/${a}/benchmark/case/${ae}`;S(ae,ge,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),B=m.useCallback((ae="benchmark")=>{var ge;if(c)return;const he=((ge=u.evals)==null?void 0:ge.evals)??[];if(he.length===0)return;const pe=he.map(je=>je.id);for(const je of pe)p.current.delete(je),g.current.delete(je);d({type:"BULK_RUN_START",caseIds:pe,mode:ae}),h.current=new Set(pe);for(const je of pe)if(ae==="comparison")S(je,`/api/skills/${t}/${a}/compare`,{eval_ids:[je]});else{const Be=`/api/skills/${t}/${a}/benchmark/case/${je}`;S(je,Be,ae==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),D=m.useCallback(ae=>{k(ae),d({type:"CASE_RUN_CANCEL",caseId:ae}),h.current.delete(ae),g.current.add(ae)},[k]),F=m.useCallback(()=>{E(),d({type:"CANCEL_ALL"}),h.current.clear()},[E]),w=m.useCallback(async(ae,he)=>{d({type:"OPEN_IMPROVE",evalId:ae})},[]),O=m.useCallback(async(ae,he)=>{try{await Ce.applyImprovement(t,a,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),A(ae,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,a,A]),z=Rd(),U=m.useRef(null),H=m.useRef(0);m.useEffect(()=>{const ae=z.events;for(let he=H.current;he<ae.length;he++){const pe=ae[he],ge=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge.improved,Be=ge.reasoning,Oe=ge.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Be,evalChanges:Oe})}if(pe.event==="error"){const je=ge;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}H.current=ae.length},[z.events]),m.useEffect(()=>{z.error&&d({type:"AI_EDIT_ERROR",message:z.error})},[z.error]),m.useEffect(()=>()=>{z.stop()},[z.stop]);const q=m.useCallback(async(ae,he,pe)=>{c||(H.current=0,d({type:"AI_EDIT_LOADING"}),U.current=z.stop,z.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:ae,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:he,model:pe}))},[c,t,a,u.skillContent,u.evals,z]),X=m.useCallback(()=>{z.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[z]),J=m.useCallback(async()=>{const ae=u.aiEditResult;if(ae!=null&&ae.improved)try{if(await Ce.applyImprovement(t,a,ae.improved),d({type:"SET_CONTENT",content:ae.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Qs(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),ge=u.evals??{skill_name:a,evals:[]},je=pe(ge,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ce.saveEvals(t,a,je);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:je}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:he.message})}},[t,a,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),$=m.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),L=m.useCallback(ae=>{d({type:"TOGGLE_EVAL_CHANGE",index:ae})},[]),_=m.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=m.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=m.useCallback(async()=>{const ae=u.aiEditEvalsRetry;if(ae)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,a,u.aiEditEvalsRetry]),se=m.useCallback(async()=>{try{const ae=await Ce.getSkillDetail(t,a);d({type:"SET_CONTENT",content:ae.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:M}=Ha(),Y=Rd(),G=m.useRef(0);m.useEffect(()=>{const ae=Y.events;for(let he=G.current;he<ae.length;he++){const pe=ae[he],ge=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge;Ce.saveEvals(t,a,je).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}pe.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:ge})}G.current=ae.length},[Y.events,t,a]),m.useEffect(()=>{Y.error&&d({type:"SET_ERROR",error:Y.error})},[Y.error]),m.useEffect(()=>()=>{Y.stop()},[Y.stop]);const te=m.useCallback(async ae=>{if(c)return;G.current=0,d({type:"GENERATE_EVALS_START"});const he={};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=Fw(ae==null?void 0:ae.testType);pe&&(he.testType=pe),Y.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,a,Y,M]),fe=Rd(),ie=m.useRef(0);m.useEffect(()=>()=>{fe.stop()},[fe.stop]),m.useEffect(()=>{const ae=fe.events;for(let he=ie.current;he<ae.length;he++){const pe=ae[he];if(pe.event==="classifying"){const ge=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:ge.index,total:ge.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const ge=pe.data;if(ge.error)d({type:"ACTIVATION_ERROR",error:ge.error});else{d({type:"ACTIVATION_DONE",summary:ge});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(M==null?void 0:M.model)||"unknown",provider:(M==null?void 0:M.provider)||"unknown",promptCount:ge.total,summary:{precision:ge.precision,recall:ge.recall,reliability:ge.reliability,tp:ge.tp,tn:ge.tn,fp:ge.fp,fn:ge.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...u.activationHistory??[]]})}}}ie.current=ae.length},[fe.events,M,u.activationHistory]),m.useEffect(()=>{fe.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:fe.error}))},[fe.error]);const ye=m.useRef(null),de=m.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),fe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[fe]),Se=m.useCallback(ae=>{const pe=ae.trim().split(`
|
|
@@ -99,4 +99,4 @@ You are an expert at...
|
|
|
99
99
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
100
100
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
101
101
|
}`})]}),document.body)}function ON({agent:t,focused:a,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function BN({row:t,onFocus:a}){return r.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:a,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),r.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function IN({agent:t}){const a=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return r.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:a,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),r.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&r.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function UN({agent:t,activeAgentId:a,onSwitch:s}){const o=t.id===a,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":$N(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Vd,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Vd,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Vd,{label:ne.scopePicker.statsLastSync,value:t.lastSync?HN(t.lastSync):"—"})]}),r.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function Vd({label:t,value:a}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:a})]})}function Jg(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function HN(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function $N(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function VN(t){const a=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)a.set(o,s);return t.agents.map(s=>{const o=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function PN({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),y=m.useMemo(()=>p?p.health==="ok"?"var(--color-ok, #22c55e)":p.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[p]),v=m.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),b=m.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(p==null?void 0:p.displayName)??"Select agent"}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(p==null?void 0:p.installedCount)??0," · ",(p==null?void 0:p.globalCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(_N,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const Py="vskill-ccode-banner-dismissed",FN=new Set(["claude-cli","claude-code"]);function GN(){try{return sessionStorage.getItem(Py)==="true"}catch{return!1}}function WN(){try{sessionStorage.setItem(Py,"true")}catch{}}function qN({activeAgentId:t}){const[a,s]=m.useState(()=>GN()),o=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{WN(),s(!0)},[]);return!t||!FN.has(t)||a?null:r.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function YN(){const[t,a]=m.useState(null),[s,o]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const h=await Ce.getAgents();a(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Eo="workspace",KN=["skills","agents"];async function XN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function QN(t){const a=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${a.status}`)}return await a.json()}async function ZN(t){const a=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${a.status}`)}return await a.json()}async function JN(t){const a=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${a.status}`)}return await a.json()}function Pd(){for(const t of KN)Tn(t)}function eT(){const{data:t,loading:a,error:s,revalidate:o}=ni(Eo,XN),c=t,u=c==null?void 0:c.projects.find(p=>p.id===c.activeProjectId),d=m.useCallback(async p=>{await QN(p),Tn(Eo),Pd()},[]),h=m.useCallback(async p=>{await ZN(p),Tn(Eo),Pd()},[]),g=m.useCallback(async p=>{await JN(p),Tn(Eo),Pd()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function tT({workspace:t,onSwitch:a,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(""),[v,b]=m.useState(null),[S,k]=m.useState(null),[E,C]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),B=(t==null?void 0:t.projects)??[],D=B.find(z=>z.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function z(U){A.current&&!A.current.contains(U.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function F(){b(null);const z=p.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),y(""),g(!1)}catch(U){const H=U instanceof Error?U.message:String(U);/does not exist/i.test(H)?b(`Path not found on disk: ${z}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function w(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),g(!0)}catch{}else g(!0)}function O(z){if(z.length<=50)return z;const U=z.split("/");return U.length<=4?z:`${U.slice(0,3).join("/")}/…/${U.slice(-2).join("/")}`}return r.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(D==null?void 0:D.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(D==null?void 0:D.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D?D.name:"No project"}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&r.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[B.length===0&&r.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),B.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(z=>{const U=c?c(z.path):!1,H=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return r.jsxs("li",{role:"menuitem","data-stale":U?"true":"false",onMouseEnter:()=>k(z.id),onMouseLeave:()=>k(X=>X===z.id?null:X),onClick:()=>{if(!U){if(H){d(!1);return}C(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:U?"not-allowed":"pointer",background:q&&!U?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:U?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:H?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),H&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),U&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:X=>{X.stopPropagation(),o(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&r.jsxs("button",{type:"button",onClick:()=>void w(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:p,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&F(),z.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),r.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${E.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),r.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function nT(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function rT({open:t,projects:a,onSwitch:s,onClose:o}){const[c,u]=m.useState(""),[d,h]=m.useState(0),g=m.useMemo(()=>nT(a,c),[a,c]);m.useEffect(()=>{t||(u(""),h(0))},[t]),m.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const p=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:p,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>r.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:y.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const ev=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function aT({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=m.useState("destination"),[g,p]=m.useState(s),[y,v]=m.useState(""),[b,S]=m.useState(""),[k,E]=m.useState(""),[C,N]=m.useState([]),[T,A]=m.useState(!1),[B,D]=m.useState(null);if(m.useEffect(()=>{t&&(h("destination"),p(s),v(""),S(""),E(""),D(null))},[t,s]),m.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(L=>L.json()).then(L=>{$&&N(L.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),m.useEffect(()=>{if(!t)return;function $(L){L.key==="Escape"&&(L.preventDefault(),a())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,a]),!t)return null;const F=C.length>0,w=o&&F,O=o,z=ev.test(y),U=g==="existing-plugin"?b.length>0:ev.test(b),H=!T&&z&&(g==="standalone"||U),q=lT(c,g,b,y);async function X(){D(null),A(!0);try{const _=new URLSearchParams;_.set("mode",g),_.set("skillName",y),b&&_.set("pluginName",b);const I=await fetch(`/api/authoring/skill-exists?${_.toString()}`),V=await I.json();if(!I.ok){D(V.error??`Check failed: ${I.status}`);return}if(V.exists){D(`Skill '${y}' already exists${V.path?` at ${V.path}`:""}`);return}}catch(_){D(_ instanceof Error?_.message:String(_));return}finally{A(!1)}const $=new URLSearchParams;$.set("mode",g),$.set("skillName",y),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const L=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=L),a()}async function J(){D(null),A(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),L=await $.json();if(!$.ok||!L.ok){D(L.error??`Create failed: ${$.status}`);return}Tn("skills"),u==null||u({mode:g,skillName:y,pluginName:L.pluginName??null,skillMdPath:L.skillMdPath}),a()}catch($){D($ instanceof Error?$.message:String($))}finally{A(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(Fd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>p("standalone")}),r.jsx(Fd,{title:"Add to existing plugin",subtitle:w?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:g==="existing-plugin",onClick:()=>w&&p("existing-plugin")}),r.jsx(Fd,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&p("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&r.jsx(No,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:$=>S($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:To(!b||U)})}),g==="existing-plugin"&&r.jsx(No,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...To(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>r.jsx("option",{value:$.name,children:$.name},$.path))]})}),r.jsx(No,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:To(!y||z)})}),r.jsx(No,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:k,onChange:$=>E($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...To(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map(($,L)=>r.jsx("div",{children:$},L))]}),B&&r.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:B})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[r.jsx("button",{type:"button",onClick:a,style:Gd,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:tv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:Gd,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!H,style:{...Gd,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void J(),disabled:!H,style:{...tv,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function Fd({title:t,subtitle:a,description:s,icon:o,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function No({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function To(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const tv={padding:"8px 16px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:"pointer",fontFamily:"inherit",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",letterSpacing:"0.01em"},Gd={padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontFamily:"inherit"};function lT(t,a,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function Fy(t){return t.trim().toLowerCase()}function sT(t,a){const s=Fy(a);return s?t.filter(o=>o.name.toLowerCase().includes(s)||o.source.toLowerCase().includes(s)):t}function iT(t,a){const s=Fy(a);return s?t.filter(o=>[o.name,o.description??"",o.category??"",o.author??""].join(" ").toLowerCase().includes(s)):t}function oT({open:t,onClose:a,onInstall:s,onUninstall:o,installedNames:c}){const[u,d]=m.useState(null),[h,g]=m.useState([]),[p,y]=m.useState(null),[v,b]=m.useState(null),[S,k]=m.useState(!1),[E,C]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState("");m.useEffect(()=>{p?T(""):B("")},[p]);const D=m.useMemo(()=>sT(h,N),[h,N]),F=m.useMemo(()=>iT((v==null?void 0:v.plugins)??[],A),[v,A]);return m.useEffect(()=>{t&&(k(!0),C(null),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);g(w.marketplaces??[])}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1)))},[t]),m.useEffect(()=>{if(!p){b(null);return}k(!0),C(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(p)}`).then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);b(w)}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1))},[p]),m.useEffect(()=>{if(!t)return;function w(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[p&&r.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:p?(v==null?void 0:v.name)??p:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&r.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!p&&!S&&h.length===0&&!E&&r.jsx(cT,{}),!p&&h.length>0&&r.jsx(nv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!p&&h.length>0&&D.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!p&&D.map(w=>r.jsxs("button",{type:"button",onClick:()=>y(w.name),style:dT,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:w.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.source})]},w.name)),p&&v&&r.jsxs(r.Fragment,{children:[v.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&r.jsx(nv,{value:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&F.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),F.map(w=>{const O=c.has(w.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[w.name,w.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:w.version}),w.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:w.category})]}),w.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:w.description})]}),O&&o?r.jsx("button",{type:"button",disabled:u===w.name,onClick:async()=>{d(w.name);try{await o(w.name)}finally{d(null)}},"aria-label":`Uninstall ${w.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===w.name?"wait":"pointer",opacity:u===w.name?.6:1,fontFamily:"inherit"},children:u===w.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(w.name,p),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:O?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:O?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:O?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:O?"default":"pointer",fontFamily:"inherit",boxShadow:O?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:O?"Installed":"Install"})]})},w.name)})]})]}),!p&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(uT,{onAdded:()=>{Tn("marketplaces"),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>g(w.marketplaces??[]))}})})]})]}):null}function nv({value:t,onChange:a,placeholder:s,ariaLabel:o,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":o,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function cT(){return r.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",r.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[r.jsx("li",{children:r.jsx("code",{children:"anthropics/claude-plugins-official"})}),r.jsx("li",{children:r.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function uT({onAdded:t}){const[a,s]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(null);async function h(){const g=a.trim();if(g){c(!0),d(null);try{const p=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await p.json().catch(()=>({}));if(!p.ok||!y.ok){d(y.error??`Add failed (${p.status})`);return}s(""),t()}catch(p){d(p instanceof Error?p.message:String(p))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!a.trim()?"not-allowed":"pointer",opacity:o||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const dT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Wd=12;function fT({job:t,onDone:a}){const[s,o]=m.useState([]),[c,u]=m.useState("running"),[d,h]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),a({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const E=k.body.getReader(),C=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=C.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const D of B){const F=D.match(/^data:\s*(.*)$/m);if(F)try{const w=JSON.parse(F[1]);w.type==="stdout"&&w.line?(b=[...b,w.line].slice(-Wd),o(b)):w.type==="stderr"&&w.line?(b=[...b,`⚠ ${w.line}`].slice(-Wd),o(b)):w.type==="done"?(S=w.ok?"ok":"failed",u(S),Dv(),Tn("skills"),a({ok:w.ok??!1,code:w.code??null,lines:b})):w.type==="error"&&w.error&&(b=[...b,`✘ ${w.error}`].slice(-Wd),o(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",p=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?r.jsx(pT,{}):p}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
|
|
102
|
-
`)})]})}function pT(){return r.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const mT=3e3,hT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function rv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function xT(){const{toast:t}=_f(),a=m.useRef(new Map),s=m.useCallback(o=>{if(!rv(o.provider))return;const c=Date.now(),u=a.current.get(o.provider)??0;if(c-u<mT)return;a.current.set(o.provider,c);const d=hT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!rv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Gy="vskill.studio.prefs";function Wy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function qy(){const t=Wy();if(!t)return{};try{const a=t.getItem(Gy);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function gT(t,a){const s=Wy();if(s)try{const c={...qy(),[t]:a};s.setItem(Gy,JSON.stringify(c))}catch{}}function vT(t,a){const o=qy()[t];return o===void 0?a:o}const av={open:!1,x:0,y:0,skill:null};function yT(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function _a(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function bT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function jT(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{_a(ne.toasts.permissionDenied,"error");return}_a(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_a(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_a(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_a(ne.toasts.skillDuplicated,"info");return;case"update":_a(ne.toasts.skillUpdated,"info");return;case"uninstall":_a(ne.actions.editPlaceholder,"info");return;case"delete":bT(a);return;default:return}}function ST(t){return t.startsWith("#/create")}function kT(t){return t.startsWith("#/updates")}function Yy(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),a}function wT(){return Yy(ST)}function CT(){return Yy(kT)}const ET=m.lazy(()=>Qs(()=>import("./CommandPalette-DVR-q8QQ.js"),__vite__mapDeps([2,1]))),NT=m.lazy(()=>Qs(()=>import("./CreateSkillPage-CZUWGR8T.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage}))),TT=m.lazy(()=>Qs(()=>Promise.resolve().then(()=>_E),void 0).then(t=>({default:t.UpdatesPanel})));function RT(){return r.jsx(gS,{children:r.jsx(mS,{children:r.jsxs(nN,{children:[r.jsx(AT,{}),r.jsx(gN,{})]})})})}function AT(){var Wn,Et;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=er(),{config:h}=Ha(),{mode:g,resolvedTheme:p,setTheme:y}=zv(),{toast:v}=_f(),[b,S]=m.useState(()=>Bw()),[k]=m.useState(!0),[E,C]=m.useState(!1),[N,T]=m.useState(!1),[A,B]=m.useState(!1),[D,F]=m.useState("overview"),[w,O]=m.useState(av),z=m.useCallback((oe,xe)=>{O(yT(oe,xe))},[]),U=YN(),[H,q]=m.useState(()=>vT("activeAgent",null)),X=m.useCallback(oe=>{q(oe),gT("activeAgent",oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:oe}}))},[]);m.useEffect(()=>{var oe;!H&&((oe=U.response)!=null&&oe.suggested)&&X(U.response.suggested)},[H,(Wn=U.response)==null?void 0:Wn.suggested,X]);const J=m.useMemo(()=>U.response?VN(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=eT(),[se,M]=m.useState(!1),[Y,G]=m.useState(!1),[te,fe]=m.useState("standalone"),ie=m.useCallback((oe="standalone")=>{fe(oe),G(!0)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;ie((Ee==null?void 0:Ee.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",oe),()=>window.removeEventListener("studio:request-create-skill",oe)},[ie]);const[ye,de]=m.useState(!1),[Se,Ae]=m.useState(null);m.useEffect(()=>{function oe(){de(!0)}return window.addEventListener("studio:open-marketplace",oe),()=>window.removeEventListener("studio:open-marketplace",oe)},[]);const _e=m.useMemo(()=>{const oe=new Set;for(const xe of t.skills)xe.source==="plugin"&&xe.pluginName&&oe.add(xe.pluginName);return oe},[t.skills]);af([{key:"p",meta:!0,handler:oe=>{var Ee;const xe=typeof document<"u"?document.activeElement:null;xe&&xe.tagName==="INPUT"||((Ee=oe==null?void 0:oe.preventDefault)==null||Ee.call(oe),M(dn=>!dn))}}],{enabled:!0});const ae=zN(),he=ae.open;m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.provider&&he(Ee.provider)}return window.addEventListener("studio:open-setup-drawer",oe),()=>window.removeEventListener("studio:open-setup-drawer",oe)},[he]);const pe=m.useCallback(()=>{O(av)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.message&&v({message:Ee.message,severity:Ee.severity??"info"})}return window.addEventListener("studio:toast",oe),()=>window.removeEventListener("studio:toast",oe)},[v]),xT();const[ge,je]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Oe(Ee==null?void 0:Ee.provider),je(!0)}return window.addEventListener("studio:open-settings",oe),()=>window.removeEventListener("studio:open-settings",oe)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[at,Nt]=m.useState(null),[ht,Dt]=m.useState(()=>new Set),Tt=m.useRef(!1),Qe=m.useMemo(()=>kN(),[]),tt=m.useCallback(oe=>`${oe.plugin}/${oe.skill}`,[]),be=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.add(tt(oe)),Ee})},[tt]),pt=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.delete(tt(oe)),Ee})},[tt]),Ct=wN({delayMs:1e4,onCommit:oe=>{o(),pt(oe)},onFailure:(oe,xe)=>{pt(oe),v({message:`Couldn't delete ${oe.skill}: ${xe.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{be(oe),Ct.enqueueDelete(oe)}}})}});m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.skill&&Nt(Ee.skill)}return window.addEventListener("studio:request-delete",oe),()=>window.removeEventListener("studio:request-delete",oe)},[]);const Yt=m.useCallback(()=>{const oe=at;if(Nt(null),!oe)return;const xe={plugin:oe.plugin,skill:oe.skill};be(xe),Ct.enqueueDelete(xe);const Ee=Tt.current?"":`Sent to your ${Qe}. Open Trash to restore. `;Tt.current=!0,v({message:`${Ee}Deleted ${oe.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ct.cancelDelete(tt(xe)),pt(xe)}}})},[at,be,pt,Ct,v,Qe,tt]),un=m.useCallback(()=>{Nt(null)},[]),Gt=m.useMemo(()=>t.skills.filter(oe=>!ht.has(tt(oe))),[t.skills,ht,tt]),rn=m.useMemo(()=>t.selectedSkill?t.skills.find(oe=>oe.plugin===t.selectedSkill.plugin&&oe.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=m.useCallback(oe=>{a({plugin:oe.plugin,skill:oe.skill,origin:oe.origin})},[a]),Mt=m.useMemo(()=>{if(!t.selectedSkill)return"";const oe=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${oe})`},[t.selectedSkill]),xt=m.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(oe=>!oe)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);af([{key:"cmd+k",handler:()=>C(oe=>!oe)},{key:"ctrl+k",handler:()=>C(oe=>!oe)},{key:"?",handler:()=>T(oe=>!oe)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(oe=>!oe)},{key:"ctrl+b",handler:()=>B(oe=>!oe)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const gt=wT(),zr=CT()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(TT,{})}):gt?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(NT,{})}):r.jsx(cN,{selectedSkillInfo:rn,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return r.jsxs(r.Fragment,{children:[r.jsx(vS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:r.jsx(Hw,{connected:k}),liveMessage:Mt,topRail:r.jsx(x2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ie("standalone"),projectPickerSlot:$&&$.projects.length>0?r.jsx(tT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0}),sidebar:r.jsx(Rw,{skills:Gt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?r.jsxs(r.Fragment,{children:[r.jsx(PN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:oe=>ae.open(oe)}),r.jsx(qN,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(Uw,{initialWidth:b??Hs,onChange:S}),main:zr,statusBar:r.jsx(N2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Et=h==null?void 0:h.providers)==null?void 0:Et.map(oe=>{const xe=oe.id;return{id:xe,label:oe.label,available:oe.available,kind:xe==="ollama"||xe==="lm-studio"?"start-service":xe==="anthropic"||xe==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(yN,{open:N,onClose:()=>T(!1)}),r.jsx(NN,{open:ae.isOpen,providerKey:ae.providerKey,onClose:ae.close}),r.jsx(jN,{state:w,onClose:pe,onAction:(oe,xe)=>jT(oe,xe)}),E&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(ET,{open:E,onClose:()=>C(!1),commands:xt})}),r.jsx(rT,{open:se,projects:($==null?void 0:$.projects)??[],onSwitch:oe=>{L(oe)},onClose:()=>M(!1)}),r.jsx(aT,{open:Y,onClose:()=>G(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:oe=>{o(),setTimeout(()=>{u(oe.pluginName??"",oe.skillName)},500)}}),r.jsx(oT,{open:ye,onClose:()=>de(!1),installedNames:_e,onInstall:(oe,xe)=>{Ae({plugin:oe,marketplace:xe,ref:`${oe}@${xe}`}),de(!1)},onUninstall:async oe=>{if(window.confirm(`Uninstall ${oe}? This removes the plugin and its skills.`))try{const xe=await fetch(`/api/plugins/${encodeURIComponent(oe)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Ee=await xe.json().catch(()=>({}));if(!xe.ok||!Ee.ok){v({message:Ee.error??`Uninstall failed (${xe.status})`,severity:"error"});return}v({message:`Uninstalled ${oe}.`,severity:"info"}),o()}catch(xe){v({message:xe instanceof Error?xe.message:String(xe),severity:"error"})}}}),r.jsx(Av,{open:ge,onClose:()=>je(!1),initialProvider:Be,onToast:oe=>v({message:oe,severity:"info"})}),r.jsx(fT,{job:Se,onDone:oe=>{oe.ok&&(o(),setTimeout(()=>Ae(null),3e3))}}),r.jsx(SN,{open:at!==null,title:at?`Delete "${at.skill}"?`:"",body:`It will be sent to your ${Qe}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:un})]})}const lv="vskill.migrations.scope-rename.v1",MT={own:"authoring-project",installed:"available-project",global:"available-personal"},LT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function zT(t){if(t.getItem(lv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(LT);if(!c)continue;const[,u,d]=c,h=MT[d];if(!h)continue;const g=t.getItem(o);g!==null&&a.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of a)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(lv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{zT(window.localStorage)}catch{}p0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(Dj,{children:r.jsx(S2,{children:r.jsx(RT,{})})})}));export{Jo as E,wv as L,ri as P,Te as R,AE as S,Ha as a,qy as b,NE as c,Qo as d,vT as g,r as j,m as r,ne as s,df as t,K0 as u,gT as w};
|
|
102
|
+
`)})]})}function pT(){return r.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const mT=3e3,hT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function rv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function xT(){const{toast:t}=_f(),a=m.useRef(new Map),s=m.useCallback(o=>{if(!rv(o.provider))return;const c=Date.now(),u=a.current.get(o.provider)??0;if(c-u<mT)return;a.current.set(o.provider,c);const d=hT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!rv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Gy="vskill.studio.prefs";function Wy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function qy(){const t=Wy();if(!t)return{};try{const a=t.getItem(Gy);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function gT(t,a){const s=Wy();if(s)try{const c={...qy(),[t]:a};s.setItem(Gy,JSON.stringify(c))}catch{}}function vT(t,a){const o=qy()[t];return o===void 0?a:o}const av={open:!1,x:0,y:0,skill:null};function yT(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function _a(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function bT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function jT(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{_a(ne.toasts.permissionDenied,"error");return}_a(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_a(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_a(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_a(ne.toasts.skillDuplicated,"info");return;case"update":_a(ne.toasts.skillUpdated,"info");return;case"uninstall":_a(ne.actions.editPlaceholder,"info");return;case"delete":bT(a);return;default:return}}function ST(t){return t.startsWith("#/create")}function kT(t){return t.startsWith("#/updates")}function Yy(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),a}function wT(){return Yy(ST)}function CT(){return Yy(kT)}const ET=m.lazy(()=>Qs(()=>import("./CommandPalette-C6JeUs8n.js"),__vite__mapDeps([2,1]))),NT=m.lazy(()=>Qs(()=>import("./CreateSkillPage-DbC_X2Lt.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage}))),TT=m.lazy(()=>Qs(()=>Promise.resolve().then(()=>_E),void 0).then(t=>({default:t.UpdatesPanel})));function RT(){return r.jsx(gS,{children:r.jsx(mS,{children:r.jsxs(nN,{children:[r.jsx(AT,{}),r.jsx(gN,{})]})})})}function AT(){var Wn,Et;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=er(),{config:h}=Ha(),{mode:g,resolvedTheme:p,setTheme:y}=zv(),{toast:v}=_f(),[b,S]=m.useState(()=>Bw()),[k]=m.useState(!0),[E,C]=m.useState(!1),[N,T]=m.useState(!1),[A,B]=m.useState(!1),[D,F]=m.useState("overview"),[w,O]=m.useState(av),z=m.useCallback((oe,xe)=>{O(yT(oe,xe))},[]),U=YN(),[H,q]=m.useState(()=>vT("activeAgent",null)),X=m.useCallback(oe=>{q(oe),gT("activeAgent",oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:oe}}))},[]);m.useEffect(()=>{var oe;!H&&((oe=U.response)!=null&&oe.suggested)&&X(U.response.suggested)},[H,(Wn=U.response)==null?void 0:Wn.suggested,X]);const J=m.useMemo(()=>U.response?VN(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=eT(),[se,M]=m.useState(!1),[Y,G]=m.useState(!1),[te,fe]=m.useState("standalone"),ie=m.useCallback((oe="standalone")=>{fe(oe),G(!0)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;ie((Ee==null?void 0:Ee.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",oe),()=>window.removeEventListener("studio:request-create-skill",oe)},[ie]);const[ye,de]=m.useState(!1),[Se,Ae]=m.useState(null);m.useEffect(()=>{function oe(){de(!0)}return window.addEventListener("studio:open-marketplace",oe),()=>window.removeEventListener("studio:open-marketplace",oe)},[]);const _e=m.useMemo(()=>{const oe=new Set;for(const xe of t.skills)xe.source==="plugin"&&xe.pluginName&&oe.add(xe.pluginName);return oe},[t.skills]);af([{key:"p",meta:!0,handler:oe=>{var Ee;const xe=typeof document<"u"?document.activeElement:null;xe&&xe.tagName==="INPUT"||((Ee=oe==null?void 0:oe.preventDefault)==null||Ee.call(oe),M(dn=>!dn))}}],{enabled:!0});const ae=zN(),he=ae.open;m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.provider&&he(Ee.provider)}return window.addEventListener("studio:open-setup-drawer",oe),()=>window.removeEventListener("studio:open-setup-drawer",oe)},[he]);const pe=m.useCallback(()=>{O(av)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.message&&v({message:Ee.message,severity:Ee.severity??"info"})}return window.addEventListener("studio:toast",oe),()=>window.removeEventListener("studio:toast",oe)},[v]),xT();const[ge,je]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Oe(Ee==null?void 0:Ee.provider),je(!0)}return window.addEventListener("studio:open-settings",oe),()=>window.removeEventListener("studio:open-settings",oe)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[at,Nt]=m.useState(null),[ht,Dt]=m.useState(()=>new Set),Tt=m.useRef(!1),Qe=m.useMemo(()=>kN(),[]),tt=m.useCallback(oe=>`${oe.plugin}/${oe.skill}`,[]),be=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.add(tt(oe)),Ee})},[tt]),pt=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.delete(tt(oe)),Ee})},[tt]),Ct=wN({delayMs:1e4,onCommit:oe=>{o(),pt(oe)},onFailure:(oe,xe)=>{pt(oe),v({message:`Couldn't delete ${oe.skill}: ${xe.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{be(oe),Ct.enqueueDelete(oe)}}})}});m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.skill&&Nt(Ee.skill)}return window.addEventListener("studio:request-delete",oe),()=>window.removeEventListener("studio:request-delete",oe)},[]);const Yt=m.useCallback(()=>{const oe=at;if(Nt(null),!oe)return;const xe={plugin:oe.plugin,skill:oe.skill};be(xe),Ct.enqueueDelete(xe);const Ee=Tt.current?"":`Sent to your ${Qe}. Open Trash to restore. `;Tt.current=!0,v({message:`${Ee}Deleted ${oe.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ct.cancelDelete(tt(xe)),pt(xe)}}})},[at,be,pt,Ct,v,Qe,tt]),un=m.useCallback(()=>{Nt(null)},[]),Gt=m.useMemo(()=>t.skills.filter(oe=>!ht.has(tt(oe))),[t.skills,ht,tt]),rn=m.useMemo(()=>t.selectedSkill?t.skills.find(oe=>oe.plugin===t.selectedSkill.plugin&&oe.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=m.useCallback(oe=>{a({plugin:oe.plugin,skill:oe.skill,origin:oe.origin})},[a]),Mt=m.useMemo(()=>{if(!t.selectedSkill)return"";const oe=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${oe})`},[t.selectedSkill]),xt=m.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(oe=>!oe)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);af([{key:"cmd+k",handler:()=>C(oe=>!oe)},{key:"ctrl+k",handler:()=>C(oe=>!oe)},{key:"?",handler:()=>T(oe=>!oe)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(oe=>!oe)},{key:"ctrl+b",handler:()=>B(oe=>!oe)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const gt=wT(),zr=CT()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(TT,{})}):gt?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(NT,{})}):r.jsx(cN,{selectedSkillInfo:rn,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return r.jsxs(r.Fragment,{children:[r.jsx(vS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:r.jsx(Hw,{connected:k}),liveMessage:Mt,topRail:r.jsx(x2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ie("standalone"),projectPickerSlot:$&&$.projects.length>0?r.jsx(tT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0}),sidebar:r.jsx(Rw,{skills:Gt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?r.jsxs(r.Fragment,{children:[r.jsx(PN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:oe=>ae.open(oe)}),r.jsx(qN,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(Uw,{initialWidth:b??Hs,onChange:S}),main:zr,statusBar:r.jsx(N2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Et=h==null?void 0:h.providers)==null?void 0:Et.map(oe=>{const xe=oe.id;return{id:xe,label:oe.label,available:oe.available,kind:xe==="ollama"||xe==="lm-studio"?"start-service":xe==="anthropic"||xe==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(yN,{open:N,onClose:()=>T(!1)}),r.jsx(NN,{open:ae.isOpen,providerKey:ae.providerKey,onClose:ae.close}),r.jsx(jN,{state:w,onClose:pe,onAction:(oe,xe)=>jT(oe,xe)}),E&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(ET,{open:E,onClose:()=>C(!1),commands:xt})}),r.jsx(rT,{open:se,projects:($==null?void 0:$.projects)??[],onSwitch:oe=>{L(oe)},onClose:()=>M(!1)}),r.jsx(aT,{open:Y,onClose:()=>G(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:oe=>{o(),setTimeout(()=>{u(oe.pluginName??"",oe.skillName)},500)}}),r.jsx(oT,{open:ye,onClose:()=>de(!1),installedNames:_e,onInstall:(oe,xe)=>{Ae({plugin:oe,marketplace:xe,ref:`${oe}@${xe}`}),de(!1)},onUninstall:async oe=>{if(window.confirm(`Uninstall ${oe}? This removes the plugin and its skills.`))try{const xe=await fetch(`/api/plugins/${encodeURIComponent(oe)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Ee=await xe.json().catch(()=>({}));if(!xe.ok||!Ee.ok){v({message:Ee.error??`Uninstall failed (${xe.status})`,severity:"error"});return}v({message:`Uninstalled ${oe}.`,severity:"info"}),o()}catch(xe){v({message:xe instanceof Error?xe.message:String(xe),severity:"error"})}}}),r.jsx(Av,{open:ge,onClose:()=>je(!1),initialProvider:Be,onToast:oe=>v({message:oe,severity:"info"})}),r.jsx(fT,{job:Se,onDone:oe=>{oe.ok&&(o(),setTimeout(()=>Ae(null),3e3))}}),r.jsx(SN,{open:at!==null,title:at?`Delete "${at.skill}"?`:"",body:`It will be sent to your ${Qe}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:un})]})}const lv="vskill.migrations.scope-rename.v1",MT={own:"authoring-project",installed:"available-project",global:"available-personal"},LT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function zT(t){if(t.getItem(lv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(LT);if(!c)continue;const[,u,d]=c,h=MT[d];if(!h)continue;const g=t.getItem(o);g!==null&&a.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of a)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(lv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{zT(window.localStorage)}catch{}p0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(Dj,{children:r.jsx(S2,{children:r.jsx(RT,{})})})}));export{Jo as E,wv as L,ri as P,Te as R,AE as S,Ha as a,qy as b,NE as c,Qo as d,vT as g,r as j,m as r,ne as s,df as t,K0 as u,gT as w};
|