diff --git a/lib/client.js b/lib/client.js index 35ffc4a..a234030 100644 --- a/lib/client.js +++ b/lib/client.js @@ -990,7 +990,7 @@ color: var(--dsw-alias-state-business-primary, #3e63dd); `)?` `:``}`;return{value:i+o+a,cursor:i.length+o.length}}function Me(e){return Array.from(e).filter(e=>Oe.has(e.type)).slice(0,10)}function Ne(e){return[`backlog`,`todo`,`in_progress`,`in_review`,`done`,`canceled`,`archived`].filter(t=>x(e.status,t))}function Z(e){return e===void 0?``:e.replace(/^session-(taskboard-)?/,``).slice(0,8)}function Pe(e,t){if(t.systemKey===void 0)return t.body;if(t.systemRows!==void 0){let n=t.systemRows.map(t=>{let n=t.repo===``?e(`iso.repo.root`):t.repo,r=t.outcome===`merged`?`✓`:t.outcome===`noop`?`⟲`:`✗`;return t.outcome===`failed`&&t.error!==void 0?`${n} ${r} ${t.error}`:`${n} ${r}`}).join(` · `);return e(t.systemKey,{summary:n})}return e(t.systemKey,t.systemParams)}function Fe(e,t){if(e===void 0||t===void 0)return``;let n=Math.max(0,Math.round((t-e)/1e3));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m${n%60}s`:`${Math.floor(n/3600)}h${Math.floor(n%3600/60)}m`}function Q({icon:e,children:t,tone:n,title:r}){return(0,l.jsxs)(`span`,{className:`dsh-atb-chip2`,"data-tone":n,title:r,children:[e!==void 0&&(0,l.jsx)(`span`,{className:`dsh-atb-chip2-icon`,children:e}),t]})}function Ie({text:e}){let t=W(),[n,r]=(0,c.useState)(null),i=/!\[(.*?)\]\(((?:data:image\/[^)]+)|(?:https?:\/\/[^)]+)|(?:[^)]+\.(?:png|jpg|jpeg|gif|webp|svg)))\)/gi,a=[],o=0,s,u=0;for(;(s=i.exec(e))!==null;){s.index>o&&a.push((0,l.jsx)(`span`,{children:e.slice(o,s.index)},`txt-${o}`));let n=s[1]||t(`md.imageAlt`,{n:++u}),c=s[2]??``;a.push((0,l.jsxs)(`div`,{className:`dsh-atb-detail-img-wrap`,children:[(0,l.jsx)(`img`,{src:c,alt:n,className:`dsh-atb-detail-img`,onClick:()=>r(c),title:t(`md.imageTitle`,{alt:n})}),(0,l.jsx)(`span`,{className:`dsh-atb-detail-img-caption`,children:n})]},`img-${s.index}`)),o=i.lastIndex}return or(null),children:(0,l.jsxs)(`div`,{className:`dsh-atb-lightbox-content`,onClick:e=>e.stopPropagation(),children:[(0,l.jsx)(`img`,{src:n,alt:t(`md.lightboxAlt`),className:`dsh-atb-lightbox-img`}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-lightbox-close`,title:t(`md.closePreview`),onClick:()=>r(null),children:`✕`})]})})]})}function Le(e){return[...e.executions].reverse().find(e=>e.isolation!==void 0||e.worktreePath!==void 0||e.isolationNote!==void 0)}function Re(e){return e===void 0?``:e.slice(0,8)}function ze(e){let t=e.slice(3),n=t.indexOf(` -> `);return n>=0&&(t=t.slice(n+4)),t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>1&&(t=t.slice(1,-1)),t}function Be({controller:e,task:t,execution:n,commit:r,path:i,repo:a}){let o=W(),[s,u]=(0,c.useState)({loading:!0});return(0,c.useEffect)(()=>{let o=!0;return u({loading:!0}),e.fetchDiff(t.id,{execution:n.id,...r===void 0?{path:i??``}:{commit:r},...a===void 0?{}:{repo:a}}).then(e=>{o&&u(e===void 0?{loading:!1,failed:!0}:{loading:!1,diff:e.diff,truncated:e.truncated})}),()=>{o=!1}},[e,t.id,n.id,r,i,a]),(0,l.jsxs)(`div`,{className:`dsh-atb-diffview`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diffview-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-diffview-title`,children:r===void 0?o(`diff.file`,{path:i??``}):o(`diff.commit`,{hash:Re(r)})}),s.loading&&(0,l.jsx)(`span`,{className:`dsh-atb-diffview-hint`,children:o(`shared.loading`)}),s.truncated===!0&&(0,l.jsx)(`span`,{className:`dsh-atb-diffview-hint`,children:o(`diff.truncated`)})]}),s.failed===!0?(0,l.jsx)(`div`,{className:`dsh-atb-diffview-error`,children:o(`diff.failed`)}):(0,l.jsx)(`pre`,{className:`dsh-atb-diffview-pre`,children:s.diff??``})]})}function Ve({task:e,controller:t}){let n=W(),r=e.checklist??[];if(r.length===0)return null;let{done:i,total:a}=j(e),o=a-i,s=e.status===`in_review`;return(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard`,"data-kind":`checklist`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard-label`,children:[n(`checklist.title`),(0,l.jsxs)(`span`,{className:`dsh-atb-cl-progress`,"data-tone":s&&o>0?`bad`:void 0,children:[`☑ `,i,`/`,a,s&&o>0?n(`checklist.unchecked`,{n:o}):i===a?n(`checklist.allDone`):``]})]}),(0,l.jsx)(`div`,{className:`dsh-atb-cl-items`,children:r.map(r=>(0,l.jsxs)(`label`,{className:`dsh-atb-cl-item`,"data-checked":r.checked?`true`:void 0,"data-alert":s&&!r.checked?`true`:void 0,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:r.checked,onChange:()=>void t.toggleChecklistItem(e,r.id)}),(0,l.jsx)(`span`,{className:`dsh-atb-cl-text`,children:r.text}),(0,l.jsxs)(`span`,{className:`dsh-atb-cl-meta`,children:[r.checked?`${r.checkedBy===`user`?n(`checklist.byUser`):`🤖 ${Z(r.checkedBy)}`} · ${J(r.checkedAt)}`:n(`checklist.uncheckedItem`),r.note!==void 0&&r.note.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-cl-note`,title:r.note,children:n(`checklist.evidence`,{note:r.note})})]})]},r.id))})]})}function He({task:e}){let t=W(),n=[...e.executions].reverse().find(e=>e.report!==void 0),r=n?.report;if(n===void 0||r===void 0)return null;let i=(e,t)=>t!==void 0&&t.length>0?(0,l.jsxs)(`div`,{className:`dsh-atb-rpt-sec`,children:[(0,l.jsx)(`div`,{className:`dsh-atb-rpt-label`,children:e}),(0,l.jsx)(`ul`,{className:`dsh-atb-rpt-list`,children:t.map((e,t)=>(0,l.jsx)(`li`,{children:e},t))})]}):null;return(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard`,"data-kind":`report`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard-label`,children:[t(`report.title`),(0,l.jsx)(`span`,{className:`dsh-atb-cl-progress`,children:t(`report.submitted`,{time:J(n.endedAt??n.startedAt)})})]}),(0,l.jsx)(`div`,{className:`dsh-atb-rpt-summary`,children:r.summary}),i(t(`report.changedFiles`),r.changedFiles),i(t(`report.checks`),r.checks),i(t(`report.artifacts`),r.artifacts),r.risk.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-rpt-sec`,children:[(0,l.jsx)(`div`,{className:`dsh-atb-rpt-label`,children:t(`report.risk`)}),(0,l.jsx)(`div`,{className:`dsh-atb-rpt-risk`,children:r.risk})]})]})}function Ue({task:e,controller:t}){let n=W(),{alert:r,el:i}=X(),[a,o]=(0,c.useState)(!1),[s,u]=(0,c.useState)(null),[d,f]=(0,c.useState)(!1),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),_=Le(e),v=e.executions.some(e=>e.outcome===`running`);if(_===void 0)return null;let y=()=>{f(!0),t.mergeBranch(e.id).then(e=>{if(f(!1),o(!1),!e.ok)r(n(`iso.merge.failed`,{error:e.error}));else if(e.results!==void 0){let t=e=>e===``?n(`iso.repo.root`):e,i=e.results.map(e=>`${t(e.repo)} ${e.outcome===`merged`?`✓`:e.outcome===`noop`?`⟲`:`✗`}`).join(` · `),a=e.results.some(e=>e.outcome===`failed`),o=e.results.find(e=>e.outcome===`failed`)?.error;r(a?n(`iso.merge.partial`,{summary:i,error:o??``}):n(`iso.merge.done`,{summary:i}))}else e.noop===!0&&r(n(`iso.merge.noop`))})},b=i=>{f(!0),t.removeWorktree(e.id,i).then(e=>{f(!1),u(null),e.ok?e.branchError!==void 0&&r(n(`iso.remove.branchFailed`,{error:e.branchError})):r(n(`iso.remove.failed`,{error:e.error}))})};if(_.isolation!==`worktree`||_.worktreePath===void 0)return(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard`,"data-kind":`isolation`,children:[(0,l.jsx)(`div`,{className:`dsh-atb-fieldcard-label`,children:n(`iso.title`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-iso-none`,children:[n(`iso.none`),_.isolationNote===void 0?``:` · ${_.isolationNote}`]}),i]});let x=_.repos!==void 0&&_.repos.length>0,S=x?(_.repos??[]).map(e=>({repo:e.repo,label:e.repo===``?n(`iso.repo.root`):e.repo,branch:e.branch,worktreePath:e.worktreePath,baseCommit:e.baseCommit,headCommit:e.headCommit,commits:e.commits??[],commitTotal:e.commitsTotal??(e.commits??[]).length,dirty:e.dirtyFiles??[],dirtyTotal:e.dirtyFilesTotal??(e.dirtyFiles??[]).length,...e.diffStat===void 0?{}:{diffStat:e.diffStat},...e.changedFiles===void 0?{}:{changedFiles:e.changedFiles}})):[{label:n(`iso.repo.root`),branch:_.branch??e.branch,worktreePath:_.worktreePath,baseCommit:_.baseCommit,headCommit:_.headCommit,commits:_.commits??[],commitTotal:_.commitsTotal??(_.commits??[]).length,dirty:_.dirtyFiles??[],dirtyTotal:_.dirtyFilesTotal??(_.dirtyFiles??[]).length,..._.diffStat===void 0?{}:{diffStat:_.diffStat},..._.changedFiles===void 0?{}:{changedFiles:_.changedFiles}}];return(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard`,"data-kind":`isolation`,children:[(0,l.jsx)(`div`,{className:`dsh-atb-fieldcard-label`,children:n(`iso.worktreeTitle`)}),S.map(r=>(0,l.jsxs)(`section`,{className:`dsh-atb-iso-repo`,"data-multi":x?`true`:void 0,children:[x&&(0,l.jsxs)(`div`,{className:`dsh-atb-iso-repohead`,title:r.worktreePath,children:[(0,l.jsx)(`code`,{children:r.label}),(0,l.jsxs)(`span`,{className:`dsh-atb-iso-fact`,children:[n(`iso.branch`),` `,(0,l.jsx)(`b`,{children:r.branch})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-iso-facts`,children:[!x&&(0,l.jsxs)(`span`,{className:`dsh-atb-iso-fact`,title:r.worktreePath,children:[n(`iso.branch`),` `,(0,l.jsx)(`b`,{children:r.branch})]}),(0,l.jsx)(`span`,{className:`dsh-atb-iso-fact`,children:n(`iso.baseline`,{base:Re(r.baseCommit),head:Re(r.headCommit)})}),r.changedFiles!==void 0&&r.changedFiles>0&&(0,l.jsx)(`span`,{className:`dsh-atb-iso-fact`,children:n(`iso.changed`,{n:r.changedFiles})}),r.diffStat!==void 0&&(0,l.jsx)(`span`,{className:`dsh-atb-iso-fact`,title:r.diffStat,children:r.diffStat})]}),r.commits.length>0?(0,l.jsxs)(`div`,{className:`dsh-atb-iso-commits`,children:[r.commits.slice(0,10).map(i=>(0,l.jsxs)(`div`,{className:`dsh-atb-iso-commit`,"data-open":p?.commit===i.hash&&p?.repo===r.repo?`true`:void 0,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-iso-commit-btn`,title:n(`iso.commit.openTitle`),onClick:()=>m(p?.commit===i.hash&&p?.repo===r.repo?null:{commit:i.hash,...r.repo===void 0?{}:{repo:r.repo}}),children:[(0,l.jsx)(`code`,{children:Re(i.hash)}),(0,l.jsx)(`span`,{children:i.subject})]}),p?.commit===i.hash&&p?.repo===r.repo&&(0,l.jsx)(Be,{controller:t,task:e,execution:_,commit:i.hash,repo:r.repo})]},i.hash)),r.commitTotal>10&&(0,l.jsx)(`div`,{className:`dsh-atb-iso-more`,children:n(`iso.commits.more`,{n:r.commitTotal})})]}):(0,l.jsx)(`div`,{className:`dsh-atb-iso-nocommit`,children:n(`iso.nocommit`)}),r.dirtyTotal>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-iso-dirty`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-iso-dirty-toggle`,onClick:()=>g(!h),children:[n(`iso.dirty.toggle`,{n:r.dirtyTotal}),n(h?`iso.dirty.collapse`:`iso.dirty.expand`)]}),h&&(0,l.jsxs)(`div`,{className:`dsh-atb-iso-dirty-files`,children:[r.dirty.slice(0,30).map((e,t)=>{let i=ze(e);return(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-iso-dirty-file`,title:n(`iso.dirty.openTitle`),onClick:()=>m(p?.path===i&&p?.repo===r.repo?null:{path:i,...r.repo===void 0?{}:{repo:r.repo}}),children:[(0,l.jsx)(`code`,{children:e.slice(0,2)}),` `,i]},`${e}-${t}`)}),r.dirtyTotal>30&&(0,l.jsx)(`div`,{className:`dsh-atb-iso-more`,children:n(`iso.dirty.more`,{n:r.dirtyTotal})})]}),p?.path!==void 0&&p?.repo===r.repo&&h&&(0,l.jsx)(Be,{controller:t,task:e,execution:_,path:p.path,repo:r.repo})]})]},r.repo??`root`)),(0,l.jsxs)(`div`,{className:`dsh-atb-iso-actions`,children:[v?(0,l.jsx)(`span`,{className:`dsh-atb-iso-hint`,children:n(`iso.hint.running`)}):a?(0,l.jsxs)(`span`,{className:`dsh-atb-confirm`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-confirm-label`,children:n(`iso.merge.confirm`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,disabled:d,onClick:y,children:n(`iso.merge.go`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>o(!1),children:n(`shared.cancel`)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:d,title:n(`iso.merge.title`),onClick:()=>o(!0),children:n(`iso.merge.button`)}),!v&&(s===null?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,disabled:d,title:n(`iso.remove.wtTitle`),onClick:()=>u(`wt`),children:n(`iso.remove.wt`)}),e.branch!==void 0&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,disabled:d,title:n(`iso.remove.wtbTitle`),onClick:()=>u(`wtb`),children:n(`iso.remove.wtb`)})]}):(0,l.jsxs)(`span`,{className:`dsh-atb-confirm`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-confirm-label`,children:n(s===`wtb`?`iso.remove.confirmWtb`:`iso.remove.confirmWt`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,disabled:d,onClick:()=>b(s===`wtb`),children:n(`shared.confirmDelete`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>u(null),children:n(`shared.cancel`)})]})),!v&&s===null&&!a&&(0,l.jsx)(`span`,{className:`dsh-atb-iso-hint`,children:n(`iso.hint.keep`)})]}),i]})}function We({task:e,controller:t,now:n}){let r=W(),[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(!1),u=(0,c.useRef)(null),d=(0,c.useRef)(null),[f,p]=(0,c.useState)(!1),[m,h]=(0,c.useState)(!1),[g,_]=(0,c.useState)(!1),[v,y]=(0,c.useState)(!1),[b,x]=(0,c.useState)(!1),{alert:S,el:ee}=X(),C=t.getSnapshot().workspaces.find(t=>t.id===e.workspaceId),w=e.status!==`in_progress`&&e.status!==`done`&&e.status!==`archived`,T=e.executions.find(e=>e.outcome===`running`),E=e.status===`in_progress`?e.claimedBy:void 0,te=n!==void 0&&Ce(e,n),D=(e.checklist??[]).filter(e=>!e.checked).length,ne=[...e.executions].reverse().find(e=>e.sessionId!==void 0),O=T?.sessionId??ne?.sessionId??(e.claimedBy?.startsWith(`session-`)?e.claimedBy:void 0),k=re(e),A=t.getSnapshot(),M=A.sessionArchive?.taskId===e.id?A.sessionArchive.result:void 0,N=e=>{b||(x(!0),e().catch(()=>void 0).finally(()=>x(!1)))},P=()=>{o||i.trim().length===0||t.comment(e.id,i).then(e=>{e&&a(``)})},F=async e=>{let n=Me(e);if(n.length===0||o)return;s(!0);let c=u.current,l=c?.value??i,d=c?.selectionStart??l.length,f=c?.selectionEnd??d,p=!1;try{for(let e of n){let n=await t.uploadImage(e);if(n===void 0)continue;let i=je(l,d,f,Ae(n,ke(e.name,r(`image.defaultAlt`))));l=i.value,d=i.cursor,f=d,p=!0}p&&(a(l),setTimeout(()=>{u.current?.focus(),u.current?.setSelectionRange(d,d)},0))}finally{s(!1)}},I=e=>{t.openSession(e).then(t=>{t===`missing`?S(r(`card.session.missing`,{id:Z(e)})):t===`archived`?S(r(`card.session.archived`,{id:Z(e)})):t===`unavailable`&&S(r(`card.session.unavailable`,{id:e}))})};return(0,l.jsxs)(`div`,{className:`dsh-atb-detail`,"data-urgency":e.urgency,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-detail-head`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-detail-titlewrap`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-detail-titlebar`,children:[(0,l.jsx)(`h3`,{children:e.title}),(0,l.jsx)(`span`,{className:`dsh-atb-statuspill`,"data-status":e.status,children:r(_e[e.status]??e.status)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-detail-chips`,children:[(0,l.jsxs)(Q,{tone:e.urgency,children:[`● `,r(G[e.urgency]??e.urgency)]}),(0,l.jsx)(Q,{icon:`📁`,children:C?.title??Z(e.workspaceId)}),e.model!==void 0&&(0,l.jsxs)(Q,{icon:`✦`,title:r(`card.badge.modelTitle`,{model:e.model.provider+`/`+e.model.model})+(e.model.reasoningEffort===void 0?``:r(`card.badge.modelEffort`,{effort:e.model.reasoningEffort})),children:[e.model.model,e.model.reasoningEffort===void 0?``:` · ${e.model.reasoningEffort}`]}),e.presetId!==void 0&&(0,l.jsx)(Q,{icon:`🎛`,children:e.presetId}),e.execution.mode===`scheduled`&&(0,l.jsx)(Q,{icon:`⏰`,children:r(`detail.chip.nextRun`,{cron:e.execution.cron??``,time:J(e.execution.nextRunAt)})}),e.execution.queuedRunAt!==void 0&&(0,l.jsx)(Q,{icon:`⏳`,tone:`urgent`,children:r(`detail.chip.queuedRun`,{time:J(e.execution.queuedRunAt)})}),e.blocked&&(0,l.jsx)(Q,{icon:`⛔`,tone:`urgent`,children:r(`shared.blocked`)}),e.checklist!==void 0&&e.checklist.length>0&&(0,l.jsx)(Q,{icon:`☑`,tone:e.status===`in_review`&&e.checklist.some(e=>!e.checked)?`urgent`:void 0,children:r(`detail.chip.checklist`,{done:j(e).done,total:e.checklist.length})}),e.branch!==void 0&&(0,l.jsxs)(Q,{icon:`🌿`,tone:void 0,children:[`Worktree · `,e.branch.length>28?`${e.branch.slice(0,28)}…`:e.branch]}),(e.isolation===void 0||e.isolation===`worktree`)&&e.branch===void 0&&(0,l.jsx)(Q,{icon:`🌿`,children:r(`detail.chip.isolated`)}),e.permission===`read-only`&&(0,l.jsx)(Q,{icon:`🔒`,tone:`urgent`,children:r(`detail.chip.permReadOnly`)}),e.permission===`danger-full-access`&&(0,l.jsx)(Q,{icon:`⚡`,tone:`urgent`,children:r(`detail.chip.permFull`)}),(e.permission===`workspace-write`||e.permission===void 0)&&(0,l.jsx)(Q,{icon:`📁`,children:r(`detail.chip.permWrite`)}),E!==void 0&&(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-chip2 dsh-atb-chip-btn`,"data-tone":te?`urgent`:void 0,title:r(`detail.chip.holderTitle`,{id:E}),onClick:()=>I(E),children:[(0,l.jsx)(`span`,{className:`dsh-atb-chip2-icon`,children:te?`⏱`:`🤖`}),r(te?`detail.chip.holderStale`:`detail.chip.holderBy`),Z(E),r(`detail.chip.holderSuffix`)]}),e.trashedAt!==void 0&&(0,l.jsx)(Q,{icon:`🗑`,tone:`urgent`,children:r(`detail.chip.trashed`)}),(0,l.jsxs)(Q,{children:[`v`,e.version]})]}),(0,l.jsx)(`div`,{className:`dsh-atb-detail-sub`,children:r(`detail.sub.line`,{time:J(e.updatedAt),who:e.updatedBy.kind===`agent`?`🤖 ${Z(e.updatedBy.sessionId)}`:e.updatedBy.kind===`system`?r(`detail.updatedBy.system`):r(`detail.updatedBy.user`)})})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-detail-topbtns`,children:[O!==void 0&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-session`,title:r(`detail.session.jumpTitle`,{id:O}),onClick:()=>I(O),children:r(`detail.session.jump`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-edit`,onClick:()=>t.openEditor(e.id),children:r(`detail.action.edit`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-edit`,title:r(`detail.action.duplicateTitle`),disabled:b,onClick:()=>N(()=>t.duplicate(e)),children:r(`detail.action.duplicate`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-edit`,title:r(`detail.action.saveTplTitle`),disabled:b,onClick:()=>N(async()=>{await t.saveAsTemplate(e)&&S(r(`detail.action.saveTplDone`))}),children:r(`detail.action.saveTpl`)}),w&&e.branch!==void 0&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-run`,title:r(`detail.action.reuseTitle`),disabled:b,onClick:()=>N(()=>t.run(e.id,!0)),children:r(`detail.action.reuse`)}),w&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-run`,title:e.model===void 0?r(`detail.action.runTitleDefault`):r(`detail.action.runTitleModel`,{model:e.model.model}),disabled:b,onClick:()=>N(()=>t.run(e.id)),children:r(`detail.action.run`)}),T!==void 0&&(g?(0,l.jsxs)(`span`,{className:`dsh-atb-confirm`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-confirm-label`,children:r(`detail.action.stopConfirm`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>{t.cancel(e.id),_(!1)},children:r(`detail.action.stop`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>_(!1),children:r(`shared.cancel`)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-run`,"data-danger":`true`,title:r(`detail.action.stopTitle`,{id:T.sessionId??``}),onClick:()=>_(!0),children:r(`detail.action.stopExec`)})),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-detail-close`,"aria-label":r(`shared.close`),onClick:()=>t.select(void 0),children:`✕`})]})]}),e.description.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard`,children:[(0,l.jsx)(`div`,{className:`dsh-atb-fieldcard-label`,children:r(`detail.field.description`)}),(0,l.jsx)(`div`,{className:`dsh-atb-desc`,children:(0,l.jsx)(Ie,{text:e.description})})]}),e.prompt.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-fieldcard`,"data-kind":`prompt`,children:[(0,l.jsx)(`div`,{className:`dsh-atb-fieldcard-label`,children:r(`detail.field.prompt`)}),(0,l.jsx)(`div`,{className:`dsh-atb-promptbox`,children:(0,l.jsx)(Ie,{text:e.prompt})})]}),(0,l.jsx)(Ue,{task:e,controller:t}),(0,l.jsx)(He,{task:e}),(0,l.jsx)(Ve,{task:e,controller:t}),M!==void 0&&(0,l.jsxs)(`div`,{role:`status`,className:`dsh-atb-confirm`,children:[(0,l.jsx)(`span`,{children:r(`detail.move.archiveResult`,{n:M.archived.length})}),M.failed.map(e=>(0,l.jsxs)(`span`,{children:[e.sessionId,`: `,e.error]},e.sessionId)),M.unsupported.length>0&&(0,l.jsxs)(`span`,{children:[r(`detail.move.archiveUnsupported`),` `,M.unsupported.join(`, `)]})]}),e.status===`archived`&&k.length>0&&A.archiveSessionsSupported&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:b,onClick:()=>N(()=>t.retryArchiveSessions(e.id)),children:r(`detail.move.archiveRetry`)}),(0,l.jsx)(`div`,{className:`dsh-atb-detail-actions`,children:(0,l.jsxs)(`div`,{className:`dsh-atb-movebtns`,children:[Ne(e).map(n=>n===`done`?f?(0,l.jsxs)(`span`,{className:`dsh-atb-confirm`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-confirm-label`,"data-tone":D>0?`bad`:void 0,children:D>0?r(`detail.move.confirmDoneUnchecked`,{n:D}):r(`detail.move.confirmDone`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,onClick:()=>{t.move(e.id,e.version,`done`),p(!1)},children:r(`detail.move.confirm`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>p(!1),children:r(`shared.cancel`)})]},n):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-movebtn`,"data-to":n,onClick:()=>{p(!0),y(!1)},children:r(`detail.move.to`,{status:r(ve[n])})},n):n===`archived`?v?(0,l.jsxs)(`span`,{className:`dsh-atb-confirm`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-confirm-label`,children:k.length===1?r(`detail.move.confirmArchiveSessionWithId`,{id:Z(k[0])}):k.length>1?r(`detail.move.confirmArchiveSessionCount`,{n:k.length}):r(`detail.move.confirmArchive`)}),k.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-confirm-label`,children:k.join(`, `)}),k.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:!A.archiveSessionsSupported||b,title:A.archiveSessionsSupported?void 0:r(`detail.move.archiveUnsupported`),onClick:()=>{N(()=>t.move(e.id,e.version,`archived`,{archiveSessions:!0})),y(!1)},children:r(`detail.move.archiveWithSession`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>{N(()=>t.move(e.id,e.version,`archived`,{archiveSessions:!1})),y(!1)},children:r(`detail.move.archiveCardOnly`)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,onClick:()=>{t.move(e.id,e.version,`archived`),y(!1)},children:r(`detail.move.confirm`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>y(!1),children:r(`shared.cancel`)})]},n):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-movebtn`,"data-to":n,onClick:()=>{y(!0),p(!1)},children:r(`detail.move.to`,{status:r(ve[n])})},n):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-movebtn`,"data-to":n,onClick:()=>void t.move(e.id,e.version,n),children:r(`detail.move.to`,{status:r(ve[n])})},n)),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-movebtn`,"data-to":`blocked`,onClick:()=>void t.toggleBlocked(e),children:e.blocked?r(`detail.blocked.unmark`):r(`detail.blocked.mark`)}),E!==void 0&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-movebtn`,"data-to":`release`,title:r(`detail.release.title`,{id:E}),onClick:()=>void t.move(e.id,e.version,`todo`),children:r(`detail.release.button`)})]})}),(0,l.jsxs)(`div`,{className:`dsh-atb-section`,children:[(0,l.jsxs)(`h4`,{children:[r(`detail.comments.title`),e.comments.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-count2`,children:e.comments.length})]}),e.comments.length===0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:r(`detail.comments.empty`)}):(0,l.jsx)(`div`,{className:`dsh-atb-commentlist`,children:e.comments.map(e=>(0,l.jsxs)(`div`,{className:`dsh-atb-bubble`,"data-from":e.threadId===void 0?`user`:`agent`,children:[(0,l.jsx)(`div`,{className:`dsh-atb-bubble-avatar`,children:e.threadId===void 0?`👤`:`🤖`}),(0,l.jsxs)(`div`,{className:`dsh-atb-bubble-main`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-bubble-meta`,children:[(0,l.jsx)(`b`,{children:e.threadId===void 0?r(`detail.comments.user`):`agent ${Z(e.threadId)}`}),(0,l.jsx)(`span`,{children:J(e.createdAt)})]}),(0,l.jsx)(`div`,{className:`dsh-atb-bubble-body`,children:(0,l.jsx)(Ie,{text:Pe(r,e)})})]})]},e.id))}),(0,l.jsxs)(`div`,{className:`dsh-atb-composer`,children:[(0,l.jsx)(`textarea`,{ref:u,className:`dsh-atb-composer-input`,value:i,placeholder:r(`detail.composer.placeholder`),disabled:o,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&i.trim().length>0&&!o&&P()},onPaste:e=>{let t=Me(e.clipboardData.files);t.length>0&&(e.preventDefault(),F(t))},onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{let t=Me(e.dataTransfer.files);t.length>0&&(e.preventDefault(),F(t))}}),(0,l.jsx)(`input`,{ref:d,type:`file`,accept:De,multiple:!0,hidden:!0,onChange:e=>{e.target.files!==null&&F(e.target.files),e.target.value=``}}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-image-add`,disabled:o,title:r(`image.add`),onClick:()=>d.current?.click(),children:o?`…`:`🖼`}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-composer-send`,disabled:i.trim().length===0||o,onClick:P,children:r(`detail.composer.send`)})]})]}),e.executions.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-section`,children:[(0,l.jsxs)(`h4`,{children:[r(`detail.exec.title`),(0,l.jsx)(`span`,{className:`dsh-atb-count2`,children:e.executions.length}),e.executionsPruned!==void 0&&e.executionsPruned>0&&(0,l.jsx)(`span`,{className:`dsh-atb-count2`,title:r(`detail.exec.prunedTitle`,{n:e.executionsPruned}),children:r(`detail.exec.pruned`,{n:e.executionsPruned})})]}),(0,l.jsx)(`div`,{className:`dsh-atb-execlist`,children:[...e.executions].reverse().map(e=>(0,l.jsxs)(`div`,{className:`dsh-atb-exec-row`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-exec-dot`,"data-outcome":e.outcome}),(0,l.jsx)(`span`,{className:`dsh-atb-exec-trigger`,children:e.trigger===`manual`?r(`detail.exec.trigger.manual`):r(`detail.exec.trigger.scheduled`)}),(0,l.jsx)(`span`,{className:`dsh-atb-exec-outcome`,"data-outcome":e.outcome,children:r(ye[e.outcome]??e.outcome)}),(0,l.jsxs)(`span`,{className:`dsh-atb-exec-time`,children:[J(e.startedAt),e.endedAt!==void 0&&` · ${Fe(e.startedAt,e.endedAt)}`]}),e.sessionId!==void 0&&(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-exec-session`,title:r(`detail.exec.openTitle`,{id:e.sessionId}),onClick:()=>I(e.sessionId),children:[`🤖 `,Z(e.sessionId),` ↗`]}),e.error!==void 0&&(0,l.jsxs)(`span`,{className:`dsh-atb-exec-error`,title:e.error,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]},e.id))})]}),(0,l.jsx)(`div`,{className:`dsh-atb-dangerzone`,children:e.trashedAt===void 0?(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>void t.remove(e.id,e.version,!1),children:r(`detail.danger.delete`)}):m?(0,l.jsxs)(`span`,{className:`dsh-atb-confirm`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-confirm-label`,children:r(`detail.danger.purgeConfirm`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>{t.remove(e.id,e.version,!0),h(!1)},children:r(`detail.danger.purgeGo`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>h(!1),children:r(`shared.cancel`)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>h(!0),children:r(`detail.danger.purge`)})}),ee]})}const Ge=e=>[{name:`goal`,kind:`command`,description:e(`slash.cmd.goal.desc`),hint:e(`slash.cmd.goal.hint`)},{name:`schedule`,kind:`command`,description:e(`slash.cmd.schedule.desc`),hint:e(`slash.cmd.schedule.hint`)},{name:`plan`,kind:`command`,description:e(`slash.cmd.plan.desc`)},{name:`browser`,kind:`command`,description:e(`slash.cmd.browser.desc`)},{name:`grill-me`,kind:`command`,description:e(`slash.cmd.grill-me.desc`)},{name:`teamwork-preview`,kind:`command`,description:e(`slash.cmd.teamwork-preview.desc`)},{name:`learn`,kind:`command`,description:e(`slash.cmd.learn.desc`)},{name:`review`,kind:`command`,description:e(`slash.cmd.review.desc`)},{name:`security`,kind:`command`,description:e(`slash.cmd.security.desc`)},{name:`permission`,kind:`command`,description:e(`slash.cmd.permission.desc`),hint:e(`slash.cmd.permission.hint`)}],Ke=e=>[{name:`frontend-ui-engineering`,kind:`skill`,description:e(`slash.skill.frontend-ui-engineering`)},{name:`api-and-interface-design`,kind:`skill`,description:e(`slash.skill.api-and-interface-design`)},{name:`test-driven-development`,kind:`skill`,description:e(`slash.skill.test-driven-development`)},{name:`debugging-and-error-recovery`,kind:`skill`,description:e(`slash.skill.debugging-and-error-recovery`)},{name:`performance-optimization`,kind:`skill`,description:e(`slash.skill.performance-optimization`)},{name:`ci-cd-and-automation`,kind:`skill`,description:e(`slash.skill.ci-cd-and-automation`)},{name:`code-review-and-quality`,kind:`skill`,description:e(`slash.skill.code-review-and-quality`)},{name:`code-simplification`,kind:`skill`,description:e(`slash.skill.code-simplification`)},{name:`context-engineering`,kind:`skill`,description:e(`slash.skill.context-engineering`)},{name:`doubt-driven-development`,kind:`skill`,description:e(`slash.skill.doubt-driven-development`)},{name:`git-workflow-and-versioning`,kind:`skill`,description:e(`slash.skill.git-workflow-and-versioning`)},{name:`idea-refine`,kind:`skill`,description:e(`slash.skill.idea-refine`)},{name:`incremental-implementation`,kind:`skill`,description:e(`slash.skill.incremental-implementation`)},{name:`interview-me`,kind:`skill`,description:e(`slash.skill.interview-me`)},{name:`memory-leak-debugging`,kind:`skill`,description:e(`slash.skill.memory-leak-debugging`)},{name:`observability-and-instrumentation`,kind:`skill`,description:e(`slash.skill.observability-and-instrumentation`)},{name:`planning-and-task-breakdown`,kind:`skill`,description:e(`slash.skill.planning-and-task-breakdown`)},{name:`security-and-hardening`,kind:`skill`,description:e(`slash.skill.security-and-hardening`)},{name:`shipping-and-launch`,kind:`skill`,description:e(`slash.skill.shipping-and-launch`)},{name:`source-driven-development`,kind:`skill`,description:e(`slash.skill.source-driven-development`)},{name:`spec-driven-development`,kind:`skill`,description:e(`slash.skill.spec-driven-development`)},{name:`using-agent-skills`,kind:`skill`,description:e(`slash.skill.using-agent-skills`)}];function qe({value:e,onChange:t,controller:n,placeholder:r,rows:i=4,maxLength:a=8e3,disabled:o=!1,autoFocus:s=!1,className:d,ariaLabel:f,allowImages:p=!1,onUploadingChange:m}){let h=W(),g=(0,c.useRef)(null),_=(0,c.useRef)(null),v=(0,c.useRef)(null),y=(0,c.useRef)(null),[b,x]=(0,c.useState)({}),[S,ee]=(0,c.useState)(void 0),C=(0,c.useMemo)(()=>{let e=(e,t)=>{let n=new Map;for(let t of e)n.set(t.name,t);for(let e of t??[])n.set(e.name,e);return Array.from(n.values())};return{commands:e(Ge(h),S?.commands),skills:e(Ke(h),S?.skills)}},[h,S]),[w,T]=(0,c.useState)(!1),[E,te]=(0,c.useState)(``),[D,ne]=(0,c.useState)(-1),[O,k]=(0,c.useState)(0),[A,re]=(0,c.useState)(!1),j=async r=>{let i=Me(r);if(!p||n===void 0||i.length===0||A)return;re(!0),m?.(!0);let a=g.current,o=a?.value??e,s=a?.selectionStart??o.length,c=a?.selectionEnd??s,l=!1;try{for(let e of i){let t=await n.uploadImage(e);if(t===void 0)continue;let r=je(o,s,c,Ae(t,ke(e.name,h(`image.defaultAlt`))));o=r.value,s=r.cursor,c=s,l=!0}l&&(t(o),setTimeout(()=>{g.current?.focus(),g.current?.setSelectionRange(s,s)},0))}finally{re(!1),m?.(!1)}};(0,c.useEffect)(()=>{if(n===void 0)return;let e=!0;return n.fetchPromptCompletions().then(t=>{!e||t===void 0||ee({commands:t.commands.map(e=>({...e,kind:`command`})),skills:t.skills.map(e=>({...e,kind:`skill`}))})}),()=>{e=!1}},[n]);let M=(0,c.useMemo)(()=>{let e=E.toLowerCase().trim(),t=[...C.commands,...C.skills];return e.length===0?t:t.filter(t=>t.name.toLowerCase().includes(e)||t.description!==void 0&&t.description.toLowerCase().includes(e))},[C,E]);(0,c.useEffect)(()=>{O>=M.length&&k(Math.max(0,M.length-1))},[M.length,O]),(0,c.useLayoutEffect)(()=>{if(!w)return;let e=v.current,t=e?.children[O];if(e===null||!(t instanceof HTMLElement))return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.topn.bottom&&(e.scrollTop+=r.bottom-n.bottom)},[w,O,M]);let N=()=>{let e=g.current;if(e===null)return;let t=e.selectionStart,n=e.value.slice(0,t),r=n.lastIndexOf(`/`);if(r>=0){let e=r>0?n[r-1]??` `:` -`,t=/\s/.test(e)||r===0,i=n.slice(r+1),a=!/\s/.test(i);if(t&&a){ne(r),te(i),T(!0);return}}T(!1)},P=n=>{let r=g.current;if(r===null||D<0)return;let i=r.selectionStart,a=e.slice(0,D),o=e.slice(i),s=`/${n.name} `;t(a+s+o),T(!1),setTimeout(()=>{if(g.current!==null){let e=D+s.length;g.current.focus(),g.current.setSelectionRange(e,e)}},0)},F=e=>{if(w&&M.length>0){if(e.key===`ArrowDown`){e.preventDefault(),k(e=>(e+1)%M.length);return}if(e.key===`ArrowUp`){e.preventDefault(),k(e=>(e-1+M.length)%M.length);return}if(e.key===`Enter`||e.key===`Tab`){let t=M[O];if(t!==void 0){e.preventDefault(),P(t);return}}if(e.key===`Escape`){e.preventDefault(),T(!1);return}}},I=(0,c.useCallback)(()=>{let e=g.current;if(e===null)return;let t=e.getBoundingClientRect(),n=window.innerHeight,r=_.current?.offsetHeight??0,i=r>0?r:240,a=t.top-6-8,o=n-8-(t.bottom+6),s=o>a,c=Math.min(i,Math.max(s?o:a,120)),l=s?t.bottom+6:t.top-6-c;x(e=>e.left===t.left&&e.top===l&&e.width===t.width&&e.maxHeight===c?e:{position:`fixed`,left:t.left,top:l,width:t.width,maxHeight:c,zIndex:100})},[]);return(0,c.useLayoutEffect)(()=>{w&&I()}),(0,c.useEffect)(()=>{if(w)return window.addEventListener(`scroll`,I,!0),window.addEventListener(`resize`,I),()=>{window.removeEventListener(`scroll`,I,!0),window.removeEventListener(`resize`,I)}},[w,I]),(0,l.jsxs)(`div`,{className:`dsh-atb-prompt-wrap ${d??``}`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-prompt-inner`,children:[(0,l.jsx)(`textarea`,{ref:g,className:`dsh-atb-prompt-input`,value:e,rows:i,maxLength:a,disabled:o||A,autoFocus:s,placeholder:r,"aria-label":f,onChange:e=>{t(e.target.value),N()},onKeyUp:N,onClick:N,onKeyDown:F,onPaste:e=>{let t=Me(e.clipboardData.files);p&&t.length>0&&(e.preventDefault(),j(t))},onDragOver:e=>{p&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{let t=Me(e.dataTransfer.files);p&&t.length>0&&(e.preventDefault(),j(t))}}),w&&M.length>0&&(0,u.createPortal)((0,l.jsxs)(`div`,{ref:_,className:`dsh-atb-slash-popup`,style:b,role:`listbox`,"aria-label":h(`slash.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-slash-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-slash-title`,children:h(`slash.title`)}),(0,l.jsx)(`span`,{className:`dsh-atb-slash-hint`,children:h(`slash.hint`)})]}),(0,l.jsx)(`div`,{ref:v,className:`dsh-atb-slash-list`,children:M.map((e,t)=>(0,l.jsxs)(`div`,{role:`option`,"aria-selected":t===O,className:`dsh-atb-slash-item`,"data-active":t===O?`true`:void 0,"data-kind":e.kind,onClick:()=>P(e),onMouseEnter:()=>k(t),children:[(0,l.jsx)(`span`,{className:`dsh-atb-slash-badge`,"data-kind":e.kind,children:e.kind===`command`?h(`slash.badge.command`):h(`slash.badge.skill`)}),(0,l.jsxs)(`span`,{className:`dsh-atb-slash-name`,children:[`/`,e.name]}),e.hint&&(0,l.jsx)(`span`,{className:`dsh-atb-slash-param`,children:e.hint}),e.description&&(0,l.jsx)(`span`,{className:`dsh-atb-slash-desc`,children:e.description})]},`${e.kind}-${e.name}`))})]}),document.body)]}),p&&(0,l.jsxs)(`div`,{className:`dsh-atb-image-actions`,children:[(0,l.jsx)(`input`,{ref:y,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,multiple:!0,hidden:!0,onChange:e=>{e.target.files!==null&&j(e.target.files),e.target.value=``}}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-image-add`,disabled:o||A,onClick:()=>y.current?.click(),children:h(A?`image.uploading`:`image.add`)}),(0,l.jsx)(`span`,{className:`dsh-atb-image-hint`,children:h(`image.hint`)})]}),(0,l.jsx)(`div`,{className:`dsh-atb-prompt-foot`,children:(0,l.jsxs)(`span`,{className:`dsh-atb-prompt-tip`,children:[h(`slash.tipA`),` `,(0,l.jsx)(`code`,{children:`/`}),` `,h(`slash.tipB`)]})})]})}const Je=`dsh-taskboard-last-model-v1`;function Ye(){try{let e=localStorage.getItem(Je);if(e===null)return;let t=JSON.parse(e);if(typeof t==`object`&&t){let{provider:e,model:n,reasoningEffort:r}=t;if(typeof e==`string`&&typeof n==`string`&&e.trim().length>0&&n.trim().length>0)return{provider:e.trim(),model:n.trim(),...typeof r==`string`&&r.trim().length>0?{reasoningEffort:r.trim()}:{}}}return}catch{return}}function Xe(e){try{e===void 0?localStorage.removeItem(Je):localStorage.setItem(Je,JSON.stringify(e))}catch{}}const Ze=e=>[{value:`urgent`,label:e(`form.urgency.urgent`),hint:e(`form.urgency.urgentHint`)},{value:`normal`,label:e(`form.urgency.normal`),hint:e(`form.urgency.normalHint`)},{value:`relaxed`,label:e(`form.urgency.relaxed`),hint:e(`form.urgency.relaxedHint`)}],Qe=e=>[{label:e(`form.cron.daily`),cron:`0 9 * * *`},{label:e(`form.cron.hourly`),cron:`0 * * * *`},{label:e(`form.cron.every10min`),cron:`*/10 * * * *`},{label:e(`form.cron.weekly`),cron:`0 9 * * 1`}],$e=e=>[{value:`workspace-write`,label:e(`form.perm.write`),hint:e(`form.perm.writeHint`),icon:`📁`},{value:`read-only`,label:e(`form.perm.readOnly`),hint:e(`form.perm.readOnlyHint`),icon:`🔒`},{value:`danger-full-access`,label:e(`form.perm.fullAccess`),hint:e(`form.perm.fullAccessHint`),icon:`⚡`}];function $({label:e,required:t=!1,full:n=!1,children:r}){return(0,l.jsxs)(`label`,{className:`dsh-atb-field`,"data-span":n?`full`:void 0,children:[(0,l.jsxs)(`span`,{className:`dsh-atb-field-label`,children:[e,t&&(0,l.jsx)(`em`,{className:`dsh-atb-req`,children:`*`})]}),r]})}function et({rows:e,onChange:t,editing:n}){let r=W(),i=(n,r)=>{t(e.map((e,t)=>t===n?{...e,...r}:e))},a=e.filter(e=>e.checked).length;return(0,l.jsxs)(`div`,{className:`dsh-atb-cke`,children:[e.map((a,o)=>(0,l.jsxs)(`div`,{className:`dsh-atb-cke-row`,children:[n&&(0,l.jsx)(`input`,{type:`checkbox`,className:`dsh-atb-cke-box`,checked:a.checked,title:r(`form.check.checkedTitle`,{who:a.checkedBy??r(`form.check.notCheckedYet`)}),onChange:e=>i(o,{checked:e.target.checked})}),(0,l.jsx)(`input`,{className:`dsh-atb-cke-text`,value:a.text,maxLength:200,placeholder:r(`form.check.itemPlaceholder`,{n:o+1}),spellCheck:!1,onChange:e=>i(o,{text:e.target.value})}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-cke-del`,title:r(`form.check.removeTitle`),onClick:()=>t(e.filter((e,t)=>t!==o)),children:`✕`})]},a.id??`new-${o}`)),e.length<30&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-cke-add`,onClick:()=>t([...e,{text:``,checked:!1}]),children:r(`form.check.add`)}),e.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-cke-hint`,children:n?r(`form.check.hintEdit`,{checked:a,total:e.length}):r(`form.check.hintCreate`,{n:e.length})})]})}function tt({controller:e,task:t}){let n=W(),r=e.getSnapshot(),i=r.templatePrefill,a=t!==void 0,[o,s]=(0,c.useState)(t?.title??i?.title??``),[u,d]=(0,c.useState)(t?.description??i?.description??``),[f,p]=(0,c.useState)(t?.prompt??i?.prompt??``),[m,h]=(0,c.useState)(t?.workspaceId??r.filters.workspaceId??r.workspaces[0]?.id??``),[g,_]=(0,c.useState)(t?.urgency??(i?.urgency===`urgent`||i?.urgency===`relaxed`?i.urgency:`normal`)),v=t?.execution??i?.execution,[y,b]=(0,c.useState)(v?.mode===`scheduled`?v.cron===void 0?`once`:`periodic`:`claim`),[x,C]=(0,c.useState)(t?.execution.cron??i?.execution?.cron??`0 9 * * *`),[T,E]=(0,c.useState)(t?.execution.periodicCompletion??i?.execution?.periodicCompletion??`spawn`),te=v?.mode===`scheduled`&&v.runAt!==void 0?v.runAt:void 0,[D,O]=(0,c.useState)(()=>{if(te===void 0)return``;let e=new Date(te);if(Number.isNaN(e.getTime()))return``;let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`}),[A,re]=(0,c.useState)([]),j=t?.model??i?.model??(a?void 0:Ye()),[M,N]=(0,c.useState)(j===void 0?``:JSON.stringify({provider:j.provider,model:j.model})),[P,F]=(0,c.useState)(j?.reasoningEffort??``),I=t?.presetId??i?.presetId??``,[L,R]=(0,c.useState)(I),[z,B]=(0,c.useState)([]),[V,ie]=(0,c.useState)(void 0),[ae,oe]=(0,c.useState)(t?.permission??(i?.permission?S(i.permission):w(r.ledger.settings))),[se,ce]=(0,c.useState)(t?.isolation??(i?.isolation===`none`?`none`:i?.isolation===`worktree`?`worktree`:ee(r.ledger.settings))),[H,le]=(0,c.useState)(t?.checklist!==void 0&&t.checklist.length>0?t.checklist.map(e=>({...e})):(i?.checklist??[]).map(e=>({text:e,checked:!1}))),U=(0,c.useRef)(null),[ue,de]=(0,c.useState)(!1),[fe,pe]=(0,c.useState)(!1);(0,c.useEffect)(()=>{U.current?.focus();let t=t=>{t.key===`Escape`&&e.closeForm()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),(0,c.useEffect)(()=>{e.fetchModelCatalog().then(re).catch(()=>re([]))},[e]),(0,c.useEffect)(()=>{e.fetchPresetCatalog().then(e=>{B(e.presets),ie(e.defaultId),!a&&I===``&&e.defaultId!==void 0&&R(e.defaultId)}).catch(()=>B([]))},[e,a,t?.presetId,I]);let me=y===`periodic`?ne(x.trim()):null,he=me===null?null:k(me,Date.now()),ge=y===`periodic`&&(me===null||he===null),_e=y===`once`&&D!==``?new Date(D).getTime():NaN,ve=y===`once`&&(D===``||Number.isNaN(_e)||_e<=Date.now()),G=o.trim().length>0&&m!==``&&!ge&&!ve,ye=()=>y===`periodic`?{mode:`scheduled`,cron:x.trim(),periodicCompletion:T}:y===`once`?{mode:`scheduled`,runAt:new Date(D).toISOString()}:{mode:`claim`},be=a&&t.status===`in_progress`,K=a&&((t.executions?.length??0)>0||t.status===`in_progress`),q=e.gitAvailable(m),xe=e.repoCount(m),Se=K||!q,Ce=()=>{if(q)return se},we=()=>L.trim().length>0?L.trim():void 0,Te=()=>H.map(e=>({...e,text:e.text.trim()})).filter(e=>e.text.length>0),Y=M===``?void 0:JSON.parse(M),X=(Y===void 0?void 0:A.find(e=>e.provider===Y.provider&&e.model===Y.model))?.reasoning,Ee=()=>{if(Y===void 0)return;let e=P.trim();return{provider:Y.provider,model:Y.model,...e.length>0?{reasoningEffort:e}:{}}},De=()=>{if(!G||ue||fe)return;let n=Ee();a||Xe(n);let r=Ce(),i=we(),s=Te();de(!0),(a?e.update(t.id,t.version,{title:o,description:u,prompt:f,urgency:g,workspaceId:m,execution:ye(),model:n??null,...r!==void 0&&!K?{isolation:r}:{},presetId:i??null,permission:ae,checklist:s.length>0?s:null}):e.create({title:o,workspaceId:m,urgency:g,description:u.length>0?u:void 0,prompt:f.length>0?f:void 0,execution:ye(),model:n,...r===void 0?{}:{isolation:r},...i===void 0?{}:{presetId:i},permission:ae,...s.length>0?{checklist:s.map(e=>e.text)}:{}})).catch(()=>void 0).finally(()=>de(!1))},Oe=()=>{if(!G||be||ue||fe)return;let n=Ee();a||Xe(n);let r=Ce(),i=we(),s=Te();de(!0),(async()=>{if(a)await e.update(t.id,t.version,{title:o,description:u,prompt:f,urgency:g,workspaceId:m,execution:ye(),model:n??null,...r!==void 0&&!K?{isolation:r}:{},presetId:i??null,permission:ae,checklist:s.length>0?s:null})&&await e.run(t.id);else{let t=await e.create({title:o,workspaceId:m,urgency:g,description:u.length>0?u:void 0,prompt:f.length>0?f:void 0,execution:ye(),model:n,...r===void 0?{}:{isolation:r},...i===void 0?{}:{presetId:i},permission:ae,...s.length>0?{checklist:s.map(e=>e.text)}:{}});t!==void 0&&await e.run(t)}})().catch(()=>void 0).finally(()=>de(!1))},ke=G?y===`periodic`&&he!==null?n(`form.hint.nextRun`,{time:J(he)}):y===`once`&&!Number.isNaN(_e)?n(`form.hint.onceAt`,{time:J(_e)}):a?n(`form.hint.saveVersion`,{v:t.version,next:t.version+1}):n(`form.hint.createClaim`):o.trim().length===0?n(`form.hint.needTitle`):n(m===``?`form.hint.needProject`:ve?`form.hint.runAtBad`:`form.hint.cronBad`);return(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeForm()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-taskform-modal`,"data-mode":a?`edit`:`create`,role:`dialog`,"aria-modal":`true`,"aria-label":n(a?`form.title.edit`:`form.title.create`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:a?`✎`:`✚`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:n(a?`form.title.edit`:`form.title.create`)}),(0,l.jsx)(`p`,{children:n(a?`form.subtitle.edit`:`form.subtitle.create`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":n(`shared.close`),onClick:()=>e.closeForm(),children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body dsh-atb-taskform-body`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-form-col dsh-atb-form-left`,children:[(0,l.jsx)($,{label:n(`form.field.title`),required:!0,full:!0,children:(0,l.jsx)(`input`,{ref:U,value:o,onChange:e=>s(e.target.value),placeholder:n(`form.field.titlePlaceholder`),maxLength:200})}),(0,l.jsxs)(`div`,{className:`dsh-atb-form-subgrid`,children:[(0,l.jsx)($,{label:n(`form.field.project`),required:!0,children:(0,l.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),children:r.workspaces.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.title||e.path},e.id))})}),(0,l.jsx)($,{label:n(`form.field.model`),children:(0,l.jsxs)(`select`,{value:M,onChange:e=>{let t=e.target.value;if(N(t),t===``)F(``);else{let e=JSON.parse(t),n=A.find(t=>t.provider===e.provider&&t.model===e.model);n?.reasoning?.defaultEffort===void 0?F(``):F(n.reasoning.defaultEffort)}},children:[(0,l.jsx)(`option`,{value:``,children:n(`form.field.modelDefault`)}),A.map(e=>(0,l.jsx)(`option`,{value:JSON.stringify({provider:e.provider,model:e.model}),children:n(`form.model.option`,{name:e.name??e.model,provider:e.provider})},`${e.provider}/${e.model}`))]})}),Y!==void 0&&(0,l.jsx)($,{label:n(`form.field.effort`),children:(0,l.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),title:n(`form.field.effortTitle`),children:[(0,l.jsxs)(`option`,{value:``,children:[n(`form.effort.follow`),X?.defaultEffort===void 0?``:n(`shared.current`,{name:X.efforts.find(e=>e.id===X.defaultEffort)?.name??X.defaultEffort})]}),X!==void 0&&X.efforts.length>0?X.efforts.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.name,e.description?` (${e.description})`:``]},e.id)):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`option`,{value:`low`,children:n(`form.effort.low`)}),(0,l.jsx)(`option`,{value:`medium`,children:n(`form.effort.medium`)}),(0,l.jsx)(`option`,{value:`high`,children:n(`form.effort.high`)}),(0,l.jsx)(`option`,{value:`none`,children:n(`form.effort.none`)})]})]})}),z.length>0&&(0,l.jsx)($,{label:n(`form.field.preset`),children:(0,l.jsxs)(`select`,{value:L,onChange:e=>R(e.target.value),title:n(`form.field.presetTitle`),children:[(0,l.jsxs)(`option`,{value:``,children:[n(`form.preset.follow`),V===void 0?``:n(`shared.current`,{name:z.find(e=>e.id===V)?.name??V})]}),z.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.name??e.id,e.id===V?n(`form.preset.defaultTag`):``]},e.id))]})})]}),(0,l.jsx)($,{label:n(`form.field.urgency`),full:!0,children:(0,l.jsx)(`div`,{className:`dsh-atb-urgency-picker`,children:Ze(n).map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-urgency-opt`,"data-urgency":e.value,"data-on":g===e.value,onClick:()=>_(e.value),children:[(0,l.jsxs)(`span`,{className:`dsh-atb-urgency-name`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-urgency":e.value}),e.label]}),(0,l.jsx)(`span`,{className:`dsh-atb-urgency-hint`,children:e.hint})]},e.value))})}),(0,l.jsx)($,{label:n(`form.field.permission`),full:!0,children:(0,l.jsx)(`div`,{className:`dsh-atb-perm-picker`,children:$e(n).map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":ae===e.value,onClick:()=>oe(e.value),children:[(0,l.jsxs)(`span`,{className:`dsh-atb-perm-name`,children:[e.icon,` `,e.label,e.value===`workspace-write`?n(`form.perm.defaultTag`):``]}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:e.hint})]},e.value))})}),(0,l.jsx)($,{label:n(`form.field.mode`),full:!0,children:(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,"data-exec":`true`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":y===`claim`,onClick:()=>b(`claim`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.mode.claim`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.mode.claimHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":y===`once`,onClick:()=>b(`once`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.mode.once`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.mode.onceHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":y===`periodic`,onClick:()=>b(`periodic`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.mode.periodic`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.mode.periodicHint`)})]})]})}),y===`once`&&(0,l.jsx)($,{label:n(`form.field.runAt`),required:!0,full:!0,children:(0,l.jsx)(`input`,{type:`datetime-local`,className:ve?`dsh-atb-input-bad`:void 0,value:D,onChange:e=>O(e.target.value),spellCheck:!1})}),y===`periodic`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)($,{label:n(`form.field.cron`),required:!0,full:!0,children:[(0,l.jsx)(`input`,{className:ge?`dsh-atb-input-bad`:void 0,value:x,onChange:e=>C(e.target.value),placeholder:n(`form.cron.placeholder`),spellCheck:!1}),(0,l.jsxs)(`span`,{className:`dsh-atb-cron-presets`,children:[Qe(n).map(e=>(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-cron-preset`,"data-on":x.trim()===e.cron,onClick:()=>C(e.cron),children:e.label},e.cron)),!ge&&he!==null&&(0,l.jsx)(`span`,{className:`dsh-atb-cron-next`,children:n(`form.cron.next`,{time:J(he)})})]})]}),(0,l.jsx)($,{label:n(`form.field.periodicCompletion`),full:!0,children:(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":T===`rearm`,onClick:()=>E(`rearm`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.periodicCompletion.rearm`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.periodicCompletion.rearmHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":T===`spawn`,onClick:()=>E(`spawn`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.periodicCompletion.spawn`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.periodicCompletion.spawnHint`)})]})]})})]}),(0,l.jsxs)($,{label:n(`form.field.isolation`),full:!0,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,"data-disabled":Se?`true`:void 0,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":se===`worktree`,disabled:Se,title:n(K?`form.iso.locked`:q?`form.iso.worktreeTitle`:`form.iso.nonGit`),onClick:()=>ce(`worktree`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.iso.worktree`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(K?`form.iso.lockedShort`:q?`form.iso.worktreeHint`:`form.iso.nonGit`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":se===`none`,disabled:Se,title:n(K?`form.iso.locked`:`form.iso.noneTitle`),onClick:()=>ce(`none`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.iso.none`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(K?`form.iso.lockedShort`:q?`form.iso.noneHint`:`form.iso.noneHintNonGit`)})]})]}),!q&&!K&&(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:n(`form.iso.nonGitNote`)}),q&&!K&&xe>1&&(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,"data-mirror":`true`,children:n(`form.iso.mirrorNote`,{n:xe})})]}),(0,l.jsx)($,{label:n(a?`form.field.checklist`:`form.field.checklistOptional`),full:!0,children:(0,l.jsx)(et,{rows:H,onChange:le,editing:a})})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-form-col dsh-atb-form-right`,children:[(0,l.jsx)($,{label:n(a?`form.field.description`:`form.field.descriptionOptional`),full:!0,children:(0,l.jsx)(qe,{value:u,onChange:d,controller:e,rows:7,placeholder:n(`form.desc.placeholder`),allowImages:!0,onUploadingChange:pe})}),(0,l.jsx)($,{label:n(a?`form.field.prompt`:`form.field.promptOptional`),full:!0,children:(0,l.jsx)(qe,{value:f,onChange:p,controller:e,rows:7,placeholder:n(`form.prompt.placeholder`)})})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,"data-tone":G?void 0:`bad`,children:ke}),(0,l.jsxs)(`span`,{className:`dsh-atb-modal-footbtns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>e.closeForm(),children:n(`shared.cancel`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:!G||be||ue||fe,title:n(be?`form.action.runBlockedTitle`:ue||fe?`form.action.runBusyTitle`:`form.action.runTitle`),onClick:Oe,children:n(`form.action.run`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,disabled:!G||ue||fe,onClick:De,children:n(a?`form.action.save`:`form.action.create`)})]})]})]})})}const nt=e=>[{value:`none`,name:e(`form.iso.none`),hint:e(`set.iso.noneHint`)},{value:`worktree`,name:e(`form.iso.worktree`),hint:e(`set.iso.worktreeHint`)}];function rt({controller:e}){let t=W(),n=e.getSnapshot(),r=n.ledger.settings?.defaultIsolation??`none`,i=C(n.ledger.settings),a=w(n.ledger.settings),o=T(n.ledger.settings),s=E(n.ledger.settings),u=te(n.ledger.settings),d=D(n.ledger.settings),[f,p]=(0,c.useState)(r),[m,h]=(0,c.useState)(i),[g,_]=(0,c.useState)(a),[v,y]=(0,c.useState)(String(o)),[b,x]=(0,c.useState)(String(s)),[S,ee]=(0,c.useState)(String(u)),[ne,O]=(0,c.useState)(String(d)),[k,A]=(0,c.useState)(n.storage?.currentDirectory??``),[re,j]=(0,c.useState)(!1),[M,N]=(0,c.useState)(!1),P=Number(v),F=Number(b),I=Number(S),L=Number(ne),R=Number.isSafeInteger(P)&&P>=1&&P<=100&&Number.isSafeInteger(F)&&F>=1&&F<=1440&&Number.isSafeInteger(I)&&I>=0&&I<=10080&&Number.isSafeInteger(L)&&L>=0&&L<=6e4,z=f!==r||m!==i||g!==a||v!==String(o)||b!==String(s)||S!==String(u)||ne!==String(d),B=k.trim().length===0?n.storage?.defaultDirectory??``:k.trim(),V=n.storage!==void 0&&B!==n.storage.currentDirectory;return(0,c.useEffect)(()=>{!re&&n.storage!==void 0&&A(n.storage.currentDirectory)},[n.storage,re]),(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeSettings()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-set`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`set.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`🛠`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`set.title`)}),(0,l.jsx)(`p`,{children:t(`set.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:()=>e.closeSettings(),children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body`,children:[(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.iso.heading`)}),(0,l.jsx)(`div`,{className:`dsh-atb-mode-picker`,children:nt(t).map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":f===e.value,title:e.hint,onClick:()=>p(e.value),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:e.name}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:e.hint})]},e.value))}),(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:t(`set.iso.current`,{current:t(r===`worktree`?`form.iso.worktree`:`form.iso.none`)})})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.sync.heading`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":!m,title:t(`set.sync.off.title`),onClick:()=>h(!1),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`set.sync.off.name`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`set.sync.off.hint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":m,title:t(`set.sync.on.title`),onClick:()=>h(!0),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`set.sync.on.name`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`set.sync.on.hint`)})]})]}),(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:t(i?`set.sync.stateOn`:`set.sync.stateOff`)})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.perm.heading`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-perm-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":g===`workspace-write`,onClick:()=>_(`workspace-write`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-perm-name`,children:t(`set.perm.writeName`)}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:t(`set.perm.writeHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":g===`read-only`,onClick:()=>_(`read-only`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-perm-name`,children:t(`set.perm.readOnlyName`)}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:t(`set.perm.readOnlyHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":g===`danger-full-access`,onClick:()=>_(`danger-full-access`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-perm-name`,children:t(`set.perm.fullName`)}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:t(`set.perm.fullHint`)})]})]}),(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:t(`set.perm.current`,{current:t(a===`read-only`?`set.perm.readOnlyName`:a===`danger-full-access`?`set.perm.fullName`:`set.perm.writeName`)})})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.schedule.heading`)}),(0,l.jsx)(`p`,{className:`dsh-atb-isolation-note`,children:t(`set.schedule.hint`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-settings-numbers`,children:[(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.concurrent`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`1`,max:`100`,step:`1`,value:v,onChange:e=>y(e.target.value)})]}),(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.missedAfter`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`1`,max:`1440`,step:`1`,value:b,onChange:e=>x(e.target.value)})]}),(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.queueMaxAge`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`0`,max:`10080`,step:`1`,value:S,onChange:e=>ee(e.target.value)})]}),(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.dispatchInterval`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`0`,max:`60000`,step:`1`,value:ne,onChange:e=>O(e.target.value)})]})]}),!R&&(0,l.jsx)(`span`,{className:`dsh-atb-storage-error`,children:t(`set.schedule.invalid`)})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.storage.heading`)}),(0,l.jsx)(`p`,{className:`dsh-atb-isolation-note`,children:t(`set.storage.hint`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input dsh-atb-storage-path`,value:k,disabled:n.storage===void 0||M,placeholder:n.storage?.defaultDirectory??t(`set.storage.loading`),onChange:t=>{A(t.target.value),j(!0),e.dismissStorageNotice()}}),n.storageNotice!==void 0&&(0,l.jsxs)(`div`,{className:`dsh-atb-storage-notice`,role:`status`,children:[(0,l.jsxs)(`span`,{className:`dsh-atb-storage-notice-ok`,children:[`✓ `,t(`set.storage.migrated`,{path:n.storageNotice.path})]}),n.storageNotice.warnings.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-storage-notice-warn`,children:t(`set.storage.warnings`,{warnings:n.storageNotice.warnings.join(`; `)})})]}),n.storage!==void 0&&(0,l.jsxs)(`div`,{className:`dsh-atb-storage-meta`,children:[(0,l.jsx)(`span`,{children:t(`set.storage.current`,{path:n.storage.currentDirectory})}),(0,l.jsx)(`span`,{children:t(`set.storage.assets`,{count:n.storage.assetCount,size:(n.storage.assetBytes/1024/1024).toFixed(1)})}),n.storage.error!==void 0&&(0,l.jsx)(`span`,{className:`dsh-atb-storage-error`,children:n.storage.error})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-storage-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:n.storage===void 0||M,onClick:()=>{A(n.storage?.defaultDirectory??``),j(!0)},children:t(`set.storage.default`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:n.storage===void 0||M||B.length===0,onClick:()=>{N(!0),e.checkStorage(B).finally(()=>N(!1))},children:t(`set.storage.check`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,disabled:!V||M,onClick:()=>{window.confirm(t(`set.storage.confirm`,{from:n.storage?.currentDirectory??``,to:B}))&&(N(!0),e.migrateStorage(B).then(e=>{e&&(j(!1),A(B))}).finally(()=>N(!1)))},children:t(M?`set.storage.migrating`:`set.storage.migrate`)})]})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,children:t(z?`set.foot.dirty`:`set.foot.clean`)}),(0,l.jsxs)(`span`,{className:`dsh-atb-modal-footbtns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>e.closeSettings(),children:t(`shared.cancel`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,disabled:!z||!R,onClick:()=>{e.updateSettings({defaultIsolation:f,syncExternalSessions:m,defaultPermission:g,maxConcurrent:P,scheduleMissedAfterMinutes:F,queueMaxAgeMinutes:I,dispatchIntervalMs:L}).then(t=>{t&&e.closeSettings()})},children:t(`set.action.save`)})]})]})]})})}function it({row:e}){return(0,l.jsxs)(`div`,{className:`dsh-atb-imp-row`,title:e.id,children:[(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-title`,children:e.title}),(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-status`,children:e.status})]})}function at({controller:e}){let t=W(),[n,r]=(0,c.useState)(``),[i,a]=(0,c.useState)(null),[o,s]=(0,c.useState)(void 0),[u,d]=(0,c.useState)(void 0),[f,p]=(0,c.useState)(`merge`),[m,h]=(0,c.useState)(!1),[g,_]=(0,c.useState)(void 0),[v,y]=(0,c.useState)(!1),b=(0,c.useRef)(null),{alert:x,el:S}=X(),ee=n=>{d(void 0),s(void 0),_(void 0),y(!1),r(``),a(null),n!==void 0&&n.text().then(i=>{try{let t=JSON.parse(i);a(t),r(n.name),e.importPreview(t).then(e=>{e!==void 0&&d(e)})}catch{s(t(`imp.parseError`))}})},C=()=>{if(!(i===null||u===void 0||m)){if(f===`replace`&&!v){y(!0);return}h(!0),e.importCommit(f,i).then(e=>{h(!1),y(!1),e!==void 0&&_(e.mode===`replace`?t(`imp.result.replace`,{n:e.created+e.overwritten,total:e.replacedTotal??0}):t(`imp.result.merge`,{n:e.created,m:e.overwritten}))})}},w=()=>e.closeImport();return(0,l.jsxs)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:e=>{e.target===e.currentTarget&&w()},children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-imp`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`imp.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`⬆`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`imp.title`)}),(0,l.jsx)(`p`,{children:t(`imp.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:w,children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-imp-picker`,children:[(0,l.jsx)(`input`,{ref:b,type:`file`,accept:`.json,application/json`,onChange:e=>ee(e.target.files?.[0])}),n.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-imp-filename`,children:n})]}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-note`,children:t(`imp.note`)}),o!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-imp-error`,children:o}),u===void 0&&o===void 0&&n.length>0&&(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`imp.previewing`)}),u!==void 0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stats`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stat`,"data-tone":`ok`,children:[(0,l.jsx)(`b`,{children:u.create.length}),(0,l.jsx)(`span`,{children:t(`imp.stat.create`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stat`,"data-tone":`warn`,children:[(0,l.jsx)(`b`,{children:u.overwrite.length}),(0,l.jsx)(`span`,{children:t(`imp.stat.overwrite`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stat`,"data-tone":u.invalid.length>0?`bad`:void 0,children:[(0,l.jsx)(`b`,{children:u.invalid.length}),(0,l.jsx)(`span`,{children:t(`imp.stat.invalid`)})]})]}),u.create.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-imp-sec`,children:[(0,l.jsx)(`h4`,{children:t(`imp.sec.create`)}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-list`,children:u.create.map(e=>(0,l.jsx)(it,{row:e},e.id))})]}),u.overwrite.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-imp-sec`,children:[(0,l.jsx)(`h4`,{children:t(`imp.sec.overwrite`)}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-list`,children:u.overwrite.map(e=>(0,l.jsx)(it,{row:e},e.id))})]}),u.invalid.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-imp-sec`,children:[(0,l.jsx)(`h4`,{children:t(`imp.sec.invalid`)}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-list`,children:u.invalid.map((e,n)=>(0,l.jsxs)(`div`,{className:`dsh-atb-imp-row`,"data-tone":`bad`,title:e.id??``,children:[(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-title`,children:e.id??t(`imp.noId`)}),(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-status`,children:e.reason})]},e.id??`invalid-${n}`))})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":f===`merge`,onClick:()=>{p(`merge`),y(!1)},children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`imp.mode.merge`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`imp.mode.mergeHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":f===`replace`,onClick:()=>p(`replace`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`imp.mode.replace`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`imp.mode.replaceHint`)})]})]}),g!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-imp-result`,children:g})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,children:t(f===`replace`?v?`imp.foot.replaceConfirm`:`imp.foot.replaceNeedConfirm`:`imp.foot.mergeHint`)}),(0,l.jsxs)(`span`,{className:`dsh-atb-modal-footbtns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:w,children:t(g===void 0?`shared.cancel`:`shared.close`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,"data-danger":f===`replace`&&v?`true`:void 0,disabled:u===void 0||m,onClick:C,children:t(f===`replace`&&v?`imp.action.confirmReplace`:`imp.action.run`)})]})]})]}),S]})}function ot({controller:e}){let t=W(),n=e.getSnapshot(),[r,i]=(0,c.useState)({}),[a,o]=(0,c.useState)(void 0),{alert:s,el:u}=X(),d=()=>e.closeTemplateManager(),f=e=>r[e.id]??xe(e),p=e=>{if(e===void 0)return``;let n=G[e];return n===void 0?` · ${e}`:` · ${t(n)}`},m=(r,a)=>{let o=n.templates.find(e=>e.id===r);o===void 0||a===xe(o)||e.upsertTemplate({id:r,name:a,task:o.task}).then(e=>{e&&(i(e=>{let t={...e};return delete t[r],t}),s(t(`tpl.renamed`)))})};return(0,l.jsxs)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:e=>{e.target===e.currentTarget&&d()},children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-tplm`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`tpl.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`⌗`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`tpl.title`)}),(0,l.jsx)(`p`,{children:t(`tpl.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:d,children:`✕`})]}),(0,l.jsx)(`div`,{className:`dsh-atb-modal-body`,children:n.templates.length===0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`tpl.empty`)}):(0,l.jsx)(`div`,{className:`dsh-atb-tplm-list`,children:n.templates.map(n=>(0,l.jsxs)(`div`,{className:`dsh-atb-tplm-row`,children:[(0,l.jsx)(`input`,{className:`dsh-atb-tplm-name`,value:f(n),maxLength:60,spellCheck:!1,"aria-label":t(`tpl.name.aria`,{name:xe(n)}),onChange:e=>i(t=>({...t,[n.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&m(n.id,f(n))}}),(0,l.jsxs)(`span`,{className:`dsh-atb-tplm-meta`,title:`${n.builtin===!0?t(`tpl.builtin`):t(`tpl.custom`)}${n.task.checklist!==void 0&&n.task.checklist.length>0?t(`tpl.meta.checklist`,{n:n.task.checklist.length}):``}${p(n.task.urgency)}${n.task.permission===void 0?``:` · ${t(`shared.permission`)}: ${n.task.permission}`}`,children:[n.builtin===!0?t(`tpl.builtin`):t(`tpl.custom`),n.task.checklist!==void 0&&n.task.checklist.length>0?t(`tpl.meta.checklist`,{n:n.task.checklist.length}):``,p(n.task.urgency),n.task.permission!==void 0&&n.task.permission!==`workspace-write`?` · ${n.task.permission===`read-only`?t(`tpl.meta.permReadOnly`):t(`tpl.meta.permFull`)}`:``]}),(0,l.jsxs)(`span`,{className:`dsh-atb-tplm-btns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:f(n)===xe(n)||f(n).trim().length===0,title:t(`tpl.rename.title`),onClick:()=>m(n.id,f(n)),children:t(`tpl.rename.button`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`tpl.use.title`),onClick:()=>{d(),e.newFromTemplate(Se(n))},children:t(`tpl.use.button`)}),a===n.id?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>{e.deleteTemplate(n.id),o(void 0)},children:t(`shared.confirmDelete`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>o(void 0),children:t(`shared.cancel`)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,title:t(`tpl.delete.title`),onClick:()=>o(n.id),children:`🗑`})]})]},n.id))})}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,children:t(`tpl.foot.hint`)}),(0,l.jsx)(`span`,{className:`dsh-atb-modal-footbtns`,children:(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:d,children:t(`shared.close`)})})]})]}),u]})}const st={urgent:0,normal:1,relaxed:2};function ct(e,t){let n=e.search.trim().toLowerCase(),r=t.filter(t=>(e.filters.workspaceId===void 0||t.workspaceId===e.filters.workspaceId)&&(e.filters.urgencies.length===0||e.filters.urgencies.includes(t.urgency))&&(n.length===0||t.title.toLowerCase().includes(n)||t.id.toLowerCase().includes(n)));if(e.sortBy==="default")return r;let i=[...r];return e.sortBy===`updated`?i.sort((e,t)=>t.updatedAt-e.updatedAt):e.sortBy===`created`?i.sort((e,t)=>t.createdAt-e.createdAt):e.sortBy===`urgency`?i.sort((e,t)=>st[e.urgency]-st[t.urgency]||t.updatedAt-e.updatedAt):e.sortBy===`title`&&i.sort((e,t)=>e.title.localeCompare(t.title,void 0,{numeric:!0})),i}function lt({controller:e}){let t=W(),n=(0,c.useSyncExternalStore)(t=>e.subscribe(t),()=>e.getSnapshot()),[r,i]=(0,c.useState)(()=>Date.now());(0,c.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),6e4);return()=>clearInterval(e)},[]);let a=ct(n,n.ledger.tasks.filter(e=>e.trashedAt===void 0)),o=n.selectedId===void 0?void 0:n.ledger.tasks.find(e=>e.id===n.selectedId),{alert:s,el:u}=X(),[d,f]=(0,c.useState)(!1),p=()=>f(!1),[m,h]=(0,c.useState)(!1),g=()=>h(!1);return(0,l.jsxs)(`div`,{className:`dsh-atb-board`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-toolbar`,children:[(0,l.jsx)(`h2`,{className:`dsh-atb-title`,children:t(`board.title`)}),(0,l.jsx)(`span`,{className:`dsh-atb-count`,children:t(`board.count.tasks`,{n:a.length,rev:n.ledger.revision})}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,onClick:()=>{let t=!d;f(t),t&&e.prepareTemplateMenu()},children:t(`board.action.newTask`)}),d&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`dsh-atb-newmenu-backdrop`,onClick:p}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu-list`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,onClick:()=>{p(),e.setComposer(!0)},children:t(`board.action.blankTask`)}),n.templates.map(t=>{let n=xe(t),r=Se(t);return(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,title:r.description!==void 0&&r.description.length>0?r.description.slice(0,120):n,onClick:()=>{p(),e.newFromTemplate(r)},children:n},t.id)}),(0,l.jsx)(`div`,{className:`dsh-atb-newmenu-sep`}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,onClick:()=>{p(),e.openTemplateManager()},children:t(`board.action.manageTemplates`)})]})]})]}),(0,l.jsx)(`div`,{className:`dsh-atb-spacer`}),(0,l.jsx)(`input`,{className:`dsh-atb-input dsh-atb-search`,value:n.search,placeholder:t(`board.search.placeholder`),spellCheck:!1,onChange:t=>e.setSearch(t.target.value)}),(0,l.jsxs)(`select`,{className:`dsh-atb-select`,value:n.filters.workspaceId??``,onChange:t=>e.setWorkspaceFilter(t.target.value===``?void 0:t.target.value),children:[(0,l.jsx)(`option`,{value:``,children:t(`board.filter.allProjects`)}),n.workspaces.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.title||e.path},e.id))]}),(0,l.jsxs)(`select`,{className:`dsh-atb-select`,value:n.sortBy,title:t(`board.sort.title`),onChange:t=>e.setSortBy(t.target.value),children:[(0,l.jsx)(`option`,{value:`default`,children:t(`board.sort.default`)}),(0,l.jsx)(`option`,{value:`updated`,children:t(`board.sort.updated`)}),(0,l.jsx)(`option`,{value:`urgency`,children:t(`board.sort.urgency`)}),(0,l.jsx)(`option`,{value:`created`,children:t(`board.sort.created`)}),(0,l.jsx)(`option`,{value:`title`,children:t(`board.sort.byTitle`)})]}),[`urgent`,`normal`,`relaxed`].map(r=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-chip`,"data-urgency":r,"data-on":n.filters.urgencies.includes(r),onClick:()=>e.toggleUrgency(r),children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-urgency":r}),t(G[r])]},r)),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>e.toggleSecondary(),children:n.secondaryOpen?t(`board.action.backToBoard`):t(`board.action.otherTasks`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.settingsTitle`),onClick:()=>e.openSettings(),children:t(`board.action.settings`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.diagTitle`),onClick:()=>e.openDiagnostics(),children:t(`board.action.diag`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.importTitle`),onClick:()=>e.openImport(),children:t(`board.action.import`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.exportTitle`),onClick:()=>h(!m),children:t(`board.action.export`)}),m&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`dsh-atb-newmenu-backdrop`,onClick:g}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu-list`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,title:t(`board.export.jsonTitle`),onClick:()=>{g(),e.exportJson()},children:t(`board.export.json`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,title:t(`board.export.csvTitle`),onClick:()=>{g(),e.exportCsv()},children:t(`board.export.csv`)})]})]})]}),(0,l.jsxs)(`a`,{className:`dsh-atb-ver`,href:`https://github.com/cloader/dsh-taskboard`,target:`_blank`,rel:`noopener noreferrer`,children:[`V`,`0.8.2`]})]}),n.error!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-error`,children:n.error}),n.secondaryOpen?(0,l.jsx)(ft,{controller:e,tasks:ct(n,n.ledger.tasks)}):(0,l.jsx)(`div`,{className:`dsh-atb-columns`,children:v.map(i=>{let o=a.filter(e=>e.status===i);return(0,l.jsxs)(`div`,{className:`dsh-atb-column`,onDragOver:e=>{e.dataTransfer.types.includes(`application/x-dsh-atb-task`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.dataset.dragover=`true`)},onDragLeave:e=>{delete e.currentTarget.dataset.dragover},onDrop:r=>{r.preventDefault(),delete r.currentTarget.dataset.dragover;let a=r.dataTransfer.getData(we);if(a.length===0)return;let o=n.ledger.tasks.find(e=>e.id===a);if(!(o===void 0||o.status===i)){if(!x(o.status,i)){s(t(`board.drag.forbidden`,{from:t(ge[o.status]),to:t(ge[i])}));return}e.move(a,o.version,i)}},children:[(0,l.jsxs)(`div`,{className:`dsh-atb-colhead`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-status":i}),t(ge[i]),(0,l.jsx)(`span`,{className:`dsh-atb-colcount`,children:o.length}),i===`in_progress`&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-queuechip`,title:t(`queue.panel.title`),"data-bad":(n.queue?.depth??0)>0?`true`:void 0,onClick:()=>e.openQueuePanel(),children:t(`board.queue.chip`,{n:n.queue?.depth??0})})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-cards`,children:[o.map(t=>(0,l.jsx)(Y,{task:t,controller:e,draggable:!0,now:r,onAlert:s},t.id)),o.length===0&&(0,l.jsx)(`div`,{className:`dsh-atb-empty`,children:t(`board.empty`)})]})]},i)})}),o!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-detailpanel`,children:(0,l.jsx)(We,{task:o,controller:e,now:r},o.id)}),n.composerOpen&&(0,l.jsx)(tt,{controller:e,task:n.editingId===void 0?void 0:n.ledger.tasks.find(e=>e.id===n.editingId)}),n.diagOpen&&(0,l.jsx)(dt,{controller:e}),n.queueOpen&&(0,l.jsx)(ut,{controller:e,onAlert:s}),n.settingsOpen&&(0,l.jsx)(rt,{controller:e}),n.importOpen&&(0,l.jsx)(at,{controller:e}),n.tplManagerOpen&&(0,l.jsx)(ot,{controller:e}),u]})}function ut({controller:e,onAlert:t}){let n=W(),r=e.getSnapshot().queue,[i,a]=(0,c.useState)(!1),[o,s]=(0,c.useState)(!1),u=r?.depth??0,d=r?.oldestWaitMinutes,f=async()=>{if(!i){a(!0);return}s(!0);let r=await e.clearQueue();s(!1),a(!1),r!==void 0&&(t(n(`queue.cleared`,{n:r.cleared})),e.closeQueuePanel())};return(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeQueuePanel()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-queuepanel`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`queue.panel.title`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`📋`}),(0,l.jsx)(`div`,{className:`dsh-atb-modal-headtext`,children:(0,l.jsx)(`h3`,{children:n(`queue.panel.title`)})}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":n(`shared.close`),onClick:()=>e.closeQueuePanel(),children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-grid`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":u>0?`true`:void 0,children:[(0,l.jsx)(`b`,{children:u}),(0,l.jsx)(`span`,{children:n(`queue.depth`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":d!==void 0&&d>5?`true`:void 0,children:[(0,l.jsxs)(`b`,{children:[d??0,`m`]}),(0,l.jsx)(`span`,{children:n(`queue.wait`)})]})]}),(0,l.jsx)(`div`,{className:`dsh-atb-queuepanel-actions`,children:(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:u===0||o,"data-armed":i?`true`:void 0,onClick:()=>{f()},children:n(i?`queue.confirm`:`queue.clear`)})})]})]})})}function dt({controller:e}){let t=W(),n=e.getSnapshot(),r=n.diagnostics,i=e=>{let t=n.workspaces.find(t=>t.id===e);return t?.title??t?.path??e.slice(0,8)};return(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeDiagnostics()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-diag`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`diag.title`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`⚙`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`diag.title`)}),(0,l.jsx)(`p`,{children:t(`diag.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:()=>e.closeDiagnostics(),children:`✕`})]}),(0,l.jsx)(`div`,{className:`dsh-atb-modal-body`,children:r===void 0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`shared.loading`)}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-grid`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,children:[(0,l.jsx)(`b`,{children:r.revision}),(0,l.jsx)(`span`,{children:t(`diag.revision`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,children:[(0,l.jsx)(`b`,{children:r.tasks}),(0,l.jsx)(`span`,{children:t(`diag.tasks`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":r.staleRunning>0?`true`:void 0,children:[(0,l.jsx)(`b`,{children:r.staleRunning}),(0,l.jsx)(`span`,{children:t(`diag.running`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":r.orphanWorktrees.length>0?`true`:void 0,children:[(0,l.jsx)(`b`,{children:r.orphanWorktrees.length}),(0,l.jsx)(`span`,{children:t(`diag.orphans`)})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`diag.orphans.heading`)}),r.orphanWorktrees.length===0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`diag.orphans.none`)}):(0,l.jsx)(`div`,{className:`dsh-atb-diag-orphans`,children:r.orphanWorktrees.map(n=>(0,l.jsxs)(`div`,{className:`dsh-atb-diag-orphan`,children:[(0,l.jsxs)(`span`,{className:`dsh-atb-diag-orphan-path`,title:n.path,children:[i(n.workspaceId),` · `,n.taskId]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>void e.cleanupOrphan(n.workspaceId,n.taskId),children:t(`diag.orphans.cleanup`)})]},n.path))}),(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`diag.orphans.hint`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`diag.gitignore.heading`)}),(r.gitIgnoreSuggestions??[]).length===0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`diag.gitignore.none`)}):(0,l.jsx)(`div`,{className:`dsh-atb-diag-orphans`,children:r.gitIgnoreSuggestions.map(e=>(0,l.jsx)(`div`,{className:`dsh-atb-diag-orphan`,children:(0,l.jsxs)(`span`,{className:`dsh-atb-diag-orphan-path`,title:e.workspacePath,children:[i(e.workspaceId),` · `,t(`diag.gitignore.suggestA`),` `,(0,l.jsx)(`code`,{children:`.dsh-worktrees/`}),t(`diag.gitignore.suggestB`)]})},e.workspaceId))})]})]})})]})})}function ft({controller:e,tasks:t}){let n=W(),[r,i]=(0,c.useState)(`none`),[a,o]=(0,c.useState)(!1),[s,u]=(0,c.useState)(()=>new Set),d=t.filter(e=>e.trashedAt!==void 0),f=t.filter(e=>e.trashedAt===void 0&&e.status===`archived`),p=t.filter(e=>e.trashedAt===void 0&&e.status===`canceled`),m=e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},h=e=>{u(t=>{let n=e.length>0&&e.every(e=>t.has(e.id)),r=new Set(t);for(let t of e)n?r.delete(t.id):r.add(t.id);return r})},g=async t=>{let n=(t===`trashArchived`?f:d).filter(e=>s.has(e.id));o(!0);try{for(let r of n){try{await e.remove(r.id,r.version,t===`purgeTrashed`)}catch{}u(e=>{let t=new Set(e);return t.delete(r.id),t})}}finally{o(!1),i(`none`),u(new Set)}},_=()=>{i(`none`),u(new Set)},v=[{label:n(`status.column.canceled`),dot:`canceled`,rows:p},{label:n(`status.column.archived`),dot:`archived`,rows:f,action:`trashArchived`},{label:n(`board.group.trashed`),dot:`trashed`,rows:d,action:`purgeTrashed`}];return d.length+f.length+p.length===0?(0,l.jsx)(`div`,{className:`dsh-atb-secondary`,children:(0,l.jsx)(`div`,{className:`dsh-atb-empty`,children:n(`board.secondary.empty`)})}):(0,l.jsx)(`div`,{className:`dsh-atb-columns`,children:v.map(t=>{let o=r===t.action,c=o?t.rows.filter(e=>s.has(e.id)).length:0,d=t.rows.length>0&&c===t.rows.length;return(0,l.jsxs)(`div`,{className:`dsh-atb-column`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-colhead`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-status":t.dot}),t.label,(0,l.jsx)(`span`,{className:`dsh-atb-colcount`,children:t.rows.length}),t.action&&t.rows.length>0&&(o?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:a,title:n(`board.batch.confirmCancelTip`),onClick:_,children:n(`board.batch.cancel`)}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,disabled:a||c===0,title:n(c===0?`board.batch.noneSelected`:`board.batch.confirmTip`),onClick:()=>{g(t.action)},children:[n(`board.batch.confirm`),`(`,c,`)`]}),(0,l.jsx)(`input`,{type:`checkbox`,className:`dsh-atb-selectall`,checked:d,disabled:a,title:n(`board.batch.selectAll`),onClick:e=>e.stopPropagation(),onChange:()=>h(t.rows)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:a,title:t.action===`trashArchived`?n(`board.batch.trashArchivedTip`):n(`board.batch.purgeTrashedTip`),onClick:()=>{i(t.action),u(new Set)},children:t.action===`trashArchived`?n(`board.batch.trashArchived`):n(`board.batch.purgeTrashed`)}))]}),(0,l.jsxs)(`div`,{className:`dsh-atb-cards`,children:[t.rows.map(n=>t.action&&o?(0,l.jsxs)(`div`,{className:`dsh-atb-selrow`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`dsh-atb-selbox`,checked:s.has(n.id),disabled:a,onClick:e=>e.stopPropagation(),onChange:()=>m(n.id)}),(0,l.jsx)(Y,{task:n,controller:e})]},n.id):(0,l.jsx)(Y,{task:n,controller:e},n.id)),t.rows.length===0&&(0,l.jsx)(`div`,{className:`dsh-atb-empty`,children:n(`board.empty`)})]})]},t.label)})})}function pt(e){let t=()=>{if((document.body.getAttribute(`data-dsh-desktop-platform`)??new URLSearchParams(window.location.search).get(`dsh-desktop-platform`))!==`win32`){delete e.dataset.dshAtbWindows,e.style.removeProperty(`--dsh-atb-viewport-top`);return}e.dataset.dshAtbWindows=``,e.style.setProperty(`--dsh-atb-viewport-top`,`${e.getBoundingClientRect().top}px`)},n,r=()=>{n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,t()}))},i=new MutationObserver(r);i.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:[`class`,`data-dsh-desktop-platform`,`data-dsh-desktop-mode`,`data-details-collapsed`]}),i.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-dsh-atb-active`]});let a=typeof ResizeObserver>`u`?void 0:new ResizeObserver(r);return a?.observe(e),e.parentElement!==null&&a?.observe(e.parentElement),window.addEventListener(`resize`,r),r(),()=>{i.disconnect(),a?.disconnect(),window.removeEventListener(`resize`,r),n!==void 0&&cancelAnimationFrame(n),delete e.dataset.dshAtbWindows,e.style.removeProperty(`--dsh-atb-viewport-top`)}}function mt(){let e=document.querySelector(`[data-pane="sidebar"], [class*="sidebarCol"], .dshDesktopUpstreamSidebar, .dshDesktopSidebarSurface`);if(e!==null)return e.querySelector(`[class*="logoRow"]`)?.parentElement??e.firstElementChild}function ht(e){let t=e.querySelector(`button[class*="newSession"]`);if(t!==null)return t;for(let t of e.children)if(t instanceof HTMLButtonElement&&!t.matches(`[data-dsh-atb-entry]`))return t;let n=e.querySelector(`button[aria-label="新建会话"], button[aria-label="New Session"], button[aria-label*="新会话"], button[aria-label*="new session" i]`);return n===null?Array.from(e.querySelectorAll(`button`)).find(e=>!e.matches(`[data-dsh-atb-entry]`)&&/新会话|新建会话|new session/i.test(e.textContent??``)):n}function gt(e){let t=document.createElement(`button`);return t.type=`button`,t.dataset.dshAtbEntry=``,t.className=`dsh-atb-entry`,t.setAttribute(`aria-label`,U(`shared.entry.aria`)),t.innerHTML=``,t.addEventListener(`click`,()=>{e.toggleBoard()}),t}function _t(e){let t=0,n=0,r=0;for(let i of e.getSnapshot().ledger.tasks)i.trashedAt===void 0&&(i.status===`todo`?t++:i.status===`in_progress`?n++:i.status===`in_review`&&r++);return[t,n,r]}function vt(e,t){let n=String(t);if(e.dataset.value===n)return;let r=e.dataset.value;if(e.dataset.value=n,e.style.minWidth=`${n.length}ch`,r===void 0){e.textContent=n;return}e.dataset.busy===`1`&&(e.dataset.busy=``,e.dataset.anim=``);let i=document.createElement(`span`);i.className=`dsh-atb-rn`,i.textContent=r;let a=document.createElement(`span`);a.className=`dsh-atb-rn dsh-atb-rn-next`,a.textContent=n,e.replaceChildren(i,a),e.dataset.dir=t>Number(r)?`up`:`down`,e.dataset.busy=`1`,requestAnimationFrame(()=>{e.dataset.anim=`1`});let o=()=>{e.dataset.busy===`1`&&(e.dataset.busy=``,e.dataset.anim=``,e.textContent=e.dataset.value??``)};e.addEventListener(`transitionend`,o,{once:!0}),setTimeout(o,400)}function yt(e,t){let n=e.querySelector(`.dsh-atb-entry-stats`);if(n===null)return()=>{};let r=[`todo`,`in_progress`,`in_review`],i=[];for(let e=0;e<3;e++){if(e>0){let e=document.createElement(`span`);e.className=`dsh-atb-entry-sep`,e.textContent=`|`,n.append(e)}let t=document.createElement(`span`);t.className=`dsh-atb-roll`,t.dataset.stat=r[e],n.append(t),i.push(t)}return()=>{let[e,r,a]=_t(t);vt(i[0],e),vt(i[1],r),vt(i[2],a),n.title=U(`shared.stats.title`,{todo:e,doing:r,review:a})}}function bt(e,t){let n=ht(e);if(n===void 0)return!1;if(t.parentElement!==e){let r=n.closest(`[class*="logoRow"]`),i=r!==null&&r.parentElement===e?r:n,a=Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.matches(`[data-dsh-atb-entry], [data-dsh-taskboard-entry], [data-dsh-ssh-entry]`)),o=a.length>0?a[0]??null:i.nextElementSibling??null;e.insertBefore(t,o)}return!0}function xt(e){let t=gt(e),n={attempts:0,found:!1,placed:!1},r=globalThis.location?.hostname;(r===`localhost`||r===`127.0.0.1`)&&(window.__atbDebug=n);let i,a=!1,o=()=>{if(n.attempts++,i!==void 0&&!i.isConnected&&(c.disconnect(),i=void 0,a=!1),a){if(document.body.contains(t))return;c.disconnect(),i=void 0,a=!1}i??=mt(),i!==void 0&&(n.found=ht(i)!==void 0,a=bt(i,t),n.placed=a,a&&c.observe(i,{childList:!0,subtree:!0}))},s=new MutationObserver(()=>{o()});s.observe(document.body,{childList:!0,subtree:!0});let c=new MutationObserver(()=>{if(i===void 0||!i.isConnected){a=!1,o();return}i.contains(t)||(a=bt(i,t))}),l=setInterval(()=>{o()},2e3),u=yt(t,e),d=()=>{e.getSnapshot().boardOpen?t.dataset.active=`true`:delete t.dataset.active,u()},f=e.subscribe(d),p=H.subscribe(()=>{t.setAttribute(`aria-label`,U(`shared.entry.aria`));let e=t.querySelector(`.dsh-atb-entry-label`);e!==null&&(e.textContent=U(`shared.entry.label`)),u()});return d(),o(),()=>{clearInterval(l),s.disconnect(),c.disconnect(),p(),f(),t.remove()}}const St=`data-dsh-atb-active`,Ct=[`data-dsh-taskboard-active`,`data-dsh-ssh-active`],wt=`dsh-panel-activate`,Tt=`dsh-taskboard`;function Et(){return document.querySelector(`[data-pane="conversation"], [class*="centerCol"], .dshDesktopConversationSurface`)??void 0}function Dt(e){let t,n,r,i=()=>{if(n!==void 0)return;let i=Et();i!==void 0&&(n=document.createElement(`div`),n.dataset.dshAtbView=``,n.className=`dsh-atb-view`,i.appendChild(n),r=pt(n),t=(0,d.createRoot)(n),t.render((0,l.jsx)(lt,{controller:e})))},a=new MutationObserver(()=>{i()});a.observe(document.body,{childList:!0,subtree:!0});let o=()=>{if(e.getSnapshot().boardOpen){for(let e of Ct)document.documentElement.removeAttribute(e);document.documentElement.setAttribute(St,``),document.dispatchEvent(new CustomEvent(wt,{detail:Tt}))}else document.documentElement.removeAttribute(St)},s=t=>{t.detail!==Tt&&e.getSnapshot().boardOpen&&e.closeBoard()},c=t=>{if(!e.getSnapshot().boardOpen)return;let n=t.target;n!==null&&n.closest(`[data-dsh-atb-entry]`)===null&&n.closest(`[class*="sessionRow"], [class*="projectRow"], [class*="searchResultRow"], [class*="searchResultWorkspace"], [class*="newSession"]`)!==null&&e.closeBoard()};document.addEventListener(`click`,c,!0),document.addEventListener(wt,s);let u=e.subscribe(o);return o(),i(),()=>{document.removeEventListener(`click`,c,!0),document.removeEventListener(wt,s),a.disconnect(),u(),r?.(),document.documentElement.removeAttribute(St),t?.unmount(),n?.remove()}}const Ot=`dsh-taskboard`;function kt(e){let t=e.get?.(`slots`)??e.slots;if(!(t===void 0||typeof t.register!=`function`||typeof t.inject!=`function`||typeof t.spec!=`function`)){try{if(t.spec(`main`)===void 0||t.spec(`sidebar.panellist`)===void 0)return}catch{return}return t}}function At(e){return function(){let t=c.useCallback(e=>{if(e===null)return;let t=`__dshAtbInsetDispose`,n=e;n[t]===void 0&&(n[t]=pt(e))},[]);return c.createElement(`div`,{"data-dsh-atb-panel-root":``,ref:t,className:`dsh-atb-panel-root`},c.createElement(lt,{controller:e}))}}function jt(e){return function(t){let n=typeof t.size==`number`?t.size:16,r=c.useCallback(t=>e.subscribe(t),[e]),i=c.useCallback(()=>e.getSnapshot(),[e]),a=c.useSyncExternalStore(r,i,i),o=c.useMemo(()=>{let e=0,t=0,n=0;for(let r of a.ledger.tasks)r.trashedAt===void 0&&(r.status===`todo`?e++:r.status===`in_progress`?t++:r.status===`in_review`&&n++);return{todo:e,doing:t,review:n}},[a.ledger]),[s,l]=c.useState(!0),u=c.useCallback(e=>{if(e===null||typeof ResizeObserver>`u`)return;let t=e.closest(`button`);t!==null&&new ResizeObserver(()=>{l(t.clientWidth>44)}).observe(t)},[]),d=U(`shared.stats.title`,{todo:o.todo,doing:o.doing,review:o.review});return c.createElement(`span`,{className:`dsh-atb-pglyph`,ref:u},c.createElement(`span`,{className:`dsh-atb-picon`},c.createElement(`svg`,{width:n,height:n,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":1.3,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":!0},c.createElement(`rect`,{x:2,y:2,width:12,height:12,rx:2}),c.createElement(`path`,{d:`M6 2v12M10 2v12`})),!s&&o.todo>0?c.createElement(`span`,{className:`dsh-atb-pbadge`,title:d,"aria-hidden":!0},o.todo):null),s&&(o.todo>0||o.doing>0||o.review>0)?c.createElement(`span`,{className:`dsh-atb-pstats`,title:d,"aria-hidden":!0},c.createElement(`span`,{"data-stat":`todo`},o.todo),c.createElement(`span`,{className:`dsh-atb-psep`},`|`),c.createElement(`span`,{"data-stat":`in_progress`},o.doing),c.createElement(`span`,{className:`dsh-atb-psep`},`|`),c.createElement(`span`,{"data-stat":`in_review`},o.review)):null)}}function Mt(e,t,n){let r=[];try{let i=t.get?.(`layout`)??t.layout;n.installCloseRequester(()=>{i?.selectPanel(null)}),r.push(()=>{n.installCloseRequester(void 0)});let a=At(n);r.push(e.inject(`main`,()=>e.register({name:`main`,key:Ot},a)));let o=jt(n);r.push(e.inject(`sidebar.panellist`,()=>e.register({name:`sidebar.panellist`,id:Ot,order:10,label:()=>U(`shared.entry.label`)},o))),console.info(`[dsh-taskboard] official panel mode: registered`,Ot)}catch(e){console.error(`[dsh-taskboard] official panel registration failed — falling back to legacy mounting:`,e);for(let e of r.splice(0))e();return}return()=>{for(let e of r.splice(0))e()}}function Nt(e,t){let n=kt(e);if(n!==void 0){let r=Mt(n,e,t);if(r!==void 0)return r}let r=[];r=[xt(t),Dt(t)];let i=0,a,o=setInterval(()=>{i++;let n=kt(e);if(n!==void 0){let i=Mt(n,e,t);if(i!==void 0){a=i,clearInterval(o);for(let e of r.splice(0))e();return}}i>=3&&clearInterval(o)},350);return()=>{clearInterval(o);for(let e of r.splice(0))e();a?.()}}function Pt(e){let t=(e,t,n)=>e.list.getSnapshot().byId[n]===void 0?`absent`:t?.list.getSnapshot().archivedSessionIds.includes(n)??!1?`archived`:`openable`;return async n=>{let r=e.getSessions();if(r===void 0)return`unavailable`;try{let i=t(r,e.getWorkspaces(),n);if(i===`absent`){try{await r.refresh()}catch{}i=t(r,e.getWorkspaces(),n)}return i===`archived`?`archived`:i===`absent`?`missing`:(r.open(n),`opened`)}catch{return`unavailable`}}}const Ft=[`connection`];function It(e){try{he(),se(e.get?.(`locale`),()=>e.get?.(`locale`));let t=_(),n=new pe(t);n.installModelCatalog(async()=>{try{let t=e.get?.(`modelDirectories`)??e.modelDirectories;if(t?.catalog?.load!==void 0){let e=await t.catalog.load();if(e?.groups!==void 0&&e.groups.length>0){let t=[];for(let n of e.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}}catch{}try{let t=e.get?.(`remote`)??e.remote;if(t?.session?.modelCatalog!==void 0){let e=await t.session.modelCatalog();if(e.ok&&e.value?.groups!==void 0&&e.value.groups.length>0){let t=[];for(let n of e.value.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}if(t?.llm?.models!==void 0){let e=await t.llm.models({});if(e.result.ok&&e.result.value?.groups!==void 0&&e.result.value.groups.length>0){let t=[];for(let n of e.result.value.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}}catch{}try{let t=e.get?.(`connection`)??e.connection;if(t?.api?.llm?.models!==void 0){let e=await t.api.llm.models({});if(e.result.ok&&e.result.value?.groups!==void 0&&e.result.value.groups.length>0){let t=[];for(let n of e.result.value.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}}catch{}try{let e=await t.modelCatalog();if(e.models!==void 0&&e.models.length>0)return e.models}catch{}return[]}),n.installPresetRoster(async()=>{try{let t=e.get?.(`remote`)??e.remote;if(t?.agentPresets?.list!==void 0){let e=await t.agentPresets.list(),n=e.ok===!0?e.value.presets:e.result?.ok===!0?e.result.value.presets:void 0;if(n!==void 0&&n.length>0){let e=n.map(e=>({id:e.id,name:e.name})),t=n.find(e=>e.isDefault);return{presets:e,...t===void 0?{}:{defaultId:t.id}}}}}catch{}try{let t=e.get?.(`connection`)??e.connection;if(t?.api?.agentPresets?.list!==void 0){let e=await t.api.agentPresets.list({});if(e.result.ok&&e.result.value?.presets!==void 0&&e.result.value.presets.length>0){let t=e.result.value.presets.map(e=>({id:e.id,name:e.name})),n=e.result.value.presets.find(e=>e.isDefault);return{presets:t,...n===void 0?{}:{defaultId:n.id}}}}}catch{}try{let e=await t.modelCatalog();if(e.presets!==void 0&&e.presets.length>0)return{presets:e.presets,...e.defaultPresetId===void 0?{}:{defaultId:e.defaultPresetId}}}catch{}return{presets:[]}}),n.installSessionJumper(Pt({getSessions:()=>e.get?.(`sessions`),getWorkspaces:()=>e.get?.(`workspaces`)})),n.start();let r=[];try{r.push(Nt(e,n))}catch(e){console.error(`[dsh-taskboard] mount failed:`,e)}e.effect?.(()=>()=>{for(let e of r.splice(0))e();n.dispose(),ce()},`dsh-taskboard: client mount`)}catch(e){console.error(`[dsh-taskboard] client half failed to start:`,e)}}exports.apply=It,exports.inject=Ft,exports.name=`dsh-taskboard/client`; +`,t=/\s/.test(e)||r===0,i=n.slice(r+1),a=!/\s/.test(i);if(t&&a){ne(r),te(i),T(!0);return}}T(!1)},P=n=>{let r=g.current;if(r===null||D<0)return;let i=r.selectionStart,a=e.slice(0,D),o=e.slice(i),s=`/${n.name} `;t(a+s+o),T(!1),setTimeout(()=>{if(g.current!==null){let e=D+s.length;g.current.focus(),g.current.setSelectionRange(e,e)}},0)},F=e=>{if(w&&M.length>0){if(e.key===`ArrowDown`){e.preventDefault(),k(e=>(e+1)%M.length);return}if(e.key===`ArrowUp`){e.preventDefault(),k(e=>(e-1+M.length)%M.length);return}if(e.key===`Enter`||e.key===`Tab`){let t=M[O];if(t!==void 0){e.preventDefault(),P(t);return}}if(e.key===`Escape`){e.preventDefault(),T(!1);return}}},I=(0,c.useCallback)(()=>{let e=g.current;if(e===null)return;let t=e.getBoundingClientRect(),n=window.innerHeight,r=_.current?.offsetHeight??0,i=r>0?r:240,a=t.top-6-8,o=n-8-(t.bottom+6),s=o>a,c=Math.min(i,Math.max(s?o:a,120)),l=s?t.bottom+6:t.top-6-c;x(e=>e.left===t.left&&e.top===l&&e.width===t.width&&e.maxHeight===c?e:{position:`fixed`,left:t.left,top:l,width:t.width,maxHeight:c,zIndex:100})},[]);return(0,c.useLayoutEffect)(()=>{w&&I()}),(0,c.useEffect)(()=>{if(w)return window.addEventListener(`scroll`,I,!0),window.addEventListener(`resize`,I),()=>{window.removeEventListener(`scroll`,I,!0),window.removeEventListener(`resize`,I)}},[w,I]),(0,l.jsxs)(`div`,{className:`dsh-atb-prompt-wrap ${d??``}`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-prompt-inner`,children:[(0,l.jsx)(`textarea`,{ref:g,className:`dsh-atb-prompt-input`,value:e,rows:i,maxLength:a,disabled:o||A,autoFocus:s,placeholder:r,"aria-label":f,onChange:e=>{t(e.target.value),N()},onKeyUp:N,onClick:N,onKeyDown:F,onPaste:e=>{let t=Me(e.clipboardData.files);p&&t.length>0&&(e.preventDefault(),j(t))},onDragOver:e=>{p&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{let t=Me(e.dataTransfer.files);p&&t.length>0&&(e.preventDefault(),j(t))}}),w&&M.length>0&&(0,u.createPortal)((0,l.jsxs)(`div`,{ref:_,className:`dsh-atb-slash-popup`,style:b,role:`listbox`,"aria-label":h(`slash.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-slash-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-slash-title`,children:h(`slash.title`)}),(0,l.jsx)(`span`,{className:`dsh-atb-slash-hint`,children:h(`slash.hint`)})]}),(0,l.jsx)(`div`,{ref:v,className:`dsh-atb-slash-list`,children:M.map((e,t)=>(0,l.jsxs)(`div`,{role:`option`,"aria-selected":t===O,className:`dsh-atb-slash-item`,"data-active":t===O?`true`:void 0,"data-kind":e.kind,onClick:()=>P(e),onMouseEnter:()=>k(t),children:[(0,l.jsx)(`span`,{className:`dsh-atb-slash-badge`,"data-kind":e.kind,children:e.kind===`command`?h(`slash.badge.command`):h(`slash.badge.skill`)}),(0,l.jsxs)(`span`,{className:`dsh-atb-slash-name`,children:[`/`,e.name]}),e.hint&&(0,l.jsx)(`span`,{className:`dsh-atb-slash-param`,children:e.hint}),e.description&&(0,l.jsx)(`span`,{className:`dsh-atb-slash-desc`,children:e.description})]},`${e.kind}-${e.name}`))})]}),document.body)]}),p&&(0,l.jsxs)(`div`,{className:`dsh-atb-image-actions`,children:[(0,l.jsx)(`input`,{ref:y,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,multiple:!0,hidden:!0,onChange:e=>{e.target.files!==null&&j(e.target.files),e.target.value=``}}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-image-add`,disabled:o||A,onClick:()=>y.current?.click(),children:h(A?`image.uploading`:`image.add`)}),(0,l.jsx)(`span`,{className:`dsh-atb-image-hint`,children:h(`image.hint`)})]}),(0,l.jsx)(`div`,{className:`dsh-atb-prompt-foot`,children:(0,l.jsxs)(`span`,{className:`dsh-atb-prompt-tip`,children:[h(`slash.tipA`),` `,(0,l.jsx)(`code`,{children:`/`}),` `,h(`slash.tipB`)]})})]})}const Je=`dsh-taskboard-last-model-v1`;function Ye(){try{let e=localStorage.getItem(Je);if(e===null)return;let t=JSON.parse(e);if(typeof t==`object`&&t){let{provider:e,model:n,reasoningEffort:r}=t;if(typeof e==`string`&&typeof n==`string`&&e.trim().length>0&&n.trim().length>0)return{provider:e.trim(),model:n.trim(),...typeof r==`string`&&r.trim().length>0?{reasoningEffort:r.trim()}:{}}}return}catch{return}}function Xe(e){try{e===void 0?localStorage.removeItem(Je):localStorage.setItem(Je,JSON.stringify(e))}catch{}}const Ze=e=>[{value:`urgent`,label:e(`form.urgency.urgent`),hint:e(`form.urgency.urgentHint`)},{value:`normal`,label:e(`form.urgency.normal`),hint:e(`form.urgency.normalHint`)},{value:`relaxed`,label:e(`form.urgency.relaxed`),hint:e(`form.urgency.relaxedHint`)}],Qe=e=>[{label:e(`form.cron.daily`),cron:`0 9 * * *`},{label:e(`form.cron.hourly`),cron:`0 * * * *`},{label:e(`form.cron.every10min`),cron:`*/10 * * * *`},{label:e(`form.cron.weekly`),cron:`0 9 * * 1`}],$e=e=>[{value:`workspace-write`,label:e(`form.perm.write`),hint:e(`form.perm.writeHint`),icon:`📁`},{value:`read-only`,label:e(`form.perm.readOnly`),hint:e(`form.perm.readOnlyHint`),icon:`🔒`},{value:`danger-full-access`,label:e(`form.perm.fullAccess`),hint:e(`form.perm.fullAccessHint`),icon:`⚡`}];function $({label:e,required:t=!1,full:n=!1,children:r}){return(0,l.jsxs)(`label`,{className:`dsh-atb-field`,"data-span":n?`full`:void 0,children:[(0,l.jsxs)(`span`,{className:`dsh-atb-field-label`,children:[e,t&&(0,l.jsx)(`em`,{className:`dsh-atb-req`,children:`*`})]}),r]})}function et({rows:e,onChange:t,editing:n}){let r=W(),i=(n,r)=>{t(e.map((e,t)=>t===n?{...e,...r}:e))},a=e.filter(e=>e.checked).length;return(0,l.jsxs)(`div`,{className:`dsh-atb-cke`,children:[e.map((a,o)=>(0,l.jsxs)(`div`,{className:`dsh-atb-cke-row`,children:[n&&(0,l.jsx)(`input`,{type:`checkbox`,className:`dsh-atb-cke-box`,checked:a.checked,title:r(`form.check.checkedTitle`,{who:a.checkedBy??r(`form.check.notCheckedYet`)}),onChange:e=>i(o,{checked:e.target.checked})}),(0,l.jsx)(`input`,{className:`dsh-atb-cke-text`,value:a.text,maxLength:200,placeholder:r(`form.check.itemPlaceholder`,{n:o+1}),spellCheck:!1,onChange:e=>i(o,{text:e.target.value})}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-cke-del`,title:r(`form.check.removeTitle`),onClick:()=>t(e.filter((e,t)=>t!==o)),children:`✕`})]},a.id??`new-${o}`)),e.length<30&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-cke-add`,onClick:()=>t([...e,{text:``,checked:!1}]),children:r(`form.check.add`)}),e.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-cke-hint`,children:n?r(`form.check.hintEdit`,{checked:a,total:e.length}):r(`form.check.hintCreate`,{n:e.length})})]})}function tt({controller:e,task:t}){let n=W(),r=e.getSnapshot(),i=r.templatePrefill,a=t!==void 0,[o,s]=(0,c.useState)(t?.title??i?.title??``),[u,d]=(0,c.useState)(t?.description??i?.description??``),[f,p]=(0,c.useState)(t?.prompt??i?.prompt??``),[m,h]=(0,c.useState)(t?.workspaceId??r.filters.workspaceId??r.workspaces[0]?.id??``),[g,_]=(0,c.useState)(t?.urgency??(i?.urgency===`urgent`||i?.urgency===`relaxed`?i.urgency:`normal`)),v=t?.execution??i?.execution,[y,b]=(0,c.useState)(v?.mode===`scheduled`?v.cron===void 0?`once`:`periodic`:`claim`),[x,C]=(0,c.useState)(t?.execution.cron??i?.execution?.cron??`0 9 * * *`),[T,E]=(0,c.useState)(t?.execution.periodicCompletion??i?.execution?.periodicCompletion??`spawn`),te=v?.mode===`scheduled`&&v.runAt!==void 0?v.runAt:void 0,[D,O]=(0,c.useState)(()=>{if(te===void 0)return``;let e=new Date(te);if(Number.isNaN(e.getTime()))return``;let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`}),[A,re]=(0,c.useState)([]),j=t?.model??i?.model??(a?void 0:Ye()),[M,N]=(0,c.useState)(j===void 0?``:JSON.stringify({provider:j.provider,model:j.model})),[P,F]=(0,c.useState)(j?.reasoningEffort??``),I=t?.presetId??i?.presetId??``,[L,R]=(0,c.useState)(I),[z,B]=(0,c.useState)([]),[V,ie]=(0,c.useState)(void 0),[ae,oe]=(0,c.useState)(t?.permission??(i?.permission?S(i.permission):w(r.ledger.settings))),[se,ce]=(0,c.useState)(t?.isolation??(i?.isolation===`none`?`none`:i?.isolation===`worktree`?`worktree`:ee(r.ledger.settings))),[H,le]=(0,c.useState)(t?.checklist!==void 0&&t.checklist.length>0?t.checklist.map(e=>({...e})):(i?.checklist??[]).map(e=>({text:e,checked:!1}))),U=(0,c.useRef)(null),[ue,de]=(0,c.useState)(!1),[fe,pe]=(0,c.useState)(!1);(0,c.useEffect)(()=>{U.current?.focus();let t=t=>{t.key===`Escape`&&e.closeForm()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),(0,c.useEffect)(()=>{e.fetchModelCatalog().then(re).catch(()=>re([]))},[e]),(0,c.useEffect)(()=>{e.fetchPresetCatalog().then(e=>{B(e.presets),ie(e.defaultId),!a&&I===``&&e.defaultId!==void 0&&R(e.defaultId)}).catch(()=>B([]))},[e,a,t?.presetId,I]);let me=y===`periodic`?ne(x.trim()):null,he=me===null?null:k(me,Date.now()),ge=y===`periodic`&&(me===null||he===null),_e=y===`once`&&D!==``?new Date(D).getTime():NaN,ve=y===`once`&&(D===``||Number.isNaN(_e)||_e<=Date.now()),G=o.trim().length>0&&m!==``&&!ge&&!ve,ye=()=>y===`periodic`?{mode:`scheduled`,cron:x.trim(),periodicCompletion:T}:y===`once`?{mode:`scheduled`,runAt:new Date(D).toISOString()}:{mode:`claim`},be=a&&t.status===`in_progress`,K=a&&((t.executions?.length??0)>0||t.status===`in_progress`),q=e.gitAvailable(m),xe=e.repoCount(m),Se=K||!q,Ce=()=>{if(q)return se},we=()=>L.trim().length>0?L.trim():void 0,Te=()=>H.map(e=>({...e,text:e.text.trim()})).filter(e=>e.text.length>0),Y=M===``?void 0:JSON.parse(M),X=(Y===void 0?void 0:A.find(e=>e.provider===Y.provider&&e.model===Y.model))?.reasoning,Ee=()=>{if(Y===void 0)return;let e=P.trim();return{provider:Y.provider,model:Y.model,...e.length>0?{reasoningEffort:e}:{}}},De=()=>{if(!G||ue||fe)return;let n=Ee();a||Xe(n);let r=Ce(),i=we(),s=Te();de(!0),(a?e.update(t.id,t.version,{title:o,description:u,prompt:f,urgency:g,workspaceId:m,execution:ye(),model:n??null,...r!==void 0&&!K?{isolation:r}:{},presetId:i??null,permission:ae,checklist:s.length>0?s:null}):e.create({title:o,workspaceId:m,urgency:g,description:u.length>0?u:void 0,prompt:f.length>0?f:void 0,execution:ye(),model:n,...r===void 0?{}:{isolation:r},...i===void 0?{}:{presetId:i},permission:ae,...s.length>0?{checklist:s.map(e=>e.text)}:{}})).catch(()=>void 0).finally(()=>de(!1))},Oe=()=>{if(!G||be||ue||fe)return;let n=Ee();a||Xe(n);let r=Ce(),i=we(),s=Te();de(!0),(async()=>{if(a)await e.update(t.id,t.version,{title:o,description:u,prompt:f,urgency:g,workspaceId:m,execution:ye(),model:n??null,...r!==void 0&&!K?{isolation:r}:{},presetId:i??null,permission:ae,checklist:s.length>0?s:null})&&await e.run(t.id);else{let t=await e.create({title:o,workspaceId:m,urgency:g,description:u.length>0?u:void 0,prompt:f.length>0?f:void 0,execution:ye(),model:n,...r===void 0?{}:{isolation:r},...i===void 0?{}:{presetId:i},permission:ae,...s.length>0?{checklist:s.map(e=>e.text)}:{}});t!==void 0&&await e.run(t)}})().catch(()=>void 0).finally(()=>de(!1))},ke=G?y===`periodic`&&he!==null?n(`form.hint.nextRun`,{time:J(he)}):y===`once`&&!Number.isNaN(_e)?n(`form.hint.onceAt`,{time:J(_e)}):a?n(`form.hint.saveVersion`,{v:t.version,next:t.version+1}):n(`form.hint.createClaim`):o.trim().length===0?n(`form.hint.needTitle`):n(m===``?`form.hint.needProject`:ve?`form.hint.runAtBad`:`form.hint.cronBad`);return(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeForm()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-taskform-modal`,"data-mode":a?`edit`:`create`,role:`dialog`,"aria-modal":`true`,"aria-label":n(a?`form.title.edit`:`form.title.create`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:a?`✎`:`✚`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:n(a?`form.title.edit`:`form.title.create`)}),(0,l.jsx)(`p`,{children:n(a?`form.subtitle.edit`:`form.subtitle.create`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":n(`shared.close`),onClick:()=>e.closeForm(),children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body dsh-atb-taskform-body`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-form-col dsh-atb-form-left`,children:[(0,l.jsx)($,{label:n(`form.field.title`),required:!0,full:!0,children:(0,l.jsx)(`input`,{ref:U,value:o,onChange:e=>s(e.target.value),placeholder:n(`form.field.titlePlaceholder`),maxLength:200})}),(0,l.jsxs)(`div`,{className:`dsh-atb-form-subgrid`,children:[(0,l.jsx)($,{label:n(`form.field.project`),required:!0,children:(0,l.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),children:r.workspaces.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.title||e.path},e.id))})}),(0,l.jsx)($,{label:n(`form.field.model`),children:(0,l.jsxs)(`select`,{value:M,onChange:e=>{let t=e.target.value;if(N(t),t===``)F(``);else{let e=JSON.parse(t),n=A.find(t=>t.provider===e.provider&&t.model===e.model);n?.reasoning?.defaultEffort===void 0?F(``):F(n.reasoning.defaultEffort)}},children:[(0,l.jsx)(`option`,{value:``,children:n(`form.field.modelDefault`)}),A.map(e=>(0,l.jsx)(`option`,{value:JSON.stringify({provider:e.provider,model:e.model}),children:n(`form.model.option`,{name:e.name??e.model,provider:e.provider})},`${e.provider}/${e.model}`))]})}),Y!==void 0&&(0,l.jsx)($,{label:n(`form.field.effort`),children:(0,l.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),title:n(`form.field.effortTitle`),children:[(0,l.jsxs)(`option`,{value:``,children:[n(`form.effort.follow`),X?.defaultEffort===void 0?``:n(`shared.current`,{name:X.efforts.find(e=>e.id===X.defaultEffort)?.name??X.defaultEffort})]}),X!==void 0&&X.efforts.length>0?X.efforts.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.name,e.description?` (${e.description})`:``]},e.id)):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`option`,{value:`low`,children:n(`form.effort.low`)}),(0,l.jsx)(`option`,{value:`medium`,children:n(`form.effort.medium`)}),(0,l.jsx)(`option`,{value:`high`,children:n(`form.effort.high`)}),(0,l.jsx)(`option`,{value:`none`,children:n(`form.effort.none`)})]})]})}),z.length>0&&(0,l.jsx)($,{label:n(`form.field.preset`),children:(0,l.jsxs)(`select`,{value:L,onChange:e=>R(e.target.value),title:n(`form.field.presetTitle`),children:[(0,l.jsxs)(`option`,{value:``,children:[n(`form.preset.follow`),V===void 0?``:n(`shared.current`,{name:z.find(e=>e.id===V)?.name??V})]}),z.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.name??e.id,e.id===V?n(`form.preset.defaultTag`):``]},e.id))]})})]}),(0,l.jsx)($,{label:n(`form.field.urgency`),full:!0,children:(0,l.jsx)(`div`,{className:`dsh-atb-urgency-picker`,children:Ze(n).map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-urgency-opt`,"data-urgency":e.value,"data-on":g===e.value,onClick:()=>_(e.value),children:[(0,l.jsxs)(`span`,{className:`dsh-atb-urgency-name`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-urgency":e.value}),e.label]}),(0,l.jsx)(`span`,{className:`dsh-atb-urgency-hint`,children:e.hint})]},e.value))})}),(0,l.jsx)($,{label:n(`form.field.permission`),full:!0,children:(0,l.jsx)(`div`,{className:`dsh-atb-perm-picker`,children:$e(n).map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":ae===e.value,onClick:()=>oe(e.value),children:[(0,l.jsxs)(`span`,{className:`dsh-atb-perm-name`,children:[e.icon,` `,e.label,e.value===`workspace-write`?n(`form.perm.defaultTag`):``]}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:e.hint})]},e.value))})}),(0,l.jsx)($,{label:n(`form.field.mode`),full:!0,children:(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,"data-exec":`true`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":y===`claim`,onClick:()=>b(`claim`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.mode.claim`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.mode.claimHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":y===`once`,onClick:()=>b(`once`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.mode.once`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.mode.onceHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":y===`periodic`,onClick:()=>b(`periodic`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.mode.periodic`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.mode.periodicHint`)})]})]})}),y===`once`&&(0,l.jsx)($,{label:n(`form.field.runAt`),required:!0,full:!0,children:(0,l.jsx)(`input`,{type:`datetime-local`,className:ve?`dsh-atb-input-bad`:void 0,value:D,onChange:e=>O(e.target.value),spellCheck:!1})}),y===`periodic`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)($,{label:n(`form.field.cron`),required:!0,full:!0,children:[(0,l.jsx)(`input`,{className:ge?`dsh-atb-input-bad`:void 0,value:x,onChange:e=>C(e.target.value),placeholder:n(`form.cron.placeholder`),spellCheck:!1}),(0,l.jsxs)(`span`,{className:`dsh-atb-cron-presets`,children:[Qe(n).map(e=>(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-cron-preset`,"data-on":x.trim()===e.cron,onClick:()=>C(e.cron),children:e.label},e.cron)),!ge&&he!==null&&(0,l.jsx)(`span`,{className:`dsh-atb-cron-next`,children:n(`form.cron.next`,{time:J(he)})})]})]}),(0,l.jsx)($,{label:n(`form.field.periodicCompletion`),full:!0,children:(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":T===`rearm`,onClick:()=>E(`rearm`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.periodicCompletion.rearm`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.periodicCompletion.rearmHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":T===`spawn`,onClick:()=>E(`spawn`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.periodicCompletion.spawn`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(`form.periodicCompletion.spawnHint`)})]})]})})]}),(0,l.jsxs)($,{label:n(`form.field.isolation`),full:!0,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,"data-disabled":Se?`true`:void 0,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":se===`worktree`,disabled:Se,title:n(K?`form.iso.locked`:q?`form.iso.worktreeTitle`:`form.iso.nonGit`),onClick:()=>ce(`worktree`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.iso.worktree`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(K?`form.iso.lockedShort`:q?`form.iso.worktreeHint`:`form.iso.nonGit`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":se===`none`,disabled:Se,title:n(K?`form.iso.locked`:`form.iso.noneTitle`),onClick:()=>ce(`none`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:n(`form.iso.none`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:n(K?`form.iso.lockedShort`:q?`form.iso.noneHint`:`form.iso.noneHintNonGit`)})]})]}),!q&&!K&&(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:n(`form.iso.nonGitNote`)}),q&&!K&&xe>1&&(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,"data-mirror":`true`,children:n(`form.iso.mirrorNote`,{n:xe})})]}),(0,l.jsx)($,{label:n(a?`form.field.checklist`:`form.field.checklistOptional`),full:!0,children:(0,l.jsx)(et,{rows:H,onChange:le,editing:a})})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-form-col dsh-atb-form-right`,children:[(0,l.jsx)($,{label:n(a?`form.field.description`:`form.field.descriptionOptional`),full:!0,children:(0,l.jsx)(qe,{value:u,onChange:d,controller:e,rows:7,placeholder:n(`form.desc.placeholder`),allowImages:!0,onUploadingChange:pe})}),(0,l.jsx)($,{label:n(a?`form.field.prompt`:`form.field.promptOptional`),full:!0,children:(0,l.jsx)(qe,{value:f,onChange:p,controller:e,rows:7,placeholder:n(`form.prompt.placeholder`)})})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,"data-tone":G?void 0:`bad`,children:ke}),(0,l.jsxs)(`span`,{className:`dsh-atb-modal-footbtns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>e.closeForm(),children:n(`shared.cancel`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:!G||be||ue||fe,title:n(be?`form.action.runBlockedTitle`:ue||fe?`form.action.runBusyTitle`:`form.action.runTitle`),onClick:Oe,children:n(`form.action.run`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,disabled:!G||ue||fe,onClick:De,children:n(a?`form.action.save`:`form.action.create`)})]})]})]})})}const nt=e=>[{value:`none`,name:e(`form.iso.none`),hint:e(`set.iso.noneHint`)},{value:`worktree`,name:e(`form.iso.worktree`),hint:e(`set.iso.worktreeHint`)}];function rt({controller:e}){let t=W(),n=e.getSnapshot(),r=n.ledger.settings?.defaultIsolation??`none`,i=C(n.ledger.settings),a=w(n.ledger.settings),o=T(n.ledger.settings),s=E(n.ledger.settings),u=te(n.ledger.settings),d=D(n.ledger.settings),[f,p]=(0,c.useState)(r),[m,h]=(0,c.useState)(i),[g,_]=(0,c.useState)(a),[v,y]=(0,c.useState)(String(o)),[b,x]=(0,c.useState)(String(s)),[S,ee]=(0,c.useState)(String(u)),[ne,O]=(0,c.useState)(String(d)),[k,A]=(0,c.useState)(n.storage?.currentDirectory??``),[re,j]=(0,c.useState)(!1),[M,N]=(0,c.useState)(!1),P=Number(v),F=Number(b),I=Number(S),L=Number(ne),R=Number.isSafeInteger(P)&&P>=1&&P<=100&&Number.isSafeInteger(F)&&F>=1&&F<=1440&&Number.isSafeInteger(I)&&I>=0&&I<=10080&&Number.isSafeInteger(L)&&L>=0&&L<=6e4,z=f!==r||m!==i||g!==a||v!==String(o)||b!==String(s)||S!==String(u)||ne!==String(d),B=k.trim().length===0?n.storage?.defaultDirectory??``:k.trim(),V=n.storage!==void 0&&B!==n.storage.currentDirectory;return(0,c.useEffect)(()=>{!re&&n.storage!==void 0&&A(n.storage.currentDirectory)},[n.storage,re]),(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeSettings()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-set`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`set.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`🛠`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`set.title`)}),(0,l.jsx)(`p`,{children:t(`set.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:()=>e.closeSettings(),children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body`,children:[(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.iso.heading`)}),(0,l.jsx)(`div`,{className:`dsh-atb-mode-picker`,children:nt(t).map(e=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":f===e.value,title:e.hint,onClick:()=>p(e.value),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:e.name}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:e.hint})]},e.value))}),(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:t(`set.iso.current`,{current:t(r===`worktree`?`form.iso.worktree`:`form.iso.none`)})})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.sync.heading`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":!m,title:t(`set.sync.off.title`),onClick:()=>h(!1),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`set.sync.off.name`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`set.sync.off.hint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":m,title:t(`set.sync.on.title`),onClick:()=>h(!0),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`set.sync.on.name`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`set.sync.on.hint`)})]})]}),(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:t(i?`set.sync.stateOn`:`set.sync.stateOff`)})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.perm.heading`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-perm-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":g===`workspace-write`,onClick:()=>_(`workspace-write`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-perm-name`,children:t(`set.perm.writeName`)}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:t(`set.perm.writeHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":g===`read-only`,onClick:()=>_(`read-only`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-perm-name`,children:t(`set.perm.readOnlyName`)}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:t(`set.perm.readOnlyHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-perm-opt`,"data-on":g===`danger-full-access`,onClick:()=>_(`danger-full-access`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-perm-name`,children:t(`set.perm.fullName`)}),(0,l.jsx)(`span`,{className:`dsh-atb-perm-hint`,children:t(`set.perm.fullHint`)})]})]}),(0,l.jsx)(`span`,{className:`dsh-atb-isolation-note`,children:t(`set.perm.current`,{current:t(a===`read-only`?`set.perm.readOnlyName`:a===`danger-full-access`?`set.perm.fullName`:`set.perm.writeName`)})})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.schedule.heading`)}),(0,l.jsx)(`p`,{className:`dsh-atb-isolation-note`,children:t(`set.schedule.hint`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-settings-numbers`,children:[(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.concurrent`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`1`,max:`100`,step:`1`,value:v,onChange:e=>y(e.target.value)})]}),(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.missedAfter`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`1`,max:`1440`,step:`1`,value:b,onChange:e=>x(e.target.value)})]}),(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.queueMaxAge`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`0`,max:`10080`,step:`1`,value:S,onChange:e=>ee(e.target.value)})]}),(0,l.jsxs)(`label`,{children:[(0,l.jsx)(`span`,{children:t(`set.schedule.dispatchInterval`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input`,type:`number`,min:`0`,max:`60000`,step:`1`,value:ne,onChange:e=>O(e.target.value)})]})]}),!R&&(0,l.jsx)(`span`,{className:`dsh-atb-storage-error`,children:t(`set.schedule.invalid`)})]}),(0,l.jsxs)(`section`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`set.storage.heading`)}),(0,l.jsx)(`p`,{className:`dsh-atb-isolation-note`,children:t(`set.storage.hint`)}),(0,l.jsx)(`input`,{className:`dsh-atb-input dsh-atb-storage-path`,value:k,disabled:n.storage===void 0||M,placeholder:n.storage?.defaultDirectory??t(`set.storage.loading`),onChange:t=>{A(t.target.value),j(!0),e.dismissStorageNotice()}}),n.storageNotice!==void 0&&(0,l.jsxs)(`div`,{className:`dsh-atb-storage-notice`,role:`status`,children:[(0,l.jsxs)(`span`,{className:`dsh-atb-storage-notice-ok`,children:[`✓ `,t(`set.storage.migrated`,{path:n.storageNotice.path})]}),n.storageNotice.warnings.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-storage-notice-warn`,children:t(`set.storage.warnings`,{warnings:n.storageNotice.warnings.join(`; `)})})]}),n.storage!==void 0&&(0,l.jsxs)(`div`,{className:`dsh-atb-storage-meta`,children:[(0,l.jsx)(`span`,{children:t(`set.storage.current`,{path:n.storage.currentDirectory})}),(0,l.jsx)(`span`,{children:t(`set.storage.assets`,{count:n.storage.assetCount,size:(n.storage.assetBytes/1024/1024).toFixed(1)})}),n.storage.error!==void 0&&(0,l.jsx)(`span`,{className:`dsh-atb-storage-error`,children:n.storage.error})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-storage-actions`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:n.storage===void 0||M,onClick:()=>{A(n.storage?.defaultDirectory??``),j(!0)},children:t(`set.storage.default`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:n.storage===void 0||M||B.length===0,onClick:()=>{N(!0),e.checkStorage(B).finally(()=>N(!1))},children:t(`set.storage.check`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,disabled:!V||M,onClick:()=>{window.confirm(t(`set.storage.confirm`,{from:n.storage?.currentDirectory??``,to:B}))&&(N(!0),e.migrateStorage(B).then(e=>{e&&(j(!1),A(B))}).finally(()=>N(!1)))},children:t(M?`set.storage.migrating`:`set.storage.migrate`)})]})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,children:t(z?`set.foot.dirty`:`set.foot.clean`)}),(0,l.jsxs)(`span`,{className:`dsh-atb-modal-footbtns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>e.closeSettings(),children:t(`shared.cancel`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,disabled:!z||!R,onClick:()=>{e.updateSettings({defaultIsolation:f,syncExternalSessions:m,defaultPermission:g,maxConcurrent:P,scheduleMissedAfterMinutes:F,queueMaxAgeMinutes:I,dispatchIntervalMs:L}).then(t=>{t&&e.closeSettings()})},children:t(`set.action.save`)})]})]})]})})}function it({row:e}){return(0,l.jsxs)(`div`,{className:`dsh-atb-imp-row`,title:e.id,children:[(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-title`,children:e.title}),(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-status`,children:e.status})]})}function at({controller:e}){let t=W(),[n,r]=(0,c.useState)(``),[i,a]=(0,c.useState)(null),[o,s]=(0,c.useState)(void 0),[u,d]=(0,c.useState)(void 0),[f,p]=(0,c.useState)(`merge`),[m,h]=(0,c.useState)(!1),[g,_]=(0,c.useState)(void 0),[v,y]=(0,c.useState)(!1),b=(0,c.useRef)(null),{alert:x,el:S}=X(),ee=n=>{d(void 0),s(void 0),_(void 0),y(!1),r(``),a(null),n!==void 0&&n.text().then(i=>{try{let t=JSON.parse(i);a(t),r(n.name),e.importPreview(t).then(e=>{e!==void 0&&d(e)})}catch{s(t(`imp.parseError`))}})},C=()=>{if(!(i===null||u===void 0||m)){if(f===`replace`&&!v){y(!0);return}h(!0),e.importCommit(f,i).then(e=>{h(!1),y(!1),e!==void 0&&_(e.mode===`replace`?t(`imp.result.replace`,{n:e.created+e.overwritten,total:e.replacedTotal??0}):t(`imp.result.merge`,{n:e.created,m:e.overwritten}))})}},w=()=>e.closeImport();return(0,l.jsxs)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:e=>{e.target===e.currentTarget&&w()},children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-imp`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`imp.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`⬆`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`imp.title`)}),(0,l.jsx)(`p`,{children:t(`imp.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:w,children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-imp-picker`,children:[(0,l.jsx)(`input`,{ref:b,type:`file`,accept:`.json,application/json`,onChange:e=>ee(e.target.files?.[0])}),n.length>0&&(0,l.jsx)(`span`,{className:`dsh-atb-imp-filename`,children:n})]}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-note`,children:t(`imp.note`)}),o!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-imp-error`,children:o}),u===void 0&&o===void 0&&n.length>0&&(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`imp.previewing`)}),u!==void 0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stats`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stat`,"data-tone":`ok`,children:[(0,l.jsx)(`b`,{children:u.create.length}),(0,l.jsx)(`span`,{children:t(`imp.stat.create`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stat`,"data-tone":`warn`,children:[(0,l.jsx)(`b`,{children:u.overwrite.length}),(0,l.jsx)(`span`,{children:t(`imp.stat.overwrite`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-imp-stat`,"data-tone":u.invalid.length>0?`bad`:void 0,children:[(0,l.jsx)(`b`,{children:u.invalid.length}),(0,l.jsx)(`span`,{children:t(`imp.stat.invalid`)})]})]}),u.create.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-imp-sec`,children:[(0,l.jsx)(`h4`,{children:t(`imp.sec.create`)}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-list`,children:u.create.map(e=>(0,l.jsx)(it,{row:e},e.id))})]}),u.overwrite.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-imp-sec`,children:[(0,l.jsx)(`h4`,{children:t(`imp.sec.overwrite`)}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-list`,children:u.overwrite.map(e=>(0,l.jsx)(it,{row:e},e.id))})]}),u.invalid.length>0&&(0,l.jsxs)(`div`,{className:`dsh-atb-imp-sec`,children:[(0,l.jsx)(`h4`,{children:t(`imp.sec.invalid`)}),(0,l.jsx)(`div`,{className:`dsh-atb-imp-list`,children:u.invalid.map((e,n)=>(0,l.jsxs)(`div`,{className:`dsh-atb-imp-row`,"data-tone":`bad`,title:e.id??``,children:[(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-title`,children:e.id??t(`imp.noId`)}),(0,l.jsx)(`span`,{className:`dsh-atb-imp-row-status`,children:e.reason})]},e.id??`invalid-${n}`))})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-mode-picker`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":f===`merge`,onClick:()=>{p(`merge`),y(!1)},children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`imp.mode.merge`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`imp.mode.mergeHint`)})]}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-mode-opt`,"data-on":f===`replace`,onClick:()=>p(`replace`),children:[(0,l.jsx)(`span`,{className:`dsh-atb-mode-name`,children:t(`imp.mode.replace`)}),(0,l.jsx)(`span`,{className:`dsh-atb-mode-hint`,children:t(`imp.mode.replaceHint`)})]})]}),g!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-imp-result`,children:g})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,children:t(f===`replace`?v?`imp.foot.replaceConfirm`:`imp.foot.replaceNeedConfirm`:`imp.foot.mergeHint`)}),(0,l.jsxs)(`span`,{className:`dsh-atb-modal-footbtns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:w,children:t(g===void 0?`shared.cancel`:`shared.close`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,"data-danger":f===`replace`&&v?`true`:void 0,disabled:u===void 0||m,onClick:C,children:t(f===`replace`&&v?`imp.action.confirmReplace`:`imp.action.run`)})]})]})]}),S]})}function ot({controller:e}){let t=W(),n=e.getSnapshot(),[r,i]=(0,c.useState)({}),[a,o]=(0,c.useState)(void 0),{alert:s,el:u}=X(),d=()=>e.closeTemplateManager(),f=e=>r[e.id]??xe(e),p=e=>{if(e===void 0)return``;let n=G[e];return n===void 0?` · ${e}`:` · ${t(n)}`},m=(r,a)=>{let o=n.templates.find(e=>e.id===r);o===void 0||a===xe(o)||e.upsertTemplate({id:r,name:a,task:o.task}).then(e=>{e&&(i(e=>{let t={...e};return delete t[r],t}),s(t(`tpl.renamed`)))})};return(0,l.jsxs)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:e=>{e.target===e.currentTarget&&d()},children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-tplm`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`tpl.aria`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`⌗`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`tpl.title`)}),(0,l.jsx)(`p`,{children:t(`tpl.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:d,children:`✕`})]}),(0,l.jsx)(`div`,{className:`dsh-atb-modal-body`,children:n.templates.length===0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`tpl.empty`)}):(0,l.jsx)(`div`,{className:`dsh-atb-tplm-list`,children:n.templates.map(n=>(0,l.jsxs)(`div`,{className:`dsh-atb-tplm-row`,children:[(0,l.jsx)(`input`,{className:`dsh-atb-tplm-name`,value:f(n),maxLength:60,spellCheck:!1,"aria-label":t(`tpl.name.aria`,{name:xe(n)}),onChange:e=>i(t=>({...t,[n.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&m(n.id,f(n))}}),(0,l.jsxs)(`span`,{className:`dsh-atb-tplm-meta`,title:`${n.builtin===!0?t(`tpl.builtin`):t(`tpl.custom`)}${n.task.checklist!==void 0&&n.task.checklist.length>0?t(`tpl.meta.checklist`,{n:n.task.checklist.length}):``}${p(n.task.urgency)}${n.task.permission===void 0?``:` · ${t(`shared.permission`)}: ${n.task.permission}`}`,children:[n.builtin===!0?t(`tpl.builtin`):t(`tpl.custom`),n.task.checklist!==void 0&&n.task.checklist.length>0?t(`tpl.meta.checklist`,{n:n.task.checklist.length}):``,p(n.task.urgency),n.task.permission!==void 0&&n.task.permission!==`workspace-write`?` · ${n.task.permission===`read-only`?t(`tpl.meta.permReadOnly`):t(`tpl.meta.permFull`)}`:``]}),(0,l.jsxs)(`span`,{className:`dsh-atb-tplm-btns`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:f(n)===xe(n)||f(n).trim().length===0,title:t(`tpl.rename.title`),onClick:()=>m(n.id,f(n)),children:t(`tpl.rename.button`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`tpl.use.title`),onClick:()=>{d(),e.newFromTemplate(Se(n))},children:t(`tpl.use.button`)}),a===n.id?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>{e.deleteTemplate(n.id),o(void 0)},children:t(`shared.confirmDelete`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>o(void 0),children:t(`shared.cancel`)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,title:t(`tpl.delete.title`),onClick:()=>o(n.id),children:`🗑`})]})]},n.id))})}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-foot`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-hint`,children:t(`tpl.foot.hint`)}),(0,l.jsx)(`span`,{className:`dsh-atb-modal-footbtns`,children:(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:d,children:t(`shared.close`)})})]})]}),u]})}const st={urgent:0,normal:1,relaxed:2};function ct(e,t){let n=e.search.trim().toLowerCase(),r=t.filter(t=>(e.filters.workspaceId===void 0||t.workspaceId===e.filters.workspaceId)&&(e.filters.urgencies.length===0||e.filters.urgencies.includes(t.urgency))&&(n.length===0||t.title.toLowerCase().includes(n)||t.id.toLowerCase().includes(n)));if(e.sortBy==="default")return r;let i=[...r];return e.sortBy===`updated`?i.sort((e,t)=>t.updatedAt-e.updatedAt):e.sortBy===`created`?i.sort((e,t)=>t.createdAt-e.createdAt):e.sortBy===`urgency`?i.sort((e,t)=>st[e.urgency]-st[t.urgency]||t.updatedAt-e.updatedAt):e.sortBy===`title`&&i.sort((e,t)=>e.title.localeCompare(t.title,void 0,{numeric:!0})),i}function lt({controller:e}){let t=W(),n=(0,c.useSyncExternalStore)(t=>e.subscribe(t),()=>e.getSnapshot()),[r,i]=(0,c.useState)(()=>Date.now());(0,c.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),6e4);return()=>clearInterval(e)},[]);let a=ct(n,n.ledger.tasks.filter(e=>e.trashedAt===void 0)),o=n.selectedId===void 0?void 0:n.ledger.tasks.find(e=>e.id===n.selectedId),{alert:s,el:u}=X(),[d,f]=(0,c.useState)(!1),p=()=>f(!1),[m,h]=(0,c.useState)(!1),g=()=>h(!1);return(0,l.jsxs)(`div`,{className:`dsh-atb-board`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-toolbar`,children:[(0,l.jsx)(`h2`,{className:`dsh-atb-title`,children:t(`board.title`)}),(0,l.jsx)(`span`,{className:`dsh-atb-count`,children:t(`board.count.tasks`,{n:a.length,rev:n.ledger.revision})}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-primary":`true`,onClick:()=>{let t=!d;f(t),t&&e.prepareTemplateMenu()},children:t(`board.action.newTask`)}),d&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`dsh-atb-newmenu-backdrop`,onClick:p}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu-list`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,onClick:()=>{p(),e.setComposer(!0)},children:t(`board.action.blankTask`)}),n.templates.map(t=>{let n=xe(t),r=Se(t);return(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,title:r.description!==void 0&&r.description.length>0?r.description.slice(0,120):n,onClick:()=>{p(),e.newFromTemplate(r)},children:n},t.id)}),(0,l.jsx)(`div`,{className:`dsh-atb-newmenu-sep`}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,onClick:()=>{p(),e.openTemplateManager()},children:t(`board.action.manageTemplates`)})]})]})]}),(0,l.jsx)(`div`,{className:`dsh-atb-spacer`}),(0,l.jsx)(`input`,{className:`dsh-atb-input dsh-atb-search`,value:n.search,placeholder:t(`board.search.placeholder`),spellCheck:!1,onChange:t=>e.setSearch(t.target.value)}),(0,l.jsxs)(`select`,{className:`dsh-atb-select`,value:n.filters.workspaceId??``,onChange:t=>e.setWorkspaceFilter(t.target.value===``?void 0:t.target.value),children:[(0,l.jsx)(`option`,{value:``,children:t(`board.filter.allProjects`)}),n.workspaces.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.title||e.path},e.id))]}),(0,l.jsxs)(`select`,{className:`dsh-atb-select`,value:n.sortBy,title:t(`board.sort.title`),onChange:t=>e.setSortBy(t.target.value),children:[(0,l.jsx)(`option`,{value:`default`,children:t(`board.sort.default`)}),(0,l.jsx)(`option`,{value:`updated`,children:t(`board.sort.updated`)}),(0,l.jsx)(`option`,{value:`urgency`,children:t(`board.sort.urgency`)}),(0,l.jsx)(`option`,{value:`created`,children:t(`board.sort.created`)}),(0,l.jsx)(`option`,{value:`title`,children:t(`board.sort.byTitle`)})]}),[`urgent`,`normal`,`relaxed`].map(r=>(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-chip`,"data-urgency":r,"data-on":n.filters.urgencies.includes(r),onClick:()=>e.toggleUrgency(r),children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-urgency":r}),t(G[r])]},r)),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,onClick:()=>e.toggleSecondary(),children:n.secondaryOpen?t(`board.action.backToBoard`):t(`board.action.otherTasks`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.settingsTitle`),onClick:()=>e.openSettings(),children:t(`board.action.settings`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.diagTitle`),onClick:()=>e.openDiagnostics(),children:t(`board.action.diag`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.importTitle`),onClick:()=>e.openImport(),children:t(`board.action.import`)}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,title:t(`board.action.exportTitle`),onClick:()=>h(!m),children:t(`board.action.export`)}),m&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`dsh-atb-newmenu-backdrop`,onClick:g}),(0,l.jsxs)(`div`,{className:`dsh-atb-newmenu-list`,children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,title:t(`board.export.jsonTitle`),onClick:()=>{g(),e.exportJson()},children:t(`board.export.json`)}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-newmenu-opt`,title:t(`board.export.csvTitle`),onClick:()=>{g(),e.exportCsv()},children:t(`board.export.csv`)})]})]})]}),(0,l.jsxs)(`a`,{className:`dsh-atb-ver`,href:`https://github.com/cloader/dsh-taskboard`,target:`_blank`,rel:`noopener noreferrer`,children:[`V`,`0.8.2`]})]}),n.error!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-error`,children:n.error}),n.secondaryOpen?(0,l.jsx)(ft,{controller:e,tasks:ct(n,n.ledger.tasks)}):(0,l.jsx)(`div`,{className:`dsh-atb-columns`,children:v.map(i=>{let o=a.filter(e=>e.status===i);return(0,l.jsxs)(`div`,{className:`dsh-atb-column`,onDragOver:e=>{e.dataTransfer.types.includes(`application/x-dsh-atb-task`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.dataset.dragover=`true`)},onDragLeave:e=>{delete e.currentTarget.dataset.dragover},onDrop:r=>{r.preventDefault(),delete r.currentTarget.dataset.dragover;let a=r.dataTransfer.getData(we);if(a.length===0)return;let o=n.ledger.tasks.find(e=>e.id===a);if(!(o===void 0||o.status===i)){if(!x(o.status,i)){s(t(`board.drag.forbidden`,{from:t(ge[o.status]),to:t(ge[i])}));return}e.move(a,o.version,i)}},children:[(0,l.jsxs)(`div`,{className:`dsh-atb-colhead`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-status":i}),t(ge[i]),(0,l.jsx)(`span`,{className:`dsh-atb-colcount`,children:o.length}),i===`in_progress`&&(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-queuechip`,title:t(`queue.panel.title`),"data-bad":(n.queue?.depth??0)>0?`true`:void 0,onClick:()=>e.openQueuePanel(),children:t(`board.queue.chip`,{n:n.queue?.depth??0})})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-cards`,children:[o.map(t=>(0,l.jsx)(Y,{task:t,controller:e,draggable:!0,now:r,onAlert:s},t.id)),o.length===0&&(0,l.jsx)(`div`,{className:`dsh-atb-empty`,children:t(`board.empty`)})]})]},i)})}),o!==void 0&&(0,l.jsx)(`div`,{className:`dsh-atb-detailpanel`,children:(0,l.jsx)(We,{task:o,controller:e,now:r},o.id)}),n.composerOpen&&(0,l.jsx)(tt,{controller:e,task:n.editingId===void 0?void 0:n.ledger.tasks.find(e=>e.id===n.editingId)}),n.diagOpen&&(0,l.jsx)(dt,{controller:e}),n.queueOpen&&(0,l.jsx)(ut,{controller:e,onAlert:s}),n.settingsOpen&&(0,l.jsx)(rt,{controller:e}),n.importOpen&&(0,l.jsx)(at,{controller:e}),n.tplManagerOpen&&(0,l.jsx)(ot,{controller:e}),u]})}function ut({controller:e,onAlert:t}){let n=W(),r=e.getSnapshot().queue,[i,a]=(0,c.useState)(!1),[o,s]=(0,c.useState)(!1),u=r?.depth??0,d=r?.oldestWaitMinutes,f=async()=>{if(!i){a(!0);return}s(!0);let r=await e.clearQueue();s(!1),a(!1),r!==void 0&&(t(n(`queue.cleared`,{n:r.cleared})),e.closeQueuePanel())};return(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeQueuePanel()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-queuepanel`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`queue.panel.title`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`📋`}),(0,l.jsx)(`div`,{className:`dsh-atb-modal-headtext`,children:(0,l.jsx)(`h3`,{children:n(`queue.panel.title`)})}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":n(`shared.close`),onClick:()=>e.closeQueuePanel(),children:`✕`})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-body`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-grid`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":u>0?`true`:void 0,children:[(0,l.jsx)(`b`,{children:u}),(0,l.jsx)(`span`,{children:n(`queue.depth`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":d!==void 0&&d>5?`true`:void 0,children:[(0,l.jsxs)(`b`,{children:[d??0,`m`]}),(0,l.jsx)(`span`,{children:n(`queue.wait`)})]})]}),(0,l.jsx)(`div`,{className:`dsh-atb-queuepanel-actions`,children:(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:u===0||o,"data-armed":i?`true`:void 0,onClick:()=>{f()},children:n(i?`queue.confirm`:`queue.clear`)})})]})]})})}function dt({controller:e}){let t=W(),n=e.getSnapshot(),r=n.diagnostics,i=e=>{let t=n.workspaces.find(t=>t.id===e);return t?.title??t?.path??e.slice(0,8)};return(0,l.jsx)(`div`,{className:`dsh-atb-modal-backdrop`,onClick:t=>{t.target===t.currentTarget&&e.closeDiagnostics()},children:(0,l.jsxs)(`div`,{className:`dsh-atb-modal dsh-atb-diag`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`diag.title`),children:[(0,l.jsxs)(`div`,{className:`dsh-atb-modal-head`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-modal-headicon`,children:`⚙`}),(0,l.jsxs)(`div`,{className:`dsh-atb-modal-headtext`,children:[(0,l.jsx)(`h3`,{children:t(`diag.title`)}),(0,l.jsx)(`p`,{children:t(`diag.subtitle`)})]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-modal-close`,"aria-label":t(`shared.close`),onClick:()=>e.closeDiagnostics(),children:`✕`})]}),(0,l.jsx)(`div`,{className:`dsh-atb-modal-body`,children:r===void 0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`shared.loading`)}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-grid`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,children:[(0,l.jsx)(`b`,{children:r.revision}),(0,l.jsx)(`span`,{children:t(`diag.revision`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,children:[(0,l.jsx)(`b`,{children:r.tasks}),(0,l.jsx)(`span`,{children:t(`diag.tasks`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":r.staleRunning>0?`true`:void 0,children:[(0,l.jsx)(`b`,{children:r.staleRunning}),(0,l.jsx)(`span`,{children:t(`diag.running`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-item`,"data-bad":r.orphanWorktrees.length>0?`true`:void 0,children:[(0,l.jsx)(`b`,{children:r.orphanWorktrees.length}),(0,l.jsx)(`span`,{children:t(`diag.orphans`)})]})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`diag.orphans.heading`)}),r.orphanWorktrees.length===0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`diag.orphans.none`)}):(0,l.jsx)(`div`,{className:`dsh-atb-diag-orphans`,children:r.orphanWorktrees.map(n=>(0,l.jsxs)(`div`,{className:`dsh-atb-diag-orphan`,children:[(0,l.jsxs)(`span`,{className:`dsh-atb-diag-orphan-path`,title:n.path,children:[i(n.workspaceId),` · `,n.taskId]}),(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,onClick:()=>void e.cleanupOrphan(n.workspaceId,n.taskId),children:t(`diag.orphans.cleanup`)})]},n.path))}),(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`diag.orphans.hint`)})]}),(0,l.jsxs)(`div`,{className:`dsh-atb-diag-sec`,children:[(0,l.jsx)(`h4`,{children:t(`diag.gitignore.heading`)}),(r.gitIgnoreSuggestions??[]).length===0?(0,l.jsx)(`div`,{className:`dsh-atb-empty2`,children:t(`diag.gitignore.none`)}):(0,l.jsx)(`div`,{className:`dsh-atb-diag-orphans`,children:r.gitIgnoreSuggestions.map(e=>(0,l.jsx)(`div`,{className:`dsh-atb-diag-orphan`,children:(0,l.jsxs)(`span`,{className:`dsh-atb-diag-orphan-path`,title:e.workspacePath,children:[i(e.workspaceId),` · `,t(`diag.gitignore.suggestA`),` `,(0,l.jsx)(`code`,{children:`.dsh-worktrees/`}),t(`diag.gitignore.suggestB`)]})},e.workspaceId))})]})]})})]})})}function ft({controller:e,tasks:t}){let n=W(),[r,i]=(0,c.useState)(`none`),[a,o]=(0,c.useState)(!1),[s,u]=(0,c.useState)(()=>new Set),d=t.filter(e=>e.trashedAt!==void 0),f=t.filter(e=>e.trashedAt===void 0&&e.status===`archived`),p=t.filter(e=>e.trashedAt===void 0&&e.status===`canceled`),m=e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},h=e=>{u(t=>{let n=e.length>0&&e.every(e=>t.has(e.id)),r=new Set(t);for(let t of e)n?r.delete(t.id):r.add(t.id);return r})},g=async t=>{let n=(t===`trashArchived`?f:d).filter(e=>s.has(e.id));o(!0);try{for(let r of n){try{await e.remove(r.id,r.version,t===`purgeTrashed`)}catch{}u(e=>{let t=new Set(e);return t.delete(r.id),t})}}finally{o(!1),i(`none`),u(new Set)}},_=()=>{i(`none`),u(new Set)},v=[{label:n(`status.column.canceled`),dot:`canceled`,rows:p},{label:n(`status.column.archived`),dot:`archived`,rows:f,action:`trashArchived`},{label:n(`board.group.trashed`),dot:`trashed`,rows:d,action:`purgeTrashed`}];return d.length+f.length+p.length===0?(0,l.jsx)(`div`,{className:`dsh-atb-secondary`,children:(0,l.jsx)(`div`,{className:`dsh-atb-empty`,children:n(`board.secondary.empty`)})}):(0,l.jsx)(`div`,{className:`dsh-atb-columns`,children:v.map(t=>{let o=r===t.action,c=o?t.rows.filter(e=>s.has(e.id)).length:0,d=t.rows.length>0&&c===t.rows.length;return(0,l.jsxs)(`div`,{className:`dsh-atb-column`,children:[(0,l.jsxs)(`div`,{className:`dsh-atb-colhead`,children:[(0,l.jsx)(`span`,{className:`dsh-atb-dot`,"data-status":t.dot}),t.label,(0,l.jsx)(`span`,{className:`dsh-atb-colcount`,children:t.rows.length}),t.action&&t.rows.length>0&&(o?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:a,title:n(`board.batch.confirmCancelTip`),onClick:_,children:n(`board.batch.cancel`)}),(0,l.jsxs)(`button`,{type:`button`,className:`dsh-atb-btn`,"data-danger":`true`,disabled:a||c===0,title:n(c===0?`board.batch.noneSelected`:`board.batch.confirmTip`),onClick:()=>{g(t.action)},children:[n(`board.batch.confirm`),`(`,c,`)`]}),(0,l.jsx)(`input`,{type:`checkbox`,className:`dsh-atb-selectall`,checked:d,disabled:a,title:n(`board.batch.selectAll`),onClick:e=>e.stopPropagation(),onChange:()=>h(t.rows)})]}):(0,l.jsx)(`button`,{type:`button`,className:`dsh-atb-btn`,disabled:a,title:t.action===`trashArchived`?n(`board.batch.trashArchivedTip`):n(`board.batch.purgeTrashedTip`),onClick:()=>{i(t.action),u(new Set)},children:t.action===`trashArchived`?n(`board.batch.trashArchived`):n(`board.batch.purgeTrashed`)}))]}),(0,l.jsxs)(`div`,{className:`dsh-atb-cards`,children:[t.rows.map(n=>t.action&&o?(0,l.jsxs)(`div`,{className:`dsh-atb-selrow`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`dsh-atb-selbox`,checked:s.has(n.id),disabled:a,onClick:e=>e.stopPropagation(),onChange:()=>m(n.id)}),(0,l.jsx)(Y,{task:n,controller:e})]},n.id):(0,l.jsx)(Y,{task:n,controller:e},n.id)),t.rows.length===0&&(0,l.jsx)(`div`,{className:`dsh-atb-empty`,children:n(`board.empty`)})]})]},t.label)})})}function pt(e){let t=()=>{if((document.body.getAttribute(`data-dsh-desktop-platform`)??new URLSearchParams(window.location.search).get(`dsh-desktop-platform`))!==`win32`){delete e.dataset.dshAtbWindows,e.style.removeProperty(`--dsh-atb-viewport-top`);return}e.dataset.dshAtbWindows=``,e.style.setProperty(`--dsh-atb-viewport-top`,`${e.getBoundingClientRect().top}px`)},n,r=()=>{n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,t()}))},i=new MutationObserver(r);i.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:[`class`,`data-dsh-desktop-platform`,`data-dsh-desktop-mode`,`data-details-collapsed`]}),i.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-dsh-atb-active`]});let a=typeof ResizeObserver>`u`?void 0:new ResizeObserver(r);return a?.observe(e),e.parentElement!==null&&a?.observe(e.parentElement),window.addEventListener(`resize`,r),r(),()=>{i.disconnect(),a?.disconnect(),window.removeEventListener(`resize`,r),n!==void 0&&cancelAnimationFrame(n),delete e.dataset.dshAtbWindows,e.style.removeProperty(`--dsh-atb-viewport-top`)}}function mt(){let e=document.querySelector(`[data-pane="sidebar"], [class*="sidebarCol"], .dshDesktopUpstreamSidebar, .dshDesktopSidebarSurface`);if(e!==null)return e.querySelector(`[class*="logoRow"]`)?.parentElement??e.firstElementChild}function ht(e){let t=e.querySelector(`button[class*="newSession"]`);if(t!==null)return t;for(let t of e.children)if(t instanceof HTMLButtonElement&&!t.matches(`[data-dsh-atb-entry]`))return t;let n=e.querySelector(`button[aria-label="新建会话"], button[aria-label="New Session"], button[aria-label*="新会话"], button[aria-label*="new session" i]`);return n===null?Array.from(e.querySelectorAll(`button`)).find(e=>!e.matches(`[data-dsh-atb-entry]`)&&/新会话|新建会话|new session/i.test(e.textContent??``)):n}function gt(e){let t=document.createElement(`button`);return t.type=`button`,t.dataset.dshAtbEntry=``,t.className=`dsh-atb-entry`,t.setAttribute(`aria-label`,U(`shared.entry.aria`)),t.innerHTML=``,t.addEventListener(`click`,()=>{e.toggleBoard()}),t}function _t(e){let t=0,n=0,r=0;for(let i of e.getSnapshot().ledger.tasks)i.trashedAt===void 0&&(i.status===`todo`?t++:i.status===`in_progress`?n++:i.status===`in_review`&&r++);return[t,n,r]}function vt(e,t){let n=String(t);if(e.dataset.value===n)return;let r=e.dataset.value;if(e.dataset.value=n,e.style.minWidth=`${n.length}ch`,r===void 0){e.textContent=n;return}e.dataset.busy===`1`&&(e.dataset.busy=``,e.dataset.anim=``);let i=document.createElement(`span`);i.className=`dsh-atb-rn`,i.textContent=r;let a=document.createElement(`span`);a.className=`dsh-atb-rn dsh-atb-rn-next`,a.textContent=n,e.replaceChildren(i,a),e.dataset.dir=t>Number(r)?`up`:`down`,e.dataset.busy=`1`,requestAnimationFrame(()=>{e.dataset.anim=`1`});let o=()=>{e.dataset.busy===`1`&&(e.dataset.busy=``,e.dataset.anim=``,e.textContent=e.dataset.value??``)};e.addEventListener(`transitionend`,o,{once:!0}),setTimeout(o,400)}function yt(e,t){let n=e.querySelector(`.dsh-atb-entry-stats`);if(n===null)return()=>{};let r=[`todo`,`in_progress`,`in_review`],i=[];for(let e=0;e<3;e++){if(e>0){let e=document.createElement(`span`);e.className=`dsh-atb-entry-sep`,e.textContent=`|`,n.append(e)}let t=document.createElement(`span`);t.className=`dsh-atb-roll`,t.dataset.stat=r[e],n.append(t),i.push(t)}return()=>{let[e,r,a]=_t(t);vt(i[0],e),vt(i[1],r),vt(i[2],a),n.title=U(`shared.stats.title`,{todo:e,doing:r,review:a})}}function bt(e,t){let n=ht(e);if(n===void 0)return!1;if(t.parentElement!==e){let r=n.closest(`[class*="logoRow"]`),i=r!==null&&r.parentElement===e?r:n,a=Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.matches(`[data-dsh-atb-entry], [data-dsh-taskboard-entry], [data-dsh-ssh-entry]`)),o=a.length>0?a[0]??null:i.nextElementSibling??null;e.insertBefore(t,o)}return!0}function xt(e){let t=gt(e),n={attempts:0,found:!1,placed:!1},r=globalThis.location?.hostname;(r===`localhost`||r===`127.0.0.1`)&&(window.__atbDebug=n);let i,a=!1,o=()=>{if(n.attempts++,i!==void 0&&!i.isConnected&&(c.disconnect(),i=void 0,a=!1),a){if(document.body.contains(t))return;c.disconnect(),i=void 0,a=!1}i??=mt(),i!==void 0&&(n.found=ht(i)!==void 0,a=bt(i,t),n.placed=a,a&&c.observe(i,{childList:!0,subtree:!0}))},s=new MutationObserver(()=>{o()});s.observe(document.body,{childList:!0,subtree:!0});let c=new MutationObserver(()=>{if(i===void 0||!i.isConnected){a=!1,o();return}i.contains(t)||(a=bt(i,t))}),l=setInterval(()=>{o()},2e3),u=yt(t,e),d=()=>{e.getSnapshot().boardOpen?t.dataset.active=`true`:delete t.dataset.active,u()},f=e.subscribe(d),p=H.subscribe(()=>{t.setAttribute(`aria-label`,U(`shared.entry.aria`));let e=t.querySelector(`.dsh-atb-entry-label`);e!==null&&(e.textContent=U(`shared.entry.label`)),u()});return d(),o(),()=>{clearInterval(l),s.disconnect(),c.disconnect(),p(),f(),t.remove()}}const St=`data-dsh-atb-active`,Ct=[`data-dsh-taskboard-active`,`data-dsh-ssh-active`],wt=`dsh-panel-activate`,Tt=`dsh-taskboard`;function Et(){return document.querySelector(`[data-pane="conversation"], [class*="centerCol"], .dshDesktopConversationSurface`)??void 0}function Dt(e){let t,n,r,i=()=>{if(n!==void 0)return;let i=Et();i!==void 0&&(n=document.createElement(`div`),n.dataset.dshAtbView=``,n.className=`dsh-atb-view`,i.appendChild(n),r=pt(n),t=(0,d.createRoot)(n),t.render((0,l.jsx)(lt,{controller:e})))},a=new MutationObserver(()=>{i()});a.observe(document.body,{childList:!0,subtree:!0});let o=()=>{if(e.getSnapshot().boardOpen){for(let e of Ct)document.documentElement.removeAttribute(e);document.documentElement.setAttribute(St,``),document.dispatchEvent(new CustomEvent(wt,{detail:Tt}))}else document.documentElement.removeAttribute(St)},s=t=>{t.detail!==Tt&&e.getSnapshot().boardOpen&&e.closeBoard()},c=t=>{if(!e.getSnapshot().boardOpen)return;let n=t.target;n!==null&&n.closest(`[data-dsh-atb-entry]`)===null&&n.closest(`[class*="sessionRow"], [class*="projectRow"], [class*="searchResultRow"], [class*="searchResultWorkspace"], [class*="newSession"]`)!==null&&e.closeBoard()};document.addEventListener(`click`,c,!0),document.addEventListener(wt,s);let u=e.subscribe(o);return o(),i(),()=>{document.removeEventListener(`click`,c,!0),document.removeEventListener(wt,s),a.disconnect(),u(),r?.(),document.documentElement.removeAttribute(St),t?.unmount(),n?.remove()}}const Ot=`dsh-taskboard`;function kt(e){let t=e.get?.(`slots`)??e.slots;if(!(t===void 0||typeof t.register!=`function`||typeof t.inject!=`function`||typeof t.spec!=`function`)){try{if(t.spec(`main`)===void 0||t.spec(`sidebar.panellist`)===void 0)return}catch{return}return t}}function At(e){return function(){let t=c.useCallback(e=>{if(e===null)return;let t=`__dshAtbInsetDispose`,n=e;n[t]===void 0&&(n[t]=pt(e))},[]);return c.createElement(`div`,{"data-dsh-atb-panel-root":``,ref:t,className:`dsh-atb-panel-root`},c.createElement(lt,{controller:e}))}}function jt(e){return function(t){let n=typeof t.size==`number`?t.size:16,r=c.useCallback(t=>e.subscribe(t),[e]),i=c.useCallback(()=>e.getSnapshot(),[e]),a=c.useSyncExternalStore(r,i,i),o=c.useMemo(()=>{let e=0,t=0,n=0;for(let r of a.ledger.tasks)r.trashedAt===void 0&&(r.status===`todo`?e++:r.status===`in_progress`?t++:r.status===`in_review`&&n++);return{todo:e,doing:t,review:n}},[a.ledger]),[s,l]=c.useState(!0),u=c.useCallback(e=>{if(e===null||typeof ResizeObserver>`u`)return;let t=e.closest(`button`);t!==null&&new ResizeObserver(()=>{l(t.clientWidth>44)}).observe(t)},[]),d=U(`shared.stats.title`,{todo:o.todo,doing:o.doing,review:o.review});return c.createElement(`span`,{className:`dsh-atb-pglyph`,ref:u},c.createElement(`span`,{className:`dsh-atb-picon`},c.createElement(`svg`,{width:n,height:n,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":1.3,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":!0},c.createElement(`rect`,{x:2,y:2,width:12,height:12,rx:2}),c.createElement(`path`,{d:`M6 2v12M10 2v12`})),!s&&o.todo>0?c.createElement(`span`,{className:`dsh-atb-pbadge`,title:d,"aria-hidden":!0},o.todo):null),s&&(o.todo>0||o.doing>0||o.review>0)?c.createElement(`span`,{className:`dsh-atb-pstats`,title:d,"aria-hidden":!0},c.createElement(`span`,{"data-stat":`todo`},o.todo),c.createElement(`span`,{className:`dsh-atb-psep`},`|`),c.createElement(`span`,{"data-stat":`in_progress`},o.doing),c.createElement(`span`,{className:`dsh-atb-psep`},`|`),c.createElement(`span`,{"data-stat":`in_review`},o.review)):null)}}function Mt(e,t,n){let r=[];try{let i=t.get?.(`layout`)??t.layout;n.installCloseRequester(()=>{i?.selectPanel(null)}),r.push(()=>{n.installCloseRequester(void 0)});let a=At(n);r.push(e.inject(`main`,()=>e.register({name:`main`,key:Ot},a)));let o=jt(n);r.push(e.inject(`sidebar.panellist`,()=>e.register({name:`sidebar.panellist`,id:Ot,order:10,label:()=>U(`shared.entry.label`)},o))),console.info(`[dsh-taskboard] official panel mode: registered`,Ot)}catch(e){console.error(`[dsh-taskboard] official panel registration failed — falling back to legacy mounting:`,e);for(let e of r.splice(0))e();return}return()=>{for(let e of r.splice(0))e()}}function Nt(e,t){let n=kt(e);if(n!==void 0){let r=Mt(n,e,t);if(r!==void 0)return r}let r=[];r=[xt(t),Dt(t)];let i=0,a,o=setInterval(()=>{i++;let n=kt(e);if(n!==void 0){let i=Mt(n,e,t);if(i!==void 0){a=i,clearInterval(o);for(let e of r.splice(0))e();return}}i>=3&&clearInterval(o)},350);return()=>{clearInterval(o);for(let e of r.splice(0))e();a?.()}}function Pt(e){let t=(e,t,n)=>e.list.getSnapshot().byId[n]===void 0?`absent`:t?.list.getSnapshot().archivedSessionIds.includes(n)??!1?`archived`:`openable`,n=(t,n)=>{let r=e.getUiWorkspace?.();return typeof r?.openSession==`function`?(r.openSession(n),!0):typeof t.open==`function`?(t.open(n),!0):!1};return async r=>{let i=e.getSessions();if(i===void 0)return`unavailable`;try{let a=t(i,e.getWorkspaces(),r);if(a===`absent`){try{await i.refresh()}catch{}a=t(i,e.getWorkspaces(),r)}return a===`archived`?`archived`:a===`absent`?`missing`:n(i,r)?`opened`:`unavailable`}catch{return`unavailable`}}}const Ft=[`connection`];function It(e){try{he(),se(e.get?.(`locale`),()=>e.get?.(`locale`));let t=_(),n=new pe(t);n.installModelCatalog(async()=>{try{let t=e.get?.(`modelDirectories`)??e.modelDirectories;if(t?.catalog?.load!==void 0){let e=await t.catalog.load();if(e?.groups!==void 0&&e.groups.length>0){let t=[];for(let n of e.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}}catch{}try{let t=e.get?.(`remote`)??e.remote;if(t?.session?.modelCatalog!==void 0){let e=await t.session.modelCatalog();if(e.ok&&e.value?.groups!==void 0&&e.value.groups.length>0){let t=[];for(let n of e.value.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}if(t?.llm?.models!==void 0){let e=await t.llm.models({});if(e.result.ok&&e.result.value?.groups!==void 0&&e.result.value.groups.length>0){let t=[];for(let n of e.result.value.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}}catch{}try{let t=e.get?.(`connection`)??e.connection;if(t?.api?.llm?.models!==void 0){let e=await t.api.llm.models({});if(e.result.ok&&e.result.value?.groups!==void 0&&e.result.value.groups.length>0){let t=[];for(let n of e.result.value.groups)for(let e of n.models)t.push({provider:n.id,model:e.id,name:e.name,...e.description===void 0?{}:{description:e.description},...e.reasoning===void 0?{}:{reasoning:e.reasoning}});if(t.length>0)return t}}}catch{}try{let e=await t.modelCatalog();if(e.models!==void 0&&e.models.length>0)return e.models}catch{}return[]}),n.installPresetRoster(async()=>{try{let t=e.get?.(`remote`)??e.remote;if(t?.agentPresets?.list!==void 0){let e=await t.agentPresets.list(),n=e.ok===!0?e.value.presets:e.result?.ok===!0?e.result.value.presets:void 0;if(n!==void 0&&n.length>0){let e=n.map(e=>({id:e.id,name:e.name})),t=n.find(e=>e.isDefault);return{presets:e,...t===void 0?{}:{defaultId:t.id}}}}}catch{}try{let t=e.get?.(`connection`)??e.connection;if(t?.api?.agentPresets?.list!==void 0){let e=await t.api.agentPresets.list({});if(e.result.ok&&e.result.value?.presets!==void 0&&e.result.value.presets.length>0){let t=e.result.value.presets.map(e=>({id:e.id,name:e.name})),n=e.result.value.presets.find(e=>e.isDefault);return{presets:t,...n===void 0?{}:{defaultId:n.id}}}}}catch{}try{let e=await t.modelCatalog();if(e.presets!==void 0&&e.presets.length>0)return{presets:e.presets,...e.defaultPresetId===void 0?{}:{defaultId:e.defaultPresetId}}}catch{}return{presets:[]}}),n.installSessionJumper(Pt({getSessions:()=>e.get?.(`sessions`),getWorkspaces:()=>e.get?.(`workspaces`),getUiWorkspace:()=>e.get?.(`uiWorkspace`)})),n.start();let r=[];try{r.push(Nt(e,n))}catch(e){console.error(`[dsh-taskboard] mount failed:`,e)}e.effect?.(()=>()=>{for(let e of r.splice(0))e();n.dispose(),ce()},`dsh-taskboard: client mount`)}catch(e){console.error(`[dsh-taskboard] client half failed to start:`,e)}}exports.apply=It,exports.inject=Ft,exports.name=`dsh-taskboard/client`; return module.exports; } }); diff --git a/src/client/index.ts b/src/client/index.ts index 123d9fc..88c92f9 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -16,7 +16,7 @@ import { BoardController } from './controller.ts' import { disposeI18n, initI18n } from './i18n/runtime.ts' import { injectStyles } from './styles.ts' import { mountBoardCompat } from './official-panel.tsx' -import { createSessionJumper, type SessionsServiceFace, type WorkspacesServiceFace } from './session-jump.ts' +import { createSessionJumper, type SessionsServiceFace, type UiWorkspaceFace, type WorkspacesServiceFace } from './session-jump.ts' /** Client plugin name. */ export const name = 'dsh-taskboard/client' @@ -259,11 +259,15 @@ export function apply(ctx: ClientContextFace): void { // Session navigation for execution rows: resolved LAZILY on every jump — // apply may run before the runtime provides the services, and a captured - // undefined would permanently disable the jump. On a platform without - // them the jump degrades to an 'unavailable' notice instead of failing. + // undefined would permanently disable the jump. The navigation owner is + // uiWorkspace (DSH 0.1.6+; sessions.open was removed there), passed as a + // third accessor so the jumper can fall back on runtimes that still ship + // the legacy selector. On a platform with neither, the jump degrades to an + // 'unavailable' notice instead of failing. controller.installSessionJumper(createSessionJumper({ getSessions: () => ctx.get?.('sessions') as SessionsServiceFace | undefined, getWorkspaces: () => ctx.get?.('workspaces') as WorkspacesServiceFace | undefined, + getUiWorkspace: () => ctx.get?.('uiWorkspace') as UiWorkspaceFace | undefined, })) controller.start() diff --git a/src/client/session-jump.ts b/src/client/session-jump.ts index 80ac7f8..7cdaab2 100644 --- a/src/client/session-jump.ts +++ b/src/client/session-jump.ts @@ -1,21 +1,35 @@ /** * Session jump: resolve an execution's session against the runtime's live - * session list and open it in the GUI. The runtime's `sessions` service owns - * the list mirror (`list.getSnapshot().byId`) and staging (`open`); the - * `workspaces` service carries the registry-global archive set. + * session list and open it in the GUI. + * + * NAVIGATION OWNER (DSH 0.1.6+): the runtime's `sessions` service owns only + * the list mirror (`list.getSnapshot().byId`) and the catalog; its `open()` + * selector existed through 0.1.5 and was REMOVED in 0.1.6 — see the ISessions + * contract, "Host catalog and local reference-source counts; navigation + * belongs to view owners". The documented navigation entry is now + * `uiWorkspace.openSession(target)`: "Select a Session and show its + * Conversation as one UI navigation action". The workspace service carries the + * registry-global archive set. + * + * Reading a service method the runtime no longer ships yields `undefined`, and + * calling it throws — historically swallowed into a bare 'unavailable' notice, + * which is how the `sessions.open` removal silently disabled this button on + * every 0.1.7 runtime. Resolution is therefore structural: prefer the + * navigation owner, fall back to the legacy selector only while it actually + * exists, and report 'unavailable' only when neither is present. * * Outcomes are split so the UI can prompt precisely: * - `opened` — staged and opened; the board closes over it. * - `archived` — in the list but archived (hidden from the sidebar; its log * survives, so it is distinguishable from deletion). * - `missing` — absent from the live list: deleted. - * - `unavailable`— runtime session services absent (service timing / errors). + * - `unavailable`— no navigation entry is present on this runtime. * * Service resolution is deliberately LAZY (per click): plugin apply may run - * before the runtime provides `sessions`, and a once-captured undefined would - * permanently disable the jump. When the id misses, the list mirror may also - * simply lag (reconnect re-pull, late mount): one `refresh()` is awaited and - * the lookup retried before deciding. + * before the runtime provides these services, and a once-captured undefined + * would permanently disable the jump. When the id misses, the list mirror may + * also simply lag (reconnect re-pull, late mount): one `refresh()` is awaited + * and the lookup retried before deciding. * * @module dsh-taskboard/client/session-jump */ @@ -29,8 +43,12 @@ export type SessionJumpResult = /** Narrow face of the runtime `sessions` service this module needs. */ export interface SessionsServiceFace { - /** Select a listed session as current (the window opens with it). */ - open(id: string): void + /** + * Legacy selector, present through DSH 0.1.5 and gone from 0.1.6 on. + * Optional on purpose: a runtime without it must not turn the whole jump + * into a type error, and an absent method is detected, not called. + */ + open?(id: string): void /** Re-pull the session list baseline (mirror catch-up). */ refresh(): Promise /** Live session list snapshot. */ @@ -51,12 +69,20 @@ export interface WorkspacesServiceFace { } } +/** Narrow face of the runtime `uiWorkspace` navigation service (0.1.6+). */ +export interface UiWorkspaceFace { + /** Select a Session and show its Conversation as one UI navigation action. */ + openSession(id: string): void +} + /** Lazy per-click service resolution (services may appear after apply). */ export interface SessionServiceAccess { /** The runtime sessions service, when currently provided. */ getSessions(): SessionsServiceFace | undefined /** The runtime workspaces service, when currently provided (optional). */ getWorkspaces(): WorkspacesServiceFace | undefined + /** The runtime navigation owner, when currently provided (optional). */ + getUiWorkspace?(): UiWorkspaceFace | undefined } /** @@ -71,6 +97,26 @@ export function createSessionJumper(access: SessionServiceAccess): (sessionId: s const archived = workspaces?.list.getSnapshot().archivedSessionIds.includes(sessionId) ?? false return archived ? 'archived' : 'openable' } + /** + * Hand the id to whichever navigation entry this runtime actually ships. + * Structural check first (a missing method must never be called), so an + * absent entry becomes an outcome instead of a swallowed TypeError. + * @param sessions - the resolved sessions service. + * @param sessionId - the listed session to show. + * @returns true when some entry took the navigation. + */ + const navigate = (sessions: SessionsServiceFace, sessionId: string): boolean => { + const nav = access.getUiWorkspace?.() + if (typeof nav?.openSession === 'function') { + nav.openSession(sessionId) + return true + } + if (typeof sessions.open === 'function') { + sessions.open(sessionId) + return true + } + return false + } return async (sessionId: string): Promise => { const sessions = access.getSessions() if (sessions === undefined) return 'unavailable' @@ -84,8 +130,7 @@ export function createSessionJumper(access: SessionServiceAccess): (sessionId: s } if (state === 'archived') return 'archived' if (state === 'absent') return 'missing' - sessions.open(sessionId) - return 'opened' + return navigate(sessions, sessionId) ? 'opened' : 'unavailable' } catch { return 'unavailable' } diff --git a/tests/client.spec.ts b/tests/client.spec.ts index 4aa9ce8..872c360 100644 --- a/tests/client.spec.ts +++ b/tests/client.spec.ts @@ -860,6 +860,47 @@ describe('client half', () => { controller.dispose() }) + // Regression guard for the DSH 0.1.7 runtime shape: the runtime's sessions + // service no longer carries `open()` (0.1.5 had one, 0.1.6+ removed it — + // "navigation belongs to view owners"). The documented navigation entry is + // uiWorkspace.openSession(); reading a missing `sessions.open` throws inside + // the jumper's try, so a runtime-shaped sessions service must still open. + it('session jump opens through the navigation service when sessions has no open()', async () => { + const { BoardController } = await import('../src/client/controller.ts') + const { createSessionJumper } = await import('../src/client/session-jump.ts') + + const client = { + state: async () => ({ schemaVersion: 1, revision: 1, tasks: [] }), + workspaces: async () => [], + stream: () => () => {}, + } + const controller = new BoardController(client as never) + controller.openBoard() + + // Runtime-shaped services: probe-clean, no `open` key at all. + const sessions = { + refresh: async () => {}, + list: { getSnapshot: () => ({ byId: { 's-live': {} } }) }, + } + const workspaces = { list: { getSnapshot: () => ({ archivedSessionIds: [] as string[] }) } } + const navigated: string[] = [] + const uiWorkspace = { openSession: (id: string) => { navigated.push(id) } } + + controller.installSessionJumper(createSessionJumper({ + getSessions: () => sessions as never, + getWorkspaces: () => workspaces as never, + getUiWorkspace: () => uiWorkspace as never, + })) + + // The jump must not degrade to 'unavailable' on this runtime, and the + // board must close over the session it navigated to. + expect(await controller.openSession('s-live')).toBe('opened') + expect(navigated).toEqual(['s-live']) + expect(controller.getSnapshot().boardOpen).toBe(false) + + controller.dispose() + }) + it('controller: search filter, urgency sort, and persisted view state', async () => { localStorage.clear() const { BoardController } = await import('../src/client/controller.ts')