diffstalkerd 0.14.1 → 0.14.2
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.
|
@@ -18,11 +18,11 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
18
18
|
`),r=Kb(n),i=Hb(t);if(r===null)return i;let a=n.slice(r).join(`
|
|
19
19
|
`);return i===``?a:`${i}\n\n${a}`}function Jb(e,t){return Gb(e)!==Hb(t)}function Yb(e,t){return e.branch===t?!0:e.prefix?e.branch===``||t.startsWith(`${e.branch}/`):!1}var Xb=`absent`;function Zb(e){let t=new Xs,n=H(null),r=H(null),i=H(``),a=H(Xb),o=H(`idle`),s=H(null),c=H(null),l=H(!1),u=H(!1),d=H(!1),f=H(!1),p=Q(()=>{let e=c.value?.pr??null;return e===null||e.state!==`open`||e.body===null?null:Gb(e.body)}),m=0,h=null,g=!1,_=null,v=!1,y=null,b=!0;function x(){return g||_!==null||o.value===`error`}function S(){h!==null&&(clearTimeout(h),h=null)}function C(e){r.value=e,d.value=!1,i.value=e.top??``,a.value=e.version,o.value=`idle`,s.value=null}async function w(e,n){try{let r=await t.branchPr(e.id,e.branch);n===m&&(c.value=r)}catch(t){n===m&&Qs(`read the PR of a branch`,t,{branch:e.branch})}}async function T(e,n){l.value=!0;try{let r=await t.draft(e.id,e.branch);if(n!==m)return;C(r)}catch(t){if(n!==m)return;Zs(`read PR draft`,t,{branch:e.branch}),s.value=`Could not read the draft: ${Rs(t)}`}finally{n===m&&(l.value=!1)}}async function E(){S();let e=n.value,r=_;if(e===null||!g&&o.value!==`error`){r!==null&&await r;return}g=!1;let s=i.value,c=a.value,l=(r===null?null:await r)??c;try{await t.putDraft(e.id,{branch:e.branch,top:s,version:l})}catch(t){Zs(`save PR draft`,t,{branch:e.branch})}}function D(){m+=1,n.value=null,S(),g=!1,_=null,v=!1,r.value=null,i.value=``,d.value=!1,b=!0,a.value=Xb,o.value=`idle`,s.value=null,c.value=null,l.value=!1,f.value=!1}function O(e){if(e===null)return;let t={id:e.id,branch:e.branch};n.value=t;let r=m;T(t,r),w(t,r)}function k(){h=null;let e=n.value;if(_!==null||!g||e===null)return;g=!1;let t=m,r=i.value;o.value=`saving`,_=A(e,r,t)}async function A(e,n,i){let c=null;try{let l=await t.putDraft(e.id,{branch:e.branch,top:n,version:a.value});if(c=l.version,i!==m)return c;r.value=l,a.value=l.version,o.value=g?`dirty`:`idle`,s.value=null}catch(t){if(i!==m)return null;t instanceof Is&&t.status===409?(Zs(`save PR draft`,t,{branch:e.branch}),o.value=`conflict`,g=!1,S()):(Zs(`save PR draft`,t,{branch:e.branch}),o.value=`error`,s.value=`Could not save: ${Rs(t)}`)}return i===m&&M(),c}function j(){o.value===`error`&&(g=!0),S(),k()}function M(){_=null,v&&(v=!1,R()),g&&h===null&&o.value!==`conflict`&&k()}function N(e){i.value=e,d.value=!1,b=!1,o.value!==`conflict`&&n.value!==null&&(g=!0,_===null&&(o.value=`dirty`),S(),h=setTimeout(k,400))}async function P(){let e=n.value;e!==null&&(S(),g=!1,b=!0,m+=1,_=null,await T(e,m))}async function F(){let e=n.value;if(e===null||x())return;let r=m;try{let n=await t.adoptDraft(e.id,{branch:e.branch,version:a.value});r===m&&C(n)}catch(t){if(r!==m)return;Zs(`start from the suggestion`,t,{branch:e.branch}),await T(e,r),r===m&&(s.value=`Could not start from the suggestion: ${Rs(t)}`)}}async function I(){let e=n.value;if(e===null)return;let r=m;u.value=!0;try{if(c.value?.pr){let n=await t.checkBranchPr(e.id,e.branch);r===m&&(c.value=n)}else await t.refreshWorkPrs(),await w(e,r)}catch(e){if(r!==m)return;Zs(`check PRs`,e),s.value=`Could not check PRs: ${Rs(e)}`}finally{u.value=!1}}async function L(){let e=n.value;if(e===null||x()||o.value===`conflict`)return;await I();let t=p.value;t!==null&&n.value===e&&(N(t),j())}async function ee(){let e=n.value,i=p.value;if(e===null||i===null||x()||r.value?.top==null)return;let o=m;f.value=!0;try{let n=await t.setPrTopZone(e.id,{branch:e.branch,version:a.value,expectedTop:i});if(o!==m)return;c.value=n,s.value=null}catch(n){if(o!==m)return;if(Zs(`update the PR top zone`,n,{branch:e.branch}),s.value=`Could not update GitHub: ${Rs(n)}`,n instanceof Is&&n.status===409)try{let n=await t.checkBranchPr(e.id,e.branch);o===m&&(c.value=n)}catch(t){Qs(`read the PR of a branch`,t,{branch:e.branch})}}finally{o===m&&(f.value=!1)}}async function R(){let e=n.value;if(e===null)return;let i=m,s=a.value,c;try{c=await t.draft(e.id,e.branch)}catch(t){i===m&&Qs(`re-read PR draft`,t,{branch:e.branch});return}i===m&&(_===null?a.value===s?(c.version===a.value||o.value===`conflict`?r.value!==null&&(r.value={...r.value,suggested:c.suggested,ai:c.ai,adoptedUnedited:c.adoptedUnedited}):x()?(o.value=`conflict`,g=!1,S()):C(c),w(e,i)):R():v=!0)}function te(e){let t=n.value;t!==null&&Yb(e,t.branch)&&(_===null?R():v=!0)}function ne(){let e=p.value;b&&e!==null&&e!==``&&r.value!==null&&r.value.top===null&&(x()||o.value!==`idle`||i.value!==``||(i.value=e,d.value=!0))}let re=De(!0);re.run(()=>{W([r,p],ne),W(e,e=>{let t=n.value;(e?.id!==t?.id||e?.branch!==t?.branch)&&(E(),D(),O(e))},{immediate:!0})});function ie(){if(y===null){let e=E();re.stop(),D(),y=e}return y}return Bt({branch:Q(()=>n.value?.branch??null),draft:r,text:i,baseVersion:a,save:o,error:s,pr:c,loading:l,checkingPrs:u,githubTop:p,prefilled:d,pushing:f,setText:N,reload:P,adopt:F,checkPrs:I,takeGithub:L,pushTop:ee,saveNow:j,onDraftChange:te,dispose:ie})}var Qb=Ps(`draft`,()=>{let e=new Xs,t=zl(),n=H(null),r=H(null),i=H(null),a=null,o=Q(()=>{let e=t.shared.status?.branch?.current||null,n=t.selectedStackHead;if(n===null)return e===null?[]:[e];let r=t.pickedLayer;return r===null?[n]:r.isHead&&e!==null?[e,...r.refs.filter(t=>t!==e)]:r.refs}),s=Q(()=>{let e=n.value;return e===null||e.id!==t.repoId?null:o.value.find(t=>e.names.includes(t))??null}),c=Q(()=>n.value?.id===t.repoId),l=Q(()=>i.value?.draft??null),u=Q(()=>i.value?.text??``),d=Q(()=>i.value?.baseVersion??`absent`),f=Q(()=>i.value?.save??`idle`),p=Q(()=>r.value??i.value?.error??null),m=Q(()=>i.value?.pr??null),h=Q(()=>i.value?.loading??!1),g=Q(()=>i.value?.checkingPrs??!1),_=Q(()=>i.value?.githubTop??null),v=Q(()=>i.value?.prefilled??!1),y=Q(()=>i.value?.pushing??!1);function b(){let e=t.repoId,n=s.value;return e===null||n===null?null:{id:e,branch:n}}async function x(){let i=t.repoId;if(i===null)n.value=null,r.value=null;else try{let a=await e.localBranches(i);if(i!==t.repoId)return;n.value={id:i,names:a.map(e=>e.name)},r.value=null}catch(e){if(i!==t.repoId)return;Zs(`list local branches`,e),r.value=`Could not list branches: ${Rs(e)}`}}let S=Q(()=>t.compareStack?.layers.map(e=>e.refs.join(`,`)).join(`|`)??``);function C(){a===null&&(a=De(!0),a.run(()=>{W([()=>t.repoId,()=>t.shared.status?.branch?.current??null,S],()=>void x(),{immediate:!0}),W(()=>t.lastDraftChange,e=>{e!==null&&i.value?.onDraftChange(e.event)}),W(()=>t.switchStarts,()=>i.value?.saveNow(),{flush:`sync`})}),i.value=Zb(b))}function w(){i.value?.dispose(),i.value=null,a?.stop(),a=null,n.value=null,r.value=null}function T(e){i.value?.setText(e)}async function E(){await i.value?.reload()}async function D(){await i.value?.adopt()}async function O(){await i.value?.checkPrs()}async function k(){await i.value?.takeGithub()}async function A(){await i.value?.pushTop()}return{branch:s,branchesKnown:c,draft:l,text:u,baseVersion:d,save:f,error:p,pr:m,loading:h,checkingPrs:g,githubTop:_,prefilled:v,pushing:y,start:C,stop:w,setText:T,reload:E,adopt:D,checkPrs:O,takeGithub:k,pushTop:A}}),$b=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],ex=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],tx=864e5,nx=tx;function rx(e){return String(e).padStart(2,`0`)}function ix(e){let t=new Date(e);return`${rx(t.getHours())}:${rx(t.getMinutes())}`}function ax(e){let t=new Date(e);return`${t.getDate()} ${$b[t.getMonth()]}`}function ox(e,t){let n=new Date(e),r=new Date(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()?ix(e):`${ax(e)} ${ix(e)}`}var sx=6e4,cx=[[`year`,365*tx],[`month`,30*tx],[`day`,tx],[`hour`,60*sx],[`minute`,sx]];function lx(e,t){let n=t-e;for(let e=0;e<cx.length;e++){let[t,r]=cx[e],i=Math.floor(n/r);if(i<1)continue;let a=[Wx(i,t)],o=cx[e+1];if(o!==void 0){let e=Math.min(Math.floor((n-i*r)/o[1]),t===`year`?11:1/0);e>0&&a.push(Wx(e,o[0]))}return`${a.join(` `)} ago`}return`just now`}function ux(e){let t=new Date(e);return`${ex[t.getDay()]} ${ax(e)} ${t.getFullYear()}, ${ix(e)}`}function dx(e,t){return fx(e,t,nx)}function fx(e,t,n){return e.activity!==null&&t-e.activity<=n}var px={local:`local only`,pushed:`pushed, no PR`,draft:`draft PR`,review:`in review`,changes:`changes requested`,approved:`approved`,merged:`merged`,closed:`closed`,gone:`branch gone`},mx={local:1,pushed:2,draft:3,review:4,changes:4,approved:5,merged:5,closed:0,gone:0},hx=[`local`,`pushed`,`draft`,`review`,`changes`,`approved`,`merged`,`closed`,`gone`],gx={approved:`approved`,"changes-requested":`changes requested`,reviewed:`reviewed`,commented:`commented`},_x={...gx,edited:`files edited`,git:`commit or checkout`,"head-commit":`new commit on the PR`,draft:`draft edited`,merged:`merged`,closed:`closed`};function vx(e){let t=_x[e.kind];return e.author===null?t:`${t} · ${e.author}`}function yx(e,t){let n=[];for(let r of e.pr?.progress?.events??[]){let e=Date.parse(r.at);Number.isNaN(e)||n.push({at:e,text:`${gx[r.kind]} · ${r.author}`,other:t!==null&&r.author!==t})}let r=e.pr,i=r?.state===`open`?Date.parse(r.progress?.headCommittedAt??``):NaN;if(Number.isNaN(i)||n.push({at:i,text:_x[`head-commit`],other:!1}),r!==null&&r.state!==`open`){let e=Date.parse(r.mergedAt??r.closedAt??``);Number.isNaN(e)||n.push({at:e,text:r.state,other:!1})}let a=[[e.times.edited,_x.edited],[e.times.git,_x.git],[e.times.draft,_x.draft]];for(let[e,t]of a)e!==null&&n.push({at:e,text:t,other:!1});return n.sort((e,t)=>t.at-e.at)}function bx(e){let t=[e.decision===null?`no decision`:e.decision.replace(`-`,` `)];e.pendingReviewers>0&&t.push(`${e.pendingReviewers} asked`),e.unresolvedThreads>0&&t.push(Wx(e.unresolvedThreads,`open thread`));let n=[[`Review`,t.join(`, `)],[`Checks`,e.checks===null?`none`:e.checks]];return e.conflicting&&n.push([`Merge`,`conflicts with the base branch`]),n}function xx(e){let t=[];return e.uncommitted>0&&t.push(`${e.uncommitted} uncommitted`),e.unpushed>0&&t.push(`${e.unpushed} unpushed`),e.ahead>0&&t.push(e.base===null?`${e.ahead} ahead`:`${e.ahead} ahead of ${e.base}`),t.join(`, `)}function Sx(e){let t=[[`Stage`,px[e.stage]]],n=e.pr?.baseRefName??e.facts.base;n&&t.push([`Base`,n]),e.stack&&t.push([`Stack`,`layer ${e.stack.position} of ${e.stack.size}, on ${e.stack.root}`]),e.pr?.progress&&t.push(...bx(e.pr.progress)),e.worktreePath&&t.push([`Worktree`,e.worktreePath]);let r=xx(e.facts);return r!==``&&t.push([`Local`,r]),e.note&&t.push([`Note`,Ux[e.note]]),e.tracked&&t.push([`Marks`,`tracked`]),t}function Cx(e,t,n){return{text:e,turn:t,why:n}}function wx(e,t,n){let r=e.progress;if(e.isDraft)return Cx(`draft`,`you`,`A draft on GitHub: not asking for review yet`);if(r===null)return Cx(`open`,`none`,`GitHub did not say more about this PR`);if(r.conflicting)return Cx(`conflicts`,`you`,`GitHub says it has merge conflicts`);if(r.checks===`failure`)return Cx(`checks failing`,`you`,`The checks on its head failed`);if(t.attention.includes(`changes-requested`))return Cx(`changes requested`,`you`,Dx(t)[0]??``);let i=r.events.find(e=>e.kind===`approved`&&e.author!==n);if(r.decision===`approved`||r.decision===null&&i)return Cx(`approved`,`you`,`Approved: ready to merge`);let a=r.requestedReviewers.join(`, `);if(r.decision===`changes-requested`)return Cx(`awaiting re-review`,`others`,`Asked to review again: ${a}`);if(r.requestedReviewers.length>0||r.pendingReviewers>0)return Cx(`awaiting review`,`others`,`Asked to review: ${a}`);let o=r.events.find(e=>e.kind===`reviewed`&&e.author!==n);return o?Cx(`reviewed, no decision`,`you`,`${o.author} reviewed with comments only, and nobody is asked to review now`):Cx(`needs reviewer`,`you`,`Nobody is asked to review it yet`)}var Tx={"pushed-no-pr":Cx(`no PR yet`,`you`,`Pushed, and no PR for it yet`),"not-pushed":Cx(`not pushed`,`you`,`Commits that are on no remote yet`),uncommitted:Cx(`uncommitted`,`you`,`Changes that are not committed`),empty:Cx(`nothing yet`,`none`,`A new worktree with nothing in it yet`),"branch-gone":Cx(`branch gone`,`none`,`The branch no longer exists`)};function Ex(e,t){let n=e.pr;return n?.reviewRequested?Cx(`your review`,`you`,`${n.author??`Someone`} asks you to review this`):n!==null&&n.state!==`open`?e.facts.uncommitted>0?Cx(`${n.state}, leftovers`,`you`,`The PR is done; the worktree still has changes`):Cx(n.state,`none`,`The PR is ${n.state}`):n===null?Tx[e.state]??Cx(e.state,`none`,``):wx(n,e,t)}function Dx(e){let t=e.pr,n=t?.progress??null;return e.attention.map(e=>e===`review-requested`?`${t?.author??`Someone`} asks you to review this`:`Changes requested by ${(n?.changesRequestedBy??[]).filter(e=>!(n?.requestedReviewers??[]).includes(e)).join(`, `)}, not asked to review again yet`)}function Ox(e){let t=[],n=e.pr;if(n!==null){t.push(`Pull request: ${n.url}`,`Title: ${n.title}`),n.author!==null&&t.push(`Author: ${n.author}${n.reviewRequested?` (I am asked to review it)`:``}`);let e=n.headOwner===null?``:` from ${n.headOwner}`;t.push(`Branch: ${n.headRefName}${e}, into ${n.baseRefName} of ${n.repo}`,`Head commit: ${n.headRefOid}`)}else if(e.branch!==null){let n=e.facts.base===null?``:`, ahead of ${e.facts.base}`;t.push(`Branch: ${e.branch}${n}`)}return e.repoRoot===null?n!==null&&t.push(`Local clone: none; git clone https://github.com/${n.repo}.git`):t.push(`Local clone: ${e.repoRoot}`),e.worktreePath!==null&&t.push(`Worktree: ${e.worktreePath}`),t.join(`
|
|
20
20
|
`)}var kx={you:0,others:1,none:2},Ax={"changes-requested":0,"review-required":1,approved:2},jx={failure:0,pending:1,success:2};function Mx(e){return(e.decision===null?1:Ax[e.decision])*1e4-e.unresolvedThreads}function Nx(e){let t=e.checks===null?3:jx[e.checks];return(e.conflicting?0:10)+t}function Px(e){return e.draft?e.placeholders>0?0:e.bodyDiffers?1:2:null}function Fx(e){let t=e.stack;return t===null?null:`${t.root}\u0000${String(t.position).padStart(4,`0`)}`}function Ix(e,t){let n=e.pr?.progress??null;return n===null?null:t(n)}var Lx={stage:e=>hx.indexOf(e.stage),branch:e=>e.branch,stack:Fx,pr:e=>e.pr?.number??null,review:e=>Ix(e,Mx),ci:e=>Ix(e,Nx),local:e=>e.facts.uncommitted+e.facts.unpushed||null,draft:e=>Px(e.facts),status:e=>kx[Ex(e,null).turn],activity:e=>e.activity};function Rx(e,t){let n=t.dir===`asc`?1:-1,r=Lx[t.key],i=e.map(e=>({item:e,value:r(e)}));return i.sort((e,t)=>e.value===t.value?0:e.value===null?1:t.value===null?-1:(e.value<t.value?-1:1)*n),i.map(e=>e.item)}function zx(e,t=null){let n=new Map;for(let t of e){let e=t.repoRoot??t.repoName,r=n.get(e);r===void 0&&(r={key:e,name:t.repoName,items:[]},n.set(e,r)),r.items.push(t)}for(let e of n.values())e.items=t===null?Vx(e.items):Rx(e.items,t);return[...n.values()]}function Bx(e){return e.stack===null?null:`${e.repoRoot??e.repoName}\n${e.stack.root}`}function Vx(e){let t=new Map;for(let n of e){let e=Bx(n);if(e===null)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}let n=new Set,r=[];for(let i of e){let e=Bx(i);if(e===null){r.push(i);continue}if(n.has(e))continue;n.add(e);let a=t.get(e)??[i];r.push(...[...a].sort((e,t)=>(e.stack?.position??0)-(t.stack?.position??0)))}return r}var Hx={"no-local-clone":`no clone`,"no-local-branch":`no branch`,"worktree-on-disk":`on disk`},Ux={"no-local-clone":`no local clone`,"no-local-branch":`no local branch`,"worktree-on-disk":`worktree still on disk`};function Wx(e,t){return`${e} ${t}${e===1?``:`s`}`}function Gx(e,t){switch(e){case`gh-missing`:return`gh not found — PR state unknown`;case`gh-logged-out`:return`gh not logged in — PR state unknown`;case`error`:return`could not reach GitHub: ${t??`unknown error`}`;default:return null}}function Kx(e,t,n){let r=t===null?``:` as ${t}`;return`PRs checked ${lx(e,n)}${r}`}function qx(e,t,n){let r=t===null?``:` as ${t}`;return`PRs checked ${ox(e,n)}${r}`}var Jx=[{key:`day`,label:`Last day`,within:tx},{key:`week`,label:`Last week`,within:7*tx},{key:`two-weeks`,label:`Last 2 weeks`,within:14*tx},{key:`month`,label:`Last month`,within:30*tx},{key:`older`,label:`Older`,within:1/0}];function Yx(e,t){return t===null?Vx(e):Rx(e,t)}function Xx(e,t){let n=Jx.map(e=>({...e,items:[]}));for(let r of e){let e=r.activity===null?1/0:t-r.activity;(n.find(t=>e<=t.within)??n[n.length-1]).items.push(r)}return n.filter(e=>e.items.length>0)}function Zx(e,t){let n=t.byTime?Xx(e,t.now):[{key:`all`,label:``,items:[...e]}],r=[];for(let e of n)if(t.byTime&&r.push({kind:`time`,key:`t:${e.key}`,label:e.label,count:e.items.length}),!t.byRepo)for(let n of Yx(e.items,t.sort))r.push({kind:`item`,key:n.key,item:n});else for(let n of zx(e.items,t.sort)){r.push({kind:`repo`,key:`r:${e.key}:${n.key}`,name:n.name,count:n.items.length});for(let e of n.items)r.push({kind:`item`,key:e.key,item:e})}return r}var Qx={class:`draft-panel`,"data-testid":`pr-draft-panel`,"aria-label":`PR draft`},$x={class:`panel-head`},eS=[`data-tip`],tS={key:0,class:`note`},nS={key:1,class:`note`,"data-testid":`draft-no-branch`},rS={class:`pr-line`,"data-testid":`draft-pr-line`},iS=[`href`,`data-tip`],aS={class:`pr-state`},oS=[`disabled`],sS={class:`dim`},cS=[`disabled`],lS={key:0,class:`note dim`,"data-testid":`draft-prefilled`},uS=[`value`,`disabled`],dS={class:`save-line`,"data-testid":`draft-save-line`},fS={key:1,class:`note view-error`,"data-testid":`draft-error`},pS={key:2,class:`sync`,"data-testid":`draft-body-differs`},mS={class:`sync-line`},hS=[`disabled`],gS=[`disabled`,`data-tip`],_S={key:0,class:`sync-line confirm`,"data-testid":`draft-push-confirm`},vS={class:`github-top`},yS={class:`text-block mono`,"data-testid":`draft-github-top`},bS={key:3,class:`suggestion offered`,"data-testid":`draft-suggestion`},xS={class:`text-block mono`},SS={key:4,class:`suggestion`,"data-testid":`draft-suggestion`},CS={class:`text-block mono`},wS={key:5,class:`ai-zone`,"data-testid":`draft-ai`},TS={class:`text-block mono`},ES={class:`preview-section`},DS={class:`eyebrow`},OS={key:0,class:`holes`,"data-testid":`draft-placeholder-count`},kS={class:`text-block preview mono`,"data-testid":`draft-preview`},AS={key:0,class:`hole`},jS=af(gr({__name:`PrDraftPanel`,props:{session:{}},setup(e){let t=e,n=t.session===void 0?Qb():null;jr(()=>n?.start()),Pr(()=>n?.stop());let r=Q(()=>t.session??Qb()),i=Q(()=>n!==null&&!n.branchesKnown),a=Q(()=>n!==null&&n.branch===null),o=Q(()=>r.value.text.trim()===``),s=Q(()=>r.value.draft?.suggested??null),c=Q(()=>r.value.draft?.ai??null),l=Q(()=>s.value!==null&&o.value&&r.value.save===`idle`),u=Q(()=>r.value.pr?.pr??null),d=Q(()=>{let e=u.value;return e===null?``:e.state===`open`?e.isDraft?`draft`:`open`:e.state}),f=Q(()=>{let e=u.value;return e!==null&&e.state===`open`&&e.body!==null&&!o.value&&Jb(e.body,r.value.text)}),p=Q(()=>f.value&&r.value.save===`idle`&&r.value.draft?.top!=null),m=Q(()=>Vb(r.value.text)),h=V(!1);W(p,e=>{e||(h.value=!1)});async function g(){h.value=!1,await r.value.pushTop()}let _=Q(()=>{let e=r.value.pr;if(e===null||e.pr!==null)return null;if(e.status===`never`)return`PR state not checked`;let t=Gx(e.status,e.message);return t===null?`No PR for this branch${e.checkedAt===null?``:` · ${qx(e.checkedAt,e.viewer,Date.now())}`}`:t}),v=Q(()=>{switch(r.value.save){case`dirty`:case`saving`:return`saving…`;case`conflict`:return`changed elsewhere`;case`error`:return r.value.error;default:return r.value.draft?.adoptedUnedited?`agent text, not edited`:null}}),y=Q(()=>{let e=u.value;return e!==null&&e.state===`open`&&e.body!==null?e.body:null}),b=Q(()=>y.value===null?Ub(r.value.text,c.value):qb(y.value,r.value.text)),x=Q(()=>Vb(b.value)),S=Q(()=>{let e=b.value,t=[],n=0;for(let r of Bb(e))r.start>n&&t.push({text:e.slice(n,r.start),hole:!1}),t.push({text:e.slice(r.start,r.end),hole:!0}),n=r.end;return n<e.length&&t.push({text:e.slice(n),hole:!1}),t});function C(e){r.value.setText(e.target.value)}return(e,t)=>(q(),J(`aside`,Qx,[Y(`header`,$x,[t[8]||=Y(`span`,{class:`eyebrow`},`PR draft`,-1),r.value.branch?(q(),J(`span`,{key:0,class:`branch mono`,"data-tip":r.value.branch},B(r.value.branch),9,eS)):Z(``,!0)]),i.value?(q(),J(`p`,tS,`Loading…`)):a.value?(q(),J(`p`,nS,` No local branch to draft for. Pick a layer that is a local branch, or check one out. `)):(q(),J(K,{key:2},[Y(`p`,rS,[u.value?(q(),J(K,{key:0},[Y(`a`,{class:`pr-link mono`,href:u.value.url,target:`_blank`,rel:`noopener noreferrer`,"data-tip":u.value.title},`PR #`+B(u.value.number),9,iS),Y(`span`,aS,B(d.value),1),Y(`button`,{class:`small-btn`,"data-testid":`draft-check-pr`,disabled:r.value.checkingPrs,"data-tip":`Read this PR from GitHub again`,onClick:t[0]||=e=>r.value.checkPrs()},B(r.value.checkingPrs?`checking…`:`check again`),9,oS)],64)):_.value?(q(),J(K,{key:1},[Y(`span`,sS,B(_.value),1),Y(`button`,{class:`small-btn`,"data-testid":`draft-check-prs`,disabled:r.value.checkingPrs,onClick:t[1]||=e=>r.value.checkPrs()},B(r.value.checkingPrs?`checking…`:`check PRs`),9,cS)],64)):Z(``,!0)]),t[14]||=Y(`label`,{class:`editor-label eyebrow`,for:`pr-draft-top`},`Your words (top.md)`,-1),r.value.prefilled?(q(),J(`p`,lS,` From the PR on GitHub. Saved as top.md once you edit. `)):Z(``,!0),Y(`textarea`,{id:`pr-draft-top`,class:`editor mono`,"data-testid":`draft-editor`,spellcheck:`true`,value:r.value.text,disabled:r.value.loading,placeholder:`What this change is and why. {{like this}} marks a gap to fill.`,onInput:C},null,40,uS),Y(`p`,dS,[v.value?(q(),J(`span`,{key:0,class:z({warn:r.value.save===`conflict`||r.value.save===`error`})},B(v.value),3)):Z(``,!0),r.value.save===`conflict`?(q(),J(`button`,{key:1,class:`small-btn`,"data-testid":`draft-reload`,"data-tip":`Drop what is typed here and take the file's text`,onClick:t[2]||=e=>r.value.reload()},` reload `)):Z(``,!0)]),r.value.error&&r.value.save!==`error`?(q(),J(`p`,fS,B(r.value.error),1)):Z(``,!0),p.value?(q(),J(`section`,pS,[Y(`p`,mS,[t[9]||=Y(`span`,{class:`differs`},`Your words differ from the PR on GitHub.`,-1),Y(`button`,{class:`small-btn`,"data-testid":`draft-take-github`,disabled:r.value.checkingPrs||r.value.pushing,"data-tip":`Read the PR again and save its top zone as top.md`,onClick:t[3]||=e=>r.value.takeGithub()},` Take GitHub's text `,8,hS),h.value?Z(``,!0):(q(),J(`button`,{key:0,class:`small-btn`,"data-testid":`draft-push`,disabled:r.value.pushing||m.value>0,"data-tip":m.value>0?`Fill the {{…}} placeholders first`:`Put your words in the PR's top zone on GitHub`,onClick:t[4]||=e=>h.value=!0},B(r.value.pushing?`updating…`:`Update GitHub…`),9,gS))]),h.value?(q(),J(`p`,_S,[Y(`span`,null,`Replace the top zone of PR #`+B(u.value?.number)+` on GitHub with your words? The part below the line stays as it is.`,1),Y(`button`,{class:`small-btn primary`,"data-testid":`draft-push-yes`,onClick:t[5]||=e=>g()},` Update GitHub `),Y(`button`,{class:`small-btn`,onClick:t[6]||=e=>h.value=!1},`Cancel`)])):Z(``,!0),Y(`details`,vS,[t[10]||=Y(`summary`,{class:`eyebrow`},`GitHub's text`,-1),Y(`pre`,yS,B(r.value.githubTop),1)])])):Z(``,!0),l.value?(q(),J(`section`,bS,[t[11]||=Y(`span`,{class:`eyebrow`},`agent suggestion`,-1),Y(`pre`,xS,B(s.value),1),Y(`button`,{class:`small-btn`,"data-testid":`draft-adopt`,onClick:t[7]||=e=>r.value.adopt()},` start from this `)])):s.value===null?Z(``,!0):(q(),J(`details`,SS,[t[12]||=Y(`summary`,{class:`eyebrow`},`agent suggestion`,-1),Y(`pre`,CS,B(s.value),1)])),c.value===null?Z(``,!0):(q(),J(`details`,wS,[t[13]||=Y(`summary`,{class:`eyebrow`},`AI zone (ai.md)`,-1),Y(`pre`,TS,B(c.value),1)])),Y(`section`,ES,[Y(`span`,DS,[X(B(y.value===null?`body as sent`:`body after Update GitHub`)+` `,1),x.value>0?(q(),J(`span`,OS,`· `+B(x.value)+` `+B(x.value===1?`placeholder`:`placeholders`),1)):Z(``,!0)]),Y(`pre`,kS,[(q(!0),J(K,null,G(S.value,(e,t)=>(q(),J(K,{key:t},[e.hole?(q(),J(`mark`,AS,B(e.text),1)):(q(),J(K,{key:1},[X(B(e.text),1)],64))],64))),128))])])],64))]))}}),[[`__scopeId`,`data-v-9e67b4c6`]]),MS={class:`topbar`,"data-testid":`compare-topbar`},NS={class:`base-select`},PS=[`title`],FS={key:1,class:`arrow`,"aria-hidden":`true`},IS=[`disabled`,`value`],LS={key:0,value:``,disabled:``},RS=[`value`],zS={key:1,class:`uncommitted-toggles`,"data-testid":`uncommitted-toggles`},BS=[`data-testid`,`checked`,`disabled`,`title`,`onChange`],VS={key:2,class:`stats mono`,"data-testid":`compare-stats`},HS={class:`files-changed`},US={class:`count-add`},WS={class:`count-del`},GS={key:3,class:`topbar-busy mono`,"data-testid":`compare-busy`},KS=[`aria-pressed`],qS={class:`compare-body`},JS={key:0,class:`view-error error-banner`,"data-testid":`compare-error-banner`},YS={key:1,class:`panel-note view-error`,"data-testid":`compare-error`},XS={key:2,class:`state-block`,"data-testid":`no-base-branch`},ZS={key:3,class:`panel-note`,"data-testid":`compare-loading`},QS={key:4,class:`panel-note`,"data-testid":`compare-clean`},$S={key:0,class:`commits-section`},eC=[`aria-expanded`],tC={class:`chevron`},nC={class:`commits-count`},rC={key:0,class:`commit-list mono`,"data-testid":`compare-commits`},iC={class:`hash`},aC=[`title`],oC={class:`meta`},sC={class:`author`},cC={class:`date`},lC=[`aria-busy`],uC=af(gr({__name:`CompareView`,setup(e){let t=zl(),n=Gl(),{compare:r,compareStack:i,selectedStackHead:a,pickedLayer:o,comparePair:s,compareUncommitted:c}=Fs(t),l=[{key:`staged`,label:`staged`},{key:`unstaged`,label:`unstaged`},{key:`untracked`,label:`untracked`}],u=V([]),d=V(!1),f=Bt(new Set),p=V(null),m=Q(()=>p.value?.scrollerEl??null);jr(()=>{h(),g()});async function h(){await t.refreshCompare()}async function g(){try{u.value=await t.getCandidateBaseBranches()}catch{u.value=[]}}let _=Q(()=>r.value.compareDiff),v=Q(()=>_.value?.files??[]),y=Q(()=>t.shared.status?.branch?.current||null),b=Q(()=>s.value.head??y.value),x=Q(()=>{let e=r.value.baseBranch;return e!==null&&!u.value.includes(e)?[e,...u.value]:u.value});async function S(e){let n=e.target.value;n&&n!==r.value.baseBranch&&(au({view:`compare`}),await t.setSelectedCompareBase(n))}let C=Q(()=>(i.value?.layers.length??0)>=2);async function w(e){e!==a.value&&(au({view:`compare`}),await t.setSelectedStackHead(e))}let T=Q(()=>a.value!==null&&o.value?.isHead!==!0),E=Q(()=>c.value.unstaged);async function D(e,n){let r={...c.value,[e]:n.target.checked};r.unstaged&&(r.staged=!0),await t.setCompareUncommitted(r)}function O(e){return Md(e.date.getTime())}let k=Q(()=>r.value.selection.type===`file`?r.value.selection.index:null);function A(e){au({view:`compare`}),j(e)}function j(e){t.selectCompareFile(e);let n=v.value[e];if(!n)return;let r=jl(n);f.delete(r),On(()=>p.value?.scrollToFile(r))}W(()=>n.stackScrollRequest,e=>{e&&On(()=>p.value?.scrollToFile(e.key,{smooth:!1}))}),W(()=>n.expandGatedRequest,e=>{e!==0&&p.value?.expandAllGated()});function M(e){let n=v.value.findIndex(t=>jl(t)===e);n!==-1&&t.selectCompareFile(n)}W(()=>v.value,e=>{let n=qy(e)[0];n&&k.value===null&&t.selectCompareFile(e.indexOf(n))},{immediate:!0});function N(e){f.has(e)?f.delete(e):f.add(e)}function P(e){if(au({view:`compare`}),t.wholeFile?.key===e){t.setWholeFile(null);return}let n=F.value.find(t=>jl(t)===e);if(!n)return;let r=v.value.findIndex(t=>jl(t)===e);r!==-1&&j(r),t.setWholeFile({view:`compare`,key:e,path:n.path,side:n.uncommitted})}let F=Q(()=>qy(v.value)),I=Q(()=>F.value.map(e=>({key:jl(e),path:e.path,status:e.status,uncommitted:e.uncommitted,stats:{insertions:e.additions,deletions:e.deletions},diff:t.wholeFile?.key===jl(e)?t.wholeFile.diff:e.diff,collapsed:f.has(jl(e)),refPair:e.uncommitted?{kind:`compare-uncommitted`,base:s.value.base,side:e.uncommitted}:{kind:`compare`,base:s.value.base,head:s.value.head}}))),L=Q(()=>{let e=k.value;if(e===null)return null;let t=v.value[e];return t?jl(t):null}),ee=bu(),R=V(null),te=Um({container:R,isRow:ee,row:{pref:`compareTop`,defaultRatio:.22,min:ml,max:hl}}),ne=qm(ee,m,`File diffs`,{self:!0});return(e,o)=>(q(),J(`div`,{class:z([`compare`,{portrait:U(ee)}]),style:le(U(ee)?{"--compare-top":`${(U(te).rowRatio.value*100).toFixed(2)}%`}:void 0)},[Y(`header`,MS,[(q(),ga(lr,{defer:``,to:`#view-toolbar-slot`,disabled:!U(ee)},[Y(`label`,NS,[b.value?(q(),J(`span`,{key:0,class:`head-branch mono`,title:b.value},B(b.value),9,PS)):Z(``,!0),b.value?(q(),J(`span`,FS,`→`)):Z(``,!0),o[2]||=Y(`span`,{class:`eyebrow`},`base`,-1),Y(`select`,{class:`mono`,"data-testid":`base-select`,"aria-label":`Base branch`,disabled:U(r).loading,value:U(r).baseBranch??``,onChange:S},[U(r).baseBranch===null?(q(),J(`option`,LS,`pick a base…`)):Z(``,!0),(q(!0),J(K,null,G(x.value,e=>(q(),J(`option`,{key:e,value:e},B(e),9,RS))),128))],40,IS)])],8,[`disabled`])),C.value&&U(i)?(q(),ga(Lb,{key:0,stack:U(i),active:U(a),disabled:U(r).loading,onPick:w},null,8,[`stack`,`active`,`disabled`])):Z(``,!0),T.value?Z(``,!0):(q(),J(`fieldset`,zS,[o[3]||=Y(`legend`,null,`include`,-1),(q(),J(K,null,G(l,e=>Y(`label`,{key:e.key,class:`uncommitted-toggle`},[Y(`input`,{type:`checkbox`,"data-testid":`uncommitted-toggle-${e.key}`,checked:U(c)[e.key],disabled:e.key===`staged`&&E.value,title:e.key===`staged`&&E.value?`Unstaged edits sit on top of staged ones, so unstaged includes these`:void 0,onChange:t=>D(e.key,t)},null,40,BS),Y(`span`,null,B(e.label),1)])),64))])),_.value?(q(),J(`p`,VS,[Y(`span`,HS,B(_.value.stats.filesChanged)+` `+B(_.value.stats.filesChanged===1?`file`:`files`)+` changed`,1),Y(`span`,US,`+`+B(_.value.stats.additions),1),Y(`span`,WS,`−`+B(_.value.stats.deletions),1)])):Z(``,!0),U(r).loading&&_.value?(q(),J(`span`,GS,`Loading…`)):Z(``,!0),Y(`button`,{class:z([`draft-toggle mono`,{on:U(n).prDraftOpen}]),"data-testid":`pr-draft-toggle`,"aria-pressed":U(n).prDraftOpen,title:`The PR description for this branch: your words, an agent's, and the body as sent`,onClick:o[0]||=e=>U(n).togglePrDraft()},[...o[4]||=[Y(`span`,{class:`dot`,"aria-hidden":`true`},null,-1),X(`PR draft `,-1)]],10,KS)]),Y(`div`,{class:z([`compare-main`,{"with-draft":U(n).prDraftOpen}])},[Y(`div`,qS,[U(r).error&&_.value?(q(),J(`p`,JS,B(U(r).error),1)):Z(``,!0),U(r).error&&!_.value?(q(),J(`p`,YS,B(U(r).error),1)):U(r).noBaseBranch?(q(),J(`div`,XS,[...o[5]||=[Y(`p`,{class:`state-title`},`No base branch detected.`,-1),Y(`p`,{class:`state-hint`},` Base detection uses remote refs (like origin/main) — this repo has none that qualify. Pick a base branch above to compare against. `,-1)]])):U(r).loading&&!_.value?(q(),J(`p`,ZS,` Loading compare… `)):_.value&&v.value.length===0?(q(),J(`p`,QS,` No changes`+B(b.value?` on ${b.value}`:``)+` compared to `+B(U(s).base)+`. `,1)):_.value?(q(),J(K,{key:5},[_.value.commits.length>0?(q(),J(`section`,$S,[(q(),ga(lr,{defer:``,to:`#view-toolbar-slot`,disabled:!U(ee)},[Y(`button`,{class:`commits-toggle eyebrow`,"data-testid":`commits-toggle`,"aria-expanded":d.value,onClick:o[1]||=e=>d.value=!d.value},[Y(`span`,tC,B(d.value?`▾`:`▸`),1),o[6]||=X(` Commits `,-1),Y(`span`,nC,B(_.value.commits.length),1)],8,eC)],8,[`disabled`])),d.value?(q(),J(`ul`,rC,[(q(!0),J(K,null,G(_.value.commits,e=>(q(),J(`li`,{key:e.hash,class:`commit-row`},[Y(`span`,iC,B(e.shortHash),1),Y(`span`,{class:`message`,title:e.message},B(e.message),9,aC),Y(`span`,oC,[Y(`span`,sC,B(e.author),1),Y(`span`,cC,B(O(e)),1)])]))),128))])):Z(``,!0)])):Z(``,!0),Y(`div`,{ref_key:`prBodyEl`,ref:R,class:`pr-body`,"aria-busy":U(r).loading&&!!_.value},[xa(Jy,{"data-testid":`compare-files`,files:v.value,"selected-index":k.value,portrait:U(ee),onActivate:A,onSelect:j},null,8,[`files`,`selected-index`,`portrait`]),U(ee)?(q(),ga(Rv,{key:0,split:U(te),label:`Resize file list`},null,8,[`split`])):Z(``,!0),xa(ov,ka({ref_key:`stackEl`,ref:p,class:`diffs-col`,"data-testid":`compare-diffs`,files:I.value,"active-key":L.value,syntax:U(n).diffSyntaxEnabled,mode:U(n).diffMode,wrap:U(n).wrapEnabled,"show-whole-toggle":``,"whole-key":U(t).wholeFile?.key??null,"whole-loading":U(t).wholeFileLoading,"whole-refusal":U(t).wholeFileRefusal},U(ne),{onActiveFile:M,onToggleCollapse:N,onToggleWhole:P}),null,16,[`files`,`active-key`,`syntax`,`mode`,`wrap`,`whole-key`,`whole-loading`,`whole-refusal`])],8,lC)],64)):Z(``,!0)]),U(n).prDraftOpen?(q(),ga(jS,{key:0,class:`draft-col`})):Z(``,!0)],2)],6))}}),[[`__scopeId`,`data-v-35ba9c8c`]]),dC=[`title`],fC=af(gr({__name:`ShowChangesButton`,props:{path:{}},setup(e){let t=e,n=zl(),r=Gl(),i=Q(()=>{let e=(n.shared.status?.files??[]).filter(e=>e.path===t.path);return e.length===0?null:e.find(e=>!e.staged)??e[0]});function a(){let e=i.value;if(!e)return;let t=Al(e);au({view:`changes`}),r.setActiveView(`changes`),n.selectFile(e),r.setActiveStackKey(t),r.requestStackScroll(t)}return(e,n)=>i.value?(q(),J(`button`,{key:0,class:`show-changes mono`,"data-testid":`show-changes`,title:`Show what changed in ${t.path}`,onClick:n[0]||=$(e=>a(),[`stop`])},` show changes `,8,dC)):Z(``,!0)}}),[[`__scopeId`,`data-v-786aa840`]]),pC={key:0,class:`image-view`,"data-testid":`image-view`},mC={class:`image-controls`},hC=[`aria-pressed`,`title`],gC=af(gr({__name:`ImageView`,props:{path:{},media:{}},emits:[`fail`],setup(e,{emit:t}){let n=e,r=t,i=zl(),a=V(`fit`),o=Q(()=>i.repoId===null?null:Us(i.repoId,{path:n.path,side:`worktree`,version:n.media.version}));return(t,n)=>o.value!==null&&e.media.image?(q(),J(`div`,pC,[Y(`div`,mC,[Y(`button`,{class:z([`fit-toggle mono`,{on:a.value===`actual`}]),"data-testid":`image-fit-toggle`,"aria-pressed":a.value===`actual`,"aria-label":`Show the image at its actual size`,title:a.value===`actual`?`Actual size: on. Click to shrink the image to fit`:`Actual size: off. Click to show every pixel 1:1 and scroll`,onClick:n[0]||=e=>a.value=a.value===`actual`?`fit`:`actual`},` 1:1 `,10,hC)]),xa(Sv,{src:o.value,width:e.media.image.width,height:e.media.image.height,fit:a.value,onFail:n[1]||=e=>r(`fail`)},null,8,[`src`,`width`,`height`,`fit`])])):Z(``,!0)}}),[[`__scopeId`,`data-v-94ee96d6`]]),_C={class:`file-pane`},vC={key:0,class:`pane-header mono`,"data-testid":`file-header`},yC=[`title`],bC={class:`file-meta`},xC={key:0,class:`file-lang`},SC={key:1,class:`file-lang`,"data-testid":`file-format`},CC={key:2,class:`mono`,"data-testid":`file-dimensions`},wC={key:3,"data-testid":`file-frames`},TC={key:4,class:`file-size`},EC={class:`pane-body`},DC={key:0,class:`pane-note`,"data-testid":`file-prompt`},OC={key:1,class:`pane-note pane-error mono`,"data-testid":`file-error`},kC={key:2,class:`pane-note`,"data-testid":`file-loading`},AC={key:4,class:`pane-note`,"data-testid":`file-binary`},jC={key:0,"data-testid":`image-refused`},MC={key:5,class:`pane-note`,"data-testid":`file-too-large`},NC={key:6,class:`pane-note`,"data-testid":`file-empty`},PC=[`data-ln`],FC={class:`ln code-gutter`},IC=[`innerHTML`],LC={key:0,class:`truncated-note mono`,"data-testid":`file-truncated`},RC=af(gr({__name:`FileContentPane`,props:{path:{},file:{},loading:{type:Boolean},error:{},wrap:{type:Boolean}},setup(e){let t=e,n=Q(()=>{if(t.path===null||t.file===null)return null;let{binary:e,tooLarge:n,content:r}=t.file;return e||n||r===``?null:Dg(r,t.path)}),r=Bl(),i=V(null),a=V(null),o=null;W(()=>r.lineRequest,e=>{e&&On(()=>{let t=i.value?.querySelector(`[data-ln="${e.line}"]`);t&&(t.scrollIntoView({block:`center`}),a.value=e.line,o&&clearTimeout(o),o=setTimeout(()=>{a.value=null,o=null},1200))})});let s=Q(()=>{let e=n.value?.lines.length??0;return`${Math.max(3,String(e).length)}ch`}),c=Q(()=>t.file!==null&&!t.file.binary&&!t.file.tooLarge&&t.file.content===``),l=V(!1);W(()=>[t.path,t.file],()=>{l.value=!1});let u=Q(()=>{if(l.value)return` · preview failed to decode`;let e=t.file?.media?.refusal??null,n=e===null?null:gv[e];return n===null?``:` · ${n}`}),d=Q(()=>t.file?.media?.image??null),f=Q(()=>{let e=d.value?.frames??1;return e>1?e:null});return(t,r)=>(q(),J(`div`,_C,[e.path?(q(),J(`header`,vC,[Y(`span`,{class:`file-path`,title:e.path},B(e.path),9,yC),Y(`span`,bC,[n.value?.language?(q(),J(`span`,xC,B(n.value.language),1)):Z(``,!0),d.value?(q(),J(`span`,SC,B(d.value.format),1)):Z(``,!0),d.value?(q(),J(`span`,CC,B(d.value.width)+` × `+B(d.value.height),1)):Z(``,!0),f.value?(q(),J(`span`,wC,B(f.value)+` frames`,1)):Z(``,!0),e.file?(q(),J(`span`,TC,B(U(Xl)(e.file.size)),1)):Z(``,!0),e.path?(q(),ga(fC,{key:5,path:e.path},null,8,[`path`])):Z(``,!0),xa(I_)])])):Z(``,!0),Y(`div`,EC,[e.path===null?(q(),J(`p`,DC,`Select a file`)):e.error&&e.file===null?(q(),J(`p`,OC,B(e.error),1)):e.file===null?(q(),J(`p`,kC,B(e.loading?`Loading…`:``),1)):e.file.media?.image&&!l.value?(q(),ga(gC,{key:3,path:e.path,media:e.file.media,onFail:r[0]||=e=>l.value=!0},null,8,[`path`,`media`])):e.file.binary||e.file.media?(q(),J(`p`,AC,[X(` Binary file — `+B(U(Xl)(e.file.size)),1),u.value?(q(),J(`span`,jC,B(u.value),1)):Z(``,!0)])):e.file.tooLarge?(q(),J(`p`,MC,` File too large to display (`+B(U(Xl)(e.file.size))+`) `,1)):c.value?(q(),J(`p`,NC,`Empty file`)):n.value?(q(),J(`div`,{key:7,ref_key:`scrollEl`,ref:i,class:z([`code-scroll mono`,{wrap:e.wrap}]),"data-testid":`file-content`},[Y(`div`,{class:z([`code-lines`,{stale:e.loading}]),style:le({"--ln-w":s.value})},[(q(!0),J(K,null,G(n.value.lines,(e,t)=>(q(),J(`div`,{key:t,class:z([`code-row`,{"line-flash":a.value===t+1}]),"data-ln":t+1},[Y(`span`,FC,B(t+1),1),Y(`span`,{class:`code code-cell`,innerHTML:e},null,8,IC)],10,PC))),128))],6),e.file.truncated?(q(),J(`p`,LC,` Truncated — showing the first `+B(n.value.lines.length.toLocaleString())+` of `+B(e.file.totalLines.toLocaleString())+` lines. `,1)):Z(``,!0)],2)):Z(``,!0)])]))}}),[[`__scopeId`,`data-v-19236ad9`]]),zC=5e3;function BC(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n):t}function VC(e,t){if(e.binary)return{kind:`note`,note:`Binary file — no outline.`};if(e.tooLarge)return{kind:`note`,note:`File too large to outline.`};if(t===null)return{kind:`note`,note:`Loading outline…`};if(t.status===`unavailable`)return{kind:`note`,note:`Outline unavailable for this file.`};if(t.status===`unsupported`)return t.reason===`no-script-block`?{kind:`note`,note:`No <script> block in this component.`}:{kind:`note`,note:`No outline for ${BC(e.path)} files.`};if(t.symbols.length===0)return{kind:`note`,note:`No symbols in this file.`};let n=e.truncated&&e.totalLines>zC?`Outline of the first ${zC.toLocaleString()} of ${e.totalLines.toLocaleString()} lines.`:null;return{kind:`symbols`,symbols:t.symbols,note:n}}var HC=[`value`],UC={key:0,class:`outline-note`,"data-testid":`outline-note`},WC={key:0,class:`outline-note`,"data-testid":`outline-partial`},GC={key:1,class:`outline-note`,"data-testid":`outline-no-match`},KC={key:2,class:`outline-list`,role:`listbox`,"aria-label":`Symbols`},qC=[`title`,`aria-selected`,`onMousemove`,`onClick`],JC={class:`outline-kind`},YC={class:`outline-name`},XC={key:0,class:`outline-parent`},ZC={class:`outline-line`},QC=af(gr({__name:`OutlinePopover`,setup(e,{expose:t}){let n=Bl(),{open:r,rootEl:i}=sf(),a=V(null),o=V(``),s=V(0),c=null;function l(){o.value=``,s.value=0,c=document.activeElement instanceof HTMLElement?document.activeElement:null,r.value=!0,On(()=>a.value?.focus())}W(r,e=>{if(e)return;let t=i.value?.contains(document.activeElement)??!1,n=c;c=null,t&&n?.isConnected===!0&&n.focus()}),t({openPopover:l});let u=Q(()=>n.file===null||n.selectedPath===null?{kind:`note`,note:`No file open.`}:VC({path:n.selectedPath,binary:n.file.binary,tooLarge:n.file.tooLarge,truncated:n.file.truncated,totalLines:n.file.totalLines},n.fileSymbols)),d=Q(()=>u.value.kind===`symbols`?u.value.symbols:[]),f=Q(()=>{let e=o.value.trim();if(e===``)return d.value;let t=d.value.map(e=>e.name),n=new Set(Dd(t,t.length).find(e).map(e=>e.text));return d.value.filter(e=>n.has(e.name))});W(f,()=>{s.value=0}),W(()=>n.selectedPath,()=>{r.value=!1});function p(e){n.requestLine(e.startLine),r.value=!1}function m(e){if(e.key===`ArrowDown`||e.ctrlKey&&e.key===`j`)e.preventDefault(),s.value=kd(s.value,1,f.value.length);else if(e.key===`ArrowUp`||e.ctrlKey&&e.key===`k`)e.preventDefault(),s.value=kd(s.value,-1,f.value.length);else if(e.key===`Enter`){e.preventDefault();let t=f.value[s.value];t!==void 0&&p(t)}else e.key===`Escape`&&(e.preventDefault(),r.value=!1)}return(e,t)=>U(r)?(q(),J(`div`,{key:0,ref_key:`rootEl`,ref:i,class:`outline mono`,"data-testid":`outline-popover`},[Y(`input`,{ref_key:`inputEl`,ref:a,class:`outline-input mono`,"data-testid":`outline-input`,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`filter symbols`,"aria-label":`Filter symbols`,value:o.value,onInput:t[0]||=e=>o.value=e.target.value,onKeydown:m},null,40,HC),u.value.kind===`note`?(q(),J(`p`,UC,B(u.value.note),1)):(q(),J(K,{key:1},[u.value.note?(q(),J(`p`,WC,B(u.value.note),1)):Z(``,!0),f.value.length===0?(q(),J(`p`,GC,` No symbol matches “`+B(o.value.trim())+`”. `,1)):(q(),J(`ul`,KC,[(q(!0),J(K,null,G(f.value,(e,t)=>(q(),J(`li`,{key:`${e.name}:${e.startLine}`,class:z([`outline-row`,{selected:t===s.value}]),title:e.parent?`${e.name} in ${e.parent}`:e.name,role:`option`,"aria-selected":t===s.value,onMousemove:e=>s.value=t,onClick:t=>p(e)},[Y(`span`,JC,B(e.kind),1),Y(`span`,YC,B(e.name),1),e.parent?(q(),J(`span`,XC,`in `+B(e.parent),1)):Z(``,!0),Y(`span`,ZC,B(e.startLine),1)],42,qC))),128))]))],64))],512)):Z(``,!0)}}),[[`__scopeId`,`data-v-6a76fb9b`]]),$C={class:`tree-col`},ew={class:`tree-toolbar`,role:`toolbar`,"aria-label":`Explorer filters`},tw=[`aria-pressed`,`title`],nw=[`aria-pressed`,`title`],rw=[`aria-pressed`,`title`],iw=[`disabled`],aw={class:`tree-scroll`},ow={key:0,class:`panel-note`},sw={key:1,class:`panel-note view-error`,"data-testid":`tree-error`},cw={key:2,class:`panel-note`,"data-testid":`tree-empty`},lw=[`aria-level`,`aria-expanded`,`aria-selected`,`aria-busy`,`tabindex`,`title`,`onClick`,`onKeydown`],uw={class:`chevron`,"aria-hidden":`true`},dw={key:0,class:`changes-dot`,title:`Contains changes`},fw={key:1,class:`staged-dot`,title:`Staged`},pw={key:2,class:`status-letter`,"data-testid":`status-letter`},mw={key:4,class:`panel-note view-error`,"data-testid":`tree-error`},hw=af(gr({__name:`ExplorerView`,setup(e){let t=zl(),n=Gl(),r=Bl(),i=V(null);W(()=>n.outlineRequest,e=>{e!==0&&(i.value?.openPopover(),r.loadSymbols())});let{rows:a,rootLoading:o,error:s,showHidden:c,showIgnored:l,changedOnly:u,selectedPath:d,file:f,fileLoading:p,fileError:m}=Fs(r),h=V(null);async function g(){await r.ensureRoot()}async function _(e){await r.toggleDir(e)}async function v(e){await r.openFile(e)}jr(()=>{g()}),W(()=>t.repoId,()=>{g()});function y(e){b.value=e.entry.path,au({view:`explorer`}),e.entry.type===`dir`?_(e.entry.path):v(e.entry.path)}let b=V(null),x=Q(()=>{for(let e of[b.value,d.value]){if(e===null)continue;let t=a.value.findIndex(t=>t.entry.path===e);if(t!==-1)return t}return 0});function S(e){let t=a.value[e];t&&(b.value=t.entry.path,On(()=>{h.value?.querySelectorAll(`.tree-row`)[e]?.focus()}))}function C(e){return a.value.findIndex(t=>t.entry.path===e.entry.path)}function w(e,t){let n=C(e);n!==-1&&S(Math.min(a.value.length-1,Math.max(0,n+t)))}function T(e){if(e.entry.type!==`dir`)return;if(!e.isExpanded){_(e.entry.path);return}let t=C(e);if(t===-1)return;let n=a.value[t+1];n&&n.depth>e.depth&&S(t+1)}function E(e){if(e.entry.type===`dir`&&e.isExpanded){r.collapseDir(e.entry.path);return}let t=e.entry.path;for(let e=t.lastIndexOf(`/`);e!==-1;e=t.lastIndexOf(`/`)){t=t.slice(0,e);let n=a.value.findIndex(e=>e.entry.path===t);if(n!==-1){S(n);return}}}W(()=>a.value,()=>{let e=h.value?.contains(document.activeElement)??!1;On(()=>{let t=h.value;if(!e||!t||t.contains(document.activeElement))return;let n=x.value,r=a.value[n];r&&(b.value=r.entry.path,t.querySelectorAll(`.tree-row`)[n]?.focus())})}),W(d,()=>{On(()=>{h.value?.querySelector(`.tree-row.selected`)?.scrollIntoView({block:`nearest`})})});function D(e){return e.entry.gitStatus?`st-${e.entry.gitStatus}`:null}let O=bu(),k=V(null),A=Um({container:k,isRow:O,row:{pref:`explorerTop`,defaultRatio:.34,min:ml,max:hl}}),j=V(null),M=qm(O,j,`File content`),N=Gm(O,(e,t)=>w(t,e));return(e,t)=>(q(),J(`div`,{ref_key:`containerEl`,ref:k,class:z([`explorer`,{portrait:U(O)}]),style:le(U(O)?{"--explorer-top":`${(U(A).rowRatio.value*100).toFixed(2)}%`}:void 0)},[Y(`aside`,$C,[(q(),ga(lr,{defer:``,to:`#view-toolbar-slot`,disabled:!U(O)},[Y(`div`,ew,[Y(`button`,{class:`tool-toggle mono`,"data-testid":`toggle-hidden`,"aria-pressed":U(c),title:U(c)?`Dotfiles are shown. Click to hide them`:`Dotfiles are hidden. Click to show them`,onClick:t[0]||=e=>U(r).setShowHidden(!U(c))},` dotfiles `,8,tw),Y(`button`,{class:`tool-toggle mono`,"data-testid":`toggle-ignored`,"aria-pressed":U(l),title:U(l)?`Gitignored files are shown. Click to hide them`:`Gitignored files are hidden. Click to show them`,onClick:t[1]||=e=>U(r).setShowIgnored(!U(l))},` ignored `,8,nw),Y(`button`,{class:`tool-toggle mono`,"data-testid":`toggle-changed`,"aria-pressed":U(u),title:U(u)?`Showing only files with changes. Click to show every file`:`Showing every file. Click to show only files with changes`,onClick:t[2]||=e=>U(r).setChangedOnly(!U(u))},` changed `,8,rw),Y(`button`,{class:`tool-refresh mono`,"data-testid":`tree-refresh`,"aria-label":`Reload the tree`,title:`Reload the tree`,disabled:U(o),onClick:t[3]||=e=>U(r).refresh()},` ↻ `,8,iw)])],8,[`disabled`])),Y(`div`,aw,[U(o)&&U(a).length===0?(q(),J(`p`,ow,`Loading tree…`)):U(s)&&U(a).length===0?(q(),J(`p`,sw,B(U(s)),1)):U(a).length===0?(q(),J(`p`,cw,B(U(u)?`No changed files.`:`Empty repository.`),1)):(q(),J(`div`,{key:3,ref_key:`treeEl`,ref:h,class:`tree mono`,role:`tree`,"aria-label":`Repository files`},[(q(!0),J(K,null,G(U(a),(e,n)=>(q(),J(K,{key:e.entry.path},[Y(`div`,{class:z([`tree-row list-row`,[D(e),{selected:e.entry.path===U(d)}]]),role:`treeitem`,"aria-level":e.depth+1,"aria-expanded":e.entry.type===`dir`?e.isExpanded:void 0,"aria-selected":e.entry.path===U(d),"aria-busy":e.isLoading||void 0,tabindex:n===x.value?0:-1,title:e.entry.path,onClick:t=>y(e),onKeydown:[Xo($(t=>w(e,1),[`prevent`]),[`down`]),Xo($(t=>w(e,-1),[`prevent`]),[`up`]),Xo($(t=>T(e),[`prevent`]),[`right`]),Xo($(t=>E(e),[`prevent`]),[`left`]),Xo($(t=>y(e),[`prevent`]),[`enter`]),Xo($(t=>y(e),[`prevent`]),[`space`]),t[4]||=Xo($(e=>S(0),[`prevent`]),[`home`]),t[5]||=Xo($(e=>S(U(a).length-1),[`prevent`]),[`end`]),t=>U(N)(t,e)]},[(q(!0),J(K,null,G(e.depth,e=>(q(),J(`span`,{key:e,class:`guide`,"aria-hidden":`true`}))),128)),Y(`span`,uw,B(e.entry.type===`dir`?e.isExpanded?`▾`:`▸`:``),1),Y(`span`,{class:z([`name`,{dir:e.entry.type===`dir`}])},B(e.displayName),3),e.entry.type===`dir`&&e.entry.hasChanges?(q(),J(`span`,dw,`●`)):Z(``,!0),e.entry.type===`file`&&e.entry.staged?(q(),J(`span`,fw,`●`)):Z(``,!0),e.entry.type===`file`&&e.entry.gitStatus?(q(),J(`span`,pw,B(U(Zl)(e.entry.gitStatus)),1)):Z(``,!0)],42,lw),e.isExpanded&&e.isLoading?(q(),J(`div`,{key:0,class:`tree-loading mono`,role:`presentation`,"data-testid":`dir-loading`,style:le({paddingLeft:`${(e.depth+1)*1.25+1.75}ch`})},` Loading… `,4)):Z(``,!0)],64))),128))],512)),U(s)&&U(a).length>0?(q(),J(`p`,mw,B(U(s)),1)):Z(``,!0)])]),U(O)?(q(),ga(Rv,{key:0,split:U(A),label:`Resize file tree`},null,8,[`split`])):Z(``,!0),Y(`section`,ka({ref_key:`payloadEl`,ref:j,class:`content-col`},U(M)),[xa(QC,{ref_key:`outlineEl`,ref:i},null,512),xa(RC,{path:U(d),file:U(f),loading:U(p),error:U(m),wrap:U(n).wrapEnabled},null,8,[`path`,`file`,`loading`,`error`,`wrap`])],16)],6))}}),[[`__scopeId`,`data-v-48316821`]]),gw=`pr:`;function _w(e,t){return`${e}\n${t}`}function vw(e){return`${gw}${e.repo}#${e.number}`}function yw(e){let t=e.lastIndexOf(`
|
|
21
|
-
`);return t===-1?null:{root:e.slice(0,t),branch:e.slice(t+1)}}function bw(e,t,n){return e.find(e=>e.headRefName===n&&t.includes(e.repoKey))??null}function xw(e){if(e.state===`open`)return null;let t=Date.parse(e.mergedAt??e.closedAt??``);return Number.isNaN(t)?null:t}function Sw(e,t){if(e.state===`open`)return!0;let n=xw(e);return n!==null&&t-n<=6048e5}function Cw(e){return e.status===`ok`&&!e.capped}function ww(e,t){let n=xw(e);return n!==null&&t-n>6048e5}function Tw(e,t,n){return(t?.tip??n?.head??null)===e.headRefOid}function Ew(e){let t=Date.parse(e);return Number.isNaN(t)?null:t}function Dw(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(t+1)}function Ow(e){return e.branch===null?!1:e.base===null?!e.isMain:e.branch!==Dw(e.base)}function kw(e){return e!==null&&e.top!==null&&e.top.trim()!==``}function Aw(e,t){if(t!==null){if(t.state!==`open`)return t.state;if(t.isDraft)return`draft`;let e=t.progress?.decision??null;return e===`changes-requested`?`changes`:e===`approved`?`approved`:`review`}return e===`branch-gone`?`gone`:e===`pushed-no-pr`?`pushed`:`local`}function jw(e){let t=e.filter(e=>e.state===`open`),n=new Map;for(let e of t){let t=`${e.repoKey}\n${e.headRefName}`;n.has(t)||n.set(t,e)}let r=e=>n.get(`${e.repoKey}\n${e.baseRefName}`)??null,i=new Map,a=new Map;for(let e of t){let t=new Set([e]),n=e;for(let e=r(n);e!==null&&!t.has(e);e=r(n))t.add(e),n=e;i.set(e,{depth:t.size,root:n}),a.set(n,(a.get(n)??0)+1)}let o=new Map;for(let[e,{depth:t,root:n}]of i){let r=a.get(n)??1;r>1&&o.set(e,{position:t,size:r,root:n.headRefName})}return o}function Mw(e,t){if(e===null||e.state!==`open`)return[];let n=[],r=e.progress;return t!==null&&e.author===t&&r!==null&&r.decision===`changes-requested`&&r.changesRequestedBy.some(e=>!r.requestedReviewers.includes(e))&&n.push(`changes-requested`),e.reviewRequested&&n.push(`review-requested`),n}function Nw(e,t,n){let r=[],i=(e,t)=>{e!==null&&r.push({at:e,kind:t,author:null,other:!1})};i(e.edited,`edited`),i(e.git,`git`),i(e.draft,`draft`);let a=t?.state===`open`?Ew(t.progress?.headCommittedAt??``):null;t!==null&&a!==null&&r.push({at:a,kind:`head-commit`,author:t.author,other:n!==null&&t.author!==null&&t.author!==n});let o=t?.progress?.events[0],s=o===void 0?null:Ew(o.at);o!==void 0&&s!==null&&r.push({at:s,kind:o.kind,author:o.author,other:n!==null&&o.author!==n});let c=t===null?null:xw(t);t!==null&&t.state!==`open`&&c!==null&&r.push({at:c,kind:t.state,author:null,other:!1});let l=null;for(let e of r)(l===null||e.at>l.at)&&(l=e);return l}function Pw(e){let t=null;for(let n of e.worktrees)if(!n.isBare){if(n.isMain)return n;(t===null||(n.lastActivity??-1/0)>(t.lastActivity??-1/0))&&(t=n)}return t}function Fw(e){let t=kw(e.draft)?e.draft?.top??``:null;return{uncommitted:e.worktree?.uncommitted??0,unpushed:e.branchFact?.unpushed??0,ahead:e.worktree?.aheadOfBase??0,base:e.worktree?.base??null,draft:t!==null,placeholders:t===null?0:Vb(t),adoptedUnedited:t!==null&&(e.draft?.adoptedUnedited??!1),bodyDiffers:t!==null&&e.pr?.state===`open`&&e.pr.body!==null&&Jb(e.pr.body,t)}}function Iw(e,t){return e.pr!==null&&!e.leftover?e.pr.state===`open`?`work`:`done`:t.draft||e.tracked?`work`:e.worktree===null?null:t.uncommitted>0||t.ahead>0||e.kind===`branch`&&(t.unpushed>0||Ow(e.worktree))?`candidates`:null}function Lw(e){return e.state===`open`?e.isDraft?`pr-draft`:`pr-open`:e.state}function Rw(e,t){if(e.pr!==null)return Lw(e.pr);if(e.gone)return`branch-gone`;let n=e.branchFact?.remoteCopy??!1;return n&&t.unpushed===0?`pushed-no-pr`:t.unpushed>0||!n&&(t.ahead>0||e.worktree===null)?`not-pushed`:t.uncommitted>0?`uncommitted`:`empty`}function zw(e){if(e.worktree!==null)return{path:e.worktree.path,head:null};if(e.gone||e.branch===null)return null;let t=Pw(e.repo);return t===null?null:{path:t.path,head:e.branch}}function Bw(e,t){let n=+(t.uncommitted>0);return e.kind===`detached`?`${e.worktree?.head??``}|${n}`:`${e.branchFact?.tip??e.worktree?.head??``}|${n}|${e.draft?.mtime??0}`}function Vw(e,t){let n=Fw(e),r=Iw(e,n);if(r===null)return null;let i=Rw(e,n),a={edited:e.worktree?.changedAt??null,git:e.worktree?.lastActivity??null,draft:e.draft?.mtime??null},o=Nw(a,e.pr,t.viewer);return{key:e.key,kind:e.kind,section:r,repoRoot:e.repo.root,repoName:e.repo.name,worktreePath:e.worktree?.path??null,branch:e.branch,state:i,facts:n,pr:e.pr,note:r===`done`&&e.worktree!==null?`worktree-on-disk`:null,open:zw(e),stage:Aw(i,e.pr),stack:e.pr===null?null:t.stacks.get(e.pr)??null,attention:Mw(e.pr,t.viewer),lastActivity:o,times:a,activity:o?.at??null,fingerprint:Bw(e,n),tracked:e.tracked}}function Hw(e,t){let{shown:n,marks:r}=t,i=new Set;for(let t of e.worktrees)!t.isBare&&t.branch!==null&&i.add(t.branch);for(let t of e.drafts)i.add(t.branch);for(let t of e.branches)bw(n,e.identities,t.name)!==null&&i.add(t.name);for(let t of Object.keys(r.tracked)){let n=yw(t);n!==null&&n.root===e.root&&i.add(n.branch)}return i}function Uw(e,t,n){let{repo:r}=e,{marks:i,now:a}=n,o=_w(r.root,t),s=e.worktrees.find(e=>e.branch===t)??null,c=e.branches.get(t)??null,l=c===null&&s===null&&!r.branchesCapped,u=bw(n.prs,r.identities,t),d=u!==null&&ww(u,a)&&(l||Tw(u,c,s)),f=s===null||s.uncommitted===0;if(d&&f&&n.canFinish)return null;let p=d&&(s?.uncommitted??0)>0;return Vw({key:o,kind:`branch`,repo:r,worktree:s,branch:t,branchFact:c,draft:e.drafts.get(t)??null,pr:u!==null&&(Sw(u,a)||p)?u:null,leftover:p,gone:l,tracked:i.tracked[o]!==void 0},n)}function Ww(e,t){let{marks:n}=t,r=e.worktrees.filter(e=>!e.isBare),i={repo:e,worktrees:r,branches:new Map(e.branches.map(e=>[e.name,e])),drafts:new Map(e.drafts.map(e=>[e.branch,e]))},a=[];for(let n of Hw(e,t)){let e=Uw(i,n,t);e!==null&&a.push(e)}for(let i of r){if(i.branch!==null)continue;let r=Vw({key:i.path,kind:`detached`,repo:e,worktree:i,branch:null,branchFact:null,draft:null,pr:null,leftover:!1,gone:!1,tracked:n.tracked[i.path]!==void 0},t);r!==null&&a.push(r)}return a}var Gw={uncommitted:0,unpushed:0,ahead:0,base:null,draft:!1,placeholders:0,adoptedUnedited:!1,bodyDiffers:!1},Kw={edited:null,git:null,draft:null};function qw(e,t){return e.state===`open`?e.reviewRequested&&!t?`candidates`:`work`:`done`}function Jw(e,t,n){let{marks:r}=n,i=vw(e),a=r.tracked[i]!==void 0,o=Lw(e),s=Nw(Kw,e,n.viewer),c=t.find(t=>t.identities.includes(e.repoKey))??null;return{key:i,kind:`pr`,section:qw(e,a),repoRoot:c?.root??null,repoName:c?.name??e.repo,worktreePath:null,branch:e.headRefName,state:o,facts:{...Gw},pr:e,note:c===null?`no-local-clone`:`no-local-branch`,open:null,stage:Aw(o,e),stack:n.stacks.get(e)??null,attention:Mw(e,n.viewer),lastActivity:s,times:{...Kw},activity:s?.at??null,fingerprint:e.updatedAt,tracked:a}}function Yw(e,t){return e.key===t.key?0:e.key<t.key?-1:1}function Xw(e,t){return e.activity===t.activity?Yw(e,t):e.activity===null?1:t.activity===null?-1:t.activity-e.activity}function Zw(e,t){return e.activity!==null&&t-e.activity<=12096e5}function Qw(e,t){let n=e.pr===null?null:xw(e.pr),r=t.pr===null?null:xw(t.pr);return n===r?Yw(e,t):n===null?1:r===null?-1:r-n}function $w(e,t,n){let r=new Set(t.map(e=>e.key)),i=Cw(n),a=new Set;for(let t of[...Object.keys(e.tracked),...Object.keys(e.dismissed)])r.has(t)||(i||!t.startsWith(gw))&&a.add(t);return[...a].sort()}function eT(e,t,n,r,i=!1){let a=new Set,o=e.filter(e=>!a.has(e.root)&&(a.add(e.root),!0)),s=t.prs.filter(e=>!e.reviewRequested),c={prs:s,shown:s.filter(e=>Sw(e,r)),marks:n,now:r,canFinish:Cw(t),viewer:t.viewer,stacks:jw(t.prs)},l=o.flatMap(e=>Ww(e,c)),u=new Set(l.map(e=>e.pr).filter(e=>e!==null));for(let e of c.shown)u.has(e)||l.push(Jw(e,o,c));for(let e of t.prs)e.reviewRequested&&e.state===`open`&&l.push(Jw(e,o,c));let d={work:[],candidates:[],older:[],done:[],dismissed:[],staleMarks:i?$w(n,l,t):[]};for(let e of l)n.dismissed[e.key]?.fingerprint===e.fingerprint?d.dismissed.push(e):e.section===`candidates`&&!Zw(e,r)&&e.attention.length===0?d.older.push(e):d[e.section].push(e);return d.work.sort(Xw),d.candidates.sort(Xw),d.older.sort(Xw),d.dismissed.sort(Xw),d.done.sort(Qw),d}var tT=3e5,nT={status:`never`,message:null,checkedAt:null,viewer:null,prs:[],capped:!1};async function rT(e,t,n){let r=0;async function i(){for(;r<e.length;){let t=e[r];r+=1,await n(t)}}await Promise.all(Array.from({length:Math.min(t,e.length)},i))}function iT(e){return e.roots.flatMap(e=>e.error===null?e.capped?[{path:e.path,message:`more repos than listed`}]:[]:[{path:e.path,message:e.error}])}function aT(e,t){let n=e.findIndex(e=>e.root===t.root);if(n===-1)return[...e,t];let r=[...e];return r[n]=t,r}var oT=Ps(`work`,()=>{let e=new Xs,t=H([]),n=H({total:0,done:0,running:!1}),r=H(!1),i=H([]),a=H([]),o=H(!1),s=H(null),c=H(!1),l=H({tracked:{},dismissed:{}}),u=H(null),d=H(Date.now()),f=H(null),p=0,m=Q(()=>r.value&&o.value&&i.value.length===0&&!c.value&&s.value!==null&&s.value.checkedAt!==null),h=Q(()=>eT(t.value,s.value??nT,l.value,d.value,m.value));function g(e,t,n){Zs(e,t),u.value=`${n}: ${Rs(t)}`}async function _(){try{l.value=await e.workMarks()}catch(e){g(`load Work marks`,e,`Could not load marks`)}}function v(e){return e===null||e.status===`never`||e.checkedAt===null||Date.now()-e.checkedAt>tT}async function y(){c.value=!0;try{let t=await e.workPrs();s.value=t,v(t)&&(s.value=await e.refreshWorkPrs())}catch(e){g(`load PRs`,e,`Could not load PRs`)}finally{c.value=!1}}async function b(){c.value=!0;try{s.value=await e.refreshWorkPrs()}catch(e){g(`check PRs`,e,`Could not check PRs`)}finally{c.value=!1}}async function x(r,a,o){try{let n=await e.workRepo(r);if(a!==p||o.has(n.root))return;o.set(n.root,n),t.value=aT(t.value,n)}catch(e){if(a!==p)return;Qs(`scan repo for the Work page`,e,{path:r}),i.value=[...i.value,{path:r,message:Rs(e)}]}finally{a===p&&(n.value={...n.value,done:n.value.done+1})}}async function S(){p+=1;let s=p;r.value=!1,i.value=[],a.value=[],o.value=!1,n.value={total:0,done:0,running:!0};let c,l;try{let[t,n]=await Promise.all([e.discovered(),e.listRepos()]);c=t,l=n.map(e=>e.path)}catch(e){if(s!==p)return;g(`list repos for the Work page`,e,`Could not list repos`),n.value={...n.value,running:!1};return}if(s!==p)return;a.value=iT(c),o.value=c.roots.every(e=>e.error===null&&!e.capped&&e.repos.length>0);let u=[...new Set(c.roots.flatMap(e=>e.repos.map(e=>e.path)))],d=new Map;if(n.value={total:u.length,done:0,running:!0},await rT(u,4,e=>x(e,s,d)),s!==p)return;let m=new Set(u);for(let e of d.values())for(let t of e.worktrees)m.add(t.path);let h=[...new Set(l)].filter(e=>!m.has(e));n.value={...n.value,total:u.length+h.length},await rT(h,4,e=>x(e,s,d)),s===p&&(t.value=[...d.values()],n.value={...n.value,running:!1},r.value=!0,f.value=Date.now())}async function C(){d.value=Date.now(),u.value=null,await Promise.all([_(),y(),S()])}async function w(){let e=Date.now(),t=!n.value.running&&(f.value===null||e-f.value>6e4),r=!c.value&&v(s.value);(t||r)&&(d.value=e,await Promise.all([r?b():null,t?S():null]))}async function T(){d.value=Date.now(),u.value=null,await Promise.all([b(),S()])}async function E(t,n,r){let i=h.value.staleMarks.filter(e=>e!==t),a={key:t,action:n};r!==void 0&&(a.fingerprint=r),i.length>0&&(a.prune=i);try{l.value=await e.putWorkMark(a)}catch(e){g(`save a Work mark`,e,`Could not save`)}}return{repos:t,scan:n,scanFinished:r,repoErrors:i,rootErrors:a,prs:s,prsLoading:c,marks:l,error:u,now:d,scannedAt:f,complete:m,classification:h,load:C,catchUp:w,refresh:T,runScan:S,mark:E}}),sT=[`data-icon`],cT=[`d`],lT=af(gr({__name:`WorkIcon`,props:{name:{}},setup(e){let t={stack:`M2.5 5.5 8 2.5l5.5 3L8 8.5ZM2.5 8.5 8 11.5l5.5-3M2.5 11 8 14l5.5-3`,check:`m3 8.5 3 3 7-7`,cross:`m4 4 8 8m0-8-8 8`,pending:`M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z`,comment:`M2.5 3.5h11v7.5h-6l-3 2.5V11h-2Z`,approved:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Zm-2.75 6.25 1.75 1.75 3.75-3.75`,changes:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2ZM8 5v4.5M5.75 7.25h4.5M5.75 11h4.5`,waiting:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Zm0 3v3.25l2 1.25`,pencil:`m10.5 2.5 3 3-8 8h-3v-3Z`,compare:`M2.5 5.5h10L10 3M13.5 10.5h-10L6 13`,chevron:`m6 3.5 4.5 4.5L6 12.5`,differs:`M3 6h10M3 10h10m-2.5-7-5 10`,alert:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2ZM8 5v3.75m0 2.25v.25`,copy:`M5.5 5.5h7.5v8H5.5ZM3 10.5v-8h7.5`},n=e,r=Q(()=>t[n.name]);return(t,n)=>(q(),J(`svg`,{class:`work-icon`,viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,"data-icon":e.name},[Y(`path`,{d:r.value},null,8,cT)],8,sT))}}),[[`__scopeId`,`data-v-a1673a3c`]]),uT={key:0,class:`view-error`,"data-testid":`work-draft-error`},dT={key:2,class:`loading`},fT=af(gr({__name:`WorkDraftEditor`,props:{path:{},branch:{}},setup(e){let t=e,n=new Xs,r=H(null),i=H(null),a=Zb(()=>r.value===null?null:{id:r.value,branch:t.branch}),o=!1;return jr(async()=>{try{let e=await n.openRepo(t.path);if(o){await n.closeRepo(e.id);return}r.value=e.id}catch(e){Zs(`open a repo for its PR draft`,e,{path:t.path}),i.value=`Could not open the repo: ${Rs(e)}`}}),Fr(()=>{o=!0;let e=r.value;(async()=>{if(await a.dispose(),e!==null)try{await n.closeRepo(e)}catch(e){Zs(`release a repo after its PR draft`,e,{path:t.path})}})()}),(e,t)=>i.value?(q(),J(`p`,uT,B(i.value),1)):r.value?(q(),ga(jS,{key:1,session:U(a)},null,8,[`session`])):(q(),J(`p`,dT,`Opening the draft…`))}}),[[`__scopeId`,`data-v-f26ea9b4`]]),pT=1500;function mT(){let e=H(null),t=null;function n(n){e.value=n,t!==null&&clearTimeout(t),t=setTimeout(()=>e.value=null,pT)}async function r(e){try{await navigator.clipboard.writeText(e),n(`copied`)}catch(e){Zs(`copy to the clipboard`,e),n(`failed`)}}return Fr(()=>{t!==null&&clearTimeout(t)}),{state:e,copy:r}}var hT={class:`block events`},gT={key:0,class:`none`},_T={key:1,class:`event-list`},vT=[`data-tip`],yT={class:`text`},bT={class:`block facts`},xT={class:`fact-list`},ST=[`data-tip`],CT={class:`actions`},wT=[`href`],TT={key:0,class:`block draft`},ET=8,DT=af(gr({__name:`WorkRowDetail`,props:{item:{},now:{},dismissed:{type:Boolean}},emits:[`open`,`mark`],setup(e,{emit:t}){let n=e,r=t,i=oT(),a=Q(()=>yx(n.item,i.prs?.viewer??null).slice(0,ET)),o=Q(()=>Sx(n.item)),s=Q(()=>Dx(n.item)),{state:c,copy:l}=mT(),u=Q(()=>c.value===`copied`?`Copied`:c.value===`failed`?`Could not copy`:`Copy for a session`),d=Q(()=>{let{item:e}=n;return e.kind!==`branch`||e.branch===null||e.open===null?null:{path:e.open.path,branch:e.branch}});return(t,n)=>(q(),J(`div`,{class:`detail`,"data-testid":`work-detail`,onClick:n[5]||=$(()=>{},[`stop`])},[Y(`section`,hT,[n[6]||=Y(`h3`,{class:`eyebrow`},`Activity`,-1),a.value.length===0?(q(),J(`p`,gT,`Nothing recorded.`)):(q(),J(`ol`,_T,[(q(!0),J(K,null,G(a.value,(t,n)=>(q(),J(`li`,{key:n,class:z([`event`,{other:t.other}])},[Y(`span`,{class:`at`,"data-tip":U(ux)(t.at)},B(U(lx)(t.at,e.now)),9,vT),Y(`span`,yT,B(t.text),1)],2))),128))]))]),Y(`section`,bT,[n[7]||=Y(`h3`,{class:`eyebrow`},`Facts`,-1),(q(!0),J(K,null,G(s.value,e=>(q(),J(`p`,{key:e,class:`wants`,"data-testid":`work-detail-attention`},B(e),1))),128)),Y(`dl`,xT,[(q(!0),J(K,null,G(o.value,([e,t])=>(q(),J(K,{key:e},[Y(`dt`,null,B(e),1),Y(`dd`,{"data-tip":t},B(t),9,ST)],64))),128))]),Y(`div`,CT,[e.item.open?(q(),J(`button`,{key:0,class:`action`,onClick:n[0]||=e=>r(`open`)},`Open in Compare`)):Z(``,!0),Y(`button`,{class:`action`,"data-testid":`work-detail-copy`,"data-tip":`The PR, repo, local clone and branch, to paste into a session`,onClick:n[1]||=t=>U(l)(U(Ox)(e.item))},B(u.value),1),e.item.pr?(q(),J(`a`,{key:1,class:`action`,href:e.item.pr.url,target:`_blank`,rel:`noopener noreferrer`},`Open #`+B(e.item.pr.number)+` on GitHub`,9,wT)):Z(``,!0),e.item.tracked?(q(),J(`button`,{key:2,class:`action`,"data-testid":`work-drop`,onClick:n[2]||=e=>r(`mark`,`drop`)},` Stop tracking `)):Z(``,!0),e.dismissed?(q(),J(`button`,{key:3,class:`action`,"data-testid":`work-detail-undismiss`,onClick:n[3]||=e=>r(`mark`,`undismiss`)},` Show again `)):(q(),J(`button`,{key:4,class:`action`,"data-testid":`work-dismiss`,"data-tip":`Hide this until something about it changes`,onClick:n[4]||=e=>r(`mark`,`dismiss`)},` Dismiss `))])]),d.value?(q(),J(`section`,TT,[xa(fT,{path:d.value.path,branch:d.value.branch},null,8,[`path`,`branch`])])):Z(``,!0)]))}}),[[`__scopeId`,`data-v-d98ae195`]]),OT=[`data-stage`],kT=[`data-tip`],AT={class:`pips`,"aria-hidden":`true`},jT={class:`sr-only`},MT=[`data-tip`,`aria-label`],NT=[`data-tip`],PT={class:`branch mono`},FT=[`data-tip`],IT={key:1,class:`by`,"data-testid":`work-by`},LT={key:2,class:`pr-title`},RT=[`data-tip`],zT={class:`mono`},BT={class:`cell pr`},VT=[`href`,`data-tip`],HT=[`data-tip`],UT={key:1,class:`threads`},WT={class:`mono`},GT=[`data-tip`],KT={class:`cell local mono`,"data-testid":`work-local`},qT=[`data-tip`],JT=[`data-tip`],YT=[`data-tip`],XT=[`data-tip`],ZT={key:1,class:`placeholders mono`},QT=[`data-tip`],$T=[`data-tip`],eE={class:`cell act`},tE=[`data-tip`],nE=[`data-tip`,`aria-label`],rE=[`aria-expanded`,`aria-label`],iE=af(gr({__name:`WorkRow`,props:{item:{},now:{},dismissed:{type:Boolean}},emits:[`open`,`mark`],setup(e,{emit:t}){let n=e,r=t,i=V(!1);function a(){i.value=!i.value}let o=Q(()=>mx[n.item.stage]),s=oT(),c=Q(()=>Ex(n.item,s.prs?.viewer??null)),l=Q(()=>{let e=n.item.lastActivity;return e===null?void 0:`${vx(e)}\n${ux(e.at)}`}),u=Q(()=>Dx(n.item).join(`
|
|
21
|
+
`);return t===-1?null:{root:e.slice(0,t),branch:e.slice(t+1)}}function bw(e,t,n){return e.find(e=>e.headRefName===n&&t.includes(e.repoKey))??null}function xw(e){if(e.state===`open`)return null;let t=Date.parse(e.mergedAt??e.closedAt??``);return Number.isNaN(t)?null:t}function Sw(e,t){if(e.state===`open`)return!0;let n=xw(e);return n!==null&&t-n<=6048e5}function Cw(e){return e.status===`ok`&&!e.capped}function ww(e,t){let n=xw(e);return n!==null&&t-n>6048e5}function Tw(e,t,n){return(t?.tip??n?.head??null)===e.headRefOid}function Ew(e){let t=Date.parse(e);return Number.isNaN(t)?null:t}function Dw(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(t+1)}function Ow(e){return e.branch===null?!1:e.base===null?!e.isMain:e.branch!==Dw(e.base)}function kw(e){return e!==null&&e.top!==null&&e.top.trim()!==``}function Aw(e){return kw(e)||e?.hasSuggested===!0||e?.hasAi===!0}function jw(e,t){if(t!==null){if(t.state!==`open`)return t.state;if(t.isDraft)return`draft`;let e=t.progress?.decision??null;return e===`changes-requested`?`changes`:e===`approved`?`approved`:`review`}return e===`branch-gone`?`gone`:e===`pushed-no-pr`?`pushed`:`local`}function Mw(e){let t=e.filter(e=>e.state===`open`),n=new Map;for(let e of t){let t=`${e.repoKey}\n${e.headRefName}`;n.has(t)||n.set(t,e)}let r=e=>n.get(`${e.repoKey}\n${e.baseRefName}`)??null,i=new Map,a=new Map;for(let e of t){let t=new Set([e]),n=e;for(let e=r(n);e!==null&&!t.has(e);e=r(n))t.add(e),n=e;i.set(e,{depth:t.size,root:n}),a.set(n,(a.get(n)??0)+1)}let o=new Map;for(let[e,{depth:t,root:n}]of i){let r=a.get(n)??1;r>1&&o.set(e,{position:t,size:r,root:n.headRefName})}return o}function Nw(e,t){if(e===null||e.state!==`open`)return[];let n=[],r=e.progress;return t!==null&&e.author===t&&r!==null&&r.decision===`changes-requested`&&r.changesRequestedBy.some(e=>!r.requestedReviewers.includes(e))&&n.push(`changes-requested`),e.reviewRequested&&n.push(`review-requested`),n}function Pw(e,t,n){let r=[],i=(e,t)=>{e!==null&&r.push({at:e,kind:t,author:null,other:!1})};i(e.edited,`edited`),i(e.git,`git`),i(e.draft,`draft`);let a=t?.state===`open`?Ew(t.progress?.headCommittedAt??``):null;t!==null&&a!==null&&r.push({at:a,kind:`head-commit`,author:t.author,other:n!==null&&t.author!==null&&t.author!==n});let o=t?.progress?.events[0],s=o===void 0?null:Ew(o.at);o!==void 0&&s!==null&&r.push({at:s,kind:o.kind,author:o.author,other:n!==null&&o.author!==n});let c=t===null?null:xw(t);t!==null&&t.state!==`open`&&c!==null&&r.push({at:c,kind:t.state,author:null,other:!1});let l=null;for(let e of r)(l===null||e.at>l.at)&&(l=e);return l}function Fw(e){let t=null;for(let n of e.worktrees)if(!n.isBare){if(n.isMain)return n;(t===null||(n.lastActivity??-1/0)>(t.lastActivity??-1/0))&&(t=n)}return t}function Iw(e){let t=kw(e.draft)?e.draft?.top??``:null;return{uncommitted:e.worktree?.uncommitted??0,unpushed:e.branchFact?.unpushed??0,ahead:e.worktree?.aheadOfBase??0,base:e.worktree?.base??null,draft:t!==null,placeholders:t===null?0:Vb(t),adoptedUnedited:t!==null&&(e.draft?.adoptedUnedited??!1),bodyDiffers:t!==null&&e.pr?.state===`open`&&e.pr.body!==null&&Jb(e.pr.body,t)}}function Lw(e,t){return e.pr!==null&&!e.leftover?e.pr.state===`open`?`work`:`done`:Aw(e.draft)||e.tracked?`work`:e.worktree===null?null:t.uncommitted>0||t.ahead>0||e.kind===`branch`&&(t.unpushed>0||Ow(e.worktree))?`candidates`:null}function Rw(e){return e.state===`open`?e.isDraft?`pr-draft`:`pr-open`:e.state}function zw(e,t){if(e.pr!==null)return Rw(e.pr);if(e.gone)return`branch-gone`;let n=e.branchFact?.remoteCopy??!1;return n&&t.unpushed===0?`pushed-no-pr`:t.unpushed>0||!n&&(t.ahead>0||e.worktree===null)?`not-pushed`:t.uncommitted>0?`uncommitted`:`empty`}function Bw(e){if(e.worktree!==null)return{path:e.worktree.path,head:null};if(e.gone||e.branch===null)return null;let t=Fw(e.repo);return t===null?null:{path:t.path,head:e.branch}}function Vw(e,t){let n=+(t.uncommitted>0);return e.kind===`detached`?`${e.worktree?.head??``}|${n}`:`${e.branchFact?.tip??e.worktree?.head??``}|${n}|${e.draft?.mtime??0}`}function Hw(e,t){let n=Iw(e),r=Lw(e,n);if(r===null)return null;let i=zw(e,n),a={edited:e.worktree?.changedAt??null,git:e.worktree?.lastActivity??null,draft:e.draft?.mtime??null},o=Pw(a,e.pr,t.viewer);return{key:e.key,kind:e.kind,section:r,repoRoot:e.repo.root,repoName:e.repo.name,worktreePath:e.worktree?.path??null,branch:e.branch,state:i,facts:n,pr:e.pr,note:r===`done`&&e.worktree!==null?`worktree-on-disk`:null,open:Bw(e),stage:jw(i,e.pr),stack:e.pr===null?null:t.stacks.get(e.pr)??null,attention:Nw(e.pr,t.viewer),lastActivity:o,times:a,activity:o?.at??null,fingerprint:Vw(e,n),tracked:e.tracked}}function Uw(e,t){let{shown:n,marks:r}=t,i=new Set;for(let t of e.worktrees)!t.isBare&&t.branch!==null&&i.add(t.branch);for(let t of e.drafts)i.add(t.branch);for(let t of e.branches)bw(n,e.identities,t.name)!==null&&i.add(t.name);for(let t of Object.keys(r.tracked)){let n=yw(t);n!==null&&n.root===e.root&&i.add(n.branch)}return i}function Ww(e,t,n){let{repo:r}=e,{marks:i,now:a}=n,o=_w(r.root,t),s=e.worktrees.find(e=>e.branch===t)??null,c=e.branches.get(t)??null,l=c===null&&s===null&&!r.branchesCapped,u=bw(n.prs,r.identities,t),d=u!==null&&ww(u,a)&&(l||Tw(u,c,s)),f=s===null||s.uncommitted===0;if(d&&f&&n.canFinish)return null;let p=d&&(s?.uncommitted??0)>0;return Hw({key:o,kind:`branch`,repo:r,worktree:s,branch:t,branchFact:c,draft:e.drafts.get(t)??null,pr:u!==null&&(Sw(u,a)||p)?u:null,leftover:p,gone:l,tracked:i.tracked[o]!==void 0},n)}function Gw(e,t){let{marks:n}=t,r=e.worktrees.filter(e=>!e.isBare),i={repo:e,worktrees:r,branches:new Map(e.branches.map(e=>[e.name,e])),drafts:new Map(e.drafts.map(e=>[e.branch,e]))},a=[];for(let n of Uw(e,t)){let e=Ww(i,n,t);e!==null&&a.push(e)}for(let i of r){if(i.branch!==null)continue;let r=Hw({key:i.path,kind:`detached`,repo:e,worktree:i,branch:null,branchFact:null,draft:null,pr:null,leftover:!1,gone:!1,tracked:n.tracked[i.path]!==void 0},t);r!==null&&a.push(r)}return a}var Kw={uncommitted:0,unpushed:0,ahead:0,base:null,draft:!1,placeholders:0,adoptedUnedited:!1,bodyDiffers:!1},qw={edited:null,git:null,draft:null};function Jw(e,t,n){let{marks:r}=n,i=vw(e),a=r.tracked[i]!==void 0,o=Rw(e),s=Pw(qw,e,n.viewer),c=t.find(t=>t.identities.includes(e.repoKey))??null;return{key:i,kind:`pr`,section:e.state===`open`?`work`:`done`,repoRoot:c?.root??null,repoName:c?.name??e.repo,worktreePath:null,branch:e.headRefName,state:o,facts:{...Kw},pr:e,note:c===null?`no-local-clone`:`no-local-branch`,open:null,stage:jw(o,e),stack:n.stacks.get(e)??null,attention:Nw(e,n.viewer),lastActivity:s,times:{...qw},activity:s?.at??null,fingerprint:e.updatedAt,tracked:a}}function Yw(e,t){return e.key===t.key?0:e.key<t.key?-1:1}function Xw(e,t){return e.activity===t.activity?Yw(e,t):e.activity===null?1:t.activity===null?-1:t.activity-e.activity}function Zw(e,t){return e.activity!==null&&t-e.activity<=12096e5}function Qw(e,t){let n=e.pr===null?null:xw(e.pr),r=t.pr===null?null:xw(t.pr);return n===r?Yw(e,t):n===null?1:r===null?-1:r-n}function $w(e,t,n){let r=new Set(t.map(e=>e.key)),i=Cw(n),a=new Set;for(let t of[...Object.keys(e.tracked),...Object.keys(e.dismissed)])r.has(t)||(i||!t.startsWith(gw))&&a.add(t);return[...a].sort()}function eT(e,t,n,r,i=!1){let a=new Set,o=e.filter(e=>!a.has(e.root)&&(a.add(e.root),!0)),s=t.prs.filter(e=>!e.reviewRequested),c={prs:s,shown:s.filter(e=>Sw(e,r)),marks:n,now:r,canFinish:Cw(t),viewer:t.viewer,stacks:Mw(t.prs)},l=o.flatMap(e=>Gw(e,c)),u=new Set(l.map(e=>e.pr).filter(e=>e!==null));for(let e of c.shown)u.has(e)||l.push(Jw(e,o,c));for(let e of t.prs)e.reviewRequested&&e.state===`open`&&l.push(Jw(e,o,c));let d={work:[],candidates:[],older:[],done:[],dismissed:[],staleMarks:i?$w(n,l,t):[]};for(let e of l)n.dismissed[e.key]?.fingerprint===e.fingerprint?d.dismissed.push(e):e.section===`candidates`&&!Zw(e,r)?d.older.push(e):d[e.section].push(e);return d.work.sort(Xw),d.candidates.sort(Xw),d.older.sort(Xw),d.dismissed.sort(Xw),d.done.sort(Qw),d}var tT=3e5,nT={status:`never`,message:null,checkedAt:null,viewer:null,prs:[],capped:!1};async function rT(e,t,n){let r=0;async function i(){for(;r<e.length;){let t=e[r];r+=1,await n(t)}}await Promise.all(Array.from({length:Math.min(t,e.length)},i))}function iT(e){return e.roots.flatMap(e=>e.error===null?e.capped?[{path:e.path,message:`more repos than listed`}]:[]:[{path:e.path,message:e.error}])}function aT(e,t){let n=e.findIndex(e=>e.root===t.root);if(n===-1)return[...e,t];let r=[...e];return r[n]=t,r}var oT=Ps(`work`,()=>{let e=new Xs,t=H([]),n=H({total:0,done:0,running:!1}),r=H(!1),i=H([]),a=H([]),o=H(!1),s=H(null),c=H(!1),l=H({tracked:{},dismissed:{}}),u=H(null),d=H(Date.now()),f=H(null),p=0,m=Q(()=>r.value&&o.value&&i.value.length===0&&!c.value&&s.value!==null&&s.value.checkedAt!==null),h=Q(()=>eT(t.value,s.value??nT,l.value,d.value,m.value));function g(e,t,n){Zs(e,t),u.value=`${n}: ${Rs(t)}`}async function _(){try{l.value=await e.workMarks()}catch(e){g(`load Work marks`,e,`Could not load marks`)}}function v(e){return e===null||e.status===`never`||e.checkedAt===null||Date.now()-e.checkedAt>tT}async function y(){c.value=!0;try{let t=await e.workPrs();s.value=t,v(t)&&(s.value=await e.refreshWorkPrs())}catch(e){g(`load PRs`,e,`Could not load PRs`)}finally{c.value=!1}}async function b(){c.value=!0;try{s.value=await e.refreshWorkPrs()}catch(e){g(`check PRs`,e,`Could not check PRs`)}finally{c.value=!1}}async function x(r,a,o){try{let n=await e.workRepo(r);if(a!==p||o.has(n.root))return;o.set(n.root,n),t.value=aT(t.value,n)}catch(e){if(a!==p)return;Qs(`scan repo for the Work page`,e,{path:r}),i.value=[...i.value,{path:r,message:Rs(e)}]}finally{a===p&&(n.value={...n.value,done:n.value.done+1})}}async function S(){p+=1;let s=p;r.value=!1,i.value=[],a.value=[],o.value=!1,n.value={total:0,done:0,running:!0};let c,l;try{let[t,n]=await Promise.all([e.discovered(),e.listRepos()]);c=t,l=n.map(e=>e.path)}catch(e){if(s!==p)return;g(`list repos for the Work page`,e,`Could not list repos`),n.value={...n.value,running:!1};return}if(s!==p)return;a.value=iT(c),o.value=c.roots.every(e=>e.error===null&&!e.capped&&e.repos.length>0);let u=[...new Set(c.roots.flatMap(e=>e.repos.map(e=>e.path)))],d=new Map;if(n.value={total:u.length,done:0,running:!0},await rT(u,4,e=>x(e,s,d)),s!==p)return;let m=new Set(u);for(let e of d.values())for(let t of e.worktrees)m.add(t.path);let h=[...new Set(l)].filter(e=>!m.has(e));n.value={...n.value,total:u.length+h.length},await rT(h,4,e=>x(e,s,d)),s===p&&(t.value=[...d.values()],n.value={...n.value,running:!1},r.value=!0,f.value=Date.now())}async function C(){d.value=Date.now(),u.value=null,await Promise.all([_(),y(),S()])}async function w(){let e=Date.now(),t=!n.value.running&&(f.value===null||e-f.value>6e4),r=!c.value&&v(s.value);(t||r)&&(d.value=e,await Promise.all([r?b():null,t?S():null]))}async function T(){d.value=Date.now(),u.value=null,await Promise.all([b(),S()])}async function E(t,n,r){let i=h.value.staleMarks.filter(e=>e!==t),a={key:t,action:n};r!==void 0&&(a.fingerprint=r),i.length>0&&(a.prune=i);try{l.value=await e.putWorkMark(a)}catch(e){g(`save a Work mark`,e,`Could not save`)}}return{repos:t,scan:n,scanFinished:r,repoErrors:i,rootErrors:a,prs:s,prsLoading:c,marks:l,error:u,now:d,scannedAt:f,complete:m,classification:h,load:C,catchUp:w,refresh:T,runScan:S,mark:E}}),sT=[`data-icon`],cT=[`d`],lT=af(gr({__name:`WorkIcon`,props:{name:{}},setup(e){let t={stack:`M2.5 5.5 8 2.5l5.5 3L8 8.5ZM2.5 8.5 8 11.5l5.5-3M2.5 11 8 14l5.5-3`,check:`m3 8.5 3 3 7-7`,cross:`m4 4 8 8m0-8-8 8`,pending:`M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z`,comment:`M2.5 3.5h11v7.5h-6l-3 2.5V11h-2Z`,approved:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Zm-2.75 6.25 1.75 1.75 3.75-3.75`,changes:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2ZM8 5v4.5M5.75 7.25h4.5M5.75 11h4.5`,waiting:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Zm0 3v3.25l2 1.25`,pencil:`m10.5 2.5 3 3-8 8h-3v-3Z`,compare:`M2.5 5.5h10L10 3M13.5 10.5h-10L6 13`,chevron:`m6 3.5 4.5 4.5L6 12.5`,differs:`M3 6h10M3 10h10m-2.5-7-5 10`,alert:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2ZM8 5v3.75m0 2.25v.25`,copy:`M5.5 5.5h7.5v8H5.5ZM3 10.5v-8h7.5`},n=e,r=Q(()=>t[n.name]);return(t,n)=>(q(),J(`svg`,{class:`work-icon`,viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,"data-icon":e.name},[Y(`path`,{d:r.value},null,8,cT)],8,sT))}}),[[`__scopeId`,`data-v-a1673a3c`]]),uT={key:0,class:`view-error`,"data-testid":`work-draft-error`},dT={key:2,class:`loading`},fT=af(gr({__name:`WorkDraftEditor`,props:{path:{},branch:{}},setup(e){let t=e,n=new Xs,r=H(null),i=H(null),a=Zb(()=>r.value===null?null:{id:r.value,branch:t.branch}),o=!1;return jr(async()=>{try{let e=await n.openRepo(t.path);if(o){await n.closeRepo(e.id);return}r.value=e.id}catch(e){Zs(`open a repo for its PR draft`,e,{path:t.path}),i.value=`Could not open the repo: ${Rs(e)}`}}),Fr(()=>{o=!0;let e=r.value;(async()=>{if(await a.dispose(),e!==null)try{await n.closeRepo(e)}catch(e){Zs(`release a repo after its PR draft`,e,{path:t.path})}})()}),(e,t)=>i.value?(q(),J(`p`,uT,B(i.value),1)):r.value?(q(),ga(jS,{key:1,session:U(a)},null,8,[`session`])):(q(),J(`p`,dT,`Opening the draft…`))}}),[[`__scopeId`,`data-v-f26ea9b4`]]),pT=1500;function mT(){let e=H(null),t=null;function n(n){e.value=n,t!==null&&clearTimeout(t),t=setTimeout(()=>e.value=null,pT)}async function r(e){try{await navigator.clipboard.writeText(e),n(`copied`)}catch(e){Zs(`copy to the clipboard`,e),n(`failed`)}}return Fr(()=>{t!==null&&clearTimeout(t)}),{state:e,copy:r}}var hT={class:`block events`},gT={key:0,class:`none`},_T={key:1,class:`event-list`},vT=[`data-tip`],yT={class:`text`},bT={class:`block facts`},xT={class:`fact-list`},ST=[`data-tip`],CT={class:`actions`},wT=[`href`],TT={key:0,class:`block draft`},ET=8,DT=af(gr({__name:`WorkRowDetail`,props:{item:{},now:{},dismissed:{type:Boolean}},emits:[`open`,`mark`],setup(e,{emit:t}){let n=e,r=t,i=oT(),a=Q(()=>yx(n.item,i.prs?.viewer??null).slice(0,ET)),o=Q(()=>Sx(n.item)),s=Q(()=>Dx(n.item)),{state:c,copy:l}=mT(),u=Q(()=>c.value===`copied`?`Copied`:c.value===`failed`?`Could not copy`:`Copy for a session`),d=Q(()=>{let{item:e}=n;return e.kind!==`branch`||e.branch===null||e.open===null?null:{path:e.open.path,branch:e.branch}});return(t,n)=>(q(),J(`div`,{class:`detail`,"data-testid":`work-detail`,onClick:n[5]||=$(()=>{},[`stop`])},[Y(`section`,hT,[n[6]||=Y(`h3`,{class:`eyebrow`},`Activity`,-1),a.value.length===0?(q(),J(`p`,gT,`Nothing recorded.`)):(q(),J(`ol`,_T,[(q(!0),J(K,null,G(a.value,(t,n)=>(q(),J(`li`,{key:n,class:z([`event`,{other:t.other}])},[Y(`span`,{class:`at`,"data-tip":U(ux)(t.at)},B(U(lx)(t.at,e.now)),9,vT),Y(`span`,yT,B(t.text),1)],2))),128))]))]),Y(`section`,bT,[n[7]||=Y(`h3`,{class:`eyebrow`},`Facts`,-1),(q(!0),J(K,null,G(s.value,e=>(q(),J(`p`,{key:e,class:`wants`,"data-testid":`work-detail-attention`},B(e),1))),128)),Y(`dl`,xT,[(q(!0),J(K,null,G(o.value,([e,t])=>(q(),J(K,{key:e},[Y(`dt`,null,B(e),1),Y(`dd`,{"data-tip":t},B(t),9,ST)],64))),128))]),Y(`div`,CT,[e.item.open?(q(),J(`button`,{key:0,class:`action`,onClick:n[0]||=e=>r(`open`)},`Open in Compare`)):Z(``,!0),Y(`button`,{class:`action`,"data-testid":`work-detail-copy`,"data-tip":`The PR, repo, local clone and branch, to paste into a session`,onClick:n[1]||=t=>U(l)(U(Ox)(e.item))},B(u.value),1),e.item.pr?(q(),J(`a`,{key:1,class:`action`,href:e.item.pr.url,target:`_blank`,rel:`noopener noreferrer`},`Open #`+B(e.item.pr.number)+` on GitHub`,9,wT)):Z(``,!0),e.item.tracked?(q(),J(`button`,{key:2,class:`action`,"data-testid":`work-drop`,onClick:n[2]||=e=>r(`mark`,`drop`)},` Stop tracking `)):Z(``,!0),e.dismissed?(q(),J(`button`,{key:3,class:`action`,"data-testid":`work-detail-undismiss`,onClick:n[3]||=e=>r(`mark`,`undismiss`)},` Show again `)):(q(),J(`button`,{key:4,class:`action`,"data-testid":`work-dismiss`,"data-tip":`Hide this until something about it changes`,onClick:n[4]||=e=>r(`mark`,`dismiss`)},` Dismiss `))])]),d.value?(q(),J(`section`,TT,[xa(fT,{path:d.value.path,branch:d.value.branch},null,8,[`path`,`branch`])])):Z(``,!0)]))}}),[[`__scopeId`,`data-v-d98ae195`]]),OT=[`data-stage`],kT=[`data-tip`],AT={class:`pips`,"aria-hidden":`true`},jT={class:`sr-only`},MT=[`data-tip`,`aria-label`],NT=[`data-tip`],PT={class:`branch mono`},FT=[`data-tip`],IT={key:1,class:`by`,"data-testid":`work-by`},LT={key:2,class:`pr-title`},RT=[`data-tip`],zT={class:`mono`},BT={class:`cell pr`},VT=[`href`,`data-tip`],HT=[`data-tip`],UT={key:1,class:`threads`},WT={class:`mono`},GT=[`data-tip`],KT={class:`cell local mono`,"data-testid":`work-local`},qT=[`data-tip`],JT=[`data-tip`],YT=[`data-tip`],XT=[`data-tip`],ZT={key:1,class:`placeholders mono`},QT=[`data-tip`],$T=[`data-tip`],eE={class:`cell act`},tE=[`data-tip`],nE=[`data-tip`,`aria-label`],rE=[`aria-expanded`,`aria-label`],iE=af(gr({__name:`WorkRow`,props:{item:{},now:{},dismissed:{type:Boolean}},emits:[`open`,`mark`],setup(e,{emit:t}){let n=e,r=t,i=V(!1);function a(){i.value=!i.value}let o=Q(()=>mx[n.item.stage]),s=oT(),c=Q(()=>Ex(n.item,s.prs?.viewer??null)),l=Q(()=>{let e=n.item.lastActivity;return e===null?void 0:`${vx(e)}\n${ux(e.at)}`}),u=Q(()=>Dx(n.item).join(`
|
|
22
22
|
`)),d=Q(()=>n.item.pr?.reviewRequested?n.item.pr.author:null),{state:f,copy:p}=mT(),m=Q(()=>f.value===`copied`?`Copied`:f.value===`failed`?`Could not copy`:`Copy the PR, repo and branch, to paste into a session`),h=Q(()=>n.item.pr?.progress??null),g=Q(()=>{let e=h.value;if(e===null)return;let t=[e.decision===null?`no review decision`:e.decision.replace(`-`,` `)];return e.unresolvedThreads>0&&t.push(`${e.unresolvedThreads} open threads`),e.pendingReviewers>0&&t.push(`${e.pendingReviewers} reviewers asked`),t.join(` · `)}),_=Q(()=>{let e=h.value;return e===null||n.item.stage===`draft`?null:e.decision===`approved`?`approved`:e.decision===`changes-requested`?`changes`:`waiting`}),v=Q(()=>{let e=h.value;if(e!==null)return e.checks===null?`no checks`:`checks: ${e.checks}`}),y=Q(()=>h.value?.conflicting??!1),b=Q(()=>{let e=h.value?.checks??null;return e===`success`?`check`:e===`failure`?`cross`:e===`pending`?`pending`:null}),x=Q(()=>{let e=n.item.stack;return e===null?void 0:`Layer ${e.position} of ${e.size} in the stack on ${e.root}`}),S=Q(()=>{let e=n.item.facts,t=[];return e.draft&&t.push(e.adoptedUnedited?`draft: agent text, not edited`:`draft`),e.placeholders>0&&t.push(`${e.placeholders} placeholders`),e.bodyDiffers&&t.push(`differs from the PR on GitHub`),t.length===0?void 0:t.join(` · `)}),C=Q(()=>n.item.lastActivity),w=Q(()=>dx(n.item,n.now)),T=Q(()=>!n.dismissed&&n.item.section===`candidates`&&!n.item.tracked),E=Q(()=>{let e=[n.item.branch??`detached`];return n.item.pr&&e.push(n.item.pr.title),n.item.worktreePath&&e.push(n.item.worktreePath),e.join(`
|
|
23
23
|
`)});return(t,n)=>(q(),J(`li`,{class:z([`work-row`,{expanded:i.value,dim:e.dismissed}]),"data-stage":e.item.stage,"data-testid":`work-row`},[Y(`div`,{class:`line`,"data-testid":`work-row-line`,onClick:a},[Y(`span`,{class:`cell prog`,"data-tip":U(px)[e.item.stage],"data-testid":`work-stage`},[Y(`span`,AT,[(q(),J(K,null,G(5,e=>Y(`i`,{key:e,class:z({on:e<=o.value})},null,2)),64))]),Y(`span`,jT,B(U(px)[e.item.stage]),1),e.item.attention.length>0?(q(),J(`span`,{key:0,class:`alert`,"data-testid":`work-attention`,"data-tip":u.value,"aria-label":u.value},[xa(lT,{name:`alert`})],8,MT)):Z(``,!0)],8,kT),Y(`span`,{class:`cell name`,"data-tip":E.value},[Y(`span`,PT,B(e.item.branch??`detached`),1),y.value?(q(),J(`span`,{key:0,class:`conflicts`,"data-testid":`work-conflicts`,"data-tip":`GitHub says this branch has merge conflicts with ${e.item.pr?.baseRefName}`},`conflicts`,8,FT)):Z(``,!0),d.value?(q(),J(`span`,IT,`by `+B(d.value),1)):Z(``,!0),e.item.pr?(q(),J(`span`,LT,B(e.item.pr.title),1)):Z(``,!0)],8,NT),Y(`span`,{class:`cell stack`,"data-tip":x.value,"data-testid":`work-stack`},[e.item.stack?(q(),J(K,{key:0},[xa(lT,{name:`stack`}),Y(`span`,zT,B(e.item.stack.position)+`/`+B(e.item.stack.size),1)],64)):Z(``,!0)],8,RT),Y(`span`,BT,[e.item.pr?(q(),J(`a`,{key:0,class:`pr-link mono`,"data-testid":`work-pr-link`,href:e.item.pr.url,target:`_blank`,rel:`noopener noreferrer`,"data-tip":`Open #${e.item.pr.number} on GitHub`,onClick:n[0]||=$(()=>{},[`stop`])},`#`+B(e.item.pr.number),9,VT)):Z(``,!0)]),Y(`span`,{class:`cell review`,"data-tip":g.value,"data-testid":`work-review`},[_.value?(q(),ga(lT,{key:0,name:_.value,class:z(_.value)},null,8,[`name`,`class`])):Z(``,!0),h.value&&h.value.unresolvedThreads>0?(q(),J(`span`,UT,[xa(lT,{name:`comment`}),Y(`span`,WT,B(h.value.unresolvedThreads),1)])):Z(``,!0)],8,HT),Y(`span`,{class:`cell checks`,"data-tip":v.value,"data-testid":`work-checks`},[b.value?(q(),ga(lT,{key:0,name:b.value,class:z(b.value)},null,8,[`name`,`class`])):Z(``,!0)],8,GT),Y(`span`,KT,[e.item.facts.uncommitted>0?(q(),J(`span`,{key:0,class:`uncommitted`,"data-tip":`${e.item.facts.uncommitted} uncommitted`},`●`+B(e.item.facts.uncommitted),9,qT)):Z(``,!0),e.item.facts.unpushed>0?(q(),J(`span`,{key:1,class:`unpushed`,"data-tip":`${e.item.facts.unpushed} unpushed`},`↑`+B(e.item.facts.unpushed),9,JT)):Z(``,!0),e.item.note?(q(),J(`span`,{key:2,class:`note`,"data-tip":U(Ux)[e.item.note]},B(U(Hx)[e.item.note]),9,YT)):Z(``,!0)]),Y(`span`,{class:`cell draft`,"data-tip":S.value,"data-testid":`work-draft`},[e.item.facts.draft?(q(),ga(lT,{key:0,name:`pencil`,class:z({agent:e.item.facts.adoptedUnedited})},null,8,[`class`])):Z(``,!0),e.item.facts.placeholders>0?(q(),J(`span`,ZT,B(`{`)+B(e.item.facts.placeholders)+B(`}`),1)):Z(``,!0),e.item.facts.bodyDiffers?(q(),ga(lT,{key:2,name:`differs`,class:`differs`})):Z(``,!0)],8,XT),Y(`span`,{class:z([`cell status`,c.value.turn]),"data-tip":c.value.why||void 0,"data-testid":`work-status`},B(c.value.text),11,QT),Y(`span`,{class:z([`cell when`,{recent:w.value}]),"data-tip":l.value,"data-testid":`work-when`},B(C.value?U(lx)(C.value.at,e.now):``),11,$T),Y(`span`,eE,[T.value?(q(),J(`button`,{key:0,class:`action`,"data-testid":`work-track`,"data-tip":`Keep this in Work`,onClick:n[1]||=$(t=>r(`mark`,e.item,`track`),[`stop`])},` Track `)):Z(``,!0),e.dismissed?(q(),J(`button`,{key:1,class:`action`,"data-testid":`work-undismiss`,onClick:n[2]||=$(t=>r(`mark`,e.item,`undismiss`),[`stop`])},` Show `)):Z(``,!0),!e.item.open&&e.item.pr?(q(),J(`button`,{key:2,class:z([`icon-btn`,{done:U(f)===`copied`}]),"data-testid":`work-copy`,"data-tip":m.value,"aria-label":`Copy for a session`,onClick:n[3]||=$(t=>U(p)(U(Ox)(e.item)),[`stop`])},[xa(lT,{name:U(f)===`copied`?`check`:`copy`},null,8,[`name`])],10,tE)):Z(``,!0),e.item.open?(q(),J(`button`,{key:3,class:`icon-btn`,"data-testid":`work-compare`,"data-tip":`Open ${e.item.branch??`this worktree`} in Compare`,"aria-label":`Open ${e.item.branch??`this worktree`} in Compare`,onClick:n[4]||=$(t=>r(`open`,e.item),[`stop`])},[xa(lT,{name:`compare`})],8,nE)):Z(``,!0),Y(`button`,{class:`icon-btn expand`,"data-testid":`work-expand`,"aria-expanded":i.value,"aria-label":i.value?`Close`:`Show activity and draft`,onClick:$(a,[`stop`])},[xa(lT,{name:`chevron`})],8,rE)])]),i.value?(q(),ga(DT,{key:0,item:e.item,now:e.now,dismissed:e.dismissed,onOpen:n[5]||=t=>r(`open`,e.item),onMark:n[6]||=t=>r(`mark`,e.item,t)},null,8,[`item`,`now`,`dismissed`])):Z(``,!0)],10,OT))}}),[[`__scopeId`,`data-v-9a0e5bad`]]),aE={class:`work-page`,"data-testid":`work-page`},oE={class:`work-head`},sE={class:`head-text`},cE=[`data-tip`],lE=[`data-tip`],uE={class:`filters`,role:`group`,"aria-label":`Show`},dE=[`aria-pressed`],fE=[`aria-pressed`,`data-testid`,`data-tip`,`onClick`],pE={class:`filter-count`},mE={class:`filters`,role:`group`,"aria-label":`Group`},hE=[`aria-pressed`],gE=[`aria-pressed`],_E=[`disabled`],vE={key:0,class:`page-error view-error`,"data-testid":`work-error`},yE=[`data-tip`],bE=[`data-tip`],xE={key:3,class:`state-block`,"data-testid":`work-no-repos`},SE={class:`state-hint`},CE={key:4,class:`panel-note`,"data-testid":`work-clear`},wE={key:5,class:`panel-note`,"data-testid":`work-within-empty`},TE={key:6,class:`col-heads`,"data-testid":`work-col-heads`},EE=[`aria-sort`,`data-tip`,`onClick`],DE={key:0,class:`sort-mark`,"aria-hidden":`true`},OE={key:1,class:`col-head`},kE=[`open`,`data-testid`,`onToggle`],AE={key:0,class:`eyebrow`},jE={key:1,class:`section-title eyebrow`},ME={class:`section-name`},NE={class:`count`},PE={class:`rows`},FE={key:0,class:`time-head`,"data-testid":`work-time`},IE={class:`time-name`},LE={class:`group-count`},RE={class:`group-name`},zE={class:`group-count`},BE={key:7,class:`work-section dismissed`,"data-testid":`work-dismissed`},VE={class:`eyebrow`},HE={class:`rows`},UE=3e4,WE=af(gr({__name:`WorkView`,setup(e){let t=ic(),n=zl(),r=Gl(),i=oT(),{openByPath:a}=Kl(),o=V(Date.now()),s=null;function c(){document.visibilityState===`visible`&&(o.value=Date.now(),i.catchUp())}jr(()=>{s=setInterval(()=>o.value=Date.now(),UE),document.addEventListener(`visibilitychange`,c),window.addEventListener(`focus`,c)}),Fr(()=>{s!==null&&clearInterval(s),document.removeEventListener(`visibilitychange`,c),window.removeEventListener(`focus`,c)}),jr(()=>{i.load()});let l={work:`Work`,candidates:`Candidates`,done:`Done`},u=[`work`,`candidates`,`older`,`done`],d=[`work`,`done`,`candidates`,`older`],f=[{label:`Stage`,key:`stage`,order:`how far along: local only first, merged last`},{label:`Branch`,key:`branch`,order:`branch name, A to Z`},{label:`Stack`,key:`stack`,order:`stack, each one bottom layer first`},{label:`PR`,key:`pr`,order:`PR number, lowest first`},{label:`Review`,key:`review`,order:`review: changes requested first, then waiting, then approved`},{label:`CI`,key:`ci`,order:`CI: conflicts first, then failed, running, passed`},{label:`Local`,key:`local`,order:`uncommitted plus unpushed, fewest first`},{label:`Draft`,key:`draft`,order:`PR draft: drafts with {{…}} gaps first, then drafts that differ from GitHub, then the rest`},{label:`Status`,key:`status`,order:`whose move: yours first, then someone else's, then done`},{label:`When`,key:`activity`,order:`last activity, newest first`,right:!0},{label:``,key:null}];function p(e){let t=r.workByRepo?`inside each repo`:`inside each section`;return`Sort by ${e.order} (${t}). Again to reverse, a third time for the default order. Rows with none go last.`}let m=V(null);function h(e){let t=e===`activity`?`desc`:`asc`,n=m.value;n===null||n.key!==e?m.value={key:e,dir:t}:n.dir===t?m.value={key:e,dir:t===`asc`?`desc`:`asc`}:m.value=null}function g(e){if(e!==null&&m.value?.key===e)return m.value.dir===`asc`?`ascending`:`descending`}let _=Q(()=>i.classification),v=Jx.filter(e=>e.within!==1/0),y=V(null);function b(e){return v.find(t=>t.key===e)?.within??null}function x(e,t){let n=b(t);return n===null?e:e.filter(e=>fx(e,o.value,n))}let S=Q(()=>{let e=u.flatMap(e=>_.value[e]);return Object.fromEntries(v.map(t=>[t.key,x(e,t.key).length]))}),C=V(!1);function w(e){return e===`older`?C.value:!r.workFolded.includes(e)}function T(e,t){let n=t.target.open;e===`older`?C.value=n:r.setWorkFolded(e,!n)}let E=Q(()=>{let e=(y.value===null?u:d).map(e=>{let t=x(_.value[e],y.value),n=Zx(t,{byRepo:r.workByRepo,byTime:r.workByTime,sort:m.value,now:o.value});return{name:e,title:e===`older`?``:l[e],items:t,lines:n}}).filter(e=>e.items.length>0);return e.some(e=>e.name===`candidates`&&!w(`candidates`))?e.filter(e=>e.name!==`older`):e});function D(e){return`${e} older ${e===1?`candidate`:`candidates`}`}let O=Q(()=>i.scan.running||i.prsLoading),k=Q(()=>{let e=i.prs;if(e===null)return i.prsLoading?{text:`checking PRs…`,failed:!1}:null;let t=e.checkedAt===null?null:Kx(e.checkedAt,e.viewer,o.value),n=e.checkedAt===null?void 0:ux(e.checkedAt),r=Gx(e.status,e.message);if(r!==null)return{text:t===null?r:`${r} · ${t}`,failed:!0,tip:n};if(t===null)return i.prsLoading?{text:`checking PRs…`,failed:!1}:null;let a=e.capped?`${t} · more PRs than listed`:t;return{text:i.prsLoading?`${a} · checking…`:a,failed:!1,tip:n}}),A=Q(()=>{if(i.scan.running)return{text:`scanned ${i.scan.done} of ${i.scan.total} repos`};let e=i.scannedAt;return e===null?null:{text:`Repos scanned ${lx(e,o.value)}`,tip:ux(e)}}),j=Q(()=>i.scanFinished&&i.repos.length===0&&i.repoErrors.length===0&&i.rootErrors.length===0),M=Q(()=>i.scanFinished&&!j.value&&u.every(e=>_.value[e].length===0)&&_.value.dismissed.length===0);async function N(e){let i=e.open;i!==null&&(t.activeRepoPath===i.path||await a(i.path))&&(au({repo:n.repoPath??i.path,view:`compare`}),r.setActiveView(`compare`),await n.setComparePick({head:i.head}))}function P(e,t){i.mark(e.key,t,t===`dismiss`?e.fingerprint:void 0)}return(e,t)=>(q(),J(`div`,aE,[Y(`header`,oE,[Y(`div`,sE,[t[5]||=Y(`h1`,{class:`title`},`Work`,-1),k.value?(q(),J(`p`,{key:0,class:z([`gh-line mono`,{failed:k.value.failed}]),"data-tip":k.value.tip,"data-testid":`gh-line`},B(k.value.text),11,cE)):Z(``,!0),A.value?(q(),J(`p`,{key:1,class:`scan-line mono`,"data-tip":A.value.tip,"data-testid":`scan-line`},B(A.value.text),9,lE)):Z(``,!0)]),Y(`div`,uE,[Y(`button`,{class:z([`filter chrome-chip`,{on:y.value===null}]),"aria-pressed":y.value===null,"data-testid":`work-within-all`,onClick:t[0]||=e=>y.value=null},` All `,10,dE),(q(!0),J(K,null,G(U(v),e=>(q(),J(`button`,{key:e.key,class:z([`filter chrome-chip`,{on:y.value===e.key}]),"aria-pressed":y.value===e.key,"data-testid":`work-within-${e.key}`,"data-tip":`Only what moved in the ${e.label.toLowerCase()}`,onClick:t=>y.value=e.key},[X(B(e.label)+` `,1),Y(`span`,pE,B(S.value[e.key]),1)],10,fE))),128))]),Y(`div`,mE,[Y(`button`,{class:z([`filter chrome-chip`,{on:U(r).workByRepo}]),"aria-pressed":U(r).workByRepo,"data-testid":`work-by-repo`,"data-tip":`Group the rows under a heading per repo`,onClick:t[1]||=e=>U(r).toggleWorkByRepo()},` By repository `,10,hE),Y(`button`,{class:z([`filter chrome-chip`,{on:U(r).workByTime}]),"aria-pressed":U(r).workByTime,"data-testid":`work-by-time`,"data-tip":`Group the rows by their last activity: last day, week, 2 weeks, month, older`,onClick:t[2]||=e=>U(r).toggleWorkByTime()},` By time `,10,gE)]),Y(`button`,{class:`refresh-btn chrome-chip`,"data-testid":`work-refresh`,disabled:O.value,"data-tip":`Check GitHub and rescan every repo`,onClick:t[3]||=e=>U(i).refresh()},` Refresh `,8,_E)]),U(i).error?(q(),J(`p`,vE,B(U(i).error),1)):Z(``,!0),U(i).repoErrors.length>0?(q(),J(`p`,{key:1,class:`page-error view-error`,"data-testid":`work-repo-errors`,"data-tip":U(i).repoErrors.map(e=>`${e.path}: ${e.message}`).join(`
|
|
24
24
|
`)},B(U(i).repoErrors.length)+` `+B(U(i).repoErrors.length===1?`repo`:`repos`)+` could not be scanned: `+B(U(i).repoErrors.map(e=>U(ql)(e.path)).join(`, `)),9,yE)):Z(``,!0),U(i).rootErrors.length>0?(q(),J(`p`,{key:2,class:`page-error view-error`,"data-testid":`work-root-errors`,"data-tip":U(i).rootErrors.map(e=>`${e.path}: ${e.message}`).join(`
|
|
25
|
-
`)},B(U(i).rootErrors.length)+` watch `+B(U(i).rootErrors.length===1?`directory`:`directories`)+` not fully scanned: `+B(U(i).rootErrors.map(e=>U(ql)(e.path)).join(`, `)),9,bE)):Z(``,!0),j.value?(q(),J(`div`,xE,[t[8]||=Y(`p`,{class:`state-title`},`No repos to scan.`,-1),Y(`p`,SE,[t[6]||=X(` Add a watch directory in `,-1),Y(`button`,{class:`link-btn`,onClick:t[4]||=e=>U(r).openOverlay(`settings`)},`Settings`),t[7]||=X(`, and its repos show up here. `,-1)])])):M.value?(q(),J(`p`,CE,` Nothing open. A worktree with changes, a branch ahead of its base, or an open PR shows up here. `)):y.value!==null&&E.value.length===0&&U(i).scanFinished?(q(),J(`p`,wE,` Nothing moved in the `+B(U(v).find(e=>e.key===y.value)?.label.toLowerCase())+`. `,1)):Z(``,!0),E.value.length>0?(q(),J(`div`,TE,[(q(),J(K,null,G(f,e=>(q(),J(K,{key:e.label},[e.key?(q(),J(`button`,{key:0,class:z([`col-head`,{right:e.right,sorted:m.value?.key===e.key}]),"aria-sort":g(e.key),"data-tip":p(e),onClick:t=>h(e.key)},[X(B(e.label),1),m.value?.key===e.key?(q(),J(`span`,DE,B(m.value.dir===`asc`?` ↑`:` ↓`),1)):Z(``,!0)],10,EE)):(q(),J(`span`,OE,B(e.label),1))],64))),64))])):Z(``,!0),(q(!0),J(K,null,G(E.value,e=>(q(),J(`details`,{key:e.name,class:z([`work-section`,{fold:e.name===`older`}]),open:w(e.name),"data-testid":`work-section-${e.name}`,onToggle:t=>T(e.name,t)},[e.name===`older`?(q(),J(`summary`,AE,B(D(e.items.length)),1)):(q(),J(`summary`,jE,[Y(`h2`,ME,[X(B(e.title)+` `,1),Y(`span`,NE,B(e.items.length),1)])])),Y(`ul`,PE,[(q(!0),J(K,null,G(e.lines,e=>(q(),J(K,{key:e.key},[e.kind===`time`?(q(),J(`li`,FE,[Y(`span`,IE,B(e.label),1),Y(`span`,LE,B(e.count),1)])):e.kind===`repo`?(q(),J(`li`,{key:1,class:z([`group-head`,{nested:U(r).workByTime}]),"data-testid":`work-group`},[Y(`span`,RE,B(e.name),1),Y(`span`,zE,B(e.count),1)],2)):(q(),ga(iE,{key:2,item:e.item,now:o.value,onOpen:N,onMark:P},null,8,[`item`,`now`]))],64))),128))])],42,kE))),128)),_.value.dismissed.length>0?(q(),J(`details`,BE,[Y(`summary`,VE,B(_.value.dismissed.length)+` dismissed`,1),Y(`ul`,HE,[(q(!0),J(K,null,G(_.value.dismissed,e=>(q(),ga(iE,{key:e.key,item:e,now:o.value,dismissed:``,onOpen:N,onMark:P},null,8,[`item`,`now`]))),128))])])):Z(``,!0)]))}}),[[`__scopeId`,`data-v-
|
|
25
|
+
`)},B(U(i).rootErrors.length)+` watch `+B(U(i).rootErrors.length===1?`directory`:`directories`)+` not fully scanned: `+B(U(i).rootErrors.map(e=>U(ql)(e.path)).join(`, `)),9,bE)):Z(``,!0),j.value?(q(),J(`div`,xE,[t[8]||=Y(`p`,{class:`state-title`},`No repos to scan.`,-1),Y(`p`,SE,[t[6]||=X(` Add a watch directory in `,-1),Y(`button`,{class:`link-btn`,onClick:t[4]||=e=>U(r).openOverlay(`settings`)},`Settings`),t[7]||=X(`, and its repos show up here. `,-1)])])):M.value?(q(),J(`p`,CE,` Nothing open. A worktree with changes, a branch ahead of its base, or an open PR shows up here. `)):y.value!==null&&E.value.length===0&&U(i).scanFinished?(q(),J(`p`,wE,` Nothing moved in the `+B(U(v).find(e=>e.key===y.value)?.label.toLowerCase())+`. `,1)):Z(``,!0),E.value.length>0?(q(),J(`div`,TE,[(q(),J(K,null,G(f,e=>(q(),J(K,{key:e.label},[e.key?(q(),J(`button`,{key:0,class:z([`col-head`,{right:e.right,sorted:m.value?.key===e.key}]),"aria-sort":g(e.key),"data-tip":p(e),onClick:t=>h(e.key)},[X(B(e.label),1),m.value?.key===e.key?(q(),J(`span`,DE,B(m.value.dir===`asc`?` ↑`:` ↓`),1)):Z(``,!0)],10,EE)):(q(),J(`span`,OE,B(e.label),1))],64))),64))])):Z(``,!0),(q(!0),J(K,null,G(E.value,e=>(q(),J(`details`,{key:e.name,class:z([`work-section`,{fold:e.name===`older`}]),open:w(e.name),"data-testid":`work-section-${e.name}`,onToggle:t=>T(e.name,t)},[e.name===`older`?(q(),J(`summary`,AE,B(D(e.items.length)),1)):(q(),J(`summary`,jE,[Y(`h2`,ME,[X(B(e.title)+` `,1),Y(`span`,NE,B(e.items.length),1)])])),Y(`ul`,PE,[(q(!0),J(K,null,G(e.lines,e=>(q(),J(K,{key:e.key},[e.kind===`time`?(q(),J(`li`,FE,[Y(`span`,IE,B(e.label),1),Y(`span`,LE,B(e.count),1)])):e.kind===`repo`?(q(),J(`li`,{key:1,class:z([`group-head`,{nested:U(r).workByTime}]),"data-testid":`work-group`},[Y(`span`,RE,B(e.name),1),Y(`span`,zE,B(e.count),1)],2)):(q(),ga(iE,{key:2,item:e.item,now:o.value,onOpen:N,onMark:P},null,8,[`item`,`now`]))],64))),128))])],42,kE))),128)),_.value.dismissed.length>0?(q(),J(`details`,BE,[Y(`summary`,VE,B(_.value.dismissed.length)+` dismissed`,1),Y(`ul`,HE,[(q(!0),J(K,null,G(_.value.dismissed,e=>(q(),ga(iE,{key:e.key,item:e,now:o.value,dismissed:``,onOpen:N,onMark:P},null,8,[`item`,`now`]))),128))])])):Z(``,!0)]))}}),[[`__scopeId`,`data-v-897d12ed`]]),GE=12,KE=8,qE=af(gr({__name:`HoverTip`,setup(e){let t=H(null),n=V(0),r=V(0),i=V(null),a={width:0,height:0},o={x:0,y:0};function s(){let{width:e,height:t}=a,i=window.innerWidth-e-KE;n.value=Math.max(KE,Math.min(o.x-e/2,i));let s=o.y-t-GE;r.value=s>=KE?s:o.y+24}async function c(e){if(e!==t.value){t.value=e,await On();let n=i.value;a=n===null?{width:0,height:0}:{width:n.offsetWidth,height:n.offsetHeight}}s()}function l(){t.value=null}function u(e){if(e.pointerType===`touch`)return;o={x:e.clientX,y:e.clientY};let t=(e.target instanceof Element?e.target.closest(`[data-tip]`):null)?.getAttribute(`data-tip`)??``;t===``?l():c(t)}return jr(()=>{document.addEventListener(`pointermove`,u,{passive:!0}),document.addEventListener(`pointerdown`,l,{passive:!0}),document.addEventListener(`scroll`,l,{capture:!0,passive:!0}),document.documentElement.addEventListener(`pointerleave`,l)}),Pr(()=>{document.removeEventListener(`pointermove`,u),document.removeEventListener(`pointerdown`,l),document.removeEventListener(`scroll`,l,{capture:!0}),document.documentElement.removeEventListener(`pointerleave`,l)}),(e,a)=>(q(),ga(lr,{to:`body`},[t.value===null?Z(``,!0):(q(),J(`div`,{key:0,ref_key:`tipEl`,ref:i,class:`hover-tip`,role:`tooltip`,"data-testid":`hover-tip`,style:le({left:`${n.value}px`,top:`${r.value}px`})},B(t.value),5))]))}}),[[`__scopeId`,`data-v-662bb016`]]),JE={class:`shell`},YE={class:`workspace`},XE=3e3,ZE=1500,QE=af(gr({__name:`App`,setup(e){let t=ic(),n=Bl(),r=zl(),i=Gl();xu();let{activate:a,openByPath:o}=Kl();i.init(),du(),fu(),_u();let s={changes:iy,journal:jy,history:xb,compare:uC,explorer:hw},c=Q(()=>s[i.activeView]),l=Q(()=>t.activeRepoId!==null);jr(()=>{t.connect()});let u=()=>{r.releaseOnUnload()};jr(()=>{window.addEventListener(`pagehide`,u)}),Fr(()=>{window.removeEventListener(`pagehide`,u)});let d=!0,f=null;function p(){d=!1,f!==null&&(clearTimeout(f),f=null)}function m(e){t.activeRepoId===null&&e.length!==0&&a(e[0])}let h=ou({onRestore:_}),g=V(null);async function _(e,n){if(i.setWorkOpen(e.work),e.work||e.view===null&&e.repo===null)return;e.repo!==null&&t.suspendFollowNavigation(ZE);let r=t.activeRepoId===null;r&&e.view!==null&&i.setActiveView(e.view),(await y(e,n)||v(e,n))&&(!r&&e.view!==null&&i.setActiveView(e.view),e.view!==null&&await b(e,n))}function v(e,t){return!t.isStale()&&e.repo!==null&&r.repoId===null&&r.repoPath===h.toAbsolute(e.repo)}async function y(e,t){return e.repo===null||h.isActiveRepo(e.repo)?!0:(await h.whenHomeReady,t.isStale()||!await o(h.toAbsolute(e.repo))||t.isStale()?!1:(await On(),!t.isStale()))}async function b(e,t){switch(g.value=null,e.view){case`explorer`:e.at===null?n.clearSelection():e.at!==n.selectedPath&&await n.revealFile(e.at);return;case`history`:await S(e.at,e.whole,t);return;case`compare`:await C(e,t);return;case`changes`:x(e.at,e.whole);return;default:return}}function x(e,t=null){if(e===null){r.selectFile(null),i.setActiveStackKey(null),r.setWholeFile(null);return}let n=r.shared.status?.files;if(!n){g.value={view:`changes`,at:e,whole:t,repoPath:r.repoPath};return}let a=e.slice(e.indexOf(`:`)+1),o=n.find(t=>Al(t)===e)??n.find(e=>e.path===a)??null;if(!o)return;r.selectFile(o);let s=Al(o);i.setActiveStackKey(s),i.requestStackScroll(s),r.setWholeFile(t===o.path?{view:`changes`,key:s,path:o.path}:null)}async function S(e,t,n){if(e===null){await r.selectHistoryCommit(null),r.setWholeFile(null);return}let i=e=>{r.setWholeFile(t===null?null:{view:`history`,key:`h:${e}:${t}`,path:t,hash:e})};if(r.history.selectedCommit?.hash.startsWith(e)){i(r.history.selectedCommit.hash);return}let a=r.history.commits.find(t=>t.hash.startsWith(e));if(a){await r.selectHistoryCommit(a),i(a.hash);return}let o=await r.resolveCommit(e);o===null||n.isStale()||(await r.selectHistoryCommit(o),i(o.hash))}async function C(e,t){let n=e.base!==null&&e.base!==r.selectedCompareBase?e.base:void 0;if((n!==void 0||e.head!==r.selectedStackHead)&&(await r.setComparePick({base:n,head:e.head}),t.isStale()))return;if(e.at===null){r.setWholeFile(null);return}let a=r.compare.compareDiff?.files;if(!a){g.value={view:`compare`,at:e.at,whole:e.whole,repoPath:r.repoPath};return}let o=a.findIndex(t=>t.path===e.at);if(o===-1)return;r.selectCompareFile(o);let s=a[o];i.requestStackScroll(jl(s)),r.setWholeFile(e.whole===s.path?{view:`compare`,key:jl(s),path:s.path,side:s.uncommitted}:null)}function w(e){return e.repoPath===r.repoPath||(g.value=null,!1)}return W(()=>r.shared.status,()=>{let e=g.value;e?.view===`changes`&&i.activeView===`changes`&&w(e)&&(g.value=null,x(e.at,e.whole??null))}),W(()=>r.compare.compareDiff,e=>{let t=g.value;if(t?.view!==`compare`||i.activeView!==`compare`||!e||!w(t))return;g.value=null;let n=e.files.findIndex(e=>e.path===t.at);if(n===-1)return;r.selectCompareFile(n);let a=e.files[n];i.requestStackScroll(jl(a)),r.setWholeFile(t.whole===a.path?{view:`compare`,key:jl(a),path:a.path,side:a.uncommitted}:null)}),(h.initial.view!==null||h.initial.repo!==null||h.initial.work)&&(h.initial.repo!==null&&(p(),t.skipInitialFollow=!0),h.restore(h.initial)),W([()=>t.repos,()=>t.follow],([e,n])=>{d&&(n===null?f===null&&e.length>0&&(f=setTimeout(()=>{f=null,d&&(p(),m(t.repos))},XE)):(p(),!(t.followEnabled&&n.followedRepoId!==null&&n.followedPath!==null)&&m(e)))}),Fr(()=>{f!==null&&clearTimeout(f)}),(e,n)=>(q(),J(`div`,JE,[xa(Rf),U(i).workOpen?Z(``,!0):(q(),ga(Qf,{key:0})),U(i).workOpen?Z(``,!0):(q(),ga($f,{key:1})),Y(`main`,YE,[U(i).workOpen?(q(),ga(WE,{key:0})):l.value?(q(),ga(Hr(c.value),{key:U(t).activeRepoId??``})):(q(),ga(dp,{key:1}))]),xa(cp),U(i).activeOverlay===`finder`?(q(),ga(Ep,{key:2})):U(i).activeOverlay===`search`?(q(),ga(Bp,{key:3})):U(i).activeOverlay===`help`?(q(),ga(Xp,{key:4})):U(i).activeOverlay===`settings`?(q(),ga(Mm,{key:5})):Z(``,!0),xa(qE)]))}}),[[`__scopeId`,`data-v-7d8dd518`]]),$E={black:`#000000`,red:`#cd0000`,green:`#00cd00`,yellow:`#cdcd00`,blue:`#0000ee`,magenta:`#cd00cd`,cyan:`#00cdcd`,white:`#e5e5e5`,gray:`#7f7f7f`,grey:`#7f7f7f`,blackBright:`#7f7f7f`,redBright:`#ff0000`,greenBright:`#00ff00`,yellowBright:`#ffff00`,blueBright:`#5c5cff`,magentaBright:`#ff00ff`,cyanBright:`#00ffff`,whiteBright:`#ffffff`};function eD(e){if(e.startsWith(`#`))return e.toLowerCase();let t=$E[e];if(!t)throw Error(`unknown color name: ${e}`);return t}function tD(e){return[`--diff-add-bg: ${eD(e.addBg)};`,`--diff-del-bg: ${eD(e.delBg)};`,`--diff-add-highlight: ${eD(e.addHighlight)};`,`--diff-del-highlight: ${eD(e.delHighlight)};`,`--diff-text: ${eD(e.text)};`,`--diff-add-line-num: ${eD(e.addLineNum)};`,`--diff-del-line-num: ${eD(e.delLineNum)};`,`--diff-context-line-num: ${eD(e.contextLineNum)};`,`--diff-add-symbol: ${eD(e.addSymbol)};`,`--diff-del-symbol: ${eD(e.delSymbol)};`]}function nD(e){return[`--bg: ${e.bg};`,`--surface: ${e.surface};`,`--surface-raised: ${e.surfaceRaised};`,`--border: ${e.border};`,`--text: ${e.text};`,`--text-dim: ${e.textDim};`,`--accent: ${e.accent};`,`--selection: ${e.selection};`,`--add: ${e.add};`,`--del: ${e.del};`,`--warn: ${e.warn};`,`--status-modified: ${e.statusModified};`,`--status-added: ${e.statusAdded};`,`--status-deleted: ${e.statusDeleted};`,`--status-untracked: ${e.statusUntracked};`,`--status-renamed: ${e.statusRenamed};`,`--status-copied: ${e.statusCopied};`,`--status-conflicted: ${e.statusConflicted};`,`--uncommitted: ${e.uncommitted};`,`--flash: ${e.flash};`]}function rD(e){return[`--syn-keyword: ${e.keyword};`,`--syn-string: ${e.string};`,`--syn-comment: ${e.comment};`,`--syn-number: ${e.number};`,`--syn-literal: ${e.literal};`,`--syn-title: ${e.title};`,`--syn-attr: ${e.attr};`,`--syn-meta: ${e.meta};`]}function iD(e){let t=[`color-scheme: ${e.scheme};`,...nD(e.chrome),...tD(e.colors),...rD(e.syntax)];return`:root[data-theme='${e.name}'] {\n ${t.join(`
|
|
26
26
|
`)}\n}`}function aD(){return Kc.map(e=>iD(Jc[e])).join(`
|
|
27
27
|
|
|
28
28
|
`)+`
|