@dubusoft/toodo-linux-arm64 1.3.3-dev.37 → 1.3.3-dev.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{F as a,I as o,J as s,N as c,Rt as l,U as u,V as d,ct as f,d as p,wt as m}from"./status-styles-DDSPyzwv.js";import{d as h,h as g,m as _}from"./event-DMqRNLc_.js";var v={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};v.node;var y=t(v),b={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};b.node;var x=t(b),S={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};S.node;var C=t(S),w={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};w.node;var T=t(w),E={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};E.node;var D=t(E),O={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};O.node;var k=t(O),A={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};A.node;var j=t(A),M={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};M.node;var ee=t(M),N=r(e(),1),P=n();function te(e,t){if(e===null)return;let n=[...e.querySelectorAll(`a[href], button, input, select, textarea, summary, [tabindex]`)].filter(e=>!e.matches(`:disabled, [tabindex='-1']`)&&e.getClientRects().length>0);if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement,o=a instanceof Node&&e.contains(a);(t.shiftKey?!o||a===r:!o||a===i)&&(t.preventDefault(),(t.shiftKey?i:r).focus())}function F(e){let t=/^[a-zA-Z]:/.test(e)||e.startsWith(`\\\\`)||e.includes(`\\`)&&!e.includes(`/`),n=t?`\\`:`/`,r=``,i=e,a=t?/^[\\/]{2}[^\\/]+[\\/]+[^\\/]+/.exec(e):null,o=t?/^[a-zA-Z]:([\\/]?)/.exec(e):null;a?(r=`${a[0].replace(/[\\/]+/g,`\\`).replace(/^\\/,`\\\\`)}\\`,i=e.slice(a[0].length)):o?(r=o[0].slice(0,2)+(o[1]?n:``),i=e.slice(o[0].length)):/^[\\/]/.test(e)&&(r=n,i=e.replace(/^[\\/]+/,``));let s=[];for(let e of i.split(t?/[\\/]+/:/\/+/))e!==``&&e!==`.`&&(e===`..`?s.length>0&&s[s.length-1]!==`..`?s.pop():r===``&&s.push(e):s.push(e));return{root:r,separator:n,segments:s}}function I(e){let{root:t,separator:n,segments:r}=F(e),i=t+r.join(n);return i===``?`.`:i}function L(e){return/^[a-zA-Z]:/.test(e)||e.startsWith(`\\\\`)}function R(e,t=2){let{separator:n,segments:r}=F(e);return r.length<=t?I(e):`…${n}${r.slice(-t).join(n)}`}var z=200;function B(e,t){let n=L(e)?`\\`:`/`;return/[\\/]$/.test(e)?`${e}${t}`:`${e}${n}${t}`}function ne(e){return e.replace(/(?<=[^\\/:])[\\/]+$/,``)}function V(e,t){let[n,r]=(0,N.useState)(e);return(0,N.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function re({id:e,machine:t,value:n,onChange:r,describedBy:a,required:s,autoFocus:c,className:l}){let[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(-1),m=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),h=m<0?null:n.slice(0,m+1),g=n.slice(m+1).toLowerCase(),_=V(h,z),v=o(t,u?_:null),y=u&&h!==null&&_===h,b=y&&v.data?v.data.directories.filter(e=>e.toLowerCase().startsWith(g)):[],x=b.length>0,S=`${e}-folders`,C=t.kind===`local`?`the server`:t.label;function w(e){r(e),p(-1),d(!0)}function T(e){h!==null&&w(`${B(h,e)}${L(h)?`\\`:`/`}`)}function E(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!x){d(!0);return}let t=b.length,n=e.key===`ArrowDown`;p(e=>e<0?n?0:t-1:(e+(n?1:t-1))%t)}else if(e.key===`Enter`){if(!x||f<0)return;e.preventDefault(),T(b[f])}else if(e.key===`Tab`){if(!x||e.shiftKey||f<0&&g===``)return;e.preventDefault(),e.stopPropagation(),T(b[Math.max(f,0)])}else if(e.key===`Escape`){if(!x)return;e.preventDefault(),e.stopPropagation(),d(!1)}}return(0,P.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,P.jsx)(`input`,{id:e,role:`combobox`,"aria-expanded":x,"aria-controls":S,"aria-autocomplete":`list`,"aria-activedescendant":x&&f>=0?`${S}-${f}`:void 0,"aria-describedby":a,autoComplete:`off`,spellCheck:!1,className:l,value:n,onChange:e=>w(e.target.value),onFocus:()=>d(!0),onBlur:()=>d(!1),onKeyDown:E,required:s,autoFocus:c}),x&&(0,P.jsx)(`ul`,{id:S,role:`listbox`,"aria-label":`Folders in ${h}`,className:`absolute top-full right-0 left-0 z-10 mt-1 flex max-h-56 flex-col overflow-y-auto rounded-lg border bg-popover p-1 font-mono text-xs text-popover-foreground shadow-md`,children:b.map((e,t)=>(0,P.jsxs)(`li`,{id:`${S}-${t}`,role:`option`,"aria-selected":t===f,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e),className:i(`cursor-pointer truncate rounded px-1.5 py-1 hover:bg-muted max-md:py-2`,t===f&&`bg-secondary hover:bg-secondary`),children:[e,L(h??``)?`\\`:`/`]},e))}),y&&v.isError&&(0,P.jsxs)(`p`,{role:`status`,className:`mt-1 text-xs break-words text-muted-foreground`,children:[`No suggestions: `,v.error.message,`. Type the path of a folder that exists on `,C,`, ending in a separator, to see its subfolders.`]})]})}var ie=[`none`,`local_git`,`github`],ae=[`manual`,`local_merge`,`pr_merge`],oe=[`herdr`,`plain`,`tmux`,`none`],se=[`open`,`init`,`clone`],H={none:`Plain folder`,local_git:`Local git`,github:`GitHub`},U={manual:`Manual`,local_merge:`Local merge`,pr_merge:`PR merge`},W={none:`No runner`,herdr:`herdr`,plain:`Plain`,tmux:`tmux`},ce={open:`Open existing`,init:`New repository`,clone:`Clone URL`};function G(e){return e===`none`?`manual`:e===`local_git`?`local_merge`:`pr_merge`}function K(e,t=!1){return e===`none`?`none`:t?`plain`:`herdr`}function le(e){return e===`none`?null:`open`}function ue(e,t){switch(t){case`manual`:return null;case`local_merge`:return e===`local_git`?null:e===`none`?`Needs a git repository; choose source Local git`:`GitHub tasks merge through pull requests; choose source Local git`;case`pr_merge`:return e===`github`?null:e===`none`?`Needs a git repository; choose source GitHub`:`Needs a GitHub origin remote; choose source GitHub`}}function de(e,t,n){return n!==`none`&&e===`none`?`Needs a git repository for task worktrees; choose source Local git or GitHub`:n===`none`&&t!==`manual`?`${U[t]} needs the task branch that herdr, ${W.plain}, or ${W.tmux} creates; choose completion Manual`:null}function fe(e,t){return e===`tmux`&&t.kind===`ssh`&&L(t.path)?`Needs a POSIX host; choose ${W.plain} or ${W.herdr} for a Windows SSH workspace, or choose a POSIX path for ${W.tmux}`:null}function pe(e,t){return e===`none`?`A plain folder has no repository; choose source Local git or GitHub`:e===`github`&&t===`init`?`A new repository has no GitHub origin; choose source Local git`:null}function me(e,t=!1){let{source:n}=e,r=e.repository!==null&&pe(n,e.repository)===null?e.repository:le(n),i=e.completion!==null&&ue(n,e.completion)===null?e.completion:G(n);return{source:n,repository:r,completion:i,runner:e.runner!==null&&de(n,i,e.runner)===null?e.runner:K(n,t)}}function he(e,t,n=!1){let r={...e,...t},i=me(r,n);return{source:r.source,repository:r.repository===i.repository?r.repository:null,completion:r.completion===i.completion?r.completion:null,runner:r.runner===i.runner?r.runner:null}}var q=`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,J=`h-6 rounded-md border border-input bg-background px-1.5 text-xs outline-none max-md:h-11 max-md:px-2.5 max-md:text-sm focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50`;function Y(e){let t=I(e.path);return e.kind===`local`?t:`${e.machine}:${t}`}function X(e){let t=R(e.path);return e.kind===`local`?t:`${e.machine}:${t}`}var ge={foreign:`Windows path, not on this server`,missing:`Folder not found on the server`};function _e({problem:e,className:t}){return(0,P.jsxs)(`span`,{className:i(`flex min-w-0 items-start gap-1 text-xs text-destructive`,t),title:`Toodo cannot run git in this repository until its path is corrected`,children:[(0,P.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3 shrink-0`}),(0,P.jsx)(`span`,{children:ge[e]})]})}function ve({workspace:e}){let t=H[e.source],n=U[e.completion],r=W[e.runner];return(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground`,title:`Source ${t}, completion ${n}, runner ${r}; set when the workspace was added`,children:[(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:t}),` · `,(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:n}),` `,`· `,(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:r})]})}function ye(e){return e.kind===`local`?null:e.machine}function be(e,t){let n=t.filter(t=>t.target===e);return n.length===0?`Not saved in herdr`:n.some(e=>e.enabled)?null:`Disabled in herdr`}function xe(e){return/[\\/]$/.test(e)?e:B(e,``)}function Z({label:e,help:t,children:n}){let r=(0,N.useId)(),i=`${r}-help`;return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(`label`,{htmlFor:r,className:`text-xs text-muted-foreground`,children:e}),n({id:r,describedBy:t?i:void 0}),t&&(0,P.jsx)(`p`,{id:i,className:`text-xs text-muted-foreground`,children:t})]})}function Se(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``}function Ce(e){return Se(e.trim().replace(/\.git$/,``)).split(`:`).pop()??``}function we({selectedId:e,onSelect:t}){let n=m(),r=(0,N.useSyncExternalStore)(_,h),i=r===`unreachable`||r===`retrying`,a=d(),o=f().data?.herdr.installed===!1,[s,c]=(0,N.useState)(null),u=(0,N.useRef)(null),p=()=>{c(null),u.current?.focus()},[v,y]=(0,N.useState)(!1),b=a.data??[],x=[null,...new Set([...b.map(e=>e.target),...(n.data??[]).flatMap(e=>e.location.kind===`ssh`?[e.location.machine]:[])])];return(0,P.jsxs)(`section`,{"aria-labelledby":`workspaces-heading`,className:`flex shrink-0 flex-col gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h2`,{id:`workspaces-heading`,className:`text-xs font-medium uppercase text-muted-foreground`,children:`Workspaces`}),(0,P.jsxs)(l,{variant:`ghost`,size:`xs`,onClick:()=>y(e=>!e),children:[!v&&(0,P.jsx)(D,{}),v?`Cancel`:`Add machine`]})]}),v&&(0,P.jsx)(Oe,{herdrMissing:o,onClose:()=>y(!1)}),a.isError&&(o?(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`herdr is not installed on this server, so there are no SSH machines; workspaces on Local can use runner`,` `,W.plain,`.`]}):(0,P.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Failed to list herdr machines: `,a.error.message]})),n.isPending&&!i&&(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading workspaces...`}),(n.isError||n.isPending&&i)&&(0,P.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 text-sm text-destructive`,children:[(0,P.jsxs)(`p`,{children:[`Failed to load workspaces:`,` `,n.error?.message??(g()||`The Toodo server does not answer.`)]}),(0,P.jsx)(l,{size:`xs`,variant:`outline`,onClick:()=>void n.refetch(),children:`Retry now`})]}),n.data?.length===0&&s===null&&(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No workspaces yet.`}),(0,P.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.data&&x.map(r=>{let i=r??`Local`,o=n.data.filter(e=>ye(e.location)===r),d=r!==null&&a.isSuccess?be(r,b):null;return(0,P.jsxs)(`section`,{"aria-label":`Machine ${i}`,className:`flex flex-col gap-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsxs)(`h3`,{className:`flex min-w-0 flex-1 items-center gap-1.5 px-1 text-xs font-semibold`,children:[r===null?(0,P.jsx)(T,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}):(0,P.jsx)(k,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,P.jsx)(`span`,{className:`truncate`,children:i}),d&&(0,P.jsx)(`span`,{className:`ml-1.5 font-normal text-destructive`,children:d})]}),(0,P.jsxs)(l,{size:`xs`,variant:`outline`,"aria-label":`Add workspace on ${i}`,title:`Add a workspace on this machine`,"aria-haspopup":`dialog`,"aria-expanded":s!==null&&s.machine===r,onClick:e=>{u.current=e.currentTarget,c({machine:r})},children:[(0,P.jsx)(D,{}),`Add`]})]}),o.length>0&&(0,P.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(n=>(0,P.jsx)(Te,{workspace:n,selected:n.id===e,onSelect:t},n.id))})]},i)})}),s&&(0,P.jsx)(Ie,{machine:s.machine,onCreated:e=>{p(),t(e.id)},onClose:p})]})}function Te({workspace:e,selected:t,onSelect:n}){let r=a(),[o,s]=(0,N.useState)(!1);return(0,P.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,P.jsxs)(`div`,{className:i(`group flex items-center rounded-lg hover:bg-sidebar-accent`,t&&`bg-sidebar-accent`),children:[(0,P.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:`flex min-w-0 flex-1 flex-col px-2.5 py-1.5 text-left`,children:[(0,P.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,title:Y(e.location),children:R(e.location.path)}),(0,P.jsx)(ve,{workspace:e}),e.pathProblem&&(0,P.jsx)(_e,{problem:e.pathProblem})]}),!o&&(0,P.jsx)(l,{size:`icon-xs`,variant:`ghost`,"aria-label":`Remove ${e.name}`,title:`Remove the workspace and its tasks from Toodo`,className:`mr-1 shrink-0 opacity-0 group-hover:opacity-100 hover:text-destructive focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,onClick:()=>{r.reset(),s(!0)},children:(0,P.jsx)(ee,{})})]}),o&&(0,P.jsxs)(`div`,{role:`group`,"aria-label":`Remove ${e.name}`,className:`flex flex-col gap-1.5 rounded-lg border p-2`,onKeyDown:e=>{e.key===`Escape`&&!r.isPending&&(e.preventDefault(),s(!1))},children:[(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Remove `,e.name,` and its tasks from Toodo? The repository, worktrees, and herdr workspaces are kept.`]}),r.isError&&(0,P.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.error.message}),(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[(0,P.jsx)(l,{changesData:!0,size:`xs`,variant:`destructive`,"aria-label":`Confirm remove ${e.name}`,disabled:r.isPending,onClick:()=>r.mutate(e.id),children:r.isPending?`Removing...`:`Remove`}),(0,P.jsx)(l,{size:`xs`,variant:`ghost`,autoFocus:!0,onClick:()=>s(!1),children:`Back`})]})]})]})}function Q(e,t=!1){return n=>{n.key===`Escape`&&!t&&!n.defaultPrevented&&(n.preventDefault(),e())}}function Ee({workspace:e,onClose:t}){let n=s(),r=d(),i=m(),[a,o]=(0,N.useState)(ye(e.location)),[c,u]=(0,N.useState)(e.location.path),f=[...new Set([...(r.data??[]).map(e=>e.target),...(i.data??[]).flatMap(e=>e.location.kind===`ssh`?[e.location.machine]:[])])],p=ne(c.trim());function h(r){r.preventDefault();let i=a===null?{kind:`local`,path:p}:{kind:`ssh`,machine:a,path:p};n.mutate({id:e.id,location:i},{onSuccess:t})}return(0,P.jsxs)(`form`,{onSubmit:h,"aria-label":`Move ${e.name}`,className:`flex flex-col gap-2 rounded-lg border p-2`,onKeyDown:Q(t,n.isPending),children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Point the workspace at the same repository on another machine or in another folder. Its tasks stay. A repository on a Windows host takes a Windows path such as D:\\dev\\repo.`}),(0,P.jsx)(Z,{label:`Machine`,children:({id:e})=>(0,P.jsxs)(`select`,{id:e,className:q,value:a??``,onChange:e=>o(e.target.value===``?null:e.target.value),autoFocus:!0,children:[(0,P.jsx)(`option`,{value:``,children:`Local (this server)`}),f.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})}),(0,P.jsx)(Z,{label:`Folder`,help:`The repository's own folder on that machine.`,children:({id:e,describedBy:t})=>(0,P.jsx)(re,{id:e,machine:a===null?{kind:`local`}:{kind:`ssh`,label:a},className:q,describedBy:t,value:c,onChange:u,required:!0})}),n.isError&&(0,P.jsx)(`p`,{role:`alert`,className:`text-xs break-words text-destructive`,children:n.error.message}),(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[(0,P.jsx)(l,{type:`submit`,size:`sm`,disabled:n.isPending||p===``,children:n.isPending?`Moving...`:`Move workspace`}),(0,P.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:t,children:`Cancel`})]})]})}var De=`herdr machine add <host>`;function Oe({herdrMissing:e,onClose:t}){let[n,r]=(0,N.useState)(null);async function i(){try{await navigator.clipboard.writeText(De),r(`Copied the command.`)}catch(e){r(`Could not copy: ${String(e)}`)}}return(0,P.jsxs)(`section`,{"aria-label":`Add machine`,className:`flex flex-col gap-2 rounded-lg border p-2`,onKeyDown:Q(t),children:[(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e&&`Install herdr on the server first; SSH machines need it. `,`herdr asks questions in a terminal, which the Toodo server cannot open. Run this command in a terminal on the server, replacing `,(0,P.jsx)(`code`,{children:`<host>`}),` with an SSH host from its ~/.ssh/config, then reload the machine list here.`]}),(0,P.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,P.jsx)(`code`,{className:`max-w-full rounded bg-muted px-1.5 py-1 text-xs`,"aria-label":`Add machine command`,children:De}),(0,P.jsx)(l,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void i(),children:`Copy command`})]}),n&&(0,P.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:n})]})}var ke=[`Source`,`Completion`,`Runner`,`Details`],Ae={none:`A folder without git. Tasks get no branch, worktree, or pull request.`,local_git:`A git repository without GitHub. Task branches merge locally.`,github:`A git repository with a GitHub origin. Tasks ship as pull requests.`},je={open:`The folder already holds the repository.`,init:`Make a folder a new git repository without a remote.`,clone:`Clone a repository URL into a new folder.`},Me={manual:`When its criteria are met; nothing is merged.`,local_merge:`Once its branch is merged into the base branch locally.`,pr_merge:`Once its pull request is merged into the base branch.`},Ne={herdr:`Opens agents in herdr on a worktree and branch of the task.`,plain:`Runs Claude or Codex in the background in a worktree and branch of the task, without herdr.`,tmux:`Runs Claude or Codex in a tmux session in a worktree and branch of the task, without herdr.`,none:`Only marks the task in progress.`};function Pe(e){return e?`herdr is not running on this server; start it there before starting tasks, or choose ${W.plain}.`:`herdr is not running on this server since it is not installed there; install and start herdr before starting tasks, or choose ${W.plain}.`}var Fe={clone:{submit:`Clone workspace`,pending:`Cloning...`},open:{submit:`Open workspace`,pending:`Opening...`},init:{submit:`Init workspace`,pending:`Initializing...`},none:{submit:`Add workspace`,pending:`Adding...`}};function $({legend:e,value:t,choices:n,onChange:r,autoFocus:a=!1}){let o=(0,N.useId)();return(0,P.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,P.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:e}),n.map(e=>{let n=e.value===t,s=e.problem!==null,c=s?null:e.note??null,l=`${o}-${e.value}`;return(0,P.jsxs)(`label`,{className:i(`flex items-start gap-2.5 rounded-lg border px-3 py-2 transition-colors has-focus-visible:border-ring has-focus-visible:ring-3 has-focus-visible:ring-ring/50`,s?`cursor-not-allowed border-dashed`:`cursor-pointer hover:bg-muted`,n&&`border-ring bg-secondary hover:bg-secondary`),children:[(0,P.jsx)(`input`,{type:`radio`,name:o,value:e.value,checked:n,disabled:s,autoFocus:a&&n,"aria-labelledby":l,"aria-describedby":c===null?`${l}-about`:`${l}-about ${l}-note`,onChange:()=>!s&&r(e.value),className:`mt-0.5 size-4 shrink-0 accent-primary`}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,P.jsx)(`span`,{id:l,className:i(`text-sm font-medium`,s&&`text-muted-foreground`),children:e.label}),(0,P.jsxs)(`span`,{id:`${l}-about`,className:`flex items-start gap-1 text-xs text-muted-foreground`,children:[s&&(0,P.jsx)(y,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0`}),e.problem??e.description]}),c!==null&&(0,P.jsxs)(`span`,{id:`${l}-note`,className:i(`flex items-start gap-1 text-xs`,p.attention),children:[(0,P.jsx)(j,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0`}),c]})]})]},e.value)})]})}function Ie({machine:e,onCreated:t,onClose:n}){let r=c(),a=(0,N.useRef)(null),o=(0,N.useId)(),[s,d]=(0,N.useState)(0),[p,m]=(0,N.useState)({source:`github`,repository:null,completion:null,runner:null}),[h,g]=(0,N.useState)(``),[_,v]=(0,N.useState)(null),[y,b]=(0,N.useState)(null),[S,w]=(0,N.useState)(``),T=e??`Local`,E=e===null?{kind:`local`}:{kind:`ssh`,label:e},D=f().data?.herdr,O=e===null&&D!==void 0&&!D.running?Pe(D.installed):null,k=O!==null,A=me(p,k),j=A.repository===`clone`,M=u(E).data,F=M===void 0?``:j?M:xe(M),I=_??F,L=!j&&_===null,R=y??(j?Ce(h):L?``:Se(I)),z=j&&I.trim()&&R.trim()?B(I.trim(),R.trim()):ne(I.trim()),V=s===ke.length-1,G=r.isPending,K=Fe[A.repository??`none`],le=[H[A.source],U[A.completion],W[A.runner],T],q=j?void 0:A.source===`none`?`The folder the tasks are about. Toodo runs no git or herdr there.`:`The repository's own folder.`;function J(e){let t=he(p,e,k);me(t,k).repository===`clone`!==j&&v(null),m(t)}function Y(e){d(e)}function X(){G||n()}function ge(n){if(n.preventDefault(),!V){Y(s+1);return}let i={name:R,location:e===null?{kind:`local`,path:z}:{kind:`ssh`,machine:e,path:z},repository:A.repository===null?null:A.repository===`clone`?{kind:`clone`,url:h}:{kind:A.repository},source:A.source,completion:A.completion,runner:A.runner,defaultBaseBranch:A.source===`none`?null:S.trim()||null};r.mutate(i,{onSuccess:t})}return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50`,children:[(0,P.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-0 bg-black/40 max-md:hidden`,onClick:X}),(0,P.jsx)(`div`,{ref:a,role:`dialog`,"aria-modal":!0,"aria-labelledby":o,onKeyDown:e=>{e.key===`Tab`?te(a.current,e.nativeEvent):Q(n,G)(e)},className:i(`relative flex flex-col overflow-hidden bg-background text-foreground`,`max-md:h-full max-md:pt-[env(safe-area-inset-top)] max-md:pb-[env(safe-area-inset-bottom)]`,`md:absolute md:top-1/2 md:left-1/2 md:h-[min(40rem,calc(100dvh-4rem))] md:w-[min(36rem,calc(100vw-4rem))] md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-2xl md:border md:shadow-xl`),children:(0,P.jsxs)(`form`,{onSubmit:ge,className:`flex min-h-0 flex-1 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-4 pt-3 pb-2 md:px-6 md:pt-4`,children:[(0,P.jsxs)(`h2`,{id:o,className:`min-w-0 flex-1 truncate text-base font-semibold`,children:[`New workspace on `,T]}),(0,P.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close new workspace`,title:`Close (Esc)`,disabled:G,onClick:X,children:(0,P.jsx)(ee,{})})]}),(0,P.jsx)(`ol`,{"aria-label":`Steps`,className:`grid shrink-0 grid-cols-2 gap-1 px-4 pb-3 md:grid-cols-4 md:px-6`,children:ke.map((e,t)=>{let n=t===s;return(0,P.jsx)(`li`,{className:`min-w-0`,children:(0,P.jsxs)(`button`,{type:`button`,"aria-current":n?`step`:void 0,disabled:G,onClick:()=>Y(t),className:i(`flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none`,n&&`bg-secondary hover:bg-secondary`),children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:i(`flex size-5 shrink-0 items-center justify-center rounded-full border text-xs font-medium`,n?`border-primary bg-primary text-primary-foreground`:`text-muted-foreground`),children:t+1}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,P.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:le[t]})]})]})},e)})}),(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain border-t px-4 py-4 md:px-6`,children:[s===0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)($,{legend:`What does the workspace folder hold?`,value:A.source,autoFocus:!0,choices:ie.map(e=>({value:e,label:H[e],description:Ae[e],problem:null})),onChange:e=>J({source:e})}),A.source!==`none`&&(0,P.jsx)($,{legend:`How does the repository get there?`,value:A.repository,choices:se.map(e=>({value:e,label:ce[e],description:je[e],problem:pe(A.source,e)})),onChange:e=>J({repository:e})})]}),s===1&&(0,P.jsx)($,{legend:`When is a task done?`,value:A.completion,autoFocus:!0,choices:ae.map(e=>({value:e,label:U[e],description:Me[e],problem:ue(A.source,e)})),onChange:e=>J({completion:e})}),s===2&&(0,P.jsx)($,{legend:`What does starting a task do?`,value:A.runner,autoFocus:!0,choices:oe.map(t=>({value:t,label:W[t],description:Ne[t],note:t===`herdr`?O:null,problem:fe(t,{kind:e===null?`local`:`ssh`,path:z})??de(A.source,A.completion,t)})),onChange:e=>J({runner:e})}),V&&(0,P.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[j&&(0,P.jsx)(Z,{label:`Repository URL`,children:({id:e})=>(0,P.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,value:h,onChange:e=>g(e.target.value),required:!0,autoFocus:!0})}),(0,P.jsx)(Z,{label:j?`Parent folder`:`Folder`,help:q,children:({id:e,describedBy:t})=>(0,P.jsx)(re,{id:e,machine:E,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,describedBy:t,value:I,onChange:v,required:!0,autoFocus:!j})}),(0,P.jsx)(Z,{label:`Name`,children:({id:e})=>(0,P.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,value:R,onChange:e=>b(e.target.value),required:!0})}),j&&I.trim()&&R.trim()&&(0,P.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,title:z,children:[`Clones into `,z]}),A.repository===`init`&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The folder is created if it does not exist and becomes a git repository without a remote.`}),A.source!==`none`&&(0,P.jsx)(Z,{label:`Base branch`,help:A.repository===`init`?`Uses main if empty.`:`Detected from the repository if empty.`,children:({id:e,describedBy:t})=>(0,P.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,"aria-describedby":t,value:S,onChange:e=>w(e.target.value)})}),r.isError&&(0,P.jsx)(`p`,{role:`alert`,className:`text-xs break-words text-destructive`,children:r.error.message})]})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t px-4 py-3 md:px-6`,children:[s===0?(0,P.jsx)(l,{type:`button`,variant:`ghost`,disabled:G,onClick:X,children:`Cancel`}):(0,P.jsxs)(l,{type:`button`,variant:`ghost`,disabled:G,onClick:()=>Y(s-1),children:[(0,P.jsx)(C,{"data-icon":`inline-start`}),`Back`]}),(0,P.jsx)(l,{type:`submit`,className:`ml-auto`,changesData:V,disabled:G||V&&L,children:V?G?K.pending:K.submit:(0,P.jsxs)(P.Fragment,{children:[`Next`,(0,P.jsx)(x,{"data-icon":`inline-end`})]})})]})]})})]})}export{Y as a,X as c,te as d,ee as f,x as g,C as h,J as i,I as l,D as m,_e as n,Q as o,j as p,we as r,q as s,Ee as t,R as u};
1
+ import{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{F as a,I as o,J as s,N as c,Rt as l,U as u,V as d,ct as f,d as p,wt as m}from"./status-styles-DBWBMQLY.js";import{d as h,h as g,m as _}from"./event-DMqRNLc_.js";var v={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};v.node;var y=t(v),b={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};b.node;var x=t(b),S={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};S.node;var C=t(S),w={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};w.node;var T=t(w),E={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};E.node;var D=t(E),O={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};O.node;var k=t(O),A={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};A.node;var j=t(A),M={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};M.node;var ee=t(M),N=r(e(),1),P=n();function te(e,t){if(e===null)return;let n=[...e.querySelectorAll(`a[href], button, input, select, textarea, summary, [tabindex]`)].filter(e=>!e.matches(`:disabled, [tabindex='-1']`)&&e.getClientRects().length>0);if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement,o=a instanceof Node&&e.contains(a);(t.shiftKey?!o||a===r:!o||a===i)&&(t.preventDefault(),(t.shiftKey?i:r).focus())}function F(e){let t=/^[a-zA-Z]:/.test(e)||e.startsWith(`\\\\`)||e.includes(`\\`)&&!e.includes(`/`),n=t?`\\`:`/`,r=``,i=e,a=t?/^[\\/]{2}[^\\/]+[\\/]+[^\\/]+/.exec(e):null,o=t?/^[a-zA-Z]:([\\/]?)/.exec(e):null;a?(r=`${a[0].replace(/[\\/]+/g,`\\`).replace(/^\\/,`\\\\`)}\\`,i=e.slice(a[0].length)):o?(r=o[0].slice(0,2)+(o[1]?n:``),i=e.slice(o[0].length)):/^[\\/]/.test(e)&&(r=n,i=e.replace(/^[\\/]+/,``));let s=[];for(let e of i.split(t?/[\\/]+/:/\/+/))e!==``&&e!==`.`&&(e===`..`?s.length>0&&s[s.length-1]!==`..`?s.pop():r===``&&s.push(e):s.push(e));return{root:r,separator:n,segments:s}}function I(e){let{root:t,separator:n,segments:r}=F(e),i=t+r.join(n);return i===``?`.`:i}function L(e){return/^[a-zA-Z]:/.test(e)||e.startsWith(`\\\\`)}function R(e,t=2){let{separator:n,segments:r}=F(e);return r.length<=t?I(e):`…${n}${r.slice(-t).join(n)}`}var z=200;function B(e,t){let n=L(e)?`\\`:`/`;return/[\\/]$/.test(e)?`${e}${t}`:`${e}${n}${t}`}function ne(e){return e.replace(/(?<=[^\\/:])[\\/]+$/,``)}function V(e,t){let[n,r]=(0,N.useState)(e);return(0,N.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function re({id:e,machine:t,value:n,onChange:r,describedBy:a,required:s,autoFocus:c,className:l}){let[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(-1),m=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),h=m<0?null:n.slice(0,m+1),g=n.slice(m+1).toLowerCase(),_=V(h,z),v=o(t,u?_:null),y=u&&h!==null&&_===h,b=y&&v.data?v.data.directories.filter(e=>e.toLowerCase().startsWith(g)):[],x=b.length>0,S=`${e}-folders`,C=t.kind===`local`?`the server`:t.label;function w(e){r(e),p(-1),d(!0)}function T(e){h!==null&&w(`${B(h,e)}${L(h)?`\\`:`/`}`)}function E(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!x){d(!0);return}let t=b.length,n=e.key===`ArrowDown`;p(e=>e<0?n?0:t-1:(e+(n?1:t-1))%t)}else if(e.key===`Enter`){if(!x||f<0)return;e.preventDefault(),T(b[f])}else if(e.key===`Tab`){if(!x||e.shiftKey||f<0&&g===``)return;e.preventDefault(),e.stopPropagation(),T(b[Math.max(f,0)])}else if(e.key===`Escape`){if(!x)return;e.preventDefault(),e.stopPropagation(),d(!1)}}return(0,P.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,P.jsx)(`input`,{id:e,role:`combobox`,"aria-expanded":x,"aria-controls":S,"aria-autocomplete":`list`,"aria-activedescendant":x&&f>=0?`${S}-${f}`:void 0,"aria-describedby":a,autoComplete:`off`,spellCheck:!1,className:l,value:n,onChange:e=>w(e.target.value),onFocus:()=>d(!0),onBlur:()=>d(!1),onKeyDown:E,required:s,autoFocus:c}),x&&(0,P.jsx)(`ul`,{id:S,role:`listbox`,"aria-label":`Folders in ${h}`,className:`absolute top-full right-0 left-0 z-10 mt-1 flex max-h-56 flex-col overflow-y-auto rounded-lg border bg-popover p-1 font-mono text-xs text-popover-foreground shadow-md`,children:b.map((e,t)=>(0,P.jsxs)(`li`,{id:`${S}-${t}`,role:`option`,"aria-selected":t===f,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e),className:i(`cursor-pointer truncate rounded px-1.5 py-1 hover:bg-muted max-md:py-2`,t===f&&`bg-secondary hover:bg-secondary`),children:[e,L(h??``)?`\\`:`/`]},e))}),y&&v.isError&&(0,P.jsxs)(`p`,{role:`status`,className:`mt-1 text-xs break-words text-muted-foreground`,children:[`No suggestions: `,v.error.message,`. Type the path of a folder that exists on `,C,`, ending in a separator, to see its subfolders.`]})]})}var ie=[`none`,`local_git`,`github`],ae=[`manual`,`local_merge`,`pr_merge`],oe=[`herdr`,`plain`,`tmux`,`none`],se=[`open`,`init`,`clone`],H={none:`Plain folder`,local_git:`Local git`,github:`GitHub`},U={manual:`Manual`,local_merge:`Local merge`,pr_merge:`PR merge`},W={none:`No runner`,herdr:`herdr`,plain:`Plain`,tmux:`tmux`},ce={open:`Open existing`,init:`New repository`,clone:`Clone URL`};function G(e){return e===`none`?`manual`:e===`local_git`?`local_merge`:`pr_merge`}function K(e,t=!1){return e===`none`?`none`:t?`plain`:`herdr`}function le(e){return e===`none`?null:`open`}function ue(e,t){switch(t){case`manual`:return null;case`local_merge`:return e===`local_git`?null:e===`none`?`Needs a git repository; choose source Local git`:`GitHub tasks merge through pull requests; choose source Local git`;case`pr_merge`:return e===`github`?null:e===`none`?`Needs a git repository; choose source GitHub`:`Needs a GitHub origin remote; choose source GitHub`}}function de(e,t,n){return n!==`none`&&e===`none`?`Needs a git repository for task worktrees; choose source Local git or GitHub`:n===`none`&&t!==`manual`?`${U[t]} needs the task branch that herdr, ${W.plain}, or ${W.tmux} creates; choose completion Manual`:null}function fe(e,t){return e===`tmux`&&t.kind===`ssh`&&L(t.path)?`Needs a POSIX host; choose ${W.plain} or ${W.herdr} for a Windows SSH workspace, or choose a POSIX path for ${W.tmux}`:null}function pe(e,t){return e===`none`?`A plain folder has no repository; choose source Local git or GitHub`:e===`github`&&t===`init`?`A new repository has no GitHub origin; choose source Local git`:null}function me(e,t=!1){let{source:n}=e,r=e.repository!==null&&pe(n,e.repository)===null?e.repository:le(n),i=e.completion!==null&&ue(n,e.completion)===null?e.completion:G(n);return{source:n,repository:r,completion:i,runner:e.runner!==null&&de(n,i,e.runner)===null?e.runner:K(n,t)}}function he(e,t,n=!1){let r={...e,...t},i=me(r,n);return{source:r.source,repository:r.repository===i.repository?r.repository:null,completion:r.completion===i.completion?r.completion:null,runner:r.runner===i.runner?r.runner:null}}var q=`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,J=`h-6 rounded-md border border-input bg-background px-1.5 text-xs outline-none max-md:h-11 max-md:px-2.5 max-md:text-sm focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50`;function Y(e){let t=I(e.path);return e.kind===`local`?t:`${e.machine}:${t}`}function X(e){let t=R(e.path);return e.kind===`local`?t:`${e.machine}:${t}`}var ge={foreign:`Windows path, not on this server`,missing:`Folder not found on the server`};function _e({problem:e,className:t}){return(0,P.jsxs)(`span`,{className:i(`flex min-w-0 items-start gap-1 text-xs text-destructive`,t),title:`Toodo cannot run git in this repository until its path is corrected`,children:[(0,P.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3 shrink-0`}),(0,P.jsx)(`span`,{children:ge[e]})]})}function ve({workspace:e}){let t=H[e.source],n=U[e.completion],r=W[e.runner];return(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground`,title:`Source ${t}, completion ${n}, runner ${r}; set when the workspace was added`,children:[(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:t}),` · `,(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:n}),` `,`· `,(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:r})]})}function ye(e){return e.kind===`local`?null:e.machine}function be(e,t){let n=t.filter(t=>t.target===e);return n.length===0?`Not saved in herdr`:n.some(e=>e.enabled)?null:`Disabled in herdr`}function xe(e){return/[\\/]$/.test(e)?e:B(e,``)}function Z({label:e,help:t,children:n}){let r=(0,N.useId)(),i=`${r}-help`;return(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(`label`,{htmlFor:r,className:`text-xs text-muted-foreground`,children:e}),n({id:r,describedBy:t?i:void 0}),t&&(0,P.jsx)(`p`,{id:i,className:`text-xs text-muted-foreground`,children:t})]})}function Se(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``}function Ce(e){return Se(e.trim().replace(/\.git$/,``)).split(`:`).pop()??``}function we({selectedId:e,onSelect:t}){let n=m(),r=(0,N.useSyncExternalStore)(_,h),i=r===`unreachable`||r===`retrying`,a=d(),o=f().data?.herdr.installed===!1,[s,c]=(0,N.useState)(null),u=(0,N.useRef)(null),p=()=>{c(null),u.current?.focus()},[v,y]=(0,N.useState)(!1),b=a.data??[],x=[null,...new Set([...b.map(e=>e.target),...(n.data??[]).flatMap(e=>e.location.kind===`ssh`?[e.location.machine]:[])])];return(0,P.jsxs)(`section`,{"aria-labelledby":`workspaces-heading`,className:`flex shrink-0 flex-col gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h2`,{id:`workspaces-heading`,className:`text-xs font-medium uppercase text-muted-foreground`,children:`Workspaces`}),(0,P.jsxs)(l,{variant:`ghost`,size:`xs`,onClick:()=>y(e=>!e),children:[!v&&(0,P.jsx)(D,{}),v?`Cancel`:`Add machine`]})]}),v&&(0,P.jsx)(Oe,{herdrMissing:o,onClose:()=>y(!1)}),a.isError&&(o?(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`herdr is not installed on this server, so there are no SSH machines; workspaces on Local can use runner`,` `,W.plain,`.`]}):(0,P.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Failed to list herdr machines: `,a.error.message]})),n.isPending&&!i&&(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading workspaces...`}),(n.isError||n.isPending&&i)&&(0,P.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 text-sm text-destructive`,children:[(0,P.jsxs)(`p`,{children:[`Failed to load workspaces:`,` `,n.error?.message??(g()||`The Toodo server does not answer.`)]}),(0,P.jsx)(l,{size:`xs`,variant:`outline`,onClick:()=>void n.refetch(),children:`Retry now`})]}),n.data?.length===0&&s===null&&(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No workspaces yet.`}),(0,P.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.data&&x.map(r=>{let i=r??`Local`,o=n.data.filter(e=>ye(e.location)===r),d=r!==null&&a.isSuccess?be(r,b):null;return(0,P.jsxs)(`section`,{"aria-label":`Machine ${i}`,className:`flex flex-col gap-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsxs)(`h3`,{className:`flex min-w-0 flex-1 items-center gap-1.5 px-1 text-xs font-semibold`,children:[r===null?(0,P.jsx)(T,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}):(0,P.jsx)(k,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,P.jsx)(`span`,{className:`truncate`,children:i}),d&&(0,P.jsx)(`span`,{className:`ml-1.5 font-normal text-destructive`,children:d})]}),(0,P.jsxs)(l,{size:`xs`,variant:`outline`,"aria-label":`Add workspace on ${i}`,title:`Add a workspace on this machine`,"aria-haspopup":`dialog`,"aria-expanded":s!==null&&s.machine===r,onClick:e=>{u.current=e.currentTarget,c({machine:r})},children:[(0,P.jsx)(D,{}),`Add`]})]}),o.length>0&&(0,P.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(n=>(0,P.jsx)(Te,{workspace:n,selected:n.id===e,onSelect:t},n.id))})]},i)})}),s&&(0,P.jsx)(Ie,{machine:s.machine,onCreated:e=>{p(),t(e.id)},onClose:p})]})}function Te({workspace:e,selected:t,onSelect:n}){let r=a(),[o,s]=(0,N.useState)(!1);return(0,P.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,P.jsxs)(`div`,{className:i(`group flex items-center rounded-lg hover:bg-sidebar-accent`,t&&`bg-sidebar-accent`),children:[(0,P.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:`flex min-w-0 flex-1 flex-col px-2.5 py-1.5 text-left`,children:[(0,P.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,title:Y(e.location),children:R(e.location.path)}),(0,P.jsx)(ve,{workspace:e}),e.pathProblem&&(0,P.jsx)(_e,{problem:e.pathProblem})]}),!o&&(0,P.jsx)(l,{size:`icon-xs`,variant:`ghost`,"aria-label":`Remove ${e.name}`,title:`Remove the workspace and its tasks from Toodo`,className:`mr-1 shrink-0 opacity-0 group-hover:opacity-100 hover:text-destructive focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,onClick:()=>{r.reset(),s(!0)},children:(0,P.jsx)(ee,{})})]}),o&&(0,P.jsxs)(`div`,{role:`group`,"aria-label":`Remove ${e.name}`,className:`flex flex-col gap-1.5 rounded-lg border p-2`,onKeyDown:e=>{e.key===`Escape`&&!r.isPending&&(e.preventDefault(),s(!1))},children:[(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Remove `,e.name,` and its tasks from Toodo? The repository, worktrees, and herdr workspaces are kept.`]}),r.isError&&(0,P.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.error.message}),(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[(0,P.jsx)(l,{changesData:!0,size:`xs`,variant:`destructive`,"aria-label":`Confirm remove ${e.name}`,disabled:r.isPending,onClick:()=>r.mutate(e.id),children:r.isPending?`Removing...`:`Remove`}),(0,P.jsx)(l,{size:`xs`,variant:`ghost`,autoFocus:!0,onClick:()=>s(!1),children:`Back`})]})]})]})}function Q(e,t=!1){return n=>{n.key===`Escape`&&!t&&!n.defaultPrevented&&(n.preventDefault(),e())}}function Ee({workspace:e,onClose:t}){let n=s(),r=d(),i=m(),[a,o]=(0,N.useState)(ye(e.location)),[c,u]=(0,N.useState)(e.location.path),f=[...new Set([...(r.data??[]).map(e=>e.target),...(i.data??[]).flatMap(e=>e.location.kind===`ssh`?[e.location.machine]:[])])],p=ne(c.trim());function h(r){r.preventDefault();let i=a===null?{kind:`local`,path:p}:{kind:`ssh`,machine:a,path:p};n.mutate({id:e.id,location:i},{onSuccess:t})}return(0,P.jsxs)(`form`,{onSubmit:h,"aria-label":`Move ${e.name}`,className:`flex flex-col gap-2 rounded-lg border p-2`,onKeyDown:Q(t,n.isPending),children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Point the workspace at the same repository on another machine or in another folder. Its tasks stay. A repository on a Windows host takes a Windows path such as D:\\dev\\repo.`}),(0,P.jsx)(Z,{label:`Machine`,children:({id:e})=>(0,P.jsxs)(`select`,{id:e,className:q,value:a??``,onChange:e=>o(e.target.value===``?null:e.target.value),autoFocus:!0,children:[(0,P.jsx)(`option`,{value:``,children:`Local (this server)`}),f.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})}),(0,P.jsx)(Z,{label:`Folder`,help:`The repository's own folder on that machine.`,children:({id:e,describedBy:t})=>(0,P.jsx)(re,{id:e,machine:a===null?{kind:`local`}:{kind:`ssh`,label:a},className:q,describedBy:t,value:c,onChange:u,required:!0})}),n.isError&&(0,P.jsx)(`p`,{role:`alert`,className:`text-xs break-words text-destructive`,children:n.error.message}),(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[(0,P.jsx)(l,{type:`submit`,size:`sm`,disabled:n.isPending||p===``,children:n.isPending?`Moving...`:`Move workspace`}),(0,P.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:t,children:`Cancel`})]})]})}var De=`herdr machine add <host>`;function Oe({herdrMissing:e,onClose:t}){let[n,r]=(0,N.useState)(null);async function i(){try{await navigator.clipboard.writeText(De),r(`Copied the command.`)}catch(e){r(`Could not copy: ${String(e)}`)}}return(0,P.jsxs)(`section`,{"aria-label":`Add machine`,className:`flex flex-col gap-2 rounded-lg border p-2`,onKeyDown:Q(t),children:[(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e&&`Install herdr on the server first; SSH machines need it. `,`herdr asks questions in a terminal, which the Toodo server cannot open. Run this command in a terminal on the server, replacing `,(0,P.jsx)(`code`,{children:`<host>`}),` with an SSH host from its ~/.ssh/config, then reload the machine list here.`]}),(0,P.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,P.jsx)(`code`,{className:`max-w-full rounded bg-muted px-1.5 py-1 text-xs`,"aria-label":`Add machine command`,children:De}),(0,P.jsx)(l,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void i(),children:`Copy command`})]}),n&&(0,P.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:n})]})}var ke=[`Source`,`Completion`,`Runner`,`Details`],Ae={none:`A folder without git. Tasks get no branch, worktree, or pull request.`,local_git:`A git repository without GitHub. Task branches merge locally.`,github:`A git repository with a GitHub origin. Tasks ship as pull requests.`},je={open:`The folder already holds the repository.`,init:`Make a folder a new git repository without a remote.`,clone:`Clone a repository URL into a new folder.`},Me={manual:`When its criteria are met; nothing is merged.`,local_merge:`Once its branch is merged into the base branch locally.`,pr_merge:`Once its pull request is merged into the base branch.`},Ne={herdr:`Opens agents in herdr on a worktree and branch of the task.`,plain:`Runs Claude or Codex in the background in a worktree and branch of the task, without herdr.`,tmux:`Runs Claude or Codex in a tmux session in a worktree and branch of the task, without herdr.`,none:`Only marks the task in progress.`};function Pe(e){return e?`herdr is not running on this server; start it there before starting tasks, or choose ${W.plain}.`:`herdr is not running on this server since it is not installed there; install and start herdr before starting tasks, or choose ${W.plain}.`}var Fe={clone:{submit:`Clone workspace`,pending:`Cloning...`},open:{submit:`Open workspace`,pending:`Opening...`},init:{submit:`Init workspace`,pending:`Initializing...`},none:{submit:`Add workspace`,pending:`Adding...`}};function $({legend:e,value:t,choices:n,onChange:r,autoFocus:a=!1}){let o=(0,N.useId)();return(0,P.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,P.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:e}),n.map(e=>{let n=e.value===t,s=e.problem!==null,c=s?null:e.note??null,l=`${o}-${e.value}`;return(0,P.jsxs)(`label`,{className:i(`flex items-start gap-2.5 rounded-lg border px-3 py-2 transition-colors has-focus-visible:border-ring has-focus-visible:ring-3 has-focus-visible:ring-ring/50`,s?`cursor-not-allowed border-dashed`:`cursor-pointer hover:bg-muted`,n&&`border-ring bg-secondary hover:bg-secondary`),children:[(0,P.jsx)(`input`,{type:`radio`,name:o,value:e.value,checked:n,disabled:s,autoFocus:a&&n,"aria-labelledby":l,"aria-describedby":c===null?`${l}-about`:`${l}-about ${l}-note`,onChange:()=>!s&&r(e.value),className:`mt-0.5 size-4 shrink-0 accent-primary`}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,P.jsx)(`span`,{id:l,className:i(`text-sm font-medium`,s&&`text-muted-foreground`),children:e.label}),(0,P.jsxs)(`span`,{id:`${l}-about`,className:`flex items-start gap-1 text-xs text-muted-foreground`,children:[s&&(0,P.jsx)(y,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0`}),e.problem??e.description]}),c!==null&&(0,P.jsxs)(`span`,{id:`${l}-note`,className:i(`flex items-start gap-1 text-xs`,p.attention),children:[(0,P.jsx)(j,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0`}),c]})]})]},e.value)})]})}function Ie({machine:e,onCreated:t,onClose:n}){let r=c(),a=(0,N.useRef)(null),o=(0,N.useId)(),[s,d]=(0,N.useState)(0),[p,m]=(0,N.useState)({source:`github`,repository:null,completion:null,runner:null}),[h,g]=(0,N.useState)(``),[_,v]=(0,N.useState)(null),[y,b]=(0,N.useState)(null),[S,w]=(0,N.useState)(``),T=e??`Local`,E=e===null?{kind:`local`}:{kind:`ssh`,label:e},D=f().data?.herdr,O=e===null&&D!==void 0&&!D.running?Pe(D.installed):null,k=O!==null,A=me(p,k),j=A.repository===`clone`,M=u(E).data,F=M===void 0?``:j?M:xe(M),I=_??F,L=!j&&_===null,R=y??(j?Ce(h):L?``:Se(I)),z=j&&I.trim()&&R.trim()?B(I.trim(),R.trim()):ne(I.trim()),V=s===ke.length-1,G=r.isPending,K=Fe[A.repository??`none`],le=[H[A.source],U[A.completion],W[A.runner],T],q=j?void 0:A.source===`none`?`The folder the tasks are about. Toodo runs no git or herdr there.`:`The repository's own folder.`;function J(e){let t=he(p,e,k);me(t,k).repository===`clone`!==j&&v(null),m(t)}function Y(e){d(e)}function X(){G||n()}function ge(n){if(n.preventDefault(),!V){Y(s+1);return}let i={name:R,location:e===null?{kind:`local`,path:z}:{kind:`ssh`,machine:e,path:z},repository:A.repository===null?null:A.repository===`clone`?{kind:`clone`,url:h}:{kind:A.repository},source:A.source,completion:A.completion,runner:A.runner,defaultBaseBranch:A.source===`none`?null:S.trim()||null};r.mutate(i,{onSuccess:t})}return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50`,children:[(0,P.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-0 bg-black/40 max-md:hidden`,onClick:X}),(0,P.jsx)(`div`,{ref:a,role:`dialog`,"aria-modal":!0,"aria-labelledby":o,onKeyDown:e=>{e.key===`Tab`?te(a.current,e.nativeEvent):Q(n,G)(e)},className:i(`relative flex flex-col overflow-hidden bg-background text-foreground`,`max-md:h-full max-md:pt-[env(safe-area-inset-top)] max-md:pb-[env(safe-area-inset-bottom)]`,`md:absolute md:top-1/2 md:left-1/2 md:h-[min(40rem,calc(100dvh-4rem))] md:w-[min(36rem,calc(100vw-4rem))] md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-2xl md:border md:shadow-xl`),children:(0,P.jsxs)(`form`,{onSubmit:ge,className:`flex min-h-0 flex-1 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-4 pt-3 pb-2 md:px-6 md:pt-4`,children:[(0,P.jsxs)(`h2`,{id:o,className:`min-w-0 flex-1 truncate text-base font-semibold`,children:[`New workspace on `,T]}),(0,P.jsx)(l,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close new workspace`,title:`Close (Esc)`,disabled:G,onClick:X,children:(0,P.jsx)(ee,{})})]}),(0,P.jsx)(`ol`,{"aria-label":`Steps`,className:`grid shrink-0 grid-cols-2 gap-1 px-4 pb-3 md:grid-cols-4 md:px-6`,children:ke.map((e,t)=>{let n=t===s;return(0,P.jsx)(`li`,{className:`min-w-0`,children:(0,P.jsxs)(`button`,{type:`button`,"aria-current":n?`step`:void 0,disabled:G,onClick:()=>Y(t),className:i(`flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none`,n&&`bg-secondary hover:bg-secondary`),children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:i(`flex size-5 shrink-0 items-center justify-center rounded-full border text-xs font-medium`,n?`border-primary bg-primary text-primary-foreground`:`text-muted-foreground`),children:t+1}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,P.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:le[t]})]})]})},e)})}),(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain border-t px-4 py-4 md:px-6`,children:[s===0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)($,{legend:`What does the workspace folder hold?`,value:A.source,autoFocus:!0,choices:ie.map(e=>({value:e,label:H[e],description:Ae[e],problem:null})),onChange:e=>J({source:e})}),A.source!==`none`&&(0,P.jsx)($,{legend:`How does the repository get there?`,value:A.repository,choices:se.map(e=>({value:e,label:ce[e],description:je[e],problem:pe(A.source,e)})),onChange:e=>J({repository:e})})]}),s===1&&(0,P.jsx)($,{legend:`When is a task done?`,value:A.completion,autoFocus:!0,choices:ae.map(e=>({value:e,label:U[e],description:Me[e],problem:ue(A.source,e)})),onChange:e=>J({completion:e})}),s===2&&(0,P.jsx)($,{legend:`What does starting a task do?`,value:A.runner,autoFocus:!0,choices:oe.map(t=>({value:t,label:W[t],description:Ne[t],note:t===`herdr`?O:null,problem:fe(t,{kind:e===null?`local`:`ssh`,path:z})??de(A.source,A.completion,t)})),onChange:e=>J({runner:e})}),V&&(0,P.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[j&&(0,P.jsx)(Z,{label:`Repository URL`,children:({id:e})=>(0,P.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,value:h,onChange:e=>g(e.target.value),required:!0,autoFocus:!0})}),(0,P.jsx)(Z,{label:j?`Parent folder`:`Folder`,help:q,children:({id:e,describedBy:t})=>(0,P.jsx)(re,{id:e,machine:E,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,describedBy:t,value:I,onChange:v,required:!0,autoFocus:!j})}),(0,P.jsx)(Z,{label:`Name`,children:({id:e})=>(0,P.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,value:R,onChange:e=>b(e.target.value),required:!0})}),j&&I.trim()&&R.trim()&&(0,P.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,title:z,children:[`Clones into `,z]}),A.repository===`init`&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The folder is created if it does not exist and becomes a git repository without a remote.`}),A.source!==`none`&&(0,P.jsx)(Z,{label:`Base branch`,help:A.repository===`init`?`Uses main if empty.`:`Detected from the repository if empty.`,children:({id:e,describedBy:t})=>(0,P.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,"aria-describedby":t,value:S,onChange:e=>w(e.target.value)})}),r.isError&&(0,P.jsx)(`p`,{role:`alert`,className:`text-xs break-words text-destructive`,children:r.error.message})]})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t px-4 py-3 md:px-6`,children:[s===0?(0,P.jsx)(l,{type:`button`,variant:`ghost`,disabled:G,onClick:X,children:`Cancel`}):(0,P.jsxs)(l,{type:`button`,variant:`ghost`,disabled:G,onClick:()=>Y(s-1),children:[(0,P.jsx)(C,{"data-icon":`inline-start`}),`Back`]}),(0,P.jsx)(l,{type:`submit`,className:`ml-auto`,changesData:V,disabled:G||V&&L,children:V?G?K.pending:K.submit:(0,P.jsxs)(P.Fragment,{children:[`Next`,(0,P.jsx)(x,{"data-icon":`inline-end`})]})})]})]})})]})}export{Y as a,X as c,te as d,ee as f,x as g,C as h,J as i,I as l,D as m,_e as n,Q as o,j as p,we as r,q as s,Ee as t,R as u};
package/web/index.html CHANGED
@@ -8,11 +8,11 @@
8
8
  <meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)" />
