cogpit 3.2.0 → 3.3.3
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/dist/cli-runtime.js +773 -289
- package/dist/instance-worker.js +116 -32
- package/dist/web/assets/{CogpitBlock-L2yaEovX.js → CogpitBlock-wGqNs0O4.js} +11 -11
- package/dist/web/assets/{CommandPaletteHost-CwInMsCp.js → CommandPaletteHost-CmYWiZ7B.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-9ySKSxnx.js → ConfigBrowser-CytfmqPO.js} +1 -1
- package/dist/web/assets/CrewPanel-CQZnoKsK.js +6 -0
- package/dist/web/assets/{HighlightedEditor-CHdo4vxt.js → HighlightedEditor-DxjHIbls.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-CRuTSHwt.js → KeyboardShortcutsDialog-C80JLjM1.js} +1 -1
- package/dist/web/assets/MissionHome-D99esiPz.js +2 -0
- package/dist/web/assets/{MobileFileChanges-Ie2O9iTa.js → MobileFileChanges-BVQ33Ask.js} +1 -1
- package/dist/web/assets/{PluginsDialog-84zjmDAJ.js → PluginsDialog-CvkHGbUm.js} +1 -1
- package/dist/web/assets/{PreviewPanel-US9z-vcE.js → PreviewPanel-qO4KW6kE.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-BelqVoKU.js → ProjectFilesPanel-B0x7DBNN.js} +3 -3
- package/dist/web/assets/{ProjectSwitcherModal-BgzjVxf6.js → ProjectSwitcherModal-Do6cTEA1.js} +1 -1
- package/dist/web/assets/{TerminalOutput-D2nGNnds.js → TerminalOutput-tARkD49T.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-DT9ZVWtN.js → ThemeSelectorModal-Dpj_3aEi.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-C1fYtY5J.js → WorkflowsPanel-BHW1lAj9.js} +1 -1
- package/dist/web/assets/{WorktreePanel-CVZp_AIL.js → WorktreePanel-VWeRB-Ta.js} +1 -1
- package/dist/web/assets/{edition-ui-hI8w0jpR.js → edition-ui-uRoClaTy.js} +1 -1
- package/dist/web/assets/index-3o4W_DIX.js +1 -0
- package/dist/web/assets/{index-NgN68ZoJ.js → index-BVrmKCdP.js} +95 -95
- package/dist/web/assets/index-BcQTD79n.css +1 -0
- package/dist/web/assets/{index-D9cBiMbf.js → index-CiUDHF56.js} +4 -4
- package/dist/web/assets/{index-BbEO6jPZ.js → index-Dvo0JdAM.js} +1 -1
- package/dist/web/assets/{session-parser.worker-D3SBmcaP.js → session-parser.worker-DFMK_2Iu.js} +1 -1
- package/dist/web/assets/switch-85f85r6I.js +1 -0
- package/dist/web/assets/{vendor-ui-Dxtv9P3W.js → vendor-ui-Dfr2Rf5Q.js} +194 -184
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/CrewPanel-9nMm5pVI.js +0 -1
- package/dist/web/assets/MissionHome-LPTXsRcd.js +0 -1
- package/dist/web/assets/index-D6mWk1bF.css +0 -1
- package/dist/web/assets/index-IUqOcQ_C.js +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{r as N,c as z,j as a}from"./vendor-react-gGw_S5I_.js";import{U as Ie,bZ as We,b_ as me,aE as Je,J as D,b$ as ot,l as ct,c0 as ut,B as ae,L as dt,M as ft,N as mt,O as pt,Q as ht,C as Pe,b5 as Fe,z as qe,q as Xe,aJ as xt,b6 as gt,c1 as wt,bz as bt,c2 as yt,bw as jt,bV as vt,bW as Nt,bX as _e,bY as Ue,bh as kt,$ as Qe,Z as Ct,c3 as St,c4 as It,c5 as Rt,c6 as $t,bE as Et}from"./index-BVrmKCdP.js";import{S as Mt}from"./switch-85f85r6I.js";import{ar as At,as as Ot,j as Lt,at as Tt,a5 as zt,au as Dt,av as Pt,a7 as Ft,m as qt,aw as _t,ak as Ut,$ as Ht,C as He,ax as Bt,ay as Yt,az as Gt,X as Kt}from"./vendor-ui-Dfr2Rf5Q.js";import{r as Vt,M as Wt}from"./vendor-markdown-BE1gYnO9.js";import"./vendor-shiki-DOn6sF-i.js";async function be(s){if(s.ok)return s;const e=await s.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function ke(s,e){return[...new Map([...s,...e].map(t=>[t.sequence,t])).values()].sort((t,n)=>t.sequence-n.sequence)}function Jt(s){const[e,t]=N.useState(null),[n,r]=N.useState([]),[i,c]=N.useState(null),[l,d]=N.useState(!1),[o,u]=N.useState(!1),[m,g]=N.useState(!1),[b,p]=N.useState(new Set),h=N.useRef(0),f=N.useRef(null),x=N.useRef(!1),w=N.useRef(!1),j=N.useRef(new Set),C=N.useRef(!1),E=N.useRef(null),A=N.useCallback(async v=>{const S=++h.current;try{const y=E.current,M=await(await be(await Ie(`/api/crew-chat/${encodeURIComponent(s)}${y===null?"":`?after=${y}&limit=100`}`))).json();if(!v()||S!==h.current)return;t(I=>I&&JSON.stringify(I.members)===JSON.stringify(M.members)?{...M,members:I.members}:M),r(I=>ke(I,M.messages)),E.current=M.nextCursor,C.current||(C.current=!0,g(M.hasMore)),c(null)}catch(y){v()&&S===h.current&&c(y instanceof Error?y.message:"Couldn't load crew chat.")}},[s]);We(A,2e3);const L=N.useCallback(async v=>{var S;if(x.current)return!1;x.current=!0,d(!0),((S=f.current)==null?void 0:S.text)!==v&&(f.current={text:v,id:crypto.randomUUID()});try{const k=await(await be(await me(`/api/crew-chat/${encodeURIComponent(s)}`,{text:v,commandId:f.current.id}))).json();return h.current++,r(M=>ke(M,[k.message])),f.current=null,c(k.pending.length?"Message saved. Some members are unavailable; delivery will retry.":null),!0}catch(y){return c(y instanceof Error?y.message:"Couldn't send the message."),!1}finally{x.current=!1,d(!1)}},[s]),O=N.useCallback(async(v,S)=>{if(!j.current.has(v)){j.current.add(v),p(y=>new Set(y).add(v));try{await be(await me(`/api/crew-chat/${encodeURIComponent(s)}`,{sessionId:v,listening:S},{method:"PATCH"})),h.current++,t(y=>y&&{...y,members:y.members.map(k=>k.sessionId===v?{...k,listening:S}:k)}),c(null)}catch(y){c(y instanceof Error?y.message:"Couldn't change listening.")}finally{j.current.delete(v),p(y=>{const k=new Set(y);return k.delete(v),k})}}},[s]),T=N.useCallback(async()=>{if(!(!n.length||w.current)){w.current=!0,u(!0);try{const S=await(await be(await Ie(`/api/crew-chat/${encodeURIComponent(s)}?before=${n[0].sequence}`))).json();r(y=>ke(y,S.messages)),g(S.hasMore)}catch(v){c(v instanceof Error?v.message:"Couldn't load older messages.")}finally{w.current=!1,u(!1)}}},[n,s]);return{page:e,messages:n,error:i,posting:l,busyMembers:b,hasOlder:m,loadingOlder:o,post:L,setListening:O,older:T}}const Xt=8e3,Ze={PASS:"success",PASSED:"success",APPROVE:"success",APPROVED:"success",MERGED:"success",READY:"success",GREEN:"success",DONE:"success",FAIL:"destructive",FAILS:"destructive",FAILED:"destructive",ERROR:"destructive",RED:"destructive",CHANGES_REQUESTED:"destructive",BLOCKED:"warning",BLOCKER:"warning",URGENT:"warning",WAITING:"warning","DECISION NEEDED":"warning"},Qt=new RegExp([String.raw`(?<mention>(?<=^|[\s(])@[a-z0-9_-]+\b)`,String.raw`(?<status>\b(?:${Object.keys(Ze).sort((s,e)=>e.length-s.length).join("|")})\b)`,String.raw`(?<sha>\b(?:[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|(?=[0-9a-f]*[a-f])(?=[0-9a-f]*\d)[0-9a-f]{7,40})\b)`,String.raw`(?<path>(?<=^|[\s(“"'=])(?:(?:~|\.{1,2})?\/[\w.@%+=-]+(?:\/[\w.@%+=-]*)*|[\w.-]+\/[\w.@/-]*\.[a-z][a-z0-9]{0,5}\b))`].join("|"),"gi"),Zt=new RegExp("(?<=^|[\\s:;,.])\\((\\d{1,2}|[a-z])\\)(?=\\s)","g"),et=/^\((\d{1,2}|[a-z])\)\s+/;function es(s){return new Map(s.flatMap(e=>[[e.handle.toLowerCase(),e.sessionId],[e.sessionId.toLowerCase(),e.sessionId]]))}function ts({handles:s}){return e=>{tt(e,s)}}function tt(s,e){if(!s.children||s.type==="link"||s.type==="linkReference")return;const t=n=>s.type==="listItem"?Be(ns(n)):ss(n).flatMap(Be);s.children=as(s.children.flatMap(n=>n.type==="paragraph"?t(n):[n])),s.children=s.children.flatMap(n=>n.type==="text"?ls(n.value??"",e):[n]);for(const n of s.children)tt(n,e)}function ss(s){var t;const e=[[]];for(const n of s.children??[]){if(n.type!=="text"||!((t=n.value)!=null&&t.includes(`
|
|
2
|
+
`))){e.at(-1).push(n);continue}n.value.split(`
|
|
3
|
+
`).forEach((r,i)=>{i>0&&e.push([]),r&&e.at(-1).push({type:"text",value:r})})}return e.filter(n=>n.some(r=>r.type!=="text"||r.value.trim())).map(n=>({type:"paragraph",children:Re(n)}))}function ns(s){return{...s,children:(s.children??[]).flatMap(e=>{var t;return e.type==="text"&&((t=e.value)!=null&&t.includes(`
|
|
4
|
+
`))?e.value.split(`
|
|
5
|
+
`).flatMap((n,r)=>[...r>0?[{type:"break"}]:[],...n?[{type:"text",value:n}]:[]]):[e]})}}function st(s,e){return e?s===e:s==="1"||s==="a"}function nt(s){return/\d/.test(s)?String(Number(s)+1):String.fromCharCode(s.charCodeAt(0)+1)}function Be(s){const e=s.children??[],t=[];let n=null;if(e.forEach((l,d)=>{if(l.type==="text")for(const o of l.value.matchAll(Zt)){const u=o[1];st(u,n)&&(t.push({child:d,start:o.index,end:o.index+o[0].length,label:u}),n=nt(u))}}),t.length<2)return[s];const r=[[]];e.forEach((l,d)=>{if(l.type!=="text"){r.at(-1).push(l);return}let o=0;for(const u of t.filter(m=>m.child===d))u.start>o&&r.at(-1).push({type:"text",value:l.value.slice(o,u.start)}),r.push([]),o=u.end;o<l.value.length&&r.at(-1).push({type:"text",value:l.value.slice(o)})});const[i,...c]=r.map(Re);return[...i.length?[{type:"paragraph",children:i}]:[],at(c,t[0].label)]}function as(s){const e=[];for(let t=0;t<s.length;){const n=[];let r=null;for(let i=t;i<s.length;i++){const c=Ye(s[i]);if(!c||!st(c,r))break;n.push(rs(s[i])),r=nt(c)}n.length>=2?(e.push(at(n,Ye(s[t]))),t+=n.length):e.push(s[t++])}return e}function Ye(s){var t,n;const e=s.type==="paragraph"?(t=s.children)==null?void 0:t[0]:void 0;return(e==null?void 0:e.type)==="text"?((n=e.value.match(et))==null?void 0:n[1])??null:null}function rs(s){const[e,...t]=s.children;return Re([{type:"text",value:e.value.replace(et,"")},...t])}function at(s,e){return{type:"list",ordered:!0,start:1,spread:!1,.../[a-z]/.test(e)&&{data:{hProperties:{type:"a"}}},children:s.map(t=>({type:"listItem",spread:!1,checked:null,children:[{type:"paragraph",children:t}]}))}}function Re(s){const e=s.map(r=>({...r})),t=e[0],n=e.at(-1);return(t==null?void 0:t.type)==="text"&&(t.value=t.value.trimStart()),(n==null?void 0:n.type)==="text"&&(n.value=n.value.trimEnd()),e.filter(r=>r.type!=="text"||r.value)}function ls(s,e){const t=[];let n=0;for(const r of s.matchAll(Qt)){const i=r.groups.path?r[0].replace(/[.,;:)]+$/,""):r[0],c=is(r.groups,i,e);c&&(r.index>n&&t.push({type:"text",value:s.slice(n,r.index)}),t.push(c),n=r.index+i.length)}return n<s.length&&t.push({type:"text",value:s.slice(n)}),t}function is(s,e,t){if(s.mention){const n=t.get(e.slice(1).toLowerCase());return Ce(e,"mention",n?{dataSessionId:n}:{})}return s.status?e===e.toUpperCase()?Ce(e,"status",{dataTone:Ze[e]}):null:s.sha?e===e.toLowerCase()?Ce(e,"sha"):null:e.length>1?{type:"inlineCode",value:e}:null}function Ce(s,e,t={}){return{type:"text",value:s,data:{hName:"span",hProperties:{dataCrewToken:e,...t}}}}function os(s,e,t){const n=s.match(/^(?:[ \t]*@[a-z0-9_-]+[,:]?)+(?:[ \t]+|[ \t]*\n)/i);if(!n||[...n[0].matchAll(/@([a-z0-9_-]+)/gi)].map(c=>t.get(c[1].toLowerCase())).some(c=>!c||!e.includes(c)))return s;const i=s.slice(n[0].length);return i.trim()?i:s}const ye=[255,330,185,290,210,350,232,310];function rt(s){const e=`oklch(0.64 0.14 ${s})`;return{color:`color-mix(in oklch, ${e} 78%, var(--foreground))`,backgroundColor:`color-mix(in oklch, ${e} 16%, transparent)`}}function cs(s,e){return new Map(s.filter(t=>t.sessionId!==e).map((t,n)=>[t.sessionId,rt(ye[n%ye.length])]))}function lt(s,e){const t=e.get(s);if(t)return t;let n=2166136261;for(let r=0;r<s.length;r++)n=Math.imul(n^s.charCodeAt(r),16777619);return rt(ye[(n>>>0)%ye.length])}const us=5*6e4;function ds(s,e){const t=[];let n=null;for(const r of s){const i=r.author.kind==="user"?`user:${r.author.name}`:`agent:${r.author.sessionId??r.author.name}`,c=[...r.mentions].sort().join(","),l=new Date(r.createdAt).setHours(0,0,0,0);n&&n.author===i&&n.recipients===c&&n.day===l&&r.createdAt-n.at<us?t.at(-1).messages.push(r):t.push({role:r.author.kind==="user"?"user":r.author.sessionId===e?"lead":"agent",recipients:r.mentions,...(n==null?void 0:n.day)!==l&&{day:l},messages:[r]}),n={author:i,recipients:c,day:l,at:r.createdAt}}return t}function fs(s){const e=s.match(/^https?:\/\/github\.com\/[^/\s]+\/([^/\s]+)\/(pull|issues|commit)\/([0-9a-f]+)(?:[/?#].*)?$/i);if(!e)return null;const[,t,n,r]=e;return n==="commit"?{kind:"commit",label:`${t}@${r.slice(0,7)}`}:/^\d+$/.test(r)?{kind:n==="pull"?"pull":"issue",label:`${t}#${r}`}:null}function Se(s){return s.replace(/^https?:\/\/(www\.)?/i,"").replace(/\/$/,"")}function it(s){const e=z.c(18),{role:t,sessionId:n,kinds:r,tints:i,className:c}=s;let l;if(e[0]!==r||e[1]!==t||e[2]!==n){const h=n?r.get(n):void 0;l=t==="user"?Pt:h?ut(h):Ft,e[0]=r,e[1]=t,e[2]=n,e[3]=l}else l=e[3];const d=l,o=t==="lead"?"bg-foreground/[0.08] text-foreground/80":"bg-muted text-muted-foreground";let u;e[4]!==c||e[5]!==o?(u=D("flex size-6 shrink-0 items-center justify-center rounded-full",o,c),e[4]=c,e[5]=o,e[6]=u):u=e[6];let m;e[7]!==t||e[8]!==n||e[9]!==i?(m=t==="agent"&&n?lt(n,i):void 0,e[7]=t,e[8]=n,e[9]=i,e[10]=m):m=e[10];const g=t==="user"?"size-3.5":"size-3";let b;e[11]!==d||e[12]!==g?(b=a.jsx(d,{className:g}),e[11]=d,e[12]=g,e[13]=b):b=e[13];let p;return e[14]!==u||e[15]!==m||e[16]!==b?(p=a.jsx("span",{"aria-hidden":"true",className:u,style:m,children:b}),e[14]=u,e[15]=m,e[16]=b,e[17]=p):p=e[17],p}function ms(s){const e=new Date().setHours(0,0,0,0);if(s===e)return"Today";const t=new Date(e);if(s===t.setDate(t.getDate()-1))return"Yesterday";const n=new Date(s);return n.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric",...n.getFullYear()!==new Date().getFullYear()&&{year:"numeric"}})}function ps(s){const e=z.c(6),{day:t}=s;let n;e[0]!==t?(n=ms(t),e[0]=t,e[1]=n):n=e[1];const r=n;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"h-px flex-1 bg-border"}),e[2]=i):i=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("span",{className:"h-px flex-1 bg-border"}),e[3]=c):c=e[3];let l;return e[4]!==r?(l=a.jsxs("div",{role:"separator","aria-label":r,className:"flex items-center gap-3 text-[11px] text-muted-foreground",children:[i,r,c]}),e[4]=r,e[5]=l):l=e[5],l}function hs(s){const e=z.c(18),{run:t,members:n,handles:r,kinds:i,tints:c,rootId:l}=s,d=t.messages[0].author;let o,u;if(e[0]!==d||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==l||e[5]!==t.messages||e[6]!==t.recipients||e[7]!==t.role||e[8]!==c){let g;e[11]!==n?(g=h=>{var f;return((f=n.get(h))==null?void 0:f.name)??[]},e[11]=n,e[12]=g):g=e[12];const b=t.recipients.flatMap(g),p=t.role==="user"&&"-mx-2 rounded-lg bg-muted/50 px-2 py-2";e[13]!==p?(o=D("flex flex-col gap-2.5",p),e[13]=p,e[14]=o):o=e[14],u=t.messages.map((h,f)=>a.jsxs("article",{"aria-label":`Message from ${d.name}`,className:"group/message grid grid-cols-[1.5rem_minmax(0,1fr)] gap-x-2.5",children:[f===0?a.jsxs(a.Fragment,{children:[a.jsx(it,{role:t.role,sessionId:d.sessionId,kinds:i,tints:c,className:"row-span-2 mt-px"}),a.jsxs("header",{className:"flex min-w-0 items-baseline gap-1.5 leading-6",children:[a.jsx("span",{className:"truncate text-[13px] font-medium",children:d.name}),b.length>0&&a.jsxs("span",{className:"flex min-w-0 items-baseline gap-1 text-xs text-muted-foreground",title:`To ${b.join(", ")}`,children:[a.jsx(Dt,{"aria-hidden":"true",className:"size-3 shrink-0 translate-y-0.5"}),a.jsx("span",{className:"sr-only",children:"To"}),a.jsx("span",{className:"truncate",children:b.join(", ")})]}),a.jsx(Ge,{at:h.createdAt,className:"ml-auto pl-2 text-[11px]"})]})]}):a.jsx(Ge,{at:h.createdAt,short:!0,className:"pt-[3px] text-center text-[10px] opacity-0 group-hover/message:opacity-100 group-focus-within/message:opacity-100"}),a.jsx("div",{className:"col-start-2 min-w-0",children:a.jsx(ws,{message:h,handles:r,tints:c,rootId:l})})]},h.sequence)),e[0]=d,e[1]=r,e[2]=i,e[3]=n,e[4]=l,e[5]=t.messages,e[6]=t.recipients,e[7]=t.role,e[8]=c,e[9]=o,e[10]=u}else o=e[9],u=e[10];let m;return e[15]!==o||e[16]!==u?(m=a.jsx("div",{className:o,children:u}),e[15]=o,e[16]=u,e[17]=m):m=e[17],m}function Ge(s){const e=z.c(12),{at:t,short:n,className:r}=s;let i,c,l;if(e[0]!==t||e[1]!==n){const u=new Date(t);i=n?new Intl.DateTimeFormat([],{hour:"numeric",minute:"2-digit"}).formatToParts(u).filter(gs).map(xs).join(""):u.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),c=u.toISOString(),l=u.toLocaleString(),e[0]=t,e[1]=n,e[2]=i,e[3]=c,e[4]=l}else i=e[2],c=e[3],l=e[4];let d;e[5]!==r?(d=D("shrink-0 tabular-nums text-muted-foreground",r),e[5]=r,e[6]=d):d=e[6];let o;return e[7]!==i||e[8]!==c||e[9]!==l||e[10]!==d?(o=a.jsx("time",{dateTime:c,title:l,className:d,children:i}),e[7]=i,e[8]=c,e[9]=l,e[10]=d,e[11]=o):o=e[11],o}function xs(s){return s.value}function gs(s){return s.type==="hour"||s.type==="minute"||s.type==="literal"&&s.value.trim()}const ws=N.memo(function(e){const t=z.c(13),{message:n,handles:r,tints:i,rootId:c}=e;let l;t[0]!==r||t[1]!==n.mentions||t[2]!==n.text?(l=os(n.text,n.mentions,r),t[0]=r,t[1]=n.mentions,t[2]=n.text,t[3]=l):l=t[3];const d=l;let o;t[4]!==r?(o=[Vt,[ts,{handles:r}]],t[4]=r,t[5]=o):o=t[5];const u=o;let m;t[6]!==c||t[7]!==i?(m=vs(c,i),t[6]=c,t[7]=i,t[8]=m):m=t[8];const g=m;let b;return t[9]!==g||t[10]!==u||t[11]!==d?(b=a.jsx(bs,{children:a.jsx("div",{className:"text-[13px] leading-relaxed text-foreground/90 [overflow-wrap:anywhere]",children:a.jsx(Wt,{remarkPlugins:u,components:g,children:d})})}),t[9]=g,t[10]=u,t[11]=d,t[12]=b):b=t[12],b});function bs(s){const e=z.c(16),{children:t}=s,n=N.useRef(null),[r,i]=N.useState(!1),[c,l]=N.useState(!1);let d,o;e[0]!==c?(d=()=>{const x=n.current;if(!x||c)return;const w=()=>i(x.scrollHeight>x.clientHeight+1);if(w(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(w);return j.observe(x),()=>j.disconnect()},o=[c],e[0]=c,e[1]=d,e[2]=o):(d=e[1],o=e[2]),N.useLayoutEffect(d,o);const u=c?Tt:zt,m=!c&&"max-h-72 overflow-hidden",g=!c&&r&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-3rem),transparent)]";let b;e[3]!==m||e[4]!==g?(b=D(m,g),e[3]=m,e[4]=g,e[5]=b):b=e[5];let p;e[6]!==t||e[7]!==b?(p=a.jsx("div",{ref:n,className:b,children:t}),e[6]=t,e[7]=b,e[8]=p):p=e[8];let h;e[9]!==u||e[10]!==c||e[11]!==r?(h=r&&a.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"mt-1 inline-flex items-center gap-1 rounded-sm text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(u,{"aria-hidden":"true",className:"size-3"}),c?"Show less":"Show more"]}),e[9]=u,e[10]=c,e[11]=r,e[12]=h):h=e[12];let f;return e[13]!==p||e[14]!==h?(f=a.jsxs(a.Fragment,{children:[p,h]}),e[13]=p,e[14]=h,e[15]=f):f=e[15],f}const ys={success:"bg-success/10 text-success",warning:"bg-warning/12 text-warning",destructive:"bg-destructive/10 text-destructive"},js={pull:Lt,issue:Ot,commit:At},Ke=Je.a;function vs(s,e){return{...Je,p:({children:t})=>a.jsx("p",{className:"my-1.5 first:mt-0 last:mb-0",children:t}),ul:({children:t})=>a.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-1 pl-4 marker:text-muted-foreground/60 first:mt-0 last:mb-0",children:t}),ol:({children:t,type:n,start:r})=>a.jsx("ol",{start:r,className:D("my-1.5 flex flex-col gap-1 pl-5 marker:text-muted-foreground/70 first:mt-0 last:mb-0",n==="a"?"list-[lower-alpha]":"list-decimal"),children:t}),li:({children:t})=>a.jsx("li",{className:"pl-0.5",children:t}),h1:fe,h2:fe,h3:fe,h4:fe,h5:fe,h6:fe,blockquote:({children:t})=>a.jsx("blockquote",{className:"my-1.5 border-l-2 pl-2.5 text-muted-foreground",children:t}),hr:()=>a.jsx(ct,{className:"my-2.5"}),code:t=>{const{children:n,className:r}=t;return r||typeof n!="string"||n.includes(`
|
|
6
|
+
`)?a.jsx(ot,{...t}):a.jsx("code",{className:"rounded-[4px] bg-muted px-1 py-px font-mono text-[0.88em] text-foreground/85",children:n})},a:({href:t,children:n})=>{const r=typeof n=="string"&&t!==void 0&&Se(t)===Se(n),i=r?fs(t):null;if(i){const c=js[i.kind];return a.jsxs(Ke,{href:t,className:"inline-flex items-baseline gap-1 rounded-[4px] bg-muted px-1 font-medium text-foreground/85 no-underline hover:bg-accent",children:[a.jsx(c,{"aria-hidden":"true",className:"size-3 shrink-0 translate-y-0.5 text-muted-foreground"}),i.label]})}return a.jsx(Ke,{href:t,className:"cursor-pointer text-foreground underline decoration-foreground/25 underline-offset-2 hover:decoration-foreground/60",children:r?Se(t):n})},span:({children:t,...n})=>{const r=n,i=r["data-crew-token"];return i==="mention"?a.jsx(Ns,{sessionId:r["data-session-id"],rootId:s,tints:e,children:t}):i==="status"?a.jsx("span",{className:D("rounded-[4px] px-1 py-px text-[0.85em] font-medium",ys[r["data-tone"]]),children:t}):i==="sha"?a.jsx("span",{className:"font-mono text-[0.88em] text-muted-foreground",children:t}):a.jsx("span",{children:t})}}}function fe(s){const e=z.c(2),{children:t}=s;let n;return e[0]!==t?(n=a.jsx("p",{className:"mb-1 mt-3 font-semibold text-foreground first:mt-0",children:t}),e[0]=t,e[1]=n):n=e[1],n}function Ns(s){const e=z.c(10),{sessionId:t,rootId:n,tints:r,children:i}=s;let c;e[0]!==n||e[1]!==t||e[2]!==r?(c=t&&t!==n?lt(t,r):void 0,e[0]=n,e[1]=t,e[2]=r,e[3]=c):c=e[3];const l=c,d=!l&&(t?"bg-foreground/[0.08] text-foreground":"bg-muted text-muted-foreground");let o;e[4]!==d?(o=D("rounded-[4px] px-0.5 font-medium",d),e[4]=d,e[5]=o):o=e[5];let u;return e[6]!==i||e[7]!==l||e[8]!==o?(u=a.jsx("span",{style:l,className:o,children:i}),e[6]=i,e[7]=l,e[8]=o,e[9]=u):u=e[9],u}const ks=[],Cs=new Map;function Ss(s){var Ee,Me,Ae,Oe,Le,Te,ze;const e=z.c(111),{rootId:t,kinds:n,active:r}=s,i=n===void 0?Cs:n,c=r===void 0?!0:r,l=Jt(t),[d,o]=N.useState(""),u=N.useRef(null),m=N.useRef(!0);let g;e[0]!==l.messages?(g=(Ee=l.messages.at(-1))==null?void 0:Ee.sequence,e[0]=l.messages,e[1]=g):g=e[1];const b=g,p=((Me=l.page)==null?void 0:Me.members)??ks;let h;e[2]!==p?(h=es(p),e[2]=p,e[3]=h):h=e[3];const f=h;let x;e[4]!==p||e[5]!==t?(x=cs(p,t),e[4]=p,e[5]=t,e[6]=x):x=e[6];const w=x;let j;e[7]!==p?(j=new Map(p.map(Rs)),e[7]=p,e[8]=j):j=e[8];const C=j;let E;e[9]!==l.messages||e[10]!==t?(E=ds(l.messages,t),e[9]=l.messages,e[10]=t,e[11]=E):E=e[11];const A=E;let L;e[12]!==c?(L=()=>{var $,R;c&&m.current&&((R=($=u.current)==null?void 0:$.scrollIntoView)==null||R.call($,{block:"end"}))},e[12]=c,e[13]=L):L=e[13];let O;e[14]!==c||e[15]!==b?(O=[c,b],e[14]=c,e[15]=b,e[16]=O):O=e[16],N.useEffect(L,O);let T;e[17]!==l||e[18]!==d?(T=async()=>{const $=d.trim();!$||l.posting||await l.post($)&&(o(R=>R.trim()===$?"":R),m.current=!0)},e[17]=l,e[18]=d,e[19]=T):T=e[19];const v=T;let S;e[20]!==l.page||e[21]!==p?(S=l.page?`${p.filter(Is).length} listening · Members & mentions`:"Loading chat…",e[20]=l.page,e[21]=p,e[22]=S):S=e[22];let y;e[23]!==S?(y=a.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:S}),e[23]=S,e[24]=y):y=e[24];let k;if(e[25]!==l||e[26]!==i||e[27]!==p||e[28]!==t||e[29]!==w){let $;e[31]!==l||e[32]!==i||e[33]!==t||e[34]!==w?($=R=>{var De;return a.jsxs(Pe,{orientation:"horizontal",className:"items-center gap-2",children:[a.jsx(it,{role:R.sessionId===t?"lead":"agent",sessionId:R.sessionId,kinds:i,tints:w,className:"size-5"}),a.jsxs(Fe,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${R.sessionId}`,"aria-label":`Listen for ${R.name}`,children:[a.jsx("span",{className:"truncate",children:R.name}),a.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",R.handle]})]}),a.jsx(ae,{variant:"ghost",size:"icon-xs",disabled:!((De=l.page)!=null&&De.canPost)||!R.canInteract,onClick:()=>o(pe=>`${pe}${pe&&!/\s$/.test(pe)?" ":""}@${R.handle} `),"aria-label":`Mention ${R.name}`,title:`Mention @${R.handle}`,className:"text-muted-foreground",children:a.jsx(_t,{"data-icon":"inline-start"})}),a.jsx(Mt,{id:`listen-${R.sessionId}`,size:"sm",checked:R.listening,disabled:!R.canInteract||l.busyMembers.has(R.sessionId),onCheckedChange:pe=>void l.setListening(R.sessionId,pe)})]},R.sessionId)},e[31]=l,e[32]=i,e[33]=t,e[34]=w,e[35]=$):$=e[35],k=p.map($),e[25]=l,e[26]=i,e[27]=p,e[28]=t,e[29]=w,e[30]=k}else k=e[30];let M;e[36]!==k?(M=a.jsx(qe,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:k}),e[36]=k,e[37]=M):M=e[37];let I;e[38]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx("p",{className:"pb-1 text-xs text-muted-foreground",children:"Listening sends short notices while an agent works. @mentions send the full message, even when listening is off."}),e[38]=I):I=e[38];let P;e[39]!==y||e[40]!==M?(P=a.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[y,M,I]}),e[39]=y,e[40]=M,e[41]=P):P=e[41];let Y;e[42]===Symbol.for("react.memo_cache_sentinel")?(Y=$=>{const R=$.target;m.current=R.scrollHeight-R.scrollTop-R.clientHeight<80},e[42]=Y):Y=e[42];let F;e[43]!==l?(F=l.hasOlder&&a.jsx("div",{className:"flex justify-center py-2",children:a.jsx(ae,{variant:"ghost",size:"xs",disabled:l.loadingOlder,onClick:()=>void l.older(),children:l.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=l,e[44]=F):F=e[44];let q;e[45]!==l.messages.length||e[46]!==l.page?(q=l.page&&l.messages.length===0&&a.jsx(dt,{children:a.jsxs(ft,{children:[a.jsx(mt,{variant:"icon",children:a.jsx(qt,{})}),a.jsx(pt,{children:"Talk to the crew"}),a.jsx(ht,{children:"Share a discovery, ask a question, or tag someone for their input."})]})}),e[45]=l.messages.length,e[46]=l.page,e[47]=q):q=e[47];let _;if(e[48]!==C||e[49]!==f||e[50]!==i||e[51]!==t||e[52]!==A||e[53]!==w){let $;e[55]!==C||e[56]!==f||e[57]!==i||e[58]!==t||e[59]!==w?($=R=>a.jsxs(N.Fragment,{children:[R.day!==void 0&&a.jsx(ps,{day:R.day}),a.jsx(hs,{run:R,members:C,handles:f,kinds:i,tints:w,rootId:t})]},R.messages[0].sequence),e[55]=C,e[56]=f,e[57]=i,e[58]=t,e[59]=w,e[60]=$):$=e[60],_=A.map($),e[48]=C,e[49]=f,e[50]=i,e[51]=t,e[52]=A,e[53]=w,e[54]=_}else _=e[54];let G;e[61]===Symbol.for("react.memo_cache_sentinel")?(G=a.jsx("div",{ref:u}),e[61]=G):G=e[61];let W;e[62]!==_?(W=a.jsxs("div",{role:"log","aria-label":"Shared messages","aria-live":"polite","aria-relevant":"additions",className:"flex flex-col gap-4 px-3 py-3",children:[_,G]}),e[62]=_,e[63]=W):W=e[63];let J;e[64]!==F||e[65]!==q||e[66]!==W?(J=a.jsxs(Xe,{className:"min-h-0 flex-1",onScrollCapture:Y,children:[F,q,W]}),e[64]=F,e[65]=q,e[66]=W,e[67]=J):J=e[67];let U;e[68]!==v?(U=$=>{$.preventDefault(),v()},e[68]=v,e[69]=U):U=e[69];const X=!!l.error,Q=`crew-chat-${t}`;let H;e[70]!==Q?(H=a.jsx(Fe,{htmlFor:Q,className:"sr-only",children:"Message the crew"}),e[70]=Q,e[71]=H):H=e[71];const Z=`crew-chat-${t}`,ee=!((Ae=l.page)!=null&&Ae.canPost),te=!!l.error;let K;e[72]===Symbol.for("react.memo_cache_sentinel")?(K=$=>o($.target.value),e[72]=K):K=e[72];let B;e[73]!==v?(B=$=>{$.key==="Enter"&&($.metaKey||$.ctrlKey)&&!$.nativeEvent.isComposing&&($.preventDefault(),v())},e[73]=v,e[74]=B):B=e[74];let V;e[75]!==d||e[76]!==Z||e[77]!==ee||e[78]!==te||e[79]!==B?(V=a.jsx(xt,{id:Z,value:d,rows:3,maxLength:Xt,placeholder:"Message the crew… use @ to tag an agent",disabled:ee,"aria-invalid":te,onChange:K,onKeyDown:B}),e[75]=d,e[76]=Z,e[77]=ee,e[78]=te,e[79]=B,e[80]=V):V=e[80];let se;e[81]!==l.error?(se=l.error&&a.jsx("p",{role:"alert",className:"text-xs text-destructive",children:l.error}),e[81]=l.error,e[82]=se):se=e[82];let ne;e[83]!==X||e[84]!==H||e[85]!==V||e[86]!==se?(ne=a.jsxs(Pe,{"data-invalid":X,children:[H,V,se]}),e[83]=X,e[84]=H,e[85]=V,e[86]=se,e[87]=ne):ne=e[87];const ve=((Oe=l.page)==null?void 0:Oe.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let le;e[88]!==ve?(le=a.jsx(gt,{className:"flex-1",children:ve}),e[88]=ve,e[89]=le):le=e[89];let ie;e[90]!==((Le=l.page)==null?void 0:Le.canPost)||e[91]!==l.posting||e[92]!==d?(ie=!((Te=l.page)!=null&&Te.canPost)||!d.trim()||l.posting,e[90]=(ze=l.page)==null?void 0:ze.canPost,e[91]=l.posting,e[92]=d,e[93]=ie):ie=e[93];let ge;e[94]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx(Ut,{"data-icon":"inline-start"}),e[94]=ge):ge=e[94];const Ne=l.posting?"Sending…":"Send";let oe;e[95]!==ie||e[96]!==Ne?(oe=a.jsxs(ae,{type:"submit",size:"sm",disabled:ie,children:[ge,Ne]}),e[95]=ie,e[96]=Ne,e[97]=oe):oe=e[97];let ce;e[98]!==le||e[99]!==oe?(ce=a.jsxs("div",{className:"flex items-center gap-2",children:[le,oe]}),e[98]=le,e[99]=oe,e[100]=ce):ce=e[100];let ue;e[101]!==ne||e[102]!==ce?(ue=a.jsxs(qe,{className:"gap-2",children:[ne,ce]}),e[101]=ne,e[102]=ce,e[103]=ue):ue=e[103];let de;e[104]!==U||e[105]!==ue?(de=a.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:U,children:ue}),e[104]=U,e[105]=ue,e[106]=de):de=e[106];let we;return e[107]!==P||e[108]!==J||e[109]!==de?(we=a.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[P,J,de]}),e[107]=P,e[108]=J,e[109]=de,e[110]=we):we=e[110],we}function Is(s){return s.listening}function Rs(s){return[s.sessionId,s]}const $s=4e3;function Es(s){var h;const[e,t]=N.useState(null),[n,r]=N.useState(null),[i,c]=N.useState(new Set),l=(h=wt())==null?void 0:h.refresh,d=N.useRef(s),o=N.useRef(new Set);N.useLayoutEffect(()=>(d.current=s,()=>{d.current=null}),[s]);const u=N.useCallback(async f=>{if(s)try{const x=await Ie(`/api/session-crew/${encodeURIComponent(s)}`);if(!f())return;if(!x.ok){r(x.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const w=await x.json();if(!f())return;t(j=>JSON.stringify(j)===JSON.stringify(w)?j:w),r(null)}catch{f()&&r("Couldn't load the crew.")}},[s]);We(s?u:null,$s),N.useEffect(()=>{t(f=>f!=null&&f.members.some(x=>x.sessionId===s)?f:null),r(null),c(new Set)},[s]);const m=N.useCallback(async(f,x,w)=>{const j=`${s}:${f}`;if(o.current.has(j))return;const C=()=>d.current===s;o.current.add(j),c(E=>new Set(E).add(f));try{const E=await x();if(!C())return;if(!E.ok&&E.status!==404){r(w);return}l==null||l(),await u(C)}catch{C()&&r(w)}finally{o.current.delete(j),C()&&c(E=>{const A=new Set(E);return A.delete(f),A})}},[u,l,s]),g=N.useCallback((f,x,w)=>m(x,()=>me("/api/session-respond",{sessionId:f,requestId:x,...w}),"Couldn't send the answer."),[m]),b=N.useCallback((f,x)=>m(x,()=>me("/api/delegated-tasks",{sessionId:f,taskId:x,action:"ack"}),"Couldn't mark the result read."),[m]),p=N.useCallback(f=>m(f.sessionId,()=>{var x;return((x=f.result)==null?void 0:x.state)==="running"&&f.parentId?me("/api/delegated-tasks",{sessionId:f.parentId,taskId:f.result.taskId,action:"cancel"}):me("/api/stop-session",{sessionId:f.sessionId})},"Couldn't stop the session."),[m]);return{crew:e,error:n,busy:i,respond:g,markRead:b,stop:p}}function xe(s){switch(s.outcome){case"needs_input":return"needs-you";case"running":return"working";case"error":return"failed";case"unreachable":case"not_found":return"unreachable";default:return"done"}}function Ve(s,e){var t,n;return{sessionId:s.sessionId,dirName:((t=s.address)==null?void 0:t.dirName)??"",fileName:((n=s.address)==null?void 0:n.fileName)??"",projectShortName:"",lastModified:s.lastActivityAt??"",lastActivityAt:s.lastActivityAt,size:0,cwd:s.cwd,customTitle:s.customTitle,aiTitle:s.aiTitle,firstUserMessage:s.firstUserMessage,...s.parentId&&{crew:{rootId:e,parentId:s.parentId,startedAt:s.startedAt??0,...s.name&&{name:s.name}}}}}function Ms(s,e,t){var l;const n=((l=[...e.values()].find(d=>d.parentId===null))==null?void 0:l.sessionId)??s.sessionId,r=t[s.sessionId],i=Ve(s,n);if(!s.parentId)return bt(i,r);const c=e.get(s.parentId);return yt(i,{customName:r,parent:c&&Ve(c,n)})}function As(s){const e=new Map;for(const i of s.members){if(!i.parentId)continue;const c=e.get(i.parentId);c?c.push(i):e.set(i.parentId,[i])}const t=[],n=new Set,r=(i,c)=>{var d;const l=[...e.get(i)??[]].sort((o,u)=>(o.startedAt??0)-(u.startedAt??0));for(const o of l)n.has(o.sessionId)||(n.add(o.sessionId),t.push({member:o,depth:c,children:((d=e.get(o.sessionId))==null?void 0:d.length)??0}),r(o.sessionId,c+1))};r(s.rootId,0);for(const i of s.members)i.parentId&&!n.has(i.sessionId)&&(n.add(i.sessionId),t.push({member:i,depth:0,children:0}));return t}function Os(s){const e=({member:t,pending:n})=>n.askedAt??(Date.parse(t.lastActivityAt??"")||0);return s.members.flatMap(t=>t.waiting.map(n=>({member:t,pending:n}))).sort((t,n)=>e(t)-e(n))}function Ls(s){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const t of s.members){if(!t.parentId)continue;e.size++;const n=xe(t);n==="working"?e.working++:n==="needs-you"?e.needsYou++:n==="failed"?e.failed++:n==="unreachable"?e.unreachable++:e.done++,$e(t)&&e.unreadResults++}return e}function $e(s){return!!(s.result&&s.result.state!=="running"&&!s.result.acknowledged)}function je(s){const[e]=s.waiting;switch(xe(s)){case"needs-you":return(e==null?void 0:e.kind)==="permission"?`Waiting on a permission · ${e.toolName}`:(e==null?void 0:e.kind)==="question"?"Asked a question":"Plan to review";case"working":return s.status==="tool_use"&&s.toolName?s.toolName:s.status==="thinking"?"Thinking":s.status==="compacting"?"Compacting":s.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return s.error?`Failed · ${s.error}`:"Failed";case"unreachable":return s.device?`${s.device.name} is not answering`:"Not found";default:return $e(s)?"Finished · result unread":"Finished"}}const Ts=[{id:"all",label:"All"},{id:"working",label:"Working"},{id:"needs-you",label:"Need you"},{id:"done",label:"Done"}],zs={working:"bg-success shadow-[0_0_0_2px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40",failed:"bg-destructive",unreachable:"border border-muted-foreground/50"},re={working:"bg-success ring-2 ring-success/30","needs-you":"bg-warning",done:"bg-muted-foreground/50",failed:"bg-destructive",unreachable:"border border-muted-foreground/60"};function Xs(s){var M;const e=z.c(33),{context:t,closePanel:n}=s,r=((M=t.session)==null?void 0:M.sessionId)??null,{crew:i,error:c,busy:l,respond:d,markRead:o,stop:u}=Es(r),{names:m}=jt(),[g,b]=N.useState("overview");let p;e[0]!==(i==null?void 0:i.members)?(p=new Map(((i==null?void 0:i.members)??[]).map(Ps)),e[0]=i==null?void 0:i.members,e[1]=p):p=e[1];const h=p;let f;e[2]!==(i==null?void 0:i.members)?(f=new Map(((i==null?void 0:i.members)??[]).flatMap(Ds)),e[2]=i==null?void 0:i.members,e[3]=f):f=e[3];const x=f;let w;e[4]!==h||e[5]!==m?(w=I=>Ms(I,h,m),e[4]=h,e[5]=m,e[6]=w):w=e[6];const j=w;let C;e[7]!==t?(C=I=>{I.address&&I.device?Rt($t(I.address.dirName,I.address.fileName,I.device.id)):I.address&&t.openSession?t.openSession(I.address.dirName,I.address.fileName):Et(I.sessionId)},e[7]=t,e[8]=C):C=e[8];const E=C;let A,L,O;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(Gt,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),L=a.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),O=a.jsx("div",{className:"flex-1"}),e[9]=A,e[10]=L,e[11]=O):(A=e[9],L=e[10],O=e[11]);let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(Kt,{"data-icon":"inline-start"}),e[12]=T):T=e[12];let v;e[13]!==n?(v=a.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[A,L,O,a.jsx(ae,{variant:"ghost",size:"icon-sm",onClick:n,"aria-label":"Close crew",children:T})]}),e[13]=n,e[14]=v):v=e[14];let S;e[15]!==c?(S=c&&a.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[15]=c,e[16]=S):S=e[16];let y;e[17]!==l||e[18]!==i||e[19]!==c||e[20]!==x||e[21]!==o||e[22]!==j||e[23]!==E||e[24]!==d||e[25]!==r||e[26]!==u||e[27]!==g?(y=i?a.jsxs(vt,{value:g,onValueChange:b,className:"min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[a.jsxs(Nt,{variant:"line",className:"mx-3 mb-1",children:[a.jsx(_e,{value:"overview",children:"Overview"}),a.jsx(_e,{value:"chat",children:"Chat"})]}),a.jsx(Ue,{value:"overview",className:"min-h-0",children:a.jsxs(Xe,{className:"h-full min-h-0",children:[a.jsx(Fs,{crew:i,hereId:r,nameOf:j,onOpen:E}),a.jsx(Us,{crew:i,busy:l,nameOf:j,onOpen:E,onRespond:d}),a.jsx(Hs,{crew:i,hereId:r,busy:l,nameOf:j,onOpen:E,onMarkRead:o,onStop:u})]})}),a.jsx(Ue,{value:"chat",keepMounted:!0,className:"min-h-0",children:a.jsx(Ss,{rootId:i.rootId,kinds:x,active:g==="chat"},i.rootId)})]}):!c&&a.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[17]=l,e[18]=i,e[19]=c,e[20]=x,e[21]=o,e[22]=j,e[23]=E,e[24]=d,e[25]=r,e[26]=u,e[27]=g,e[28]=y):y=e[28];let k;return e[29]!==S||e[30]!==y||e[31]!==v?(k=a.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[v,S,y]}),e[29]=S,e[30]=y,e[31]=v,e[32]=k):k=e[32],k}function Ds(s){return s.address?[[s.sessionId,kt(s.address.dirName)]]:[]}function Ps(s){return[s.sessionId,s]}function Fs(s){var j;const e=z.c(45),{crew:t,hereId:n,nameOf:r,onOpen:i}=s;let c,l,d,o,u;if(e[0]!==t||e[1]!==n||e[2]!==r||e[3]!==i){let C;e[9]!==t.rootId?(C=k=>k.sessionId===t.rootId,e[9]=t.rootId,e[10]=C):C=e[10];const E=t.members.find(C),A=t.members.filter(qs);let L;e[11]!==t?(L=Ls(t),e[11]=t,e[12]=L):L=e[12],u=L;const O=(j=A[0])==null?void 0:j.startedAt;c="Crew summary",l="border-b px-3 pb-3 pt-1";const T=E&&a.jsx("button",{type:"button",onClick:()=>i(E),"aria-current":E.sessionId===n?"true":void 0,className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:r(E)}),v=u.size===1?"session":"sessions",S=O?` · since ${_s(O)}`:"";let y;e[13]!==v||e[14]!==S||e[15]!==u.size?(y=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[u.size," ",v,S]}),e[13]=v,e[14]=S,e[15]=u.size,e[16]=y):y=e[16],e[17]!==y||e[18]!==T?(d=a.jsxs("div",{className:"flex items-baseline gap-2",children:[T,y]}),e[17]=y,e[18]=T,e[19]=d):d=e[19],o=A.length>0&&a.jsx("div",{"data-crew-strip":!0,className:"mt-2.5 flex gap-[3px]",role:"list","aria-label":"One cell per session, in the order they were started",children:A.map(k=>{const M=xe(k);return a.jsx("button",{type:"button",role:"listitem","data-crew-cell":M,title:`${r(k)}: ${je(k)}`,"aria-label":`${r(k)}: ${je(k)}`,onClick:()=>{var I;return(I=document.querySelector(`[data-crew-row="${k.sessionId}"]`))==null?void 0:I.scrollIntoView({block:"nearest",behavior:"smooth"})},className:D("h-2.5 min-w-[3px] flex-1 rounded-[2px] outline-none focus-visible:ring-2 focus-visible:ring-ring",zs[M],k.sessionId===n&&"outline outline-[1.5px] outline-offset-2 outline-foreground")},k.sessionId)})}),e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=c,e[5]=l,e[6]=d,e[7]=o,e[8]=u}else c=e[4],l=e[5],d=e[6],o=e[7],u=e[8];let m;e[20]!==u.working?(m=u.working>0&&a.jsx(he,{dot:re.working,value:u.working,label:"working"}),e[20]=u.working,e[21]=m):m=e[21];let g;e[22]!==u.needsYou?(g=u.needsYou>0&&a.jsx(he,{dot:re["needs-you"],value:u.needsYou,label:u.needsYou===1?"needs you":"need you"}),e[22]=u.needsYou,e[23]=g):g=e[23];let b;e[24]!==u.done?(b=u.done>0&&a.jsx(he,{dot:re.done,value:u.done,label:"done"}),e[24]=u.done,e[25]=b):b=e[25];let p;e[26]!==u.failed?(p=u.failed>0&&a.jsx(he,{dot:re.failed,value:u.failed,label:"failed"}),e[26]=u.failed,e[27]=p):p=e[27];let h;e[28]!==u.unreachable?(h=u.unreachable>0&&a.jsx(he,{dot:re.unreachable,value:u.unreachable,label:"away"}),e[28]=u.unreachable,e[29]=h):h=e[29];let f;e[30]!==u.unreadResults?(f=u.unreadResults>0&&a.jsxs("span",{className:"ml-auto text-warning",children:[a.jsx("span",{className:"font-medium tabular-nums",children:u.unreadResults})," ",u.unreadResults===1?"result":"results"," unread"]}),e[30]=u.unreadResults,e[31]=f):f=e[31];let x;e[32]!==f||e[33]!==m||e[34]!==g||e[35]!==b||e[36]!==p||e[37]!==h?(x=a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[m,g,b,p,h,f]}),e[32]=f,e[33]=m,e[34]=g,e[35]=b,e[36]=p,e[37]=h,e[38]=x):x=e[38];let w;return e[39]!==c||e[40]!==x||e[41]!==l||e[42]!==d||e[43]!==o?(w=a.jsxs("section",{"aria-label":c,className:l,children:[d,o,x]}),e[39]=c,e[40]=x,e[41]=l,e[42]=d,e[43]=o,e[44]=w):w=e[44],w}function qs(s){return s.parentId!==null}function _s(s){const e=new Date(s),t=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?t:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${t}`}function he(s){const e=z.c(10),{dot:t,value:n,label:r}=s;let i;e[0]!==t?(i=D("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let c;e[2]!==i?(c=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=c):c=e[3];let l;e[4]!==n?(l=a.jsx("span",{className:"font-medium tabular-nums text-foreground",children:n}),e[4]=n,e[5]=l):l=e[5];let d;return e[6]!==r||e[7]!==c||e[8]!==l?(d=a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,l," ",r]}),e[6]=r,e[7]=c,e[8]=l,e[9]=d):d=e[9],d}function Us(s){const e=z.c(6),{crew:t,busy:n,nameOf:r,onOpen:i,onRespond:c}=s,l=Os(t),[d,o]=N.useState(0);if(l.length===0)return null;const u=Math.min(d,l.length-1),{member:m,pending:g}=l[u],b=l[u+1];let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Needs you"}),e[0]=p):p=e[0];let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx("span",{className:"flex-1"}),e[1]=h):h=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx("span",{className:D("size-1.5 shrink-0 rounded-full",re["needs-you"]),"aria-hidden":"true"}),e[2]=f):f=e[2];const x=g.askedAt?`waiting ${Qe(new Date(g.askedAt).toISOString())}`:"waiting";let w;e[3]!==x?(w=a.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:x}),e[3]=x,e[4]=w):w=e[4];let j;return e[5]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(He,{"data-icon":"inline-end"}),e[5]=j):j=e[5],a.jsxs("section",{"aria-label":"Needs you",className:"border-b px-3 py-2.5",children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[p,a.jsx("span",{className:"tabular-nums",children:l.length}),h,l.length>1&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"tabular-nums",children:[u+1," of ",l.length]}),a.jsx(ae,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:u===0,onClick:()=>o(u-1),children:a.jsx(Ht,{"data-icon":"inline-start"})}),a.jsx(ae,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:u===l.length-1,onClick:()=>o(u+1),children:a.jsx(He,{"data-icon":"inline-start"})})]})]}),a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-xs",children:[f,a.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:r(m)}),m.device&&a.jsx(Ct,{variant:"outline",children:m.device.name}),w]}),a.jsx(St,{sessionId:m.sessionId,pending:g,queued:0,responding:n.has(g.requestId),onRespond:(C,E)=>void c(m.sessionId,C,E),onOpen:()=>i(m)},g.requestId),a.jsxs(ae,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>i(m),children:["Open session",j]})]}),b&&a.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",a.jsx("span",{className:"font-medium text-foreground",children:r(b.member)})," ",je(b.member).toLowerCase()]})]})}function Hs(s){const e=z.c(17),{crew:t,hereId:n,busy:r,nameOf:i,onOpen:c,onMarkRead:l,onStop:d}=s,[o,u]=N.useState("all");let m;if(e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==n||e[4]!==i||e[5]!==l||e[6]!==c||e[7]!==d){let g;e[9]!==o?(g=w=>{const{member:j}=w;if(o==="all")return!0;const C=xe(j);return o==="done"?C!=="working"&&C!=="needs-you":C===o},e[9]=o,e[10]=g):g=e[10];const b=As(t).filter(g);let p,h;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),h=a.jsx("span",{className:"flex-1"}),e[11]=p,e[12]=h):(p=e[11],h=e[12]);let f;e[13]!==o?(f=Ts.map(w=>{const{id:j,label:C}=w;return a.jsx("button",{type:"button",role:"radio","aria-checked":o===j,onClick:()=>u(j),className:D("rounded-full px-2 py-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",o===j&&"bg-accent text-foreground"),children:C},j)}),e[13]=o,e[14]=f):f=e[14];let x;e[15]!==f?(x=a.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[p,h,a.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:f})]}),e[15]=f,e[16]=x):x=e[16],m=a.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[x,b.length===0?a.jsx("p",{className:"px-1.5 py-4 text-center text-xs text-muted-foreground",children:"No sessions here."}):a.jsx("ul",{className:"flex flex-col",children:b.map(w=>a.jsx(Bs,{row:w,here:w.member.sessionId===n,busy:r,name:i(w.member),onOpen:c,onMarkRead:l,onStop:d},w.member.sessionId))})]}),e[0]=r,e[1]=t,e[2]=o,e[3]=n,e[4]=i,e[5]=l,e[6]=c,e[7]=d,e[8]=m}else m=e[8];return m}function Bs(s){var se,ne;const e=z.c(73),{row:t,here:n,busy:r,name:i,onOpen:c,onMarkRead:l,onStop:d}=s,{member:o,depth:u,children:m}=t;let g;e[0]!==o?(g=xe(o),e[0]=o,e[1]=g):g=e[1];const b=g;let p;e[2]!==o?(p=je(o),e[2]=o,e[3]=p):p=e[3];const h=p;let f;e[4]!==o.pullRequests?(f=(se=o.pullRequests)==null?void 0:se.at(-1),e[4]=o.pullRequests,e[5]=f):f=e[5];const x=f;let w;e[6]!==o?(w=$e(o)&&o.result&&o.parentId,e[6]=o,e[7]=w):w=e[7];const j=w,C=(b==="working"||b==="needs-you")&&(!o.device||((ne=o.result)==null?void 0:ne.state)==="running"&&o.parentId!==null),E=o.sessionId,A=n?"bg-accent":"hover:bg-accent/60",L=u>0&&"border-l border-border/70";let O;e[8]!==A||e[9]!==L?(O=D("group/crew relative rounded-md",A,L),e[8]=A,e[9]=L,e[10]=O):O=e[10];const T=u>0?6+(u-1)*14:0;let v;e[11]!==T?(v={marginLeft:T},e[11]=T,e[12]=v):v=e[12];let S;e[13]!==o||e[14]!==c?(S=()=>c(o),e[13]=o,e[14]=c,e[15]=S):S=e[15];const y=n?"true":void 0,k=`${i}, ${h}`,M=re[b];let I;e[16]!==M?(I=D("size-1.5 justify-self-center rounded-full",M),e[16]=M,e[17]=I):I=e[17];let P;e[18]!==I?(P=a.jsx("span",{className:I,"aria-hidden":"true"}),e[18]=I,e[19]=P):P=e[19];let Y;e[20]!==i?(Y=a.jsx("span",{className:"truncate",children:i}),e[20]=i,e[21]=Y):Y=e[21];let F;e[22]!==n?(F=n&&a.jsx("span",{className:"shrink-0 rounded-full border px-1.5 text-[10.5px] font-normal text-muted-foreground",children:"you are here"}),e[22]=n,e[23]=F):F=e[23];let q;e[24]!==Y||e[25]!==F?(q=a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[Y,F]}),e[24]=Y,e[25]=F,e[26]=q):q=e[26];let _;e[27]!==o.lastActivityAt?(_=o.lastActivityAt?Qe(o.lastActivityAt):"",e[27]=o.lastActivityAt,e[28]=_):_=e[28];let G;e[29]!==_?(G=a.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:_}),e[29]=_,e[30]=G):G=e[30];const W=(b==="needs-you"||j)&&"text-warning",J=b==="failed"&&"text-destructive";let U;e[31]!==W||e[32]!==J?(U=D("min-w-0 flex-1 truncate",W,J),e[31]=W,e[32]=J,e[33]=U):U=e[33];let X;e[34]!==h||e[35]!==U?(X=a.jsx("span",{className:U,children:h}),e[34]=h,e[35]=U,e[36]=X):X=e[36];let Q;e[37]!==x?(Q=x&&a.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",x.number]}),e[37]=x,e[38]=Q):Q=e[38];let H;e[39]!==o.device?(H=o.device&&a.jsx("span",{className:"shrink-0",children:o.device.name}),e[39]=o.device,e[40]=H):H=e[40];let Z;e[41]!==m?(Z=m>0&&a.jsxs("span",{className:"shrink-0",children:[m," ",m===1?"session":"sessions"]}),e[41]=m,e[42]=Z):Z=e[42];let ee;e[43]!==o.model?(ee=o.model&&a.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:It(o.model)}),e[43]=o.model,e[44]=ee):ee=e[44];let te;e[45]!==X||e[46]!==Q||e[47]!==H||e[48]!==Z||e[49]!==ee?(te=a.jsxs("span",{className:"col-start-2 col-end-4 flex min-w-0 items-center gap-2 text-[11.5px] text-muted-foreground",children:[X,Q,H,Z,ee]}),e[45]=X,e[46]=Q,e[47]=H,e[48]=Z,e[49]=ee,e[50]=te):te=e[50];let K;e[51]!==S||e[52]!==y||e[53]!==k||e[54]!==P||e[55]!==q||e[56]!==G||e[57]!==te?(K=a.jsxs("button",{type:"button",onClick:S,"aria-current":y,"aria-label":k,className:"grid w-full grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[P,q,G,te]}),e[51]=S,e[52]=y,e[53]=k,e[54]=P,e[55]=q,e[56]=G,e[57]=te,e[58]=K):K=e[58];let B;e[59]!==r||e[60]!==C||e[61]!==o||e[62]!==i||e[63]!==l||e[64]!==d||e[65]!==j?(B=(j||C)&&a.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[j&&o.result&&o.parentId&&a.jsx(ae,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${i}'s result read`,title:"Mark the result read",disabled:r.has(o.result.taskId),onClick:()=>void l(o.parentId,o.result.taskId),children:a.jsx(Bt,{"data-icon":"inline-start"})}),C&&a.jsx(ae,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${i}`,title:"Stop this session",disabled:r.has(o.sessionId),onClick:()=>void d(o),children:a.jsx(Yt,{"data-icon":"inline-start"})})]}),e[59]=r,e[60]=C,e[61]=o,e[62]=i,e[63]=l,e[64]=d,e[65]=j,e[66]=B):B=e[66];let V;return e[67]!==o.sessionId||e[68]!==v||e[69]!==K||e[70]!==B||e[71]!==O?(V=a.jsxs("li",{"data-crew-row":E,className:O,style:v,children:[K,B]}),e[67]=o.sessionId,e[68]=v,e[69]=K,e[70]=B,e[71]=O,e[72]=V):V=e[72],V}export{Xs as CrewPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as G,r as H,j as i}from"./vendor-react-gGw_S5I_.js";import{V as M,W as P,J as X,X as z}from"./index-
|
|
1
|
+
import{c as G,r as H,j as i}from"./vendor-react-gGw_S5I_.js";import{V as M,W as P,J as X,X as z}from"./index-BVrmKCdP.js";const F=2e5;function W(l){const e=G.c(32),{value:t,onChange:v,readOnly:f,filePath:E,ariaLabel:L,textareaRef:u,onKeyDown:S,onSelect:_}=l,p=M(),[h,N]=H.useState(null),d=H.useRef(null),m=H.useRef(null);let x;e[0]!==E?(x=P(E)??"markdown",e[0]=E,e[1]=x):x=e[1];const g=x,b=t.length>F;let j,k;e[2]!==p||e[3]!==g||e[4]!==b||e[5]!==t?(j=()=>{if(b){N(null);return}let r=!1;const I=setTimeout(()=>{z(t,g,p).then(A=>{r||N(A)})},80);return()=>{r=!0,clearTimeout(I)}},k=[t,g,p,b],e[2]=p,e[3]=g,e[4]=b,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]),H.useEffect(j,k);let R;e[8]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{d.current&&m.current&&(m.current.scrollTop=d.current.scrollTop,m.current.scrollLeft=d.current.scrollLeft)},e[8]=R):R=e[8];const D=R;let T;e[9]!==u?(T=r=>{d.current=r,u&&(u.current=r)},e[9]=u,e[10]=T):T=e[10];const y=T;let n;e[11]!==h||e[12]!==t?(n=h?h.map(J):i.jsx("code",{className:"text-foreground",children:t}),e[11]=h,e[12]=t,e[13]=n):n=e[13];let s;e[14]!==n?(s=i.jsx("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden font-mono text-[13px] leading-relaxed p-4 m-0 pointer-events-none whitespace-pre-wrap break-words",children:n}),e[14]=n,e[15]=s):s=e[15];let o;e[16]!==v?(o=r=>v(r.target.value),e[16]=v,e[17]=o):o=e[17];const C=f&&"cursor-default";let a;e[18]!==C?(a=X("absolute inset-0 w-full h-full resize-none bg-transparent font-mono text-[13px] leading-relaxed p-4 outline-none","text-transparent caret-foreground selection:bg-selection","scrollbar-thin scrollbar-track-transparent scrollbar-thumb-border",C),e[18]=C,e[19]=a):a=e[19];let c;e[20]!==L||e[21]!==y||e[22]!==S||e[23]!==_||e[24]!==f||e[25]!==a||e[26]!==o||e[27]!==t?(c=i.jsx("textarea",{ref:y,"aria-label":L,value:t,onChange:o,onScroll:D,onKeyDown:S,onSelect:_,readOnly:f,spellCheck:!1,className:a,placeholder:"Empty file"}),e[20]=L,e[21]=y,e[22]=S,e[23]=_,e[24]=f,e[25]=a,e[26]=o,e[27]=t,e[28]=c):c=e[28];let w;return e[29]!==c||e[30]!==s?(w=i.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[s,c]}),e[29]=c,e[30]=s,e[31]=w):w=e[31],w}function J(l,e){return i.jsxs("span",{children:[l.map(K),`
|
|
2
2
|
`]},e)}function K(l,e){return i.jsx("span",{style:{color:l.color},children:l.content},e)}export{W as H};
|
package/dist/web/assets/{KeyboardShortcutsDialog-CRuTSHwt.js → KeyboardShortcutsDialog-C80JLjM1.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-
|
|
1
|
+
import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-BVrmKCdP.js";import{R as O,K as oe,S as ce}from"./vendor-ui-Dfr2Rf5Q.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const ie=new Set(["Alt","Control","Meta","Shift"]);function fe(e){const s=q.c(6),{open:f,onOpenChange:l}=e,x=f?"open":"closed";let a;s[0]!==x?(a=t.jsx(de,{},x),s[0]=x,s[1]=a):a=s[1];let r;return s[2]!==l||s[3]!==f||s[4]!==a?(r=t.jsx(F,{open:f,onOpenChange:l,children:a}),s[2]=l,s[3]=f,s[4]=a,s[5]=r):r=s[5],r}function de(){const e=q.c(45),[s,f]=k.useState(""),[l,x]=k.useState(null),[a,r]=k.useState(null),[B,G]=k.useState($);let E,I;e[0]!==l?(E=()=>{if(!l)return;const D=l,A=function(n){if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),x(null),r(null);return}if(ie.has(n.key))return;n.preventDefault(),n.stopPropagation();const c=le(n),p=ne(c,D);if(p){r(`Already assigned to “${p.label}”.`);return}re(D,c),G($()),x(null),r(null)};return window.addEventListener("keydown",A,!0),()=>window.removeEventListener("keydown",A,!0)},I=[l],e[0]=l,e[1]=E,e[2]=I):(E=e[1],I=e[2]),k.useEffect(E,I);let g,j,d,y,b,N,S,w,m,u,h;if(e[3]!==B||e[4]!==a||e[5]!==s||e[6]!==l){const D=s.trim().toLowerCase(),A=D?T.filter(i=>`${i.label} ${i.description} ${i.group}`.toLowerCase().includes(D)):T;j=H,S="max-w-2xl gap-0 overflow-hidden p-0",w=!1,e[18]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs(M,{className:"p-4 pb-3",children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(oe,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4"}),"Keyboard shortcuts"]}),t.jsx(J,{children:"Click a shortcut, then press a new key combination. Changes are saved on this device."})]}),u=t.jsx(V,{}),e[18]=m,e[19]=u):(m=e[18],u=e[19]);let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(W,{children:t.jsx(ce,{"data-icon":"inline-start","aria-hidden":"true"})}),e[20]=K):K=e[20];let n;e[21]===Symbol.for("react.memo_cache_sentinel")?(n=i=>f(i.target.value),e[21]=n):n=e[21];let c;e[22]!==s?(c=t.jsxs(X,{className:"flex-1",children:[K,t.jsx(Z,{"aria-label":"Search keyboard shortcuts",value:s,onChange:n,placeholder:"Search shortcuts…"})]}),e[22]=s,e[23]=c):c=e[23];let p;e[24]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsxs(P,{variant:"outline",size:"sm",onClick:()=>{ee(),G($()),r(null)},children:[t.jsx(O,{"data-icon":"inline-start"}),"Reset all"]}),e[24]=p):p=e[24],e[25]!==c?(h=t.jsxs("div",{className:"flex items-center gap-2 p-3",children:[c,p]}),e[25]=c,e[26]=h):h=e[26],e[27]!==a?(d=a&&t.jsx(te,{variant:"destructive",className:"mx-3 mb-2 w-auto",children:t.jsxs(se,{children:[a," Press another shortcut or Esc to cancel."]})}),e[27]=a,e[28]=d):d=e[28],g=ae,N="h-[min(28rem,60vh)]",y="flex flex-col gap-4 px-3 pb-4",b=Q.map(i=>{const L=A.filter(o=>o.group===i);return L.length===0?null:t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:i}),L.map(o=>{const z=l===o.command;return t.jsxs("div",{className:"flex min-h-12 items-center gap-3 rounded-md px-2 py-1.5 hover:bg-accent",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm",children:o.label}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.description})]}),t.jsx(P,{variant:z?"secondary":"outline",size:"sm",className:"min-w-28 font-mono text-xs",onClick:()=>{r(null),x(z?null:o.command)},"aria-label":`Change shortcut for ${o.label}`,children:z?"Press keys…":Y(B[o.command])}),t.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>{_(o.command),G($()),r(null)},"aria-label":`Reset shortcut for ${o.label}`,children:t.jsx(O,{"data-icon":"inline-start"})})]},o.command)})]},i)}),e[3]=B,e[4]=a,e[5]=s,e[6]=l,e[7]=g,e[8]=j,e[9]=d,e[10]=y,e[11]=b,e[12]=N,e[13]=S,e[14]=w,e[15]=m,e[16]=u,e[17]=h}else g=e[7],j=e[8],d=e[9],y=e[10],b=e[11],N=e[12],S=e[13],w=e[14],m=e[15],u=e[16],h=e[17];let C;e[29]!==y||e[30]!==b?(C=t.jsx("div",{className:y,children:b}),e[29]=y,e[30]=b,e[31]=C):C=e[31];let v;e[32]!==g||e[33]!==C||e[34]!==N?(v=t.jsx(g,{className:N,children:C}),e[32]=g,e[33]=C,e[34]=N,e[35]=v):v=e[35];let R;return e[36]!==j||e[37]!==d||e[38]!==v||e[39]!==S||e[40]!==w||e[41]!==m||e[42]!==u||e[43]!==h?(R=t.jsxs(j,{className:S,showCloseButton:w,children:[m,u,h,d,v]}),e[36]=j,e[37]=d,e[38]=v,e[39]=S,e[40]=w,e[41]=m,e[42]=u,e[43]=h,e[44]=R):R=e[44],R}export{fe as KeyboardShortcutsDialog};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as Y,r as W,j as t}from"./vendor-react-gGw_S5I_.js";import{bf as Se,J as Z,bg as Ce,bh as ye,v as Ae,bi as ve,bj as de,aJ as De,B as H,bk as Pe,bl as _e,P as Ee,bm as Me,ba as ue,a$ as fe,A as me,be as $e,bn as oe,H as Re,T as ze,bo as Oe,bp as Ke,bq as Te,br as Le,bs as Fe,bt as Be,bu as Qe,bv as Ue,bw as He,bx as Ve,by as Ye,$ as le,L as Ge,M as Xe,Q as Je,bz as We,Z as Ze,bA as pe,bB as es,bC as ss,bD as ts,bE as ns,bF as is}from"./index-BVrmKCdP.js";import{n as xe,ak as ls,b as rs,al as os,am as as,an as cs,ao as ds,C as Ie,$ as us,ap as fs,S as ms,X as xs}from"./vendor-ui-Dfr2Rf5Q.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const gs=6;function ps(c){const e=Y.c(72),{recent:s,start:n}=c,[l,r]=W.useState(null),[i,x]=W.useState(""),a=l??s[0]??null;let u,h,d,f,o,g,m,b,p,j,v,N,w;if(e[0]!==l||e[1]!==a||e[2]!==s||e[3]!==n||e[4]!==i){h=(l&&!s.some(A=>he(A,l))?[l,...s]:[...s]).slice(0,gs);let z;e[18]!==i?(z=i.trim(),e[18]=i,e[19]=z):z=e[19];const F=z;u=!!(a&&F);let q;e[20]===Symbol.for("react.memo_cache_sentinel")?(q=(A,V)=>{r({dirName:A,cwd:V,name:V?ve(V):A})},e[20]=q):q=e[20],d=q;let T;e[21]!==n.defaultAgentKind?(T=A=>d(de(n.defaultAgentKind,A),A),e[21]=n.defaultAgentKind,e[22]=T):T=e[22],f=T;const G=a==null?void 0:a.cwd;let B;e[23]!==G||e[24]!==a?(B=a&&G?A=>r({...a,dirName:de(A,G)}):void 0,e[23]=G,e[24]=a,e[25]=B):B=e[25],m=B;let X;e[26]!==F||e[27]!==a||e[28]!==n?(X=A=>{A==null||A.preventDefault(),!(!a||!F)&&(n.onStart(a.dirName,a.cwd,F),x(""))},e[26]=F,e[27]=a,e[28]=n,e[29]=X):X=e[29],g=X;let J;e[30]!==g?(J=A=>{A.key==="Enter"&&!A.shiftKey&&!A.nativeEvent.isComposing&&(A.preventDefault(),g())},e[30]=g,e[31]=J):J=e[31],o=J,N="Start a session",w="flex min-w-0 flex-col gap-3",b="flex flex-wrap items-center gap-1.5",p="group",j="Projects",v=h.map(A=>{const V=a!==null&&he(A,a);return t.jsxs("button",{type:"button","aria-pressed":V,title:A.cwd??A.name,onClick:()=>r(A),className:Z("flex max-w-48 items-center gap-1.5 rounded-full border py-1 pl-1.5 pr-3 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",V?"border-foreground/80 bg-foreground text-background":"border-border/70 text-muted-foreground hover:border-foreground/40 hover:text-foreground"),children:[t.jsx(Se,{projectPath:A.cwd??null,fallback:t.jsx(xe,{className:"size-3.5","aria-hidden":"true"}),className:"size-4"}),t.jsx("span",{className:"truncate",children:A.name})]},A.cwd??A.dirName)}),e[0]=l,e[1]=a,e[2]=s,e[3]=n,e[4]=i,e[5]=u,e[6]=h,e[7]=d,e[8]=f,e[9]=o,e[10]=g,e[11]=m,e[12]=b,e[13]=p,e[14]=j,e[15]=v,e[16]=N,e[17]=w}else u=e[5],h=e[6],d=e[7],f=e[8],o=e[9],g=e[10],m=e[11],b=e[12],p=e[13],j=e[14],v=e[15],N=e[16],w=e[17];const I=h.length>0;let y;e[32]!==d||e[33]!==f||e[34]!==n.defaultAgentKind||e[35]!==I?(y=t.jsx(hs,{defaultAgentKind:n.defaultAgentKind,onChoose:d,onChooseFolder:f,anyListed:I}),e[32]=d,e[33]=f,e[34]=n.defaultAgentKind,e[35]=I,e[36]=y):y=e[36];let k;e[37]!==b||e[38]!==p||e[39]!==j||e[40]!==v||e[41]!==y?(k=t.jsxs("div",{className:b,role:p,"aria-label":j,children:[v,y]}),e[37]=b,e[38]=p,e[39]=j,e[40]=v,e[41]=y,e[42]=k):k=e[42];let D;e[43]!==l||e[44]!==a?(D=z=>{!l&&a&&r(a),x(z.target.value)},e[43]=l,e[44]=a,e[45]=D):D=e[45];const _=a?`Describe the task for ${a.name}`:"Pick a project, then describe the task";let S;e[46]!==o||e[47]!==D||e[48]!==_||e[49]!==i?(S=t.jsx(De,{"aria-label":"First message",value:i,onChange:D,onKeyDown:o,placeholder:_,rows:1,className:"max-h-48 min-h-9 flex-1 resize-none rounded-none border-0 bg-transparent px-0 py-2 shadow-none focus-visible:border-transparent focus-visible:ring-0"}),e[46]=o,e[47]=D,e[48]=_,e[49]=i,e[50]=S):S=e[50];let P;e[51]!==a||e[52]!==n.model||e[53]!==m?(P=a&&t.jsx(Ce,{isNewSession:!0,agentKind:ye(a.dirName),onAgentKindChange:m,selectedModel:n.model.selectedModel,onModelChange:n.model.onModelChange,selectedEffort:n.model.selectedEffort,onEffortChange:n.model.onEffortChange}),e[51]=a,e[52]=n.model,e[53]=m,e[54]=P):P=e[54];const R=!u;let M;e[55]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(ls,{"data-icon":"icon"}),e[55]=M):M=e[55];let E;e[56]!==R?(E=t.jsx(H,{type:"submit",size:"icon-xs",disabled:R,"aria-label":"Start session",title:"Start session (Enter)",children:M}),e[56]=R,e[57]=E):E=e[57];let C;e[58]!==P||e[59]!==E?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1 pb-0.5",children:[P,E]}),e[58]=P,e[59]=E,e[60]=C):C=e[60];let $;e[61]!==S||e[62]!==C?($=t.jsxs("div",{className:"flex items-end gap-2 rounded-xl border bg-popover py-2 pl-4 pr-2 shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",children:[S,C]}),e[61]=S,e[62]=C,e[63]=$):$=e[63];let O;e[64]!==g||e[65]!==$?(O=t.jsx("form",{onSubmit:g,className:"min-w-0",children:$}),e[64]=g,e[65]=$,e[66]=O):O=e[66];let K;return e[67]!==O||e[68]!==N||e[69]!==w||e[70]!==k?(K=t.jsxs("section",{"aria-label":N,className:w,children:[k,O]}),e[67]=O,e[68]=N,e[69]=w,e[70]=k,e[71]=K):K=e[71],K}function he(c,e){return c.cwd&&e.cwd?c.cwd===e.cwd:c.dirName===e.dirName}function hs(c){const e=Y.c(19),{defaultAgentKind:s,onChoose:n,onChooseFolder:l,anyListed:r}=c,[i,x]=W.useState(!1),a=Ae(i),u=r?"ghost":"outline";let h;e[0]!==u?(h=t.jsx(H,{variant:u,size:"xs",className:"rounded-full text-muted-foreground"}),e[0]=u,e[1]=h):h=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(xe,{"data-icon":"inline-start"}),e[2]=d):d=e[2];const f=r?"Other project":"Choose a project";let o;e[3]!==h||e[4]!==f?(o=t.jsxs(Pe,{render:h,children:[d,f]}),e[3]=h,e[4]=f,e[5]=o):o=e[5];let g;e[6]!==n?(g=(j,v)=>{x(!1),n(j,v)},e[6]=n,e[7]=g):g=e[7];let m;e[8]!==l?(m=j=>{x(!1),l(j)},e[8]=l,e[9]=m):m=e[9];let b;e[10]!==s||e[11]!==a||e[12]!==g||e[13]!==m?(b=t.jsx(_e,{align:"start",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:t.jsx(Ee,{projects:a,defaultAgentKind:s,onNewSession:g,onNewFolder:m})}),e[10]=s,e[11]=a,e[12]=g,e[13]=m,e[14]=b):b=e[14];let p;return e[15]!==i||e[16]!==o||e[17]!==b?(p=t.jsxs(Me,{open:i,onOpenChange:x,children:[o,b]}),e[15]=i,e[16]=o,e[17]=b,e[18]=p):p=e[18],p}function bs(c){const e={};for(const s of c)s.type==="boolean"?e[s.name]=s.defaultValue===!0:s.defaultValue!==void 0?e[s.name]=String(s.defaultValue):e[s.name]="";return e}function js(c,e){const s={};for(const n of c){const l=e[n.name];if(typeof l=="boolean"){s[n.name]=l;continue}l!==""&&(s[n.name]=n.type==="number"||n.type==="integer"?Number(l):l)}return s}function ws(c,e){return c.every(s=>{if(!s.required)return!0;const n=e[s.name];return typeof n=="boolean"?!0:n===""?!1:s.type==="number"||s.type==="integer"?Number.isFinite(Number(n)):!0})}function Ns(c){const e=Y.c(52),{request:s,responding:n,onAnswer:l}=c;let r;e[0]!==s.fields?(r=()=>bs(s.fields),e[0]=s.fields,e[1]=r):r=e[1];const[i,x]=W.useState(r);let a;e[2]!==s.fields||e[3]!==i?(a=ws(s.fields,i),e[2]=s.fields,e[3]=i,e[4]=a):a=e[4];const u=a,h=s.displayName||s.title||s.serverName;let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=(N,w)=>{x(I=>({...I,[N]:w}))},e[5]=d):d=e[5];const f=d;let o;e[6]!==l||e[7]!==s.requestId?(o=()=>l==null?void 0:l(s.requestId,{action:"decline"}),e[6]=l,e[7]=s.requestId,e[8]=o):o=e[8];const g=o;if(s.mode==="url"&&s.url){const N=s.url;let w;e[9]!==s.message?(w=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[9]=s.message,e[10]=w):w=e[10];let I;e[11]!==N?(I=t.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:N,children:N}),e[11]=N,e[12]=I):I=e[12];let y;e[13]!==g||e[14]!==l||e[15]!==s.requestId||e[16]!==n||e[17]!==N?(y=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsxs(H,{size:"sm",disabled:n,onClick:()=>{window.open(N,"_blank","noopener,noreferrer"),l(s.requestId,{action:"accept"})},children:["Open link",t.jsx(rs,{"data-icon":"inline-end"})]}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[13]=g,e[14]=l,e[15]=s.requestId,e[16]=n,e[17]=N,e[18]=y):y=e[18];let k;return e[19]!==h||e[20]!==w||e[21]!==I||e[22]!==y?(k=t.jsxs(be,{server:h,children:[w,I,y]}),e[19]=h,e[20]=w,e[21]=I,e[22]=y,e[23]=k):k=e[23],k}let m;e[24]!==s.message?(m=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[24]=s.message,e[25]=m):m=e[25];let b;if(e[26]!==l||e[27]!==s.fields||e[28]!==s.requestId||e[29]!==n||e[30]!==i){let N;e[32]!==l||e[33]!==s.requestId||e[34]!==n||e[35]!==i?(N=w=>t.jsx(ys,{id:`elicit-${s.requestId}-${w.name}`,field:w,value:i[w.name],disabled:n||!l,onChange:I=>f(w.name,I)},w.name),e[32]=l,e[33]=s.requestId,e[34]=n,e[35]=i,e[36]=N):N=e[36],b=s.fields.map(N),e[26]=l,e[27]=s.fields,e[28]=s.requestId,e[29]=n,e[30]=i,e[31]=b}else b=e[31];let p;e[37]!==b?(p=t.jsx("div",{className:"mt-3 flex flex-col gap-3",children:b}),e[37]=b,e[38]=p):p=e[38];let j;e[39]!==u||e[40]!==g||e[41]!==l||e[42]!==s.fields||e[43]!==s.requestId||e[44]!==n||e[45]!==i?(j=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx(H,{size:"sm",disabled:n||!u,onClick:()=>l(s.requestId,{action:"accept",content:js(s.fields,i)}),children:"Send"}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[39]=u,e[40]=g,e[41]=l,e[42]=s.fields,e[43]=s.requestId,e[44]=n,e[45]=i,e[46]=j):j=e[46];let v;return e[47]!==h||e[48]!==m||e[49]!==p||e[50]!==j?(v=t.jsxs(be,{server:h,children:[m,p,j]}),e[47]=h,e[48]=m,e[49]=p,e[50]=j,e[51]=v):v=e[51],v}function ys(c){const e=Y.c(55),{id:s,field:n,value:l,disabled:r,onChange:i}=c;if(n.type==="boolean"){const g=l===!0;let m;e[0]!==i?(m=v=>i(v===!0),e[0]=i,e[1]=m):m=e[1];let b;e[2]!==r||e[3]!==s||e[4]!==g||e[5]!==m?(b=t.jsx($e,{id:s,checked:g,disabled:r,onCheckedChange:m}),e[2]=r,e[3]=s,e[4]=g,e[5]=m,e[6]=b):b=e[6];let p;e[7]!==n?(p=t.jsx(ae,{field:n}),e[7]=n,e[8]=p):p=e[8];let j;return e[9]!==s||e[10]!==b||e[11]!==p?(j=t.jsxs(oe,{htmlFor:s,className:"items-start gap-2 font-normal",children:[b,p]}),e[9]=s,e[10]=b,e[11]=p,e[12]=j):j=e[12],j}if(n.type==="enum"){let g;e[13]!==n?(g=t.jsx(ae,{field:n}),e[13]=n,e[14]=g):g=e[14];let m;e[15]!==s||e[16]!==g?(m=t.jsx(oe,{htmlFor:s,children:g}),e[15]=s,e[16]=g,e[17]=m):m=e[17];let b;e[18]!==l?(b=typeof l=="string"&&l?[l]:[],e[18]=l,e[19]=b):b=e[19];let p;e[20]!==i?(p=y=>{y[0]&&i(y[0])},e[20]=i,e[21]=p):p=e[21];const j=n.label;let v;e[22]!==n.options?(v=n.options??[],e[22]=n.options,e[23]=v):v=e[23];let N;if(e[24]!==r||e[25]!==v){let y;e[27]!==r?(y=k=>t.jsx(Re,{value:k.value,disabled:r,className:"w-full justify-start px-3",children:k.label},k.value),e[27]=r,e[28]=y):y=e[28],N=v.map(y),e[24]=r,e[25]=v,e[26]=N}else N=e[26];let w;e[29]!==n.label||e[30]!==s||e[31]!==b||e[32]!==p||e[33]!==N?(w=t.jsx(ze,{id:s,value:b,onValueChange:p,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":j,children:N}),e[29]=n.label,e[30]=s,e[31]=b,e[32]=p,e[33]=N,e[34]=w):w=e[34];let I;return e[35]!==m||e[36]!==w?(I=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,w]}),e[35]=m,e[36]=w,e[37]=I):I=e[37],I}let x;e[38]!==n?(x=t.jsx(ae,{field:n}),e[38]=n,e[39]=x):x=e[39];let a;e[40]!==s||e[41]!==x?(a=t.jsx(oe,{htmlFor:s,children:x}),e[40]=s,e[41]=x,e[42]=a):a=e[42];const u=n.type==="string"?"text":"number",h=typeof l=="string"?l:"";let d;e[43]!==i?(d=g=>i(g.target.value),e[43]=i,e[44]=d):d=e[44];let f;e[45]!==r||e[46]!==n.label||e[47]!==s||e[48]!==u||e[49]!==h||e[50]!==d?(f=t.jsx(ue,{id:s,"aria-label":n.label,type:u,value:h,disabled:r,onChange:d}),e[45]=r,e[46]=n.label,e[47]=s,e[48]=u,e[49]=h,e[50]=d,e[51]=f):f=e[51];let o;return e[52]!==a||e[53]!==f?(o=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[a,f]}),e[52]=a,e[53]=f,e[54]=o):o=e[54],o}function ae(c){const e=Y.c(8),{field:s}=c;let n;e[0]!==s.required?(n=s.required&&t.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=s.required,e[1]=n):n=e[1];let l;e[2]!==s.description?(l=s.description&&t.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:s.description}),e[2]=s.description,e[3]=l):l=e[3];let r;return e[4]!==s.label||e[5]!==n||e[6]!==l?(r=t.jsxs("span",{className:"min-w-0",children:[s.label,n,l]}),e[4]=s.label,e[5]=n,e[6]=l,e[7]=r):r=e[7],r}function be(c){const e=Y.c(8),{server:s,children:n}=c;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(os,{className:"text-info"}),e[0]=l):l=e[0];let r;e[1]!==s?(r=t.jsxs(fe,{children:[s," needs input"]}),e[1]=s,e[2]=r):r=e[2];let i;e[3]!==n?(i=t.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=i):i=e[4];let x;return e[5]!==r||e[6]!==i?(x=t.jsxs(me,{className:"border-info/40 bg-info/5",children:[l,r,i]}),e[5]=r,e[6]=i,e[7]=x):x=e[7],x}function vs(c){const e=Y.c(15),{request:s,responding:n,onChoose:l}=c;let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(as,{className:"text-warning"}),i=t.jsx(fe,{children:"The agent declined this request"}),e[0]=r,e[1]=i):(r=e[0],i=e[1]);let x;e[2]!==s.originalModel?(x=t.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[s.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=s.originalModel,e[3]=x):x=e[3];let a;e[4]!==s.guidanceText?(a=s.guidanceText&&t.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:s.guidanceText}),e[4]=s.guidanceText,e[5]=a):a=e[5];let u;e[6]!==l||e[7]!==s.fallbackModel||e[8]!==s.requestId||e[9]!==n?(u=l&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(H,{size:"sm",disabled:n,onClick:()=>l(s.requestId,"retry_fallback"),children:["Retry on ",s.fallbackModel]}),t.jsx(H,{variant:"outline",size:"sm",disabled:n,onClick:()=>l(s.requestId,"edit_prompt"),children:"Edit prompt"}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,className:"ml-auto text-muted-foreground",onClick:()=>l(s.requestId,"cancelled"),children:"Dismiss"})]}),e[6]=l,e[7]=s.fallbackModel,e[8]=s.requestId,e[9]=n,e[10]=u):u=e[10];let h;return e[11]!==x||e[12]!==a||e[13]!==u?(h=t.jsxs(me,{className:"border-warning/40 bg-warning/5",children:[r,i,t.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[x,a,u]})]}),e[11]=x,e[12]=a,e[13]=u,e[14]=h):h=e[14],h}function Is(c){const e=Y.c(64),{request:s,input:n,canAnswer:l,onOpen:r}=c;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[x,a]=W.useState(i),{sessionId:u}=s;switch(s.kind){case"permission":{const h=s.request;let d;e[1]!==n.responding||e[2]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[1]=n.responding,e[2]=s.request.requestId,e[3]=d):d=e[3];let f;e[4]!==l||e[5]!==n||e[6]!==u?(f=l?(g,m)=>void n.respond(u,g,m):void 0,e[4]=l,e[5]=n,e[6]=u,e[7]=f):f=e[7];let o;return e[8]!==s.request||e[9]!==d||e[10]!==f?(o=t.jsx(Ke,{request:h,queued:0,responding:d,onRespond:f}),e[8]=s.request,e[9]=d,e[10]=f,e[11]=o):o=e[11],o}case"question":{const h=s.request;let d;e[12]!==n.responding||e[13]!==s.request.toolUseId?(d=n.responding.has(s.request.toolUseId),e[12]=n.responding,e[13]=s.request.toolUseId,e[14]=d):d=e[14];let f;e[15]!==x||e[16]!==s.request.toolUseId?(f=x.has(s.request.toolUseId),e[15]=x,e[16]=s.request.toolUseId,e[17]=f):f=e[17];let o;e[18]!==l||e[19]!==n||e[20]!==u?(o=l?async(m,b)=>{(await n.answerQuestion(u,m,b)).gone&&a(j=>new Set(j).add(m))}:void 0,e[18]=l,e[19]=n,e[20]=u,e[21]=o):o=e[21];let g;return e[22]!==r||e[23]!==s.request||e[24]!==d||e[25]!==f||e[26]!==o?(g=t.jsx(Oe,{request:h,responding:d,gone:f,onAnswer:o,onOpenSession:r}),e[22]=r,e[23]=s.request,e[24]=d,e[25]=f,e[26]=o,e[27]=g):g=e[27],g}case"elicitation":{const h=s.request;let d;e[28]!==n.responding||e[29]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[28]=n.responding,e[29]=s.request.requestId,e[30]=d):d=e[30];let f;e[31]!==l||e[32]!==n||e[33]!==u?(f=l?(g,m)=>void n.answerElicitation(u,g,m):void 0,e[31]=l,e[32]=n,e[33]=u,e[34]=f):f=e[34];let o;return e[35]!==s.request||e[36]!==d||e[37]!==f?(o=t.jsx(Ns,{request:h,responding:d,onAnswer:f}),e[35]=s.request,e[36]=d,e[37]=f,e[38]=o):o=e[38],o}case"dialog":{const h=s.request;let d;e[39]!==n.responding||e[40]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[39]=n.responding,e[40]=s.request.requestId,e[41]=d):d=e[41];let f;e[42]!==l||e[43]!==n||e[44]!==u?(f=l?(g,m)=>void n.answerDialog(u,g,m):void 0,e[42]=l,e[43]=n,e[44]=u,e[45]=f):f=e[45];let o;return e[46]!==s.request||e[47]!==d||e[48]!==f?(o=t.jsx(vs,{request:h,responding:d,onChoose:f}),e[46]=s.request,e[47]=d,e[48]=f,e[49]=o):o=e[49],o}case"plan":case"deferred":{let h;e[50]!==s.kind?(h=s.kind==="plan"?t.jsx(cs,{className:"text-warning"}):t.jsx(ds,{className:"text-warning"}),e[50]=s.kind,e[51]=h):h=e[51];const d=s.kind==="plan"?"A plan is waiting for review":"A permission was deferred";let f;e[52]!==d?(f=t.jsx(fe,{children:d}),e[52]=d,e[53]=f):f=e[53];const o=s.kind==="plan"?"Review it in its session.":"Open the session and resume it to answer.";let g;e[54]!==o?(g=t.jsx("p",{className:"col-start-2 mt-1 text-sm text-muted-foreground",children:o}),e[54]=o,e[55]=g):g=e[55];let m;e[56]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ie,{"data-icon":"inline-end"}),e[56]=m):m=e[56];let b;e[57]!==r?(b=t.jsx("div",{className:"col-start-2 mt-2",children:t.jsxs(H,{size:"xs",onClick:r,children:["Open session",m]})}),e[57]=r,e[58]=b):b=e[58];let p;return e[59]!==h||e[60]!==f||e[61]!==g||e[62]!==b?(p=t.jsxs(me,{className:"border-warning/40 bg-warning/5",children:[h,f,g,b]}),e[59]=h,e[60]=f,e[61]=g,e[62]=b,e[63]=p):p=e[63],p}}}function ks(c,e,s=()=>!0){const n=new Map(e.map(i=>[i.sessionId,i])),l=i=>{const x=n.get(i);return x?Be(x):Date.now()},r=[];for(const[i,x]of c.permissionsBySession)for(const a of x)r.push({kind:"permission",sessionId:i,since:a.timestamp,request:a});for(const[i,x]of c.questionsBySession)for(const a of x)r.push({kind:"question",sessionId:i,since:a.askedAt,request:a});for(const[i,x]of c.elicitationsBySession)for(const a of x)r.push({kind:"elicitation",sessionId:i,since:a.askedAt,request:a});for(const[i,x]of c.dialogsBySession)for(const a of x)r.push({kind:"dialog",sessionId:i,since:a.askedAt,request:a});for(const i of c.awaitingPlan)r.push({kind:"plan",sessionId:i,since:l(i)});for(const i of e)i.agentStatus==="deferred"&&!i.archived&&r.push({kind:"deferred",sessionId:i.sessionId,since:l(i.sessionId)});return r.filter(i=>s(i.sessionId)).sort((i,x)=>i.since-x.since)}function je(c){switch(c.kind){case"permission":return c.request.requestId;case"question":return c.request.toolUseId;case"elicitation":case"dialog":return c.request.requestId;default:return`${c.kind}:${c.sessionId}`}}const qs=7*864e5,we=3,Ss=30,Cs=50;function As(c,e){const s=c.filter(r=>!r.archived&&!(r.teamName&&r.agentName)),{topLevel:n,crewOf:l}=Te(s);return n.map(r=>{const i=l.get(r.sessionId)??[],x=i.length?Le(r,i):r.lastActivityAt||r.lastModified,a=[r,...i].flatMap(u=>(u.pullRequests??[]).map(h=>({pullRequest:h,by:u}))).sort((u,h)=>Date.parse(h.pullRequest.timestamp)-Date.parse(u.pullRequest.timestamp))[0];return{session:r,state:e(r).state,members:i,cells:i.map(u=>e(u).state),counts:i.length?Fe(i,e):null,activityAt:x,...a&&{landed:{number:a.pullRequest.number,title:a.pullRequest.title,url:a.pullRequest.url,by:a.by}}}}).sort((r,i)=>Date.parse(i.activityAt)-Date.parse(r.activityAt))}function Ds(c,e=Date.now()){const s=c.filter(n=>e-Date.parse(n.activityAt)<qs);return(s.length>=we?s:c.slice(0,we)).slice(0,Ss)}function Ps(c,e,s=6){const n=[],l=new Set;for(const r of c){const i=e(r.session);if(!(!i.cwd||l.has(i.cwd))&&(l.add(i.cwd),n.push(i),n.length===s))break}return n}function _s(c,e,s){const n=e.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[]:c.filter(l=>{const r=s(l).filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase();return n.every(i=>r.includes(i))}).slice(0,Cs)}const Es={working:"bg-success shadow-[0_0_0_1.5px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40"};function Ms(c,e){const s=c.cwd?is(c.cwd):null,n=(s==null?void 0:s.parentPath)??c.cwd,l=s?de(ye(c.dirName),s.parentPath):c.dirName;return{dirName:l,cwd:n,name:e[l]??(n?ve(n):c.projectShortName)}}function $s(c){const e=c.target instanceof HTMLElement&&c.target.closest("input,textarea,select,[contenteditable=true]");return!c.metaKey&&!c.ctrlKey&&!c.altKey&&!e}function Gs(c){const e=Y.c(81),{onOpenSession:s,onBrowseProjects:n,start:l}=c,r=Qe(),i=Ue(),{names:x,rename:a}=He(),{names:u}=Ve(),h=Ye(),[d,f]=W.useState(""),o=W.useRef(null);let g;e[0]!==r.sessions?(g=r.sessions.filter(Os),e[0]=r.sessions,e[1]=g):g=e[1];const m=g;let b;e[2]!==m?(b=new Map(m.map(zs)),e[2]=m,e[3]=b):b=e[3];const p=b;let j;e[4]!==i.awaitingDialog||e[5]!==i.awaitingElicitation?(j=new Set([...i.awaitingElicitation,...i.awaitingDialog]),e[4]=i.awaitingDialog,e[5]=i.awaitingElicitation,e[6]=j):j=e[6];let v;e[7]!==i.awaitingPermission||e[8]!==i.awaitingPlan||e[9]!==i.awaitingQuestion||e[10]!==j?(v={awaitingPermission:i.awaitingPermission,awaitingQuestion:i.awaitingQuestion,awaitingPrompt:j,awaitingPlan:i.awaitingPlan},e[7]=i.awaitingPermission,e[8]=i.awaitingPlan,e[9]=i.awaitingQuestion,e[10]=j,e[11]=v):v=e[11];const N=v;let w;e[12]!==r.procBySession||e[13]!==N?(w=Q=>es(Q,r.procBySession,N),e[12]=r.procBySession,e[13]=N,e[14]=w):w=e[14];const I=w;let y;e[15]!==p||e[16]!==h?(y=Q=>{const L=p.get(Q);return h(L==null?void 0:L.access).canInteract},e[15]=p,e[16]=h,e[17]=y):y=e[17];const k=y;let D;e[18]!==k||e[19]!==i||e[20]!==m?(D=ks(i,m,k),e[18]=k,e[19]=i,e[20]=m,e[21]=D):D=e[21];const _=D;let S;e[22]!==p||e[23]!==x?(S=Q=>ss(Q,p,x),e[22]=p,e[23]=x,e[24]=S):S=e[24];const P=S;let R;e[25]!==u?(R=Q=>u[Q.dirName]??ts(Q),e[25]=u,e[26]=R):R=e[26];const M=R;let E,C,$;if(e[27]!==P||e[28]!==M||e[29]!==u||e[30]!==d||e[31]!==m||e[32]!==I){E=As(m,I),$=d.trim().length>0?_s(E,d,U=>{var ge;return[P(U.session.sessionId),M(U.session),U.session.gitBranch,U.session.cwd,U.session.lastUserMessage,U.session.firstUserMessage,(ge=U.landed)==null?void 0:ge.title,U.landed&&`#${U.landed.number}`,...U.members.map(qe=>P(qe.sessionId))]}):Ds(E);let L;e[36]!==u?(L=U=>Ms(U,u),e[36]=u,e[37]=L):L=e[37],C=Ps(E,L),e[27]=P,e[28]=M,e[29]=u,e[30]=d,e[31]=m,e[32]=I,e[33]=E,e[34]=C,e[35]=$}else E=e[33],C=e[34],$=e[35];const O=C;let K;e[38]!==p||e[39]!==s?(K=Q=>{const L=p.get(Q);L?s(L.dirName,L.fileName):ns(Q)},e[38]=p,e[39]=s,e[40]=K):K=e[40];const z=K;let F;e[41]!==r.processes?(F=r.processes.filter(Rs),e[41]=r.processes,e[42]=F):F=e[42];const q=F.length;let T,G;e[43]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const Q=L=>{var U;L.key==="/"&&$s(L)&&(L.preventDefault(),(U=o.current)==null||U.focus())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},G=[],e[43]=T,e[44]=G):(T=e[43],G=e[44]),W.useEffect(T,G);let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Mission Control"}),e[45]=B):B=e[45];let X;e[46]!==q?(X=q>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[q," ",q===1?"agent":"agents"," running on this machine"]}),e[46]=q,e[47]=X):X=e[47];let J;e[48]!==X?(J=t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[B,X]}),e[48]=X,e[49]=J):J=e[49];let A;e[50]!==O||e[51]!==l?(A=l&&t.jsx(ps,{recent:O,start:l}),e[50]=O,e[51]=l,e[52]=A):A=e[52];let V;e[53]!==J||e[54]!==A?(V=t.jsxs("div",{className:"mx-auto flex w-full max-w-6xl shrink-0 flex-col gap-8 px-6 pt-16 lg:px-10",children:[J,A]}),e[53]=J,e[54]=A,e[55]=V):V=e[55];const re=_.length>0&&"lg:grid lg:grid-cols-[minmax(0,380px)_minmax(0,1fr)] lg:grid-rows-[minmax(0,1fr)]";let ee;e[56]!==re?(ee=Z("mx-auto flex w-full max-w-6xl flex-col gap-8 px-6 pb-10 pt-10 lg:h-full lg:px-10",re),e[56]=re,e[57]=ee):ee=e[57];let se;e[58]!==p||e[59]!==k||e[60]!==i||e[61]!==P||e[62]!==z||e[63]!==_?(se=_.length>0?t.jsx(Ks,{queue:_,input:i,byId:p,nameOf:P,onOpen:z,canAnswer:k}):t.jsxs("p",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success/40","aria-hidden":"true"}),"Nothing is waiting on you."]}),e[58]=p,e[59]=k,e[60]=i,e[61]=P,e[62]=z,e[63]=_,e[64]=se):se=e[64];let te;e[65]!==P||e[66]!==n||e[67]!==z||e[68]!==M||e[69]!==d||e[70]!==a||e[71]!==E.length||e[72]!==$?(te=t.jsx(Ls,{sessions:$,total:E.length,query:d,onQueryChange:f,searchRef:o,nameOf:P,projectLabel:M,onOpen:z,onRename:a,onBrowseProjects:n}),e[65]=P,e[66]=n,e[67]=z,e[68]=M,e[69]=d,e[70]=a,e[71]=E.length,e[72]=$,e[73]=te):te=e[73];let ne;e[74]!==ee||e[75]!==se||e[76]!==te?(ne=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto lg:overflow-hidden",children:t.jsxs("div",{className:ee,children:[se,te]})}),e[74]=ee,e[75]=se,e[76]=te,e[77]=ne):ne=e[77];let ie;return e[78]!==V||e[79]!==ne?(ie=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[V,ne]}),e[78]=V,e[79]=ne,e[80]=ie):ie=e[80],ie}function Rs(c){return c.sessionId}function zs(c){return[c.sessionId,c]}function Os(c){return!c.archived}function ke(c){const e=Y.c(9),{title:s,count:n,children:l}=c;let r;e[0]!==s?(r=t.jsx("h2",{className:"text-sm font-medium",children:s}),e[0]=s,e[1]=r):r=e[1];let i;e[2]!==n?(i=n!==void 0&&t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n}),e[2]=n,e[3]=i):i=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("span",{className:"flex-1"}),e[4]=x):x=e[4];let a;return e[5]!==l||e[6]!==r||e[7]!==i?(a=t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r,i,x,l]}),e[5]=l,e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function ce(c,e){const s=c==null?void 0:c.crew;return s?e(s.rootId)??s.rootTitle??null:null}const Ne={permission:"asked a permission",question:"asked a question",elicitation:"asked for input",dialog:"needs a choice",plan:"has a plan to review",deferred:"has a deferred permission"};function Ks(c){const e=Y.c(71),{queue:s,input:n,byId:l,nameOf:r,onOpen:i,canAnswer:x}=c,[a,u]=W.useState(0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=new Set,e[0]=h):h=e[0];const d=W.useRef(h),f=Math.min(a,s.length-1),o=s[f];let g;if(e[1]!==l||e[2]!==r||e[3]!==o.sessionId){const q=l.get(o.sessionId);g=ce(q,r),e[1]=l,e[2]=r,e[3]=o.sessionId,e[4]=g}else g=e[4];const m=g;let b;e[5]!==f||e[6]!==x||e[7]!==n||e[8]!==i||e[9]!==s.length||e[10]!==o.kind||e[11]!==o.request||e[12]!==o.sessionId?(b=q=>{const T=q.target;if(!(T.closest("input,textarea,select,[contenteditable=true]")||q.metaKey||q.ctrlKey||q.altKey)&&((q.key==="j"||q.key==="n"||q.key==="ArrowDown")&&(q.preventDefault(),u(Math.min(s.length-1,f+1))),(q.key==="k"||q.key==="ArrowUp")&&(q.preventDefault(),u(Math.max(0,f-1))),q.key==="o"&&(q.preventDefault(),i(o.sessionId)),(q.key==="Enter"||q.key==="d")&&T===q.currentTarget&&x(o.sessionId))){if(o.kind!=="permission")return;const G=q.key==="d"||o.request.defaultToNo?"deny":"allow",B=o.request.requestId;if(o.request.availableDecisions&&!o.request.availableDecisions.includes(G)||(q.preventDefault(),d.current.has(B)||n.responding.has(B)))return;d.current.add(B),n.respond(o.sessionId,B,G).finally(()=>d.current.delete(B))}},e[5]=f,e[6]=x,e[7]=n,e[8]=i,e[9]=s.length,e[10]=o.kind,e[11]=o.request,e[12]=o.sessionId,e[13]=b):b=e[13];const p=b;let j;e[14]!==f||e[15]!==s.length?(j=s.length>1&&t.jsxs("span",{className:"flex items-center gap-1 text-xs tabular-nums text-muted-foreground",children:[f+1," of ",s.length,t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:f===0,onClick:()=>u(f-1),children:t.jsx(us,{"data-icon":"inline-start"})}),t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:f===s.length-1,onClick:()=>u(f+1),children:t.jsx(Ie,{"data-icon":"inline-start"})})]}),e[14]=f,e[15]=s.length,e[16]=j):j=e[16];let v;e[17]!==s.length||e[18]!==j?(v=t.jsx(ke,{title:"Needs you",count:s.length,children:j}),e[17]=s.length,e[18]=j,e[19]=v):v=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-warning","aria-hidden":"true"}),e[20]=N):N=e[20];let w;e[21]!==i||e[22]!==o.sessionId?(w=()=>i(o.sessionId),e[21]=i,e[22]=o.sessionId,e[23]=w):w=e[23];let I;e[24]!==r||e[25]!==o.sessionId?(I=r(o.sessionId)??"A session",e[24]=r,e[25]=o.sessionId,e[26]=I):I=e[26];let y;e[27]!==w||e[28]!==I?(y=t.jsx("button",{type:"button",onClick:w,className:"min-w-0 truncate rounded-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:I}),e[27]=w,e[28]=I,e[29]=y):y=e[29];let k;e[30]!==m?(k=m&&t.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:["· ",m]}),e[30]=m,e[31]=k):k=e[31];let D;e[32]!==o.since?(D=le(new Date(o.since).toISOString()),e[32]=o.since,e[33]=D):D=e[33];let _;e[34]!==D?(_=t.jsxs("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-warning",children:["waiting ",D]}),e[34]=D,e[35]=_):_=e[35];let S;e[36]!==k||e[37]!==_||e[38]!==y?(S=t.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-[13px]",children:[N,y,k,_]}),e[36]=k,e[37]=_,e[38]=y,e[39]=S):S=e[39];const P=Ne[o.kind];let R;e[40]!==P?(R=t.jsx("p",{className:"px-0.5 text-xs text-muted-foreground",children:P}),e[40]=P,e[41]=R):R=e[41];let M;e[42]!==o?(M=je(o),e[42]=o,e[43]=M):M=e[43];let E;e[44]!==x||e[45]!==o.sessionId?(E=x(o.sessionId),e[44]=x,e[45]=o.sessionId,e[46]=E):E=e[46];let C;e[47]!==i||e[48]!==o.sessionId?(C=()=>i(o.sessionId),e[47]=i,e[48]=o.sessionId,e[49]=C):C=e[49];let $;e[50]!==n||e[51]!==o||e[52]!==M||e[53]!==E||e[54]!==C?($=t.jsx(Is,{request:o,input:n,canAnswer:E,onOpen:C},M),e[50]=n,e[51]=o,e[52]=M,e[53]=E,e[54]=C,e[55]=$):$=e[55];let O;e[56]!==S||e[57]!==R||e[58]!==$?(O=t.jsxs("div",{className:"flex flex-col gap-2",children:[S,R,$]}),e[56]=S,e[57]=R,e[58]=$,e[59]=O):O=e[59];let K;e[60]!==f||e[61]!==l||e[62]!==r||e[63]!==s?(K=s.length>1&&t.jsx("ol",{className:"mt-3 flex flex-col","aria-label":"Also waiting",children:s.map((q,T)=>T===f?null:t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>u(T),className:"grid w-full grid-cols-[18px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg px-2 py-2 text-left text-[12.5px] outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{className:"text-right text-[11px] tabular-nums text-muted-foreground/80",children:T+1}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsxs("span",{className:"truncate font-medium",children:[r(q.sessionId)??"A session",ce(l.get(q.sessionId),r)&&t.jsxs("span",{className:"font-normal text-muted-foreground",children:[" · ",ce(l.get(q.sessionId),r)]})]}),t.jsx("span",{className:"truncate text-[11.5px] text-muted-foreground",children:Ne[q.kind]})]}),t.jsx("span",{className:"text-[11px] tabular-nums text-warning",children:le(new Date(q.since).toISOString())})]})},je(q)))}),e[60]=f,e[61]=l,e[62]=r,e[63]=s,e[64]=K):K=e[64];let z;e[65]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("p",{className:"mt-2 px-0.5 text-[11px] text-muted-foreground/80",children:"J / K move · Enter answers · D denies · O opens"}),e[65]=z):z=e[65];let F;return e[66]!==p||e[67]!==O||e[68]!==K||e[69]!==v?(F=t.jsxs("section",{"aria-label":"Needs you",tabIndex:0,onKeyDown:p,className:"min-w-0 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring lg:min-h-0 lg:overflow-y-auto",children:[v,O,K,z]}),e[66]=p,e[67]=O,e[68]=K,e[69]=v,e[70]=F):F=e[70],F}function Ts(c){var e,s;return c.state==="needs-you"||(((e=c.counts)==null?void 0:e.needsYou)??0)>0?pe.attention:c.state==="working"||(((s=c.counts)==null?void 0:s.working)??0)>0?pe.working:null}function Ls(c){const e=Y.c(39),{sessions:s,total:n,query:l,onQueryChange:r,searchRef:i,nameOf:x,projectLabel:a,onOpen:u,onRename:h,onBrowseProjects:d}=c;let f;e[0]!==l?(f=l.trim(),e[0]=l,e[1]=f):f=e[1];const o=f.length>0;let g;e[2]!==r||e[3]!==i?(g=()=>{var S;r(""),(S=i.current)==null||S.focus()},e[2]=r,e[3]=i,e[4]=g):g=e[4];const m=g,b=o?s.length:n;let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(ms,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),e[5]=p):p=e[5];let j;e[6]!==r?(j=S=>r(S.target.value),e[6]=r,e[7]=j):j=e[7];let v;e[8]!==m||e[9]!==i?(v=S=>{var P;S.key==="Escape"&&(S.preventDefault(),m(),(P=i.current)==null||P.blur())},e[8]=m,e[9]=i,e[10]=v):v=e[10];let N;e[11]!==l||e[12]!==i||e[13]!==j||e[14]!==v?(N=t.jsx(ue,{ref:i,type:"search","aria-label":"Search sessions",placeholder:"Search sessions",value:l,onChange:j,onKeyDown:v,className:"h-7 pl-8 pr-7 text-xs [&::-webkit-search-cancel-button]:hidden"}),e[11]=l,e[12]=i,e[13]=j,e[14]=v,e[15]=N):N=e[15];let w;e[16]!==m||e[17]!==o?(w=o?t.jsx("button",{type:"button","aria-label":"Clear search",onClick:m,className:"absolute right-1.5 top-1/2 flex size-4 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(xs,{className:"size-3"})}):t.jsx("kbd",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 font-mono text-[10px] text-muted-foreground/70","aria-hidden":"true",children:"/"}),e[16]=m,e[17]=o,e[18]=w):w=e[18];let I;e[19]!==N||e[20]!==w?(I=t.jsxs("div",{className:"relative w-full max-w-64",children:[p,N,w]}),e[19]=N,e[20]=w,e[21]=I):I=e[21];let y;e[22]!==d?(y=d&&t.jsxs(H,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:d,children:[t.jsx(xe,{"data-icon":"inline-start"}),"All projects"]}),e[22]=d,e[23]=y):y=e[23];let k;e[24]!==y||e[25]!==b||e[26]!==I?(k=t.jsxs(ke,{title:"Your sessions",count:b,children:[I,y]}),e[24]=y,e[25]=b,e[26]=I,e[27]=k):k=e[27];let D;e[28]!==x||e[29]!==u||e[30]!==h||e[31]!==a||e[32]!==l||e[33]!==o||e[34]!==s?(D=s.length===0?t.jsx(Ge,{children:t.jsx(Xe,{children:t.jsx(Je,{children:o?`No session matches “${l.trim()}”.`:"Start a session and it shows up here, with every session it starts."})})}):t.jsx("ul",{className:"flex flex-col lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:s.map(S=>t.jsx(Fs,{entry:S,nameOf:x,projectLabel:a,onOpen:u,onRename:h},S.session.sessionId))}),e[28]=x,e[29]=u,e[30]=h,e[31]=a,e[32]=l,e[33]=o,e[34]=s,e[35]=D):D=e[35];let _;return e[36]!==k||e[37]!==D?(_=t.jsxs("section",{"aria-label":"Your sessions",className:"flex min-w-0 flex-col lg:min-h-0 lg:flex-1",children:[k,D]}),e[36]=k,e[37]=D,e[38]=_):_=e[38],_}function Fs(c){const e=Y.c(63),{entry:s,nameOf:n,projectLabel:l,onOpen:r,onRename:i}=c,[x,a]=W.useState(null),{session:u}=s;let h;e[0]!==n||e[1]!==u.sessionId?(h=n(u.sessionId)??"Untitled session",e[0]=n,e[1]=u.sessionId,e[2]=h):h=e[2];const d=h;let f;e[3]!==u?(f=We(u),e[3]=u,e[4]=f):f=e[4];const o=f;let g,m,b;if(e[5]!==x||e[6]!==s||e[7]!==n||e[8]!==r||e[9]!==i||e[10]!==o||e[11]!==l||e[12]!==u||e[13]!==d){const v=Ts(s);let N;e[17]!==x||e[18]!==i||e[19]!==o||e[20]!==u.sessionId||e[21]!==d?(N=()=>{if(x===null)return;const C=x.trim();a(null),C!==d&&i(u.sessionId,C===o?"":C)},e[17]=x,e[18]=i,e[19]=o,e[20]=u.sessionId,e[21]=d,e[22]=N):N=e[22];const w=N;let I;e[23]!==s.counts||e[24]!==u.isActive?(I=s.counts?t.jsxs(t.Fragment,{children:[s.counts.working>0&&t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.working})," working"]}),s.counts.needsYou>0&&t.jsxs("span",{className:"text-warning",children:[t.jsx("span",{className:"font-medium tabular-nums",children:s.counts.needsYou})," need you"]}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.size})," in crew"]})]}):u.isActive&&t.jsx("span",{children:"working"}),e[23]=s.counts,e[24]=u.isActive,e[25]=I):I=e[25];let y;e[26]!==I?(y=t.jsx("span",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:I}),e[26]=I,e[27]=y):y=e[27];let k;e[28]!==s.landed?(k=s.landed&&t.jsxs(Ze,{variant:"outline",className:"shrink-0",children:["#",s.landed.number]}),e[28]=s.landed,e[29]=k):k=e[29];let D;e[30]!==s.landed||e[31]!==n||e[32]!==u.lastUserMessage?(D=s.landed?`${s.landed.title??"Pull request"} · ${n(s.landed.by.sessionId)??""}`:u.lastUserMessage??"",e[30]=s.landed,e[31]=n,e[32]=u.lastUserMessage,e[33]=D):D=e[33];let _;e[34]!==D?(_=t.jsx("span",{className:"truncate",children:D}),e[34]=D,e[35]=_):_=e[35];let S;e[36]!==_||e[37]!==k?(S=t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[k,_]}),e[36]=_,e[37]=k,e[38]=S):S=e[38];let P;e[39]!==s.activityAt||e[40]!==s.counts?(P=s.counts?`crew active ${le(s.activityAt)}`:le(s.activityAt),e[39]=s.activityAt,e[40]=s.counts,e[41]=P):P=e[41];let R;e[42]!==P?(R=t.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:P}),e[42]=P,e[43]=R):R=e[43];let M;e[44]!==S||e[45]!==R||e[46]!==y?(M=t.jsxs(t.Fragment,{children:[y,S,R]}),e[44]=S,e[45]=R,e[46]=y,e[47]=M):M=e[47];const E=M;g="group/row relative border-t border-border/70 first:border-t-0",e[48]!==s.cells||e[49]!==s.members||e[50]!==n||e[51]!==r||e[52]!==d?(m=s.members.length>0&&t.jsx("div",{role:"group","aria-label":`${d} crew`,className:"flex flex-wrap gap-1 px-3 pt-3",children:s.members.map((C,$)=>t.jsx("button",{type:"button","aria-label":`Open ${n(C.sessionId)??"crew member"}`,title:`${n(C.sessionId)}: ${s.cells[$]}`,onClick:()=>r(C.sessionId),className:"flex size-5 items-center justify-center rounded-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx("span",{className:Z("size-2 rounded-[2px]",Es[s.cells[$]])})},C.sessionId))}),e[48]=s.cells,e[49]=s.members,e[50]=n,e[51]=r,e[52]=d,e[53]=m):m=e[53],b=x===null?t.jsxs("button",{type:"button",onClick:()=>r(u.sessionId),className:Z("grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]","outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[v&&t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",v),"aria-hidden":"true"}),t.jsx("span",{className:"truncate text-[13.5px] font-medium",children:d}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:l(u)})]}),E]}):t.jsxs("div",{className:"grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[v&&t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",v),"aria-hidden":"true"}),t.jsx(ue,{autoFocus:!0,"aria-label":"Session name",value:x,placeholder:o,onChange:C=>a(C.target.value),onFocus:Bs,onBlur:w,onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),w()),C.key==="Escape"&&(C.preventDefault(),a(null))},className:"h-7 max-w-md text-[13.5px] font-medium"}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:l(u)})]}),E]}),e[5]=x,e[6]=s,e[7]=n,e[8]=r,e[9]=i,e[10]=o,e[11]=l,e[12]=u,e[13]=d,e[14]=g,e[15]=m,e[16]=b}else g=e[14],m=e[15],b=e[16];let p;e[54]!==x||e[55]!==s.members.length||e[56]!==d?(p=x===null&&t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":`Rename ${d}`,title:"Rename",onClick:()=>a(d),className:Z("absolute right-2 text-muted-foreground opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",s.members.length>0?"top-[42px]":"top-2.5"),children:t.jsx(fs,{"data-icon":"icon"})}),e[54]=x,e[55]=s.members.length,e[56]=d,e[57]=p):p=e[57];let j;return e[58]!==g||e[59]!==m||e[60]!==b||e[61]!==p?(j=t.jsxs("li",{className:g,children:[m,b,p]}),e[58]=g,e[59]=m,e[60]=b,e[61]=p,e[62]=j):j=e[62],j}function Bs(c){return c.target.select()}export{Gs as MissionHome};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-
|
|
1
|
+
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-BVrmKCdP.js";import"./vendor-ui-Dfr2Rf5Q.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const E=x.memo(function(c){const e=d.c(10),{open:l,onClose:a,session:r,sessionChangeKey:h}=c;let i;e[0]!==a?(i=m=>{m||a()},e[0]=a,e[1]=i):i=e[1];let t;e[2]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs(p,{className:"shrink-0 px-4 py-3",children:[s.jsx(f,{children:"File changes"}),s.jsx(j,{className:"sr-only",children:"Review files changed in this session."})]}),e[2]=t):t=e[2];let n;e[3]!==r||e[4]!==h?(n=s.jsxs(g,{side:"bottom",className:"h-[72svh] max-h-[92svh] rounded-t-xl",children:[t,s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(C,{session:r,sessionChangeKey:h})})]}),e[3]=r,e[4]=h,e[5]=n):n=e[5];let o;return e[6]!==l||e[7]!==i||e[8]!==n?(o=s.jsx(S,{open:l,onOpenChange:i,children:n}),e[6]=l,e[7]=i,e[8]=n,e[9]=o):o=e[9],o});export{E as MobileFileChanges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as ue,r as C,j as t}from"./vendor-react-gGw_S5I_.js";import{C as Z,b7 as Ie,bw as X,bE as Ze,bx as Re,bF as Xe,b5 as de,B as E,z as Fe,bG as et,bH as Ge,bI as Ke,bJ as Je,bK as We,bL as Qe,bM as Ye,A as se,p as ne,bN as tt,Z as $e,bO as st,bP as qe,a8 as nt,a9 as it,ac as lt,a6 as at,ab as ot,aa as rt,a5 as ct,a4 as dt,b6 as De,bQ as ut,bR as ft,D as ht,h as mt,i as pt,j as xt,k as gt,bS as jt,bT as bt,bU as vt,bV as Ae,bW as Oe,L as yt,M as Ct,N as wt,O as Nt,Q as St}from"./index-NgN68ZoJ.js";import{a as kt,ar as $t}from"./vendor-ui-Dxtv9P3W.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function Be(l){const e=l.trim().replace(/^v/i,"").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);return e?{parts:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]?e[4].split("."):[]}:null}function Dt(l,e){if(l.length===0&&e.length===0)return 0;if(l.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(l.length,e.length);s+=1){const i=l[s],r=e[s];if(i===void 0)return-1;if(r===void 0)return 1;const a=/^\d+$/.test(i),n=/^\d+$/.test(r);if(a&&n){if(Number(i)!==Number(r))return Number(i)<Number(r)?-1:1;continue}if(a!==n)return a?-1:1;if(i!==r)return i<r?-1:1}return 0}function It(l,e){const s=Be(l),i=Be(e);if(!s||!i)return null;for(let r=0;r<3;r+=1)if(s.parts[r]!==i.parts[r])return s.parts[r]<i.parts[r]?-1:1;return Dt(s.prerelease,i.prerelease)}function Me(l){const e=ue.c(33),{value:s,onChange:i,projects:r,disabled:a}=l,n=a===void 0?!1:a,d=C.useId();let o;e[0]!==s.projectIds||e[1]!==s.type?(o=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=o):o=e[2];let v;e[3]!==o?(v=new Set(o),e[3]=o,e[4]=v):v=e[4];const y=v;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Ze,{children:"Available in"}),e[5]=h):h=e[5];const w=`${d}-all`,j=s.type==="all";let c;e[6]!==i?(c=N=>i(N?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==n||e[9]!==w||e[10]!==j||e[11]!==c?(p=t.jsx(Ie,{id:w,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=w,e[10]=j,e[11]=c,e[12]=p):p=e[12];const m=`${d}-all`;let x;e[13]!==m?(x=t.jsx(X,{htmlFor:m,children:"All projects on this host, including new projects"}),e[13]=m,e[14]=x):x=e[14];let g;e[15]!==x||e[16]!==p?(g=t.jsxs(Z,{orientation:"horizontal",children:[p,x]}),e[15]=x,e[16]=p,e[17]=g):g=e[17];let b;e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==r||e[22]!==y||e[23]!==s.projectIds||e[24]!==s.type?(b=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:r.map(N=>t.jsxs(Z,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-${N.id}`,checked:y.has(N.id),disabled:n,onCheckedChange:D=>i({type:"projects",projectIds:D?[...s.projectIds,N.id]:s.projectIds.filter(R=>R!==N.id)})}),t.jsx(X,{htmlFor:`${d}-${N.id}`,children:N.name})]},N.id))}),e[18]=n,e[19]=d,e[20]=i,e[21]=r,e[22]=y,e[23]=s.projectIds,e[24]=s.type,e[25]=b):b=e[25];const k=s.type==="projects"&&s.projectIds.length===0?"Installed but hidden until you choose a project.":"This setting is shared by every client connected to this host.";let S;e[26]!==k?(S=t.jsx(Re,{children:k}),e[26]=k,e[27]=S):S=e[27];let u;return e[28]!==n||e[29]!==g||e[30]!==b||e[31]!==S?(u=t.jsxs(Xe,{disabled:n,children:[h,g,b,S]}),e[28]=n,e[29]=g,e[30]=b,e[31]=S,e[32]=u):u=e[32],u}function Rt(l){const e=ue.c(69),{client:s,run:i,busy:r}=l,a=C.useId(),[n,d]=C.useState(""),[o,v]=C.useState(""),[y,h]=C.useState(null),[w,j]=C.useState(""),[c,p]=C.useState(!1);let m;e[0]!==s||e[1]!==w||e[2]!==o||e[3]!==n||e[4]!==y||e[5]!==i?(m=Q=>{Q.preventDefault(),i(async()=>{var ce;if(!y||y.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((ce=globalThis.crypto)!=null&&ce.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const B=await y.arrayBuffer(),re=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",B)),Et).join("");if(re!==w.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:o,root:new TextDecoder("utf-8",{fatal:!0}).decode(B),fingerprint:re}),p(!1),d(""),v(""),j("")})},e[0]=s,e[1]=w,e[2]=o,e[3]=n,e[4]=y,e[5]=i,e[6]=m):m=e[6];const x=`${a}-name`;let g;e[7]!==x?(g=t.jsx(X,{htmlFor:x,children:"Development publisher"}),e[7]=x,e[8]=g):g=e[8];const b=`${a}-name`;let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=Q=>d(Q.target.value),e[9]=k):k=e[9];let S;e[10]!==r||e[11]!==n||e[12]!==b?(S=t.jsx(de,{id:b,value:n,onChange:k,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:r}),e[10]=r,e[11]=n,e[12]=b,e[13]=S):S=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Re,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=u):u=e[14];let N;e[15]!==g||e[16]!==S?(N=t.jsxs(Z,{children:[g,S,u]}),e[15]=g,e[16]=S,e[17]=N):N=e[17];const D=`${a}-label`;let R;e[18]!==D?(R=t.jsx(X,{htmlFor:D,children:"Display name"}),e[18]=D,e[19]=R):R=e[19];const A=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Q=>v(Q.target.value),e[20]=O):O=e[20];let I;e[21]!==r||e[22]!==o||e[23]!==A?(I=t.jsx(de,{id:A,value:o,onChange:O,maxLength:100,required:!0,disabled:r}),e[21]=r,e[22]=o,e[23]=A,e[24]=I):I=e[24];let U;e[25]!==R||e[26]!==I?(U=t.jsxs(Z,{children:[R,I]}),e[25]=R,e[26]=I,e[27]=U):U=e[27];const H=`${a}-root`;let z;e[28]!==H?(z=t.jsx(X,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=z):z=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Q=>{var B;h(((B=Q.target.files)==null?void 0:B[0])??null),p(!1)},e[30]=G):G=e[30];let F;e[31]!==r||e[32]!==ee?(F=t.jsx(de,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:r}),e[31]=r,e[32]=ee,e[33]=F):F=e[33];let K;e[34]!==z||e[35]!==F?(K=t.jsxs(Z,{children:[z,F]}),e[34]=z,e[35]=F,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(X,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let L;e[39]===Symbol.for("react.memo_cache_sentinel")?(L=Q=>{j(Q.target.value),p(!1)},e[39]=L):L=e[39];let M;e[40]!==r||e[41]!==w||e[42]!==J?(M=t.jsx(de,{id:J,value:w,onChange:L,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:r}),e[40]=r,e[41]=w,e[42]=J,e[43]=M):M=e[43];let T;e[44]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Re,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=T):T=e[44];let V;e[45]!==_||e[46]!==M?(V=t.jsxs(Z,{children:[_,M,T]}),e[45]=_,e[46]=M,e[47]=V):V=e[47];const f=`${a}-trust`;let $;e[48]!==r||e[49]!==f||e[50]!==c?($=t.jsx(Ie,{id:f,checked:c,onCheckedChange:p,disabled:r}),e[48]=r,e[49]=f,e[50]=c,e[51]=$):$=e[51];const W=`${a}-trust`;let q;e[52]!==W?(q=t.jsx(X,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=q):q=e[53];let Y;e[54]!==$||e[55]!==q?(Y=t.jsxs(Z,{orientation:"horizontal",children:[$,q]}),e[54]=$,e[55]=q,e[56]=Y):Y=e[56];const ae=r||!c||!y;let ie;e[57]!==ae?(ie=t.jsx(E,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==U||e[60]!==K||e[61]!==V||e[62]!==Y||e[63]!==ie||e[64]!==N?(le=t.jsxs(Fe,{children:[N,U,K,V,Y,ie]}),e[59]=U,e[60]=K,e[61]=V,e[62]=Y,e[63]=ie,e[64]=N,e[65]=le):le=e[65];let oe;return e[66]!==m||e[67]!==le?(oe=t.jsx("form",{onSubmit:m,children:le}),e[66]=m,e[67]=le,e[68]=oe):oe=e[68],oe}function Et(l){return l.toString(16).padStart(2,"0")}const Pt={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Tt({client:l,preview:e,activation:s,key:i,onFrame:r,onComplete:a,onError:n}){const d=new AbortController;let o="loading",v,y=0;const h=()=>new Error("The installation check expired. Review the package again to retry.");function w(m){o==="canceled"||o==="finished"||(o="canceled",clearTimeout(v),d.abort(),r(null),n(m))}function j(){o==="canceled"||o==="finished"||(o="finished",clearTimeout(v),a())}async function c(m){if(o==="committing"){o="recovering",clearTimeout(v);try{const x=await l.transactionOutcome(e);if(o!=="recovering")return;x.status==="committed"?(await l.refresh(),o==="recovering"&&j()):w(m)}catch{o==="recovering"&&w(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function p(){if(o==="trial"){if(Date.now()>y){w(h());return}o="committing";try{await l.commit(e,d.signal),o==="committing"&&j()}catch(m){await c(m instanceof Error?m:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const m=await l.payload(e.transactionId,d.signal);if(d.signal.aborted||(y=await l.beginTrial(e,d.signal),d.signal.aborted))return;const x=y-Date.now();if(x<=0){w(h());return}o="trial",v=setTimeout(()=>{o==="committing"?(d.abort(),c(h())):o==="trial"&&w(h())},x),r({key:i,client:l,props:{payload:m,digest:e.digest,activationKey:i,context:Pt,active:!1,title:"Plugin installation check",execute:async(g,b)=>{if(d.signal.throwIfAborted(),b.throwIfAborted(),g.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{p()},onError:w}})}catch(m){w(m instanceof Error?m:new Error("Plugin trial failed"))}})(),()=>{o="canceled",clearTimeout(v),d.abort()}}function At(l){const e=ue.c(22),{client:s,preview:i,activation:r,onComplete:a,onError:n}=l,d=`${r}:trial:${i.transactionId}:${i.digest}:${i.registryRevision}`,[o,v]=C.useState(null);let y;e[0]!==a||e[1]!==n?(y={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=y):y=e[2];const h=C.useRef(y);let w;e[3]!==a||e[4]!==n?(w=()=>{h.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=w):w=e[5],C.useLayoutEffect(w);let j,c;e[6]!==r||e[7]!==s||e[8]!==d||e[9]!==i?(j=()=>Tt({client:s,preview:i,activation:r,key:d,onFrame:v,onComplete:()=>h.current.onComplete(),onError:g=>h.current.onError(g)}),c=[s,i,r,d],e[6]=r,e[7]=s,e[8]=d,e[9]=i,e[10]=j,e[11]=c):(j=e[10],c=e[11]),C.useLayoutEffect(j,c);let p;e[12]!==i.manifest.name?(p=t.jsxs("p",{children:["Checking that ",i.manifest.name," starts correctly…"]}),e[12]=i.manifest.name,e[13]=p):p=e[13];let m;e[14]!==r||e[15]!==s||e[16]!==o||e[17]!==d?(m=r&&(o==null?void 0:o.key)===d&&o.client===s&&t.jsx(et,{...o.props}),e[14]=r,e[15]=s,e[16]=o,e[17]=d,e[18]=m):m=e[18];let x;return e[19]!==p||e[20]!==m?(x=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[p,m]}),e[19]=p,e[20]=m,e[21]=x):x=e[21],x}function Ot({connection:l,resourceId:e,target:s,client:i,disabled:r,save:a}){const n=C.useId(),d=l.definition.resources[e],o=l.selected[e],[v,y]=C.useState(""),[h,w]=C.useState(null),[j,c]=C.useState(!1),[p,m]=C.useState(null),x=C.useRef(null);C.useEffect(()=>()=>{var u;return(u=x.current)==null?void 0:u.abort()},[]);const g=tt(l.definition,e).find(u=>!l.selected[u]),b=r||!!g||d.scope==="project"&&!s.projectId;async function k(){var N;(N=x.current)==null||N.abort();const u=new AbortController;x.current=u,c(!0),m(null);try{const D=await i.connectionOptions(s,l.id,e,u.signal);u.signal.aborted||w(D)}catch(D){u.signal.aborted||m(D instanceof Error?D.message:"Unable to load choices")}finally{u.signal.aborted||c(!1)}}const S=o&&!(h!=null&&h.some(u=>u.id===o.id))?[o,...h??[]]:h??[];return t.jsxs(Z,{"data-disabled":b,"data-invalid":!!p,children:[t.jsx(X,{htmlFor:`${n}-resource`,children:d.label}),t.jsx(Re,{children:d.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),o&&t.jsxs("p",{className:"text-sm",children:["Selected: ",o.label]}),g&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",l.definition.resources[g].label," first."]}),d.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),d.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"button",variant:"outline",size:"sm",disabled:b||j,onClick:()=>{k()},children:j?"Loading choices…":h?"Refresh choices":"Browse choices"}),h&&t.jsxs(Ye,{items:S.map(u=>({value:u.id,label:u.label})),value:(o==null?void 0:o.id)??null,disabled:b||j,onValueChange:u=>{u&&u!==(o==null?void 0:o.id)&&a(l.id,"select",{resourceId:e,value:u})},children:[t.jsx(Qe,{id:`${n}-resource`,"aria-invalid":!!p,children:t.jsx(We,{placeholder:`Choose ${d.label}`})}),t.jsx(Ge,{children:t.jsx(Ke,{children:S.map(u=>t.jsx(Je,{value:u.id,children:u.label},u.id))})})]}),(h==null?void 0:h.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),d.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:u=>{u.preventDefault(),a(l.id,"select",{resourceId:e,value:v.trim()})},children:[t.jsx(de,{id:d.options?`${n}-input`:`${n}-resource`,"aria-label":`${d.label} ${d.input.urls?"URL or ID":"ID"}`,value:v,onChange:u=>y(u.target.value),maxLength:2048,disabled:b,autoComplete:"off",spellCheck:!1,placeholder:d.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(E,{type:"submit",size:"sm",variant:"outline",disabled:b||!v.trim(),children:"Validate and select"})]}),o&&t.jsxs(E,{type:"button",size:"sm",variant:"ghost",disabled:b,onClick:()=>{a(l.id,"select",{resourceId:e,value:null})},children:["Clear ",d.label]}),p&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:p})]})}function Ft(l){const e=ue.c(45),{connection:s,target:i,client:r,disabled:a,save:n}=l,d=C.useId(),[o,v]=C.useState(""),[y,h]=C.useState(!1),w=s.label;let j;e[0]!==s.label?(j=t.jsx("h3",{className:"font-medium",children:s.label}),e[0]=s.label,e[1]=j):j=e[1];const c=s.status==="disconnected"?"Needs connection":s.readOnly?"Configured by host":"Connected";let p;e[2]!==c?(p=t.jsx($e,{variant:"outline",children:c}),e[2]=c,e[3]=p):p=e[3];let m;e[4]!==j||e[5]!==p?(m=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,p]}),e[4]=j,e[5]=p,e[6]=m):m=e[6];let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Cogpit keeps this credential on the selected host. Plugin code cannot read it."}),e[7]=x):x=e[7];let g;e[8]!==s.definition.operations?(g=new Set(Object.values(s.definition.operations).map(_t)),e[8]=s.definition.operations,e[9]=g):g=e[9];let b;e[10]!==g?(b=[...g],e[10]=g,e[11]=b):b=e[11];const k=b.join(", ");let S;e[12]!==k?(S=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",k]}),e[12]=k,e[13]=S):S=e[13];let u;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==d||e[20]!==y||e[21]!==n?(u=s.legacyImportAvailable&&t.jsxs("div",{className:"flex flex-col gap-3 rounded-md bg-muted p-3",children:[t.jsx("p",{className:"text-sm",children:"An existing host connection has saved settings available to import."}),s.status==="connected"&&!s.readOnly&&t.jsxs(Z,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-replace`,checked:y,onCheckedChange:h,disabled:a}),t.jsx(X,{htmlFor:`${d}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(E,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:y})},children:"Import saved host settings"})]}),e[14]=s.id,e[15]=s.legacyImportAvailable,e[16]=s.readOnly,e[17]=s.status,e[18]=a,e[19]=d,e[20]=y,e[21]=n,e[22]=u):u=e[22];let N;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==d||e[29]!==n||e[30]!==o?(N=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:A=>{A.preventDefault();const O=o.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Fe,{children:[t.jsxs(Z,{"data-disabled":a,children:[t.jsx(X,{htmlFor:`${d}-secret`,children:s.definition.secret.label}),t.jsx(de,{id:`${d}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:o,onChange:A=>v(A.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"submit",size:"sm",disabled:a||!o.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(E,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"disconnect",{})},children:"Disconnect"})]})]})}),e[23]=s.definition.secret,e[24]=s.id,e[25]=s.readOnly,e[26]=s.status,e[27]=a,e[28]=d,e[29]=n,e[30]=o,e[31]=N):N=e[31];let D;e[32]!==r||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==i?(D=s.status!=="disconnected"&&t.jsx(Fe,{children:Object.keys(s.definition.resources).map(A=>t.jsx(Ot,{connection:s,resourceId:A,target:i,client:r,disabled:a,save:n},A))}),e[32]=r,e[33]=s,e[34]=a,e[35]=n,e[36]=i,e[37]=D):D=e[37];let R;return e[38]!==s.label||e[39]!==S||e[40]!==u||e[41]!==N||e[42]!==D||e[43]!==m?(R=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":w,children:[m,x,S,u,N,D]}),e[38]=s.label,e[39]=S,e[40]=u,e[41]=N,e[42]=D,e[43]=m,e[44]=R):R=e[44],R}function _t(l){return l.origin}function zt({client:l,target:e}){const[s,i]=C.useState(null),[r,a]=C.useState(null),[n,d]=C.useState(!1),o=C.useRef(null),v=C.useRef(!1),y=e.pluginId,h=e.projectId;C.useEffect(()=>{const j=new AbortController;return o.current=j,l.connections({pluginId:y,projectId:h},j.signal).then(c=>{j.signal.aborted||i(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),o.current=null}},[l,y,h]);async function w(j,c,p){if(!s||v.current||!o.current||o.current.signal.aborted)return;v.current=!0;const m=o.current.signal;d(!0),a(null);try{const x=await l.changeConnection(e,j,c,p,s.revision,m);m.aborted||i(x)}catch(x){m.aborted||a(x instanceof Error?x.message:"Connection change failed")}finally{v.current=!1,m.aborted||d(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[r&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:r})}),!s&&!r&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(Ft,{connection:j,target:e,client:l,disabled:n,save:w},`${j.id}:${s.revision}`)),(s==null?void 0:s.connections.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not use provider connections."})]})}function Lt(l){const e=ue.c(32),{client:s,status:i,pluginId:r,initialProjectId:a}=l,[n,d]=C.useState(a),o=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let y;e[1]!==i.projects?(y=[v,...i.projects.map(Ut)],e[1]=i.projects,e[2]=y):y=e[2];const h=y;let w;e[3]!==o?(w=t.jsx(X,{htmlFor:o,children:"Project settings"}),e[3]=o,e[4]=w):w=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=R=>d(R||null),e[5]=c):c=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(We,{}),e[6]=p):p=e[6];let m;e[7]!==o?(m=t.jsx(Qe,{id:o,children:p}),e[7]=o,e[8]=m):m=e[8];let x;e[9]!==h?(x=t.jsx(Ge,{children:t.jsx(Ke,{children:h.map(Vt)})}),e[9]=h,e[10]=x):x=e[10];let g;e[11]!==h||e[12]!==j||e[13]!==m||e[14]!==x?(g=t.jsxs(Ye,{items:h,value:j,onValueChange:c,children:[m,x]}),e[11]=h,e[12]=j,e[13]=m,e[14]=x,e[15]=g):g=e[15];let b;e[16]!==i.host.name?(b=t.jsxs(Re,{children:["Connection credentials belong to ",i.host.name,". Project resources stay within the project you choose."]}),e[16]=i.host.name,e[17]=b):b=e[17];let k;e[18]!==b||e[19]!==w||e[20]!==g?(k=t.jsxs(Z,{children:[w,g,b]}),e[18]=b,e[19]=w,e[20]=g,e[21]=k):k=e[21];const S=`${r}:${n??"host"}:${i.connectionRevision??0}`;let u;e[22]!==r||e[23]!==n?(u={pluginId:r,projectId:n},e[22]=r,e[23]=n,e[24]=u):u=e[24];let N;e[25]!==s||e[26]!==S||e[27]!==u?(N=t.jsx(zt,{client:s,target:u},S),e[25]=s,e[26]=S,e[27]=u,e[28]=N):N=e[28];let D;return e[29]!==k||e[30]!==N?(D=t.jsxs("div",{className:"flex flex-col gap-4",children:[k,N]}),e[29]=k,e[30]=N,e[31]=D):D=e[31],D}function Vt(l){return t.jsx(Je,{value:l.value,children:l.label},l.value)}function Ut(l){return{value:l.id,label:l.name}}function Mt(l){var ie;const e=ue.c(174),{plugin:s,status:i,client:r,busy:a,run:n,onPreview:d,onConnections:o,onUpdate:v}=l,y=C.useId(),[h,w]=C.useState(s.scope),[j,c]=C.useState(!1),[p,m]=C.useState(!1);let x,g,b,k,S,u,N,D,R,A,O,I;if(e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==d||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==h||e[8]!==i.host.name||e[9]!==i.projects||e[10]!==i.runtime||e[11]!==i.store){const le=st(),oe=qe(s.manifest,le,i.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Q;e[24]!==r||e[25]!==s.id||e[26]!==n||e[27]!==i.store?(Q=(P,Te)=>n(()=>r.changeInstalled(s.id,P,Te,i.store.revision)),e[24]=r,e[25]=s.id,e[26]=n,e[27]=i.store,e[28]=Q):Q=e[28];const B=Q,re=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let ce;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==i.store?(ce=s.lastError&&((ie=i.store.availableSeeds)==null?void 0:ie.find(P=>P.manifest.id===s.id&&P.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=i.store,e[33]=ce):ce=e[33];const _e=ce;A="flex flex-col gap-3 rounded-lg border p-4";let fe;e[34]!==s.manifest.name?(fe=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=fe):fe=e[35];let he;e[36]!==s.id||e[37]!==s.manifest.version?(he=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[s.id," · ",s.manifest.version]}),e[36]=s.id,e[37]=s.manifest.version,e[38]=he):he=e[38];let me;e[39]!==fe||e[40]!==he?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[fe,he]}),e[39]=fe,e[40]=he,e[41]=me):me=e[41];const ze=re==="Enabled"?"secondary":"outline";let pe;e[42]!==re||e[43]!==ze?(pe=t.jsx($e,{variant:ze,children:re}),e[42]=re,e[43]=ze,e[44]=pe):pe=e[44],e[45]!==me||e[46]!==pe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,pe]}),e[45]=me,e[46]=pe,e[47]=O):O=e[47],e[48]!==s.lastError?(I=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=I):I=e[49],g=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(P=>t.jsxs("p",{children:[P.side==="client"?"This client":P.side==="host"?i.host.name:"This package",": ",P.name," requires ",P.required,"; available ",P.actual??"none","."]},`${P.side}:${P.code}:${P.name}`)),t.jsx("p",{children:"Keep the saved data and update the affected app, or choose a compatible retained version below."})]})});let xe;e[50]!==B||e[51]!==s.enabled?(xe=()=>B("enabled",{enabled:!s.enabled}),e[50]=B,e[51]=s.enabled,e[52]=xe):xe=e[52];const Le=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==Le?(ge=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:Le}),e[53]=a,e[54]=xe,e[55]=Le,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==o||e[59]!==s.id||e[60]!==s.manifest.permissions.connections.length?(je=s.manifest.permissions.connections.length>0&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>o(s.id),children:"Connections"}),e[57]=a,e[58]=o,e[59]=s.id,e[60]=s.manifest.permissions.connections.length,e[61]=je):je=e[61];const Ve=a||s.pinned;let be;e[62]!==v||e[63]!==s?(be=()=>v(s),e[62]=v,e[63]=s,e[64]=be):be=e[64];let ve;e[65]!==Ve||e[66]!==be?(ve=t.jsx(E,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[65]=Ve,e[66]=be,e[67]=ve):ve=e[67];let ye;e[68]!==a||e[69]!==r||e[70]!==d||e[71]!==s.id||e[72]!==s.scope||e[73]!==_e||e[74]!==n?(ye=_e&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>d(await r.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[68]=a,e[69]=r,e[70]=d,e[71]=s.id,e[72]=s.scope,e[73]=_e,e[74]=n,e[75]=ye):ye=e[75];let Ce;e[76]!==B||e[77]!==s.pinned?(Ce=()=>B("pin",{pinned:!s.pinned}),e[76]=B,e[77]=s.pinned,e[78]=Ce):Ce=e[78];const Ue=s.pinned?"Unpin version":"Pin version";let we;e[79]!==a||e[80]!==Ce||e[81]!==Ue?(we=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:Ce,children:Ue}),e[79]=a,e[80]=Ce,e[81]=Ue,e[82]=we):we=e[82];let Ee;e[83]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>{m(!1),c(!0)},e[83]=Ee):Ee=e[83];let Ne;e[84]!==a?(Ne=t.jsx(E,{size:"sm",variant:"ghost",disabled:a,onClick:Ee,children:"Uninstall"}),e[84]=a,e[85]=Ne):Ne=e[85],e[86]!==ge||e[87]!==je||e[88]!==ve||e[89]!==ye||e[90]!==we||e[91]!==Ne?(b=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,we,Ne]}),e[86]=ge,e[87]=je,e[88]=ve,e[89]=ye,e[90]=we,e[91]=Ne,e[92]=b):b=e[92],e[93]!==s.pinned?(k=s.pinned&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unpin this version before updating or rolling back. Revoked packages remain blocked."}),e[93]=s.pinned,e[94]=k):k=e[94],D="text-sm",e[95]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[95]=R):R=e[95],x="flex flex-col gap-4 pt-4",e[96]!==a||e[97]!==h||e[98]!==i.projects?(S=t.jsx(Me,{value:h,onChange:w,projects:i.projects,disabled:a}),e[96]=a,e[97]=h,e[98]=i.projects,e[99]=S):S=e[99];let Se;e[100]!==a||e[101]!==s.scope||e[102]!==h?(Se=a||JSON.stringify(h)===JSON.stringify(s.scope),e[100]=a,e[101]=s.scope,e[102]=h,e[103]=Se):Se=e[103];let ke;e[104]!==B||e[105]!==h?(ke=()=>B("scope",{scope:h}),e[104]=B,e[105]=h,e[106]=ke):ke=e[106],e[107]!==i.host.name||e[108]!==Se||e[109]!==ke?(u=t.jsxs(E,{size:"sm",variant:"outline",disabled:Se,onClick:ke,children:["Save projects on ",i.host.name]}),e[107]=i.host.name,e[108]=Se,e[109]=ke,e[110]=u):u=e[110];let Pe;e[111]!==s.selectedDigest?(Pe=P=>P.digest!==s.selectedDigest,e[111]=s.selectedDigest,e[112]=Pe):Pe=e[112],N=s.versions.filter(Pe).map(P=>{const Te=!P.unavailableReason&&qe(P.manifest,le,i.runtime,{allowPrerelease:P.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(E,{size:"sm",variant:"outline",disabled:a||s.pinned||!Te,onClick:()=>n(async()=>d({...await r.rollback(s.id,P.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",P.manifest.version]}),!Te&&t.jsx("p",{className:"text-xs text-muted-foreground",children:P.unavailableReason??"This version is incompatible with the connected host or client."})]},P.digest)}),e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=v,e[5]=s,e[6]=n,e[7]=h,e[8]=i.host.name,e[9]=i.projects,e[10]=i.runtime,e[11]=i.store,e[12]=x,e[13]=g,e[14]=b,e[15]=k,e[16]=S,e[17]=u,e[18]=N,e[19]=D,e[20]=R,e[21]=A,e[22]=O,e[23]=I}else x=e[12],g=e[13],b=e[14],k=e[15],S=e[16],u=e[17],N=e[18],D=e[19],R=e[20],A=e[21],O=e[22],I=e[23];let U;e[113]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[113]=U):U=e[113];let H;e[114]!==x||e[115]!==S||e[116]!==u||e[117]!==N?(H=t.jsxs("div",{className:x,children:[S,u,N,U]}),e[114]=x,e[115]=S,e[116]=u,e[117]=N,e[118]=H):H=e[118];let z;e[119]!==H||e[120]!==D||e[121]!==R?(z=t.jsxs("details",{className:D,children:[R,H]}),e[119]=H,e[120]=D,e[121]=R,e[122]=z):z=e[122];let ee;e[123]!==s.manifest.name?(ee=t.jsxs(nt,{children:["Uninstall ",s.manifest.name,"?"]}),e[123]=s.manifest.name,e[124]=ee):ee=e[124];let G;e[125]!==i.host.name?(G=t.jsxs(it,{children:["This removes the plugin from ",i.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[125]=i.host.name,e[126]=G):G=e[126];let F;e[127]!==ee||e[128]!==G?(F=t.jsxs(at,{children:[ee,G]}),e[127]=ee,e[128]=G,e[129]=F):F=e[129];const K=`${y}-delete`,te=a||i.connectionRevision===void 0;let _;e[130]!==p||e[131]!==K||e[132]!==te?(_=t.jsx(Ie,{id:K,checked:p,onCheckedChange:m,disabled:te}),e[130]=p,e[131]=K,e[132]=te,e[133]=_):_=e[133];const J=`${y}-delete`;let L;e[134]!==J?(L=t.jsx(X,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[134]=J,e[135]=L):L=e[135];let M;e[136]!==_||e[137]!==L?(M=t.jsxs(Z,{orientation:"horizontal",children:[_,L]}),e[136]=_,e[137]=L,e[138]=M):M=e[138];let T;e[139]!==p?(T=p&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This cannot be undone. Other administrators' saved data is retained. Provider tokens and legacy backup files are not removed."}),e[139]=p,e[140]=T):T=e[140];let V;e[141]!==a?(V=t.jsx(ot,{disabled:a,children:"Cancel"}),e[141]=a,e[142]=V):V=e[142];let f;e[143]!==r||e[144]!==p||e[145]!==s.id||e[146]!==n||e[147]!==i.connectionRevision||e[148]!==i.store?(f=()=>{c(!1),n(()=>r.changeInstalled(s.id,"uninstall",p?{deleteData:!0,expectedConnectionRevision:i.connectionRevision}:{deleteData:!1},i.store.revision))},e[143]=r,e[144]=p,e[145]=s.id,e[146]=n,e[147]=i.connectionRevision,e[148]=i.store,e[149]=f):f=e[149];let $;e[150]!==a||e[151]!==i.host.name||e[152]!==f?($=t.jsxs(lt,{variant:"destructive",disabled:a,onClick:f,children:["Uninstall from ",i.host.name]}),e[150]=a,e[151]=i.host.name,e[152]=f,e[153]=$):$=e[153];let W;e[154]!==V||e[155]!==$?(W=t.jsxs(rt,{children:[V,$]}),e[154]=V,e[155]=$,e[156]=W):W=e[156];let q;e[157]!==F||e[158]!==M||e[159]!==T||e[160]!==W?(q=t.jsxs(ct,{children:[F,M,T,W]}),e[157]=F,e[158]=M,e[159]=T,e[160]=W,e[161]=q):q=e[161];let Y;e[162]!==j||e[163]!==q?(Y=t.jsx(dt,{open:j,onOpenChange:c,children:q}),e[162]=j,e[163]=q,e[164]=Y):Y=e[164];let ae;return e[165]!==g||e[166]!==b||e[167]!==k||e[168]!==z||e[169]!==Y||e[170]!==A||e[171]!==O||e[172]!==I?(ae=t.jsxs("article",{className:A,children:[O,I,g,b,k,z,Y]}),e[165]=g,e[166]=b,e[167]=k,e[168]=z,e[169]=Y,e[170]=A,e[171]=O,e[172]=I,e[173]=ae):ae=e[173],ae}const qt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Bt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"};function Ht(l,e){return e==="pullSessions"?"Read related Cogpit sessions for the selected GitHub repository":e==="mergePull"?"Merge pull requests in the selected GitHub repository when you confirm, using this host's signed-in CLI":`Read ${qt[l]} ${Bt[e]} using this host's signed-in CLI`}function He(l){const e=l.permissions;return[...e.context.map(s=>s==="session.identity"?"Recognise the open session among related sessions, by handle only":"Read the selected project's name and plugin identifier"),...e.composer.map(()=>"Append text to your draft message"),...e.navigation.map(s=>s==="external"?"Ask Cogpit to open HTTPS links":"Open permitted sessions"),...e.storage?[`Store up to ${e.storage.quotaKiB} KiB of ${e.storage.scope} settings`]:[],...e.connections.flatMap(s=>s.operations.map(i=>`Use connection ${s.id}: ${i}`)),...e.integrations.flatMap(s=>s.operations.map(i=>Ht(s.id,i)))]}function Gt(l){var j;const e=ue.c(32),{preview:s}=l;let i,r,a,n,d,o;if(e[0]!==s.connectionDefinitions||e[1]!==s.manifest||e[2]!==s.oldVersion||e[3]!==s.operation||e[4]!==s.previousConnectionDefinitions||e[5]!==s.previousManifest){const c=He(s.manifest),p=s.previousManifest?He(s.previousManifest):null,m=p?c.filter(b=>!p.includes(b)):[],x=p?p.filter(b=>!c.includes(b)):[],g=s.previousConnectionDefinitions?s.connectionDefinitions.filter(b=>{var S;const k=(S=s.previousConnectionDefinitions)==null?void 0:S.find(u=>u.id===b.id);return!k||JSON.stringify(k)!==JSON.stringify(b)}):[];i="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(r=s.oldVersion&&t.jsxs(se,{children:[t.jsx(De,{children:s.operation==="rollback"?"Rollback keeps current settings":"Update on this host"}),t.jsxs(ne,{children:["Saved settings and connections are retained. This version replaces ",s.oldVersion," in every enabled project and connected client. A failed trial leaves the current version selected."]})]}),e[12]=s.oldVersion,e[13]=s.operation,e[14]=r):r=e[14],a=p&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),m.length===0&&x.length===0&&g.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),m.map(Xt),x.map(Zt),g.map(Yt)]}),n=s.oldVersion&&!p&&t.jsx(se,{children:t.jsx(ne,{children:"This host does not report previous permissions. Review all requested access before continuing."})}),e[15]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=d):d=e[15],o=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(Qt)}):t.jsx("p",{className:"text-muted-foreground",children:"No project, connection, storage, or composer access requested."}),e[0]=s.connectionDefinitions,e[1]=s.manifest,e[2]=s.oldVersion,e[3]=s.operation,e[4]=s.previousConnectionDefinitions,e[5]=s.previousManifest,e[6]=i,e[7]=r,e[8]=a,e[9]=n,e[10]=d,e[11]=o}else i=e[6],r=e[7],a=e[8],n=e[9],d=e[10],o=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Kt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let y;e[18]!==s.incompatibleClients?(y=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(De,{children:"Some connected clients cannot run this version"}),t.jsxs(ne,{children:[s.incompatibleClients.join(", "),". Their plugin panels will be unavailable until those clients are updated. Offline clients are checked when they reconnect."]})]}),e[18]=s.incompatibleClients,e[19]=y):y=e[19];let h;e[20]!==s.digest?(h=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=h):h=e[21];let w;return e[22]!==i||e[23]!==r||e[24]!==a||e[25]!==n||e[26]!==d||e[27]!==o||e[28]!==v||e[29]!==y||e[30]!==h?(w=t.jsxs("div",{className:i,children:[r,a,n,d,o,v,y,h]}),e[22]=i,e[23]=r,e[24]=a,e[25]=n,e[26]=d,e[27]=o,e[28]=v,e[29]=y,e[30]=h,e[31]=w):w=e[31],w}function Kt(l){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:l.label}),t.jsxs("p",{children:["Access to ",Object.values(l.resources).map(Wt).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(l.operations).map(Jt))].join(", ")]})]},l.id)}function Jt(l){return l.origin}function Wt(l){return l.label}function Qt(l){return t.jsx("li",{children:l},l)}function Yt(l){return t.jsxs("p",{children:["Changed connection: ",l.label,". Review its destinations and access below."]},l.id)}function Zt(l){return t.jsxs("p",{children:["Removed: ",l]},`remove:${l}`)}function Xt(l){return t.jsxs("p",{children:["Added: ",l]},`add:${l}`)}function ls({client:l,state:e,currentPath:s,onClose:i,initialPluginId:r}){var V;const a=C.useId(),n=e.status,d=ut(),o=(n==null?void 0:n.safeMode)||d,{project:v,resolving:y}=ft({client:l,status:n,activation:e.activation,projectPath:s}),[h,w]=C.useState(null),j=h??{type:"projects",projectIds:v?[v.id]:[]},[c,p]=C.useState(null),[m,x]=C.useState({activation:"",hostName:""}),[g,b]=C.useState(!1),[k,S]=C.useState(!1),[u,N]=C.useState(null),[D,R]=C.useState(null),[A,O]=C.useState("installed"),[I,U]=C.useState(null),[H,z]=C.useState(null),[ee,G]=C.useState(r),F=n==null?void 0:n.store.plugins.find(f=>f.id===ee),K=C.useRef(!1),te=!!(n!=null&&n.store.available)&&m.activation===e.activation;function _(f){x({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),p(f)}C.useEffect(()=>{!c||te&&!(o&&g)||(b(!1),p(null),N("The host connection or plugin execution state changed. Review the package again before installing."),l.cancel(c).catch(()=>{}))},[l,c,te,o,g]),C.useEffect(()=>()=>{c&&l.cancel(c).catch(()=>{})},[l,c]);async function J(f){if(!K.current){K.current=!0,S(!0),N(null),R(null);try{await f()}catch($){N($ instanceof Error?$.message:"Plugin action failed")}finally{K.current=!1,S(!1)}}}function L(){const f=c;b(!1),p(null),f&&l.cancel(f).catch(()=>{})}async function M(){if(!H||!I&&!h&&y)return;const f=await l.stage(H,(I==null?void 0:I.scope)??j);if(I&&f.manifest.id!==I.id)throw await l.cancel(f),new Error(`Choose a package for ${I.manifest.name} (${I.id}).`);_(f)}const T=k||g||!(n!=null&&n.store.available);return t.jsx(ht,{open:!0,onOpenChange:f=>{!f&&!k&&!g&&(L(),i())},children:t.jsxs(mt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!k&&!g,children:[t.jsxs(pt,{children:[t.jsx(xt,{children:"Plugins"}),t.jsx(gt,{children:n?`Installed on ${n.host.name}. Changes apply to every client connected to this host.`:"Connecting to the selected host…"})]}),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 overflow-y-auto",children:[(e.error||u||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:n!=null&&n.store.available&&!u&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:u??e.error??(n==null?void 0:n.store.error)})]}),D&&t.jsx(se,{children:t.jsx(ne,{children:D})}),o&&t.jsxs(se,{children:[t.jsx(De,{children:"Plugin safe mode"}),t.jsxs(ne,{children:["Plugin panels are stopped. You can disable or uninstall plugins here.",(n==null?void 0:n.safeMode)&&" The host owner must restart Cogpit without COGPIT_DISABLE_PLUGINS=1 to resume plugins on this host."]})]}),t.jsx(E,{size:"sm",variant:"outline",disabled:k||g||(n==null?void 0:n.safeMode),onClick:()=>jt(!d),children:d?"Resume plugins in this browser":"Pause plugins in this browser"}),(n==null?void 0:n.store.recoveryCode)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.store.recoveryCode==="STORE_LOCKED"?"Close the other Cogpit process using this data directory, then restart this host.":n.store.recoveryCode==="STORE_VERSION"?"Open this host with the Cogpit version that last used its plugin store, or a newer compatible version.":"Keep the plugin data directory intact. Restart with plugin safe mode enabled and check the host log before restoring a verified backup."}),!n&&t.jsxs(E,{variant:"outline",disabled:k,onClick:()=>{J(()=>l.refresh())},children:[t.jsx(kt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&F&&!c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("h2",{className:"font-medium",children:[F.manifest.name," connections"]}),t.jsx(E,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),t.jsx(Lt,{client:l,status:n,pluginId:F.id,initialProjectId:(v==null?void 0:v.id)??null},`${F.id}:${n.store.revision}`)]}),n&&!F&&!c&&t.jsxs(bt,{value:A,onValueChange:f=>{O(String(f)),U(null),z(null)},children:[t.jsxs(vt,{className:"h-auto flex-wrap",children:[t.jsx(Ae,{value:"installed",children:"Installed"}),t.jsx(Ae,{value:"browse",children:"Browse"}),t.jsx(Ae,{value:"install",children:"Install from file"}),t.jsx(Ae,{value:"publishers",children:"Publishers"})]}),t.jsx(Oe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(f=>t.jsx(Mt,{plugin:f,status:n,client:l,busy:T,run:$=>{J($)},onPreview:_,onConnections:G,onUpdate:$=>{U($),z(null),O("install")}},`${f.id}:${n.store.revision}`)):t.jsx(yt,{children:t.jsxs(Ct,{children:[t.jsx(wt,{variant:"icon",children:t.jsx($t,{})}),t.jsx(Nt,{children:"No installed plugins"}),t.jsx(St,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Oe,{value:"browse",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["These optional plugins are available with this Cogpit release. Choose which ones to install on ",n.host.name,"."]}),t.jsx(Me,{value:j,onChange:w,projects:n.projects,disabled:T}),(n.store.availableSeeds??[]).map(f=>{const $=n.store.plugins.find(q=>q.id===f.manifest.id),W=$&&It(f.manifest.version,$.manifest.version)===1;return t.jsxs("article",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:f.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.manifest.version," · ",f.manifest.publisher]})]}),W?t.jsx(E,{size:"sm",disabled:T||$.pinned,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,$.scope)))},children:$.pinned?"Pinned to installed version":"Review update"}):$?t.jsx($e,{variant:"outline",children:"Installed"}):t.jsx(E,{size:"sm",disabled:T||!h&&y,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,j)))},children:"Review installation"})]},f.manifest.id)}),!((V=n.store.availableSeeds)!=null&&V.length)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This host has no bundled plugin packages. You can install a signed package from a file."})]})}),t.jsx(Oe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:f=>{f.preventDefault(),J(M)},children:t.jsxs(Fe,{children:[I&&t.jsxs("p",{className:"text-sm",children:["Update ",I.manifest.name," from ",I.manifest.version,". Existing project access is retained."]}),t.jsxs(Z,{children:[t.jsx(X,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(de,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:T,required:!0,onChange:f=>{var $;return z((($=f.target.files)==null?void 0:$[0])??null)}})]}),!I&&t.jsx(Me,{value:j,onChange:w,projects:n.projects,disabled:T}),t.jsxs(E,{type:"submit",disabled:T||!H||!I&&!h&&y,children:["Review ",I?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Oe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(f=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[f.label," ",t.jsx($e,{variant:"outline",children:f.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[f.id," · ",f.fingerprint]})]},f.id)),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Trust a development publisher"}),t.jsx("div",{className:"pt-4",children:t.jsx(Rt,{client:l,busy:T,run:f=>{J(f)}})})]})]})})]}),c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"text-lg font-medium",children:[c.manifest.name," ",c.manifest.version]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.oldVersion?`Replaces ${c.oldVersion}`:"New installation"," on ",m.hostName]}),t.jsx($e,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Gt,{preview:c}),t.jsxs("p",{className:"text-sm",children:["Available in: ",c.scope.type==="all"?"all projects on this host, including new projects":c.scope.projectIds.length?c.scope.projectIds.map(f=>{var $;return(($=n==null?void 0:n.projects.find(W=>W.id===f))==null?void 0:$.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(f=>t.jsxs("li",{children:[f.side,": ",f.name," requires ",f.required,"; available ",f.actual??"none","."]},`${f.side}:${f.code}:${f.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(f=>f.name).join(", "),"."]})}),g&&te&&!o?t.jsxs(t.Fragment,{children:[t.jsx(At,{client:l,preview:c,activation:e.activation,onComplete:()=>{b(!1),p(null),R(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${m.hostName}.`),O("installed"),U(null)},onError:f=>{N(f.message),L()}}),t.jsxs(E,{variant:"outline",onClick:L,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(E,{variant:"outline",disabled:k,onClick:L,children:"Cancel"}),t.jsxs(E,{disabled:T||!te||!c.compatibility.compatible||o,onClick:()=>{N(null),b(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",m.hostName]})]})]})]})]})})}export{ls as PluginsDialog};
|
|
1
|
+
import{c as ue,r as C,j as t}from"./vendor-react-gGw_S5I_.js";import{C as Z,be as Ie,b5 as X,bG as Ze,b6 as Re,bH as Xe,ba as de,B as E,z as Fe,bI as et,bJ as Ge,bK as Ke,bL as Je,bM as We,bN as Ye,bO as Qe,A as se,p as ne,bP as tt,Z as $e,bQ as st,bR as Me,a8 as nt,a9 as it,ac as lt,a6 as at,ab as ot,aa as rt,a5 as ct,a4 as dt,a$ as De,bS as ut,bT as ft,D as ht,h as mt,i as pt,j as xt,k as gt,bU as jt,bV as bt,bW as vt,bX as Ae,bY as Oe,L as yt,M as Ct,N as wt,O as Nt,Q as St}from"./index-BVrmKCdP.js";import{a as kt,aq as $t}from"./vendor-ui-Dfr2Rf5Q.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function Be(l){const e=l.trim().replace(/^v/i,"").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);return e?{parts:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]?e[4].split("."):[]}:null}function Dt(l,e){if(l.length===0&&e.length===0)return 0;if(l.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(l.length,e.length);s+=1){const i=l[s],r=e[s];if(i===void 0)return-1;if(r===void 0)return 1;const a=/^\d+$/.test(i),n=/^\d+$/.test(r);if(a&&n){if(Number(i)!==Number(r))return Number(i)<Number(r)?-1:1;continue}if(a!==n)return a?-1:1;if(i!==r)return i<r?-1:1}return 0}function It(l,e){const s=Be(l),i=Be(e);if(!s||!i)return null;for(let r=0;r<3;r+=1)if(s.parts[r]!==i.parts[r])return s.parts[r]<i.parts[r]?-1:1;return Dt(s.prerelease,i.prerelease)}function qe(l){const e=ue.c(33),{value:s,onChange:i,projects:r,disabled:a}=l,n=a===void 0?!1:a,d=C.useId();let o;e[0]!==s.projectIds||e[1]!==s.type?(o=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=o):o=e[2];let v;e[3]!==o?(v=new Set(o),e[3]=o,e[4]=v):v=e[4];const y=v;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Ze,{children:"Available in"}),e[5]=h):h=e[5];const w=`${d}-all`,j=s.type==="all";let c;e[6]!==i?(c=N=>i(N?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==n||e[9]!==w||e[10]!==j||e[11]!==c?(p=t.jsx(Ie,{id:w,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=w,e[10]=j,e[11]=c,e[12]=p):p=e[12];const m=`${d}-all`;let x;e[13]!==m?(x=t.jsx(X,{htmlFor:m,children:"All projects on this host, including new projects"}),e[13]=m,e[14]=x):x=e[14];let g;e[15]!==x||e[16]!==p?(g=t.jsxs(Z,{orientation:"horizontal",children:[p,x]}),e[15]=x,e[16]=p,e[17]=g):g=e[17];let b;e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==r||e[22]!==y||e[23]!==s.projectIds||e[24]!==s.type?(b=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:r.map(N=>t.jsxs(Z,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-${N.id}`,checked:y.has(N.id),disabled:n,onCheckedChange:D=>i({type:"projects",projectIds:D?[...s.projectIds,N.id]:s.projectIds.filter(R=>R!==N.id)})}),t.jsx(X,{htmlFor:`${d}-${N.id}`,children:N.name})]},N.id))}),e[18]=n,e[19]=d,e[20]=i,e[21]=r,e[22]=y,e[23]=s.projectIds,e[24]=s.type,e[25]=b):b=e[25];const k=s.type==="projects"&&s.projectIds.length===0?"Installed but hidden until you choose a project.":"This setting is shared by every client connected to this host.";let S;e[26]!==k?(S=t.jsx(Re,{children:k}),e[26]=k,e[27]=S):S=e[27];let u;return e[28]!==n||e[29]!==g||e[30]!==b||e[31]!==S?(u=t.jsxs(Xe,{disabled:n,children:[h,g,b,S]}),e[28]=n,e[29]=g,e[30]=b,e[31]=S,e[32]=u):u=e[32],u}function Rt(l){const e=ue.c(69),{client:s,run:i,busy:r}=l,a=C.useId(),[n,d]=C.useState(""),[o,v]=C.useState(""),[y,h]=C.useState(null),[w,j]=C.useState(""),[c,p]=C.useState(!1);let m;e[0]!==s||e[1]!==w||e[2]!==o||e[3]!==n||e[4]!==y||e[5]!==i?(m=Y=>{Y.preventDefault(),i(async()=>{var ce;if(!y||y.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((ce=globalThis.crypto)!=null&&ce.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const B=await y.arrayBuffer(),re=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",B)),Et).join("");if(re!==w.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:o,root:new TextDecoder("utf-8",{fatal:!0}).decode(B),fingerprint:re}),p(!1),d(""),v(""),j("")})},e[0]=s,e[1]=w,e[2]=o,e[3]=n,e[4]=y,e[5]=i,e[6]=m):m=e[6];const x=`${a}-name`;let g;e[7]!==x?(g=t.jsx(X,{htmlFor:x,children:"Development publisher"}),e[7]=x,e[8]=g):g=e[8];const b=`${a}-name`;let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=Y=>d(Y.target.value),e[9]=k):k=e[9];let S;e[10]!==r||e[11]!==n||e[12]!==b?(S=t.jsx(de,{id:b,value:n,onChange:k,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:r}),e[10]=r,e[11]=n,e[12]=b,e[13]=S):S=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Re,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=u):u=e[14];let N;e[15]!==g||e[16]!==S?(N=t.jsxs(Z,{children:[g,S,u]}),e[15]=g,e[16]=S,e[17]=N):N=e[17];const D=`${a}-label`;let R;e[18]!==D?(R=t.jsx(X,{htmlFor:D,children:"Display name"}),e[18]=D,e[19]=R):R=e[19];const A=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Y=>v(Y.target.value),e[20]=O):O=e[20];let I;e[21]!==r||e[22]!==o||e[23]!==A?(I=t.jsx(de,{id:A,value:o,onChange:O,maxLength:100,required:!0,disabled:r}),e[21]=r,e[22]=o,e[23]=A,e[24]=I):I=e[24];let U;e[25]!==R||e[26]!==I?(U=t.jsxs(Z,{children:[R,I]}),e[25]=R,e[26]=I,e[27]=U):U=e[27];const H=`${a}-root`;let z;e[28]!==H?(z=t.jsx(X,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=z):z=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Y=>{var B;h(((B=Y.target.files)==null?void 0:B[0])??null),p(!1)},e[30]=G):G=e[30];let F;e[31]!==r||e[32]!==ee?(F=t.jsx(de,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:r}),e[31]=r,e[32]=ee,e[33]=F):F=e[33];let K;e[34]!==z||e[35]!==F?(K=t.jsxs(Z,{children:[z,F]}),e[34]=z,e[35]=F,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(X,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let L;e[39]===Symbol.for("react.memo_cache_sentinel")?(L=Y=>{j(Y.target.value),p(!1)},e[39]=L):L=e[39];let q;e[40]!==r||e[41]!==w||e[42]!==J?(q=t.jsx(de,{id:J,value:w,onChange:L,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:r}),e[40]=r,e[41]=w,e[42]=J,e[43]=q):q=e[43];let T;e[44]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Re,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=T):T=e[44];let V;e[45]!==_||e[46]!==q?(V=t.jsxs(Z,{children:[_,q,T]}),e[45]=_,e[46]=q,e[47]=V):V=e[47];const f=`${a}-trust`;let $;e[48]!==r||e[49]!==f||e[50]!==c?($=t.jsx(Ie,{id:f,checked:c,onCheckedChange:p,disabled:r}),e[48]=r,e[49]=f,e[50]=c,e[51]=$):$=e[51];const W=`${a}-trust`;let M;e[52]!==W?(M=t.jsx(X,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=M):M=e[53];let Q;e[54]!==$||e[55]!==M?(Q=t.jsxs(Z,{orientation:"horizontal",children:[$,M]}),e[54]=$,e[55]=M,e[56]=Q):Q=e[56];const ae=r||!c||!y;let ie;e[57]!==ae?(ie=t.jsx(E,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==U||e[60]!==K||e[61]!==V||e[62]!==Q||e[63]!==ie||e[64]!==N?(le=t.jsxs(Fe,{children:[N,U,K,V,Q,ie]}),e[59]=U,e[60]=K,e[61]=V,e[62]=Q,e[63]=ie,e[64]=N,e[65]=le):le=e[65];let oe;return e[66]!==m||e[67]!==le?(oe=t.jsx("form",{onSubmit:m,children:le}),e[66]=m,e[67]=le,e[68]=oe):oe=e[68],oe}function Et(l){return l.toString(16).padStart(2,"0")}const Pt={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Tt({client:l,preview:e,activation:s,key:i,onFrame:r,onComplete:a,onError:n}){const d=new AbortController;let o="loading",v,y=0;const h=()=>new Error("The installation check expired. Review the package again to retry.");function w(m){o==="canceled"||o==="finished"||(o="canceled",clearTimeout(v),d.abort(),r(null),n(m))}function j(){o==="canceled"||o==="finished"||(o="finished",clearTimeout(v),a())}async function c(m){if(o==="committing"){o="recovering",clearTimeout(v);try{const x=await l.transactionOutcome(e);if(o!=="recovering")return;x.status==="committed"?(await l.refresh(),o==="recovering"&&j()):w(m)}catch{o==="recovering"&&w(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function p(){if(o==="trial"){if(Date.now()>y){w(h());return}o="committing";try{await l.commit(e,d.signal),o==="committing"&&j()}catch(m){await c(m instanceof Error?m:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const m=await l.payload(e.transactionId,d.signal);if(d.signal.aborted||(y=await l.beginTrial(e,d.signal),d.signal.aborted))return;const x=y-Date.now();if(x<=0){w(h());return}o="trial",v=setTimeout(()=>{o==="committing"?(d.abort(),c(h())):o==="trial"&&w(h())},x),r({key:i,client:l,props:{payload:m,digest:e.digest,activationKey:i,context:Pt,active:!1,title:"Plugin installation check",execute:async(g,b)=>{if(d.signal.throwIfAborted(),b.throwIfAborted(),g.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{p()},onError:w}})}catch(m){w(m instanceof Error?m:new Error("Plugin trial failed"))}})(),()=>{o="canceled",clearTimeout(v),d.abort()}}function At(l){const e=ue.c(22),{client:s,preview:i,activation:r,onComplete:a,onError:n}=l,d=`${r}:trial:${i.transactionId}:${i.digest}:${i.registryRevision}`,[o,v]=C.useState(null);let y;e[0]!==a||e[1]!==n?(y={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=y):y=e[2];const h=C.useRef(y);let w;e[3]!==a||e[4]!==n?(w=()=>{h.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=w):w=e[5],C.useLayoutEffect(w);let j,c;e[6]!==r||e[7]!==s||e[8]!==d||e[9]!==i?(j=()=>Tt({client:s,preview:i,activation:r,key:d,onFrame:v,onComplete:()=>h.current.onComplete(),onError:g=>h.current.onError(g)}),c=[s,i,r,d],e[6]=r,e[7]=s,e[8]=d,e[9]=i,e[10]=j,e[11]=c):(j=e[10],c=e[11]),C.useLayoutEffect(j,c);let p;e[12]!==i.manifest.name?(p=t.jsxs("p",{children:["Checking that ",i.manifest.name," starts correctly…"]}),e[12]=i.manifest.name,e[13]=p):p=e[13];let m;e[14]!==r||e[15]!==s||e[16]!==o||e[17]!==d?(m=r&&(o==null?void 0:o.key)===d&&o.client===s&&t.jsx(et,{...o.props}),e[14]=r,e[15]=s,e[16]=o,e[17]=d,e[18]=m):m=e[18];let x;return e[19]!==p||e[20]!==m?(x=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[p,m]}),e[19]=p,e[20]=m,e[21]=x):x=e[21],x}function Ot({connection:l,resourceId:e,target:s,client:i,disabled:r,save:a}){const n=C.useId(),d=l.definition.resources[e],o=l.selected[e],[v,y]=C.useState(""),[h,w]=C.useState(null),[j,c]=C.useState(!1),[p,m]=C.useState(null),x=C.useRef(null);C.useEffect(()=>()=>{var u;return(u=x.current)==null?void 0:u.abort()},[]);const g=tt(l.definition,e).find(u=>!l.selected[u]),b=r||!!g||d.scope==="project"&&!s.projectId;async function k(){var N;(N=x.current)==null||N.abort();const u=new AbortController;x.current=u,c(!0),m(null);try{const D=await i.connectionOptions(s,l.id,e,u.signal);u.signal.aborted||w(D)}catch(D){u.signal.aborted||m(D instanceof Error?D.message:"Unable to load choices")}finally{u.signal.aborted||c(!1)}}const S=o&&!(h!=null&&h.some(u=>u.id===o.id))?[o,...h??[]]:h??[];return t.jsxs(Z,{"data-disabled":b,"data-invalid":!!p,children:[t.jsx(X,{htmlFor:`${n}-resource`,children:d.label}),t.jsx(Re,{children:d.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),o&&t.jsxs("p",{className:"text-sm",children:["Selected: ",o.label]}),g&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",l.definition.resources[g].label," first."]}),d.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),d.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"button",variant:"outline",size:"sm",disabled:b||j,onClick:()=>{k()},children:j?"Loading choices…":h?"Refresh choices":"Browse choices"}),h&&t.jsxs(Qe,{items:S.map(u=>({value:u.id,label:u.label})),value:(o==null?void 0:o.id)??null,disabled:b||j,onValueChange:u=>{u&&u!==(o==null?void 0:o.id)&&a(l.id,"select",{resourceId:e,value:u})},children:[t.jsx(Ye,{id:`${n}-resource`,"aria-invalid":!!p,children:t.jsx(We,{placeholder:`Choose ${d.label}`})}),t.jsx(Ge,{children:t.jsx(Ke,{children:S.map(u=>t.jsx(Je,{value:u.id,children:u.label},u.id))})})]}),(h==null?void 0:h.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),d.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:u=>{u.preventDefault(),a(l.id,"select",{resourceId:e,value:v.trim()})},children:[t.jsx(de,{id:d.options?`${n}-input`:`${n}-resource`,"aria-label":`${d.label} ${d.input.urls?"URL or ID":"ID"}`,value:v,onChange:u=>y(u.target.value),maxLength:2048,disabled:b,autoComplete:"off",spellCheck:!1,placeholder:d.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(E,{type:"submit",size:"sm",variant:"outline",disabled:b||!v.trim(),children:"Validate and select"})]}),o&&t.jsxs(E,{type:"button",size:"sm",variant:"ghost",disabled:b,onClick:()=>{a(l.id,"select",{resourceId:e,value:null})},children:["Clear ",d.label]}),p&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:p})]})}function Ft(l){const e=ue.c(45),{connection:s,target:i,client:r,disabled:a,save:n}=l,d=C.useId(),[o,v]=C.useState(""),[y,h]=C.useState(!1),w=s.label;let j;e[0]!==s.label?(j=t.jsx("h3",{className:"font-medium",children:s.label}),e[0]=s.label,e[1]=j):j=e[1];const c=s.status==="disconnected"?"Needs connection":s.readOnly?"Configured by host":"Connected";let p;e[2]!==c?(p=t.jsx($e,{variant:"outline",children:c}),e[2]=c,e[3]=p):p=e[3];let m;e[4]!==j||e[5]!==p?(m=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,p]}),e[4]=j,e[5]=p,e[6]=m):m=e[6];let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Cogpit keeps this credential on the selected host. Plugin code cannot read it."}),e[7]=x):x=e[7];let g;e[8]!==s.definition.operations?(g=new Set(Object.values(s.definition.operations).map(_t)),e[8]=s.definition.operations,e[9]=g):g=e[9];let b;e[10]!==g?(b=[...g],e[10]=g,e[11]=b):b=e[11];const k=b.join(", ");let S;e[12]!==k?(S=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",k]}),e[12]=k,e[13]=S):S=e[13];let u;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==d||e[20]!==y||e[21]!==n?(u=s.legacyImportAvailable&&t.jsxs("div",{className:"flex flex-col gap-3 rounded-md bg-muted p-3",children:[t.jsx("p",{className:"text-sm",children:"An existing host connection has saved settings available to import."}),s.status==="connected"&&!s.readOnly&&t.jsxs(Z,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-replace`,checked:y,onCheckedChange:h,disabled:a}),t.jsx(X,{htmlFor:`${d}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(E,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:y})},children:"Import saved host settings"})]}),e[14]=s.id,e[15]=s.legacyImportAvailable,e[16]=s.readOnly,e[17]=s.status,e[18]=a,e[19]=d,e[20]=y,e[21]=n,e[22]=u):u=e[22];let N;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==d||e[29]!==n||e[30]!==o?(N=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:A=>{A.preventDefault();const O=o.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Fe,{children:[t.jsxs(Z,{"data-disabled":a,children:[t.jsx(X,{htmlFor:`${d}-secret`,children:s.definition.secret.label}),t.jsx(de,{id:`${d}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:o,onChange:A=>v(A.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"submit",size:"sm",disabled:a||!o.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(E,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"disconnect",{})},children:"Disconnect"})]})]})}),e[23]=s.definition.secret,e[24]=s.id,e[25]=s.readOnly,e[26]=s.status,e[27]=a,e[28]=d,e[29]=n,e[30]=o,e[31]=N):N=e[31];let D;e[32]!==r||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==i?(D=s.status!=="disconnected"&&t.jsx(Fe,{children:Object.keys(s.definition.resources).map(A=>t.jsx(Ot,{connection:s,resourceId:A,target:i,client:r,disabled:a,save:n},A))}),e[32]=r,e[33]=s,e[34]=a,e[35]=n,e[36]=i,e[37]=D):D=e[37];let R;return e[38]!==s.label||e[39]!==S||e[40]!==u||e[41]!==N||e[42]!==D||e[43]!==m?(R=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":w,children:[m,x,S,u,N,D]}),e[38]=s.label,e[39]=S,e[40]=u,e[41]=N,e[42]=D,e[43]=m,e[44]=R):R=e[44],R}function _t(l){return l.origin}function zt({client:l,target:e}){const[s,i]=C.useState(null),[r,a]=C.useState(null),[n,d]=C.useState(!1),o=C.useRef(null),v=C.useRef(!1),y=e.pluginId,h=e.projectId;C.useEffect(()=>{const j=new AbortController;return o.current=j,l.connections({pluginId:y,projectId:h},j.signal).then(c=>{j.signal.aborted||i(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),o.current=null}},[l,y,h]);async function w(j,c,p){if(!s||v.current||!o.current||o.current.signal.aborted)return;v.current=!0;const m=o.current.signal;d(!0),a(null);try{const x=await l.changeConnection(e,j,c,p,s.revision,m);m.aborted||i(x)}catch(x){m.aborted||a(x instanceof Error?x.message:"Connection change failed")}finally{v.current=!1,m.aborted||d(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[r&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:r})}),!s&&!r&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(Ft,{connection:j,target:e,client:l,disabled:n,save:w},`${j.id}:${s.revision}`)),(s==null?void 0:s.connections.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not use provider connections."})]})}function Lt(l){const e=ue.c(32),{client:s,status:i,pluginId:r,initialProjectId:a}=l,[n,d]=C.useState(a),o=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let y;e[1]!==i.projects?(y=[v,...i.projects.map(Ut)],e[1]=i.projects,e[2]=y):y=e[2];const h=y;let w;e[3]!==o?(w=t.jsx(X,{htmlFor:o,children:"Project settings"}),e[3]=o,e[4]=w):w=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=R=>d(R||null),e[5]=c):c=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(We,{}),e[6]=p):p=e[6];let m;e[7]!==o?(m=t.jsx(Ye,{id:o,children:p}),e[7]=o,e[8]=m):m=e[8];let x;e[9]!==h?(x=t.jsx(Ge,{children:t.jsx(Ke,{children:h.map(Vt)})}),e[9]=h,e[10]=x):x=e[10];let g;e[11]!==h||e[12]!==j||e[13]!==m||e[14]!==x?(g=t.jsxs(Qe,{items:h,value:j,onValueChange:c,children:[m,x]}),e[11]=h,e[12]=j,e[13]=m,e[14]=x,e[15]=g):g=e[15];let b;e[16]!==i.host.name?(b=t.jsxs(Re,{children:["Connection credentials belong to ",i.host.name,". Project resources stay within the project you choose."]}),e[16]=i.host.name,e[17]=b):b=e[17];let k;e[18]!==b||e[19]!==w||e[20]!==g?(k=t.jsxs(Z,{children:[w,g,b]}),e[18]=b,e[19]=w,e[20]=g,e[21]=k):k=e[21];const S=`${r}:${n??"host"}:${i.connectionRevision??0}`;let u;e[22]!==r||e[23]!==n?(u={pluginId:r,projectId:n},e[22]=r,e[23]=n,e[24]=u):u=e[24];let N;e[25]!==s||e[26]!==S||e[27]!==u?(N=t.jsx(zt,{client:s,target:u},S),e[25]=s,e[26]=S,e[27]=u,e[28]=N):N=e[28];let D;return e[29]!==k||e[30]!==N?(D=t.jsxs("div",{className:"flex flex-col gap-4",children:[k,N]}),e[29]=k,e[30]=N,e[31]=D):D=e[31],D}function Vt(l){return t.jsx(Je,{value:l.value,children:l.label},l.value)}function Ut(l){return{value:l.id,label:l.name}}function qt(l){var ie;const e=ue.c(174),{plugin:s,status:i,client:r,busy:a,run:n,onPreview:d,onConnections:o,onUpdate:v}=l,y=C.useId(),[h,w]=C.useState(s.scope),[j,c]=C.useState(!1),[p,m]=C.useState(!1);let x,g,b,k,S,u,N,D,R,A,O,I;if(e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==d||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==h||e[8]!==i.host.name||e[9]!==i.projects||e[10]!==i.runtime||e[11]!==i.store){const le=st(),oe=Me(s.manifest,le,i.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Y;e[24]!==r||e[25]!==s.id||e[26]!==n||e[27]!==i.store?(Y=(P,Te)=>n(()=>r.changeInstalled(s.id,P,Te,i.store.revision)),e[24]=r,e[25]=s.id,e[26]=n,e[27]=i.store,e[28]=Y):Y=e[28];const B=Y,re=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let ce;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==i.store?(ce=s.lastError&&((ie=i.store.availableSeeds)==null?void 0:ie.find(P=>P.manifest.id===s.id&&P.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=i.store,e[33]=ce):ce=e[33];const _e=ce;A="flex flex-col gap-3 rounded-lg border p-4";let fe;e[34]!==s.manifest.name?(fe=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=fe):fe=e[35];let he;e[36]!==s.id||e[37]!==s.manifest.version?(he=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[s.id," · ",s.manifest.version]}),e[36]=s.id,e[37]=s.manifest.version,e[38]=he):he=e[38];let me;e[39]!==fe||e[40]!==he?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[fe,he]}),e[39]=fe,e[40]=he,e[41]=me):me=e[41];const ze=re==="Enabled"?"secondary":"outline";let pe;e[42]!==re||e[43]!==ze?(pe=t.jsx($e,{variant:ze,children:re}),e[42]=re,e[43]=ze,e[44]=pe):pe=e[44],e[45]!==me||e[46]!==pe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,pe]}),e[45]=me,e[46]=pe,e[47]=O):O=e[47],e[48]!==s.lastError?(I=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=I):I=e[49],g=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(P=>t.jsxs("p",{children:[P.side==="client"?"This client":P.side==="host"?i.host.name:"This package",": ",P.name," requires ",P.required,"; available ",P.actual??"none","."]},`${P.side}:${P.code}:${P.name}`)),t.jsx("p",{children:"Keep the saved data and update the affected app, or choose a compatible retained version below."})]})});let xe;e[50]!==B||e[51]!==s.enabled?(xe=()=>B("enabled",{enabled:!s.enabled}),e[50]=B,e[51]=s.enabled,e[52]=xe):xe=e[52];const Le=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==Le?(ge=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:Le}),e[53]=a,e[54]=xe,e[55]=Le,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==o||e[59]!==s.id||e[60]!==s.manifest.permissions.connections.length?(je=s.manifest.permissions.connections.length>0&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>o(s.id),children:"Connections"}),e[57]=a,e[58]=o,e[59]=s.id,e[60]=s.manifest.permissions.connections.length,e[61]=je):je=e[61];const Ve=a||s.pinned;let be;e[62]!==v||e[63]!==s?(be=()=>v(s),e[62]=v,e[63]=s,e[64]=be):be=e[64];let ve;e[65]!==Ve||e[66]!==be?(ve=t.jsx(E,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[65]=Ve,e[66]=be,e[67]=ve):ve=e[67];let ye;e[68]!==a||e[69]!==r||e[70]!==d||e[71]!==s.id||e[72]!==s.scope||e[73]!==_e||e[74]!==n?(ye=_e&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>d(await r.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[68]=a,e[69]=r,e[70]=d,e[71]=s.id,e[72]=s.scope,e[73]=_e,e[74]=n,e[75]=ye):ye=e[75];let Ce;e[76]!==B||e[77]!==s.pinned?(Ce=()=>B("pin",{pinned:!s.pinned}),e[76]=B,e[77]=s.pinned,e[78]=Ce):Ce=e[78];const Ue=s.pinned?"Unpin version":"Pin version";let we;e[79]!==a||e[80]!==Ce||e[81]!==Ue?(we=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:Ce,children:Ue}),e[79]=a,e[80]=Ce,e[81]=Ue,e[82]=we):we=e[82];let Ee;e[83]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>{m(!1),c(!0)},e[83]=Ee):Ee=e[83];let Ne;e[84]!==a?(Ne=t.jsx(E,{size:"sm",variant:"ghost",disabled:a,onClick:Ee,children:"Uninstall"}),e[84]=a,e[85]=Ne):Ne=e[85],e[86]!==ge||e[87]!==je||e[88]!==ve||e[89]!==ye||e[90]!==we||e[91]!==Ne?(b=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,we,Ne]}),e[86]=ge,e[87]=je,e[88]=ve,e[89]=ye,e[90]=we,e[91]=Ne,e[92]=b):b=e[92],e[93]!==s.pinned?(k=s.pinned&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unpin this version before updating or rolling back. Revoked packages remain blocked."}),e[93]=s.pinned,e[94]=k):k=e[94],D="text-sm",e[95]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[95]=R):R=e[95],x="flex flex-col gap-4 pt-4",e[96]!==a||e[97]!==h||e[98]!==i.projects?(S=t.jsx(qe,{value:h,onChange:w,projects:i.projects,disabled:a}),e[96]=a,e[97]=h,e[98]=i.projects,e[99]=S):S=e[99];let Se;e[100]!==a||e[101]!==s.scope||e[102]!==h?(Se=a||JSON.stringify(h)===JSON.stringify(s.scope),e[100]=a,e[101]=s.scope,e[102]=h,e[103]=Se):Se=e[103];let ke;e[104]!==B||e[105]!==h?(ke=()=>B("scope",{scope:h}),e[104]=B,e[105]=h,e[106]=ke):ke=e[106],e[107]!==i.host.name||e[108]!==Se||e[109]!==ke?(u=t.jsxs(E,{size:"sm",variant:"outline",disabled:Se,onClick:ke,children:["Save projects on ",i.host.name]}),e[107]=i.host.name,e[108]=Se,e[109]=ke,e[110]=u):u=e[110];let Pe;e[111]!==s.selectedDigest?(Pe=P=>P.digest!==s.selectedDigest,e[111]=s.selectedDigest,e[112]=Pe):Pe=e[112],N=s.versions.filter(Pe).map(P=>{const Te=!P.unavailableReason&&Me(P.manifest,le,i.runtime,{allowPrerelease:P.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(E,{size:"sm",variant:"outline",disabled:a||s.pinned||!Te,onClick:()=>n(async()=>d({...await r.rollback(s.id,P.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",P.manifest.version]}),!Te&&t.jsx("p",{className:"text-xs text-muted-foreground",children:P.unavailableReason??"This version is incompatible with the connected host or client."})]},P.digest)}),e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=v,e[5]=s,e[6]=n,e[7]=h,e[8]=i.host.name,e[9]=i.projects,e[10]=i.runtime,e[11]=i.store,e[12]=x,e[13]=g,e[14]=b,e[15]=k,e[16]=S,e[17]=u,e[18]=N,e[19]=D,e[20]=R,e[21]=A,e[22]=O,e[23]=I}else x=e[12],g=e[13],b=e[14],k=e[15],S=e[16],u=e[17],N=e[18],D=e[19],R=e[20],A=e[21],O=e[22],I=e[23];let U;e[113]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[113]=U):U=e[113];let H;e[114]!==x||e[115]!==S||e[116]!==u||e[117]!==N?(H=t.jsxs("div",{className:x,children:[S,u,N,U]}),e[114]=x,e[115]=S,e[116]=u,e[117]=N,e[118]=H):H=e[118];let z;e[119]!==H||e[120]!==D||e[121]!==R?(z=t.jsxs("details",{className:D,children:[R,H]}),e[119]=H,e[120]=D,e[121]=R,e[122]=z):z=e[122];let ee;e[123]!==s.manifest.name?(ee=t.jsxs(nt,{children:["Uninstall ",s.manifest.name,"?"]}),e[123]=s.manifest.name,e[124]=ee):ee=e[124];let G;e[125]!==i.host.name?(G=t.jsxs(it,{children:["This removes the plugin from ",i.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[125]=i.host.name,e[126]=G):G=e[126];let F;e[127]!==ee||e[128]!==G?(F=t.jsxs(at,{children:[ee,G]}),e[127]=ee,e[128]=G,e[129]=F):F=e[129];const K=`${y}-delete`,te=a||i.connectionRevision===void 0;let _;e[130]!==p||e[131]!==K||e[132]!==te?(_=t.jsx(Ie,{id:K,checked:p,onCheckedChange:m,disabled:te}),e[130]=p,e[131]=K,e[132]=te,e[133]=_):_=e[133];const J=`${y}-delete`;let L;e[134]!==J?(L=t.jsx(X,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[134]=J,e[135]=L):L=e[135];let q;e[136]!==_||e[137]!==L?(q=t.jsxs(Z,{orientation:"horizontal",children:[_,L]}),e[136]=_,e[137]=L,e[138]=q):q=e[138];let T;e[139]!==p?(T=p&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This cannot be undone. Other administrators' saved data is retained. Provider tokens and legacy backup files are not removed."}),e[139]=p,e[140]=T):T=e[140];let V;e[141]!==a?(V=t.jsx(ot,{disabled:a,children:"Cancel"}),e[141]=a,e[142]=V):V=e[142];let f;e[143]!==r||e[144]!==p||e[145]!==s.id||e[146]!==n||e[147]!==i.connectionRevision||e[148]!==i.store?(f=()=>{c(!1),n(()=>r.changeInstalled(s.id,"uninstall",p?{deleteData:!0,expectedConnectionRevision:i.connectionRevision}:{deleteData:!1},i.store.revision))},e[143]=r,e[144]=p,e[145]=s.id,e[146]=n,e[147]=i.connectionRevision,e[148]=i.store,e[149]=f):f=e[149];let $;e[150]!==a||e[151]!==i.host.name||e[152]!==f?($=t.jsxs(lt,{variant:"destructive",disabled:a,onClick:f,children:["Uninstall from ",i.host.name]}),e[150]=a,e[151]=i.host.name,e[152]=f,e[153]=$):$=e[153];let W;e[154]!==V||e[155]!==$?(W=t.jsxs(rt,{children:[V,$]}),e[154]=V,e[155]=$,e[156]=W):W=e[156];let M;e[157]!==F||e[158]!==q||e[159]!==T||e[160]!==W?(M=t.jsxs(ct,{children:[F,q,T,W]}),e[157]=F,e[158]=q,e[159]=T,e[160]=W,e[161]=M):M=e[161];let Q;e[162]!==j||e[163]!==M?(Q=t.jsx(dt,{open:j,onOpenChange:c,children:M}),e[162]=j,e[163]=M,e[164]=Q):Q=e[164];let ae;return e[165]!==g||e[166]!==b||e[167]!==k||e[168]!==z||e[169]!==Q||e[170]!==A||e[171]!==O||e[172]!==I?(ae=t.jsxs("article",{className:A,children:[O,I,g,b,k,z,Q]}),e[165]=g,e[166]=b,e[167]=k,e[168]=z,e[169]=Q,e[170]=A,e[171]=O,e[172]=I,e[173]=ae):ae=e[173],ae}const Mt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Bt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"};function Ht(l,e){return e==="pullSessions"?"Read related Cogpit sessions for the selected GitHub repository":e==="mergePull"?"Merge pull requests in the selected GitHub repository when you confirm, using this host's signed-in CLI":`Read ${Mt[l]} ${Bt[e]} using this host's signed-in CLI`}function He(l){const e=l.permissions;return[...e.context.map(s=>s==="session.identity"?"Recognise the open session among related sessions, by handle only":"Read the selected project's name and plugin identifier"),...e.composer.map(()=>"Append text to your draft message"),...e.navigation.map(s=>s==="external"?"Ask Cogpit to open HTTPS links":"Open permitted sessions"),...e.storage?[`Store up to ${e.storage.quotaKiB} KiB of ${e.storage.scope} settings`]:[],...e.connections.flatMap(s=>s.operations.map(i=>`Use connection ${s.id}: ${i}`)),...e.integrations.flatMap(s=>s.operations.map(i=>Ht(s.id,i)))]}function Gt(l){var j;const e=ue.c(32),{preview:s}=l;let i,r,a,n,d,o;if(e[0]!==s.connectionDefinitions||e[1]!==s.manifest||e[2]!==s.oldVersion||e[3]!==s.operation||e[4]!==s.previousConnectionDefinitions||e[5]!==s.previousManifest){const c=He(s.manifest),p=s.previousManifest?He(s.previousManifest):null,m=p?c.filter(b=>!p.includes(b)):[],x=p?p.filter(b=>!c.includes(b)):[],g=s.previousConnectionDefinitions?s.connectionDefinitions.filter(b=>{var S;const k=(S=s.previousConnectionDefinitions)==null?void 0:S.find(u=>u.id===b.id);return!k||JSON.stringify(k)!==JSON.stringify(b)}):[];i="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(r=s.oldVersion&&t.jsxs(se,{children:[t.jsx(De,{children:s.operation==="rollback"?"Rollback keeps current settings":"Update on this host"}),t.jsxs(ne,{children:["Saved settings and connections are retained. This version replaces ",s.oldVersion," in every enabled project and connected client. A failed trial leaves the current version selected."]})]}),e[12]=s.oldVersion,e[13]=s.operation,e[14]=r):r=e[14],a=p&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),m.length===0&&x.length===0&&g.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),m.map(Xt),x.map(Zt),g.map(Qt)]}),n=s.oldVersion&&!p&&t.jsx(se,{children:t.jsx(ne,{children:"This host does not report previous permissions. Review all requested access before continuing."})}),e[15]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=d):d=e[15],o=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(Yt)}):t.jsx("p",{className:"text-muted-foreground",children:"No project, connection, storage, or composer access requested."}),e[0]=s.connectionDefinitions,e[1]=s.manifest,e[2]=s.oldVersion,e[3]=s.operation,e[4]=s.previousConnectionDefinitions,e[5]=s.previousManifest,e[6]=i,e[7]=r,e[8]=a,e[9]=n,e[10]=d,e[11]=o}else i=e[6],r=e[7],a=e[8],n=e[9],d=e[10],o=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Kt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let y;e[18]!==s.incompatibleClients?(y=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(De,{children:"Some connected clients cannot run this version"}),t.jsxs(ne,{children:[s.incompatibleClients.join(", "),". Their plugin panels will be unavailable until those clients are updated. Offline clients are checked when they reconnect."]})]}),e[18]=s.incompatibleClients,e[19]=y):y=e[19];let h;e[20]!==s.digest?(h=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=h):h=e[21];let w;return e[22]!==i||e[23]!==r||e[24]!==a||e[25]!==n||e[26]!==d||e[27]!==o||e[28]!==v||e[29]!==y||e[30]!==h?(w=t.jsxs("div",{className:i,children:[r,a,n,d,o,v,y,h]}),e[22]=i,e[23]=r,e[24]=a,e[25]=n,e[26]=d,e[27]=o,e[28]=v,e[29]=y,e[30]=h,e[31]=w):w=e[31],w}function Kt(l){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:l.label}),t.jsxs("p",{children:["Access to ",Object.values(l.resources).map(Wt).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(l.operations).map(Jt))].join(", ")]})]},l.id)}function Jt(l){return l.origin}function Wt(l){return l.label}function Yt(l){return t.jsx("li",{children:l},l)}function Qt(l){return t.jsxs("p",{children:["Changed connection: ",l.label,". Review its destinations and access below."]},l.id)}function Zt(l){return t.jsxs("p",{children:["Removed: ",l]},`remove:${l}`)}function Xt(l){return t.jsxs("p",{children:["Added: ",l]},`add:${l}`)}function ls({client:l,state:e,currentPath:s,onClose:i,initialPluginId:r}){var V;const a=C.useId(),n=e.status,d=ut(),o=(n==null?void 0:n.safeMode)||d,{project:v,resolving:y}=ft({client:l,status:n,activation:e.activation,projectPath:s}),[h,w]=C.useState(null),j=h??{type:"projects",projectIds:v?[v.id]:[]},[c,p]=C.useState(null),[m,x]=C.useState({activation:"",hostName:""}),[g,b]=C.useState(!1),[k,S]=C.useState(!1),[u,N]=C.useState(null),[D,R]=C.useState(null),[A,O]=C.useState("installed"),[I,U]=C.useState(null),[H,z]=C.useState(null),[ee,G]=C.useState(r),F=n==null?void 0:n.store.plugins.find(f=>f.id===ee),K=C.useRef(!1),te=!!(n!=null&&n.store.available)&&m.activation===e.activation;function _(f){x({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),p(f)}C.useEffect(()=>{!c||te&&!(o&&g)||(b(!1),p(null),N("The host connection or plugin execution state changed. Review the package again before installing."),l.cancel(c).catch(()=>{}))},[l,c,te,o,g]),C.useEffect(()=>()=>{c&&l.cancel(c).catch(()=>{})},[l,c]);async function J(f){if(!K.current){K.current=!0,S(!0),N(null),R(null);try{await f()}catch($){N($ instanceof Error?$.message:"Plugin action failed")}finally{K.current=!1,S(!1)}}}function L(){const f=c;b(!1),p(null),f&&l.cancel(f).catch(()=>{})}async function q(){if(!H||!I&&!h&&y)return;const f=await l.stage(H,(I==null?void 0:I.scope)??j);if(I&&f.manifest.id!==I.id)throw await l.cancel(f),new Error(`Choose a package for ${I.manifest.name} (${I.id}).`);_(f)}const T=k||g||!(n!=null&&n.store.available);return t.jsx(ht,{open:!0,onOpenChange:f=>{!f&&!k&&!g&&(L(),i())},children:t.jsxs(mt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!k&&!g,children:[t.jsxs(pt,{children:[t.jsx(xt,{children:"Plugins"}),t.jsx(gt,{children:n?`Installed on ${n.host.name}. Changes apply to every client connected to this host.`:"Connecting to the selected host…"})]}),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 overflow-y-auto",children:[(e.error||u||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:n!=null&&n.store.available&&!u&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:u??e.error??(n==null?void 0:n.store.error)})]}),D&&t.jsx(se,{children:t.jsx(ne,{children:D})}),o&&t.jsxs(se,{children:[t.jsx(De,{children:"Plugin safe mode"}),t.jsxs(ne,{children:["Plugin panels are stopped. You can disable or uninstall plugins here.",(n==null?void 0:n.safeMode)&&" The host owner must restart Cogpit without COGPIT_DISABLE_PLUGINS=1 to resume plugins on this host."]})]}),t.jsx(E,{size:"sm",variant:"outline",disabled:k||g||(n==null?void 0:n.safeMode),onClick:()=>jt(!d),children:d?"Resume plugins in this browser":"Pause plugins in this browser"}),(n==null?void 0:n.store.recoveryCode)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.store.recoveryCode==="STORE_LOCKED"?"Close the other Cogpit process using this data directory, then restart this host.":n.store.recoveryCode==="STORE_VERSION"?"Open this host with the Cogpit version that last used its plugin store, or a newer compatible version.":"Keep the plugin data directory intact. Restart with plugin safe mode enabled and check the host log before restoring a verified backup."}),!n&&t.jsxs(E,{variant:"outline",disabled:k,onClick:()=>{J(()=>l.refresh())},children:[t.jsx(kt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&F&&!c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("h2",{className:"font-medium",children:[F.manifest.name," connections"]}),t.jsx(E,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),t.jsx(Lt,{client:l,status:n,pluginId:F.id,initialProjectId:(v==null?void 0:v.id)??null},`${F.id}:${n.store.revision}`)]}),n&&!F&&!c&&t.jsxs(bt,{value:A,onValueChange:f=>{O(String(f)),U(null),z(null)},children:[t.jsxs(vt,{className:"h-auto flex-wrap",children:[t.jsx(Ae,{value:"installed",children:"Installed"}),t.jsx(Ae,{value:"browse",children:"Browse"}),t.jsx(Ae,{value:"install",children:"Install from file"}),t.jsx(Ae,{value:"publishers",children:"Publishers"})]}),t.jsx(Oe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(f=>t.jsx(qt,{plugin:f,status:n,client:l,busy:T,run:$=>{J($)},onPreview:_,onConnections:G,onUpdate:$=>{U($),z(null),O("install")}},`${f.id}:${n.store.revision}`)):t.jsx(yt,{children:t.jsxs(Ct,{children:[t.jsx(wt,{variant:"icon",children:t.jsx($t,{})}),t.jsx(Nt,{children:"No installed plugins"}),t.jsx(St,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Oe,{value:"browse",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["These optional plugins are available with this Cogpit release. Choose which ones to install on ",n.host.name,"."]}),t.jsx(qe,{value:j,onChange:w,projects:n.projects,disabled:T}),(n.store.availableSeeds??[]).map(f=>{const $=n.store.plugins.find(M=>M.id===f.manifest.id),W=$&&It(f.manifest.version,$.manifest.version)===1;return t.jsxs("article",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:f.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.manifest.version," · ",f.manifest.publisher]})]}),W?t.jsx(E,{size:"sm",disabled:T||$.pinned,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,$.scope)))},children:$.pinned?"Pinned to installed version":"Review update"}):$?t.jsx($e,{variant:"outline",children:"Installed"}):t.jsx(E,{size:"sm",disabled:T||!h&&y,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,j)))},children:"Review installation"})]},f.manifest.id)}),!((V=n.store.availableSeeds)!=null&&V.length)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This host has no bundled plugin packages. You can install a signed package from a file."})]})}),t.jsx(Oe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:f=>{f.preventDefault(),J(q)},children:t.jsxs(Fe,{children:[I&&t.jsxs("p",{className:"text-sm",children:["Update ",I.manifest.name," from ",I.manifest.version,". Existing project access is retained."]}),t.jsxs(Z,{children:[t.jsx(X,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(de,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:T,required:!0,onChange:f=>{var $;return z((($=f.target.files)==null?void 0:$[0])??null)}})]}),!I&&t.jsx(qe,{value:j,onChange:w,projects:n.projects,disabled:T}),t.jsxs(E,{type:"submit",disabled:T||!H||!I&&!h&&y,children:["Review ",I?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Oe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(f=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[f.label," ",t.jsx($e,{variant:"outline",children:f.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[f.id," · ",f.fingerprint]})]},f.id)),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Trust a development publisher"}),t.jsx("div",{className:"pt-4",children:t.jsx(Rt,{client:l,busy:T,run:f=>{J(f)}})})]})]})})]}),c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"text-lg font-medium",children:[c.manifest.name," ",c.manifest.version]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.oldVersion?`Replaces ${c.oldVersion}`:"New installation"," on ",m.hostName]}),t.jsx($e,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Gt,{preview:c}),t.jsxs("p",{className:"text-sm",children:["Available in: ",c.scope.type==="all"?"all projects on this host, including new projects":c.scope.projectIds.length?c.scope.projectIds.map(f=>{var $;return(($=n==null?void 0:n.projects.find(W=>W.id===f))==null?void 0:$.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(f=>t.jsxs("li",{children:[f.side,": ",f.name," requires ",f.required,"; available ",f.actual??"none","."]},`${f.side}:${f.code}:${f.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(f=>f.name).join(", "),"."]})}),g&&te&&!o?t.jsxs(t.Fragment,{children:[t.jsx(At,{client:l,preview:c,activation:e.activation,onComplete:()=>{b(!1),p(null),R(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${m.hostName}.`),O("installed"),U(null)},onError:f=>{N(f.message),L()}}),t.jsxs(E,{variant:"outline",onClick:L,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(E,{variant:"outline",disabled:k,onClick:L,children:"Cancel"}),t.jsxs(E,{disabled:T||!te||!c.compatibility.compatible||o,onClick:()=>{N(null),b(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",m.hostName]})]})]})]})]})})}export{ls as PluginsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as t}from"./vendor-react-gGw_S5I_.js";import{y as ne,B as g,l as K,z as ie,C as oe,m as le,n as ce,I as de,E as G,G as ue,T as he,H as pe,J as me,L as fe,M as xe,N as we,O as ve,Q as ge,R as be,U as je,w as b}from"./index-
|
|
1
|
+
import{r as a,j as t}from"./vendor-react-gGw_S5I_.js";import{y as ne,B as g,l as K,z as ie,C as oe,m as le,n as ce,I as de,E as G,G as ue,T as he,H as pe,J as me,L as fe,M as xe,N as we,O as ve,Q as ge,R as be,U as je,w as b}from"./index-BVrmKCdP.js";import{E as H,X as ye,a as Se,b as Ne,c as Ie,M as Ee,T as ke,d as Me,e as Pe,Z as ze,f as Re}from"./vendor-ui-Dfr2Rf5Q.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const O=360,Ce=560,V="cogpit-preview-width",Y="cogpit-preview-viewport",_="cogpit-preview-zoom",E=.5,k=1.5,I=.1,h={responsive:{label:"Responsive",width:null,height:null,icon:Pe},phone:{label:"Phone",width:390,height:844,icon:Me},tablet:{label:"Tablet",width:768,height:1024,icon:ke},desktop:{label:"Desktop",width:1280,height:800,icon:Ee}};function Te(){try{const s=Number(localStorage.getItem(V));if(Number.isFinite(s)&&s>=O)return s}catch{}return Ce}function De(){try{const s=localStorage.getItem(Y);if(s&&s in h)return s}catch{}return"responsive"}function Oe(){try{const s=localStorage.getItem(_);if(s===null)return 1;const i=Number(s);if(Number.isFinite(i))return Math.min(k,Math.max(E,i))}catch{}return 1}function X(s){return be(`cogpit-preview-url:${s}`)}function A(s){const i=s.trim();if(!i||/^[a-z][a-z\d+.-]*:/i.test(i)&&!/^https?:\/\//i.test(i)&&!/^[^/]+:\d+(?:\/|$)/.test(i))return null;const j=/^https?:\/\//i.test(i)?i:`http://${i}`;try{const n=new URL(j);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}catch{return null}}function B(s,i){return`http://${i||"localhost"}:${s}/`}function Le({cwd:s,onClose:i}){const[M,j]=a.useState([]),[n,P]=a.useState(""),[W,y]=a.useState(""),[z,R]=a.useState(null),[J,Q]=a.useState(0),[q,C]=a.useState(!1),[S,ee]=a.useState(Te),[l,te]=a.useState(De),[o,p]=a.useState(Oe),c=a.useRef(null),$=a.useRef(null),T=a.useRef(null),{activeDevice:m}=ne(),N=(m==null?void 0:m.host)??(window.location.hostname||"localhost"),re=m==null?void 0:m.id;a.useEffect(()=>{let e="";try{e=localStorage.getItem(X(s))??""}catch{}const r=e?A(e)??"":"";P(r),y(r),R(null)},[s,re]),a.useEffect(()=>{let e=!1;async function r(){try{const u=await je(`/api/background-tasks?cwd=${encodeURIComponent(s)}`);if(e||!u.ok)return;const x=await u.json(),f=Array.isArray(x)?x:[];j(f);const L=f.flatMap(w=>w.ports.filter(v=>w.portStatus[v])).at(0);if(L){const w=B(L,N);P(v=>v||w),y(v=>v||w)}}catch{e||j([])}}r();const d=window.setInterval(r,1e4);return()=>{e=!0,window.clearInterval(d)}},[s,N]),a.useEffect(()=>{if(n)try{localStorage.setItem(X(s),n)}catch{}},[s,n]),a.useEffect(()=>{try{localStorage.setItem(Y,l),localStorage.setItem(_,String(o))}catch{}},[l,o]);const Z=a.useMemo(()=>[...new Set(M.flatMap(e=>e.ports.filter(r=>e.portStatus[r])))].sort((e,r)=>e-r),[M]),U=a.useCallback(e=>{const r=A(e);if(!r){R("Enter a valid HTTP or HTTPS URL.");return}R(null),P(r),y(r),C(!0)},[]),D=a.useCallback(()=>{n&&(C(!0),Q(e=>e+1))},[n]);a.useEffect(()=>{function e(r){var d,u,x;if((d=$.current)!=null&&d.contains(document.activeElement)){if(b("previewRefresh",r)){r.preventDefault(),D();return}if(b("previewFocusUrl",r)){r.preventDefault(),(u=T.current)==null||u.focus(),(x=T.current)==null||x.select();return}if(b("previewZoomIn",r)){r.preventDefault(),p(f=>Math.min(k,Number((f+I).toFixed(1))));return}if(b("previewZoomOut",r)){r.preventDefault(),p(f=>Math.max(E,Number((f-I).toFixed(1))));return}b("previewResetZoom",r)&&(r.preventDefault(),p(1))}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[D]);const se=a.useCallback(e=>{e.preventDefault(),c.current={startX:e.clientX,startWidth:S,currentWidth:S},e.currentTarget.setPointerCapture(e.pointerId)},[S]),ae=a.useCallback(e=>{if(!c.current)return;const r=Math.max(O,window.innerWidth*.7),d=c.current.startWidth+(c.current.startX-e.clientX),u=Math.min(r,Math.max(O,d));c.current.currentWidth=u,ee(u)},[]),F=a.useCallback(()=>{if(!c.current)return;const e=c.current.currentWidth;c.current=null;try{localStorage.setItem(V,String(e))}catch{}},[]);return t.jsxs("aside",{ref:$,"aria-label":"Development preview",className:"view-transition-right-panel panel-enter-right relative flex min-h-0 shrink-0 flex-col border-l bg-canvas",style:{width:S},children:[t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-primary/30",onPointerDown:se,onPointerMove:ae,onPointerUp:F,onPointerCancel:F}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(H,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Preview"}),t.jsx("span",{className:"flex-1"}),t.jsx(g,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close preview",children:t.jsx(ye,{"data-icon":"inline-start"})})]}),t.jsx(K,{}),t.jsx("form",{className:"p-2",onSubmit:e=>{e.preventDefault(),U(W)},children:t.jsx(ie,{className:"gap-2",children:t.jsxs(oe,{"data-invalid":!!z,children:[t.jsxs(le,{children:[t.jsx(ce,{ref:T,"aria-label":"Preview URL","aria-invalid":!!z,value:W,onChange:e=>y(e.target.value),placeholder:"localhost:3000",spellCheck:!1}),t.jsxs(de,{align:"inline-end",children:[t.jsx(G,{size:"icon-xs",disabled:!n,onClick:D,"aria-label":"Refresh preview",children:t.jsx(Se,{"data-icon":"inline-start",className:q?"animate-spin":void 0})}),t.jsx(G,{size:"icon-xs",disabled:!n,onClick:()=>window.open(n,"_blank","noopener,noreferrer"),"aria-label":"Open preview in browser",children:t.jsx(Ne,{"data-icon":"inline-start"})})]})]}),t.jsx(ue,{children:z})]})})}),Z.length>0&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto px-2 pb-2",children:[t.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),Z.map(e=>t.jsxs(g,{variant:"outline",size:"xs",className:"font-mono text-xs",onClick:()=>U(B(e,N)),"aria-label":`Open ${N}:${e} preview`,children:[":",e]},e))]}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-2 pb-2",children:[t.jsx(he,{"aria-label":"Preview viewport",value:[l],onValueChange:e=>{const r=e[0];r&&r in h&&te(r)},variant:"outline",size:"sm",spacing:0,children:Object.entries(h).map(([e,r])=>{const d=r.icon;return t.jsx(pe,{value:e,"aria-label":`${r.label} viewport`,title:r.width?`${r.label} · ${r.width}×${r.height}`:r.label,children:t.jsx(d,{})},e)})}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o<=E,onClick:()=>p(e=>Math.max(E,Number((e-I).toFixed(1)))),"aria-label":"Zoom preview out",title:"Zoom out",children:t.jsx(ze,{"data-icon":"inline-start"})}),t.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>p(1),"aria-label":"Reset preview zoom",children:[Math.round(o*100),"%"]}),t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o>=k,onClick:()=>p(e=>Math.min(k,Number((e+I).toFixed(1)))),"aria-label":"Zoom preview in",title:"Zoom in",children:t.jsx(Re,{"data-icon":"inline-start"})})]})]}),t.jsx(K,{}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/30 p-3",children:n?t.jsx("div",{className:me("relative mx-auto overflow-hidden bg-white ring-1 ring-border",l==="responsive"&&"size-full"),style:l==="responsive"?void 0:{width:h[l].width*o,height:h[l].height*o},children:t.jsx("iframe",{title:"Development preview",src:n,className:"block border-0 bg-white",style:l==="responsive"?{width:`${100/o}%`,height:`${100/o}%`,transform:`scale(${o})`,transformOrigin:"top left"}:{width:h[l].width,height:h[l].height,transform:`scale(${o})`,transformOrigin:"top left"},sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>C(!1)},`${n}-${J}`)}):t.jsx(fe,{className:"size-full",children:t.jsxs(xe,{children:[t.jsx(we,{variant:"icon",children:t.jsx(H,{})}),t.jsx(ve,{children:"No preview selected"}),t.jsx(ge,{children:"Start a local development server or enter its URL above. Detected ports appear automatically."})]})})})]})}export{Le as PreviewPanel,A as normalizePreviewUrl};
|