epiq 1.17.0 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import{a as F}from"./chunk-6R2YRUOL.js";import{$ as In,A as ee,B as Tt,D as nn,E as sn,F as an,G as ln,H as mn,I as cn,J as dn,K as un,M as pn,N as fn,P as gn,Q as yn,R as hn,S as bn,T as no,U as Et,V as xn,W as wn,Y as vn,Z as Sn,a as Ur,b as pe,ba as Tn,c as ie,ca as En,d as Gr,e as $r,ea as Cn,f as Fr,fa as Pn,g as Hr,ga as Ct,h as kr,ha as Pt,i as Wr,ia as An,j as Vr,ja as Nn,ka as Mn,l as Yr,la as io,m as Kr,ma as so,n as qr,na as Rn,oa as Ae,p as Jr,pa as ao,q as Xr,qa as Bn,r as zr,ra as Ln,s as Qr,t as Zr,ta as jn,u as en,ua as _n,v as tn,va as Dn,w as on,y as rn,z as It}from"./chunk-J3S3W27J.js";import{$ as Xo,$b as xt,Ac as Fe,Bb as dr,Cb as ur,Cc as jr,Db as ne,Dc as _r,E as oo,Ea as zo,Eb as pr,Ec as Dr,Fb as fr,Fc as q,G as Ho,Gb as b,Hb as gr,Ib as yt,L as ko,La as $e,Lb as Ce,Lc as Or,Ma as Qo,Nb as yr,Ob as ue,P as Wo,Q as Vo,Sa as de,Sb as ht,T as ct,Tb as bt,U as Te,Ua as Ee,V as Yo,X as H,Xb as hr,Y as Ko,Yb as br,Z as qo,Zb as xr,_ as Jo,_b as wr,a as jo,aa as dt,ac as vr,b as st,ba as Ge,bb as Zo,bc as Sr,c as at,cb as er,cc as wt,da as ut,db as tr,dc as Ir,ea as pt,eb as gt,ec as Tr,fc as Er,g as lt,ha as ft,hb as or,ib as rr,ic as Cr,j as _o,jb as nr,jc as Pr,k as oe,kb as ir,kc as Ar,l as Do,lc as Nr,n as Ie,o as re,p as Oo,pc as Mr,q as Ue,qc as ro,r as m,rc as Rr,s as Uo,sc as vt,t as Go,tb as sr,tc as St,u as $o,ub as ar,uc as Br,v as Fo,vb as lr,vc as Lr,w as to,wb as mr,wc as Q,x as mt,xb as cr,xc as Pe,zc as O}from"./chunk-5WUPZIRV.js";import{f as it,g as Lo}from"./chunk-WUCQWBQE.js";import{b as G,c as T,d as h,e as $}from"./chunk-5RIQL7P4.js";import z from"chalk";import{render as Dl}from"ink";import Ol from"meow";import Ul from"react";import bs from"node:os";import xs from"node:path";import He from"chalk";var At=["\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557","\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551","\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551\u2584\u2584 \u2588\u2588\u2551","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D","\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2580\u2580\u255D "];var Nt=" ",Gn=He.hex(m.secondary2),On=He.hex(m.gray),ws=()=>{let t=At[0].length+At.length*2;return At.map((o,n)=>Array.from(o).map((s,u)=>{let[r,f,y]=Go((u+n*2)/t);return He.rgb(r,f,y)(s)}).join(""))},vs=e=>{let t=bs.homedir();return e===t||e.startsWith(t+xs.sep)?"~"+e.slice(t.length):e},Un=(e,t)=>`${Nt}${He.hex(m.accent)("\u279C")} ${Gn(e.padEnd(9))}${t}`,lo=({url:e,repoRoot:t,version:o,reused:n})=>["",...ws().map(s=>Nt+s),"",`${Nt}${Gn("gui")} ${On(`\xB7 v${o}`)}`,"",Un("Local",He.hex(m.accent).bold(e)),Un("Project",vs(t)),"",Nt+On(n?"already running for this project \xB7 opened in your browser":"press ctrl+c to stop"),""].join(`
3
+ `);import{spawn as Ss}from"node:child_process";import ke from"node:process";var $n=(e=ke.platform,t=ke.env)=>e==="darwin"||e==="win32"||!!(t.DISPLAY||t.WAYLAND_DISPLAY||t.BROWSER),Fn=e=>{let t=ke.platform==="darwin"?"open":ke.platform==="win32"?"cmd":"xdg-open",o=ke.platform==="win32"?["/c","start","",e]:[e];try{let n=Ss(t,o,{detached:!0,stdio:"ignore"});n.on("error",s=>{logger.info(`[gui] could not open a browser: ${s.message}`)}),n.unref()}catch(n){logger.info(`[gui] could not open a browser: ${String(n)}`)}};import{readFile as xi,stat as ca}from"node:fs/promises";import{createHash as da}from"node:crypto";import ua from"node:http";import xe from"node:path";import{fileURLToPath as pa}from"node:url";import Is from"node:fs";import Hn from"node:path";var We=Number(process.env.EPIQ_GUI_PORT)||3710,mo="/api/instance",co="epiq",Mt=e=>{try{return Is.realpathSync(Hn.resolve(e))}catch{return Hn.resolve(e)}},Ts=e=>{let t=e;return typeof t=="object"&&t!==null&&t.app===co&&typeof t.repoRoot=="string"&&typeof t.version=="string"&&typeof t.pid=="number"},kn=async(e,t=500)=>{let o=new AbortController,n=setTimeout(()=>o.abort(),t);try{let s=await fetch(`http://127.0.0.1:${e}${mo}`,{signal:o.signal});if(!s.ok)return null;let u=await s.json();return Ts(u)?u:null}catch{return null}finally{clearTimeout(n)}};var Es=6e4,Wn=e=>{let t,o=!1,n=!1,s=0,u=()=>{let g=Do();return h(g)?(st.error(g.message),null):g.value},r=()=>{let g=u();if(!g)return!1;let l=Ie();return h(l)?!1:!!g.autoSync&&Mr(l.value)===null},f=()=>{let g=jo(u()?.autoSyncDebounceMs);return Math.max(0,g-(Date.now()-s))},y=async()=>{if(!(o||n)&&r()){n=!0,s=Date.now();try{await pe(async()=>{if(ie().mode!=="live")return!1;let l=await Tt({repoRoot:e.project.repoRoot});return await e.publisher.publishIfLogMoved(),!h(l)})&&e.onReposFetch?.(Es)}finally{n=!1,p()}}};function p(){o||!r()||n||t||(t=setTimeout(()=>{t=void 0,y()},f()))}return p(),{queueSync:p,reschedule:()=>{t&&(clearTimeout(t),t=void 0),p()},dispose:()=>{o=!0,t&&clearTimeout(t)}}};var Rt=(e,t)=>{let o,n=!1,s=async()=>{let u=Date.now();try{await e()}catch(r){logger.error("[watch] check threw",r)}n||(o=setTimeout(s,Math.max(t,Date.now()-u)))};return o=setTimeout(s,t),()=>{n=!0,o&&clearTimeout(o)}};var Cs=/^(```|~~~)[^\n]*\n[\s\S]*?\n\1[ \t]*$/gm,Ps=/^(?:```|~~~)[\s\S]*$/m,As=/^[ \t]*\|?[ \t]*:?-{2,}:?[ \t]*(?:\|[ \t]*:?-{2,}:?[ \t]*)*\|?[ \t]*$/gm,Ns=/^[ \t]*\|.*$/gm,Ms=/!\[[^\]]*\]\([^)]*\)/g,Rs=/\[([^\]]*)\]\([^)]*\)/g,Bs=/^[ \t]*(?:[#>]+[ \t]*|[-*+][ \t]+|\d+[.)][ \t]+)/gm,Ls=/^[ \t]*(?:-{3,}|\*{3,}|_{3,})[ \t]*$/gm,js=/[*`~]/g,_s=/(?<![0-9A-Za-z])_|_(?![0-9A-Za-z])/g,Ds=e=>Jo(e.replace(Cs," ").replace(Ps," ").replace(Ms," ").replace(Rs,"$1").replace(Ls," ").replace(As," ").replace(Ns,t=>t.replaceAll("|"," ")).replace(Bs,"").replace(js,"").replace(_s,"")),Os=.5,Vn=(e,t)=>{if(t<=0)return"";let o=Ds(e);if(o.length<=t)return o;let n="\u2026",s=t-n.length;if(s<=0)return n.slice(0,t);let u=o.slice(0,s),r=u.lastIndexOf(" ");return`${(r>=s*Os?u.slice(0,r):u).trimEnd()}${n}`};var Us=e=>({...e,boards:(e.boards??[]).map(t=>({...t,swimlanes:(t.swimlanes??[]).map(o=>({...o,issues:(o.issues??[]).map(n=>({...n,description:""}))}))})),commentsByIssueId:Object.fromEntries(Object.entries(e.commentsByIssueId??{}).filter(([,t])=>t.length>0).map(([t,o])=>[t,o.map(n=>({...n,body:""}))])),attachmentsByIssueId:Object.fromEntries(Object.entries(e.attachmentsByIssueId??{}).filter(([,t])=>t.length>0))}),be=e=>h(e)?e:T(e.message,Us(e.value)),Gs=(e,t)=>(e.boards??[]).flatMap(o=>o.swimlanes??[]).flatMap(o=>o.issues??[]).find(o=>o.id===t),Yn=(e,t)=>{let o=Gs(e,t);return{issueId:t,description:o?.description??"",comments:e.commentsByIssueId?.[t]??[]}},$s=280,Kn=(e,t)=>({issueId:e,excerpt:Vn(t,$s)});var Fs=1e3,qn=e=>{let t=oe(e.repoRoot);if(h(t))return null;let o=lt({repoRoot:t.value});return h(o)?null:o.value},Jn=e=>{let t=()=>{let r=qn(e.project);return r===null?null:$e(r)},o=()=>{let r=tr(e.project.repoRoot);return h(r)?null:JSON.stringify([r.value.live,r.value.overLimit])},n=o(),s=t();return{publishIfLogMoved:async()=>{let r=qn(e.project);if(r===null||await gt(r))return;let f=$e(r);if(f===s)return;s=f;let y=be(await ee({repoRoot:e.project.repoRoot}));if(h(y))return;ue({type:"state",payload:y});let p=o();p!==null&&p!==n&&(n=p,ue({type:"repos:changed"}))}}},Xn=(e,t=Fs)=>Rt(()=>pe(async()=>{ie().mode==="live"&&await e.publishIfLogMoved()}),t);var Hs=new Set(["127.0.0.1","[::1]","localhost","epiq.localhost"]),uo=(e,t)=>{if(!e)return!1;if(e==="null")return!0;let o;try{o=new URL(e)}catch{return!0}return o.protocol!=="http:"||o.port!==String(t)?!0:!Hs.has(o.hostname)},zn=(e,t)=>e.method==="GET"||e.method==="HEAD"?null:uo(e.origin,t)?{status:403,message:"Cross-origin request"}:e.method==="POST"&&!(e.contentType??"").toLowerCase().startsWith("application/json")?{status:415,message:"Expected content-type: application/json"}:null;import{WebSocketServer as sa}from"ws";var ks=e=>{let t={};for(let o of e){let n=or(o.subject),s=new Set([...n?[n]:[],...o.refs??[]]);for(let u of s)(t[u]??=[]).push({time:o.time,insertions:o.insertions,deletions:o.deletions})}return t},Qn=async(e={})=>{let t=await rr(e.repoRoot);return h(t)?t:T("Collected commits by ref",ks(t.value))};var Ws="Filed here",Zn=(e,t)=>e.set(t,(e.get(t)??0)+1),ei=(e,t,o)=>[...e.entries()].map(([n,s])=>({laneId:n,title:n===null?Ws:o(n),count:s,share:t===0?0:s/t})).sort((n,s)=>s.count-n.count||n.title.localeCompare(s.title)),ti=(e,t,o)=>{let n=new Map,s=new Map,u=0,r=0;for(let f of t)for(let[y,p]of f.entries()){if(p!==e)continue;u++,Zn(n,f[y-1]??null);let g=f[y+1];g!==void 0&&(r++,Zn(s,g))}return{arrived:u,departed:r,arrivesFrom:ei(n,u,o),movesOnTo:ei(s,r,o)}};var Ve=1440*60*1e3,Vs=({laneIds:e,journeys:t,now:o,days:n})=>{let s=o-(n-1)*Ve,u=new Map(e.map(r=>[r,Array.from({length:n},()=>[])]));for(let r of t)for(let[f,y]of r.entries()){let p=u.get(y.laneId);if(!p)continue;let g=r[f+1]?.enteredAt,l=Math.max(0,Math.ceil((y.enteredAt-s)/Ve)),d=g===void 0?n-1:Math.min(n-1,Math.ceil((g-s)/Ve)-1);for(let a=l;a<=d;a++)p[a].push(s+a*Ve-y.enteredAt)}return Object.fromEntries([...u].map(([r,f])=>[r,f.map((y,p)=>({t:s+p*Ve,median:_n(y.sort((g,l)=>g-l)),count:y.length}))]))},oi=({laneId:e,journeys:t,now:o,days:n})=>Vs({laneIds:[e],journeys:t,now:o,days:n})[e];var Ys=40,Ks=30,qs=()=>({tickets:0,commits:0,insertions:0,deletions:0}),Js=async(e,t)=>{let o=qs();for(let n of t.slice(0,Ys)){let s=await Et({repoRoot:e,idOrRef:de(n)});h(s)||s.value.shape.commits===0||(o.tickets++,o.commits+=s.value.shape.commits,o.insertions+=s.value.shape.insertions,o.deletions+=s.value.shape.deletions)}return o},ri=async e=>{let t=Vr();if(h(t))return t;let{nodes:o}=t.value;if(!o[e.swimlaneId])return G("Swimlane not found");let s=Object.values(o).filter(ct),u=s.map(y=>Ur(y.log??[],oo(y.id))),r=ti(e.swimlaneId,u.map(y=>y.map(p=>p.laneId)),y=>o[y]?.title??"Elsewhere"),f=s.filter(y=>y.parentNodeId===e.swimlaneId).map(y=>y.id);return T("Derived swimlane stats",{swimlaneId:e.swimlaneId,createdAt:oo(e.swimlaneId),...r,stayTrend:oi({laneId:e.swimlaneId,journeys:u,now:Date.now(),days:Ks}),code:await Js(e.repoRoot,f)})};var ni=new Set(["sync","email:link","email:unlink","repo:connect","repo:disconnect","issues:create","board:create","board:edit:title","swimlane:create","swimlane:edit:title","board:edit:description","swimlane:edit:description","swimlane:rule:set","goal:edit:description","swimlane:delete","swimlane:move","issues:move","issue:close","issue:reopen","issue:edit:title","issue:edit:description","issue:tag:add","issue:tag:remove","issue:goal:set","goal:create","goal:rename","goal:remove","contributor:remove","tag:remove","issue:assignee:add","issue:assignee:remove","issue:comment:add","issue:comment:delete"]);var ii=e=>{let t=Ge({exclude:e});return h(t)?[]:t.value.map(o=>({projectId:o.projectId,name:dt(o.root),root:o.root,lastOpenedAt:o.lastOpenedAt}))},si=e=>{let t=Ge();if(h(t))return G(t.message);let o=t.value.find(n=>n.root===e);return o?T("Resolved recent project",o.root):G(`Not a recent project: ${e}`)};import{z as c}from"zod";var v=c.string().min(1),ai=c.discriminatedUnion("at",[c.object({at:c.literal("start")}),c.object({at:c.literal("end")}),c.object({at:c.literal("before"),sibling:v}),c.object({at:c.literal("after"),sibling:v})]),ae=c.number().finite(),w=(e,t)=>c.object({type:c.literal(e),payload:t}),le=e=>c.object({type:c.literal(e)}),Xs=c.discriminatedUnion("type",[le("state:get"),le("issues:list"),le("sync"),le("time-travel:live"),le("diff-stats:get"),w("project:open",c.object({root:c.string().min(1)})),w("issues:create",c.object({title:c.string(),parentId:v,description:c.string().optional(),tagNames:c.array(c.string()).optional()})),w("board:create",c.object({title:c.string()})),w("board:edit:title",c.object({boardId:v,title:c.string()})),w("swimlane:create",c.object({title:c.string(),boardId:v})),w("swimlane:edit:title",c.object({swimlaneId:v,title:c.string()})),w("board:edit:description",c.object({boardId:v,description:c.string()})),w("swimlane:edit:description",c.object({swimlaneId:v,description:c.string()})),w("swimlane:rule:set",c.object({swimlaneId:v,rule:c.string().min(1).max(64),on:c.boolean()})),w("goal:edit:description",c.object({goalId:v,description:c.string()})),w("swimlane:delete",c.object({swimlaneId:v})),w("swimlane:move",c.object({swimlaneId:v,boardId:v,position:ai.optional()})),w("issues:move",c.object({issueId:v,parentId:v,position:ai.optional()})),w("issue:edit:title",c.object({issueId:v,title:c.string()})),w("issue:edit:description",c.object({issueId:v,description:c.string()})),w("issue:tag:add",c.object({issueId:v,tagName:c.string()})),w("issue:goal:set",c.object({issueId:v,goal:v.nullable()})),w("goal:create",c.object({name:c.string(),issueId:v.optional()})),w("goal:rename",c.object({goalId:v,name:c.string()})),w("goal:remove",c.object({goalId:v})),w("issue:tag:remove",c.object({issueId:v,tagId:v})),w("contributor:remove",c.object({contributorId:v})),w("tag:remove",c.object({tagId:v})),c.object({type:c.literal("contributors:get"),payload:c.object({boardId:v.optional()}).optional()}),w("issue:assignee:add",c.object({issueId:v,assigneeId:v.optional(),assigneeName:c.string().optional(),createUnlinked:c.boolean().optional()})),w("issue:assignee:remove",c.object({issueId:v,assigneeId:v})),w("issue:close",c.object({issueId:v})),w("issue:reopen",c.object({issueId:v})),w("issue:comment:add",c.object({issueId:v,body:c.string()})),w("issue:comment:delete",c.object({issueId:v,commentId:v})),w("issue:comment:edit",c.object({issueId:v,commentId:v,body:c.string()})),w("issue:get",c.object({issueId:v})),w("issue:preview:get",c.object({issueId:v})),c.object({type:c.literal("timeline:get"),payload:c.object({start:ae.optional(),end:ae.optional(),boardId:v.optional(),requestId:c.number().finite().optional()}).optional()}),c.object({type:c.literal("commits:get"),payload:c.object({start:ae.optional(),end:ae.optional(),requestId:c.number().finite().optional()}).optional()}),w("time-travel:scrub",c.object({targetTime:ae})),w("time-travel:checkout-event",c.object({eventId:c.string().min(1)})),w("commit:inspect",c.object({sha:c.string(),repo:c.string().max(80).optional()})),le("repos:get"),w("repo:preview",c.object({url:c.string().min(1).max(mt),branches:c.enum(["default","all"]).optional(),since:c.string().max(20).optional(),label:c.string().max(24).optional()})),w("repo:preview:cancel",c.union([c.object({repo:c.string().min(1).max(80)}),c.object({url:c.string().min(1).max(mt)})])),w("repo:connect",c.object({url:c.string().min(1).max(mt),branches:c.enum(["default","all"]).optional(),since:c.string().max(20).optional(),label:c.string().max(24).optional()})),w("repo:disconnect",c.object({repo:c.string().min(1).max(2e3)})),c.object({type:c.literal("emails:get")}),w("email:link",c.object({email:c.string().min(1).max(254),contributorId:c.string().min(1).optional()})),w("email:unlink",c.object({email:c.string().min(1).max(254),contributorId:c.string().min(1).optional()})),w("commit:diff:get",c.object({sha:c.string(),repo:c.string().max(80).optional()})),w("issue:commits:get",c.object({issueId:v})),w("issue:squashed-diff:get",c.object({issueId:v,asOfTime:ae.optional()})),w("issue:stats:get",c.object({issueId:v,asOfTime:ae.optional()})),w("swimlane:stats:get",c.object({swimlaneId:v})),w("goal:stats:get",c.object({goalId:v,key:c.string().max(200),asOfTime:ae.optional()})),w("goal:commits:get",c.object({goalId:v,key:c.string().max(200),asOfTime:ae.optional()})),w("board:overview:get",c.object({boardId:v})),le("me:stats:get"),le("settings:get"),le("version:get"),w("settings:set",c.object({autoSync:c.boolean().optional(),autoSyncIntervalMs:c.number().finite().optional()}))]);var li=e=>{let t=Xs.safeParse(e);return t.success?{ok:!0,message:t.data}:{ok:!1,error:`Invalid message: ${t.error.issues.map(n=>`${n.path.join(".")||"<root>"}: ${n.message}`).join(", ")}`}};var zs="https://registry.npmjs.org/epiq/latest",Qs="https://api.github.com/repos/ljtn/epiq/releases?per_page=30",Zs="https://raw.githubusercontent.com/ljtn/epiq/main/install.sh";var mi=new Map,po=new Map;var go=/^v?\d+\.\d+\.\d+$/,fo=e=>e.replace(/^v/,""),Ne=(e,t)=>{let o=fo(e).split(".").map(Number),n=fo(t).split(".").map(Number);for(let s=0;s<Math.max(o.length,n.length);s++){let u=o[s]??0,r=n[s]??0;if(u>r)return 1;if(u<r)return-1}return 0},ea=()=>process.env.IS_CI==="true"||process.env.EPIQ_NO_UPDATE_CHECK==="1",ta=async e=>{try{let t=await fetch(e,{signal:AbortSignal.timeout(5e3),headers:{accept:"application/json"}});return t.ok?await t.json():null}catch{return null}},ui=(e,t=()=>!0)=>{let o=mi.get(e);if(o&&Date.now()-o.at<o.ttl)return Promise.resolve(o.body);let n=po.get(e);if(n)return n;let s=ta(e).then(u=>(mi.set(e,{at:Date.now(),ttl:u!==null&&t(u)?864e5:36e5,body:u}),po.delete(e),u));return po.set(e,s),s},yo=async e=>{if(ea())return{current:e,latest:null,updateAvailable:!1};let t=await ui(zs),o=typeof t?.version=="string"&&go.test(t.version)?t.version:null;return{current:e,latest:o,updateAvailable:o?Ne(o,e)>0:!1}},oa=e=>{let t=[],o=null;for(let n of e.replace(/\r/g,"").split(`
4
+ `)){let s=n.trimEnd();if(s.trim())if(/^[-*] /.test(s.trimStart())&&!/^\s{2,}/.test(s))o||(o={title:null,items:[]},t.push(o)),o.items.push(s.trimStart().slice(2).trim());else if(/^\s+/.test(s)&&o?.items.length)o.items[o.items.length-1]+=` ${s.trim()}`;else{if(go.test(s.trim())&&t.length===0)continue;o={title:s.replace(/^#+\s*/,"").trim(),items:[]},t.push(o)}}return t.filter(n=>n.items.length>0)},ra=e=>{let t=e;return typeof t?.tag_name!="string"||!go.test(t.tag_name)||t.draft||t.prerelease?null:{version:fo(t.tag_name),url:typeof t.html_url=="string"?t.html_url:"",publishedAt:typeof t.published_at=="string"&&!Number.isNaN(Date.parse(t.published_at))?t.published_at:null,sections:typeof t.body=="string"?oa(t.body):[]}},ci=e=>Array.isArray(e)?e.map(ra).filter(t=>!!t):[],na=async e=>ci(await ui(Qs,t=>ci(t).some(o=>Ne(o.version,e)===0))),ia=(e,t,o)=>e.filter(n=>Ne(n.version,t)>0&&Ne(n.version,o)<=0).sort((n,s)=>Ne(s.version,n.version)),di={script:`curl -fsSL ${Zs} | sh`,npm:"npm install --global epiq@latest"},pi=async e=>{let t=await yo(e);if(!t.updateAvailable||!t.latest)return{...t,releases:[],currentPublishedAt:null,commands:di};let o=await na(t.latest);return{...t,releases:ia(o,e,t.latest),currentPublishedAt:o.find(n=>Ne(n.version,e)===0)?.publishedAt??null,commands:di}};var aa=1024*1024,ho=()=>{ue({type:"state",payload:be(It())})},fi=()=>{ue({type:"repos:changed"})},bo=async(e,t)=>{la(await jn({repoRoot:e,minIntervalMs:t}))},la=e=>{h(e)||(e.value.some(t=>t.changed)&&fi(),e.value.some(t=>t.changed||!t.ok)&&ue({type:"repos:fetched"}))},S=(e,t)=>{e.send(JSON.stringify(t))},Ye=async(e,t)=>{let o=be(await ee({repoRoot:t}));return h(o)&&o.message===_o?S(e,{type:"state:unavailable",payload:{message:o.message,repoRoot:t,recentProjects:ii(t)}}):S(e,{type:"state",payload:o})},ma=async(e,t)=>{let o=()=>S(e,{type:"state",payload:be(It())});if(ie().mode!=="live")return o();let n=await ee({repoRoot:t});return ie().mode!=="live"?o():S(e,{type:"state",payload:be(n)})},E=async(e,t,o,n,s)=>{if(S(e,{type:n,payload:s}),h(s))return S(e,{type:"failed",payload:s.message});o(),ma(e,t)},gi=(e,t,{onStateChanged:o,onSyncSettingsChanged:n,getPort:s})=>{new sa({server:e,path:"/ws",maxPayload:aa,verifyClient:r=>!uo(r.origin,s())}).on("connection",r=>{yr(r),r.on("message",async f=>{let y=async l=>{let{type:d}=l,a=t.repoRoot;if(d==="project:open"){let i=si(l.payload.root);return S(r,{type:"project:open:result",payload:i}),h(i)?void 0:(t.repoRoot=i.value,Ye(r,i.value))}if(d==="timeline:get"){let{requestId:i,...x}=l.payload??{};return S(r,{type:"timeline",requestId:i,payload:await Gr({repoRoot:a,...x})})}if(d==="issue:get"){let i=l.payload?.issueId,x=It(),L=cn(i);return S(r,{type:"issue",payload:h(x)?x:T("Issue detail",{...Yn(x.value,i),history:h(L)?[]:L.value})})}if(d==="issue:preview:get"){let{issueId:i}=l.payload,x=rn(i);return S(r,{type:"issue:preview:result",payload:{issueId:i,result:h(x)?x:T("Issue preview",Kn(i,x.value))}})}if(d==="commits:get"){let{requestId:i,...x}=l.payload??{};return S(r,{type:"commits",requestId:i,payload:no(await nr({repoRoot:a,...x}))})}if(d==="emails:get")return S(r,{type:"emails",payload:await io({repoRoot:a}),suggestions:await so({repoRoot:a})});if(d==="email:link"||d==="email:unlink"){let x=await(d==="email:link"?Nn:Mn)({repoRoot:a,...l.payload});return S(r,{type:"emails",payload:await io({repoRoot:a}),suggestions:await so({repoRoot:a}),lastAction:h(x)?{ok:!1,message:x.message}:{ok:!0,message:x.message}}),E(r,a,o,`${d}:result`,x)}if(d==="me:stats:get")return S(r,{type:"me:stats",payload:await Rn({repoRoot:a})});if(d==="version:get")return S(r,{type:"version",payload:await pi(F)});if(d==="settings:get")return S(r,{type:"settings",payload:ro()});if(d==="settings:set"){let i=Rr({enabled:l.payload.autoSync,intervalMs:l.payload.autoSyncIntervalMs});return h(i)||n(),S(r,{type:"settings",payload:h(i)?ro():i,lastAction:h(i)?{ok:!1,message:i.message}:{ok:!0,message:i.message}})}if(d==="commit:inspect")return S(r,{type:"commit:inspect:result",payload:await cr({repoRoot:a,sha:l.payload.sha,repo:l.payload.repo})});if(d==="commit:diff:get"){let{sha:i,repo:x}=l.payload;return S(r,{type:"commit:diff:result",payload:{sha:i,repo:x,result:await lr({repoRoot:a,sha:i,repo:x})}})}if(d==="repos:get"){let i=await sr(a);return S(r,{type:"repos",payload:await Ae({repoRoot:a}),own:i})}if(d==="repo:preview"){let i=await ao({repoRoot:a,...l.payload,previewOnly:!0});return S(r,{type:"repos",for:d,url:l.payload.url.trim(),payload:h(i)?await Ae({repoRoot:a}):i,preview:h(i)?null:i.value.preview??null,lastAction:{ok:!h(i),message:i.message}})}if(d==="repo:preview:cancel")return Ln(l.payload),S(r,{type:"repos",for:d,payload:await Ae({repoRoot:a}),preview:null});if(d==="repo:connect"||d==="repo:disconnect"){let i=d==="repo:connect"?await ao({repoRoot:a,...l.payload,confirm:!0}):await Bn({repoRoot:a,...l.payload});return S(r,{type:"repos",for:d,payload:h(i)?await Ae({repoRoot:a}):i,preview:null,lastAction:{ok:!h(i),message:i.message}}),h(i)?S(r,{type:`${d}:result`,payload:i}):(!h(i)&&i.message!==Zo&&!i.message.startsWith(er)&&fi(),E(r,a,o,`${d}:result`,i))}if(d==="issue:commits:get"){let{issueId:i}=l.payload;return S(r,{type:"issue:commits:result",payload:{issueId:i,result:await ar(a,no(await ir({repoRoot:a,ref:de(i)})))}})}if(d==="issue:squashed-diff:get"){let{issueId:i,asOfTime:x}=l.payload;return S(r,{type:"issue:squashed-diff:result",payload:{issueId:i,asOfTime:x??null,result:await mr({repoRoot:a,ref:de(i),end:x})}})}if(d==="issue:stats:get"){let{issueId:i,asOfTime:x}=l.payload;return S(r,{type:"issue:stats:result",payload:{issueId:i,asOfTime:x??null,result:await Et({repoRoot:a,idOrRef:de(i),end:x})}})}if(d==="diff-stats:get")return S(r,{type:"diff-stats",payload:await Qn({repoRoot:a})});if(d==="swimlane:stats:get"){let{swimlaneId:i}=l.payload;return S(r,{type:"swimlane:stats:result",payload:{swimlaneId:i,result:await ri({repoRoot:a,swimlaneId:i})}})}if(d==="goal:stats:get"){let{goalId:i,key:x,asOfTime:L}=l.payload;return S(r,{type:"goal:stats:result",payload:{goalId:i,key:x,result:await xn({repoRoot:a,goal:i,end:L})}})}if(d==="goal:commits:get"){let{goalId:i,key:x,asOfTime:L}=l.payload;return S(r,{type:"goal:commits:result",payload:{goalId:i,key:x,result:await wn({repoRoot:a,goal:i,end:L})}})}if(d==="board:overview:get"){let{boardId:i}=l.payload;return S(r,{type:"board:overview:result",payload:{boardId:i,result:Dn({boardId:i})}})}if(d==="time-travel:scrub"){let i=await $r({repoRoot:a,targetTime:l.payload.targetTime});return S(r,{type:"time-travel:result",payload:i}),h(i)?void 0:ho()}if(d==="time-travel:checkout-event"){let i=await Fr({repoRoot:a,eventId:l.payload.eventId});return S(r,{type:"time-travel:result",payload:i}),h(i)?void 0:ho()}if(d==="time-travel:live"){let i=await Hr({repoRoot:a});return S(r,{type:"time-travel:result",payload:i}),h(i)?void 0:ho()}if(d==="state:get")return Ye(r,a);if(d==="sync"){let i=await Tt({repoRoot:a});return S(r,{type:"sync:result",payload:i}),o(),h(i)||bo(a),Ye(r,a)}if(d==="issue:comment:add"){let i=await Ct({repoRoot:a,...l.payload});return E(r,a,o,"issue:comment:add:result",i)}if(d==="issue:comment:edit"){let i=await An({repoRoot:a,...l.payload});return E(r,a,o,"issue:comment:edit:result",i)}if(d==="issue:comment:delete"){let i=await Pt({repoRoot:a,...l.payload});return S(r,{type:"issue:comment:delete:result",payload:i}),h(i)?S(r,{type:"failed",payload:i.message}):(o(),Ye(r,a))}if(d==="issue:edit:description"){let i=await dn({repoRoot:a,...l.payload});return E(r,a,o,"issue:edit:description:result",i)}if(d==="issue:edit:title"){let i=await un({repoRoot:a,...l.payload});return E(r,a,o,"issue:edit:title:result",i)}if(d==="issue:tag:add"){let i=await vn({repoRoot:a,...l.payload});return E(r,a,o,"issue:tag:add:result",i)}if(d==="issue:goal:set")return E(r,a,o,"issue:goal:set:result",await Jr({repoRoot:a,...l.payload}));if(d==="goal:create")return E(r,a,o,"goal:create:result",await Xr({repoRoot:a,...l.payload}));if(d==="goal:rename")return E(r,a,o,"goal:rename:result",await zr({repoRoot:a,...l.payload}));if(d==="goal:remove")return E(r,a,o,"goal:remove:result",await Qr({repoRoot:a,...l.payload}));if(d==="issue:tag:remove"){let i=await In({repoRoot:a,...l.payload});return E(r,a,o,"issue:tag:remove:result",i)}if(d==="contributor:remove"){let i=await En({repoRoot:a,...l.payload});return E(r,a,o,"contributor:remove:result",i)}if(d==="tag:remove"){let i=await Sn({repoRoot:a,...l.payload});return E(r,a,o,"tag:remove:result",i)}if(d==="contributors:get")return S(r,{type:"contributors",boardId:l.payload?.boardId,payload:await Cn({repoRoot:a,...l.payload})});if(d==="issue:assignee:add"){let i=await Tn({repoRoot:a,...l.payload});return E(r,a,o,"issue:assignee:add:result",i)}if(d==="issue:assignee:remove"){let i=await Pn({repoRoot:a,...l.payload});return E(r,a,o,"issue:assignee:remove:result",i)}if(d==="issues:list")return S(r,{type:"issues",payload:await nn({repoRoot:a})});if(d==="issues:create"){let i=await sn({...l.payload,repoRoot:a});return S(r,{type:"issues:create:result",payload:i}),h(i)?ue({type:"failed",payload:i.message}):(o(),Ye(r,a))}if(d==="board:create"){let i=await pn({...l.payload,repoRoot:a});return E(r,a,o,"board:create:result",i)}if(d==="board:edit:title"){let i=await fn({...l.payload,repoRoot:a});return E(r,a,o,"board:edit:title:result",i)}if(d==="swimlane:create"){let i=await gn({...l.payload,repoRoot:a});return E(r,a,o,"swimlane:create:result",i)}if(d==="swimlane:edit:title"){let i=await yn({...l.payload,repoRoot:a});return E(r,a,o,"swimlane:edit:title:result",i)}if(d==="board:edit:description"){let i=await Yr({...l.payload,repoRoot:a});return E(r,a,o,"board:edit:description:result",i)}if(d==="swimlane:edit:description"){let i=await Kr({...l.payload,repoRoot:a});return E(r,a,o,"swimlane:edit:description:result",i)}if(d==="swimlane:rule:set"){let i=await Zr({...l.payload,repoRoot:a});return E(r,a,o,"swimlane:rule:set:result",i)}if(d==="goal:edit:description"){let i=await qr({repoRoot:a,goal:l.payload.goalId,description:l.payload.description});return E(r,a,o,"goal:edit:description:result",i)}if(d==="swimlane:delete"){let i=await bn({...l.payload,repoRoot:a});return E(r,a,o,"swimlane:delete:result",i)}if(d==="swimlane:move"){if(!l.payload.position)return S(r,{type:"error",message:"Missing move position"});let i=await hn({...l.payload,repoRoot:a});return E(r,a,o,"swimlane:move:result",i)}if(d==="issues:move"){if(!l.payload.position)return S(r,{type:"error",message:"Missing move position"});let i=await mn({...l.payload,repoRoot:a});return E(r,a,o,"issues:move:result",i)}if(d==="issue:close"){let i=await an({repoRoot:a,issueId:l.payload.issueId});return E(r,a,o,"issue:close:result",i)}if(d==="issue:reopen"){let i=await ln({repoRoot:a,issueId:l.payload.issueId});return E(r,a,o,"issue:reopen:result",i)}return S(r,{type:"error",message:"Unknown message type"})},p,g=async l=>{if(p!=="repo:connect"&&p!=="repo:disconnect"&&p!=="repo:preview")return S(r,{type:"error",message:l});S(r,{type:"repos",for:p,payload:await Ae({repoRoot:t.repoRoot}),preview:null,lastAction:{ok:!1,message:l}}),p!=="repo:preview"&&S(r,{type:`${p}:result`,payload:G(l)})};try{let l=JSON.parse(f.toString());p=l?.type;let d=li(l);if(!d.ok)return await g(d.error);let a=d.message;return ni.has(a.type)?await pe(async()=>ie().mode!=="live"?S(r,{type:"failed",payload:"Read-only while viewing history"}):y(a)):await y(a)}catch(l){return g(l instanceof Error?l.message:String(l))}})})};var fa=xe.dirname(pa(import.meta.url)),ga=process.env.IS_LOCAL==="true"?xe.resolve(process.cwd(),"dist/gui"):xe.join(fa,"gui"),Bt,ya=async()=>(Bt===void 0&&(Bt=await import("node:sea").catch(()=>null)),Bt?.isSea()?Bt:null),R=(e,t,o)=>{e.writeHead(t,{"content-type":"application/json"}),e.end(JSON.stringify(o))},ha=e=>R(e,409,{isError:!0,message:"Read-only while viewing history"}),Lt=(e,t)=>pe(async()=>ie().mode!=="live"?ha(e):t()),yi=async(e,t=1024*1024)=>new Promise((o,n)=>{let s=[],u=0;e.on("data",r=>{if(u+=r.length,u>t){e.destroy(),n(new Error("Request body too large"));return}s.push(r)}),e.on("end",()=>{let r=Buffer.concat(s).toString("utf8");try{o(r?JSON.parse(r):{})}catch{n(new Error("Invalid JSON body"))}}),e.on("error",n)}),ba=2*1024*1024,xa={png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp"},wa=e=>e.endsWith(".html")?"text/html; charset=utf-8":e.endsWith(".js")?"text/javascript; charset=utf-8":e.endsWith(".css")?"text/css; charset=utf-8":e.endsWith(".json")?"application/json; charset=utf-8":e.endsWith(".ico")?"image/x-icon":e.endsWith(".woff2")?"font/woff2":"application/octet-stream",hi=new Map,va=e=>`"${da("sha1").update(e).digest("base64url")}"`,Sa=async e=>{try{let{size:t,mtimeMs:o}=await ca(e);return`${t}:${o}`}catch{return null}},Ia=e=>{try{return decodeURIComponent(e)}catch{return null}},bi=async(e,t,o)=>{let n=e==="/"?"/index.html":Ia(e);if(n===null)return R(o,404,{isError:!0,message:"Not found"});let s=n.replace(/^\/+/,""),u=xe.resolve(ga),r=xe.resolve(u,s),f=xe.relative(u,r);if(f.startsWith("..")||xe.isAbsolute(f))return R(o,403,{isError:!0,message:"Forbidden"});let y=await ya(),p=y?"sea":await Sa(r),g=p===null?void 0:hi.get(f),l=g&&g.stamp===p?g.etag:null;if(l&&t.headers["if-none-match"]===l)return o.writeHead(304,{etag:l,"cache-control":"no-cache"}),o.end();try{let d=y?Buffer.from(y.getAsset(`gui/${f}`)):await xi(r),a=l??va(d);return p!==null&&hi.set(f,{stamp:p,etag:a}),o.writeHead(200,{"content-type":wa(r),etag:a,"cache-control":"no-cache"}),o.end(d)}catch{return R(o,404,{isError:!0,message:`Not found: ${s}`})}},Ta=async(e,t=We)=>new Promise((o,n)=>{let s=u=>{let r=y=>{if(e.off("listening",f),y.code==="EADDRINUSE"&&u===t){e.removeListener("error",r),s(0);return}n(y)},f=()=>{e.off("error",r);let y=e.address();if(!y||typeof y=="string"){n(new Error("Unable to resolve address"));return}o(y.port)};e.once("error",r),e.once("listening",f),e.listen(u,"127.0.0.1")};s(t)}),wi=async e=>{Or(!1);let t=0,o={repoRoot:e.repoRoot},n=ua.createServer((p,g)=>{s(p,g).catch(l=>(logger.error(`[gui] ${p.method} ${p.url}: ${l instanceof Error?l.message:String(l)}`),g.headersSent?g.end():R(g,500,{isError:!0,message:"Internal error"})))});async function s(p,g){let l=new URL(p.url??"/","http://127.0.0.1"),d=zn({method:p.method,origin:p.headers.origin,contentType:p.headers["content-type"]},t);if(d)return R(g,d.status,{isError:!0,message:d.message});if(p.method==="GET"&&l.pathname===mo)return R(g,200,{app:co,repoRoot:Mt(o.repoRoot),version:F,pid:process.pid});if(l.pathname==="/api/state")return R(g,200,await ee({repoRoot:o.repoRoot}));if(p.method==="POST"&&l.pathname==="/api/comments")try{let a=await yi(p);if(!a.issueId||!a.body?.trim())return R(g,400,{isError:!0,message:"Missing issueId or body"});let i=a.issueId,x=a.body;return await Lt(g,async()=>{let L=await Ct({repoRoot:o.repoRoot,issueId:i,body:x});return h(L)?R(g,400,{isError:!0,message:L.message}):R(g,200,await ee({repoRoot:o.repoRoot}))})}catch(a){return R(g,400,{isError:!0,message:a instanceof Error?a.message:"Unable to add comment"})}if(p.method==="POST"&&l.pathname==="/api/attachments")try{let a=await yi(p,ba);if(!a.issueId||!a.dataBase64)return R(g,400,{isError:!0,message:"Missing issueId or dataBase64"});let i=a.issueId,x=a.dataBase64,L=a.name??"";return await Lt(g,async()=>{let D=await en({repoRoot:o.repoRoot,issueId:i,name:L,dataBase64:x});return h(D)?R(g,400,{isError:!0,message:D.message}):R(g,200,{...await ee({repoRoot:o.repoRoot}),attachment:D.value})})}catch(a){return R(g,400,{isError:!0,message:a instanceof Error?a.message:"Unable to add attachment"})}if(p.method==="DELETE"&&l.pathname.startsWith("/api/attachments/")){let a=decodeURIComponent(l.pathname.replace("/api/attachments/",""));return a?Lt(g,async()=>{let i=await tn({repoRoot:o.repoRoot,attachmentId:a});return h(i)?R(g,400,{isError:!0,message:i.message}):R(g,200,await ee({repoRoot:o.repoRoot}))}):R(g,400,{isError:!0,message:"Missing attachment id"})}if(p.method==="GET"&&l.pathname.startsWith("/media/")){let a=decodeURIComponent(l.pathname.replace("/media/","")),i=await on({repoRoot:o.repoRoot,fileName:a});if(h(i))return R(g,404,{isError:!0,message:i.message});try{let x=await xi(i.value.filePath);return g.writeHead(200,{"content-type":xa[i.value.ext]??"application/octet-stream","cache-control":"public, max-age=31536000, immutable"}),g.end(x)}catch{return R(g,404,{isError:!0,message:"Attachment blob not found"})}}if(p.method==="DELETE"&&l.pathname.startsWith("/api/comments/")){let a=decodeURIComponent(l.pathname.replace("/api/comments/",""));return a?Lt(g,async()=>{let i=await Pt({repoRoot:o.repoRoot,commentId:a});return h(i)?R(g,400,{isError:!0,message:i.message}):R(g,200,await ee({repoRoot:o.repoRoot}))}):R(g,400,{isError:!0,message:"Missing comment id"})}return l.pathname.startsWith("/board/")||l.pathname==="/log"?bi("/",p,g):bi(l.pathname,p,g)}try{t=await Ta(n)}catch(p){return G(p instanceof Error?`Unable to start GUI server: ${p.message}`:`Unable to start GUI server: ${String(p)}`)}let u=Jn({project:o}),r=Wn({project:o,publisher:u,onReposFetch:p=>bo(o.repoRoot,p)}),f=Xn(u);gi(n,o,{onStateChanged:()=>r.queueSync(),onSyncSettingsChanged:()=>r.reschedule(),getPort:()=>t}),n.on("close",()=>{r.dispose(),f()});let y=n.address();return!y||typeof y=="string"?(n.close(),G("Unable to resolve GUI server address")):T("Started GUI server",{url:`http://epiq.localhost:${y.port}${e.boardId?`/board/${e.boardId}`:""}`,server:n})};var vi=async e=>{let t=f=>{e.open!==!1&&$n()&&Fn(f)},o=it({});if(h(o))return G(o.message);let n=Ie();$(n)&&Ue(n.value);let s=await kn(We);if(s&&s.repoRoot===Mt(e.repoRoot)){let f=`http://127.0.0.1:${We}`;return console.log(lo({url:f,repoRoot:e.repoRoot,version:F,reused:!0})),t(f),T("Reused running GUI",{url:f})}let u=await wi({repoRoot:e.repoRoot,boardId:""});if(h(u))return u;let{url:r}=u.value;return console.log(lo({url:r,repoRoot:e.repoRoot,version:F,reused:!1})),t(r),T("Started GUI",{url:r})};import{Box as ce}from"ink";import M from"react";import{Box as xo,Text as Ke}from"ink";import te,{useEffect as Ea,useMemo as Ca}from"react";import{ulid as Pa}from"ulid";var Si=({text:e,match:t,color:o,highlightColor:n=m.secondary,dimColor:s=!1})=>{if(!t)return te.createElement(Ke,{color:o,dimColor:s},e);let u=e.toLowerCase(),r=t.toLowerCase(),f=u.indexOf(r);return f===-1?te.createElement(Ke,{color:o,dimColor:s},e):te.createElement(Ke,{color:o,dimColor:s},e.slice(0,f),te.createElement(Ke,{backgroundColor:n,bold:!0},e.slice(f,f+t.length)),e.slice(f+t.length))},Ii=Pa(),Aa=e=>`${e}`,Na=e=>{let{pendingNavTarget:t}=Tr();if(!t)return[];let{breadCrumb:o,contextNode:n,selectedNode:s}=t,u=new Set(zo(ft.NONE,{breadCrumb:o,contextNode:n,readOnly:Q().readOnly,selectedNode:s}));return[...new Set(Object.values(ft))].filter(r=>r!=="move").filter(r=>r.length>0).filter(r=>r!==ft.PALETTE).map(r=>{let f=xr(r),y=Br.find(p=>p.intent===f);return{command:r,description:y?.description??`[${r}] Run command`,isAvailable:u.has(r)}}).filter(r=>r.command.toLowerCase().startsWith(e)||e.length>=2&&r.description.toLowerCase().includes(e)).sort((r,f)=>r.isAvailable!==f.isAvailable?r.isAvailable?-1:1:r.command.localeCompare(f.command))},Ma=e=>Ee.text({id:Ii,parentNodeId:e,rank:"000000",name:"Command Palette",readonly:!0,isVirtual:!0}),Ra=(e,t,o)=>Ee.text({id:Aa(e.command),parentNodeId:o,rank:String(t).padStart(6,"0"),name:e.command,disabled:!e.isAvailable,readonly:!0,isVirtual:!0}),wo=[],Ba=e=>{Ti();let t=q.createNode(Ma(Q().rootNodeId));h(t)||!Te(t.value)||(wo=[t.value,...e.map((o,n)=>Ra(o,n,Ii)).map(q.createNode).filter($).map(({value:o})=>o).filter(Te)],Ce.navigate({contextNode:t.value,selectedIndex:0}))},Ti=()=>{let e=wo.map(t=>t.id);wo=[];for(let t of e)q.deleteNode(t)};function Ei({width:e,height:t}){let n=fr().value.trim().toLowerCase(),s=Ca(()=>Na(n),[n]);Ea(()=>(Ba(s),()=>{Ti()}),[s]);let u=Q().selectedIndex;return te.createElement(xo,{flexDirection:"column",width:e,height:t-2},te.createElement(xt,{height:t-4,itemHeight:3,selectedIndex:u},s.map((r,f)=>{let y=f===u,p=r.isAvailable?m.accent:m.secondary2,g=r.isAvailable?"":"[unavailable] ";return te.createElement(xo,{key:r.command,flexDirection:"column",paddingX:1,borderLeft:!1,borderBottom:!1,borderRight:!1,borderColor:m.secondary,borderStyle:"single"},te.createElement(Ke,{color:p,dimColor:!r.isAvailable},y?"\u276F ":" ",te.createElement(Si,{text:Xo(r.command),match:n,color:p,dimColor:!r.isAvailable})),te.createElement(xo,{paddingLeft:2},te.createElement(Si,{text:g+r.description,match:n.length>=2?n:"",color:y&&r.isAvailable?m.primary:m.secondary2,dimColor:!r.isAvailable})))})))}import{Box as Ka}from"ink";import Dt from"react";import Je from"chalk";import{Box as qe,Text as Ni}from"ink";import we,{useEffect as Mi,useMemo as La,useState as Ri}from"react";var Me=["\u2803","\u2806","\u2830","\u2818"],Ci=120,Pi=({isPalette:e,isPending:t,frame:o})=>{if(t){let n=(o%Me.length+Me.length)%Me.length;return Me[n]}return e?"?":":"},Ai=({infoMessage:e,isPending:t})=>t&&e.includes(ur)?"":e;var Bi=Je.hex(m.secondary),ja=Je.inverse,_a=Je.inverse.hex(m.secondary2),Da={hint:"",hints:[],overlap:0,remainder:""},ji=({value:e,command:t})=>{if(!t)return null;let o=e.trimStart(),s=e.length-o.length;return e.slice(s,s+t.length)!==t?null:{start:s,end:s+t.length}},Oa=({command:e,modifier:t})=>{if(!t)return null;if(e==="tag"||e==="assign"){let o=Uo(t);return{bg:n=>Je.bgHex(o).black(n),bgCursor:n=>Je.bgHex(o).inverse.black(n)}}return to(t)},Ua=({value:e,command:t,modifier:o})=>{if(!t||!o)return null;let n=ji({value:e,command:t});if(!n)return null;let u=e.slice(n.end).match(/^\s*/)?.[0].length??0,r=n.end+u;return e.slice(r,r+o.length)!==o?null:{start:r,end:r+o.length}},Li=()=>({value:ne.value,cursorPosition:ne.cursorPosition,commandIsPending:ne.commandIsPending,autoCompletion:ne.commandMeta.autoCompletion??Da,infoMessage:ne.commandMeta.infoMessage,validationStatus:ne.commandMeta.validity,command:ne.commandMeta.command,inputString:ne.commandMeta.inputString,modifier:ne.commandMeta.modifier}),Ga=(e,t)=>e.value===t.value&&e.cursorPosition===t.cursorPosition&&e.commandIsPending===t.commandIsPending&&e.infoMessage===t.infoMessage&&e.autoCompletion.hint===t.autoCompletion.hint&&e.autoCompletion.overlap===t.autoCompletion.overlap&&e.autoCompletion.remainder===t.autoCompletion.remainder&&e.validationStatus===t.validationStatus&&e.command===t.command&&e.modifier===t.modifier&&e.inputString===t.inputString,_i=({width:e,mode:t})=>{let[o,n]=Ri(Li());Mi(()=>{let B=()=>{let C=Li();n(I=>Ga(I,C)?I:C)},P=pr(B);return B(),()=>{P()}},[]);let{value:s,cursorPosition:u,infoMessage:r,commandIsPending:f,autoCompletion:y,command:p,modifier:g,validationStatus:l}=o,d=f&&l===dr.Invalid,a=Ai({infoMessage:r,isPending:f}),[i,x]=Ri(0);Mi(()=>{if(!f){x(0);return}let B=setInterval(()=>{x(P=>(P+1)%Me.length)},Ci);return()=>{clearInterval(B)}},[f]);let L=Pi({isPalette:t===H.PALETTE,isPending:f,frame:i}),D=La(()=>{let B=Math.max(0,Math.min(u,s.length)),P=ji({value:s,command:p}),C=Ua({value:s,command:p,modifier:g}),I=p?to(p):null,V=Oa({command:p,modifier:g}),Se=(Y,K)=>{let Zt=P&&K>=P.start&&K<P.end,eo=C&&K>=C.start&&K<C.end;return Zt&&I?I.fg(Y):eo&&V?V.bg(Y):Y},De=(Y,K)=>{let Zt=P&&K>=P.start&&K<P.end,eo=C&&K>=C.start&&K<C.end;return Zt&&I?I.fgCursor(Y):eo&&V?V.bgCursor(Y):ja(Y)},he=s.slice(0,B),Z=s[B]??" ",Oe=B<s.length?s.slice(B+1):"",nt=Array.from(he).map((Y,K)=>Se(Y,K)).join(""),Ro=De(Z,B),Bo=Array.from(Oe).map((Y,K)=>Se(Y,B+1+K)).join("");if(y.hint){let Y=y.hint[y.overlap]??Z;Ro=_a(Y),Bo=Bi(y.remainder.slice(1)+Oe)}return nt+Ro+Bo},[s,u,y,p,g]);return we.createElement(qe,{flexDirection:"column",justifyContent:"flex-start"},we.createElement(qe,{flexDirection:"column",paddingX:1,borderColor:m.secondary,borderStyle:"round",width:e},we.createElement(qe,{height:1,flexWrap:"nowrap"},we.createElement(qe,{flexShrink:0},we.createElement(Ni,{wrap:"truncate-start"},Bi(L),D)),a&&we.createElement(qe,{flexShrink:1,minWidth:0},we.createElement(Ni,{wrap:"truncate",color:d?m.red:m.secondary2},` ${a} `)))))};import{Box as $a,Text as Xe}from"ink";import Re from"react";var Di=" ",Fa=({keys:e,label:t})=>e.length+1+t.length,Ha=(e,t)=>{let o=[],n=0;for(let s of e){let r=(o.length>0?Di.length:0)+Fa(s);if(n+r>t-4)break;o.push(s),n+=r}return o},Oi=({width:e,availableHints:t})=>{let o=Ha(t,e);return Re.createElement($a,{width:e,borderStyle:"round",borderColor:m.secondary,paddingX:1},o.length?Re.createElement(Xe,{wrap:"truncate"},o.map(({keys:s,label:u},r)=>Re.createElement(Xe,{key:`${s}-${u}`},r>0?Di:"",Re.createElement(Xe,{color:m.accent},s),Re.createElement(Xe,{color:m.secondary2}," ",u)))):Re.createElement(Xe,{color:m.secondary2},"\xA0"))};import{Box as ka,Text as jt}from"ink";import ze,{useEffect as Wa,useRef as Be,useState as Va}from"react";var Ya=40,_t=.3,vo="\u2500",Ui=1,Gi=16,$i=({width:e})=>{let{replay:t}=O(),o=t!==null,n=t?Math.min(1,Math.max(0,t.progress)):0,u=Math.max(4,e-6),r=u*Ui,[f,y]=Va(0),p=Be(n);p.current=n;let g=Be(0),l=Be(0),d=Be(0),a=Be(0),i=Be(0);if(Wa(()=>{if(!o){g.current=0,d.current=0,a.current=0,i.current=0,y(0);return}g.current=p.current,l.current=Date.now(),d.current=p.current;let P=setInterval(()=>{let C=Date.now(),I=p.current;if(I!==d.current){let Z=I-d.current,Oe=C-l.current;if(Z<0)a.current=0,i.current=0;else if(Z>0&&Oe>0){let nt=Z/Oe;a.current=a.current===0?nt:a.current*(1-_t)+nt*_t,i.current=i.current===0?Z:i.current*(1-_t)+Z*_t}g.current=I,l.current=C,d.current=I}let V=C-l.current,Se=Math.min(i.current,a.current*V),De=Math.min(1,g.current+Se),he=Math.round(De*r);y(Z=>Z===he?Z:he)},Ya);return()=>clearInterval(P)},[o,r]),!t)return null;let x=P=>{let C=u>1?P/(u-1):0,I=Math.round(C*(Gi-1))/(Gi-1);return Fo(I)},L=Math.min(u,Math.floor(f/Ui)),D=[];for(let P=0;P<L;P++){let C=x(P),I=D[D.length-1];I&&I.color===C?I.text+=vo:D.push({text:vo,color:C})}let B=vo.repeat(Math.max(0,u-L));return ze.createElement(ka,{width:e,borderStyle:"round",borderColor:m.secondary,paddingX:1,columnGap:1},ze.createElement(jt,{color:m.secondary2},"\u25B6"),ze.createElement(jt,null,D.map((P,C)=>ze.createElement(jt,{key:C,color:P.color},P.text)),ze.createElement(jt,{color:m.secondary,dimColor:!0},B)))};var Qe=({width:e,mode:t,availableHints:o})=>{let{timeMode:n}=O(),s=t===H.COMMAND_LINE||t===H.PALETTE;return Dt.createElement(Ka,null,s?Dt.createElement(_i,{width:e,mode:t}):n==="replay"?Dt.createElement($i,{width:e}):Dt.createElement(Oi,{width:e,mode:t,availableHints:o}))};import{Box as fe,Text as Le}from"ink";import k,{useEffect as qa,useMemo as Ja}from"react";import{ulid as Fi}from"ulid";var Ut=Fi(),Xa=()=>[...new Set([...Q().availableActions].map(e=>e.description).filter(e=>e!==void 0))].map(Lr).filter(e=>e!==null).sort(({keys:e},{keys:t})=>e.length===1&&t.length!==1?-1:e.length!==1&&t.length===1?1:e.localeCompare(t,void 0,{sensitivity:"base"})).map(({keys:e,label:t})=>({keys:e,action:t})),za=e=>Ee.text({id:Ut,parentNodeId:e,rank:"000000",name:"Help",isVirtual:!0,readonly:!0}),Qa=(e,t,o)=>Ee.text({id:Fi(),parentNodeId:o,rank:String(t).padStart(6,"0"),name:e.keys,readonly:!0,isVirtual:!0}),Ot=[],Hi=()=>{let e=Ot.filter(o=>o.id!==Ut).map(o=>o.id),t=Ot.filter(o=>o.id===Ut).map(o=>o.id);Ot=[];for(let o of[...e,...t])q.deleteNode(o)},Za=e=>{Hi();let t=q.createNode(za(Q().rootNodeId));if(h(t)||!Te(t.value))return logger.error("Could not attach help nodes");Ot=[t.value,...e.map((o,n)=>Qa(o,n,Ut)).map(q.createNode).filter($).map(({value:o})=>o).filter(Te)],Ce.navigate({contextNode:t.value,selectedIndex:0})},ki=({width:e,height:t})=>{let o=Ja(()=>Xa(),[]);qa(()=>(Za(o),()=>{Hi()}),[o]);let n=Q().selectedIndex;return k.createElement(fe,{flexDirection:"column",marginTop:3,borderColor:m.secondary,borderStyle:"round",width:e,height:t-2},k.createElement(fe,{paddingX:1,justifyContent:"center"},k.createElement(Le,{color:m.accent},"Help"),k.createElement(Le,{dimColor:!0}," \u2014 navigate with arrows/hjkl, press q to close")),k.createElement(fe,{paddingX:1,marginTop:1},k.createElement(fe,{width:20,justifyContent:"flex-end"},k.createElement(Le,{color:m.secondary},"Key(s)")),k.createElement(fe,{flexGrow:1,width:40,paddingLeft:2},k.createElement(Le,{color:m.secondary},"Action"))),k.createElement(xt,{height:t-7,itemHeight:1,selectedIndex:n},o.map(({keys:s,action:u},r)=>{let f=r===n;return k.createElement(fe,{paddingX:1,key:`${s}-${u}-${r}`,flexDirection:"row"},k.createElement(fe,{width:20,justifyContent:"flex-end"},k.createElement(Le,{color:m.accent},s)),k.createElement(fe,{flexGrow:1,width:40,paddingLeft:2},k.createElement(Le,{color:f?m.primary:m.secondary2},u)))})))};import{Box as je,Text as W}from"ink";import A,{useEffect as el,useState as So}from"react";var Gt=({index:e,email:t,note:o,noteColor:n})=>A.createElement(je,null,A.createElement(W,{color:m.accent},e===void 0?" ":` ${e}.`),A.createElement(W,null," ",t),o&&A.createElement(W,{color:n??m.secondary2},` ${o}`)),Wi=({height:e})=>{let[t,o]=So([]),[n,s]=So([]),[u,r]=So(null),{userName:f,gitEmail:y,gitName:p,userId:g}=re();return el(()=>{let l=!0;return(async()=>{let a=Pe(),i=oe(process.cwd());if(h(a)||h(i)||!g)return;let x=a.value.emailLinks,L=Vo(x,g);o(L.map(C=>({email:C,others:Wo(x,C).filter(I=>I!==g).map(I=>a.value.contributors[I]?.name??I)})));let D=at(i.value),B=await vt({repoRoot:i.value,stateBranch:h(D)?void 0:D.value,names:[f,p],links:x});if(!l)return;if(h(B)){r(B.message);return}let P=St(B.value);ut(P.map(C=>C.email)),s(P)})(),()=>{l=!1}},[g,f,p,y]),A.createElement(je,{height:e-4,flexDirection:"column",paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:m.secondary,rowGap:1},A.createElement(je,null,A.createElement(W,{color:m.accent,bold:!0},f??"Not configured"),A.createElement(W,{color:m.secondary2}," on this board")),u&&A.createElement(W,{color:m.red},u),A.createElement(je,{flexDirection:"column"},A.createElement(W,{color:m.secondary2},"CLAIMED"),t.length===0?A.createElement(Gt,{email:"Nothing claimed \u2014 your commits show the name git signed them with.",note:""}):t.map(l=>A.createElement(Gt,{key:l.email,email:l.email,note:l.others.length>0?`CONTESTED: also ${l.others.join(", ")}, resolves to nobody`:l.email===y?"your git identity here":void 0,noteColor:l.others.length>0?m.yellow:void 0}))),A.createElement(je,{flexDirection:"column"},A.createElement(W,{color:m.secondary2},"UNCLAIMED IN THIS HISTORY"),n.length===0?A.createElement(Gt,{email:"Nothing left to claim here."}):n.map(l=>A.createElement(Gt,{key:l.email,email:l.email,note:`${l.commits} commit${l.commits===1?"":"s"} as ${l.names.join(", ")||"unknown"}`}))),A.createElement(je,{flexDirection:"column"},A.createElement(W,{color:m.secondary2},A.createElement(W,{color:m.accent},"[enter]")," writes a claim for the first into the command line, to confirm or change."),A.createElement(W,{color:m.secondary2},A.createElement(W,{color:m.accent},":config emails")," claims by address,",A.createElement(W,{color:m.accent}," :config emails-unclaim "),"gives one back."),A.createElement(W,{color:m.secondary2},A.createElement(W,{color:m.accent},"[esc]")," to close")))};import tl from"chalk";import{Box as ve,Text as U}from"ink";import N from"react";var ol=8,rl=()=>{let e=Ge({exclude:process.cwd()});return h(e)?[]:e.value.slice(0,ol)},Vi=({width:e,height:t})=>{let o=rl();return N.createElement(ve,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:m.secondary,rowGap:1},N.createElement(U,{color:m.accent,bold:!0},"Initialize project"),N.createElement(U,null,`This folder is not an ${tl.hex(m.accent)("epiq")} project yet.`),N.createElement(U,{color:m.primary},"To start tracking issues here, we need to initialize a new",N.createElement(U,{color:m.primary,backgroundColor:m.secondary}," .epiq/project.json "),"file in this repository."),N.createElement(ve,{marginTop:1,flexDirection:"column"},N.createElement(ve,null,N.createElement(U,{color:m.accent}," "),N.createElement(U,{color:m.primary},"Type "),N.createElement(U,{backgroundColor:m.secondary}," :init "))),N.createElement(ve,{marginTop:1},N.createElement(U,{color:m.secondary2},"This will create, commit and push "),N.createElement(U,{color:m.primary,backgroundColor:m.secondary}," .epiq/project.json ")),o.length>0&&N.createElement(ve,{marginTop:1,flexDirection:"column"},N.createElement(U,{color:m.accent,bold:!0},"Or open a recent project"),o.map((n,s)=>N.createElement(ve,{key:n.projectId},N.createElement(U,{color:m.accent},` ${s+1} `),N.createElement(U,{color:m.primary},dt(n.root)),N.createElement(U,{color:m.secondary2},` ${n.root}`))),N.createElement(ve,{marginTop:1},N.createElement(U,{color:m.accent}," "),N.createElement(U,{color:m.primary},"Type "),N.createElement(U,{backgroundColor:m.secondary}," :open 1 "),N.createElement(U,{color:m.secondary2}," or "),N.createElement(U,{backgroundColor:m.secondary}," :open <path> "))))};import{Box as Ft,Text as X}from"ink";import j from"react";import{Box as $t,Text as me}from"ink";import J,{useEffect as nl,useState as Yi}from"react";var Ki=()=>{let[e,t]=Yi(null),[o,n]=Yi(null);return nl(()=>{let s=!0;return(async()=>{let r=Pe(),f=oe(process.cwd());if(h(r)||h(f))return;let y=at(f.value),{userName:p,gitName:g}=re(),l=await vt({repoRoot:f.value,stateBranch:h(y)?void 0:y.value,names:[p,g],links:r.value.emailLinks});if(!s)return;if(h(l)){n(l.message);return}let d=St(l.value);ut(d.map(a=>a.email)),t(d)})(),()=>{s=!1}},[]),o?J.createElement($t,{marginTop:1},J.createElement(me,{color:m.red},o)):e===null?null:e.length===0?J.createElement($t,{marginTop:1},J.createElement(me,{color:m.secondary2},"No unclaimed addresses in this history \u2014 type",J.createElement(me,{color:m.accent}," :config emails none "),"to move on.")):J.createElement($t,{flexDirection:"column",marginTop:1},e.map(s=>J.createElement(me,{key:s.email},J.createElement(me,{color:m.accent}," \xB7 "),J.createElement(me,null,s.email),J.createElement(me,{color:m.secondary2},` ${s.commits} commit${s.commits===1?"":"s"} as ${s.names.join(", ")||"unknown"}`))),J.createElement($t,{marginTop:1},J.createElement(me,{color:m.secondary2},"Claim yours by address, or",J.createElement(me,{color:m.accent}," none "),"to skip.")))};var il=({isDone:e,command:t,value:o,verb:n="Type",hint:s})=>j.createElement(Ft,null,j.createElement(X,{color:m.accent,dimColor:e},e?" \u2714 ":" "),j.createElement(X,{dimColor:e},n," "),j.createElement(X,{backgroundColor:m.secondary,dimColor:e}," "+t+" "),o!==void 0&&j.createElement(j.Fragment,null,j.createElement(X,{dimColor:e}," "),j.createElement(X,{color:m.secondary,dimColor:e},"<"+o+">")),s),sl=(e,t)=>e.length===0?void 0:qo(e.join(", "),Math.max(12,t-34)),al=e=>{if(typeof e=="string")return e;if(typeof e=="boolean")return e?"on":"off"};function Io({width:e,height:t}){let{isSetPreferredEditor:o,isSetUserName:n,userName:s,preferredEditor:u,autoSync:r,isSetAutoSync:f,isSetEmails:y,claimedEmails:p,emailSetupDeclined:g}=pt(),l=[{key:"username",done:n,command:":config username",value:s,message:"First, choose your username."},{key:"editor",done:o,command:":config editor",value:u,message:"Nice. Now pick your editor."},{key:"autosync",done:f,command:":config autosync",value:r,message:"Almost there. Configure auto sync."},{key:"emails",done:y,command:":config emails",value:g?"declined":sl(p,e),message:"Last one. Claim the git addresses whose commits are yours, so the board calls them by your name."}],d=l.findIndex(i=>!i.done),a=d===-1?void 0:l[d];return j.createElement(Ft,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:m.secondary,rowGap:1},j.createElement(X,{color:m.accent,bold:!0},"Welcome! \u{1F539}"),j.createElement(X,null,"Let's get you started - it's a breeze."),j.createElement(X,{color:m.secondary2},"Remember - you can always search available commands by typing:",j.createElement(X,{color:m.accent}," ? ")),a&&j.createElement(X,{color:m.secondary2},a.message),j.createElement(Ft,{flexDirection:"column"},l.map((i,x)=>{if(!(d===-1||x<=d))return null;let D=x===d,B=D&&d===0;return j.createElement(Ft,{key:i.key,flexDirection:"column",marginBottom:1},j.createElement(il,{isDone:i.done,command:B?":config us":i.command,value:i.done?al(i.value):void 0,verb:D&&!B?"Waiting:":"Type",hint:B?j.createElement(X,{color:m.secondary2}," then ",j.createElement(X,{color:m.accent},"tab")," to auto-complete ",j.createElement(X,{backgroundColor:m.secondary},` ${i.command.split(" ").pop()} `)):void 0}),i.key==="emails"&&!i.done&&j.createElement(Ki,null))})))}import Yt from"chalk";import{Box as tt,Text as _e}from"ink";import _ from"react";import{Box as Ht,Text as qi}from"ink";import ge from"react";import ll from"chalk";var ml=e=>(q.getTag(e)?.name??"").length+3,cl=e=>{let t=q.getContributor(e);return(t?t.name:"").length+3},Ji=({width:e})=>{let{viewMode:t}=re(),o=O(),{breadCrumb:n,contextNode:s,selectedIndex:u,renderedChildrenIndex:r}=o,f=r[s.id]?.[u],y=_r(f?.id??s.id,"TICKET"),p=$(y)?y.value:void 0,g=(p?.props.tags??[]).filter(I=>q.getTag(I)),l=p?.props.assignees??[],d=p?.parentNodeId?!Dr(s.id,p.parentNodeId)&&t==="dense":!1,a=n.map((I,V)=>{let Se=V===n.length-1,De=yt(I.id),he=Se?De?.[u]?.title:void 0;return`${V?" / ":""}${I.title??""}${he?` \u25B8 ${he}`:""}`}).join(""),i=p?q.getCommentsByIssue(p.id):[],x=i.length?String(i.length).length+11:0,L=d?g.reduce((I,V)=>I+ml(V),0)+l.reduce((I,V)=>I+cl(V),0)+x:0,D=f?.id!=null&&!(t==="wide"&&ct(f)),B=Math.max(0,e-L),P=a.substring(0,B)+(D?ll.hex(m.secondary2).dim(` ${de(f.id)}`):""),C=d?[...g.map(I=>ge.createElement(Ht,{key:`tag-${I}`,paddingLeft:1},ge.createElement(Sr,{id:I}))),...l.map(I=>ge.createElement(Ht,{key:`assignee-${I}`,paddingLeft:1},ge.createElement(vr,{id:I}))),i.length?ge.createElement(Ht,{key:"comments",paddingLeft:1},ge.createElement(qi,{color:m.accent},"[",i.length," comment",i.length===1?"":"s","]")):null]:[];return ge.createElement(Ht,{overflow:"hidden",justifyContent:"flex-start",alignItems:"flex-start"},ge.createElement(qi,{color:m.secondary2},P),C)};import{Box as dl,Text as Xi}from"ink";import kt from"react";var ul=({filters:e})=>kt.createElement(dl,{columnGap:1},kt.createElement(Xi,{color:"red"},"APPLIED FILTERS:"),e.map(({value:t,target:o,operator:n},s)=>kt.createElement(Xi,{key:s,backgroundColor:"black",color:"white"},` ${o}${n}"${t}" `))),zi=kt.memo(ul);import{Box as pl,Text as Wt}from"ink";import Ze from"react";function Qi(){let{eventLog:e,unappliedEvents:t}=O(),o=e.at(-1)?.id,n=Ho(o??""),s=$(n)?wt(n.value):"INVALID DATE";return Ze.createElement(pl,{paddingLeft:1},Ze.createElement(Wt,{backgroundColor:m.accent,color:m.secondary}," Readonly "),Ze.createElement(Wt,{color:m.accent}," "+t.length+" edits ago at "+s+"."),Ze.createElement(Wt,{color:m.accent}," Resume with "),Ze.createElement(Wt,{backgroundColor:m.accent,color:m.secondary}," ",":peek now"," "))}import{Box as fl,Text as To}from"ink";import Vt from"react";function Zi(){let{replay:e}=O();if(!e)return null;let{appliedCount:t,totalCount:o,currentTime:n}=e;return Vt.createElement(fl,{paddingRight:2,columnGap:1,justifyContent:"flex-end"},Vt.createElement(To,{backgroundColor:m.accent,color:m.secondary}," \u25B6 REPLAY "),Vt.createElement(To,{color:m.secondary2},wt(new Date(n))),Vt.createElement(To,{color:m.accent},`${t}/${o} edits`))}import Eo from"chalk";import{Box as gl,Text as es}from"ink";import Co,{useEffect as yl,useState as hl}from"react";var bl=["#4c567a","#9d7cd8","#7aa2f7","#7dcfff","#9d7cd8"],xl=150,ts=12,wl=.36;function os({syncStatus:e,autoSync:t}){let[o,n]=hl(0);yl(()=>{if(e.status!=="syncing"){n(0);return}let f=0,y=setInterval(()=>{f+=1;let p=(Math.sin(f*wl)+1)/2,g=Math.round(p*(ts-1));n(l=>l===g?l:g)},xl);return()=>clearInterval(y)},[e.status]);let s={synced:" ",failed:"---",offline:"off",syncing:"...",pending:"idle"},r={synced:m.secondary2,failed:m.yellow,offline:m.secondary2,pending:m.secondary2,syncing:$o(bl,o/(ts-1))??""}[e.status];return Co.createElement(gl,null,Co.createElement(es,null,Eo.hex(m.secondary2).dim(t?"Sync (auto): ":"Sync: ")),Co.createElement(es,null,Eo.hex(r)("\u25CF")+Eo.hex(m.secondary2).dim(` ${s[e.status].padEnd(4)} `)))}import et from"chalk";import{Text as rs}from"ink";import ns,{useEffect as vl,useState as Sl}from"react";var Il=(e,t)=>{let o=e.split("."),n=t.split("."),s=n.findIndex((u,r)=>u!=o[r]);return n.map((u,r)=>r>=s?et.hex(m.accent).dim(u):et.hex(m.secondary).dim(u)).join(et.hex(m.secondary2).dim("."))};function is(){let[e,t]=Sl({current:F,latest:null,updateAvailable:!1});return vl(()=>{let o=!0;return yo(F).then(n=>{o&&t(n)}),()=>{o=!1}},[]),!e.updateAvailable||!e.latest?ns.createElement(rs,{dimColor:!0,color:m.secondary2},F+" "):ns.createElement(rs,null,et.hex(m.secondary2).dim(F),et.hex(m.accent).dim(" \u2197 "),Il(F,e.latest))}function ot({filters:e,hideBreadCrumb:t=!1}){let{timeMode:o,syncStatus:n,mode:s,replay:u}=O(),{userName:r,preferredEditor:f,autoSync:y}=re(),p=64,g=process.stdout.columns-p-8,l=t||o==="replay",d=u?Ko(u.currentLabel,Math.max(0,g)):"";return _.createElement(tt,{justifyContent:"space-between",flexDirection:"row","max-width":process.stdout.columns-40,height:1,overflow:"hidden"},o==="replay"?_.createElement(tt,{paddingLeft:1},_.createElement(_e,{color:m.secondary2},d)):l?_.createElement(_e,null," "):s===H.PALETTE?_.createElement(tt,null,_.createElement(_e,{color:m.accent},"Command Palette"),_.createElement(_e,{dimColor:!0,color:m.secondary2}," ","- search, select and press enter")):_.createElement(tt,{paddingLeft:1},e.length>0?_.createElement(zi,{filters:e}):_.createElement(Ji,{width:g})),o==="live"?_.createElement(tt,{columnGap:1,paddingRight:2,"max-width":p,overflow:"hidden",justifyContent:"flex-end"},_.createElement(os,{autoSync:!!y,syncStatus:n}),_.createElement(_e,null,Yt.hex(m.secondary2).dim("Mode: ")+Yt.hex(m.secondary2).dim(s.padEnd(8," "))," "),_.createElement(ss,{icon:"@",value:r}),_.createElement(ss,{icon:"\u276F",value:f}),_.createElement(is,null)):"",o==="peek"?_.createElement(Qi,null):"",o==="replay"?_.createElement(Zi,null):"")}function ss({icon:e,value:t}){return _.createElement(_e,null,Yt.dim(e)+Yt.hex(m.accent)(` ${t??"-"} `))}import{Box as Tl,Text as El}from"ink";import rt from"react";import{Box as Kt,Text as Po}from"ink";import ye from"react";function Ao({height:e,width:t}){let o=O(),n=o.nodes[o.rootNodeId],s=n?.id?Fe(n?.id):[];return ye.createElement(Kt,{flexDirection:"column",height:e,padding:1,borderStyle:"round",borderColor:m.secondary,width:t},ye.createElement(Kt,{padding:1,paddingTop:0,paddingBottom:0},ye.createElement(Po,null,"Select a board:")),ye.createElement(Kt,{padding:1,flexDirection:"column"},s.map((u,r)=>{let f=o.contextNode.context==="WORKSPACE"&&o.selectedIndex===r,p=Fe(u.id).flatMap(({id:g})=>yt(g)).length;return ye.createElement(Kt,{key:u.id??r},ye.createElement(Po,{color:f?m.accent:m.secondary2},ye.createElement(wr,{isSelected:f})),ye.createElement(Po,{color:f?m.accent:m.secondary2},u.title," (",p," issues)",u.readonly?" \u{1F512}":""))})))}var Cl=({contextNode:e,selectedIndex:t,breadCrumb:o,mode:n,viewMode:s,height:u,width:r})=>{let{renderedChildrenIndex:f}=O(),y=o.find(({context:d})=>d==="BOARD"),l=u-1-3;return rt.createElement(Tl,{flexDirection:"row"},e.context==="WORKSPACE"?rt.createElement(Ao,{height:l,width:r}):y?rt.createElement(Ir,{height:l,width:r,swimlanes:(f[y.id]??[]).filter(d=>d!==void 0&&Yo(d)),contextNode:e,selectedIndex:t,breadCrumb:o,viewMode:s,mode:n}):rt.createElement(El,null))},as=rt.memo(Cl);import{useEffect as Pl}from"react";var Al=e=>{Pl(()=>{if(!e)return;let t,o=!1,n=()=>{if(o)return;let{autoSyncIntervalMs:s,userName:u,preferredEditor:r}=re();r&&u&&s&&(t=setTimeout(()=>{if(o)return;let{readOnly:f,mode:y}=Q();y==="default"&&!f&&br(),n()},s))};return n(),()=>{o=!0,t&&clearTimeout(t)}},[e])},ls=({autoSync:e})=>(Al(e),null);import{useEffect as Nl}from"react";var ms=()=>{let e=oe(process.cwd());return h(e)?T("No project here",null):lt({repoRoot:e.value})},cs=async()=>{let e=ms();if(h(e))return G(e.message);if(e.value===null)return T("No project here",null);let t=e.value,o=await gt(t);if(!jr())return T("State not initialized",null);let n=Pe();if(h(n))return T("State not initialized",null);let{mode:s,readOnly:u,timeMode:r,syncStatus:f,selectedNode:y,contextNode:p}=n.value;if(Cr())return T("Project loading",null);let g=ms();return h(g)||g.value!==t?T("Project changed",null):s!==H.DEFAULT||u||r!=="live"?T("Skipped while not on the live board",null):y?.isVirtual||p?.isVirtual?T("Skipped on a virtual node",null):f?.status==="syncing"?T("Sync in progress",null):o?T("Worktree held by a sync",null):$e(t)===Qo(t)?T("Log unchanged",null):(st.debug("[watch] event log moved, reloading state"),hr(t))};var Ml=1e3,ds=()=>(Nl(()=>Rt(cs,Ml),[]),null);function No({width:e,height:t}){let o=O(),{autoSync:n,viewMode:s}=Oo(),u=o.filters;if(o.mode===H.HELP)return M.createElement(ce,{flexDirection:"column"},M.createElement(ki,{width:e,height:t}));if(o.mode===H.IDENTITY)return M.createElement(ce,{flexDirection:"column"},M.createElement(Wi,{width:e,height:t}));if(o.mode===H.PALETTE)return M.createElement(ce,{flexDirection:"column"},M.createElement(ot,{filters:u}),M.createElement(Ei,{width:e,height:t-2}),M.createElement(Qe,{width:e,mode:o.mode,availableHints:o.availableHints}));let{isSetupDone:r}=pt(),f=!r,y=r&&!o.hasProjectDefinition;if(f)return M.createElement(ce,{flexDirection:"column"},M.createElement(ce,{flexDirection:"column"},M.createElement(ot,{hideBreadCrumb:!0,filters:u}),M.createElement(Io,{height:t,width:e})),M.createElement(Qe,{width:e,mode:o.mode,availableHints:[]}));if(y)return M.createElement(ce,{flexDirection:"column"},M.createElement(ce,{flexDirection:"column"},M.createElement(ot,{hideBreadCrumb:!0,filters:u}),M.createElement(Vi,{height:t,width:e})),M.createElement(Qe,{width:e,mode:o.mode,availableHints:[]}));let p=ko(o.breadCrumb??[],"BOARD");if($(p)){let g=p.value.id,l=Fe(g).length,d=3,a=Math.floor(e/d),i=Math.floor(e/Math.max(l,1));e=Math.min(i,a)*Math.max(l,d)}return M.createElement(ce,{flexDirection:"column"},M.createElement(ls,{autoSync:n}),M.createElement(ds,null),M.createElement(ce,{flexDirection:"column"},M.createElement(ot,{filters:u}),M.createElement(as,{width:e,height:t,contextNode:o.contextNode,selectedIndex:o.selectedIndex,breadCrumb:o.breadCrumb,viewMode:s??"dense",mode:o.mode})),M.createElement(Qe,{width:e,mode:o.mode,availableHints:o.availableHints}))}import Rl from"readline";var qt,Jt,se,Bl=new Set([b.MoveCursorLeft,b.EraseInputWord,b.MoveCursorLeftOfWord,b.MoveCursorRight,b.MoveCursorRightOfWord,b.NavToPreviousContainer,b.NavToNextContainer,b.NavPreviousItem,b.NavNextItem,b.NavPreviousItemJump,b.NavNextItemJump,b.SetViewDense,b.SetViewWide,b.Confirm,b.Exit,b.Yank,b.InitCommandLine,b.InitCommandPalette,b.ExitCommandLine,b.CaptureInput,b.EraseInput,b.EraseInputWord,b.HideHelp,b.ViewHelp,b.SetViewDense,b.SetViewWide,b.GetLastCommandFromHistory,b.GetNextCommandFromHistory,b.AutoCompleteCommand]),Ll=new Set([b.NavPreviousItem,b.NavNextItem,b.NavPreviousItemJump,b.NavNextItemJump,b.NavToPreviousContainer,b.NavToNextContainer,b.Confirm,b.Exit,b.InitCommandPalette,b.InitMove,b.MoveNextItem,b.MovePreviousItem,b.MoveNextItemJump,b.MovePreviousItemJump,b.MoveToNextContainer,b.MoveToPreviousContainer,b.Delete,b.AddItem,b.EditTitle,b.EditDescription,b.ConfirmMove,b.Edit,b.ViewHelp,b.Yank]),us=async e=>{if(e.ctrl&&e.name==="c")return Ce.exit();let{actionIndex:t,mode:o,readOnly:n,timeMode:s}=Q(),u=gr(e,o);if(!u||n&&!Bl.has(u)||s==="replay"&&o===H.DEFAULT&&Ll.has(u))return;let r=t[o]?.[u];if(r?.action)try{await r.action(r,e)}catch(f){logger.error(f)}},jl=()=>async function(t,o){o.name!=="escape"&&(se&&(clearTimeout(se),se=void 0),await us(o))},_l=()=>async function(t){if(t.length===1&&t[0]===27){se&&clearTimeout(se),se=setTimeout(()=>{us({name:"escape",ctrl:!1,meta:!1,shift:!1,sequence:"\x1B"}),se=void 0},25);return}se&&(clearTimeout(se),se=void 0)};function ps(){qt&&process.stdin.removeListener("keypress",qt),Jt&&process.stdin.removeListener("data",Jt),qt=jl(),Jt=_l(),Rl.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.on("data",Jt),process.stdin.on("keypress",qt)}async function fs(){try{let e=it({});if(h(e))return ht(0,e.message);let t=Ie();$(t)&&Ue(t.value);let o=oe(process.cwd());Ue({gitEmail:await kr(process.cwd()),gitName:await Wr(process.cwd())});let n=$(o)?await Pr(o.value):Nr();if(h(n))return n;let s=Mo();return h(s)?ht(6,s.message):(ps(),$(o)&&Ar(o.value),T("Booted Epiq",void 0))}catch(e){return ht(0,bt(e))}}Er();var Gl=`${z.bold("Epiq CLI")}
5
+
6
+ ${z.dim("Boot in directory:")}
7
+ ${z.cyan("$ epiq")}
8
+
9
+ ${z.dim("Launch GUI:")}
10
+ ${z.cyan("$ epiq gui")}
11
+ ${z.cyan("$ epiq gui --no-open")} ${z.dim("no browser")}
12
+
13
+ ${z.dim("Act as somebody other than the configured user:")}
14
+ ${z.cyan("$ epiq --as claude")}
15
+ `,Qt=Ol(Gl,{importMeta:import.meta,version:F,flags:{init:{type:"boolean",default:!1},as:{type:"string"},open:{type:"boolean",default:!0}}}),Xt=Qt.input[0];Xt&&Xt!=="gui"&&(console.error(z.red(`Unknown command: ${Xt}`)),process.exit(1));if(Qt.flags.as!==void 0){let e=Lo(Qt.flags.as,"--as");h(e)&&(console.error(z.red(e.message)),process.exit(1))}var gs=process.stdout.columns||120,ys=()=>Math.max(1,(process.stdout.rows||20)-(process.platform==="win32"?1:0)),hs=ys(),zt=null,$l=e=>{try{return zt?(zt.rerender(e),T("Rerendered app",void 0)):(zt=Dl(e,{incrementalRendering:!0,interactive:!!process.stdout.isTTY}),T("Rendered app",void 0))}catch(t){return G(`Unable to render app: ${bt(t)}`)}},Mo=()=>$l(Ul.createElement(No,{width:gs,height:hs}));process.stdout.on("resize",()=>{if(gs=process.stdout.columns||120,hs=ys(),!zt)return;let e=Mo();h(e)&&logger.info(`[boot:resize] ${e.message}`)});if(Xt==="gui"){let e=await vi({repoRoot:process.cwd(),open:Qt.flags.open});h(e)&&(console.error(z.red(`Failed to start Epiq GUI:
16
+ ${e.message}`)),process.exitCode=1)}else{process.stdin.isTTY&&process.stdin.setRawMode(!0),console.clear();let e=await fs();h(e)&&(logger.info(e.message),console.error(z.red(`Failed to boot Epiq:
17
+ ${e.message}`)),process.exitCode=1)}export{Mo as renderApp};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as t}from"./chunk-2KWSZBVJ.js";var r=`epiq-mcp ${t}
2
+ import{a as t}from"./chunk-6R2YRUOL.js";var r=`epiq-mcp ${t}
3
3
 
4
4
  Usage: epiq-mcp [name]
5
5