9
9
  <meta name="theme-color" content="#0a0a0a" media="(prefers-color-scheme: dark)" />
10
10
  <title>Toodo</title>
11
- <script type="module" crossorigin src="/assets/index-HFVp-zc_.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-Zmn5kL0P.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/dist-ZmB2kPfR.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/event-DMqRNLc_.js">
14
- <link rel="modulepreload" crossorigin href="/assets/status-styles-DDSPyzwv.js">
15
- <link rel="modulepreload" crossorigin href="/assets/workspace-list-DRGN9qgP.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/status-styles-DBWBMQLY.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/workspace-list-CoCw30hU.js">
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-BSifYlbA.css">
17
17
  <link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials">
18
18
  <link rel="apple-touch-icon" href="/pwa/apple-touch-icon.png">
package/web/sw.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Generated by vite-pwa.ts for this build.
2
- const CACHE = "toodo-shell-c774e79c7ad7d1f7";
3
- const SHELL = ["/","/assets/details-sheet-Fivv1fWU.js","/assets/dist-ZmB2kPfR.js","/assets/event-DMqRNLc_.js","/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2","/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2","/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2","/assets/geist-latin-wght-normal-BgDaEnEv.woff2","/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2","/assets/index-BSifYlbA.css","/assets/index-HFVp-zc_.js","/assets/markdown-Drr9IKXb.js","/assets/offline-screen-DqKwnnUM.js","/assets/opener-DWhHPoCL.js","/assets/review-CjaAq8ZB.js","/assets/server-access-B8g9GUGd.js","/assets/status-styles-DDSPyzwv.js","/assets/task-details-CaCML3iM.js","/assets/task-graph-D4YgVzbz.js","/assets/task-graph-DLioOiRN.css","/assets/workspace-list-DRGN9qgP.js","/favicon.svg","/manifest.webmanifest","/pwa/apple-touch-icon.png","/pwa/icon-192.png","/pwa/icon-512.png","/pwa/icon-maskable-192.png","/pwa/icon-maskable-512.png"];
2
+ const CACHE = "toodo-shell-e16e0bfa44fd3907";
3
+ const SHELL = ["/","/assets/details-sheet-BWS6ccAQ.js","/assets/dist-ZmB2kPfR.js","/assets/event-DMqRNLc_.js","/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2","/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2","/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2","/assets/geist-latin-wght-normal-BgDaEnEv.woff2","/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2","/assets/index-BSifYlbA.css","/assets/index-Zmn5kL0P.js","/assets/markdown-CT1Xj_d_.js","/assets/offline-screen-DiQd-lnA.js","/assets/opener-DWhHPoCL.js","/assets/review-DUb-ox8c.js","/assets/server-access-BfPQvKo3.js","/assets/status-styles-DBWBMQLY.js","/assets/task-details-DKfHFIWc.js","/assets/task-graph-DLioOiRN.css","/assets/task-graph-NTqnLqwa.js","/assets/workspace-list-CoCw30hU.js","/favicon.svg","/manifest.webmanifest","/pwa/apple-touch-icon.png","/pwa/icon-192.png","/pwa/icon-512.png","/pwa/icon-maskable-192.png","/pwa/icon-maskable-512.png"];
4
4
  const SERVER_PATHS = ["/api","/mcp"];
5
5
  const NOTIFICATION_ICON = "/pwa/icon-192.png";
6
6
  // The message that asks an open page to show a task; see listenForOpenTask in src/web/push.ts.
@@ -1 +0,0 @@
1
- import{i as e,r as t,s as n}from"./dist-ZmB2kPfR.js";import{Rt as r}from"./status-styles-DDSPyzwv.js";import{s as i}from"./workspace-list-DRGN9qgP.js";import{c as a,l as o,s}from"./event-DMqRNLc_.js";import{i as c,n as l,r as u}from"./index-HFVp-zc_.js";var d=n(e(),1),f=t();function p({children:e}){return(0,d.useSyncExternalStore)(o,s)===null?(0,f.jsx)(m,{}):e}function m(){let[e,t]=(0,d.useState)(``),[n,o]=(0,d.useState)(()=>u(navigator.userAgent)),[s,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useId)(),b=`${y}-help`,x=`${y}-rejected`;async function S(t){t.preventDefault(),_(!0),p(null),h(!1);try{a(await c(e.trim(),n.trim()))}catch(e){e instanceof l?(h(!0),v.current?.focus(),v.current?.select()):e instanceof TypeError?p(`Could not reach the server: ${String(e)}`):p(e instanceof Error?e.message:String(e))}finally{_(!1)}}return(0,f.jsx)(`main`,{className:`flex min-h-svh flex-col items-center justify-center gap-4 p-6`,children:(0,f.jsxs)(`form`,{onSubmit:S,"aria-label":`Server access`,className:`flex w-full max-w-sm flex-col gap-3 rounded-lg border p-5`,children:[(0,f.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Toodo server`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Sign in with the server's access token. This browser then gets a token of its own, which you can revoke under Devices.`}),(0,f.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`label`,{htmlFor:`${y}-token`,className:`text-xs text-muted-foreground`,children:`Access token`}),(0,f.jsx)(`input`,{ref:v,id:`${y}-token`,className:`${i} aria-invalid:border-destructive`,type:`password`,autoComplete:`current-password`,value:e,onChange:e=>{t(e.target.value),h(!1)},"aria-invalid":m||void 0,"aria-describedby":m?`${x} ${b}`:b,required:!0}),m&&(0,f.jsxs)(`p`,{id:x,role:`alert`,className:`text-xs text-destructive`,children:[`The server did not accept this token. Paste the whole contents of`,` `,(0,f.jsx)(`code`,{className:`text-xs`,children:`web-token`}),` again; a device token stops working once it is revoked.`]}),(0,f.jsxs)(`p`,{id:b,className:`text-xs text-muted-foreground`,children:[`Copy it from `,(0,f.jsx)(`code`,{className:`text-xs`,children:`web-token`}),` in the server's data directory.`]})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Device name`,(0,f.jsx)(`input`,{className:i,maxLength:80,value:n,onChange:e=>o(e.target.value),required:!0})]}),s&&(0,f.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:s}),(0,f.jsx)(r,{type:`submit`,disabled:g||!e.trim()||!n.trim(),children:g?`Checking...`:`Continue`})]})})}export{p as ServerAccess};
@@ -1 +0,0 @@
1
- import{i as e,r as t,s as n,t as r}from"./dist-ZmB2kPfR.js";import{d as i,i as a,m as o,n as s,o as c,p as l,r as u,s as d}from"./event-DMqRNLc_.js";var f=n(e(),1),p=t(),m=f.createContext(void 0),h=e=>{let t=f.useContext(m);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},g=({client:e,children:t})=>(f.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,p.jsx)(m.Provider,{value:e,children:t})),_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},v=new class{#e=_;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function ee(e){setTimeout(e,0)}var te=typeof window>`u`||`Deno`in globalThis;function y(){}function ne(e,t){return typeof e==`function`?e(t):e}function re(e){return typeof e==`number`&&e>=0&&e!==1/0}function ie(e,t){return Math.max(e+(t||0)-Date.now(),0)}function b(e,t){return typeof e==`function`?e(t):e}function ae(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==se(o,t.options))return!1}else if(!S(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function oe(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(x(t.options.mutationKey)!==x(a))return!1}else if(!S(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function se(e,t){return(t?.queryKeyHashFn||x)(e)}function x(e){return JSON.stringify(e,(e,t)=>de(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function S(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!S(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!S(e[r],t[r]))return!1;return!0}return!1}var ce=Object.prototype.hasOwnProperty;function le(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ue(e)&&ue(t);if(!r&&!(de(e)&&de(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ce.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=le(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function C(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ue(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function de(e){if(!fe(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!fe(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function fe(e){return Object.prototype.toString.call(e)===`[object Object]`}function pe(e){return new Promise(t=>{v.setTimeout(t,e)})}function me(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:le(e,t)}function he(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function ge(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var _e=Symbol();function ve(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===_e?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function w(e,t){return typeof e==`function`?e(...t):!!e}function ye(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var be=()=>te,xe=()=>be(),T=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Se=new class extends T{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Ce=ee;function we(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Ce,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var E=we(),Te=new class extends T{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Ee(e){return Math.min(1e3*2**e,3e4)}function De(e){return(e??`online`)!==`online`||Te.isOnline()}var Oe=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ke(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(y);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Oe(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Se.isFocused()&&(e.networkMode===`always`||Te.isOnline())&&e.canRun(),p=()=>De(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=t=>new Promise(n=>{r=e=>{(c()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(xe()?0:3),a=e.retryDelay??Ee,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?h(r):(n++,e.onFail?.(n,r),pe(o).then(()=>f()?void 0:g(f)).then(()=>{t?h(r):_()}))})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g(p).then(_),s)}}var Ae=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),re(this.gcTime)&&(this.#e=v.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(xe()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(v.clearTimeout(this.#e),this.#e=void 0)}};function je(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ye(e,()=>t.signal,()=>n=!0)},u=ve(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?ge:he;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Ne:Me,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Me(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Me(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ne(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Pe=class extends Ae{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Le(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Le(this.options);e.data!==void 0&&(this.setState(Ie(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=me(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(y).catch(y):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>b(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_e||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>b(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!ie(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ve(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?je(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=ke({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Oe&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Oe){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Fe(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ie(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),E.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Fe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:De(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ie(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Le(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Re=class extends T{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Be(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ve(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ve(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof b(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!C(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&He(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||b(this.options.staleTime,this.#t)!==b(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return C(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(y)),t}#h(e){return!xe()&&b(this.options.enabled,this.#t)!==!1&&re(e)}#g(){this.#b();let e=b(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=ie(this.#r.dataUpdatedAt,e)+1;this.#u=v.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return b(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=v.setInterval(()=>{(this.options.refetchIntervalInBackground||Se.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(v.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(v.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Be(e,t),o=i&&He(e,n,t,r);(a||o)&&(l={...l,...Fe(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=me(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=me(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,ee=_&&g,te=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:ee,isLoading:ee,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!te,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&te,isStale:Ue(e,t),refetch:this.refetch,isEnabled:b(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),C(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();E.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function ze(e,t){return b(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||b(t.retryOnMount,e)!==!1)}function Be(e,t){return ze(e,t)||e.state.data!==void 0&&Ve(e,t,t.refetchOnMount)}function Ve(e,t,n){if(b(t.enabled,e)!==!1&&b(t.staleTime,e)!==`static`){let r=b(n,e);return r===`always`||r!==!1&&Ue(e,t)}return!1}function He(e,t,n,r){return(e!==t||b(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ue(e,n)}function Ue(e,t){return b(t.enabled,e)!==!1&&e.isStaleByTime(b(t.staleTime,e))}var We=class extends Ae{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ge(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=ke({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),E.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ge(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ke=class extends T{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),C(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&x(t.mutationKey)!==x(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ge();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){E.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},qe=f.createContext(!1),Je=()=>f.useContext(qe);qe.Provider;function Ye(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Xe=f.createContext(Ye()),Ze=()=>f.useContext(Xe),Qe=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?w(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},$e=e=>{f.useEffect(()=>{e.clearReset()},[e])},et=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||w(n,[e.error,r])),tt=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},nt=(e,t)=>e?.suspense&&t.isPending,rt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function it(e,t,n){let r=Je(),i=Ze(),a=h(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,tt(o),Qe(o,i,s),$e(i);let[l]=f.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(f.useSyncExternalStore(f.useCallback(e=>{let t=d?l.subscribe(E.batchCalls(e)):y;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),f.useEffect(()=>{l.setOptions(o)},[o,l]),nt(o,u))throw rt(o,l,i);if(et({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function D(e,t){return it(e,Re,t)}function O(e,t){let n=h(t),[r]=f.useState(()=>new Ke(n,e));f.useEffect(()=>{r.setOptions(e)},[r,e]);let i=f.useSyncExternalStore(f.useCallback(e=>r.subscribe(E.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=f.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(y)},[r]);if(i.error&&w(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function k(){return typeof window<`u`}function A(e){return ot(e)?(e.nodeName||``).toLowerCase():`#document`}function j(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function at(e){return((ot(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ot(e){return k()?e instanceof Node||e instanceof j(e).Node:!1}function st(e){return k()?e instanceof Element||e instanceof j(e).Element:!1}function M(e){return k()?e instanceof HTMLElement||e instanceof j(e).HTMLElement:!1}function ct(e){return!k()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof j(e).ShadowRoot}function lt(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=yt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ut(e){return/^(table|td|th)$/.test(A(e))}function dt(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ft=/transform|translate|scale|rotate|perspective|filter/,pt=/paint|layout|strict|content/,N=e=>!!e&&e!==`none`,mt;function ht(e){let t=st(e)?yt(e):e;return N(t.transform)||N(t.translate)||N(t.scale)||N(t.rotate)||N(t.perspective)||!_t()&&(N(t.backdropFilter)||N(t.filter))||ft.test(t.willChange||``)||pt.test(t.contain||``)}function gt(e){let t=P(e);for(;M(t)&&!vt(t);){if(ht(t))return t;if(dt(t))return null;t=P(t)}return null}function _t(){return mt??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),mt}function vt(e){return/^(html|body|#document)$/.test(A(e))}function yt(e){return j(e).getComputedStyle(e)}function bt(e){return st(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function P(e){if(A(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ct(e)&&e.host||at(e);return ct(t)?t.host:t}function xt(e){let t=P(e);return vt(t)?(e.ownerDocument||e).body:M(t)&&lt(t)?t:xt(t)}function F(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=xt(e),i=r===e.ownerDocument?.body,a=j(r);if(i){let e=St(a);return t.concat(a,a.visualViewport||[],lt(r)?r:[],e&&n?F(e):[])}return t.concat(r,F(r,[],n))}function St(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var Ct={...f},wt={};function I(e,t){let n=f.useRef(wt);return n.current===wt&&(n.current=e(t)),n}var Tt=Ct.useInsertionEffect,Et=Tt&&Tt!==Ct.useLayoutEffect?Tt:e=>e();function Dt(e){let t=I(Ot).current;return t.next=e,Et(t.effect),t.trampoline}function Ot(){let e={next:void 0,callback:kt,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function kt(){}var At=typeof document<`u`?f.useLayoutEffect:()=>{};function jt(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var Mt={};function L(e,t,n,r,i){if(!n&&!r&&!i&&!e)return R(t);let a=R(e);return t&&(a=z(a,t)),n&&(a=z(a,n)),r&&(a=z(a,r)),i&&(a=z(a,i)),a}function Nt(e){if(e.length===0)return Mt;if(e.length===1)return R(e[0]);let t=R(e[0]);for(let n=1;n<e.length;n+=1)t=z(t,e[n]);return t}function R(e){return Lt(e)?{...e(Mt)}:Pt(e)}function z(e,t){return Lt(t)?t(e):Ft(e,t)}function Pt(e){let t={...e};for(let e in t){let n=t[e];It(e,n)&&(t[e]=zt(n))}return t}function Ft(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=jt(e.style,r);break;case`className`:e[n]=Bt(e.className,r);break;default:e[n]=It(n,r)?Rt(e[n],r):r}}return e}function It(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Lt(e){return typeof e==`function`}function Rt(e,t){return t?e?(...n)=>{let r=n[0];if(Vt(r)){let i=r;B(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:zt(t):e}function zt(e){return e&&((...t)=>{let n=t[0];return Vt(n)&&B(n),e(...t)})}function B(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Bt(e,t){return t?e?t+` `+e:t:e}function Vt(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Ht(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var Ut=Ht(`https://base-ui.com/production-error`,`Base UI`),Wt=f.createContext(void 0);function Gt(e=!1){let t=f.useContext(Wt);if(t===void 0&&!e)throw Error(Ut(16));return t}function Kt(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:f.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function V(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(j(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function qt(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=f.useRef(null),s=Gt(!0),c=a??s!==void 0,{props:l}=Kt({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=f.useCallback(()=>{let e=o.current;Jt(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return At(u,[u]),{getButtonProps:f.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return L({onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(B(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Jt(r),s=!i&&Yt(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),V(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),V(r,e)))},onKeyUp(e){t||(B(e),a?.(e),e.target===e.currentTarget&&i&&c&&Jt(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),V(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Dt(e=>{o.current=e,u()})}}function Jt(e){return M(e)&&e.tagName===`BUTTON`}function Yt(e){return M(e)&&e.tagName===`A`&&!!e.href}function Xt(e,t,n,r){let i=I(Qt).current;return $t(i,e,t,n,r)&&tn(i,[e,t,n,r]),i.callback}function Zt(e){let t=I(Qt).current;return en(t,e)&&tn(t,e),t.callback}function Qt(){return{callback:null,cleanup:null,refs:[]}}function $t(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function en(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function tn(e,t){e.refs=t,e.callback=t.every(e=>e==null)?null:n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var nn=19;function rn(e){return nn>=e}function an(e){if(!f.isValidElement(e))return null;let t=e,n=t.props;return(rn(19)?n?.ref:t.ref)??null}function on(){}var sn=Object.freeze([]),H=Object.freeze({});function cn(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e)}else i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function ln(e,t){return typeof e==`function`?e(t):e}function un(e,t){return typeof e==`function`?e(t):e}function dn(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=hn(r));let i=fn(t,n,r);if(n.enabled===!1)return null;let a=n.state??H;return gn(e,r,i,a)}function fn(e,t,n){let{className:r,style:i}=e,{state:a=H,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?ln(r,a):void 0,d=l?un(i,a):void 0,f=l?cn(a,c):H,p=l&&s?pn(s):void 0,m=l?jt(f,p)??{}:H;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Zt([m.ref,an(n),...o]):Xt(m.ref,an(n),o):Xt(null,null)),l?(u!==void 0&&(m.className=Bt(m.className,u)),d!==void 0&&(m.style=jt(m.style,d)),m):H}function pn(e){return Array.isArray(e)?Nt(e):L(void 0,e)}var mn=Symbol.for(`react.lazy`);function hn(e){if(e?.$$typeof!==mn)return e;let t=f.Children.toArray(e)[0];return f.isValidElement(t)?t:e}function gn(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=L(n,t.props);return e.ref=n.ref,f.cloneElement(t,e)}return _n(e,n)}function _n(e,t){return e===`button`?(0,f.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,f.createElement)(`img`,{alt:``,...t,key:t.key}):f.createElement(e,t)}var vn=f.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=qt({disabled:i,focusableWhenDisabled:a,native:o});return dn(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})});function yn(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=yn(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function bn(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=yn(e))&&(r&&(r+=` `),r+=t);return r}var xn=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Sn=bn,Cn=((e,t)=>n=>{if(t?.variants==null)return Sn(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=xn(t)||xn(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Sn(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 motion-safe:active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:text-muted-foreground aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 max-md:min-h-11 max-md:min-w-11`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80 disabled:bg-muted`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/10 dark:hover:bg-input/20`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground disabled:bg-muted`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 disabled:bg-muted focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] max-md:text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function wn({className:e,variant:t=`default`,size:n=`default`,autoFocus:a,changesData:s,disabled:c,...l}){let u=(0,f.useSyncExternalStore)(o,i),d=u===`unreachable`||u===`retrying`,m=s??l.type===`submit`,h=(0,f.useRef)(null);return(0,f.useEffect)(()=>{a&&h.current?.focus()},[]),(0,p.jsx)(vn,{ref:h,"data-slot":`button`,disabled:c||m&&d,className:r(Cn({variant:t,size:n,className:e})),...l})}function Tn(e){return typeof e==`object`&&!!e&&typeof e.kind==`string`&&typeof e.code==`string`&&typeof e.message==`string`}async function U(e,t={}){let n=d();if(n===null)throw Error(`No access token for the Toodo server.`);let r=await l(`/api/rpc/${encodeURIComponent(e)}`,{method:`POST`,headers:{...a(n),"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.status===401)throw c(),Error(`The Toodo server did not accept the access token.`);let i=await r.text();if(r.ok)return i?JSON.parse(i):null;let o=null;try{o=JSON.parse(i)}catch{}throw Tn(o)?o:Error(i||`${r.status} ${r.statusText}`)}var W={appInfo:()=>U(`app_info`),listWorkspaces:()=>K(U(`list_workspaces`)),getWorkspace:e=>K(U(`get_workspace`,{id:e})),createWorkspace:e=>K(U(`create_workspace`,{workspace:e})),updateWorkspace:e=>K(U(`update_workspace`,{workspace:e})),moveWorkspace:(e,t)=>K(U(`move_workspace`,{id:e,location:t})),listWorkspaceBranches:e=>K(U(`list_workspace_branches`,{id:e})),createWorkspaceBaseBranch:(e,t,n)=>K(U(`create_workspace_base_branch`,{id:e,name:t,from:n})),deleteWorkspace:e=>K(U(`delete_workspace`,{id:e})),getMachineSettings:e=>K(U(`get_machine_settings`,{machine:e})),saveMachineSettings:e=>K(U(`save_machine_settings`,{settings:e})),listHerdrMachines:()=>K(U(`list_herdr_machines`)),listSshHosts:()=>K(U(`list_ssh_hosts`)),addSshHost:e=>K(U(`add_ssh_host`,{host:e})),listRemoteDirectories:(e,t)=>K(U(`list_remote_directories`,{machine:e,path:t})),listDirectories:(e,t)=>K(U(`list_directories`,{machine:e,path:t})),listTasks:()=>K(U(`list_tasks`)),listTaskRelations:()=>K(U(`list_task_relations`)),addTaskRelation:(e,t)=>K(U(`add_task_relation`,{taskId:e,relatedId:t})),removeTaskRelation:(e,t)=>K(U(`remove_task_relation`,{taskId:e,relatedId:t})),getTask:e=>K(U(`get_task`,{id:e})),createTask:e=>K(U(`create_task`,{task:e})),updateTask:e=>K(U(`update_task`,{task:e})),pauseTask:e=>K(U(`pause_task`,{id:e})),setCompletionNote:(e,t)=>K(U(`set_completion_note`,{id:e,note:t})),reopenTask:(e,t)=>K(U(`reopen_task`,{id:e,reason:t})),setTaskOutcome:(e,t,n)=>K(U(`set_task_outcome`,{id:e,resolution:t,note:n})),checkCriterion:(e,t,n,r)=>K(U(`check_criterion`,{taskId:e,criterionId:t,met:n,evidence:r})),deleteTask:(e,t)=>K(U(`delete_task`,{id:e,force:t})),addDependency:(e,t,n)=>K(U(`add_dependency`,{taskId:e,dependsOn:t,confirmPause:n})),removeDependency:(e,t)=>K(U(`remove_dependency`,{taskId:e,dependsOn:t})),listCommitRecords:e=>K(U(`list_commit_records`,{taskId:e})),listTaskActivity:e=>K(U(`list_task_activity`,{taskId:e})),herdrStatus:()=>K(U(`herdr_status`)),startTask:e=>K(U(`start_task`,{id:e})),ensureTaskWorkspace:e=>K(U(`ensure_task_workspace`,{id:e})),openTaskInHerdr:e=>K(U(`open_task_in_herdr`,{id:e})),focusAgentPane:e=>K(U(`focus_agent_pane`,{id:e})),restoreTaskWorktree:e=>K(U(`restore_task_worktree`,{id:e})),closeTaskWorkspace:e=>K(U(`close_task_workspace`,{id:e})),startPlainRun:(e,t,n,r)=>K(U(`start_plain_run`,{taskId:e,adapter:t,prompt:n,mcp:r})),listTaskRuns:e=>K(U(`list_task_runs`,{taskId:e})),getRunLog:(e,t)=>K(U(`get_run_log`,{runId:e,tailBytes:t})),stopRun:e=>K(U(`stop_run`,{runId:e})),reconcileRun:e=>K(U(`reconcile_run`,{runId:e})),runnerHealth:()=>K(U(`runner_health`)),refreshCommitRecords:e=>K(U(`refresh_commit_records`,{taskId:e})),openPullRequest:e=>K(U(`open_pull_request`,{id:e})),completeTask:e=>K(U(`complete_task`,{id:e})),concludeTask:(e,t)=>K(U(`conclude_task`,{id:e,note:t})),completeTaskMergedWith:(e,t,n)=>K(U(`complete_task_merged_with`,{id:e,mergedWithTask:t,pullRequestUrl:n})),branchFreshness:e=>K(U(`branch_freshness`,{id:e})),listPullRequestStatuses:()=>U(`list_pull_request_statuses`),linkIssue:(e,t)=>K(U(`link_issue`,{id:e,number:t})),createIssue:e=>K(U(`create_issue`,{id:e})),listAgentStatuses:()=>U(`list_agent_statuses`),mcpServerInfo:()=>U(`mcp_server_info`),listMcpTunnels:()=>U(`list_mcp_tunnels`),listConnectedApps:()=>K(U(`list_connected_apps`)),revokeConnectedApp:e=>K(U(`revoke_connected_app`,{grantId:e})),reviewPeriod:(e,t)=>K(U(`review_period`,{start:e,end:t})),getBackupSettings:()=>U(`get_backup_settings`),saveBackupSettings:e=>K(U(`save_backup_settings`,{settings:e})),listBackups:()=>K(U(`list_backups`)),restoreBackup:e=>K(U(`restore_backup`,{name:e}))},G={tasksChanged:q(`tasks-changed`),workspacesChanged:q(`workspaces-changed`),agentStatusesChanged:q(`agent-statuses-changed`),pullRequestStatusesChanged:q(`pull-request-statuses-changed`)};async function K(e){try{return{status:`ok`,data:await e}}catch(e){if(e instanceof Error)throw e;return{status:`error`,error:e}}}function q(e){return{listen:t=>s(e,t)}}function En(e){switch(e.code){case`unknownCommand`:case`invalidArguments`:return`This page is out of date with the Toodo server. Reload the page, then try again.`;case`commandPanicked`:return`Something went wrong on the Toodo server. Try again; if it keeps failing, look for "a command panicked" in the toodo-server log.`;case`storageFailed`:return`The Toodo server could not use its database (${e.message}). Try again; if it keeps failing, check the toodo-server log.`;default:return e.message}}function Dn(e,t){return/filename="([^"]+)"/.exec(e.headers.get(`Content-Disposition`)??``)?.[1]??t}function On(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}async function kn(){let e=await u(`/api/backups/export`),t=Dn(e,`toodo-backup.sqlite3`);return On(t,await e.blob()),t}async function An(e){return On(e,await(await u(`/api/backups/${encodeURIComponent(e)}`)).blob()),e}async function jn(e){return await(await u(`/api/backups/restore`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e})).json()}var Mn=`toodo-install-dismissed`;function Nn(){let{userAgent:e,maxTouchPoints:t}=navigator;return/iPhone|iPad|iPod/.test(e)||e.includes(`Macintosh`)&&t>1}function Pn(){return matchMedia(`(display-mode: standalone)`).matches||`standalone`in navigator&&navigator.standalone===!0}var J=null,Fn=!1,In=new Set;function Y(){In.forEach(e=>e())}function Ln(e){return In.add(e),()=>In.delete(e)}function Rn(){return Fn||Pn()||localStorage.getItem(Mn)!==null?`none`:J===null?Nn()?`home-screen`:`none`:`prompt`}function zn(){localStorage.setItem(Mn,`1`),Y()}async function Bn(){let e=J;if(e===null)return;J=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`dismissed`?zn():Y()}function Vn(){addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),J=e,Y()}),addEventListener(`appinstalled`,()=>{J=null,Fn=!0,Y()})}function Hn(){return`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window?`supported`:Nn()&&!Pn()?`needs-install`:`unsupported`}var X=null,Un={agent:[`Agent needs input`,`Agent finished`],pullRequests:[`CI failed`,`CI passed`,`Changes requested`,`Pull request approved`],completion:[`Task awaiting completion`]};function Wn(e){return X!==null&&Object.keys(Un).some(t=>X?.[t]===!0&&Un[t].includes(e))}function Gn(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return Uint8Array.from(atob(n),e=>e.charCodeAt(0))}function Kn(e,t){let n=e.options.applicationServerKey;return n===null||n.byteLength===t.length&&new Uint8Array(n).every((e,n)=>e===t[n])}function qn(){return navigator.serviceWorker.getRegistration()}async function Jn(e){let t=await(await qn())?.pushManager.getSubscription()??null;return t===null||Kn(t,e)?t:(await t.unsubscribe(),null)}async function Yn(e){return await(await u(`/api/push/subscription`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.toJSON())})).json()}async function Xn(){let e=await(await u(`/api/push`)).json(),t=await Jn(Gn(e.publicKey)),n=t===null?null:t.endpoint===e.subscription?.endpoint?e.subscription:await Yn(t);return X=n?.settings??null,{publicKey:e.publicKey,permission:Notification.permission,subscription:n}}async function Zn(e,t){if(await e!==`granted`)throw Error(`Notifications were not allowed.`);if(await qn()===void 0)throw Error(`Notifications need the service worker, which only the built app installs.`);let{pushManager:n}=await navigator.serviceWorker.ready,r=Gn(t),i=await Jn(r)??await n.subscribe({userVisibleOnly:!0,applicationServerKey:r});try{let e=await Yn(i);return X=e.settings,e}catch(e){throw await i.unsubscribe(),e}}async function Qn(){await(await(await qn())?.pushManager.getSubscription())?.unsubscribe(),X=null,await u(`/api/push/subscription`,{method:`DELETE`})}async function $n(e){let t=await(await u(`/api/push/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();return X=t.settings,t}async function er(){await u(`/api/push/test`,{method:`POST`})}var tr=`toodo-open-task`;function nr(e){if(!(`serviceWorker`in navigator))return()=>{};let t=navigator.serviceWorker,n=({data:t})=>{typeof t==`object`&&t&&`type`in t&&t.type===tr&&`taskId`in t&&typeof t.taskId==`number`&&e(t.taskId)};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}async function rr(){return`Notification`in window&&Notification.permission===`granted`}async function ir(){return`Notification`in window?Notification.requestPermission():`denied`}function ar(e){Wn(e.title)||new Notification(e.title,{body:e.body})}var or={planned:`Planned`,in_progress:`In progress`,in_review:`Awaiting completion`,done:`Done`};function sr(e){return e.status===`done`&&e.resolution===`completed`?`Completed`:e.status===`done`&&e.resolution===`not_adopted`?`Not adopted`:or[e.status]}function cr(e,t){switch(t.status){case`in_progress`:return`Task started`;case`in_review`:return`Task awaiting completion`;case`done`:return t.resolution===`not_adopted`?`Task concluded without merging`:`Task done`;case`planned`:return e===`in_progress`?`Task paused`:`Task status changed`}}function lr(e,t){let n=new Map(e.map(e=>[e.id,e.status])),r=new Map(t.map(e=>[e.id,e]));return t.flatMap(e=>{let t=n.get(e.id);if(t===void 0||t===e.status)return[];let i=e.dependsOn.some(e=>r.get(e)?.status!==`done`);return t===`in_progress`&&e.status===`planned`&&i&&e.herdrWorkspaceId!==null?[{title:`Task paused by a new prerequisite`,body:`#${e.id} ${e.title}: close its herdr workspace?`}]:[{title:cr(t,e),body:`#${e.id} ${e.title}: ${or[t]} -> ${sr(e)}`}]})}function ur(e,t,n){let r=new Map(e.map(e=>[e.taskId,e.status]));return t.flatMap(({taskId:e,status:t})=>{let i=r.get(e);if(i===void 0||i===t||t!==`blocked`)return[];let a=n.find(t=>t.id===e);return[{title:`Agent needs input`,body:a?`#${e} ${a.title}`:`#${e}`}]})}function dr(e,t,n){let r=new Map(e.map(e=>[e.taskId,e]));return t.flatMap(({taskId:e,checks:t,review:i})=>{let a=r.get(e);if(a===void 0)return[];let o=n.find(t=>t.id===e),s=o?`#${e} ${o.title}`:`#${e}`,c=[];return t===`failing`&&a.checks!==`failing`&&c.push({title:`CI failed`,body:s}),i===`changes_requested`&&a.review!==`changes_requested`&&c.push({title:`Changes requested`,body:s}),c})}async function fr(e){if(e.length!==0&&(await rr()||await ir()===`granted`))for(let t of e)ar(t)}var pr=class extends Error{kind;code;constructor(e){super(En(e)),this.name=`CommandFailure`,this.kind=e.kind,this.code=e.code}};async function Z(e){let t=await e;if(t.status===`error`)throw new pr(t.error);return t.data}var Q={workspaces:[`workspaces`],tasks:[`task-list`],taskRelations:[`tasks`,`relations`],herdrStatus:[`herdr-status`],runnerHealth:[`runner-health`],agentStatuses:[`agent-statuses`],pullRequestStatuses:[`pull-request-statuses`],machineSettings:e=>[`machine-settings`,e],branches:e=>[`branches`,e],commitRecords:e=>[`tasks`,e,`commit-records`],taskActivity:e=>[`tasks`,e,`activity`],branchFreshness:e=>[`tasks`,e,`branch-freshness`],taskRuns:e=>[`tasks`,e,`runs`],runLog:e=>[`run-log`,e],herdrMachines:[`herdr-machines`],backups:[`backups`],backupSettings:[`backup-settings`],mcpServerInfo:[`mcp-server-info`],mcpTunnels:[`mcp-tunnels`],review:(e,t)=>[`review`,e,t],directories:(e,t)=>[`directories`,e,t]};function mr(){return D({queryKey:Q.mcpServerInfo,queryFn:()=>W.mcpServerInfo(),refetchInterval:5e3})}function hr(){return D({queryKey:Q.mcpTunnels,queryFn:()=>W.listMcpTunnels(),refetchInterval:3e3})}function gr(){return D({queryKey:Q.backups,queryFn:()=>Z(W.listBackups())})}function _r(){return D({queryKey:Q.backupSettings,queryFn:()=>W.getBackupSettings()})}function vr(){let e=h();return O({mutationFn:e=>Z(W.saveBackupSettings(e)),onSuccess:t=>(e.setQueryData(Q.backupSettings,t),e.invalidateQueries({queryKey:Q.backups}))})}function yr(){let e=h();return O({mutationFn:e=>Z(W.restoreBackup(e)),onSuccess:()=>e.invalidateQueries()})}function br(){return O({mutationFn:kn})}function xr(){return O({mutationFn:An})}function Sr(){let e=h();return O({mutationFn:jn,onSuccess:()=>e.invalidateQueries()})}function Cr(){return D({queryKey:Q.herdrMachines,queryFn:()=>Z(W.listHerdrMachines())})}function wr(e,t){return D({queryKey:Q.directories(e,t),queryFn:()=>Z(W.listDirectories(e,t)),enabled:t!==null,retry:!1})}function Tr(e){return D({queryKey:[`home-directory`,e],queryFn:async()=>(await Z(W.listDirectories(e,null))).path,staleTime:1/0,retry:!1})}function Er(e){return e.kind===`local`?{kind:`local`}:{kind:`ssh`,label:e.machine}}function Dr(){return D({queryKey:Q.workspaces,queryFn:()=>Z(W.listWorkspaces())})}function Or(){let e=h();return O({mutationFn:e=>Z(W.createWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:Q.workspaces})})}function kr(){let e=h();return O({mutationFn:e=>Z(W.updateWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:Q.workspaces,exact:!0})})}function Ar(){let e=h();return O({mutationFn:({id:e,location:t})=>Z(W.moveWorkspace(e,t)),onSuccess:()=>{e.invalidateQueries()}})}function jr(e,t){return D({queryKey:Q.branches(e),queryFn:()=>Z(W.listWorkspaceBranches(e)),enabled:t,staleTime:0})}function Mr(e,t){return D({queryKey:Q.branchFreshness(e),queryFn:()=>Z(W.branchFreshness(e)),enabled:t,staleTime:6e4,refetchInterval:3e5,retry:!1})}function Nr(){let e=h();return O({mutationFn:({workspace:e,name:t,from:n})=>Z(W.createWorkspaceBaseBranch(e,t,n)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:Q.workspaces,exact:!0}),e.invalidateQueries({queryKey:Q.branches(t.id)})])})}function Pr(){let e=h();return O({mutationFn:e=>Z(W.deleteWorkspace(e)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:Q.workspaces,exact:!0})])})}function Fr(){return D({queryKey:Q.tasks,queryFn:()=>Z(W.listTasks())})}function Ir(e,t){return D({queryKey:Q.review(e,t),queryFn:()=>Z(W.reviewPeriod(e,t))})}function Lr(){return D({queryKey:Q.herdrStatus,queryFn:()=>Z(W.herdrStatus())})}function Rr(){return D({queryKey:Q.runnerHealth,queryFn:()=>Z(W.runnerHealth()),refetchInterval:6e4})}function zr(){return D({queryKey:Q.agentStatuses,queryFn:()=>W.listAgentStatuses()})}function Br(){return D({queryKey:Q.pullRequestStatuses,queryFn:()=>W.listPullRequestStatuses()})}function Vr(){let e=h();(0,f.useEffect)(()=>{function t(t,n,r){let i=e.getQueryData(t);e.setQueryData(t,n),!(i===void 0||document.hasFocus())&&fr(r(i,n,e.getQueryData(Q.tasks)??[])).catch(e=>console.error(`toodo: failed to show notifications`,e))}let n=[G.tasksChanged.listen(async()=>{let t=e.getQueryData(Q.tasks);await Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:[`tasks`]})]),!(t===void 0||document.hasFocus())&&fr(lr(t,e.getQueryData(Q.tasks)??[])).catch(e=>console.error(`toodo: failed to show status notifications`,e))}),G.workspacesChanged.listen(()=>e.invalidateQueries({queryKey:Q.workspaces,exact:!0})),G.agentStatusesChanged.listen(({payload:e})=>t(Q.agentStatuses,e.statuses,ur)),G.pullRequestStatusesChanged.listen(({payload:e})=>t(Q.pullRequestStatuses,e.statuses,dr))];return()=>{for(let e of n)e.then(e=>e())}},[e])}function Hr(e){return D({queryKey:Q.machineSettings(e),queryFn:()=>Z(W.getMachineSettings(e))})}function Ur(){let e=h();return O({mutationFn:e=>Z(W.saveMachineSettings(e)),onSuccess:t=>e.setQueryData(Q.machineSettings(t.machine),t)})}function Wr(){let e=h();return O({mutationFn:e=>Z(W.startTask(e)),onSuccess:()=>e.invalidateQueries({queryKey:Q.tasks})})}function Gr(){return O({mutationFn:e=>Z(W.openTaskInHerdr(e))})}function Kr(){return O({mutationFn:e=>Z(W.focusAgentPane(e))})}function qr(e,t){return D({queryKey:Q.commitRecords(e),queryFn:()=>Z(W.listCommitRecords(e)),enabled:t})}function Jr(e,t){return D({queryKey:Q.taskActivity(e),queryFn:()=>Z(W.listTaskActivity(e)),enabled:t})}var Yr=3e3;function Xr(e){return e===`reserved`||e===`running`}function Zr(e){return D({queryKey:Q.taskRuns(e),queryFn:()=>Z(W.listTaskRuns(e)),refetchInterval:e=>e.state.data?.some(e=>Xr(e.state))?Yr:!1})}function Qr(e){return D({queryKey:Q.runLog(e),queryFn:()=>Z(W.getRunLog(e,null)),enabled:e!==null,refetchInterval:e=>e.state.data&&Xr(e.state.data.run.state)?Yr:!1})}function $r(){let e=h();return O({mutationFn:({taskId:e,adapter:t,mcp:n})=>Z(W.startPlainRun(e,t,null,n)),onSettled:(t,n,{taskId:r})=>e.invalidateQueries({queryKey:Q.taskRuns(r)})})}function ei(){let e=h();return O({mutationFn:e=>Z(W.stopRun(e.id)),onSettled:(t,n,r)=>Promise.all([e.invalidateQueries({queryKey:Q.taskRuns(r.taskId)}),e.invalidateQueries({queryKey:Q.runLog(r.id)})])})}function ti(){let e=h();return O({mutationFn:e=>Z(W.reconcileRun(e.id)),onSettled:(t,n,r)=>Promise.all([e.invalidateQueries({queryKey:Q.taskRuns(r.taskId)}),e.invalidateQueries({queryKey:Q.runLog(r.id)})])})}function ni(){let e=h();return O({mutationFn:e=>Z(W.refreshCommitRecords(e)),onSuccess:(t,n)=>e.setQueryData(Q.commitRecords(n),t)})}function ri(){let e=h();return O({mutationFn:e=>Z(W.openPullRequest(e)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:Q.commitRecords(t.id)})])})}function ii(){let e=h();return O({mutationFn:e=>Z(W.completeTask(e)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:Q.commitRecords(t.id)}),e.invalidateQueries({queryKey:Q.taskActivity(t.id)})])})}function ai(){let e=h();return O({mutationFn:({id:e,note:t})=>Z(W.concludeTask(e,t)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:Q.commitRecords(t.id)}),e.invalidateQueries({queryKey:[`review`]})])})}function oi(){let e=h();return O({mutationFn:({id:e,note:t})=>Z(W.setCompletionNote(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function si(){let e=h();return O({mutationFn:({id:e,reason:t})=>Z(W.reopenTask(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function ci(){let e=h();return O({mutationFn:({id:e,resolution:t,note:n})=>Z(W.setTaskOutcome(e,t,n)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function li(){let e=h();return O({mutationFn:({id:e,mergedWithTask:t,pullRequestUrl:n})=>Z(W.completeTaskMergedWith(e,t,n)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:Q.tasks}),e.invalidateQueries({queryKey:Q.commitRecords(t.id)}),e.invalidateQueries({queryKey:[`review`]})])})}function ui(){let e=h();return O({mutationFn:e=>Z(W.restoreTaskWorktree(e)),onSuccess:()=>e.invalidateQueries({queryKey:Q.tasks})})}function di(){let e=h();return O({mutationFn:e=>Z(W.updateTask(e)),onSuccess:()=>e.invalidateQueries({queryKey:Q.tasks})})}function $(e){let t=h();return O({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:Q.tasks})})}function fi(){return $(e=>Z(W.pauseTask(e)))}function pi(){return $(e=>Z(W.closeTaskWorkspace(e)))}function mi(){return $(({taskId:e,criterionId:t,met:n,evidence:r})=>Z(W.checkCriterion(e,t,n,r)))}function hi(){return $(({id:e,force:t})=>Z(W.deleteTask(e,t)))}function gi(){return $(({id:e,dependsOn:t,confirmPause:n})=>Z(W.addDependency(e,t,n)))}function _i(){return $(({id:e,dependsOn:t})=>Z(W.removeDependency(e,t)))}function vi(){return D({queryKey:Q.taskRelations,queryFn:()=>Z(W.listTaskRelations())})}function yi(e){let t=h();return O({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:Q.taskRelations})})}function bi(){return yi(({taskId:e,relatedId:t})=>Z(W.addTaskRelation(e,t)))}function xi(){return yi(({taskId:e,relatedId:t})=>Z(W.removeTaskRelation(e,t)))}function Si(){return $(({id:e,number:t})=>Z(W.linkIssue(e,t)))}function Ci(){return $(e=>Z(W.createIssue(e)))}var wi=class extends Error{constructor(e,t,n){super(`Task #${e} was added, but issue #${t} could not be linked: ${n}`),this.name=`IssueLinkFailure`}};function Ti(){let e=h();return O({mutationFn:async({issue:e,...t})=>{let n=await Z(W.createTask(t));if(e===null)return n;try{return await Z(W.linkIssue(n.id,e))}catch(t){throw new wi(n.id,e,t instanceof Error?t.message:String(t))}},onSettled:()=>e.invalidateQueries({queryKey:Q.tasks})})}var Ei={planned:`Blocked`,ready:`Ready`,paused:`Paused`,in_progress:`In progress`,in_review:`Awaiting completion`,done:`Done`,not_adopted:`Not adopted`},Di=`Planned on`,Oi={neutral:`bg-muted text-foreground/70`,info:`bg-sky-100 text-sky-800 dark:bg-sky-950 dark:text-sky-200`,progress:`bg-blue-100 text-blue-800 dark:bg-blue-950 dark:text-blue-200`,review:`bg-violet-100 text-violet-800 dark:bg-violet-950 dark:text-violet-200`,success:`bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200`,attention:`bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-200`,danger:`bg-rose-100 text-rose-800 dark:bg-rose-950 dark:text-rose-200`},ki={neutral:`text-muted-foreground`,info:`text-sky-700 dark:text-sky-300`,progress:`text-blue-700 dark:text-blue-300`,review:`text-violet-700 dark:text-violet-300`,success:`text-emerald-700 dark:text-emerald-300`,attention:`text-amber-700 dark:text-amber-300`,danger:`text-rose-700 dark:text-rose-300`},Ai={neutral:`border-border text-muted-foreground`,info:`border-sky-300 text-sky-700 dark:border-sky-800 dark:text-sky-300`,progress:`border-blue-300 text-blue-700 dark:border-blue-800 dark:text-blue-300`,review:`border-violet-300 text-violet-700 dark:border-violet-800 dark:text-violet-300`,success:`border-emerald-300 text-emerald-700 dark:border-emerald-800 dark:text-emerald-300`,attention:`border-amber-300 text-amber-700 dark:border-amber-800 dark:text-amber-300`,danger:`border-rose-300 text-rose-700 dark:border-rose-800 dark:text-rose-300`},ji=`border-input text-foreground/70`,Mi={info:`border border-sky-300 bg-sky-50 text-sky-900 dark:border-sky-800 dark:bg-sky-950 dark:text-sky-100`,attention:`border border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100`,danger:`border border-rose-300 bg-rose-50 text-rose-900 dark:border-rose-800 dark:bg-rose-950 dark:text-rose-100`},Ni={neutral:`bg-neutral-400`,info:`bg-sky-500`,progress:`bg-blue-500`,review:`bg-violet-500`,success:`bg-emerald-500`,attention:`bg-amber-500`,danger:`bg-rose-500`},Pi={neutral:`border-muted-foreground`,info:`border-sky-500`,progress:`border-blue-500`,review:`border-violet-500`,success:`border-emerald-500`,attention:`border-amber-500`,danger:`border-rose-500 dark:border-rose-400`},Fi={done:`border-emerald-500 bg-emerald-100 dark:bg-emerald-950`,ready:`border-amber-500 shadow-none`,blocked:`border-dashed border-muted-foreground shadow-none`,paused:`border-dashed border-muted-foreground bg-muted shadow-none`,behindDue:`border-2 border-rose-500 dark:border-rose-400`},Ii=`border-foreground/70`,Li=`text-foreground`;export{ti as $,Dt as $t,Nr as A,x as An,$n as At,Vr as B,hn as Bt,Mr as C,We as Cn,jr as Ct,ii as D,Se as Dn,Xn as Dt,qr as E,E as En,Zn as Et,Pr as F,S as Fn,Ln as Ft,Hr as G,rn as Gt,Lr as H,sn as Ht,wr as I,b as In,Vn as It,Ar as J,V as Jt,mr as K,Xt as Kt,xr as L,_e as Ln,W as Lt,Ti as M,oe as Mn,zn as Mt,Or as N,ae as Nn,Bn as Nt,li as O,T as On,nr as Ot,hi as P,y as Pn,Rn as Pt,Br as Q,At as Qt,br as R,g as Rn,wn as Rt,gr as S,D as Sn,Sr as St,pi as T,Te as Tn,Qn as Tt,Tr as U,H as Ut,Cr as V,dn as Vt,Si as W,on as Wt,Gr as X,Ut as Xt,ri as Y,Gt as Yt,fi as Z,L as Zt,Z as _,ct as _n,vi as _t,Ei as a,St as an,ui as at,zr as b,_t as bn,di as bt,Pi as c,F as cn,Rr as ct,ki as d,ht as dn,oi as dt,I as en,ni as et,ji as f,st as fn,ci as ft,Q as g,lt as gn,Jr as gt,Er as h,ot as hn,ei as ht,Di as i,at as in,yr as it,Ci as j,se as jn,er as jt,ai as k,ne as kn,Hn as kt,Ai as l,P as ln,vr as lt,wi as m,vt as mn,Wr as mt,Li as n,yt as nn,xi as nt,Oi as o,A as on,Ir as ot,pr as p,M as pn,$r as pt,hr as q,qt,Ii as r,gt as rn,si as rt,Ni as s,bt as sn,Qr as st,Fi as t,Ct as tn,_i as tt,Mi as u,j as un,Ur as ut,gi as v,ut as vn,Zr as vt,mi as w,Pe as wn,Dr as wt,_r as x,O as xn,kr as xt,bi as y,dt as yn,Fr as yt,Kr as z,h as zn,Cn as zt};
@@ -1,4 +0,0 @@
1
- import{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{C as a,E as o,Rt as s,_t as c,d as l,gt as u,nt as d,o as f,w as p,y as m}from"./status-styles-DDSPyzwv.js";import{f as h}from"./workspace-list-DRGN9qgP.js";import{A as g,At as _,Ct as v,Dt as y,Et as b,G as x,H as S,J as ee,K as C,St as w,Tt as T,X as E,Y as D,c as O,gt as te,jt as k,l as ne,o as re,q as A,rt as j,s as M,tt as N,u as P,xt as F}from"./index-HFVp-zc_.js";import{t as I}from"./opener-DWhHPoCL.js";import{t as L}from"./details-sheet-Fivv1fWU.js";var R={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};R.node;var z=t(R),B={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};B.node;var V=t(B),H=r(e(),1),U=n();function W({onClose:e,children:t}){let n=(0,H.useRef)(null),[r,i]=(0,H.useState)(!1);function a(){n.current?.querySelector(`form[data-dirty]`)?i(!0):e()}return(0,H.useEffect)(()=>{function e(e){e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role=menu]`)||(r?i(!1):e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select`)||a())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,U.jsx)(L,{ref:n,width:`min(480px, max(360px, 40vw), calc(100vw - 32px))`,onClose:a,banner:r&&(0,U.jsxs)(`div`,{role:`group`,"aria-label":`Unsaved changes`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted px-4 py-2 text-xs`,children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Discard your unsaved changes?`}),(0,U.jsx)(s,{size:`xs`,variant:`outline`,autoFocus:!0,onClick:()=>i(!1),children:`Keep editing`}),(0,U.jsx)(s,{size:`xs`,variant:`destructive`,onClick:e,children:`Discard changes`})]}),children:t})}function G({task:e,detailed:t}){let n=v(e.milestones);return n.length===0?null:t?(0,U.jsx)(x,{label:`Timeline`,children:(0,U.jsx)(`dl`,{"aria-label":`Timeline of #${e.id}`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:n.map(({label:e,at:t})=>(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,U.jsx)(`dd`,{children:(0,U.jsx)(S,{at:t})})]},e))})}):(0,U.jsx)(`p`,{"aria-label":`Timeline of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:n.map(({label:e,at:t})=>(0,U.jsx)(S,{at:t,prefix:`${e} `},e))})}function ie({taskId:e}){let t=a(e,!0),n=`Base freshness of #${e}`,r=(0,U.jsxs)(s,{type:`button`,variant:`ghost`,size:`xs`,className:`ml-1.5 h-5 px-1.5 align-middle`,"aria-label":`Recheck base freshness of #${e}`,title:`Check again whether the branch is behind its base`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:[(0,U.jsx)(T,{className:i(`size-3`,t.isFetching&&`animate-spin`)}),`Recheck`]});if(t.error)return(0,U.jsxs)(`p`,{role:`note`,"aria-label":n,className:`text-xs text-muted-foreground`,title:t.error.message,children:[`Could not check whether the branch is behind its base`,r]});let o=t.data,c=o?N(o):null;if(!o||c===null)return null;let u=o.mergeable===`conflicting`;return(0,U.jsxs)(`p`,{role:`note`,"aria-label":n,"data-conflicting":u||void 0,className:i(`text-xs`,u?l.danger:l.attention),title:[o.fetchError&&`Fetching origin failed: ${o.fetchError}`,o.mergeableError].filter(Boolean).join(`
2
- `)||void 0,children:[c,o.fetchError&&` (not up to date: fetching origin failed)`,r]})}function K({task:e,mergedWith:t,through:n,detailed:r}){let i=t.pullRequestUrl;if(i===null){let t=`Shipped with task of #${e.id}`;return r?(0,U.jsx)(x,{label:`Shipped with`,children:(0,U.jsx)(`span`,{"aria-label":t,children:n??`A deleted task`})}):(0,U.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1 text-xs`,children:[(0,U.jsx)(y,{"aria-hidden":!0,className:`size-3 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Shipped with`}),(0,U.jsx)(`span`,{"aria-label":t,children:n??`a deleted task`})]})}let a=`Shipped with pull request of #${e.id}`;return r?(0,U.jsxs)(x,{label:`Shipped with`,children:[(0,U.jsx)(`span`,{"aria-label":a,className:`break-all font-mono select-all`,children:i}),n&&(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Pull request of `,n]})]}):(0,U.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1 text-xs`,children:[(0,U.jsx)(y,{"aria-hidden":!0,className:`size-3 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Shipped with`}),(0,U.jsx)(`span`,{"aria-label":a,className:`truncate select-all font-mono`,children:i}),n&&(0,U.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`of `,n]})]})}function q({task:e,tasks:t,context:n,navigation:r}){let a=c(),o=m(),s=d(),l=(a.data??[]).flatMap(({taskId:t,relatedId:n})=>t===e.id?[n]:n===e.id?[t]:[]).filter(e=>n.byId.has(e)),u=t.filter(t=>t.id!==e.id&&!l.includes(t.id)),f=[...new Set([e.workspaceId,...u.map(e=>e.workspaceId)])].map(e=>({workspaceId:e,tasks:u.filter(t=>t.workspaceId===e)})).filter(e=>e.tasks.length>0),p=E(),g=o.isPending||s.isPending||p,_=o.error??s.error;if(l.length===0&&f.length===0)return null;let v=f.length>0&&(0,U.jsxs)(`select`,{"aria-label":`Add related task to #${e.id}`,className:i(`h-6 rounded-md border border-input bg-background px-1.5 text-xs outline-none max-md:h-11 max-md:px-2.5 max-md:text-sm focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50`,`max-w-48`),value:``,disabled:g,onChange:t=>{t.target.value&&o.mutate({taskId:e.id,relatedId:Number(t.target.value)})},children:[(0,U.jsx)(`option`,{value:``,children:`Add related task...`}),f.map(e=>(0,U.jsx)(`optgroup`,{label:n.workspaceName(e.workspaceId),children:e.tasks.map(e=>(0,U.jsxs)(`option`,{value:e.id,children:[`#`,e.id,` `,e.title]},e.id))},e.workspaceId))]}),y=_&&(0,U.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:_.message});return l.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs`,children:[v,y]}):(0,U.jsxs)(x,{label:`Related`,children:[(0,U.jsxs)(`ul`,{"aria-label":`Related tasks of #${e.id}`,className:`flex flex-wrap items-center gap-1 max-md:gap-2`,children:[l.map(t=>{let i=n.byId.get(t),a=D(t,e.workspaceId,n);return(0,U.jsxs)(`li`,{className:`inline-flex h-6 min-w-0 items-center rounded-md border max-md:h-11 max-md:gap-2 max-md:border-0`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-label":`Open related task ${a}`,title:i?.title,className:`h-full min-w-0 max-w-56 truncate rounded-l-md px-1.5 tabular-nums hover:bg-muted max-md:rounded-md max-md:border max-md:px-3 disabled:cursor-default disabled:hover:bg-transparent`,disabled:r===void 0||!r.canOpen(t),onClick:()=>r?.open(t),children:[a,` `,i?.title]}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove related task #${t} from #${e.id}`,title:`Remove related task`,className:`flex h-full items-center justify-center rounded-r-md p-1 text-muted-foreground hover:bg-muted max-md:w-11 max-md:rounded-md max-md:border hover:text-foreground disabled:opacity-50`,disabled:g,onClick:()=>s.mutate({taskId:e.id,relatedId:t}),children:(0,U.jsx)(h,{className:`size-3`})})]},t)}),v]}),y]})}function J({task:e,detailed:t}){let n=e.status!==`planned`||j(e),r=o(e.id,n);if(r.isError)return(0,U.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Failed to load commits: `,r.error.message]});if(!r.data||r.data.length===0)return null;let a=(0,U.jsx)(`ul`,{"aria-label":`Commits of #${e.id}`,className:i(`flex flex-col gap-0.5`,!t&&`mt-1`),children:r.data.map(e=>(0,U.jsxs)(`li`,{className:`flex gap-2 text-xs`,title:e.author,children:[(0,U.jsx)(`code`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}),(0,U.jsx)(`span`,{className:t?`min-w-0 break-words-keep`:`truncate`,children:e.message.split(`
3
- `,1)[0]})]},e.sha))});return t?(0,U.jsx)(x,{label:`Commits (${r.data.length})`,children:a}):a}function Y({task:e}){return(0,U.jsxs)(U.Fragment,{children:[(e.estimate!==null||e.dueDate!==null)&&(0,U.jsxs)(`p`,{"aria-label":`Plan of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:[e.estimate!==null&&(0,U.jsxs)(`span`,{children:[`Estimate `,te(e.estimate)]}),e.dueDate!==null&&(0,U.jsx)(C,{task:e})]}),(0,U.jsx)(ee,{task:e})]})}var ae={commit:{label:`Commit`,icon:V,tone:`neutral`},pr_opened:{label:`Pull request opened`,icon:b,tone:`review`},checks_passed:{label:`CI passed`,icon:k,tone:`success`},checks_failed:{label:`CI failed`,icon:z,tone:`danger`},pr_merged:{label:`Merged`,icon:y,tone:`success`}};function oe({url:e}){let t=g(e),n=t=>{t.preventDefault(),I(e).catch(t=>console.error(`Failed to open ${e}`,t))};return(0,U.jsx)(`a`,{href:e,title:e,"aria-label":t?`Pull request #${t}`:`Pull request`,onClick:n,onAuxClick:n,className:`shrink-0 text-primary underline underline-offset-2 hover:no-underline`,children:t?`#${t}`:`PR`})}function se({task:e,capabilities:t}){let n=t.git&&t.merge,r=u(e.id,n&&(e.status!==`planned`||j(e)));return n?r.isError?(0,U.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Failed to load git activity: `,r.error.message]}):!r.data||r.data.length===0?null:(0,U.jsx)(x,{label:`Git activity`,children:(0,U.jsx)(`ol`,{"aria-label":`Git activity of #${e.id}`,className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5 max-md:gap-y-1.5`,children:r.data.map(({kind:e,externalRef:t,title:n,author:r,occurredAt:a})=>{let{label:o,icon:s,tone:c}=ae[e];return(0,U.jsxs)(`li`,{className:`col-span-full grid grid-cols-subgrid items-baseline`,title:r??void 0,children:[(0,U.jsx)(S,{className:`text-muted-foreground`,at:a}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2 max-md:flex-wrap max-md:gap-y-0`,children:[(0,U.jsxs)(`span`,{className:i(`inline-flex shrink-0 items-baseline gap-1`,l[c]),children:[(0,U.jsx)(s,{"aria-hidden":!0,className:`size-3 self-center`}),o]}),e===`pr_opened`||e===`pr_merged`?(0,U.jsx)(oe,{url:t}):(0,U.jsx)(`code`,{className:`shrink-0 text-muted-foreground`,children:t.slice(0,7)}),(0,U.jsx)(`span`,{className:`min-w-0 break-words-keep max-md:basis-full`,children:n})]})]},`${e}:${t}`)})})}):null}var ce={progress:`Progress`,blocker:`Blocker`};function X({kind:e}){return(0,U.jsx)(`span`,{"data-note-kind":e,className:i(`shrink-0 rounded-md px-1.5 font-medium`,e===`blocker`?f.attention:f.neutral),children:ce[e]})}function Z({task:e,detailed:t}){let n=e.notes;if(n.length===0)return null;if(!t){let t=n[n.length-1];return(0,U.jsxs)(`p`,{"aria-label":`Latest note of #${e.id}`,className:`flex min-w-0 items-center gap-1.5 text-xs`,title:F(t.at),children:[(0,U.jsx)(X,{kind:t.kind}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:P(t.body)}),n.length>1&&(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`+${n.length-1} more`})]})}return(0,U.jsx)(x,{label:`Notes (${n.length})`,children:(0,U.jsx)(`ol`,{"aria-label":`Notes of #${e.id}`,className:`flex flex-col gap-2`,children:n.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(X,{kind:e.kind}),(0,U.jsx)(S,{className:`text-muted-foreground`,at:e.at})]}),(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`p`,{className:`whitespace-pre-line break-words-keep`,children:e.body}),children:(0,U.jsx)(A,{source:e.body})})]},t))})})}var le={pending:`Pending`,met:`Met`,failed:`Failed`},ue={pending:l.neutral,met:l.success,failed:l.danger},Q={user:`you`,agent:`an agent`,toodo:`Toodo`};function $({state:e}){let t=e===`met`?k:e===`failed`?z:_;return(0,U.jsx)(`span`,{role:`img`,"aria-label":le[e],className:i(`flex size-4 shrink-0 items-center justify-center`,ue[e]),children:(0,U.jsx)(t,{"aria-hidden":!0,className:`size-3.5`})})}function de(e){if(e.checkedBy===null)return null;let t=e.checkedAt===null?``:` ${w(e.checkedAt)}`;return`Checked by ${Q[e.checkedBy]}${t}`}function fe({task:e,detailed:t}){let n=e.criteria;if(n.length===0)return null;let r=(0,U.jsx)(`ul`,{"aria-label":`Criteria of #${e.id}`,className:`flex flex-col gap-0.5`,children:n.map(n=>(0,U.jsx)(pe,{task:e,criterion:n,detailed:t},n.id))});if(!t)return r;let i=n.filter(e=>e.state===`met`).length;return(0,U.jsx)(x,{label:`Criteria (${i} of ${n.length} met)`,children:r})}function pe({task:e,criterion:t,detailed:n}){let r=p(),a=E(),[o,c]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),f=t.kind===`manual`&&e.status!==`done`,m=de(t),h=M(t.kind)?t.target:null;function g(){c(!1),d(``)}let _=ne(u.trim()!==``,g,r.isPending);function v(n){o?g():n?(r.reset(),c(!0)):r.mutate({taskId:e.id,criterionId:t.id,met:!1,evidence:null})}function y(n){n.preventDefault(),r.mutate({taskId:e.id,criterionId:t.id,met:!0,evidence:u.trim()||null},{onSuccess:g})}return(0,U.jsxs)(`li`,{"data-criterion-state":t.state,className:`flex min-w-0 flex-col gap-0.5 text-xs`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,title:n?void 0:[m,t.evidence,h].filter(Boolean).join(`
4
- `)||void 0,children:[f?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`label`,{className:`flex size-4 shrink-0 items-center justify-center max-md:-mx-3.5 max-md:size-11`,children:(0,U.jsx)(`input`,{type:`checkbox`,"aria-label":`Check criterion ${t.id} of #${e.id}`,checked:t.state===`met`||o,disabled:r.isPending||a,onChange:e=>v(e.target.checked)})}),t.state===`failed`&&(0,U.jsx)($,{state:`failed`})]}):(0,U.jsx)($,{state:t.state}),(0,U.jsx)(`span`,{className:i(`min-w-0`,n?`break-words-keep`:`truncate`,t.state===`failed`&&l.danger),children:t.text}),t.kind!==`manual`&&(0,U.jsx)(`span`,{className:`shrink-0 rounded-md bg-muted px-1.5 text-muted-foreground`,children:re[t.kind]}),!n&&t.evidence&&(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.evidence})]}),n&&h&&(0,U.jsx)(`code`,{className:`ml-5.5 break-all text-muted-foreground`,children:h}),n&&(t.evidence||m)&&(0,U.jsxs)(`p`,{className:`ml-5.5 whitespace-pre-line break-words-keep text-muted-foreground`,children:[t.evidence,t.evidence&&m&&` · `,t.checkedBy!==null&&(0,U.jsxs)(U.Fragment,{children:[`Checked by `,Q[t.checkedBy],t.checkedAt!==null&&(0,U.jsxs)(U.Fragment,{children:[` `,(0,U.jsx)(S,{at:t.checkedAt})]})]})]}),o&&(0,U.jsxs)(`form`,{onSubmit:y,className:`ml-5.5 flex flex-wrap items-center gap-1`,onKeyDown:_.onKeyDown,children:[(0,U.jsx)(`input`,{className:i(`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`h-7 flex-1 basis-48`),"aria-label":`Evidence for criterion ${t.id}`,placeholder:`Evidence (optional), e.g. a link or what you checked`,value:u,onChange:e=>d(e.target.value),autoFocus:!0}),_.asking?(0,U.jsx)(O,{label:`Discard evidence for criterion ${t.id}`,question:`Discard the evidence?`,onKeep:_.keep,onDiscard:_.discard}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(s,{type:`submit`,size:`xs`,disabled:r.isPending,children:r.isPending?`Saving...`:`Save`}),(0,U.jsx)(s,{type:`button`,size:`xs`,variant:`ghost`,onClick:_.request,children:`Cancel`})]})]}),r.isError&&(0,U.jsx)(`p`,{role:`alert`,className:`ml-5.5 text-destructive`,children:r.error.message})]})}export{ie as BranchFreshnessNote,J as CommitList,q as RelatedTasks,K as ShippedWith,se as TaskActivity,fe as TaskCriteria,W as TaskDetailsSheet,Z as TaskNotes,Y as TaskPlan,G as TaskTimeline};