Sign In

@illodev/workfile

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@illodev/workfile - npm Package Compare versions

Comparing version
0.5.4
to
0.6.0
+1
dist/ui/static/Boards-BBnEa8Dy.js
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{bt as r,ct as i,wt as a,xt as o}from"./ui-primitives-Beqd9I2k.js";import{c as s,i as c,o as l,s as u,t as d}from"./theme-CNCrPl--.js";import{$ as f,M as p,N as m,P as h,R as g,Z as _,at as v,it as y,j as b,k as x,n as S,ot as C,r as w,rt as T,t as E,tt as D,z as O}from"./index-Dpy209ef.js";var k=e(t(),1),A=n(),j=[];function M(e,t){let[n,r]=(0,k.useState)(t);(0,k.useEffect)(()=>{r(t)},[e.length,t]);let i=(0,k.useCallback)(()=>r(n=>Math.min(n+t,e.length)),[e.length,t]);return[n>=e.length?e:e.slice(0,n),n<e.length,i]}function N({onVisible:e,remaining:t}){let n=(0,k.useRef)(null);return(0,k.useEffect)(()=>{let t=n.current;if(!t)return;let r=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&e()},{rootMargin:`600px 0px`});return r.observe(t),()=>r.disconnect()},[e,t]),(0,A.jsxs)(`span`,{ref:n,className:`px-0.5 py-1 font-mono text-[11px] text-muted-foreground`,children:[`+`,t,` more`]})}function P({task:e,epicId:t,onOpen:n,onDragStart:r,onCarry:i,carrying:a}){let o=e.claimed_at?Date.parse(e.claimed_at.includes(`T`)?e.claimed_at:`${e.claimed_at}T00:00:00`):NaN,c=Number.isNaN(o)?null:Math.max(0,Math.floor((Date.now()-o)/864e5)),u=[t&&t!==e.id?`epic ${t}`:``,e.effort?`effort ${e.effort}`:``,e.claimed_by?`claimed by ${e.claimed_by}${c==null?``:` · ${c}d`}`:``].filter(Boolean);return(0,A.jsxs)(`article`,{className:s(`flex cursor-pointer flex-col gap-1.5 rounded-lg border bg-background px-3 py-2.5 shadow-xs outline-none transition-[color,border-color,box-shadow] hover:border-ring focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,a&&`border-ring ring-2 ring-ring`),tabIndex:0,draggable:!!r,"aria-grabbed":i?!!a:void 0,title:u.length?u.join(` · `):void 0,onClick:()=>n(e.id),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n(e.id)):t.key===` `&&i?(t.preventDefault(),i()):t.key===` `&&(t.preventDefault(),n(e.id))},onDragStart:r,children:[(0,A.jsxs)(`span`,{className:`flex items-center`,children:[(0,A.jsx)(`span`,{className:`font-mono text-[11px] text-foreground/70`,children:e.id}),(0,A.jsx)(`span`,{className:`flex-1`}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] font-medium`,style:{color:d(e.priority)},children:e.priority})]}),(0,A.jsx)(`span`,{className:`text-[12.5px] leading-snug font-medium`,role:`heading`,"aria-level":3,children:e.title}),(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground`,children:[(0,A.jsx)(`span`,{children:e.area}),(0,A.jsx)(`span`,{children:`·`}),(0,A.jsx)(`span`,{children:e.type}),e.claimed_by?(0,A.jsxs)(`span`,{className:`ml-auto inline-flex min-w-0 items-center gap-[5px]`,style:{color:l(`doing`)},children:[(0,A.jsx)(`span`,{className:`size-[5px] flex-none rounded-full bg-current`,"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`max-w-[90px] truncate`,children:e.claimed_by})]}):null]}),Array.isArray(e.scope)&&e.scope.length?(0,A.jsxs)(`span`,{className:`mt-0.5 truncate border-t border-dashed pt-1.5 font-mono text-[10.5px] text-muted-foreground`,children:[`scope `,e.scope.join(` · `)]}):null]})}function F({status:e,cards:t,epicIds:n,collapsed:a,onToggleCollapsed:c,onOpen:d,onMove:f,onCarry:_,carryingId:v,isDropTarget:y,onDragEnterColumn:S,onDragLeaveColumn:w}){let[T,E,D]=M(t,25),k=l(e),j={onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,S?.(e)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||w?.(e)},onDrop:t=>{t.preventDefault(),w?.(e);let n=t.dataTransfer.getData(`text/plain`);n&&f(n,e).catch(()=>void 0)}};return a?(0,A.jsxs)(O,{role:`region`,"aria-label":`${e}, ${t.length} cards, collapsed`,className:s(`relative w-11 flex-none gap-0 overflow-hidden rounded-lg py-0 shadow-xs`,y&&`border-primary`),...j,children:[(0,A.jsx)(g,{edge:`top`,color:k}),(0,A.jsxs)(`button`,{type:`button`,"aria-expanded":!1,"aria-label":`Expand the ${e} column`,title:`${e} · ${t.length}`,className:s(`flex h-full w-full cursor-pointer flex-col items-center gap-2.5 px-1 pt-4 pb-3 transition-colors hover:bg-accent/50`,y&&`bg-accent/50`),onClick:c,children:[(0,A.jsx)(o,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,A.jsx)(`span`,{className:`min-h-0 flex-1 truncate font-mono text-[11px] uppercase tracking-[0.06em] [writing-mode:vertical-rl]`,style:{color:k},children:e}),(0,A.jsx)(C,{variant:`secondary`,className:`h-5 shrink-0 rounded-md px-[7px] font-mono text-[11px] font-normal`,children:t.length})]})]}):(0,A.jsxs)(O,{role:`region`,"aria-label":`${e}, ${t.length} cards`,className:s(`relative w-[268px] flex-none gap-0 overflow-hidden rounded-lg py-0 shadow-xs`,y&&`border-primary`),...j,children:[(0,A.jsx)(g,{edge:`top`,color:k}),(0,A.jsxs)(`header`,{className:`flex flex-none items-center gap-2 px-3 pb-2.5 pt-4`,children:[(0,A.jsx)(`span`,{className:`flex-1 font-mono text-[11px] uppercase tracking-[0.06em]`,style:{color:k},children:e}),(0,A.jsx)(C,{variant:`secondary`,className:`h-5 rounded-md px-[7px] font-mono text-[11px] font-normal`,children:t.length}),c?(0,A.jsx)(u,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-expanded":!0,"aria-label":`Collapse the ${e} column`,title:`Collapse column`,className:`-mr-1 text-muted-foreground`,onClick:c,children:(0,A.jsx)(r,{"aria-hidden":`true`})}):null]}),(0,A.jsxs)(`div`,{className:s(`scroll-fade flex flex-1 flex-col gap-2 overflow-y-auto p-2.5`,y&&`bg-accent/50`),children:[t.length===0?(0,A.jsx)(x,{className:`flex-1 gap-2 rounded-lg border border-dashed p-4`,children:(0,A.jsxs)(p,{className:`gap-1`,children:[(0,A.jsx)(m,{variant:`icon`,className:`mb-0 size-8 [&_svg:not([class*='size-'])]:size-4`,children:(0,A.jsx)(i,{"aria-hidden":`true`})}),(0,A.jsx)(h,{className:`text-[12.5px] font-medium`,children:`No cards`}),(0,A.jsx)(b,{className:`text-[11.5px]`,children:`Nothing in this state.`})]})}):T.map(e=>(0,A.jsx)(P,{task:e,epicId:n.get(e.id),onOpen:d,onCarry:_?()=>_(e):void 0,carrying:v===e.id,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id)}},e.id)),E&&(0,A.jsx)(N,{onVisible:D,remaining:t.length-T.length})]})]})}function I({tasks:e,epicIds:t,showClosed:n,onOpen:r,onMove:i}){let[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(()=>{try{let e=localStorage.getItem(`workfile-flow-collapsed`);return new Set(e?JSON.parse(e):[])}catch{return new Set}}),p=(0,k.useCallback)(e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),localStorage.setItem(`workfile-flow-collapsed`,JSON.stringify([...n])),n})},[]),m=(0,k.useMemo)(()=>[`backlog`,`next`,`doing`,`review`,`blocked`,`deferred`,...n?[`done`,`discarded`]:[]],[n]),h=(0,k.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.status);e?e.push(n):t.set(n.status,[n])}return t},[e]),g=e=>{o({id:e.id,status:e.status}),u(`${e.id} picked up from ${e.status}. Use the arrow keys to choose a column, space to drop, escape to cancel.`)},_=e=>{if(!a)return;let t=m.indexOf(a.status),n=m[Math.min(m.length-1,Math.max(0,t+e))];!n||n===a.status||(o({...a,status:n}),u(`${a.id} over ${n}.`))},v=async()=>{if(!a)return;let t=a;o(null);let n=e.find(e=>e.id===t.id);n&&n.status!==t.status?(await i(t.id,t.status),u(`${t.id} moved to ${t.status}.`)):u(`${t.id} put back.`)};return(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-3 overflow-x-auto p-3.5`,onDragEnd:()=>c(null),onKeyDown:e=>{a&&(e.key===`Escape`?(e.preventDefault(),o(null),u(`Move cancelled.`)):e.key===`ArrowRight`?(e.preventDefault(),_(1)):e.key===`ArrowLeft`?(e.preventDefault(),_(-1)):(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),v()))},children:[(0,A.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:l}),m.map(e=>(0,A.jsx)(F,{status:e,cards:h.get(e)??j,epicIds:t,collapsed:d.has(e),onToggleCollapsed:()=>p(e),onOpen:r,onMove:i,onCarry:g,carryingId:a?.id??null,isDropTarget:a?.status===e||s===e,onDragEnterColumn:c,onDragLeaveColumn:e=>c(t=>t===e?null:t)},e))]})}function L({tasks:e,allTasks:t,epicIds:n,onOpen:r}){let i=(0,k.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),a=(0,k.useMemo)(()=>{let t=new Map;for(let r of e){let e=n.get(r.id)||(r.type===`epic`?r.id:`__none`);t.has(e)||t.set(e,[]),r.id!==e&&t.get(e)?.push(r)}return[...t].sort(([e],[t])=>e===`__none`?1:t===`__none`?-1:e.localeCompare(t,void 0,{numeric:!0}))},[n,e]);return a.length?(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3.5`,children:(0,A.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:a.map(([e,t])=>{let n=i.get(e),a=t.length,o=t.filter(e=>e.status===`done`||e.status===`discarded`).length,c=t.filter(e=>e.status===`doing`).length,u=a-o-c,d=e=>a?`${e/a*100}%`:`0%`,f=[{label:`${o} done`,color:l(`done`)},{label:`${c} doing`,color:l(`doing`)},{label:`${u} open`,color:null}],p=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,A.jsx)(`span`,{className:`font-mono text-[11.5px] text-foreground/70`,children:e===`__none`?`—`:e}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-semibold tracking-[-0.01em] text-pretty`,children:n?.title||`Without epic`}),n?(0,A.jsx)(`span`,{className:`font-mono text-[11px]`,style:{color:l(n.status)},children:n.status}):null,(0,A.jsxs)(`span`,{className:`font-mono text-[11.5px] text-muted-foreground`,children:[o,`/`,a]})]}),(0,A.jsx)(`span`,{className:`flex h-2 w-full overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:a>0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`h-full`,style:{width:d(o),background:l(`done`)}}),(0,A.jsx)(`span`,{className:`h-full`,style:{width:d(c),background:l(`doing`)}})]}):null}),(0,A.jsxs)(`span`,{className:`flex flex-wrap items-center gap-3.5 font-mono text-[10.5px] text-muted-foreground`,children:[f.map(e=>(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-[5px]`,children:[(0,A.jsx)(`span`,{className:s(`size-1.5 rounded-[2px]`,!e.color&&`bg-muted-foreground`),style:e.color?{background:e.color}:void 0,"aria-hidden":`true`}),e.label]},e.label)),(0,A.jsx)(`span`,{className:`ml-auto`,children:n?.area??``})]})]});return n?(0,A.jsx)(`button`,{type:`button`,className:`flex w-full cursor-pointer flex-col gap-2.5 rounded-xl border bg-card px-4 py-3.5 text-left text-card-foreground shadow-xs outline-none transition-[color,border-color,box-shadow] hover:border-ring focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,onClick:()=>r(e),children:p},e):(0,A.jsx)(O,{className:`gap-2.5 rounded-xl px-4 py-3.5 shadow-xs`,children:p},e)})})}):(0,A.jsx)(x,{className:`flex-1 p-6`,children:(0,A.jsxs)(p,{children:[(0,A.jsx)(h,{className:`text-sm`,children:`No epics`}),(0,A.jsx)(b,{className:`text-[11.5px]`,children:`No cards match the current filters.`})]})})}var R=300,z=30;function B({task:e,span:t,mode:n,epicId:r,pct:i,labelWidth:a,onOpen:o}){let s=l(e.status);return(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),title:`${w(e,n,t)} · ${e.status}${r&&r!==e.id?` · epic ${r}`:``}`,className:`flex w-full cursor-pointer items-center border-b bg-transparent p-0 text-left transition-colors hover:bg-muted`,children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 border-r px-3.5`,style:{width:a,flex:`0 0 ${a}px`,height:`var(--row-h)`},children:[(0,A.jsx)(`span`,{className:`flex-none whitespace-nowrap font-mono text-[11px] text-foreground/70`,children:e.id}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-[12.5px]`,children:e.title})]}),(0,A.jsx)(`span`,{className:`relative block flex-1`,style:{height:`var(--row-h)`},children:t.point?(0,A.jsx)(`span`,{style:{position:`absolute`,top:`50%`,width:9,height:9,transform:`translate(-50%, -50%) rotate(45deg)`,borderRadius:2,background:s,display:`block`,left:`${i(t.from)}%`}}):(0,A.jsx)(`span`,{style:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,height:12,minWidth:6,borderRadius:3,background:s,display:`block`,left:`${i(t.from)}%`,width:`${Math.max(i(t.to)-i(t.from),.8)}%`}})})]})}function V({tasks:e,epicIds:t,axes:n={},mode:r,counts:i,onModeChange:o,onOpen:s}){let l=_()?168:R,d=l+460,[m,g]=(0,k.useState)(()=>{try{return localStorage.getItem(`workfile-timeline-group`)||`none`}catch{return`none`}}),C=(0,k.useCallback)(e=>{g(e);try{localStorage.setItem(`workfile-timeline-group`,e)}catch{}},[]),w=(0,k.useMemo)(()=>[`none`,`epic`,`area`,...Object.keys(n)],[n]),O=w.includes(m)?m:`none`,j=(0,k.useCallback)(e=>{if(O===`epic`)return t.get(e.id)||``;if(O===`area`)return e.area||``;let n=e[O];return typeof n==`string`?n:``},[t,O]),M=(0,k.useMemo)(()=>{let t=new Map;for(let n of e){let e=S(n,r);e&&t.set(n.id,e)}return t},[r,e]),N=(0,k.useMemo)(()=>{let t=(e,t)=>M.get(e.id).from-M.get(t.id).from||e.id.localeCompare(t.id),n=e.filter(e=>M.has(e.id)).sort(t);return O===`none`?n:[...n].sort((e,n)=>{let r=j(e),i=j(n);return!r==!i?r.localeCompare(i)||t(e,n):r?-1:1})},[j,O,M,e]),P=(0,k.useMemo)(()=>{if(O===`none`)return N.map(e=>({task:e,label:null}));let e=[],t=null;for(let n of N){let r=j(n);r!==t&&(t=r,e.push({task:null,label:r||`no ${O}`})),e.push({task:n,label:null})}return e},[j,O,N]),F=(0,k.useMemo)(()=>new Map(P.flatMap((e,t)=>e.task?[[e.task.id,t]]:[])),[P]),I=(0,k.useMemo)(()=>{let e=[];for(let t of N)for(let n of t.depends||[])F.has(n)&&e.push({from:n,to:t.id});return e},[F,N]),L=(0,k.useMemo)(()=>E(N.map(e=>M.get(e.id)),Date.now()),[N,M]),V=i[r===`plan`?`actual`:`plan`];return!N.length||!L?(0,A.jsx)(x,{className:`flex-1 p-6`,children:(0,A.jsxs)(p,{children:[(0,A.jsx)(h,{className:`text-sm`,children:r===`plan`?`Nothing scheduled`:`Nothing recorded`}),(0,A.jsx)(b,{className:`text-[11.5px]`,children:r===`plan`?`Add a start or due date to a card.`:`Cards record a trail as they are claimed and moved.`}),V>0?(0,A.jsx)(b,{className:`text-[11.5px]`,children:(0,A.jsx)(u,{variant:`outline`,size:`sm`,className:`mt-2 text-[12.5px] font-medium`,onClick:()=>o(r===`plan`?`actual`:`plan`),children:r===`plan`?`show what actually happened · ${V} cards`:`show the schedule · ${V} cards`})}):null]})}):(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`div`,{className:`no-scrollbar flex flex-none items-center gap-2.5 overflow-x-auto border-b bg-card px-3.5 py-2`,children:[(0,A.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] whitespace-nowrap text-muted-foreground`,children:[N.length,` `,r===`actual`?`recorded`:`scheduled`,` ·`,` `,I.length,` dependenc`,I.length===1?`y`:`ies`]}),(0,A.jsxs)(f,{children:[(0,A.jsx)(v,{asChild:!0,children:(0,A.jsxs)(u,{variant:`outline`,size:`sm`,"aria-label":`dates`,className:`ml-auto shrink-0 text-[12.5px] font-medium`,children:[`dates`,(0,A.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:r}),(0,A.jsx)(a,{className:`size-[13px] text-muted-foreground`})]})}),(0,A.jsx)(D,{align:`end`,children:(0,A.jsxs)(T,{value:r,onValueChange:e=>o(e),children:[(0,A.jsx)(y,{value:`plan`,children:`plan`}),(0,A.jsx)(y,{value:`actual`,children:`actual`})]})})]}),(0,A.jsxs)(f,{children:[(0,A.jsx)(v,{asChild:!0,children:(0,A.jsxs)(u,{variant:`outline`,size:`sm`,"aria-label":`group`,className:`shrink-0 text-[12.5px] font-medium`,children:[`group`,(0,A.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:O}),(0,A.jsx)(a,{className:`size-[13px] text-muted-foreground`})]})}),(0,A.jsx)(D,{align:`end`,children:(0,A.jsx)(T,{value:O,onValueChange:C,children:w.map(e=>(0,A.jsx)(y,{value:e,children:e},e))})})]})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,A.jsxs)(`div`,{className:`relative min-h-full`,style:{minWidth:d},children:[(0,A.jsxs)(`div`,{"aria-hidden":`true`,className:`sticky top-0 z-[2] flex items-stretch border-b bg-card`,style:{height:z},children:[(0,A.jsx)(`span`,{className:`flex items-center border-r px-3.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,style:{width:l,flex:`0 0 ${l}px`},children:`card`}),(0,A.jsx)(`span`,{className:`relative flex-1`,children:L.ticks.map((e,t)=>(0,A.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,style:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,left:`${e.left}%`,width:`${(L.ticks[t+1]?.left??100)-e.left}%`,overflow:`hidden`,paddingLeft:8,whiteSpace:`nowrap`},children:e.label},e.key))})]}),(0,A.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute`,style:{top:z,bottom:0,left:l,right:0},children:[L.ticks.map(e=>(0,A.jsx)(`span`,{className:`absolute inset-y-0 w-px bg-border`,style:{left:`${e.left}%`}},e.key)),L.today!=null&&(0,A.jsx)(`span`,{className:`absolute inset-y-0 w-px`,style:{background:c(`error`),opacity:.55,left:`${L.today}%`}})]}),(0,A.jsxs)(`div`,{className:`relative`,children:[I.length>0&&(0,A.jsx)(`svg`,{"aria-hidden":`true`,preserveAspectRatio:`none`,viewBox:`0 0 100 ${P.length}`,className:`pointer-events-none absolute top-0 h-full`,style:{left:l,width:`calc(100% - ${l}px)`},children:I.map(e=>{let t=M.get(e.from),n=M.get(e.to);if(!t||!n)return null;let r=L.pct(t.to),i=L.pct(n.from),a=F.get(e.from)+.5,o=F.get(e.to)+.5;return(0,A.jsx)(`path`,{d:`M ${r} ${a} C ${(r+i)/2} ${a}, ${(r+i)/2} ${o}, ${i} ${o}`,vectorEffect:`non-scaling-stroke`,style:i<r?{fill:`none`,stroke:c(`error`),strokeWidth:1.5,strokeDasharray:`3 2`}:{fill:`none`,stroke:`var(--muted-foreground)`,strokeWidth:1.5,opacity:.4}},`${e.from}-${e.to}`)})}),P.map((e,n)=>e.task?(0,A.jsx)(B,{task:e.task,span:M.get(e.task.id),mode:r,epicId:t.get(e.task.id),pct:L.pct,labelWidth:l,onOpen:s},e.task.id):(0,A.jsx)(`div`,{className:`border-b bg-muted/40`,children:(0,A.jsx)(`span`,{className:`flex items-center px-3.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,style:{height:`var(--row-h)`},children:e.label})},`group-${n}-${e.label}`))]})]})})]})}export{L as EpicsView,I as FlowBoard,V as TimelineView};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{B as r,Ct as i,K as a,Q as o,W as s,ft as ee,pt as c}from"./ui-primitives-Beqd9I2k.js";import{c as l,r as u,s as d}from"./theme-CNCrPl--.js";import{C as f,D as p,I as te,L as ne,M as re,O as m,P as ie,S as h,T as ae,W as g,X as _,Z as oe,_ as se,b as v,c as ce,ct as y,d as le,f as ue,g as b,h as x,j as de,k as fe,l as pe,m as S,ot as me,p as he,st as C,v as ge,w,x as _e,y as ve}from"./index-Dpy209ef.js";import{t as ye}from"./layout-QiuZ_k5v.js";var T=e(t(),1),E=n(),D=`doc-h`,be=[`current`,`draft`,`superseded`,`archived`],O=`text-[10px] font-medium tracking-[0.07em] uppercase text-muted-foreground`;function xe({document:e,selected:t,onSelect:n}){return(0,E.jsx)(m,{asChild:!0,size:`sm`,className:l(`w-full cursor-pointer flex-col items-start gap-0.5 px-2 py-1.5 text-left hover:bg-accent`,t&&`bg-accent`),children:(0,E.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,children:[(0,E.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`flex-1 truncate text-xs font-medium`,children:e.title}),(0,E.jsx)(`span`,{className:l(`font-mono text-[10px]`,!e.managed&&`text-muted-foreground`),style:e.managed?{color:u(e.status)}:void 0,children:e.managed?e.status:`indexed`})]}),(0,E.jsx)(`span`,{className:`w-full truncate font-mono text-[10px] text-muted-foreground`,children:e.path})]})})}function Se({entries:e,activeId:t,onJump:n}){let r=Math.min(...e.map(e=>e.level));return(0,E.jsxs)(`aside`,{"aria-label":`Document outline`,className:`hidden w-[228px] shrink-0 overflow-y-auto border-l px-3 py-6.5 xl:block`,children:[(0,E.jsx)(`span`,{className:l(O,`px-2`),children:`on this page`}),(0,E.jsx)(`nav`,{className:`mt-2 flex flex-col gap-px`,children:e.map(e=>{let i=e.id===t;return(0,E.jsx)(`button`,{type:`button`,"aria-current":i?`true`:void 0,className:l(`cursor-pointer rounded-md px-2 py-1 text-left text-xs leading-snug transition-colors hover:bg-accent`,i?`bg-accent font-medium text-foreground`:`text-muted-foreground`),style:{paddingLeft:`${8+Math.min(e.level-r,3)*12}px`},onClick:()=>n(e.id),children:e.text},e.id)})})]})}function k({label:e,value:t}){return(0,E.jsxs)(v,{className:`w-auto min-w-[120px] gap-0.5 rounded-lg border bg-card px-3 py-2 shadow-xs`,children:[(0,E.jsx)(`span`,{className:O,children:e}),(0,E.jsx)(`span`,{className:`text-[13px] font-medium`,children:t})]})}function A({label:e,links:t,onOpen:n}){return t.length?(0,E.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,E.jsx)(`span`,{className:O,children:e}),t.map((e,t)=>{let r=!e.exists&&!e.title;return(0,E.jsx)(m,{asChild:!0,variant:`outline`,size:`sm`,className:l(`w-full cursor-pointer gap-2 px-2.5 py-2 text-left hover:bg-accent`,r&&`cursor-default opacity-55 hover:bg-transparent`),children:(0,E.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>n(e.id),children:[(0,E.jsx)(`span`,{className:`min-w-[78px] shrink-0 font-mono text-[11px] font-medium`,children:e.id}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:e.title||(e.exists===!1?`Missing record`:e.id)}),(e.relations??[e.relation]).filter(Boolean).map(e=>(0,E.jsx)(me,{variant:`secondary`,className:`font-mono text-[10px]`,children:e},e))]})},`${e.id}-${t}`)})]}):null}var j=(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`});function M({id:e,onSelect:t,onOpen:n}){let[r,i]=(0,T.useState)(null),[a,o]=(0,T.useState)(``),s=(0,T.useRef)(null),ee=(0,T.useMemo)(()=>r?w(r.body||``,D):[],[r]);return(0,T.useEffect)(()=>{let t=!0;return i(null),o(``),g.record(e).then(e=>{t&&i(e.record)}).catch(e=>{t&&o(e.message)}),()=>{t=!1}},[e]),a?(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:a}):r?(0,E.jsxs)(`div`,{ref:s,className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-4 py-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 font-mono text-[11px] text-muted-foreground`,children:[(0,E.jsx)(`span`,{children:r.id}),j,(0,E.jsx)(`span`,{children:r.documentKind}),j,(0,E.jsx)(`span`,{style:{color:u(r.status)},children:r.status}),j,(0,E.jsx)(`span`,{children:r.managed?`managed`:`indexed`}),(0,E.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,className:`ml-auto h-7 gap-1 px-2 text-xs`,onClick:()=>n(e),children:[(0,E.jsx)(c,{"aria-hidden":`true`,className:`size-3`}),`Open in Docs`]})]}),(0,E.jsx)(`h2`,{className:`mt-1 text-sm font-medium`,children:r.title}),(0,E.jsx)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:r.path}),r.freshness?.length?(0,E.jsx)(C,{className:`mt-3`,children:(0,E.jsx)(y,{children:r.freshness.map(e=>e.message).join(` `)})}):null,(0,E.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-start gap-1`,children:[(0,E.jsx)(`div`,{className:`min-w-0 flex-1 [&>.typeset]:[--typeset-leading:1.6] [&>.typeset]:[--typeset-size:0.8125rem] [&>.typeset>:not(.typeset-scroll)]:max-w-[72ch]`,children:(0,E.jsx)(f,{source:r.body||`_This document is empty._`,onOpen:t,headingPrefix:D})}),(0,E.jsx)(S,{entries:ee,container:s})]})]}):(0,E.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground`,children:[(0,E.jsx)(p,{}),` Reading `,e,`…`]})}function N({selectedId:e,onSelect:t,onOpenCard:n}){let[c,m]=(0,T.useState)([]),[S,me]=(0,T.useState)(``),[M,N]=(0,T.useState)(!0),[P,F]=(0,T.useState)(``),[I,Ce]=(0,T.useState)(!1),[L,we]=(0,T.useState)(!1),[R,z]=(0,T.useState)(null),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(``),[W,Te]=(0,T.useState)(null),[Ee,G]=(0,T.useState)(0);ne(e=>{te(e,`/docs/`,`docs/`)&&G(e=>e+1)}),(0,T.useEffect)(()=>{let e=!1;N(!0);let t=window.setTimeout(()=>{g.docs(S.trim()).then(t=>{e||(m(t.records),F(``))}).catch(t=>{e||F(t instanceof Error?t.message:String(t))}).finally(()=>{e||N(!1)})},S?180:0);return()=>{e=!0,window.clearTimeout(t)}},[S,Ee]),(0,T.useEffect)(()=>{if(!R||W)return;let e=!1;return g.tasks().then(t=>{e||Te(t.schema.docs)}).catch(()=>{}),()=>{e=!0}},[R,W]);let K=(0,T.useMemo)(()=>I?c.filter(e=>e.managed):c,[c,I]),q=(0,T.useMemo)(()=>{let e=K.filter(e=>e.managed),t=K.filter(e=>!e.managed);return[{key:`managed`,label:`.project/docs · managed`,docs:e},{key:`indexed`,label:`indexed · read only`,docs:t}].filter(e=>e.docs.length>0)},[K]),De=oe(),J=K.find(t=>t.id===e)||(De?void 0:K[0]),Y=(0,T.useRef)(null),[Oe,X]=(0,T.useState)(``),Z=(0,T.useMemo)(()=>J&&!L?w(J.body,D):[],[J,L]),Q=Z.length>1;(0,T.useEffect)(()=>{X(``);let e=Y.current;if(!e||!Q)return;let t=new Map,n=new IntersectionObserver(e=>{for(let n of e)t.set(n.target.id,n.isIntersecting);let n=Z.find(e=>t.get(e.id));n&&X(n.id)},{root:e,rootMargin:`0px 0px -66% 0px`,threshold:0});for(let e of Z){let t=document.getElementById(e.id);t&&n.observe(t)}return()=>n.disconnect()},[Z,Q]);let ke=e=>{document.getElementById(e)?.scrollIntoView({block:`start`,behavior:`smooth`}),X(e)},$=e=>{let r=c.find(t=>t.id===e);r?t(r.id):n(e)},Ae=(0,T.useMemo)(()=>{let e=new Set(W?.kinds??[]);for(let t of c)t.managed&&e.add(t.documentKind);return R&&e.add(R.kind),[...e].sort()},[W,c,R]),je=(0,T.useMemo)(()=>{let e=new Set(W?.statuses??be);for(let t of c)t.managed&&e.add(t.status);return R&&e.add(R.status),[...e].sort()},[W,c,R]);function Me(e){U(``),z({id:e.id,title:e.title,kind:e.documentKind,status:e.status,owners:(e.owners??[]).join(`, `),reviewed:e.reviewed??``})}async function Ne(){if(!R)return;let e=c.find(e=>e.id===R.id);if(!e){U(`This document no longer exists in the workspace.`);return}let t=R.owners.split(`,`).map(e=>e.trim()).filter(Boolean),n={},r=R.title.trim();if(r&&r!==e.title&&(n.title=r),R.kind!==e.documentKind&&(n.kind=R.kind),R.status!==e.status&&(n.status=R.status),t.join(`
`)!==(e.owners??[]).join(`
`)&&(n.owners=t),(R.reviewed||``)!==(e.reviewed??``)&&(n.reviewed=R.reviewed||null),!Object.keys(n).length){z(null);return}V(!0),U(``);try{let t=await g.patchDocument(e.id,n,e.revision);m(n=>n.map(n=>n.id===e.id?t.record:n)),z(null)}catch(e){let t=e;t.code?.endsWith(`WRITE_CONFLICT`)?(G(e=>e+1),U(`The document changed on disk; the list was refreshed. Save again to apply your changes to the latest revision.`)):U(t.message||String(e))}finally{V(!1)}}return(0,E.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,E.jsxs)(`aside`,{"aria-label":`Documents`,className:l(`min-h-0 w-full shrink-0 flex-col border-r px-2 py-3 lg:flex lg:w-[290px]`,J?`hidden`:`flex`),children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 pb-2.5`,children:[(0,E.jsxs)(se,{className:`h-8`,children:[(0,E.jsx)(ge,{children:(0,E.jsx)(a,{"aria-hidden":`true`})}),(0,E.jsx)(ve,{className:`h-8`,type:`search`,value:S,"aria-label":`Search documentation`,placeholder:`Search documentation…`,onChange:e=>me(e.target.value)})]}),(0,E.jsx)(`div`,{className:`flex gap-1.5`,children:(0,E.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,"aria-pressed":I,className:l(`h-7 gap-1.5 px-2.5 text-xs`,I&&`border-ring bg-accent`),onClick:()=>Ce(!I),children:[`managed`,(0,E.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:I?`only`:`all`})]})})]}),(0,E.jsx)(`div`,{"aria-busy":M||void 0,className:`min-h-0 flex-1 overflow-y-auto`,children:M?(0,E.jsxs)(`span`,{className:`flex items-center gap-2 px-2 py-1.5 font-mono text-[10.5px] text-muted-foreground`,children:[(0,E.jsx)(p,{className:`size-3`}),`Loading documents…`]}):P?(0,E.jsx)(C,{variant:`destructive`,className:`mt-1.5`,children:(0,E.jsx)(y,{children:P})}):q.length?q.map(e=>(0,E.jsxs)(`div`,{className:`flex flex-col gap-px pb-3.5`,children:[(0,E.jsxs)(`span`,{className:`flex items-center gap-2 px-2 py-1.5 font-mono text-[10.5px] text-muted-foreground`,children:[(0,E.jsx)(`span`,{className:`text-foreground/80`,children:e.label}),(0,E.jsx)(`span`,{children:e.docs.length})]}),e.docs.map(e=>(0,E.jsx)(xe,{document:e,selected:J?.id===e.id,onSelect:()=>t(e.id)},e.id))]},e.key)):(0,E.jsx)(fe,{className:`gap-2 p-4 md:p-4`,children:(0,E.jsxs)(re,{children:[(0,E.jsx)(ie,{className:`text-sm`,children:`No documents found.`}),(0,E.jsx)(de,{className:`text-xs`,children:I?`Try another search, or include indexed files.`:`Try another search.`})]})})})]}),(0,E.jsx)(`section`,{ref:Y,className:l(`min-w-0 flex-1 overflow-y-auto px-6 py-6.5 sm:px-8.5`,J?`block`:`hidden lg:block`),children:(0,E.jsx)(`div`,{className:ye,children:J?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-2 mb-2 lg:hidden`,onClick:()=>t(``),children:[(0,E.jsx)(i,{"aria-hidden":`true`}),`All documents`]}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 font-mono text-[11px] text-muted-foreground`,children:[(0,E.jsx)(`span`,{children:J.id}),j,(0,E.jsx)(`span`,{children:J.documentKind}),j,(0,E.jsx)(`span`,{style:{color:u(J.status)},children:J.status}),j,(0,E.jsx)(`span`,{children:J.managed?`managed`:`indexed`}),(0,E.jsx)(`span`,{className:`flex-1`}),J.managed?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>we(e=>!e),children:[L?(0,E.jsx)(ee,{"aria-hidden":`true`}):(0,E.jsx)(o,{"aria-hidden":`true`}),L?`Preview`:`Edit`]}),(0,E.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Me(J),children:[(0,E.jsx)(s,{"aria-hidden":`true`}),`Metadata`]})]}):null]}),(0,E.jsx)(`h2`,{className:`mt-3 mb-1.5 text-2xl font-semibold tracking-tight`,children:J.title}),(0,E.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:J.path}),(0,E.jsxs)(`div`,{className:`mt-4.5 flex flex-wrap gap-2`,children:[(0,E.jsx)(k,{label:`kind`,value:J.documentKind}),(0,E.jsx)(k,{label:`status`,value:J.status}),(0,E.jsx)(k,{label:`reviewed`,value:J.reviewed||`—`}),(0,E.jsx)(k,{label:`owners`,value:J.owners?.join(`, `)||`—`}),(0,E.jsx)(k,{label:`backlinks`,value:String(J.incomingTotal??J.incoming.length)}),J.updated?(0,E.jsx)(k,{label:`updated`,value:J.updated}):null]}),J.freshness.length>0?(0,E.jsxs)(C,{role:`status`,className:`mt-4.5 max-w-2xl`,children:[(0,E.jsx)(r,{"aria-hidden":`true`,className:`text-sev-warning`}),(0,E.jsx)(y,{children:J.freshness.map(e=>(0,E.jsx)(`span`,{children:e.message},`${e.code}-${e.message}`))})]}):null,(0,E.jsx)(`div`,{className:`mt-6.5`,children:L&&J.managed?(0,E.jsx)(ae,{value:J.body,revision:J.revision,onSave:async(e,t)=>{let n=await g.patchDocument(J.id,{body:e},t);m(e=>e.map(e=>e.id===J.id?n.record:e))}},J.id):J.body.trim()?(0,E.jsx)(f,{source:J.body,headingPrefix:D,onOpen:$}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J.managed?`This document is empty. Use Edit to write its first version.`:`This file has no body to render.`})}),J.outgoing.length||J.incoming.length||J.scope?.length?(0,E.jsxs)(`div`,{className:`mt-7 flex max-w-[70ch] flex-col gap-4.5`,children:[(0,E.jsx)(A,{label:`links to`,links:J.outgoing,onOpen:$}),(0,E.jsx)(A,{label:(J.incomingTotal??J.incoming.length)>J.incoming.length?`backlinks (${J.incoming.length} of ${J.incomingTotal})`:`backlinks`,links:J.incoming,onOpen:$}),J.scope?.length?(0,E.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,E.jsx)(`span`,{className:O,children:`scope`}),J.scope.map(e=>(0,E.jsx)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground [overflow-wrap:anywhere]`,children:e},e))]}):null]}):null]}):(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-muted-foreground`,children:M?`Loading documents…`:`Select a document from the list to read it.`})})}),Q?(0,E.jsx)(Se,{entries:Z,activeId:Oe,onJump:ke}):null,(0,E.jsx)(ce,{open:R!==null,onOpenChange:e=>{!e&&!B&&z(null)},children:(0,E.jsxs)(pe,{"aria-describedby":void 0,children:[(0,E.jsx)(ue,{children:(0,E.jsx)(he,{children:`Edit metadata${R?` — ${R.id}`:``}`})}),R?(0,E.jsxs)(_e,{className:`gap-4`,children:[(0,E.jsxs)(v,{children:[(0,E.jsx)(h,{htmlFor:`docs-meta-title`,children:`title`}),(0,E.jsx)(_,{id:`docs-meta-title`,value:R.title,onChange:e=>z({...R,title:e.target.value})})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,E.jsxs)(v,{className:`[&_[data-slot=native-select-wrapper]]:w-full`,children:[(0,E.jsx)(h,{htmlFor:`docs-meta-kind`,children:`kind`}),(0,E.jsx)(x,{id:`docs-meta-kind`,value:R.kind,onChange:e=>z({...R,kind:e.target.value}),children:Ae.map(e=>(0,E.jsx)(b,{value:e,children:e},e))})]}),(0,E.jsxs)(v,{className:`[&_[data-slot=native-select-wrapper]]:w-full`,children:[(0,E.jsx)(h,{htmlFor:`docs-meta-status`,children:`status`}),(0,E.jsx)(x,{id:`docs-meta-status`,value:R.status,onChange:e=>z({...R,status:e.target.value}),children:je.map(e=>(0,E.jsx)(b,{value:e,children:e},e))})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,E.jsxs)(v,{children:[(0,E.jsx)(h,{htmlFor:`docs-meta-owners`,children:`owners`}),(0,E.jsx)(_,{id:`docs-meta-owners`,value:R.owners,placeholder:`comma-separated`,onChange:e=>z({...R,owners:e.target.value})})]}),(0,E.jsxs)(v,{children:[(0,E.jsx)(h,{htmlFor:`docs-meta-reviewed`,children:`reviewed`}),(0,E.jsx)(_,{id:`docs-meta-reviewed`,type:`date`,value:R.reviewed,onChange:e=>z({...R,reviewed:e.target.value})})]})]}),H?(0,E.jsx)(C,{variant:`destructive`,children:(0,E.jsx)(y,{children:H})}):null]}):null,(0,E.jsxs)(le,{children:[(0,E.jsx)(d,{type:`button`,variant:`outline`,disabled:B,onClick:()=>z(null),children:`Cancel`}),(0,E.jsx)(d,{type:`button`,disabled:B,onClick:()=>void Ne(),children:B?`Saving…`:`Save`})]})]})})]})}export{M as DocPanel,N as DocsView};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{At as r,C as i,Tt as a,W as o,kt as s,w as c,yt as ee}from"./ui-primitives-Beqd9I2k.js";import{c as l,o as u,s as d,t as f}from"./theme-CNCrPl--.js";import{F as te,G as ne,J as re,K as ie,M as ae,P as oe,Y as se,a as p,g as m,h,i as ce,j as le,k as ue,o as g,q as de,s as fe}from"./index-Dpy209ef.js";import{t as _}from"./progress-DOIfGVtf.js";var v=e(t(),1),y=n();function b({className:e,...t}){return(0,y.jsx)(i,{"data-slot":`checkbox`,className:l(`peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary`,e),...t,children:(0,y.jsx)(c,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none`,children:(0,y.jsx)(a,{className:`size-3.5`})})})}function pe({className:e,...t}){return(0,y.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,y.jsx)(`table`,{"data-slot":`table`,className:l(`w-full caption-bottom text-sm`,e),...t})})}function me({className:e,...t}){return(0,y.jsx)(`thead`,{"data-slot":`table-header`,className:l(`[&_tr]:border-b`,e),...t})}function he({className:e,...t}){return(0,y.jsx)(`tbody`,{"data-slot":`table-body`,className:l(`[&_tr:last-child]:border-0`,e),...t})}function x({className:e,...t}){return(0,y.jsx)(`tr`,{"data-slot":`table-row`,className:l(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function S({className:e,...t}){return(0,y.jsx)(`th`,{"data-slot":`table-head`,className:l(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function C({className:e,...t}){return(0,y.jsx)(`td`,{"data-slot":`table-cell`,className:l(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}var w=[[`id`,`id`],[`title`,`title · claim`],[`status`,`status`],[`priority`,`prio`],[`type`,`type`],[`area`,`area`],[`epic`,`links`],[`updated`,`updated`]],T=new Map(p.map((e,t)=>[e,t])),E=new Map(g.map((e,t)=>[e,t])),D=w.length+1;function O(e,t){let n=new Map;for(let r of e){let e=r[t];typeof e==`string`&&n.set(e,(n.get(e)||0)+1)}return n}function k({title:e,values:t,counts:n,selected:r,color:i,onSelect:a}){let o=t.filter(e=>n.has(e));if(!o.length)return null;let s=Math.max(...o.map(e=>n.get(e)||0));return(0,y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,y.jsx)(`span`,{className:`px-1.5 font-mono text-[10px] tracking-widest uppercase text-muted-foreground`,children:e}),o.map(e=>{let t=n.get(e)||0,o=r===e;return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":o,onClick:()=>a(o?``:e),className:l(`flex w-full cursor-pointer flex-col gap-1 rounded-md px-1.5 py-1 text-left transition-colors hover:bg-accent/50`,o&&`bg-accent`),children:[(0,y.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,y.jsx)(`span`,{className:l(`min-w-0 flex-1 truncate text-xs`,o?`font-medium text-foreground`:`text-muted-foreground`),children:e}),(0,y.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:t})]}),(0,y.jsx)(_,{value:s?Math.round(t/s*100):0,className:l(`h-[5px] bg-muted [&>div]:bg-current`,!i&&`text-primary`),style:i?{color:i(e)}:void 0})]},e)})]})}function A({label:e,value:t,options:n,color:r,withDot:i,onChange:a}){return(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,style:{color:r},children:[i?(0,y.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":`true`}):null,(0,y.jsx)(h,{"aria-label":e,value:t,onChange:e=>a(e.target.value),className:`h-[22px] cursor-pointer border-transparent bg-transparent px-1 py-0 pr-8 font-mono text-[11px] text-inherit shadow-none dark:bg-transparent dark:hover:bg-transparent`,children:n.map(e=>(0,y.jsx)(m,{value:e,children:e},e))})]})}var ge=(0,v.memo)(function({task:e,epicId:t,checked:n,isOpen:r,onToggle:i,onOpen:a,onPatch:o}){let s=(e.depends?.length??0)+ +!!e.parent;return(0,y.jsxs)(x,{className:`h-[var(--row-h)] cursor-pointer`,"data-state":r?`selected`:void 0,tabIndex:0,onClick:()=>a(e.id),onKeyDown:t=>{t.key===`Enter`&&a(e.id)},children:[(0,y.jsx)(C,{className:l(`w-7 border-l-2 border-l-transparent`,r&&`border-l-primary`),onClick:e=>e.stopPropagation(),children:(0,y.jsx)(b,{"aria-label":`Select ${e.id}`,checked:n,onCheckedChange:()=>i(e.id)})}),(0,y.jsx)(C,{className:`font-mono text-xs text-muted-foreground`,children:e.id}),(0,y.jsx)(C,{className:`max-w-[520px]`,children:(0,y.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.claimed_by?(0,y.jsxs)(`span`,{className:`font-mono text-[10px] whitespace-nowrap text-muted-foreground/60`,children:[`· `,e.claimed_by]}):null]})}),(0,y.jsx)(C,{onClick:e=>e.stopPropagation(),children:(0,y.jsx)(A,{label:`Status for ${e.id}`,value:e.status,options:g,color:u(e.status),withDot:!0,onChange:t=>void o(e.id,{status:t}).catch(()=>void 0)})}),(0,y.jsx)(C,{onClick:e=>e.stopPropagation(),children:(0,y.jsx)(A,{label:`Priority for ${e.id}`,value:e.priority,options:p,color:f(e.priority),onChange:t=>void o(e.id,{priority:t}).catch(()=>void 0)})}),(0,y.jsx)(C,{className:`font-mono text-[11px] text-muted-foreground`,children:e.type}),(0,y.jsx)(C,{className:`font-mono text-[11px] text-muted-foreground`,children:e.area}),(0,y.jsxs)(C,{className:`font-mono text-[11px] text-muted-foreground/60`,children:[t?(0,y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a(t)},className:l(`cursor-pointer text-primary hover:underline`,s>0&&`mr-1.5`),children:t}):null,s>0?`${s} ↔`:t?null:`—`]}),(0,y.jsx)(C,{className:`font-mono text-[11px] text-muted-foreground/60`,children:e.updated||`—`})]})});function j({tasks:e,allTasks:t,areas:n,filters:i,setFilters:a,epicIds:c,onOpen:l,onPatch:_,onBulkPatch:C}){let[A,j]=(0,v.useState)(()=>new Set),[_e,ve]=(0,v.useState)(null),[M,ye]=(0,v.useState)(`id`),[N,P]=(0,v.useState)(`desc`),[F,I]=(0,v.useState)(``),[L,R]=(0,v.useState)(``),[z,B]=(0,v.useState)(``),V=(0,v.useRef)(null),[H,be]=(0,v.useState)({start:0,end:40}),[U,xe]=(0,v.useState)(40),W=(0,v.useDeferredValue)(i),G=(0,v.useMemo)(()=>{let e=e=>ce(t,{...W,...e});return{status:O(e({status:``}),`status`),type:O(e({type:``,showIdeas:!0}),`type`),priority:O(e({priority:``}),`priority`),area:O(e({area:``}),`area`)}},[t,W]),K=(0,v.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{let n=0;return n=M===`priority`?(T.get(e.priority)||0)-(T.get(t.priority)||0):M===`status`?(E.get(e.status)||0)-(E.get(t.status)||0):M===`epic`?(c.get(e.id)||``).localeCompare(c.get(t.id)||``):String(e[M]||``).localeCompare(String(t[M]||``),void 0,{numeric:!0}),N===`asc`?n:-n}),t},[c,N,M,e]),q=(0,v.useRef)(0),Se=K.length>0,J=(0,v.useCallback)(()=>{let e=V.current;if(!e)return;let t=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(`--row-h`))||40;xe(t);let n=Math.max(0,Math.floor(e.scrollTop/t)-10),r=Math.ceil(e.clientHeight/t);be({start:n,end:Math.min(q.current,n+r+20)})},[]);(0,v.useEffect)(()=>{let e=V.current;if(!e)return;e.addEventListener(`scroll`,J,{passive:!0}),window.addEventListener(`resize`,J);let t=new MutationObserver(J);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-density`]}),()=>{e.removeEventListener(`scroll`,J),window.removeEventListener(`resize`,J),t.disconnect()}},[J,Se]),(0,v.useEffect)(()=>{q.current=K.length,J()},[J,K.length]);let Ce=[i.search,i.status,i.area,i.type,i.priority,i.milestone,i.showIdeas,i.showClosed,M,N].join(`|`);(0,v.useEffect)(()=>{V.current&&(V.current.scrollTop=0),J()},[Ce,J]);let we=(0,v.useCallback)(e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Te=(0,v.useCallback)(e=>{ve(e),l(e)},[l]),Y=(0,v.useMemo)(()=>K.map(e=>e.id),[K]),X=Y.length>0&&Y.every(e=>A.has(e)),Ee=Y.some(e=>A.has(e)),De=K.slice(H.start,H.end),Z=!!(F||L||z);function Oe(e){M===e?P(e=>e===`asc`?`desc`:`asc`):(ye(e),P(e===`id`?`desc`:`asc`))}async function ke(){let e={};if(F&&(e.status=F),L&&(e.priority=L),z&&(e.area=z),!(!Z||A.size===0))try{await C([...A],e),j(new Set),I(``),R(``),B(``)}catch{}}let Q=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(k,{title:`status`,values:g,counts:G.status,selected:i.status,color:u,onSelect:e=>a(t=>({...t,status:e}))}),(0,y.jsx)(k,{title:`priority`,values:p,counts:G.priority,selected:i.priority,color:f,onSelect:e=>a(t=>({...t,priority:e}))}),(0,y.jsx)(k,{title:`area`,values:n,counts:G.area,selected:i.area,onSelect:e=>a(t=>({...t,area:e}))}),(0,y.jsx)(k,{title:`type`,values:fe,counts:G.type,selected:i.type,onSelect:e=>a(t=>({...t,type:e}))})]}),$=[i.status,i.priority,i.area,i.type].filter(Boolean).length;return(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,y.jsx)(`aside`,{"aria-label":`Backlog facets`,className:`hidden w-[204px] flex-none flex-col gap-5 overflow-y-auto border-r px-3.5 py-4 lg:flex`,children:Q}),(0,y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex flex-none items-center gap-2 px-3.5 pt-2.5 lg:hidden`,children:[(0,y.jsxs)(ne,{children:[(0,y.jsx)(se,{asChild:!0,children:(0,y.jsxs)(d,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5 px-2.5 text-xs`,children:[(0,y.jsx)(o,{className:`size-3.5`}),`Facets`,$?(0,y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:$}):null]})}),(0,y.jsxs)(ie,{side:`left`,className:`w-[280px] gap-0 sm:max-w-[280px]`,children:[(0,y.jsx)(de,{className:`pb-2`,children:(0,y.jsx)(re,{className:`font-mono text-[11px] tracking-wide uppercase`,children:`Facets`})}),(0,y.jsx)(`div`,{className:`flex flex-col gap-5 overflow-y-auto px-4 pb-4`,children:Q})]})]}),(0,y.jsxs)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground/70`,children:[K.length.toLocaleString(),` row`,K.length===1?``:`s`,` · scroll sideways for every column`]})]}),A.size>0&&(0,y.jsxs)(`div`,{role:`region`,"aria-label":`Bulk actions`,className:`mx-3.5 mt-2.5 mb-2.5 flex flex-none flex-wrap items-center gap-2 rounded-md border bg-muted/50 px-3 py-2`,children:[(0,y.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[A.size,` selected`]}),(0,y.jsxs)(h,{"aria-label":`Set status`,value:F,onChange:e=>I(e.target.value),className:`h-7 px-2 py-0 pr-8 text-xs`,children:[(0,y.jsx)(m,{value:``,children:`status…`}),g.map(e=>(0,y.jsx)(m,{value:e,children:e},e))]}),(0,y.jsxs)(h,{"aria-label":`Set priority`,value:L,onChange:e=>R(e.target.value),className:`h-7 px-2 py-0 pr-8 text-xs`,children:[(0,y.jsx)(m,{value:``,children:`priority…`}),p.map(e=>(0,y.jsx)(m,{value:e,children:e},e))]}),(0,y.jsxs)(h,{"aria-label":`Set area`,value:z,onChange:e=>B(e.target.value),className:`h-7 px-2 py-0 pr-8 text-xs`,children:[(0,y.jsx)(m,{value:``,children:`area…`}),n.map(e=>(0,y.jsx)(m,{value:e,children:e},e))]}),(0,y.jsxs)(te,{children:[(0,y.jsx)(d,{size:`sm`,className:`h-7`,disabled:!Z,onClick:()=>void ke(),children:`Apply`}),(0,y.jsx)(d,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>j(new Set),children:`Clear`})]})]}),K.length===0?(0,y.jsx)(ue,{children:(0,y.jsxs)(ae,{children:[(0,y.jsx)(oe,{children:`No cards match`}),(0,y.jsx)(le,{children:`Adjust filters or clear the search`})]})}):(0,y.jsx)(`div`,{ref:V,className:`min-w-0 flex-1 overflow-auto [&>[data-slot=table-container]]:overflow-visible`,children:(0,y.jsxs)(pe,{className:`text-[13px]`,children:[(0,y.jsx)(me,{children:(0,y.jsxs)(x,{className:`hover:bg-transparent`,children:[(0,y.jsx)(S,{className:`sticky top-0 z-10 w-7 bg-background`,children:(0,y.jsx)(b,{"aria-label":`Select all matching cards`,checked:X?!0:Ee?`indeterminate`:!1,onCheckedChange:()=>j(e=>{let t=new Set(e);return X?Y.forEach(e=>t.delete(e)):Y.forEach(e=>t.add(e)),t})})}),w.map(([e,t])=>(0,y.jsx)(S,{"aria-sort":M===e?N===`asc`?`ascending`:`descending`:`none`,className:`sticky top-0 z-10 bg-background`,children:(0,y.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>Oe(e),className:`-ml-2 h-7 gap-1 px-2 text-xs text-muted-foreground`,children:[t,M===e?N===`asc`?(0,y.jsx)(s,{className:`size-3`}):(0,y.jsx)(r,{className:`size-3`}):(0,y.jsx)(ee,{className:`size-3 opacity-50`})]})},e))]})}),(0,y.jsxs)(he,{children:[H.start>0&&(0,y.jsx)(`tr`,{"aria-hidden":`true`,children:(0,y.jsx)(`td`,{colSpan:D,style:{height:H.start*U}})}),De.map(e=>(0,y.jsx)(ge,{task:e,epicId:c.get(e.id)||``,checked:A.has(e.id),isOpen:_e===e.id,onToggle:we,onOpen:Te,onPatch:_},e.id)),H.end<K.length&&(0,y.jsx)(`tr`,{"aria-hidden":`true`,children:(0,y.jsx)(`td`,{colSpan:D,style:{height:(K.length-H.end)*U}})})]})]})})]})]})}export{j as Explorer};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{vt as r}from"./ui-primitives-Beqd9I2k.js";import{i,o as a,s as o}from"./theme-CNCrPl--.js";import{D as s,L as c,M as l,N as u,P as d,R as f,W as p,ct as m,j as h,k as g,ot as _,st as v,z as y}from"./index-Dpy209ef.js";var b=e(t(),1),x=n(),S=[{level:`error`,label:`errors`,hint:`must be fixed for a consistent workspace`,zeroHint:`the doctor does not block the release`},{level:`warning`,label:`warnings`,hint:`worth a look, nothing is broken yet`,zeroHint:`nothing worth flagging`},{level:`info`,label:`infos`,hint:`informational, no action required`,zeroHint:`no notices from the doctor`}];function C(e){return e.replace(/[-_.]+/g,` `)}var w={error:0,warning:1,info:2};function T({onOpen:e}){let[t,n]=(0,b.useState)(null),[T,E]=(0,b.useState)(``),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0);c(()=>A(e=>e+1)),(0,b.useEffect)(()=>{let e=!0;return p.health().then(t=>{e&&n(t)}).catch(t=>{e&&E(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[k]);let j=(0,b.useMemo)(()=>{if(!t)return[];let e=D?t.issues.filter(e=>e.severity===D):t.issues,n=new Map;for(let t of e){let e=n.get(t.code);e?e.push(t):n.set(t.code,[t])}return[...n.entries()].sort(([e,[t]],[n,[r]])=>{let i=w[t.severity]-w[r.severity];return i===0?e.localeCompare(n):i})},[t,D]);if(T)return(0,x.jsx)(`div`,{className:`p-3.5`,children:(0,x.jsx)(v,{variant:`destructive`,children:(0,x.jsx)(m,{children:T})})});if(!t)return(0,x.jsxs)(`div`,{className:`flex items-center gap-2 p-3.5`,"aria-busy":`true`,children:[(0,x.jsx)(s,{className:`size-3 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:`running workfile doctor…`})]});let M=[[`cards`,t.modules?.cards??t.cards],[`docs`,t.modules?.docs],[`memory`,t.modules?.memory],[`changelog`,t.modules?.changelog]].filter(([,e])=>e!=null).map(([e,t])=>`${t.toLocaleString()} ${e}`).join(`, `),N=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.generatedAt));return(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-3.5`,children:[(0,x.jsx)(`div`,{className:`mb-2.5 flex gap-1.5`,children:S.map(({level:e,label:n})=>(0,x.jsxs)(o,{type:`button`,variant:`outline`,size:`sm`,"aria-pressed":D===e,className:`aria-pressed:border-ring aria-pressed:bg-accent`,onClick:()=>O(t=>t===e?``:e),children:[n,(0,x.jsx)(_,{variant:`secondary`,className:`px-1.5 font-mono text-[10.5px]`,children:t.counts[e]})]},e))}),(0,x.jsx)(`div`,{className:`flex flex-wrap gap-2.5`,children:S.map(({level:e,label:n,hint:r,zeroHint:o})=>{let s=t.counts[e],c=e===`error`&&s===0?a(`done`):i(e);return(0,x.jsxs)(y,{className:`relative min-w-[13rem] flex-1 gap-1 py-3 pl-5 pr-3.5`,children:[(0,x.jsx)(f,{edge:`left`,color:c}),(0,x.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,x.jsx)(`span`,{className:`text-[26px] font-semibold tracking-tight`,style:{color:c},children:s}),(0,x.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:n})]}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s===0?o:r})]},e)})}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 px-0.5 pt-4 pb-2`,children:[(0,x.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`grouped by code · `,M,` · checked `,N]}),(0,x.jsx)(`span`,{className:`ml-auto font-mono text-[10.5px] text-muted-foreground/70`,children:`workfile doctor --json`})]}),j.length===0?(0,x.jsx)(g,{className:`gap-2 p-10`,children:(0,x.jsxs)(l,{children:[(0,x.jsx)(u,{children:(0,x.jsx)(r,{"aria-hidden":`true`,size:20,style:{color:a(`done`)}})}),(0,x.jsx)(d,{className:`text-sm`,children:`All clear`}),(0,x.jsxs)(h,{className:`text-[12.5px]`,children:[`No `,D||`integrity`,` issues found.`]})]})}):(0,x.jsx)(`div`,{className:`flex flex-col gap-2`,children:j.map(([t,n])=>(0,x.jsxs)(y,{className:`gap-0 overflow-hidden py-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1.5`,children:[(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`size-[7px] rounded-full bg-current`,style:{color:i(n[0].severity)}}),(0,x.jsx)(`span`,{className:`font-mono text-[11.5px]`,children:t}),(0,x.jsx)(`span`,{className:`flex-1 text-[12.5px] text-muted-foreground`,children:C(t)}),(0,x.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/70`,children:n.length})]}),n.map((t,n)=>(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 border-b px-3 py-[7px] last:border-0`,children:[t.id?(0,x.jsx)(o,{type:`button`,variant:`link`,className:`h-auto w-[82px] flex-[0_0_82px] justify-start p-0 font-mono text-[11px] font-normal`,onClick:()=>e(t.id),children:t.id}):(0,x.jsx)(`span`,{className:`w-[82px] flex-[0_0_82px] font-mono text-[11px] text-muted-foreground/70`,children:`—`}),(0,x.jsx)(`span`,{className:`min-w-[12rem] flex-1 text-[12.5px] text-muted-foreground`,children:t.message}),t.file?(0,x.jsx)(`span`,{className:`max-w-full truncate font-mono text-[10.5px] text-muted-foreground/70 sm:max-w-80`,title:t.file,children:t.file}):null]},`${t.id||t.file}-${n}`))]},t))})]})}export{T as HealthView};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{Ct as r,L as i,Z as a,wt as o}from"./ui-primitives-Beqd9I2k.js";import{c as s,i as c,o as l,r as u,s as d}from"./theme-CNCrPl--.js";import{$ as f,B as p,C as m,E as h,F as g,H as ee,I as _,L as te,O as v,S as y,U as b,V as x,W as S,X as C,at as ne,b as w,c as T,ct as E,d as D,et as O,f as k,g as A,h as j,j as re,k as ie,l as M,ot as ae,p as N,st as P,tt as F,u as I,z as oe}from"./index-Dpy209ef.js";import{t as se}from"./layout-QiuZ_k5v.js";var L=e(t(),1),R=n(),z=`text-[10px] font-medium tracking-widest uppercase text-muted-foreground`;function B(e){switch(e){case`added`:return l(`done`);case`changed`:return l(`doing`);case`fixed`:return l(`review`);case`removed`:return l(`blocked`);case`security`:return c(`error`);default:return l(`backlog`)}}function ce(e,t){let n=null;for(let t of e){let e=/^v?(\d+)\.(\d+)\.(\d+)/.exec(t.version);if(!e)continue;let r=[Number(e[1]),Number(e[2]),Number(e[3])];(n?r[0]-n[0]||r[1]-n[1]||r[2]-n[2]:1)>0&&(n=r)}return n?t.some(e=>[`added`,`removed`,`deprecated`].includes(e.type))?`${n[0]}.${n[1]+1}.0`:`${n[0]}.${n[1]}.${n[2]+1}`:`0.1.0`}function V(e){return e instanceof Error?e.message:String(e)}function H({label:e,value:t,options:n,onChange:r}){return(0,R.jsxs)(f,{children:[(0,R.jsx)(ne,{asChild:!0,children:(0,R.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e,className:s(`h-7 gap-1 px-2 text-xs`,t&&`border-ring bg-accent`),children:[e,(0,R.jsx)(`span`,{className:s(`font-normal`,!t&&`text-muted-foreground`),children:t||`all`}),(0,R.jsx)(o,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`})]})}),(0,R.jsxs)(F,{align:`start`,children:[(0,R.jsx)(O,{checked:!t,onSelect:()=>r(``),children:`all`}),n.map(e=>(0,R.jsx)(O,{checked:t===e,onSelect:()=>r(e),children:e},e))]})]})}function U({record:e,selected:t,onSelect:n}){let r=e.kind===`release`?`release`:e.type,i=e.kind===`release`?`var(--primary)`:B(e.type),a=e.kind===`release`?`${e.fragments.length} fragment${e.fragments.length===1?``:`s`} · ${e.date}`:e.area;return(0,R.jsx)(v,{asChild:!0,variant:`outline`,size:`sm`,children:(0,R.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:s(`flex-col flex-nowrap items-stretch gap-1 px-2.5 py-2 text-left shadow-xs`,t?`border-ring bg-accent`:`bg-card hover:border-ring`),children:[(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,R.jsx)(`span`,{className:`font-mono text-[10px]`,style:{color:i},children:r}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(`span`,{className:`max-w-[170px] truncate font-mono text-[10px] text-muted-foreground/70`,children:a})]}),(0,R.jsx)(`span`,{className:`text-sm leading-snug font-normal`,children:e.title})]})})}function W({label:e,records:t,selectedId:n,onSelect:r}){return t.length?(0,R.jsxs)(`div`,{role:`group`,"aria-label":e,className:`flex flex-col gap-1.5 pt-4`,children:[(0,R.jsxs)(`span`,{className:z,children:[e,` · `,t.length]}),t.map(e=>(0,R.jsx)(U,{record:e,selected:e.id===n,onSelect:()=>r(e.id)},e.id))]}):null}function G({id:e,title:t,relation:n,disabled:r,onOpen:i}){return(0,R.jsx)(v,{asChild:!0,variant:`outline`,size:`sm`,children:(0,R.jsxs)(`button`,{type:`button`,disabled:r,onClick:i,className:`flex-nowrap gap-2 bg-card px-2.5 py-1.5 text-left shadow-xs hover:border-ring disabled:pointer-events-none disabled:opacity-55`,children:[(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px]`,children:t}),n?(0,R.jsx)(ae,{variant:`outline`,className:`shrink-0 font-mono text-[10px] font-normal text-muted-foreground`,children:n}):null]})})}function K({label:e,links:t,onOpen:n}){return t.length?(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`span`,{className:z,children:e}),t.map(t=>(0,R.jsx)(G,{id:t.id,title:t.title,relation:t.relation,disabled:t.disabled,onOpen:()=>n(t.id)},`${e}-${t.id}`))]}):null}function le(e){return e.map(e=>({id:e.id,title:e.title||`Missing record`,relation:e.relation,disabled:!e.exists&&!e.title}))}function ue({schema:e,areas:t,onClose:n,onCreated:r}){let[i,a]=(0,L.useState)({title:``,type:e.defaults.type,area:t[0]||`general`,visibility:e.defaults.visibility,body:``}),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),u=(e,t)=>a(n=>({...n,[e]:t})),f=async()=>{s(!0);try{r((await S.createChange(i)).record)}catch(e){l(V(e))}finally{s(!1)}};return(0,R.jsx)(T,{open:!0,onOpenChange:e=>{e||n()},children:(0,R.jsxs)(M,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsxs)(k,{children:[(0,R.jsx)(N,{children:`New change fragment`}),(0,R.jsx)(I,{children:`Record one user- or operator-meaningful change.`})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`new-fragment-title`,children:`Title`}),(0,R.jsx)(C,{id:`new-fragment-title`,autoFocus:!0,required:!0,maxLength:120,value:i.title,onChange:e=>u(`title`,e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`new-fragment-type`,children:`Type`}),(0,R.jsx)(j,{id:`new-fragment-type`,value:i.type,onChange:e=>u(`type`,e.target.value),children:e.types.map(e=>(0,R.jsx)(A,{value:e,children:e},e))})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`new-fragment-area`,children:`Area`}),(0,R.jsx)(j,{id:`new-fragment-area`,value:i.area,onChange:e=>u(`area`,e.target.value),children:t.map(e=>(0,R.jsx)(A,{value:e,children:e},e))})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`new-fragment-visibility`,children:`Visibility`}),(0,R.jsx)(j,{id:`new-fragment-visibility`,value:i.visibility,onChange:e=>u(`visibility`,e.target.value),children:e.visibilities.map(e=>(0,R.jsx)(A,{value:e,children:e},e))})]})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`new-fragment-details`,children:`Details`}),(0,R.jsx)(h,{id:`new-fragment-details`,rows:5,value:i.body,onChange:e=>u(`body`,e.target.value)})]}),c?(0,R.jsx)(P,{variant:`destructive`,"aria-live":`polite`,children:(0,R.jsx)(E,{children:c})}):null,(0,R.jsxs)(D,{children:[(0,R.jsx)(d,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,R.jsx)(d,{type:`button`,disabled:o||!i.title.trim(),onClick:()=>void f(),children:o?`Saving…`:`Create fragment`})]})]})})}function de({preview:e,suggestedVersion:t,onClose:n,onReleased:r}){let[i,a]=(0,L.useState)(t),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(!1),[u,f]=(0,L.useState)(``),p=async()=>{l(!0);try{await S.createRelease({version:i,title:o||void 0,fragmentIds:e.fragments.map(e=>e.id)}),r()}catch(e){f(V(e))}finally{l(!1)}};return(0,R.jsx)(T,{open:!0,onOpenChange:e=>{e||n()},children:(0,R.jsxs)(M,{className:`flex max-h-[85vh] flex-col sm:max-w-[640px]`,children:[(0,R.jsxs)(k,{children:[(0,R.jsx)(N,{children:`Release preparation`}),(0,R.jsxs)(I,{children:[e.fragments.length,` unreleased fragment`,e.fragments.length===1?``:`s`,` selected.`]})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[150px_1fr] gap-2.5`,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`release-version`,children:`Version`}),(0,R.jsx)(C,{id:`release-version`,className:`font-mono`,placeholder:`2.4.0`,value:i,onChange:e=>a(e.target.value)})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`release-title`,children:`Release title`}),(0,R.jsx)(C,{id:`release-title`,placeholder:`Optional curated title`,value:o,onChange:e=>s(e.target.value)})]})]}),e.groups.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`span`,{className:z,style:{color:B(e.type)},children:[e.type,` · `,e.fragments.length]}),e.fragments.map(e=>(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2 text-[12.5px]`,children:[(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground/70`,children:e.area})]},e.id))]},e.type)),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:z,children:`release notes preview`}),(0,R.jsx)(`div`,{className:`max-h-[220px] overflow-y-auto rounded-md border bg-background px-3 py-1`,children:(0,R.jsx)(m,{source:e.markdown||`No release notes to render.`})})]}),u?(0,R.jsx)(P,{variant:`destructive`,"aria-live":`polite`,children:(0,R.jsx)(E,{children:u})}):null]}),(0,R.jsxs)(D,{children:[(0,R.jsx)(d,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,R.jsx)(d,{type:`button`,disabled:c||!i.trim()||!e.fragments.length,onClick:()=>void p(),children:c?`Releasing…`:`Create release`})]})]})})}function fe({record:e,schema:t,areas:n,onSaved:r}){let[i,a]=(0,L.useState)({title:e.title,type:e.type,area:e.area,visibility:e.visibility}),[o,s]=(0,L.useState)(!1),[l,u]=(0,L.useState)(``),f=(e,t)=>a(n=>({...n,[e]:t})),m={};for(let t of[`title`,`type`,`area`,`visibility`])i[t]!==e[t]&&(m[t]=i[t]);let h=Object.keys(m).length>0,g=n.includes(e.area)?n:[e.area,...n],_=async()=>{s(!0);try{let t=await S.patchChange(e.id,m,e.revision);u(``),r(t.record)}catch(e){u(V(e))}finally{s(!1)}};return(0,R.jsxs)(oe,{className:`gap-2.5 rounded-lg py-3 shadow-xs`,children:[(0,R.jsx)(ee,{className:`px-3`,children:(0,R.jsx)(b,{className:z,children:`edit fragment`})}),(0,R.jsxs)(p,{className:`flex flex-col gap-2.5 px-3`,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`edit-fragment-title`,children:`Title`}),(0,R.jsx)(C,{id:`edit-fragment-title`,maxLength:120,value:i.title,onChange:e=>f(`title`,e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:[(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`edit-fragment-type`,children:`Type`}),(0,R.jsx)(j,{id:`edit-fragment-type`,value:i.type,onChange:e=>f(`type`,e.target.value),children:t.types.map(e=>(0,R.jsx)(A,{value:e,children:e},e))})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`edit-fragment-area`,children:`Area`}),(0,R.jsx)(j,{id:`edit-fragment-area`,value:i.area,onChange:e=>f(`area`,e.target.value),children:g.map(e=>(0,R.jsx)(A,{value:e,children:e},e))})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(y,{htmlFor:`edit-fragment-visibility`,children:`Visibility`}),(0,R.jsx)(j,{id:`edit-fragment-visibility`,value:i.visibility,onChange:e=>f(`visibility`,e.target.value),children:t.visibilities.map(e=>(0,R.jsx)(A,{value:e,children:e},e))})]})]})]}),(0,R.jsxs)(x,{className:`gap-2.5 px-3`,children:[l?(0,R.jsx)(`span`,{className:`flex-1 text-xs`,style:{color:c(`error`)},"aria-live":`polite`,children:l}):(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,disabled:o||!h||!i.title.trim(),onClick:()=>void _(),children:o?`Saving…`:`Save changes`})]})]})}function pe({selectedId:e,onSelect:t,onOpenRecord:n,schema:o,areas:l}){let[f,p]=(0,L.useState)([]),[h,ee]=(0,L.useState)(``),[v,y]=(0,L.useState)(``),[b,x]=(0,L.useState)(``),[ne,w]=(0,L.useState)(!0),[T,D]=(0,L.useState)(``),[O,k]=(0,L.useState)(``),[A,j]=(0,L.useState)(!1),[M,N]=(0,L.useState)(null),[F,I]=(0,L.useState)(`public`),[z,U]=(0,L.useState)({content:``,error:``,loading:!0}),[G,pe]=(0,L.useState)(0),me=()=>pe(e=>e+1);te(e=>{_(e,`/changelog/`)&&me()}),(0,L.useEffect)(()=>{let e=!1,t=async()=>{w(!0);try{let t=await S.changelog(h.trim(),{state:v||void 0,visibility:b||void 0});if(e)return;p(t.records),D(``)}catch(t){e||D(V(t))}finally{e||w(!1)}},n=window.setTimeout(()=>void t(),h?180:0);return()=>{e=!0,window.clearTimeout(n)}},[h,v,b,G]),(0,L.useEffect)(()=>{let e=!1;return U(e=>({...e,loading:!0})),S.renderedChangelog(F).then(t=>{e||U({content:t.content,error:``,loading:!1})}).catch(t=>{e||U({content:``,error:V(t),loading:!1})}),()=>{e=!0}},[F,G]);let q=(0,L.useMemo)(()=>[...f].sort((e,t)=>{if(e.kind!==t.kind)return e.kind===`change`?-1:1;if(e.kind===`release`&&t.kind===`release`){let n=t.date.localeCompare(e.date);return n===0?t.id.localeCompare(e.id):n}return String(t.updated||``).localeCompare(String(e.updated||``))}),[f]),J=(0,L.useMemo)(()=>new Map(f.map(e=>[e.id,e])),[f]),Y=(0,L.useMemo)(()=>q.filter(e=>e.kind===`change`&&!e.released),[q]),he=(0,L.useMemo)(()=>q.filter(e=>e.kind===`change`&&e.released),[q]),X=(0,L.useMemo)(()=>q.filter(e=>e.kind===`release`),[q]),Z=(0,L.useMemo)(()=>ce(X,Y),[X,Y]),Q=e?J.get(e):void 0,$=e=>{if(J.has(e)){t(e);return}if(/^(CHG|REL)-/.test(e)){y(``),x(``),t(e);return}n(e)},ge=()=>{k(``),S.releasePreview().then(N).catch(e=>k(V(e)))},_e=Q?.issues.some(e=>e.severity===`error`)?`destructive`:`default`,ve=(0,R.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>j(!0),children:[(0,R.jsx)(a,{"aria-hidden":`true`}),`New fragment`]});return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:s(`w-full shrink-0 flex-col border-r lg:flex lg:w-[400px]`,Q?`hidden`:`flex`),children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 p-3.5 pb-0`,children:[(0,R.jsxs)(oe,{className:`flex-row items-center gap-2.5 border-primary bg-primary/10 p-3`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`text-[13px] font-semibold`,children:[Y.length,` unpublished fragment`,Y.length===1?``:`s`]}),(0,R.jsxs)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground`,children:[`next: `,Z,` ·`,` `,o.releaseStrategy]})]}),(0,R.jsx)(d,{type:`button`,size:`sm`,className:`whitespace-nowrap`,onClick:ge,children:`Prepare release`})]}),O?(0,R.jsx)(P,{variant:`destructive`,"aria-live":`polite`,children:(0,R.jsx)(E,{children:O})}):null,(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(C,{type:`search`,"aria-label":`Search history`,placeholder:`Search fragments and releases…`,value:h,onChange:e=>ee(e.target.value),className:`h-7 flex-1 px-2.5 text-xs md:text-xs`}),(0,R.jsx)(H,{label:`state`,value:v,options:[`unreleased`,`released`],onChange:y}),(0,R.jsx)(H,{label:`visibility`,value:b,options:o.visibilities,onChange:x})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3.5 pb-6 [mask-image:linear-gradient(to_bottom,black_calc(100%-24px),transparent)]`,children:ne?(0,R.jsx)(`div`,{"aria-busy":`true`,className:`flex flex-col gap-2 pt-4`,children:Array.from({length:6},(e,t)=>(0,R.jsx)(`div`,{className:`h-[52px] animate-pulse rounded-md bg-muted`},t))}):T?(0,R.jsx)(P,{variant:`destructive`,className:`mt-4`,"aria-live":`polite`,children:(0,R.jsx)(E,{children:T})}):q.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(W,{label:`unpublished`,records:Y,selectedId:e,onSelect:t}),(0,R.jsx)(W,{label:`releases`,records:X,selectedId:e,onSelect:t}),(0,R.jsx)(W,{label:`published fragments`,records:he,selectedId:e,onSelect:t})]}):(0,R.jsx)(ie,{className:`mt-4 gap-1 p-4 md:p-4`,children:(0,R.jsx)(re,{className:`text-xs`,children:`No history records match the filters.`})})})]}),(0,R.jsx)(`div`,{className:s(`min-w-0 flex-1 overflow-y-auto px-6 py-5 sm:px-8.5`,Q?`block`:`hidden lg:block`),children:(0,R.jsx)(`div`,{className:se,children:Q?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-2 mb-2 lg:hidden`,onClick:()=>t(``),children:[(0,R.jsx)(r,{"aria-hidden":`true`}),`All history`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[11px]`,children:[(0,R.jsx)(`span`,{className:`whitespace-nowrap text-primary`,children:Q.id}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:Q.kind}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),Q.kind===`change`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{style:{color:B(Q.type)},children:Q.type}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Q.area}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Q.visibility}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{style:{color:u(Q.released?`released`:`unreleased`)},children:Q.released?`released`:`unreleased`}),Q.updated?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:Q.updated})]}):null]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-primary`,children:Q.version}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Q.date}),Q.commit?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:Q.commit})]}):null,(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[Q.fragments.length,` fragment`,Q.fragments.length===1?``:`s`]})]}),(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[ve,(0,R.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close record`,title:`Back to the derived changelog`,onClick:()=>t(``),children:(0,R.jsx)(i,{"aria-hidden":`true`})})]})]}),(0,R.jsx)(`h2`,{className:`mt-2.5 mb-1 text-[26px] leading-tight font-semibold tracking-tight [text-wrap:pretty]`,children:Q.title}),(0,R.jsx)(`div`,{className:`font-mono text-[10.5px] break-all text-muted-foreground/70`,children:Q.path}),Q.issues.length>0?(0,R.jsx)(P,{variant:_e,className:`mt-3.5`,children:(0,R.jsx)(E,{className:`w-full gap-1`,children:Q.issues.map(e=>(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10.5px]`,style:{color:c(e.severity)},children:e.severity}),(0,R.jsx)(`span`,{children:e.message})]},`${e.code}-${e.message}`))})}):null,(0,R.jsx)(`div`,{className:`mt-4.5`,children:(0,R.jsx)(m,{source:Q.body||`No additional notes.`,onOpen:$})}),(0,R.jsxs)(`div`,{className:`mt-5.5 flex flex-col gap-3.5`,children:[Q.kind===`change`?(0,R.jsx)(K,{label:`shipped in`,links:(Q.releaseIds||[]).map(e=>({id:e,title:J.get(e)?.title||`Open release`,relation:`release`})),onOpen:$}):(0,R.jsx)(K,{label:`fragments · ${Q.fragments.length}`,links:Q.fragments.map(e=>{let t=J.get(e);return{id:e,title:t?.title||`Open fragment`,relation:t?.kind===`change`?t.type:void 0}}),onOpen:$}),(0,R.jsx)(K,{label:`links to`,links:le(Q.outgoing),onOpen:$}),(0,R.jsx)(K,{label:`backlinks`,links:le(Q.incoming),onOpen:$})]}),Q.kind===`change`?(0,R.jsx)(`div`,{className:`mt-5.5`,children:(0,R.jsx)(fe,{record:Q,schema:o,areas:l,onSaved:e=>p(t=>t.map(t=>t.id===e.id?e:t))},`${Q.id}:${Q.revision}`)}):null]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-2 border-b pb-3`,children:[(0,R.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Derived changelog`}),(0,R.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`visibility `,F,` · CHANGELOG.md`]}),(0,R.jsxs)(`span`,{className:`ml-auto flex flex-wrap items-center gap-2.5`,children:[(0,R.jsx)(g,{children:o.visibilities.map(e=>(0,R.jsx)(d,{type:`button`,size:`sm`,variant:F===e?`default`:`outline`,"aria-pressed":F===e,className:`h-7 px-2.5 text-xs`,onClick:()=>I(e),children:e},e))}),(0,R.jsx)(ae,{variant:`outline`,className:`rounded-md font-mono text-[10.5px] font-normal whitespace-nowrap text-muted-foreground`,children:`render --write`}),ve]})]}),z.error?(0,R.jsx)(P,{variant:`destructive`,className:`mt-4`,"aria-live":`polite`,children:(0,R.jsx)(E,{children:z.error})}):(0,R.jsx)(`pre`,{className:`mt-4 font-mono text-xs leading-[1.75] whitespace-pre-wrap text-muted-foreground`,"aria-busy":z.loading||void 0,children:z.loading&&!z.content?`Rendering…`:z.content||`Nothing to render yet — create the first change fragment.`})]})})}),A?(0,R.jsx)(ue,{schema:o,areas:l,onClose:()=>j(!1),onCreated:e=>{j(!1),p(t=>[e,...t]),t(e.id)}}):null,M?(0,R.jsx)(de,{preview:M,suggestedVersion:Z,onClose:()=>N(null),onReleased:()=>{N(null),me()}}):null]})}export{pe as HistoryView};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{K as r,Q as i,Tt as a,X as o,Z as s,lt as c,wt as l}from"./ui-primitives-Beqd9I2k.js";import{c as u,i as d,r as f,s as p}from"./theme-CNCrPl--.js";import{$ as m,B as h,C as g,D as _,E as v,H as y,I as b,L as ee,O as x,S,W as C,X as w,_ as te,at as T,b as E,c as D,ct as O,d as k,f as A,g as j,h as M,j as N,k as ne,l as P,nt as F,ot as I,p as L,st as R,tt as re,v as ie,y as z,z as B}from"./index-Dpy209ef.js";var V=e(t(),1),H=n(),U=[`low`,`medium`,`high`],W=[`critical`,`high`,`medium`,`low`],ae=`[mask-image:linear-gradient(to_bottom,black_calc(100%_-_24px),transparent)]`;function oe(e){return e&&e[0].toUpperCase()+e.slice(1)}function G(e,t){return`${e} ${t}${e===1?``:`s`}`}function K(e){return{category:e===`learnings`||e===`decisions`,confidence:e===`learnings`,severity:e===`incidents`,expires:e===`context`,review_after:e===`context`}}function se(e){let t=[];switch(e.collection){case`learnings`:t.push(e.confidence,e.category,e.occurrences==null?null:`${e.occurrences}×`);break;case`decisions`:e.superseded_by?.length?t.push(`superseded by ${e.superseded_by.join(`, `)}`):e.supersedes?.length?t.push(`supersedes ${e.supersedes.join(`, `)}`):t.push(e.category);break;case`incidents`:t.push(e.severity,e.corrective_actions?.length?G(e.corrective_actions.length,`corrective action`):null);break;case`conventions`:t.push(e.owners?.length?e.owners.join(`, `):`no owner`);break;case`context`:t.push(e.expires?`expires ${e.expires}`:null,e.review_after?`review after ${e.review_after}`:null);break;default:t.push(e.category,e.severity)}return t.filter(Boolean).join(` · `)}function q({label:e,value:t,options:n,allLabel:r=`all`,onChange:i}){return(0,H.jsxs)(m,{children:[(0,H.jsx)(T,{asChild:!0,children:(0,H.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e,className:u(`h-7 gap-1 rounded-full px-2.5 text-xs`,t&&`border-ring bg-accent`),children:[e,(0,H.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:t||r}),(0,H.jsx)(l,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`})]})}),(0,H.jsxs)(re,{align:`start`,sideOffset:4,children:[(0,H.jsxs)(F,{onSelect:()=>i(``),children:[r,t?null:(0,H.jsx)(a,{"aria-hidden":`true`,className:`ml-auto`})]}),n.map(e=>(0,H.jsxs)(F,{onSelect:()=>i(e.value),children:[e.color?(0,H.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:e.color},"aria-hidden":`true`}):null,e.label??e.value,t===e.value?(0,H.jsx)(a,{"aria-hidden":`true`,className:`ml-auto`}):null]},e.value))]})]})}function J({id:e,label:t,children:n}){return(0,H.jsxs)(E,{className:`gap-1.5 [&_[data-slot=native-select-wrapper]]:w-full`,children:[(0,H.jsx)(S,{htmlFor:e,children:t}),n]})}function ce({record:e,selected:t,onSelect:n}){let r=se(e),i=e.lifecycleIssues?.length||0;return(0,H.jsx)(x,{asChild:!0,variant:`outline`,size:`sm`,className:`w-full flex-none flex-col items-stretch gap-1 rounded-lg bg-background px-2.5 py-2 text-left shadow-xs hover:border-ring aria-[current=true]:border-ring aria-[current=true]:bg-accent`,children:(0,H.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,children:[(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,H.jsxs)(I,{variant:`outline`,className:`h-[18px] gap-1 rounded-md px-1.5 font-mono text-[10px] font-medium`,children:[(0,H.jsx)(`span`,{className:`size-[5px] shrink-0 rounded-full`,style:{backgroundColor:f(e.status)},"aria-hidden":`true`}),e.status]})]}),(0,H.jsx)(`span`,{className:`text-[13px] font-medium leading-snug`,children:e.title}),r||i?(0,H.jsxs)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground`,children:[r,r&&i?` · `:null,i?(0,H.jsx)(`span`,{style:{color:d(`warning`)},children:G(i,`lifecycle warning`)}):null]}):null]})})}function Y({issues:e,kind:t}){return e.length?(0,H.jsx)(H.Fragment,{children:e.map(e=>(0,H.jsx)(R,{variant:e.severity===`error`?`destructive`:`default`,className:`px-3 py-2`,children:(0,H.jsxs)(O,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[10.5px]`,style:{color:d(e.severity)},children:t===`lifecycle`?`lifecycle`:e.severity}),(0,H.jsx)(`span`,{children:e.message})]})},`${t}-${e.code}-${e.message}`))}):null}function X({label:e,links:t,onOpen:n}){return t.length?(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),t.map(t=>{let r=!t.exists&&!t.title;return(0,H.jsx)(x,{asChild:!0,variant:`outline`,size:`sm`,className:`gap-2 rounded-lg px-2.5 py-2 text-left hover:border-ring disabled:pointer-events-none disabled:opacity-50`,children:(0,H.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>n(t.id),children:[(0,H.jsx)(`span`,{className:`w-[78px] shrink-0 truncate font-mono text-[11px] font-medium`,children:t.id}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:t.title||`Missing record`}),(t.relations??[t.relation||t.kind]).filter(Boolean).map(e=>(0,H.jsx)(I,{variant:`secondary`,className:`h-[18px] rounded-md px-1.5 font-mono text-[10px] font-medium`,children:e},e))]})},`${e}-${t.id}`)})]}):null}function Z({message:e}){return e?(0,H.jsx)(R,{variant:`destructive`,className:`px-3 py-2`,children:(0,H.jsx)(O,{children:e})}):null}function le({schema:e,initialCollection:t,onClose:n,onCreated:r}){let i=e.collections.find(e=>e.id===t)||e.collections[0],[a,o]=(0,V.useState)({collection:i?.id||`learnings`,status:i?.statuses[0]||`active`,title:``,category:``,confidence:``,severity:``,expires:``,body:``}),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``),d=e.collections.find(e=>e.id===a.collection),f=K(a.collection),m=(e,t)=>o(n=>({...n,[e]:t})),h=t=>{let n=e.collections.find(e=>e.id===t);o(e=>({...e,collection:t,status:n?.statuses[0]||`active`}))},g=async()=>{c(!0);try{r((await C.createMemory({collection:a.collection,title:a.title,status:a.status,body:a.body,category:a.category||void 0,confidence:a.confidence||void 0,severity:a.severity||void 0,expires:a.expires||void 0})).record)}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}};return(0,H.jsx)(D,{open:!0,onOpenChange:e=>{e||n()},children:(0,H.jsxs)(P,{className:`sm:max-w-[520px]`,"aria-describedby":void 0,children:[(0,H.jsx)(A,{children:(0,H.jsxs)(L,{children:[`New `,d?.singular||`record`]})}),(0,H.jsxs)(`div`,{className:`-m-1 flex max-h-[65vh] flex-col gap-3 overflow-y-auto p-1`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,H.jsx)(J,{id:`memory-create-collection`,label:`Collection`,children:(0,H.jsx)(M,{id:`memory-create-collection`,value:a.collection,onChange:e=>h(e.target.value),children:e.collections.map(e=>(0,H.jsx)(j,{value:e.id,children:e.id},e.id))})}),(0,H.jsx)(J,{id:`memory-create-status`,label:`Status`,children:(0,H.jsx)(M,{id:`memory-create-status`,value:a.status,onChange:e=>m(`status`,e.target.value),children:(d?.statuses||[]).map(e=>(0,H.jsx)(j,{value:e,children:e},e))})})]}),(0,H.jsx)(J,{id:`memory-create-title`,label:`Title`,children:(0,H.jsx)(w,{id:`memory-create-title`,autoFocus:!0,required:!0,maxLength:120,value:a.title,onChange:e=>m(`title`,e.target.value)})}),f.category||f.confidence||f.severity||f.expires?(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[f.category?(0,H.jsx)(J,{id:`memory-create-category`,label:`Category`,children:(0,H.jsx)(w,{id:`memory-create-category`,value:a.category,onChange:e=>m(`category`,e.target.value)})}):null,f.confidence?(0,H.jsx)(J,{id:`memory-create-confidence`,label:`Confidence`,children:(0,H.jsxs)(M,{id:`memory-create-confidence`,value:a.confidence,onChange:e=>m(`confidence`,e.target.value),children:[(0,H.jsx)(j,{value:``,children:`not set`}),U.map(e=>(0,H.jsx)(j,{value:e,children:e},e))]})}):null,f.severity?(0,H.jsx)(J,{id:`memory-create-severity`,label:`Severity`,children:(0,H.jsxs)(M,{id:`memory-create-severity`,value:a.severity,onChange:e=>m(`severity`,e.target.value),children:[(0,H.jsx)(j,{value:``,children:`not set`}),W.map(e=>(0,H.jsx)(j,{value:e,children:e},e))]})}):null,f.expires?(0,H.jsx)(J,{id:`memory-create-expires`,label:`Expires`,children:(0,H.jsx)(w,{id:`memory-create-expires`,type:`date`,value:a.expires,onChange:e=>m(`expires`,e.target.value)})}):null]}):null,(0,H.jsx)(J,{id:`memory-create-body`,label:`Details`,children:(0,H.jsx)(v,{id:`memory-create-body`,rows:8,value:a.body,onChange:e=>m(`body`,e.target.value)})}),(0,H.jsx)(Z,{message:l})]}),(0,H.jsxs)(k,{children:[(0,H.jsx)(p,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,H.jsx)(p,{type:`button`,disabled:s||!a.title.trim(),onClick:()=>void g(),children:s?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{"aria-hidden":`true`}),`Saving…`]}):`Create record`})]})]})})}function Q({record:e,statuses:t,onClose:n,onUpdated:r}){let i=K(e.collection),[a,o]=(0,V.useState)({title:e.title,status:e.status,category:e.category||``,confidence:e.confidence||``,severity:e.severity||``,expires:e.expires||``,review_after:e.review_after||``,body:e.body}),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``),d=(e,t)=>o(n=>({...n,[e]:t})),f=async()=>{let t={};a.title.trim()&&a.title!==e.title&&(t.title=a.title),a.status!==e.status&&(t.status=a.status),a.body!==e.body&&(t.body=a.body);for(let n of[`category`,`confidence`,`severity`,`expires`,`review_after`])a[n]!==(e[n]||``)&&(t[n]=a[n]||null);if(!Object.keys(t).length){n();return}c(!0);try{r((await C.patchMemory(e.id,t,e.revision)).record),n()}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}};return(0,H.jsx)(D,{open:!0,onOpenChange:e=>{e||n()},children:(0,H.jsxs)(P,{className:`sm:max-w-[520px]`,"aria-describedby":void 0,children:[(0,H.jsx)(A,{children:(0,H.jsxs)(L,{children:[`Edit `,e.id]})}),(0,H.jsxs)(`div`,{className:`-m-1 flex max-h-[65vh] flex-col gap-3 overflow-y-auto p-1`,children:[(0,H.jsx)(J,{id:`memory-edit-title`,label:`Title`,children:(0,H.jsx)(w,{id:`memory-edit-title`,autoFocus:!0,required:!0,maxLength:120,value:a.title,onChange:e=>d(`title`,e.target.value)})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,H.jsx)(J,{id:`memory-edit-status`,label:`Status`,children:(0,H.jsx)(M,{id:`memory-edit-status`,value:a.status,onChange:e=>d(`status`,e.target.value),children:(t.includes(a.status)?t:[a.status,...t]).map(e=>(0,H.jsx)(j,{value:e,children:e},e))})}),i.category?(0,H.jsx)(J,{id:`memory-edit-category`,label:`Category`,children:(0,H.jsx)(w,{id:`memory-edit-category`,value:a.category,onChange:e=>d(`category`,e.target.value)})}):null,i.confidence?(0,H.jsx)(J,{id:`memory-edit-confidence`,label:`Confidence`,children:(0,H.jsxs)(M,{id:`memory-edit-confidence`,value:a.confidence,onChange:e=>d(`confidence`,e.target.value),children:[(0,H.jsx)(j,{value:``,children:`not set`}),U.map(e=>(0,H.jsx)(j,{value:e,children:e},e))]})}):null,i.severity?(0,H.jsx)(J,{id:`memory-edit-severity`,label:`Severity`,children:(0,H.jsxs)(M,{id:`memory-edit-severity`,value:a.severity,onChange:e=>d(`severity`,e.target.value),children:[(0,H.jsx)(j,{value:``,children:`not set`}),W.map(e=>(0,H.jsx)(j,{value:e,children:e},e))]})}):null,i.expires?(0,H.jsx)(J,{id:`memory-edit-expires`,label:`Expires`,children:(0,H.jsx)(w,{id:`memory-edit-expires`,type:`date`,value:a.expires,onChange:e=>d(`expires`,e.target.value)})}):null,i.review_after?(0,H.jsx)(J,{id:`memory-edit-review-after`,label:`Review after`,children:(0,H.jsx)(w,{id:`memory-edit-review-after`,type:`date`,value:a.review_after,onChange:e=>d(`review_after`,e.target.value)})}):null]}),(0,H.jsx)(J,{id:`memory-edit-body`,label:`Details`,children:(0,H.jsx)(v,{id:`memory-edit-body`,rows:10,value:a.body,onChange:e=>d(`body`,e.target.value)})}),(0,H.jsx)(Z,{message:l})]}),(0,H.jsxs)(k,{children:[(0,H.jsx)(p,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,H.jsx)(p,{type:`button`,disabled:s||!a.title.trim(),onClick:()=>void f(),children:s?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{"aria-hidden":`true`}),`Saving…`]}):`Save changes`})]})]})})}function ue({record:e,mode:t,onClose:n,onUpdated:r}){let[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(``),u=async()=>{s(!0);try{r((t===`graduate`?await C.graduateMemory(e.id,i.split(`,`).map(e=>e.trim()).filter(Boolean),e.revision):await C.supersedeMemory(e.id,i.trim(),e.revision)).record),n()}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,H.jsx)(D,{open:!0,onOpenChange:e=>{e||n()},children:(0,H.jsxs)(P,{className:`sm:max-w-[420px]`,"aria-describedby":void 0,children:[(0,H.jsx)(A,{children:(0,H.jsxs)(L,{children:[t===`graduate`?`Graduate`:`Supersede`,` `,e.id]})}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(J,{id:`memory-lifecycle-target`,label:t===`graduate`?`Target IDs`:`Replacement ID`,children:(0,H.jsx)(w,{id:`memory-lifecycle-target`,autoFocus:!0,placeholder:t===`graduate`?`CONV-0001, DOC-0004`:`ADR-0009`,value:i,onChange:e=>a(e.target.value)})}),(0,H.jsx)(Z,{message:c})]}),(0,H.jsxs)(k,{children:[(0,H.jsx)(p,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,H.jsx)(p,{type:`button`,disabled:o||!i.trim(),onClick:()=>void u(),children:o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{"aria-hidden":`true`}),`Saving…`]}):`Apply`})]})]})})}function de({record:e,statuses:t,onOpenRelation:n,onOpenRecord:r,onUpdated:a,onDialogOpenChange:s}){let[l,u]=(0,V.useState)(!1),[m,h]=(0,V.useState)(``),_=l||!!m;(0,V.useEffect)(()=>{s?.(_)},[_,s]);let v=e.collection===`learnings`&&e.status!==`graduated`,y=[`learnings`,`decisions`,`conventions`].includes(e.collection),b=[[`status`,e.status,f(e.status)]];return e.category&&b.push([`category`,e.category]),e.confidence&&b.push([`confidence`,e.confidence]),e.severity&&b.push([`severity`,e.severity,d(e.severity)]),e.occurrences!=null&&b.push([`occurrences`,String(e.occurrences)]),e.expires&&b.push([`expires`,e.expires]),e.review_after&&b.push([`review after`,e.review_after]),e.started_at&&b.push([`started`,e.started_at]),e.resolved_at&&b.push([`resolved`,e.resolved_at]),e.graduated_to?.length&&b.push([`graduated to`,e.graduated_to.join(`, `)]),e.superseded_by?.length&&b.push([`superseded by`,e.superseded_by.join(`, `)]),e.owners?.length&&b.push([`owners`,e.owners.join(`, `)]),b.push([`updated`,e.updated||`—`]),(0,H.jsxs)(`aside`,{"aria-label":`Memory record`,className:`flex min-h-0 flex-col overflow-hidden border-l bg-background`,children:[(0,H.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b px-3.5`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,H.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/60`,children:`·`}),(0,H.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.collection}),(0,H.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/60`,children:`·`}),(0,H.jsx)(`span`,{className:`font-mono text-[11px]`,style:{color:f(e.status)},children:e.status})]}),(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`h2`,{className:`m-0 text-[17px] font-semibold leading-[1.3] tracking-[-0.01em] [text-wrap:pretty]`,children:e.title}),e.path?(0,H.jsx)(`span`,{className:`break-all font-mono text-[10.5px] text-muted-foreground`,children:e.path}):null]}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-2`,children:b.map(([e,t,n])=>(0,H.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),(0,H.jsx)(`span`,{className:`text-sm`,style:n?{color:n}:void 0,children:t})]},e))}),(0,H.jsx)(Y,{issues:e.issues,kind:`validation`}),(0,H.jsx)(Y,{issues:e.lifecycleIssues||[],kind:`lifecycle`}),(0,H.jsx)(g,{className:`[--typeset-size:0.875rem]`,source:e.body||`No details recorded.`,onOpen:r}),(0,H.jsx)(X,{label:`Links to`,links:e.outgoing,onOpen:n}),(0,H.jsx)(X,{label:`Backlinks`,links:e.incoming,onOpen:n}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(!0),children:[(0,H.jsx)(i,{"aria-hidden":`true`}),`Edit`]}),v?(0,H.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(`graduate`),children:[(0,H.jsx)(c,{"aria-hidden":`true`}),`Graduate`]}):null,y?(0,H.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(`supersede`),children:[(0,H.jsx)(o,{"aria-hidden":`true`}),`Supersede`]}):null]})]}),l?(0,H.jsx)(Q,{record:e,statuses:t,onClose:()=>u(!1),onUpdated:a}):null,m?(0,H.jsx)(ue,{record:e,mode:m,onClose:()=>h(``),onUpdated:a}):null]})}function $(e,t){return e.find(e=>e.id===t)?.statuses||[]}function fe({id:e,schema:t,onSelect:n,onOpenRecord:r,onDialogOpenChange:i,onChanged:a}){let[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(``);return(0,V.useEffect)(()=>{let t=!0;return s(null),l(``),C.record(e).then(e=>{t&&s(e.record)}).catch(e=>{t&&l(e.message)}),()=>{t=!1}},[e]),c?(0,H.jsx)(`div`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:c}):o?(0,H.jsx)(de,{record:o,statuses:$(t.collections,o.collection),onOpenRelation:n,onOpenRecord:r,onUpdated:e=>{s(e),a?.()},onDialogOpenChange:i},o.id):(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground`,children:[(0,H.jsx)(_,{}),` Reading `,e,`…`]})}function pe({selectedId:e,onSelect:t,onOpenRecord:n,schema:i}){let[a,o]=(0,V.useState)([]),[c,l]=(0,V.useState)(``),[d,m]=(0,V.useState)(``),[g,v]=(0,V.useState)(``),[x,S]=(0,V.useState)(!0),[w,T]=(0,V.useState)(``),[E,D]=(0,V.useState)(null),k=(0,V.useRef)(0),A=(0,V.useCallback)(e=>{k.current=performance.now(),t(e)},[t]),[j,M]=(0,V.useState)(0);ee(e=>{b(e,`/memory/`)&&M(e=>e+1)}),(0,V.useEffect)(()=>{let e=async()=>{S(!0);try{let e=await C.memory(c.trim(),{collection:d||void 0,status:g||void 0});o(e.records),T(``)}catch(e){T(e instanceof Error?e.message:String(e))}finally{S(!1)}},t=window.setTimeout(()=>void e(),c?180:0);return()=>window.clearTimeout(t)},[c,d,g,j]);let P=(0,V.useMemo)(()=>[...a].sort((e,t)=>String(t.updated||``).localeCompare(String(e.updated||``))||e.title.localeCompare(t.title)),[a]),F=(0,V.useMemo)(()=>{let e=i.collections.filter(e=>!d||e.id===d).map(e=>({schema:e,records:P.filter(t=>t.collection===e.id)})),t=new Set(i.collections.map(e=>e.id)),n=P.filter(e=>!t.has(e.collection));return n.length&&e.push({schema:{id:`other`,singular:`record`,idPrefix:`?`,statuses:[]},records:n}),e},[i.collections,P,d]);P.find(t=>t.id===e);let L=d?$(i.collections,d):[...new Set(i.collections.flatMap(e=>e.statuses))];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3.5 pt-3.5`,children:[(0,H.jsxs)(te,{className:`w-full min-w-[180px] sm:w-[260px]`,children:[(0,H.jsx)(ie,{children:(0,H.jsx)(r,{"aria-hidden":`true`})}),(0,H.jsx)(z,{type:`search`,"aria-label":`Search workfile memory`,placeholder:`Search decisions, incidents, learnings…`,value:c,onChange:e=>l(e.target.value)})]}),(0,H.jsx)(q,{label:`collection`,value:d,options:i.collections.map(e=>({value:e.id})),onChange:e=>{m(e),v(``)}}),(0,H.jsx)(q,{label:`status`,value:g,options:L.map(e=>({value:e,color:f(e)})),onChange:v}),(0,H.jsx)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 whitespace-nowrap font-mono text-[11px] text-muted-foreground`,children:x?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{"aria-hidden":`true`,className:`size-3`}),`loading…`]}):G(a.length,`record`)})]}),w?(0,H.jsx)(R,{variant:`destructive`,className:`mx-3.5 mt-3 w-auto px-3 py-2`,children:(0,H.jsxs)(O,{children:[`Memory could not be loaded: `,w]})}):null,(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 gap-3 overflow-hidden p-3.5`,children:(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 gap-3 overflow-x-auto`,children:F.map(t=>(0,H.jsxs)(B,{className:`w-[272px] flex-none gap-0 overflow-hidden rounded-xl py-0 [--card-spacing:--spacing(2)]`,children:[(0,H.jsxs)(y,{className:`flex flex-row items-center gap-2 border-b px-3 py-2`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-primary`,children:t.schema.idPrefix}),(0,H.jsx)(`span`,{className:`flex-1 text-[12.5px] font-semibold`,children:oe(t.schema.singular)}),(0,H.jsx)(I,{variant:`secondary`,className:`h-5 px-1.5 font-mono text-[11px] font-normal`,children:t.records.length}),t.schema.id===`other`?null:(0,H.jsx)(p,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`New ${t.schema.singular}`,onClick:()=>D(t.schema.id),children:(0,H.jsx)(s,{"aria-hidden":`true`})})]}),(0,H.jsxs)(h,{className:u(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2.5`,ae),children:[t.records.map(t=>(0,H.jsx)(ce,{record:t,selected:t.id===e,onSelect:()=>A(t.id)},t.id)),!t.records.length&&!x?(0,H.jsx)(ne,{className:`gap-1 border border-dashed p-4 md:p-6`,children:(0,H.jsx)(N,{className:`font-mono text-xs`,children:`no records`})}):null]})]},t.schema.id))})}),E===null?null:(0,H.jsx)(le,{schema:i,initialCollection:E,onClose:()=>D(null),onCreated:e=>{D(null),o(t=>[e,...t]),t(e.id)}})]})}export{fe as MemoryPanel,pe as MemoryView};
import"./rolldown-runtime-CbXtAM7H.js";import{i as e,t}from"./react-Buq45Vzz.js";import{c as n,s as r}from"./ui-primitives-Beqd9I2k.js";import{c as i}from"./theme-CNCrPl--.js";e();var a=t();function o({className:e,value:t,...o}){return(0,a.jsx)(n,{"data-slot":`progress`,className:i(`relative h-2 w-full overflow-hidden rounded-full bg-primary/20`,e),...o,children:(0,a.jsx)(r,{"data-slot":`progress-indicator`,className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})})}export{o as t};
import"./rolldown-runtime-CbXtAM7H.js";import{i as e,t}from"./react-Buq45Vzz.js";import{F as n}from"./ui-primitives-Beqd9I2k.js";e();function r(e){var t,n,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=r(e[t]))&&(i&&(i+=` `),i+=n)}else for(n in e)e[n]&&(i&&(i+=` `),i+=n);return i}function i(){for(var e,t,n=0,i=``,a=arguments.length;n<a;n++)(e=arguments[n])&&(t=r(e))&&(i&&(i+=` `),i+=t);return i}var a=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,o=i,s=(e,t)=>n=>{if(t?.variants==null)return o(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,s=Object.keys(r).map(e=>{let t=n?.[e],o=i?.[e];if(t===null)return null;let s=a(t)||a(o);return r[e][s]}),c=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return o(e,s,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,...c}[t]):{...i,...c}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},c=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},l=(e,t)=>({classGroupId:e,validator:t}),u=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),d=`-`,f=[],p=`arbitrary..`,m=e=>{let t=_(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return g(e);let n=e.split(d);return h(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?c(i,t):t:i||f}return n[e]||f}}},h=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=h(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(d):e.slice(t).join(d),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},g=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?p+r:void 0})(),_=e=>{let{theme:t,classGroups:n}=e;return v(n,t)},v=(e,t)=>{let n=u();for(let r in e){let i=e[r];y(i,n,r,t)}return n},y=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];b(i,t,n,r)}},b=(e,t,n,r)=>{if(typeof e==`string`){x(e,t,n);return}if(typeof e==`function`){ee(e,t,n,r);return}S(e,t,n,r)},x=(e,t,n)=>{let r=e===``?t:C(t,e);r.classGroupId=n},ee=(e,t,n,r)=>{if(w(e)){y(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(l(n,e))},S=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];y(o,C(t,a),n,r)}},C=(e,t)=>{let n=e,r=t.split(d),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=u(),n.nextPart.set(t,i)),n=i}return n},w=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,te=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},T=`!`,E=`:`,ne=[],D=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),O=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===E){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(T)?(c=s.slice(0,-1),l=!0):s.startsWith(T)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return D(t,l,c,u)};if(t){let e=t+E,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):D(ne,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},k=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},A=e=>({cache:te(e.cacheSize),parseClassName:O(e),sortModifiers:k(e),postfixLookupClassGroupIds:j(e),...m(e)}),j=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},re=/\s+/,M=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(re),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+T:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},ie=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=N(n))&&(i&&(i+=` `),i+=r);return i},N=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=N(e[r]))&&(n&&(n+=` `),n+=t);return n},ae=(e,...t)=>{let n,r,i,a,o=o=>(n=A(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=M(e,n);return i(e,a),a};return a=o,(...e)=>a(ie(...e))},P=[],F=e=>{let t=t=>t[e]||P;return t.isThemeGetter=!0,t},I=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,L=/^\((?:(\w[\w-]*):)?(.+)\)$/i,R=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,oe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,z=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,se=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,B=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,V=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,H=e=>R.test(e),U=e=>!!e&&!Number.isNaN(Number(e)),W=e=>!!e&&Number.isInteger(Number(e)),ce=e=>e.endsWith(`%`)&&U(e.slice(0,-1)),G=e=>oe.test(e),le=()=>!0,K=e=>z.test(e)&&!se.test(e),q=()=>!1,ue=e=>B.test(e),de=e=>V.test(e),fe=e=>!J(e)&&!X(e),pe=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),me=e=>Q(e,ke,q),J=e=>I.test(e),Y=e=>Q(e,Ae,K),he=e=>Q(e,je,U),ge=e=>Q(e,Ne,le),_e=e=>Q(e,Me,q),ve=e=>Q(e,De,q),ye=e=>Q(e,Oe,de),be=e=>Q(e,Pe,ue),X=e=>L.test(e),Z=e=>$(e,Ae),xe=e=>$(e,Me),Se=e=>$(e,De),Ce=e=>$(e,ke),we=e=>$(e,Oe),Te=e=>$(e,Pe,!0),Ee=e=>$(e,Ne,!0),Q=(e,t,n)=>{let r=I.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},$=(e,t,n=!1)=>{let r=L.exec(e);return r?r[1]?t(r[1]):n:!1},De=e=>e===`position`||e===`percentage`,Oe=e=>e===`image`||e===`url`,ke=e=>e===`length`||e===`size`||e===`bg-size`,Ae=e=>e===`length`,je=e=>e===`number`,Me=e=>e===`family-name`,Ne=e=>e===`number`||e===`weight`,Pe=e=>e===`shadow`,Fe=ae(()=>{let e=F(`color`),t=F(`font`),n=F(`text`),r=F(`font-weight`),i=F(`tracking`),a=F(`leading`),o=F(`breakpoint`),s=F(`container`),c=F(`spacing`),l=F(`radius`),u=F(`shadow`),d=F(`inset-shadow`),f=F(`text-shadow`),p=F(`drop-shadow`),m=F(`blur`),h=F(`perspective`),g=F(`aspect`),_=F(`ease`),v=F(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),X,J],ee=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],S=()=>[`auto`,`contain`,`none`],C=()=>[X,J,c],w=()=>[H,`full`,`auto`,...C()],te=()=>[W,`none`,`subgrid`,X,J],T=()=>[`auto`,{span:[`full`,W,X,J]},W,X,J],E=()=>[W,`auto`,X,J],ne=()=>[`auto`,`min`,`max`,`fr`,X,J],D=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],O=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],k=()=>[`auto`,...C()],A=()=>[H,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...C()],j=()=>[H,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...C()],re=()=>[H,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...C()],M=()=>[e,X,J],ie=()=>[...b(),Se,ve,{position:[X,J]}],N=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ae=()=>[`auto`,`cover`,`contain`,Ce,me,{size:[X,J]}],P=()=>[ce,Z,Y],I=()=>[``,`none`,`full`,l,X,J],L=()=>[``,U,Z,Y],R=()=>[`solid`,`dashed`,`dotted`,`double`],oe=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],z=()=>[U,ce,Se,ve],se=()=>[``,`none`,m,X,J],B=()=>[`none`,U,X,J],V=()=>[`none`,U,X,J],K=()=>[U,X,J],q=()=>[H,`full`,...C()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[G],breakpoint:[G],color:[le],container:[G],"drop-shadow":[G],ease:[`in`,`out`,`in-out`],font:[fe],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[G],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[G],shadow:[G],spacing:[`px`,U],text:[G],"text-shadow":[G],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,H,J,X,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,X,J]}],"container-named":[pe],columns:[{columns:[U,J,X,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:ee()}],"overflow-x":[{"overflow-x":ee()}],"overflow-y":[{"overflow-y":ee()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:w()}],"inset-x":[{"inset-x":w()}],"inset-y":[{"inset-y":w()}],start:[{"inset-s":w(),start:w()}],end:[{"inset-e":w(),end:w()}],"inset-bs":[{"inset-bs":w()}],"inset-be":[{"inset-be":w()}],top:[{top:w()}],right:[{right:w()}],bottom:[{bottom:w()}],left:[{left:w()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[W,`auto`,X,J]}],basis:[{basis:[H,`full`,`auto`,s,...C()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[U,H,`auto`,`initial`,`none`,J]}],grow:[{grow:[``,U,X,J]}],shrink:[{shrink:[``,U,X,J]}],order:[{order:[W,`first`,`last`,`none`,X,J]}],"grid-cols":[{"grid-cols":te()}],"col-start-end":[{col:T()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":te()}],"row-start-end":[{row:T()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...D(),`normal`]}],"justify-items":[{"justify-items":[...O(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...O()]}],"align-content":[{content:[`normal`,...D()]}],"align-items":[{items:[...O(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...O(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":D()}],"place-items":[{"place-items":[...O(),`baseline`]}],"place-self":[{"place-self":[`auto`,...O()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mbs:[{mbs:k()}],mbe:[{mbe:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":C()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":C()}],"space-y-reverse":[`space-y-reverse`],size:[{size:A()}],"inline-size":[{inline:[`auto`,...j()]}],"min-inline-size":[{"min-inline":[`auto`,...j()]}],"max-inline-size":[{"max-inline":[`none`,...j()]}],"block-size":[{block:[`auto`,...re()]}],"min-block-size":[{"min-block":[`auto`,...re()]}],"max-block-size":[{"max-block":[`none`,...re()]}],w:[{w:[s,`screen`,...A()]}],"min-w":[{"min-w":[s,`screen`,`none`,...A()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...A()]}],h:[{h:[`screen`,`lh`,...A()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...A()]}],"max-h":[{"max-h":[`screen`,`lh`,...A()]}],"font-size":[{text:[`base`,n,Z,Y]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Ee,ge]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,ce,J]}],"font-family":[{font:[xe,_e,t]}],"font-features":[{"font-features":[J]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,X,J]}],"line-clamp":[{"line-clamp":[U,`none`,X,he]}],leading:[{leading:[a,...C()]}],"list-image":[{"list-image":[`none`,X,J]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,X,J]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...R(),`wavy`]}],"text-decoration-thickness":[{decoration:[U,`from-font`,`auto`,X,Y]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[U,`auto`,X,J]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:C()}],"tab-size":[{tab:[W,X,J]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,X,J]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,X,J]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:N()}],"bg-size":[{bg:ae()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},W,X,J],radial:[``,X,J],conic:[W,X,J]},we,ye]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:P()}],"gradient-via-pos":[{via:P()}],"gradient-to-pos":[{to:P()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:I()}],"rounded-s":[{"rounded-s":I()}],"rounded-e":[{"rounded-e":I()}],"rounded-t":[{"rounded-t":I()}],"rounded-r":[{"rounded-r":I()}],"rounded-b":[{"rounded-b":I()}],"rounded-l":[{"rounded-l":I()}],"rounded-ss":[{"rounded-ss":I()}],"rounded-se":[{"rounded-se":I()}],"rounded-ee":[{"rounded-ee":I()}],"rounded-es":[{"rounded-es":I()}],"rounded-tl":[{"rounded-tl":I()}],"rounded-tr":[{"rounded-tr":I()}],"rounded-br":[{"rounded-br":I()}],"rounded-bl":[{"rounded-bl":I()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":L()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...R(),`hidden`,`none`]}],"divide-style":[{divide:[...R(),`hidden`,`none`]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...R(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[U,X,J]}],"outline-w":[{outline:[``,U,Z,Y]}],"outline-color":[{outline:M()}],shadow:[{shadow:[``,`none`,u,Te,be]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":[`none`,d,Te,be]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:L()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[U,Y]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":[`none`,f,Te,be]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[U,X,J]}],"mix-blend":[{"mix-blend":[...oe(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":oe()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[U]}],"mask-image-linear-from-pos":[{"mask-linear-from":z()}],"mask-image-linear-to-pos":[{"mask-linear-to":z()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":z()}],"mask-image-t-to-pos":[{"mask-t-to":z()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":z()}],"mask-image-r-to-pos":[{"mask-r-to":z()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":z()}],"mask-image-b-to-pos":[{"mask-b-to":z()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":z()}],"mask-image-l-to-pos":[{"mask-l-to":z()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":z()}],"mask-image-x-to-pos":[{"mask-x-to":z()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":z()}],"mask-image-y-to-pos":[{"mask-y-to":z()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[X,J]}],"mask-image-radial-from-pos":[{"mask-radial-from":z()}],"mask-image-radial-to-pos":[{"mask-radial-to":z()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[U]}],"mask-image-conic-from-pos":[{"mask-conic-from":z()}],"mask-image-conic-to-pos":[{"mask-conic-to":z()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:N()}],"mask-size":[{mask:ae()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,X,J]}],filter:[{filter:[``,`none`,X,J]}],blur:[{blur:se()}],brightness:[{brightness:[U,X,J]}],contrast:[{contrast:[U,X,J]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Te,be]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:[``,U,X,J]}],"hue-rotate":[{"hue-rotate":[U,X,J]}],invert:[{invert:[``,U,X,J]}],saturate:[{saturate:[U,X,J]}],sepia:[{sepia:[``,U,X,J]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,X,J]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[U,X,J]}],"backdrop-contrast":[{"backdrop-contrast":[U,X,J]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,U,X,J]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[U,X,J]}],"backdrop-invert":[{"backdrop-invert":[``,U,X,J]}],"backdrop-opacity":[{"backdrop-opacity":[U,X,J]}],"backdrop-saturate":[{"backdrop-saturate":[U,X,J]}],"backdrop-sepia":[{"backdrop-sepia":[``,U,X,J]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,X,J]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[U,`initial`,X,J]}],ease:[{ease:[`linear`,`initial`,_,X,J]}],delay:[{delay:[U,X,J]}],animate:[{animate:[`none`,v,X,J]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,X,J]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:B()}],"rotate-x":[{"rotate-x":B()}],"rotate-y":[{"rotate-y":B()}],"rotate-z":[{"rotate-z":B()}],scale:[{scale:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":[`scale-3d`],skew:[{skew:K()}],"skew-x":[{"skew-x":K()}],"skew-y":[{"skew-y":K()}],transform:[{transform:[X,J,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:q()}],"translate-x":[{"translate-x":q()}],"translate-y":[{"translate-y":q()}],"translate-z":[{"translate-z":q()}],"translate-none":[`translate-none`],zoom:[{zoom:[W,X,J]}],accent:[{accent:M()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,X,J]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,X,J]}],fill:[{fill:[`none`,...M()]}],"stroke-w":[{stroke:[U,Z,Y,he]}],stroke:[{stroke:[`none`,...M()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Ie(...e){return Fe(i(e))}var Le=t(),Re=s(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function ze({className:e,variant:t=`default`,size:r=`default`,asChild:i=!1,...a}){let o=i?n:`button`;return(0,Le.jsx)(o,{"data-slot":`button`,"data-variant":t,"data-size":r,className:Ie(Re({variant:t,size:r,className:e})),...a})}function Be(e){return`var(--status-${e})`}function Ve(e){return`var(--priority-${e})`}function He(e){return`var(--sev-${e})`}var Ue={current:`done`,draft:`doing`,stale:`doing`,superseded:`backlog`,archived:`backlog`,indexed:`backlog`,active:`done`,accepted:`done`,resolved:`done`,graduated:`done`,proposed:`doing`,open:`doing`,mitigated:`doing`,closed:`done`,rejected:`discarded`,expired:`backlog`,deprecated:`backlog`,released:`done`,unreleased:`doing`};function We(e){let t=Ue[e];return t?`var(--status-${t})`:`var(--status-${e in Ge?e:`backlog`})`}var Ge={backlog:!0,next:!0,doing:!0,review:!0,blocked:!0,deferred:!0,done:!0,discarded:!0};function Ke(e){return e.startsWith(`T-`)?`cards`:e.startsWith(`DOC-`)||e.startsWith(`PATH-`)?`docs`:e.startsWith(`CHG-`)||e.startsWith(`REL-`)?`changelog`:`memory`}function qe(e){return e==null?``:e<1/60?`now`:e<1?`${Math.round(e*60)} min`:e<48?`${Math.round(e)} h`:`${Math.round(e/24)} d`}export{qe as a,Ie as c,He as i,s as l,Ke as n,Be as o,We as r,ze as s,Ve as t};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{Et as r,Y as i,et as a}from"./ui-primitives-Beqd9I2k.js";import{c as o,o as s,s as c,t as l}from"./theme-CNCrPl--.js";import{A as u,C as d,M as f,N as p,P as m,Q as h,a as g,j as _,k as v}from"./index-Dpy209ef.js";import{t as y}from"./layout-QiuZ_k5v.js";import{t as b}from"./progress-DOIfGVtf.js";var x=e(t(),1),S=n(),C=[{key:`N`,label:`Move to next`,status:`next`},{key:`D`,label:`Defer`,status:`deferred`},{key:`X`,label:`Discard`,status:`discarded`}];function w({tasks:e,repoRoot:t,repoUrl:n,onPatch:w,onOpen:T}){let[E,D]=(0,x.useState)(()=>new Set),[O,k]=(0,x.useState)(0),A=(0,x.useMemo)(()=>e.filter(e=>!E.has(e.id)),[E,e]),j=A[O]||A[0],M=e.length;(0,x.useEffect)(()=>{O>=A.length&&k(Math.max(0,A.length-1))},[O,A.length]);let N=(0,x.useCallback)(async(e,t=!0)=>{if(j){try{await w(j.id,e)}catch{return}t&&(D(e=>new Set(e).add(j.id)),k(e=>Math.min(e,Math.max(0,A.length-2))))}},[w,A.length,j]);(0,x.useEffect)(()=>{let e=e=>{if(e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if([`INPUT`,`SELECT`,`TEXTAREA`].includes(t.tagName)||t.isContentEditable)return;let n=e.key.toUpperCase();if(n===`J`||e.key===`ArrowDown`)e.preventDefault(),k(e=>Math.min(A.length-1,e+1));else if(n===`K`||e.key===`ArrowUp`)e.preventDefault(),k(e=>Math.max(0,e-1));else if(/^[1-4]$/.test(n))e.preventDefault(),N({priority:g[Number(n)-1]},!1);else{let t=C.find(e=>e.key===n);t&&(e.preventDefault(),N({status:t.status}))}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[N,A.length]);let P=e=>n?`${n.replace(/\/+$/,``)}/blob/main/${e}`:`vscode://file${t}/${e}`;return j?(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b bg-card px-3.5 py-2.5`,children:[(0,S.jsx)(b,{value:M?E.size/M*100:0,className:`max-w-[340px] flex-1`}),(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[E.size,` of `,M,` processed`]}),(0,S.jsx)(`span`,{className:`flex-1`}),(0,S.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,disabled:O===0,onClick:()=>k(e=>Math.max(0,e-1)),children:[(0,S.jsx)(h,{children:`K`}),`Previous`]}),(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:[O+1,` / `,A.length]}),(0,S.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,disabled:O>=A.length-1,onClick:()=>k(e=>Math.min(A.length-1,e+1)),children:[(0,S.jsx)(h,{children:`J`}),`Next`]}),(0,S.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>T(j.id),children:[(0,S.jsx)(a,{"aria-hidden":`true`}),`Open full card`]})]}),(0,S.jsxs)(`div`,{className:o(y,`px-6 py-7 sm:px-8`),children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[11px] text-muted-foreground`,children:[(0,S.jsx)(`span`,{children:j.id}),(0,S.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,S.jsx)(`span`,{style:{color:s(j.status)},children:j.status}),(0,S.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,S.jsx)(`span`,{children:j.area}),(0,S.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,S.jsx)(`span`,{children:j.type})]}),(0,S.jsx)(`h2`,{className:`mt-3 mb-1 text-[26px] leading-[1.2] font-semibold tracking-tight [text-wrap:pretty]`,children:j.title}),j.file?(0,S.jsx)(`a`,{className:`font-mono text-[11px] text-muted-foreground/70 underline underline-offset-[3px]`,href:P(j.file),target:n?`_blank`:void 0,rel:n?`noreferrer`:void 0,children:j.file}):null,j.source?(0,S.jsxs)(`span`,{className:`mt-[3px] block font-mono text-[11px] text-muted-foreground/70`,children:[`source`,` `,(0,S.jsx)(`a`,{className:`font-mono underline underline-offset-[3px]`,href:P(j.source),target:n?`_blank`:void 0,rel:n?`noreferrer`:void 0,children:j.source})]}):null,(0,S.jsx)(`div`,{className:`mt-[22px]`,children:(0,S.jsx)(d,{source:j.body,onOpen:T})}),(0,S.jsxs)(`div`,{className:`mt-[30px] flex flex-wrap gap-2 border-t pt-[18px]`,children:[g.map((e,t)=>(0,S.jsxs)(c,{type:`button`,variant:`outline`,"aria-pressed":j.priority===e,style:j.priority===e?{borderColor:l(e)}:void 0,onClick:()=>void N({priority:e},!1),children:[(0,S.jsx)(h,{children:t+1}),(0,S.jsx)(`span`,{style:{color:l(e)},children:e})]},e)),C.map(e=>(0,S.jsxs)(c,{type:`button`,variant:`outline`,onClick:()=>void N({status:e.status}),children:[(0,S.jsx)(h,{children:e.key}),(0,S.jsx)(`span`,{style:{color:s(e.status)},children:e.label})]},e.key))]}),(0,S.jsx)(`span`,{className:`mt-3.5 block text-xs text-muted-foreground`,children:`Every action writes the card's frontmatter to disk immediately. Shortcuts work while focus is outside a form.`})]})]}):(0,S.jsxs)(v,{className:`gap-3 p-10`,children:[(0,S.jsxs)(f,{children:[(0,S.jsx)(p,{children:(0,S.jsx)(r,{"aria-hidden":`true`,size:20,style:{color:s(`done`)}})}),(0,S.jsx)(m,{className:`text-sm`,children:`Queue clear`}),(0,S.jsxs)(_,{className:`text-[12.5px]`,children:[`You processed `,E.size.toLocaleString(),` cards.`]})]}),(0,S.jsx)(u,{children:(0,S.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{D(new Set),k(0)},children:[(0,S.jsx)(i,{"aria-hidden":`true`}),`Start again`]})})]})}export{w as TriageView};

Sorry, the diff of this file is too big to display

import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{at as r,ht as i}from"./ui-primitives-Beqd9I2k.js";import{c as a,r as o,s}from"./theme-CNCrPl--.js";import{W as c,ot as l}from"./index-Dpy209ef.js";var u=e(t(),1),d=[{id:`parent`,label:`parent`,declared:!0},{id:`depends`,label:`depends`,declared:!0},{id:`origin`,label:`origin`,declared:!0},{id:`supersedes`,label:`supersedes`,declared:!0},{id:`superseded_by`,label:`superseded by`,declared:!0},{id:`graduated_to`,label:`graduated to`,declared:!0},{id:`corrective_actions`,label:`corrective`,declared:!0},{id:`cards`,label:`cards`,declared:!0},{id:`decisions`,label:`decisions`,declared:!0},{id:`fragments`,label:`fragments`,declared:!0},{id:`related`,label:`related`,declared:!0},{id:`source`,label:`source`,declared:!0},{id:`wikilink`,label:`wiki link`,declared:!1},{id:`markdown`,label:`md link`,declared:!1},{id:`mention`,label:`mention`,declared:!1}],f=new Set(d.filter(e=>e.declared).map(e=>e.id)),p=[{id:`card`,label:`Cards`},{id:`memory`,label:`Memory`},{id:`doc`,label:`Docs`},{id:`change`,label:`Changes`},{id:`release`,label:`Releases`}],m=d.map(e=>e.id).filter(e=>e!==`mention`),h=[`card`,`memory`,`doc`];function ee(e,t){let n=e.filter(e=>t.kinds.has(e.kind)),r=new Set(n.map(e=>e.id)),i=[],a=new Map;for(let e of n)for(let n of e.edges){if(!r.has(n.to)||n.to===e.id)continue;let o=n.rel.filter(e=>t.relations.has(e));o.length&&(i.push({from:e.id,to:n.to,relations:o,declared:o.some(e=>f.has(e))}),a.set(e.id,(a.get(e.id)||0)+1),a.set(n.to,(a.get(n.to)||0)+1))}return{records:t.hideIsolated?n.filter(e=>a.get(e.id)):n,links:i,degree:a}}function g(e,t){let n=e*2.399963,r=18*Math.sqrt(e)+(t>200?40:0);return{x:Math.cos(n)*r,y:Math.sin(n)*r}}var _=9e3,v=.012,y=130,b=6e-4,x=.82;function S(e,t,n){for(let t=0;t<e.length;t+=1){let r=e[t];for(let i=t+1;i<e.length;i+=1){let a=e[i],o=r.x-a.x,s=r.y-a.y,c=o*o+s*s;c<1&&(o=(t-i)*.5,s=.5,c=o*o+s*s);let l=Math.sqrt(c),u=_*n/c,d=o/l*u,f=s/l*u;r.vx+=d,r.vy+=f,a.vx-=d,a.vy-=f}}let r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.from),i=r.get(e.to);if(!t||!i)continue;let a=i.x-t.x,o=i.y-t.y,s=Math.sqrt(a*a+o*o)||1,c=(s-y)*v*n,l=a/s*c,u=o/s*c;t.vx+=l,t.vy+=u,i.vx-=l,i.vy-=u}for(let t of e)t.vx-=t.x*b*n,t.vy-=t.y*b*n,t.vx*=x,t.vy*=x,t.x+=t.vx,t.y+=t.vy}function C(e,t,n){let r=new Map(e.map(e=>[e.id,e]));return t.map((e,i)=>{let a=r.get(e.id)??g(i,t.length);return{id:e.id,x:a.x,y:a.y,vx:0,vy:0,record:e,degree:n.get(e.id)||0}})}function w(e,t,n,r){let i=n-e,a=r-t,o=Math.sqrt(i*i+a*a)||1,s=Math.min(o*.18,60);return`M ${e} ${t} Q ${(e+n)/2-a/o*s} ${(t+r)/2+i/o*s} ${n} ${r}`}var T=.08;function E(e,t,n,r){let i=Math.min(4,Math.max(T,e.k*r));return{k:i,x:t-(t-e.x)/e.k*i,y:n-(n-e.y)/e.k*i}}function D(e,t,n){return{x:t-e.x,y:n-e.y}}function O(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);return{minX:t,minY:n,maxX:r,maxY:i}}var k=n(),A=`workfile-workflow-filters`;function te(){let e={relations:[...m],kinds:[...h],hideIsolated:!0};try{let t=localStorage.getItem(A);if(!t)return e;let n=JSON.parse(t);return{relations:Array.isArray(n.relations)?n.relations:e.relations,kinds:Array.isArray(n.kinds)?n.kinds:e.kinds,hideIsolated:typeof n.hideIsolated==`boolean`?n.hideIsolated:e.hideIsolated}}catch{return e}}function j({on:e,onClick:t,children:n,dashed:r}){return(0,k.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:a(`rounded-full border px-2 py-0.5 text-[11px] transition-colors`,e?`border-ring bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-accent/50`,r&&`border-dashed`),children:n})}function M({selectedId:e,onSelect:t}){let[n,f]=(0,u.useState)(null),[m,h]=(0,u.useState)(null),g=(0,u.useRef)(te()),[_,v]=(0,u.useState)(()=>new Set(g.current.relations)),[y,b]=(0,u.useState)(()=>new Set(g.current.kinds)),[x,T]=(0,u.useState)(g.current.hideIsolated),[M,N]=(0,u.useState)(null),P=(0,u.useRef)(0),[F,I]=(0,u.useState)({x:0,y:0,k:1}),[,L]=(0,u.useState)(0),R=(0,u.useRef)({nodes:[],links:[],alpha:0}),z=(0,u.useRef)(null),B=(0,u.useRef)(!1);(0,u.useEffect)(()=>{let e=!0;return c.graph().then(t=>{e&&f(t.records)}).catch(t=>{e&&h(t.message)}),()=>{e=!1}},[]),(0,u.useEffect)(()=>{localStorage.setItem(A,JSON.stringify({relations:[..._],kinds:[...y],hideIsolated:x}))},[_,y,x]);let V=(0,u.useMemo)(()=>ee(n??[],{relations:_,kinds:y,hideIsolated:x}),[n,y,_,x]);(0,u.useEffect)(()=>{R.current.nodes=C(R.current.nodes,V.records,V.degree),R.current.links=V.links,R.current.alpha=1,L(e=>e+1)},[V]);let H=(0,u.useCallback)(()=>{let e=R.current.nodes,t=z.current;if(!e.length||!t)return;let n=t.getBoundingClientRect(),{minX:r,minY:i,maxX:a,maxY:o}=O(e),s=Math.min(3,Math.max(.15,Math.min(n.width/(a-r+160),n.height/(o-i+160))));I({k:s,x:n.width/2-(r+a)/2*s,y:n.height/2-(i+o)/2*s})},[]);(0,u.useEffect)(()=>{let e=0,t=()=>{let n=R.current;n.alpha>.02&&n.nodes.length&&(S(n.nodes,n.links,n.alpha),n.alpha*=.97,B.current||H(),L(e=>e+1)),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[H]);let U=e=>{e.preventDefault();let t=z.current?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left,r=e.clientY-t.top;B.current=!0;let i=e.deltaY<0?1.12:.89;I(e=>E(e,n,r,i))},W=(0,u.useRef)(null),G=e=>{B.current=!0,W.current={x:e.clientX-F.x,y:e.clientY-F.y},e.target.setPointerCapture?.(e.pointerId)},K=e=>{let t=W.current;if(!t)return;let n=D(t,e.clientX,e.clientY);I(e=>({...e,...n}))},q=()=>{W.current=null},J=(e,t,n)=>{let r=new Set(e);r.has(n)?r.delete(n):r.add(n),t(r)},Y=R.current.nodes,X=(0,u.useMemo)(()=>new Map(Y.map(e=>[e.id,e])),[Y,F]),Z=M??e,Q=Z?X.get(Z):void 0,$=(0,u.useMemo)(()=>{if(!Z)return null;let e=new Set([Z]);for(let t of V.links)t.from===Z&&e.add(t.to),t.to===Z&&e.add(t.from);return e},[Z,V.links]);return m?(0,k.jsxs)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:[`The graph could not be read: `,m]}):(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b px-3 py-2`,children:[(0,k.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:p.map(e=>(0,k.jsx)(j,{on:y.has(e.id),onClick:()=>J(y,b,e.id),children:e.label},e.id))}),(0,k.jsx)(`span`,{className:`h-4 w-px bg-border`,"aria-hidden":`true`}),(0,k.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:d.map(e=>(0,k.jsx)(j,{on:_.has(e.id),dashed:!e.declared,onClick:()=>J(_,v,e.id),children:e.label},e.id))}),(0,k.jsx)(`span`,{className:`h-4 w-px bg-border`,"aria-hidden":`true`}),(0,k.jsx)(j,{on:x,onClick:()=>T(!x),children:`hide isolated`}),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[V.records.length,` nodes · `,V.links.length,` edges`]}),(0,k.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:()=>{B.current=!1,H()},children:[(0,k.jsx)(i,{"aria-hidden":`true`,className:`size-3`}),`Fit`]})]})]}),(0,k.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[n?null:(0,k.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,k.jsx)(r,{"aria-hidden":`true`,className:`size-4 animate-spin`}),`Reading the graph…`]}),(0,k.jsxs)(`svg`,{ref:z,role:`presentation`,className:`size-full cursor-grab touch-none active:cursor-grabbing`,onWheel:U,onPointerDown:G,onPointerMove:K,onPointerUp:q,onPointerLeave:q,children:[(0,k.jsx)(`defs`,{children:(0,k.jsx)(`marker`,{id:`workflow-arrow`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`5`,markerHeight:`5`,orient:`auto-start-reverse`,children:(0,k.jsx)(`path`,{d:`M 0 1 L 7 4 L 0 7 z`,className:`fill-muted-foreground`})})}),(0,k.jsxs)(`g`,{transform:`translate(${F.x} ${F.y}) scale(${F.k})`,children:[V.links.map(e=>{let t=X.get(e.from),n=X.get(e.to);if(!t||!n)return null;let r=$&&!($.has(e.from)&&$.has(e.to));return(0,k.jsx)(`path`,{d:w(t.x,t.y,n.x,n.y),fill:`none`,markerEnd:`url(#workflow-arrow)`,className:a(`stroke-muted-foreground transition-opacity`,r?`opacity-10`:`opacity-45`),strokeWidth:1.2/F.k,strokeDasharray:e.declared?void 0:`${4/F.k} ${3/F.k}`,children:(0,k.jsx)(`title`,{children:`${e.from} → ${e.to}: ${e.relations.join(`, `)}`})},`${e.from}->${e.to}`)}),Y.map(n=>{let r=$&&!$.has(n.id),i=n.id===e,s=Math.min(16,6+Math.sqrt(n.degree)*2);return(0,k.jsxs)(`g`,{transform:`translate(${n.x} ${n.y})`,className:a(`cursor-pointer transition-opacity`,r&&`opacity-20`),onPointerEnter:()=>N(n.id),onPointerLeave:()=>N(null),onClick:e=>{e.stopPropagation(),P.current=performance.now(),t(n.id)},children:[(0,k.jsx)(`circle`,{r:s,style:{fill:o(n.record.status||`backlog`)},className:a(i?`stroke-foreground`:`stroke-background`),strokeWidth:(i?3:1.5)/F.k}),(0,k.jsx)(`title`,{children:`${n.id} — ${n.record.title}`}),F.k>.55||i||r===!1?(0,k.jsx)(`text`,{y:s+11/F.k,textAnchor:`middle`,className:`pointer-events-none fill-foreground`,style:{fontSize:`${11/F.k}px`},children:n.id}):null]},n.id)})]})]}),Q?(0,k.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-3 max-w-[min(30rem,70%)] rounded-md border bg-background/95 px-3 py-2 shadow-sm`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`font-mono text-[11px] font-medium`,children:Z}),(0,k.jsx)(l,{variant:`secondary`,className:`px-1.5 py-0 text-[10px] font-normal`,children:Q.record.recordType})]}),(0,k.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:Q.record.title})]}):null]})]})}export{M as WorkflowView};
+1
-2

@@ -21,3 +21,3 @@ export declare const SCHEMA_VERSION = 2;

*/
export declare const CARD_RESERVED_KEYS: readonly ["archived", "area", "body", "claimed_at", "claimed_by", "created", "depends", "due", "effort", "file", "id", "milestone", "parent", "priority", "related", "revision", "scope", "source", "start", "status", "tags", "title", "type", "updated"];
export declare const CARD_RESERVED_KEYS: readonly ["archived", "area", "body", "claimed_at", "claimed_by", "created", "depends", "due", "effort", "file", "id", "milestone", "origin", "parent", "priority", "related", "revision", "scope", "source", "start", "status", "tags", "title", "type", "updated"];
/** What an axis name may look like: a plain, greppable frontmatter key. */

@@ -140,4 +140,3 @@ export declare const AXIS_NAME_RE: RegExp;

open: boolean;
defaultView: string;
};
}>;

@@ -57,2 +57,3 @@ export const SCHEMA_VERSION = 2;

"milestone",
"origin",
"parent",

@@ -247,5 +248,4 @@ "priority",

port: 4747,
open: true,
defaultView: "work"
open: true
}
});

@@ -55,2 +55,6 @@ export declare const AGENT_TARGETS: Readonly<{

focus: string;
provenance: {
origin: string[];
spawned: any;
};
generatedAt: string;

@@ -57,0 +61,0 @@ truncated: boolean;

@@ -466,5 +466,27 @@ import { readFile } from "node:fs/promises";

}
// Provenance, both ways, read off the field rather than off the graph edge.
//
// The edge cannot answer this. `classifiedReferences` collapses every
// explicit frontmatter link to the single relation `reference`, so in the
// index an origin is indistinguishable from a `related` or a `depends` —
// the records already arrive through `direct` below, but nothing says which
// of them this card came out of and which came out of it. The field says it
// exactly, and in both directions: one read off the focus card, the other
// off everything naming it.
// Narrowed here rather than above: `focus.kind !== "card"` already threw,
// but that guard sits inside `if (cardId)` and the union widens again on
// the way out, so `origin` — a card-only field — is unreachable without it.
const cameFrom = focus?.kind === "card" ? focus.origin || [] : [];
const spawned = focus
? index.records
.filter((record) => record.kind === "card" &&
(record.origin || []).includes(focus.id))
.map((record) => record.id)
.sort()
: [];
const directIds = new Set([
...(focus?.outgoing || []).map((item) => item.id),
...(focus?.incoming || []).map((item) => item.id)
...(focus?.incoming || []).map((item) => item.id),
...cameFrom,
...spawned
]);

@@ -537,2 +559,12 @@ const direct = index.records.filter((record) => directIds.has(record.id));

"",
// Two lines, not a section. The bundle is budgeted, and the records
// themselves follow immediately below — this only has to say which way
// provenance runs between them.
...(cameFrom.length
? [`${isEs ? "**Surgió de**" : "**Came out of**"}: ${cameFrom.join(", ")}`]
: []),
...(spawned.length
? [`${isEs ? "**Ha generado**" : "**Spawned**"}: ${spawned.join(", ")}`]
: []),
...(cameFrom.length || spawned.length ? [""] : []),
...records.flatMap((record) => [renderRecordSummary(record), ""])

@@ -544,2 +576,3 @@ ]

focus: focus?.id || null,
provenance: focus ? { origin: cameFrom, spawned } : null,
generatedAt: new Date().toISOString(),

@@ -546,0 +579,0 @@ truncated: prioritized.length > records.length,

@@ -29,5 +29,16 @@ export declare const CARD_LIST_KEYS: Set<string>;

}>;
export declare function diagnoseCards({ cards, unreadable, workspace, checkPaths, now }: {
/**
* `knownIds` is every project record ID, not every card ID.
*
* `origin` accepts any record kind — ADR-0005 spawned two cards, and four cards
* cite an LRN — so the set this rule resolves against is wider than the one
* `missing-parent` and `missing-dependency` use, and this module cannot build
* it: it is handed cards. Absent, the rule stays quiet rather than reporting
* every non-card origin as dangling, which is the same bargain `checkPaths`
* makes for `missing-source`.
*/
export declare function diagnoseCards({ cards, unreadable, workspace, checkPaths, knownIds, now }: {
cards: any;
checkPaths?: boolean;
knownIds?: Set<string>;
now?: Date;

@@ -34,0 +45,0 @@ unreadable?: any[];

@@ -12,3 +12,9 @@ import { access, readdir, readFile } from "node:fs/promises";

import { CARD_EFFORTS, CARD_PRIORITIES, CARD_STATUSES, CARD_TYPES } from "../../config/defaults.js";
export const CARD_LIST_KEYS = new Set(["tags", "depends", "scope", "related"]);
export const CARD_LIST_KEYS = new Set([
"tags",
"depends",
"scope",
"related",
"origin"
]);
export const CARD_REQUIRED_KEYS = Object.freeze([

@@ -170,3 +176,19 @@ "id",

}
export async function diagnoseCards({ cards, unreadable = [], workspace, checkPaths = true, now = new Date() }) {
/**
* `knownIds` is every project record ID, not every card ID.
*
* `origin` accepts any record kind — ADR-0005 spawned two cards, and four cards
* cite an LRN — so the set this rule resolves against is wider than the one
* `missing-parent` and `missing-dependency` use, and this module cannot build
* it: it is handed cards. Absent, the rule stays quiet rather than reporting
* every non-card origin as dangling, which is the same bargain `checkPaths`
* makes for `missing-source`.
*/
export async function diagnoseCards({ cards, unreadable = [], workspace, checkPaths = true,
// Annotated through the default rather than on the destructure: `null`
// alone infers `never`, so every `knownIds.has(...)` below becomes an
// error — but annotating the whole parameter `any` silences two unrelated
// baseline errors this file is still carrying, which the ratchet reads as
// progress that nobody made.
knownIds = null, now = new Date() }) {
const issues = unreadable.map((entry) => issue("error", "unreadable-card", { file: entry.file }, `Cannot read card: ${entry.reason}`));

@@ -275,2 +297,19 @@ const cardsById = new Map();

}
for (const source of card.origin || []) {
if (source === card.id) {
issues.push(issue("error", "self-origin", card, "Card cannot originate from itself"));
}
else if (knownIds && !knownIds.has(source)) {
// A warning where `missing-parent` is an error, and the
// difference is what breaks. A dangling parent corrupts the
// hierarchy depth every other card is measured against, and a
// dangling dependency makes unblocked work look blocked;
// nothing computes on `origin`, so what a dangling one costs is
// one missing edge in a graph nobody is blocked by. It still
// has to be reported: the value replaces prose that named IDs
// freely, so a typo here reads exactly like a real provenance
// and would otherwise go on looking like one forever.
issues.push(issue("warning", "missing-origin", card, `Origin ${source} does not resolve to any project record`));
}
}
const hierarchy = hierarchyDepth(card, byId);

@@ -277,0 +316,0 @@ if (hierarchy.cycle) {

@@ -344,2 +344,3 @@ import { mkdir, readFile, rename, rm } from "node:fs/promises";

...(input.related?.length ? { related: input.related } : {}),
...(input.origin?.length ? { origin: input.origin } : {}),
...(input.start ? { start: input.start } : {}),

@@ -346,0 +347,0 @@ ...(input.due ? { due: input.due } : {}),

@@ -20,3 +20,4 @@ import { CARD_EFFORTS, CARD_PRIORITIES, CARD_STATUSES, CARD_TYPES } from "../../config/defaults.js";

"due",
"related"
"related",
"origin"
]);

@@ -23,0 +24,0 @@ const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;

@@ -72,3 +72,7 @@ import { join } from "node:path";

now: options.now || new Date(),
checkPaths: options.checkPaths !== false
checkPaths: options.checkPaths !== false,
// Built here because this is the only layer that holds every
// kind at once: `origin` resolves against decisions and
// learnings as readily as against cards.
knownIds: new Set(index.records.map((record) => record.id).filter(Boolean))
}));

@@ -75,0 +79,0 @@ }

@@ -464,2 +464,11 @@ import { NEXT_DEFAULT_LIMIT, NEXT_MAXIMUM_LIMIT, appendCardNote, archiveCard, claimCard, createCard, patchCard, patchCardBody, rankNextCards, releaseCard, reopenCard, transitionCard } from "../cards/index.js";

focus: text("ID of the card the bundle was built around."),
provenance: {
type: "object",
additionalProperties: true,
description: "Which records this card came out of, and which came out of it. Both are read off the origin field, so the direction is exact — the graph edge alone cannot tell provenance from any other explicit link.",
properties: {
origin: strings("Records this card was discovered while working on."),
spawned: strings("Cards that declare this record as their origin.")
}
},
generatedAt: text("When the bundle was assembled, RFC 3339."),

@@ -652,2 +661,3 @@ truncated: flag("True when relevant records were dropped to respect limit."),

related: strings("IDs of records worth reading alongside this one."),
origin: strings("IDs of the records this work came out of — the card being worked when it was discovered, the decision that spawned it. Any record kind, not cards only. Unlike parent, it does not make this card part of them."),
effort: choice(CARD_EFFORTS, "Rough size: S, M or L."),

@@ -674,3 +684,4 @@ start: text("Planned start date, YYYY-MM-DD."),

scope: stringList(args.scope, "scope"),
related: stringList(args.related, "related")
related: stringList(args.related, "related"),
origin: stringList(args.origin, "origin")
});

@@ -677,0 +688,0 @@ invalidate(context);

@@ -18,12 +18,19 @@ /**

export declare function recordFromMemory(record: any): any;
export declare function recordReferences(record: any): any[];
export declare function recordReferences(record: any): string[];
/**
* References split by how they were declared.
* References named after whatever declared them.
*
* An ID written in prose is not the same thing as one listed in `depends` or
* `related`, but both used to arrive labelled `reference` and a consumer had no
* way to tell them apart. On a real workspace that made ~43% of the graph's
* edges prose, which is noise for anything trying to follow real dependencies.
* An ID written in prose is not the same thing as one listed in `depends`, and
* a `depends` is not the same thing as an `origin` — but all three used to
* arrive labelled `reference`, so a consumer could tell a real dependency from
* a sentence and nothing more. On a real workspace prose is ~38% of the edges;
* splitting the rest by the field that produced them is that same argument one
* level down, and it is what lets a view offer a filter per relationship rather
* than a two-way switch.
*
* The value is a list, ordered strongest first. `wikilink` is kept apart from
* both: `[[T-0042]]` is a deliberate link, which a bare ID in a sentence is
* not, but it is still prose and does not outrank a declared field.
*/
export declare function classifiedReferences(record: any): Map<string, string>;
export declare function classifiedReferences(record: any): Map<string, string[]>;
export declare function createDefaultCollectionRegistry(): {

@@ -30,0 +37,0 @@ register: (collection: any) => /*elided*/ any;

@@ -64,50 +64,120 @@ import { posix, resolve } from "node:path";

}
/**
* The frontmatter fields that carry record IDs, per record kind.
*
* One table rather than a branch per kind, because two functions read it and
* they disagreed silently when it was written twice: `origin` reached the ID
* list and the relation classifier separately, and either could have been
* missed. A kind absent here still carries `related`, which every record has.
*/
const REFERENCE_FIELDS = {
card: ["parent", "depends", "origin", "related"],
doc: ["supersedes", "related"],
change: ["cards", "decisions", "related"],
release: ["fragments"],
memory: [
"supersedes",
"superseded_by",
"graduated_to",
"corrective_actions",
"related"
]
};
/**
* Every declared reference, keyed by target, carrying the fields that made it.
*
* A set of fields rather than one, because a pair can hold more than one
* relationship at a time and the index used to keep whichever it saw first. On
* this repository that hid 11 of 21 `origin` edges: each was a card that also
* had `depends` or `related` to the same record, so the provenance merged into
* the edge already there and became unrenderable as provenance.
*/
function fieldReferences(record) {
const found = new Map();
const add = (id, field) => {
if (!id || id === record.id)
return;
if (!found.has(id))
found.set(id, new Set());
found.get(id).add(field);
};
for (const field of REFERENCE_FIELDS[record.kind] || ["related"]) {
const value = record[field];
if (!value)
continue;
if (Array.isArray(value))
for (const id of value)
add(id, field);
else
add(String(value), field);
}
return found;
}
export function recordReferences(record) {
const explicit = [];
if (record.kind === "card") {
if (record.parent)
explicit.push(record.parent);
explicit.push(...(record.depends || []), ...(record.related || []));
}
else if (record.kind === "doc") {
explicit.push(...(record.related || []), ...(record.supersedes || []));
}
else if (record.kind === "change") {
explicit.push(...(record.cards || []), ...(record.decisions || []), ...(record.related || []));
}
else if (record.kind === "release") {
explicit.push(...(record.fragments || []));
}
else if (record.kind === "memory") {
explicit.push(...(record.related || []), ...(record.supersedes || []), ...(record.superseded_by || []), ...(record.graduated_to || []), ...(record.corrective_actions || []));
}
else {
explicit.push(...(record.related || []));
}
const inline = String(record.body || "").match(RECORD_ID_RE) || [];
return [...new Set([...explicit, ...inline])].filter((reference) => reference && reference !== record.id);
return [...new Set([...fieldReferences(record).keys(), ...inline])].filter((reference) => reference && reference !== record.id);
}
/**
* References split by how they were declared.
* References named after whatever declared them.
*
* An ID written in prose is not the same thing as one listed in `depends` or
* `related`, but both used to arrive labelled `reference` and a consumer had no
* way to tell them apart. On a real workspace that made ~43% of the graph's
* edges prose, which is noise for anything trying to follow real dependencies.
* An ID written in prose is not the same thing as one listed in `depends`, and
* a `depends` is not the same thing as an `origin` — but all three used to
* arrive labelled `reference`, so a consumer could tell a real dependency from
* a sentence and nothing more. On a real workspace prose is ~38% of the edges;
* splitting the rest by the field that produced them is that same argument one
* level down, and it is what lets a view offer a filter per relationship rather
* than a two-way switch.
*
* The value is a list, ordered strongest first. `wikilink` is kept apart from
* both: `[[T-0042]]` is a deliberate link, which a bare ID in a sentence is
* not, but it is still prose and does not outrank a declared field.
*/
export function classifiedReferences(record) {
const explicit = new Set(recordReferences({ ...record, body: "" }));
const relations = fieldReferences(record);
const note = (id, relation) => {
if (!id || id === record.id)
return;
if (!relations.has(id))
relations.set(id, new Set());
relations.get(id).add(relation);
};
for (const match of String(record.body || "").matchAll(WIKI_LINK_RE)) {
if (match[1] !== record.id)
explicit.add(match[1]);
note(match[1], "wikilink");
}
const relations = new Map();
for (const id of explicit)
relations.set(id, "reference");
for (const id of recordReferences(record)) {
if (!relations.has(id))
relations.set(id, "mention");
note(id, "mention");
}
return relations;
return new Map([...relations].map(([id, fields]) => [id, rankRelations([...fields])]));
}
/**
* Ranked strongest first: a declared field beats a link, a link beats a bare ID.
*
* Consulted twice for different reasons — to pick the primary name a link
* reports, and to decide which backlinks survive truncation on a record
* everybody cites. Unknown names sort last rather than throwing, so a field
* added to `REFERENCE_FIELDS` without a rank degrades to prose-level ordering
* instead of taking an accidental place at the front.
*/
const RELATION_RANK = {
source: 0,
parent: 1,
depends: 1,
origin: 1,
supersedes: 1,
superseded_by: 1,
graduated_to: 1,
corrective_actions: 1,
cards: 1,
decisions: 1,
fragments: 1,
related: 2,
wikilink: 3,
markdown: 4,
mention: 5
};
function rankRelations(relations) {
return [...relations].sort((left, right) => (RELATION_RANK[left] ?? 9) - (RELATION_RANK[right] ?? 9) ||
left.localeCompare(right));
}
function markdownDocumentPaths(record) {

@@ -144,20 +214,32 @@ const links = [];

const targets = classifiedReferences(record);
// Both of these add to whatever the frontmatter already declared rather
// than replacing or skipping it. A card whose `source` path resolves to
// a document it also lists in `related` holds both relationships, and
// the reader that wants to follow sources must not lose it because the
// reader that wants `related` got there first.
const also = (id, relation) => {
if (!id || id === record.id)
return;
targets.set(id, rankRelations([...(targets.get(id) || []), relation]));
};
if (record.kind === "card" && record.source) {
const sourcePath = normalizeRepoPath(String(record.source).split("#", 1)[0]);
const sourceRecord = byPath.get(sourcePath);
if (sourceRecord && sourceRecord.id !== record.id) {
targets.set(sourceRecord.id, "source");
}
also(byPath.get(sourcePath)?.id, "source");
}
for (const linkedPath of markdownDocumentPaths(record)) {
const linkedRecord = byPath.get(linkedPath);
if (linkedRecord && linkedRecord.id !== record.id) {
if (!targets.has(linkedRecord.id)) {
targets.set(linkedRecord.id, "markdown");
}
}
also(byPath.get(linkedPath)?.id, "markdown");
}
record.outgoing = [...targets].map(([id, relation]) => ({
record.outgoing = [...targets].map(([id, relations]) => ({
id,
relation,
// `relation` stays, and stays a string: it is what every existing
// consumer reads and what the UI prints on a badge. It is now the
// strongest of the relationships rather than the only one kept.
relation: relations[0],
// And `relations` appears only when it says something `relation`
// does not. 30 of this repository's 742 edges hold more than one
// relationship, so carrying the array on all of them spent 3,636
// bytes of a 33,000-byte search payload restating the singular —
// enough to breach the budget on its own. Read it as
// `link.relations ?? [link.relation]`.
...(relations.length > 1 ? { relations } : {}),
exists: byId.has(id),

@@ -180,2 +262,3 @@ ...(byId.has(id)

relation: link.relation,
...(link.relations ? { relations: link.relations } : {}),
kind: record.kind,

@@ -186,3 +269,2 @@ title: record.title

}
const RELATION_RANK = { source: 0, reference: 1, markdown: 2, mention: 3 };
for (const record of records) {

@@ -670,3 +752,11 @@ const all = incoming.get(record.id) || [];

"archived",
// All four card edges, not just `parent`. A listing that carries one of
// them makes the reader open the file to find the rest, and a view drawing
// the graph from a summary projection cannot draw what it never received —
// it would have shown hierarchy and provenance while silently omitting
// every blocking and loose edge.
"parent",
"depends",
"origin",
"related",
"milestone",

@@ -706,2 +796,31 @@ "tags",

export function projectRecord(record, view = "full", fields = null) {
// A node and its edges, and nothing a canvas cannot draw.
//
// Its own view rather than `summary` with fields trimmed, because the
// difference is not marginal: the same 332 records cost 305 KB as summaries
// and 74 KB here, and the graph wants all of them at once rather than a
// page. What goes is the per-link title and path — a canvas resolves those
// from the node it already holds — along with the excerpt, the revision and
// every date.
//
// Edges to IDs that resolve to nothing are dropped. Prose scanning turns
// the SPEC's citation of RFC 2119 into a reference, and a graph is the one
// reader that would draw `RFC-2119` as a node.
if (view === "graph") {
return {
id: record.id,
kind: record.kind,
recordType: record.recordType,
title: record.title,
...(record.status ? { status: record.status } : {}),
...(record.area ? { area: record.area } : {}),
...(record.archived ? { archived: true } : {}),
edges: (record.outgoing || [])
.filter((link) => link.exists)
.map((link) => ({
to: link.id,
rel: link.relations ?? [link.relation]
}))
};
}
if (fields?.length) {

@@ -739,4 +858,19 @@ return Object.fromEntries(fields

if (view === "summary") {
projected.outgoing = (record.outgoing || []).map(({ id, relation, exists }) => ({ id, relation, exists }));
projected.incoming = (record.incoming || []).map(({ id, relation }) => ({ id, relation }));
// `relations` travels with them. This projection is what anything
// drawing the graph asks for — the full view carries every body — and
// rebuilding the link by hand dropped the one field that says a pair
// holds more than one relationship, which is most of what a reader
// filtering by edge type is looking for. Still absent when there is
// only one, so the cost is paid by the 4% of edges that carry it.
projected.outgoing = (record.outgoing || []).map(({ id, relation, relations, exists }) => ({
id,
relation,
...(relations ? { relations } : {}),
exists
}));
projected.incoming = (record.incoming || []).map(({ id, relation, relations }) => ({
id,
relation,
...(relations ? { relations } : {})
}));
}

@@ -743,0 +877,0 @@ return projected;

@@ -98,3 +98,2 @@ export type CardStatus = "backlog" | "next" | "doing" | "review" | "blocked" | "deferred" | "done" | "discarded";

open: boolean;
defaultView: string;
}

@@ -252,2 +251,10 @@ export interface ProjectConfig {

related?: string[];
/**
* Records this card came out of.
*
* Provenance, not decomposition: `parent` says the card is part of another,
* `origin` says it was discovered while working on one. Holds ids of any
* kind, because decisions and learnings spawn work as often as cards do.
*/
origin?: string[];
scope?: string[];

@@ -315,3 +322,16 @@ tags?: string[];

id: string;
/**
* The strongest relationship this edge carries, named after the field that
* declared it: `parent`, `depends`, `origin`, `related`, `supersedes`,
* `cards`, `fragments` and so on, plus `source`, `markdown` for a link to a
* document's path, `wikilink` for `[[T-0042]]`, and `mention` for a bare ID
* in prose.
*/
relation: string;
/**
* Every relationship the pair holds, strongest first, and present **only
* when there is more than one** — read it as `relations ?? [relation]`. A
* card can come out of another and also depend on it.
*/
relations?: string[];
exists?: boolean;

@@ -368,2 +388,4 @@ kind?: ProjectRecord["kind"];

related?: string[];
/** Records this card came out of; see `CardRecord.origin`. */
origin?: string[];
start?: string;

@@ -370,0 +392,0 @@ due?: string;

@@ -13,9 +13,8 @@ <!doctype html>

/>
<script type="module" crossorigin src="/static/index-DEiK6_Ib.js"></script>
<script type="module" crossorigin src="/static/index-Dpy209ef.js"></script>
<link rel="modulepreload" crossorigin href="/static/rolldown-runtime-CbXtAM7H.js">
<link rel="modulepreload" crossorigin href="/static/react-Buq45Vzz.js">
<link rel="modulepreload" crossorigin href="/static/ui-primitives-wYj92QGw.js">
<link rel="modulepreload" crossorigin href="/static/empty-BHqXimMR.js">
<link rel="modulepreload" crossorigin href="/static/native-select-NN1SzVJL.js">
<link rel="stylesheet" crossorigin href="/static/index-H5jAYVUH.css">
<link rel="modulepreload" crossorigin href="/static/ui-primitives-Beqd9I2k.js">
<link rel="modulepreload" crossorigin href="/static/theme-CNCrPl--.js">
<link rel="stylesheet" crossorigin href="/static/index-DPooA1WI.css">
</head>

@@ -22,0 +21,0 @@ <body>

@@ -59,2 +59,26 @@ # CLI reference

## Accepted spellings
The dispatcher answers to more words than this reference spells. Each pair below
reaches the same code — there is no behavioural difference, and neither spelling
is deprecated. The left column is what the rest of this document uses.
| Documented | Also accepted |
| --- | --- |
| `workfile doc …` | `workfile docs …` |
| `workfile changelog …` | `workfile history …` |
| `workfile ui` | `workfile serve` |
| `workfile agents check` | `workfile agents status` |
| `workfile ci check` | `workfile ci status` |
| `workfile changelog add` | `workfile changelog create` |
| `workfile memory add` | `workfile memory create` |
| `workfile claude install` | `workfile claude sync` |
| `workfile mcp serve` | `workfile mcp stdio` |
They are listed because an alias nobody documents is one nobody can rely on: it
resolves today, it is not in `--help`, and the only way to learn it is to read
the dispatcher. A test requires every subcommand the binary accepts to be named
somewhere in this file, so a new spelling that skips this table fails the suite
rather than arriving undocumented.
## Workspace

@@ -64,2 +88,3 @@

workfile init [--root PATH] [--yes] [--dry-run] [--name NAME] [--language LANG]
workfile version # the installed package version, one line
workfile schema [--json] # effective runtime schema (areas, vocabularies…)

@@ -162,3 +187,4 @@ workfile doctor [--json] [--severity error|warning] [--max-issues N] [--rebuild-cache] [--fix]

[--parent ID] [--source PATH] [--tags a,b] [--scope PATH,PATH]
[--depends ID,ID] [--related ID,ID] [--milestone M] [--effort S|M|L]
[--depends ID,ID] [--related ID,ID] [--origin ID,ID]
[--milestone M] [--effort S|M|L]
[--start DATE] [--due DATE] [--body TEXT] [--axis NAME=VALUE]

@@ -197,2 +223,11 @@ workfile card create --json-input FILE

`--origin ID,ID` records which records the work came out of — the card being
worked when it was found, the decision that produced it. Any record kind, not
cards only. It is provenance, not decomposition: use `--parent` when the card is
genuinely part of another, and `--origin` when it merely came out of it. There
is no `card patch --origin`; patching any card field goes through
`--json-input`, the same as every other field. `agents context --card ID` reads
it back in both directions, and `doctor` reports an origin that resolves to
nothing.
`--axis NAME=VALUE` writes a classification axis the project declares under

@@ -341,2 +376,22 @@ `cards.axes` — a second axis alongside `area`, for domains rather than delivery

## Claude Code
```bash
workfile claude install [--dry-run] [--force]
workfile claude check [--json]
```
`install` writes the Claude Code surface into the repository — the MCP server
registration, the slash commands, the skill and the session hooks — as managed
blocks a later resync updates without touching anything around them. `check`
reports which of them are stale and exits `1` when any is, which is what makes
it usable in CI.
`workfile claude` with no subcommand runs `check`, because reporting is the
safe default for a word that otherwise writes files.
Neither command is what installs the *package* into a Claude Code session:
a client reads `.mcp.json` and starts the server itself. See
[mcp.md](mcp.md) for what `install` writes and what each hook does.
## CI templates

@@ -343,0 +398,0 @@

@@ -52,3 +52,3 @@ # MCP server

| --- | --- |
| `.mcp.json` | Registers `workfile-mcp` — the binary that parses its own flags |
| `.mcp.json` | Registers the server, exactly as below |
| `.claude/commands/{next,claim,done,context}.md` | Slash commands over one CLI call each |

@@ -58,2 +58,21 @@ | `.claude/skills/workfile/SKILL.md` | Projects `.project/agents/protocol.md` rather than restating it |

```json
{
"mcpServers": {
"workfile": {
"command": "npx",
"args": ["-y", "@illodev/workfile", "mcp"]
}
}
}
```
It registers the package and the `mcp` subcommand, not the `workfile-mcp` bin.
That bin exists and parses its own flags — `workfile mcp config` emits it, for
hosts building a configuration themselves — but `npx` cannot select a named bin
from a package spec, so registering it that way started the CLI instead of the
server and every request was answered with the help text on stdout. T-0116
changed it in 0.4.0; this table went on describing the old behaviour until it
was corrected.
**`SessionStart`** injects the board once — cards in flight, who holds them,

@@ -195,2 +214,19 @@ which paths they cover — so a session begins informed without reading a record.

## Limits
Two, both from `project.config.mjs`, and they guard opposite directions.
| Key | Default | What it does |
| --- | --- | --- |
| `mcp.maxMessageBytes` | 1 MiB | An incoming JSON-RPC line larger than this is refused with `-32600` before it is parsed. |
| `mcp.maxToolResultBytes` | 512 KiB | A result larger than this is truncated with a `truncated` marker rather than failing the call. |
Both accept 1 KiB to 16 MiB. The asymmetry between them is deliberate: an
oversized *request* is a client defect and failing it early is the honest
answer, while an oversized *result* is usually a get-by-id with no query to
narrow, so degrading beats refusing.
`mcp.resourcePageSize` (default 100, range 1–500) bounds how many records one
resource read returns.
## Process hygiene

@@ -197,0 +233,0 @@

{
"name": "@illodev/workfile",
"version": "0.5.4",
"version": "0.6.0",
"type": "module",

@@ -5,0 +5,0 @@ "mcpName": "io.github.illodev/workfile",

import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{_t as r,mt as i,pt as a,rt as o}from"./ui-primitives-wYj92QGw.js";import{a as s,f as c,i as l,m as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./empty-BHqXimMR.js";import{A as _,G as v,Q as y,U as b,X as x,Y as S,Z as C,j as w,n as T,q as E,r as D,t as O}from"./index-DEiK6_Ib.js";var k=e(t(),1),A=n(),j=[];function M(e,t){let[n,r]=(0,k.useState)(t);(0,k.useEffect)(()=>{r(t)},[e.length,t]);let i=(0,k.useCallback)(()=>r(n=>Math.min(n+t,e.length)),[e.length,t]);return[n>=e.length?e:e.slice(0,n),n<e.length,i]}function N({onVisible:e,remaining:t}){let n=(0,k.useRef)(null);return(0,k.useEffect)(()=>{let t=n.current;if(!t)return;let r=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&e()},{rootMargin:`600px 0px`});return r.observe(t),()=>r.disconnect()},[e,t]),(0,A.jsxs)(`span`,{ref:n,className:`px-0.5 py-1 font-mono text-[11px] text-muted-foreground`,children:[`+`,t,` more`]})}function P({task:e,epicId:t,onOpen:n,onDragStart:r,onCarry:i,carrying:a}){let o=e.claimed_at?Date.parse(e.claimed_at.includes(`T`)?e.claimed_at:`${e.claimed_at}T00:00:00`):NaN,s=Number.isNaN(o)?null:Math.max(0,Math.floor((Date.now()-o)/864e5)),l=[t&&t!==e.id?`epic ${t}`:``,e.effort?`effort ${e.effort}`:``,e.claimed_by?`claimed by ${e.claimed_by}${s==null?``:` · ${s}d`}`:``].filter(Boolean);return(0,A.jsxs)(`article`,{className:u(`flex cursor-pointer flex-col gap-1.5 rounded-lg border bg-background px-3 py-2.5 shadow-xs outline-none transition-[color,border-color,box-shadow] hover:border-ring focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,a&&`border-ring ring-2 ring-ring`),tabIndex:0,draggable:!!r,"aria-grabbed":i?!!a:void 0,title:l.length?l.join(` · `):void 0,onClick:()=>n(e.id),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n(e.id)):t.key===` `&&i?(t.preventDefault(),i()):t.key===` `&&(t.preventDefault(),n(e.id))},onDragStart:r,children:[(0,A.jsxs)(`span`,{className:`flex items-center`,children:[(0,A.jsx)(`span`,{className:`font-mono text-[11px] text-foreground/70`,children:e.id}),(0,A.jsx)(`span`,{className:`flex-1`}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] font-medium`,style:{color:m(e.priority)},children:e.priority})]}),(0,A.jsx)(`span`,{className:`text-[12.5px] leading-snug font-medium`,role:`heading`,"aria-level":3,children:e.title}),(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground`,children:[(0,A.jsx)(`span`,{children:e.area}),(0,A.jsx)(`span`,{children:`·`}),(0,A.jsx)(`span`,{children:e.type}),e.claimed_by?(0,A.jsxs)(`span`,{className:`ml-auto inline-flex min-w-0 items-center gap-[5px]`,style:{color:c(`doing`)},children:[(0,A.jsx)(`span`,{className:`size-[5px] flex-none rounded-full bg-current`,"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`max-w-[90px] truncate`,children:e.claimed_by})]}):null]}),Array.isArray(e.scope)&&e.scope.length?(0,A.jsxs)(`span`,{className:`mt-0.5 truncate border-t border-dashed pt-1.5 font-mono text-[10.5px] text-muted-foreground`,children:[`scope `,e.scope.join(` · `)]}):null]})}function F({status:e,cards:t,epicIds:n,collapsed:r,onToggleCollapsed:m,onOpen:g,onMove:v,onCarry:b,carryingId:x,isDropTarget:S,onDragEnterColumn:C,onDragLeaveColumn:T}){let[E,D,O]=M(t,25),k=c(e),j={onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,C?.(e)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||T?.(e)},onDrop:t=>{t.preventDefault(),T?.(e);let n=t.dataTransfer.getData(`text/plain`);n&&v(n,e).catch(()=>void 0)}};return r?(0,A.jsxs)(w,{role:`region`,"aria-label":`${e}, ${t.length} cards, collapsed`,className:u(`relative w-11 flex-none gap-0 overflow-hidden rounded-lg py-0 shadow-xs`,S&&`border-primary`),...j,children:[(0,A.jsx)(_,{edge:`top`,color:k}),(0,A.jsxs)(`button`,{type:`button`,"aria-expanded":!1,"aria-label":`Expand the ${e} column`,title:`${e} · ${t.length}`,className:u(`flex h-full w-full cursor-pointer flex-col items-center gap-2.5 px-1 pt-4 pb-3 transition-colors hover:bg-accent/50`,S&&`bg-accent/50`),onClick:m,children:[(0,A.jsx)(i,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,A.jsx)(`span`,{className:`min-h-0 flex-1 truncate font-mono text-[11px] uppercase tracking-[0.06em] [writing-mode:vertical-rl]`,style:{color:k},children:e}),(0,A.jsx)(y,{variant:`secondary`,className:`h-5 shrink-0 rounded-md px-[7px] font-mono text-[11px] font-normal`,children:t.length})]})]}):(0,A.jsxs)(w,{role:`region`,"aria-label":`${e}, ${t.length} cards`,className:u(`relative w-[268px] flex-none gap-0 overflow-hidden rounded-lg py-0 shadow-xs`,S&&`border-primary`),...j,children:[(0,A.jsx)(_,{edge:`top`,color:k}),(0,A.jsxs)(`header`,{className:`flex flex-none items-center gap-2 px-3 pb-2.5 pt-4`,children:[(0,A.jsx)(`span`,{className:`flex-1 font-mono text-[11px] uppercase tracking-[0.06em]`,style:{color:k},children:e}),(0,A.jsx)(y,{variant:`secondary`,className:`h-5 rounded-md px-[7px] font-mono text-[11px] font-normal`,children:t.length}),m?(0,A.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-expanded":!0,"aria-label":`Collapse the ${e} column`,title:`Collapse column`,className:`-mr-1 text-muted-foreground`,onClick:m,children:(0,A.jsx)(a,{"aria-hidden":`true`})}):null]}),(0,A.jsxs)(`div`,{className:u(`scroll-fade flex flex-1 flex-col gap-2 overflow-y-auto p-2.5`,S&&`bg-accent/50`),children:[t.length===0?(0,A.jsx)(h,{className:`flex-1 gap-2 rounded-lg border border-dashed p-4`,children:(0,A.jsxs)(l,{className:`gap-1`,children:[(0,A.jsx)(s,{variant:`icon`,className:`mb-0 size-8 [&_svg:not([class*='size-'])]:size-4`,children:(0,A.jsx)(o,{"aria-hidden":`true`})}),(0,A.jsx)(d,{className:`text-[12.5px] font-medium`,children:`No cards`}),(0,A.jsx)(p,{className:`text-[11.5px]`,children:`Nothing in this state.`})]})}):E.map(e=>(0,A.jsx)(P,{task:e,epicId:n.get(e.id),onOpen:g,onCarry:b?()=>b(e):void 0,carrying:x===e.id,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id)}},e.id)),D&&(0,A.jsx)(N,{onVisible:O,remaining:t.length-E.length})]})]})}function I({tasks:e,epicIds:t,showClosed:n,onOpen:r,onMove:i}){let[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(()=>{try{let e=localStorage.getItem(`workfile-flow-collapsed`);return new Set(e?JSON.parse(e):[])}catch{return new Set}}),p=(0,k.useCallback)(e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),localStorage.setItem(`workfile-flow-collapsed`,JSON.stringify([...n])),n})},[]),m=(0,k.useMemo)(()=>[`backlog`,`next`,`doing`,`review`,`blocked`,`deferred`,...n?[`done`,`discarded`]:[]],[n]),h=(0,k.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.status);e?e.push(n):t.set(n.status,[n])}return t},[e]),g=e=>{o({id:e.id,status:e.status}),u(`${e.id} picked up from ${e.status}. Use the arrow keys to choose a column, space to drop, escape to cancel.`)},_=e=>{if(!a)return;let t=m.indexOf(a.status),n=m[Math.min(m.length-1,Math.max(0,t+e))];!n||n===a.status||(o({...a,status:n}),u(`${a.id} over ${n}.`))},v=async()=>{if(!a)return;let t=a;o(null);let n=e.find(e=>e.id===t.id);n&&n.status!==t.status?(await i(t.id,t.status),u(`${t.id} moved to ${t.status}.`)):u(`${t.id} put back.`)};return(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-3 overflow-x-auto p-3.5`,onDragEnd:()=>c(null),onKeyDown:e=>{a&&(e.key===`Escape`?(e.preventDefault(),o(null),u(`Move cancelled.`)):e.key===`ArrowRight`?(e.preventDefault(),_(1)):e.key===`ArrowLeft`?(e.preventDefault(),_(-1)):(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),v()))},children:[(0,A.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:l}),m.map(e=>(0,A.jsx)(F,{status:e,cards:h.get(e)??j,epicIds:t,collapsed:d.has(e),onToggleCollapsed:()=>p(e),onOpen:r,onMove:i,onCarry:g,carryingId:a?.id??null,isDropTarget:a?.status===e||s===e,onDragEnterColumn:c,onDragLeaveColumn:e=>c(t=>t===e?null:t)},e))]})}function L({tasks:e,allTasks:t,epicIds:n,onOpen:r}){let i=(0,k.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),a=(0,k.useMemo)(()=>{let t=new Map;for(let r of e){let e=n.get(r.id)||(r.type===`epic`?r.id:`__none`);t.has(e)||t.set(e,[]),r.id!==e&&t.get(e)?.push(r)}return[...t].sort(([e],[t])=>e===`__none`?1:t===`__none`?-1:e.localeCompare(t,void 0,{numeric:!0}))},[n,e]);return a.length?(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3.5`,children:(0,A.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:a.map(([e,t])=>{let n=i.get(e),a=t.length,o=t.filter(e=>e.status===`done`||e.status===`discarded`).length,s=t.filter(e=>e.status===`doing`).length,l=a-o-s,d=e=>a?`${e/a*100}%`:`0%`,f=[{label:`${o} done`,color:c(`done`)},{label:`${s} doing`,color:c(`doing`)},{label:`${l} open`,color:null}],p=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,A.jsx)(`span`,{className:`font-mono text-[11.5px] text-foreground/70`,children:e===`__none`?`—`:e}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-semibold tracking-[-0.01em] text-pretty`,children:n?.title||`Without epic`}),n?(0,A.jsx)(`span`,{className:`font-mono text-[11px]`,style:{color:c(n.status)},children:n.status}):null,(0,A.jsxs)(`span`,{className:`font-mono text-[11.5px] text-muted-foreground`,children:[o,`/`,a]})]}),(0,A.jsx)(`span`,{className:`flex h-2 w-full overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:a>0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`h-full`,style:{width:d(o),background:c(`done`)}}),(0,A.jsx)(`span`,{className:`h-full`,style:{width:d(s),background:c(`doing`)}})]}):null}),(0,A.jsxs)(`span`,{className:`flex flex-wrap items-center gap-3.5 font-mono text-[10.5px] text-muted-foreground`,children:[f.map(e=>(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-[5px]`,children:[(0,A.jsx)(`span`,{className:u(`size-1.5 rounded-[2px]`,!e.color&&`bg-muted-foreground`),style:e.color?{background:e.color}:void 0,"aria-hidden":`true`}),e.label]},e.label)),(0,A.jsx)(`span`,{className:`ml-auto`,children:n?.area??``})]})]});return n?(0,A.jsx)(`button`,{type:`button`,className:`flex w-full cursor-pointer flex-col gap-2.5 rounded-xl border bg-card px-4 py-3.5 text-left text-card-foreground shadow-xs outline-none transition-[color,border-color,box-shadow] hover:border-ring focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,onClick:()=>r(e),children:p},e):(0,A.jsx)(w,{className:`gap-2.5 rounded-xl px-4 py-3.5 shadow-xs`,children:p},e)})})}):(0,A.jsx)(h,{className:`flex-1 p-6`,children:(0,A.jsxs)(l,{children:[(0,A.jsx)(d,{className:`text-sm`,children:`No epics`}),(0,A.jsx)(p,{className:`text-[11.5px]`,children:`No cards match the current filters.`})]})})}var R=300,z=30;function B({task:e,span:t,mode:n,epicId:r,pct:i,labelWidth:a,onOpen:o}){let s=c(e.status);return(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),title:`${D(e,n,t)} · ${e.status}${r&&r!==e.id?` · epic ${r}`:``}`,className:`flex w-full cursor-pointer items-center border-b bg-transparent p-0 text-left transition-colors hover:bg-muted`,children:[(0,A.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 border-r px-3.5`,style:{width:a,flex:`0 0 ${a}px`,height:`var(--row-h)`},children:[(0,A.jsx)(`span`,{className:`flex-none whitespace-nowrap font-mono text-[11px] text-foreground/70`,children:e.id}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-[12.5px]`,children:e.title})]}),(0,A.jsx)(`span`,{className:`relative block flex-1`,style:{height:`var(--row-h)`},children:t.point?(0,A.jsx)(`span`,{style:{position:`absolute`,top:`50%`,width:9,height:9,transform:`translate(-50%, -50%) rotate(45deg)`,borderRadius:2,background:s,display:`block`,left:`${i(t.from)}%`}}):(0,A.jsx)(`span`,{style:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,height:12,minWidth:6,borderRadius:3,background:s,display:`block`,left:`${i(t.from)}%`,width:`${Math.max(i(t.to)-i(t.from),.8)}%`}})})]})}function V({tasks:e,epicIds:t,axes:n={},mode:i,counts:a,onModeChange:o,onOpen:s}){let c=b()?168:R,u=c+460,[m,_]=(0,k.useState)(()=>{try{return localStorage.getItem(`workfile-timeline-group`)||`none`}catch{return`none`}}),y=(0,k.useCallback)(e=>{_(e);try{localStorage.setItem(`workfile-timeline-group`,e)}catch{}},[]),w=(0,k.useMemo)(()=>[`none`,`epic`,`area`,...Object.keys(n)],[n]),D=w.includes(m)?m:`none`,j=(0,k.useCallback)(e=>{if(D===`epic`)return t.get(e.id)||``;if(D===`area`)return e.area||``;let n=e[D];return typeof n==`string`?n:``},[t,D]),M=(0,k.useMemo)(()=>{let t=new Map;for(let n of e){let e=T(n,i);e&&t.set(n.id,e)}return t},[i,e]),N=(0,k.useMemo)(()=>{let t=(e,t)=>M.get(e.id).from-M.get(t.id).from||e.id.localeCompare(t.id),n=e.filter(e=>M.has(e.id)).sort(t);return D===`none`?n:[...n].sort((e,n)=>{let r=j(e),i=j(n);return!r==!i?r.localeCompare(i)||t(e,n):r?-1:1})},[j,D,M,e]),P=(0,k.useMemo)(()=>{if(D===`none`)return N.map(e=>({task:e,label:null}));let e=[],t=null;for(let n of N){let r=j(n);r!==t&&(t=r,e.push({task:null,label:r||`no ${D}`})),e.push({task:n,label:null})}return e},[j,D,N]),F=(0,k.useMemo)(()=>new Map(P.flatMap((e,t)=>e.task?[[e.task.id,t]]:[])),[P]),I=(0,k.useMemo)(()=>{let e=[];for(let t of N)for(let n of t.depends||[])F.has(n)&&e.push({from:n,to:t.id});return e},[F,N]),L=(0,k.useMemo)(()=>O(N.map(e=>M.get(e.id)),Date.now()),[N,M]),V=a[i===`plan`?`actual`:`plan`];return!N.length||!L?(0,A.jsx)(h,{className:`flex-1 p-6`,children:(0,A.jsxs)(l,{children:[(0,A.jsx)(d,{className:`text-sm`,children:i===`plan`?`Nothing scheduled`:`Nothing recorded`}),(0,A.jsx)(p,{className:`text-[11.5px]`,children:i===`plan`?`Add a start or due date to a card.`:`Cards record a trail as they are claimed and moved.`}),V>0?(0,A.jsx)(p,{className:`text-[11.5px]`,children:(0,A.jsx)(f,{variant:`outline`,size:`sm`,className:`mt-2 text-[12.5px] font-medium`,onClick:()=>o(i===`plan`?`actual`:`plan`),children:i===`plan`?`show what actually happened · ${V} cards`:`show the schedule · ${V} cards`})}):null]})}):(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`div`,{className:`no-scrollbar flex flex-none items-center gap-2.5 overflow-x-auto border-b bg-card px-3.5 py-2`,children:[(0,A.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] whitespace-nowrap text-muted-foreground`,children:[N.length,` `,i===`actual`?`recorded`:`scheduled`,` ·`,` `,I.length,` dependenc`,I.length===1?`y`:`ies`]}),(0,A.jsxs)(v,{children:[(0,A.jsx)(C,{asChild:!0,children:(0,A.jsxs)(f,{variant:`outline`,size:`sm`,"aria-label":`dates`,className:`ml-auto shrink-0 text-[12.5px] font-medium`,children:[`dates`,(0,A.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:i}),(0,A.jsx)(r,{className:`size-[13px] text-muted-foreground`})]})}),(0,A.jsx)(E,{align:`end`,children:(0,A.jsxs)(S,{value:i,onValueChange:e=>o(e),children:[(0,A.jsx)(x,{value:`plan`,children:`plan`}),(0,A.jsx)(x,{value:`actual`,children:`actual`})]})})]}),(0,A.jsxs)(v,{children:[(0,A.jsx)(C,{asChild:!0,children:(0,A.jsxs)(f,{variant:`outline`,size:`sm`,"aria-label":`group`,className:`shrink-0 text-[12.5px] font-medium`,children:[`group`,(0,A.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:D}),(0,A.jsx)(r,{className:`size-[13px] text-muted-foreground`})]})}),(0,A.jsx)(E,{align:`end`,children:(0,A.jsx)(S,{value:D,onValueChange:y,children:w.map(e=>(0,A.jsx)(x,{value:e,children:e},e))})})]})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,A.jsxs)(`div`,{className:`relative min-h-full`,style:{minWidth:u},children:[(0,A.jsxs)(`div`,{"aria-hidden":`true`,className:`sticky top-0 z-[2] flex items-stretch border-b bg-card`,style:{height:z},children:[(0,A.jsx)(`span`,{className:`flex items-center border-r px-3.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,style:{width:c,flex:`0 0 ${c}px`},children:`card`}),(0,A.jsx)(`span`,{className:`relative flex-1`,children:L.ticks.map((e,t)=>(0,A.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,style:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,left:`${e.left}%`,width:`${(L.ticks[t+1]?.left??100)-e.left}%`,overflow:`hidden`,paddingLeft:8,whiteSpace:`nowrap`},children:e.label},e.key))})]}),(0,A.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute`,style:{top:z,bottom:0,left:c,right:0},children:[L.ticks.map(e=>(0,A.jsx)(`span`,{className:`absolute inset-y-0 w-px bg-border`,style:{left:`${e.left}%`}},e.key)),L.today!=null&&(0,A.jsx)(`span`,{className:`absolute inset-y-0 w-px`,style:{background:g(`error`),opacity:.55,left:`${L.today}%`}})]}),(0,A.jsxs)(`div`,{className:`relative`,children:[I.length>0&&(0,A.jsx)(`svg`,{"aria-hidden":`true`,preserveAspectRatio:`none`,viewBox:`0 0 100 ${P.length}`,className:`pointer-events-none absolute top-0 h-full`,style:{left:c,width:`calc(100% - ${c}px)`},children:I.map(e=>{let t=M.get(e.from),n=M.get(e.to);if(!t||!n)return null;let r=L.pct(t.to),i=L.pct(n.from),a=F.get(e.from)+.5,o=F.get(e.to)+.5;return(0,A.jsx)(`path`,{d:`M ${r} ${a} C ${(r+i)/2} ${a}, ${(r+i)/2} ${o}, ${i} ${o}`,vectorEffect:`non-scaling-stroke`,style:i<r?{fill:`none`,stroke:g(`error`),strokeWidth:1.5,strokeDasharray:`3 2`}:{fill:`none`,stroke:`var(--muted-foreground)`,strokeWidth:1.5,opacity:.4}},`${e.from}-${e.to}`)})}),P.map((e,n)=>e.task?(0,A.jsx)(B,{task:e.task,span:M.get(e.task.id),mode:i,epicId:t.get(e.task.id),pct:L.pct,labelWidth:c,onOpen:s},e.task.id):(0,A.jsx)(`div`,{className:`border-b bg-muted/40`,children:(0,A.jsx)(`span`,{className:`flex items-center px-3.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,style:{height:`var(--row-h)`},children:e.label})},`group-${n}-${e.label}`))]})]})})]})}export{L as EpicsView,I as FlowBoard,V as TimelineView};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{F as r,V as i,gt as ee,q as te,st as a,z as o}from"./ui-primitives-wYj92QGw.js";import{i as ne,l as s,m as c,o as re,p as l,r as ie,t as ae}from"./empty-BHqXimMR.js";import{n as u,t as d}from"./native-select-NN1SzVJL.js";import{$ as f,C as p,E as m,H as h,I as g,O as oe,Q as _,S as se,T as ce,U as le,_ as ue,b as v,c as de,d as fe,et as y,f as pe,g as me,h as he,k as ge,l as _e,p as ve,v as b,x as ye,y as x}from"./index-DEiK6_Ib.js";import{t as be}from"./layout-QiuZ_k5v.js";var S=e(t(),1),C=n(),w=`doc-h`,xe=[`current`,`draft`,`superseded`,`archived`],T=`text-[10px] font-medium tracking-[0.07em] uppercase text-muted-foreground`;function Se({document:e,selected:t,onSelect:n}){return(0,C.jsx)(m,{asChild:!0,size:`sm`,className:c(`w-full cursor-pointer flex-col items-start gap-0.5 px-2 py-1.5 text-left hover:bg-accent`,t&&`bg-accent`),children:(0,C.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,children:[(0,C.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`flex-1 truncate text-xs font-medium`,children:e.title}),(0,C.jsx)(`span`,{className:c(`font-mono text-[10px]`,!e.managed&&`text-muted-foreground`),style:e.managed?{color:s(e.status)}:void 0,children:e.managed?e.status:`indexed`})]}),(0,C.jsx)(`span`,{className:`w-full truncate font-mono text-[10px] text-muted-foreground`,children:e.path})]})})}function Ce({entries:e,activeId:t,onJump:n}){let r=Math.min(...e.map(e=>e.level));return(0,C.jsxs)(`aside`,{"aria-label":`Document outline`,className:`hidden w-[228px] shrink-0 overflow-y-auto border-l px-3 py-6.5 xl:block`,children:[(0,C.jsx)(`span`,{className:c(T,`px-2`),children:`on this page`}),(0,C.jsx)(`nav`,{className:`mt-2 flex flex-col gap-px`,children:e.map(e=>{let i=e.id===t;return(0,C.jsx)(`button`,{type:`button`,"aria-current":i?`true`:void 0,className:c(`cursor-pointer rounded-md px-2 py-1 text-left text-xs leading-snug transition-colors hover:bg-accent`,i?`bg-accent font-medium text-foreground`:`text-muted-foreground`),style:{paddingLeft:`${8+Math.min(e.level-r,3)*12}px`},onClick:()=>n(e.id),children:e.text},e.id)})})]})}function E({label:e,value:t}){return(0,C.jsxs)(b,{className:`w-auto min-w-[120px] gap-0.5 rounded-lg border bg-card px-3 py-2 shadow-xs`,children:[(0,C.jsx)(`span`,{className:T,children:e}),(0,C.jsx)(`span`,{className:`text-[13px] font-medium`,children:t})]})}function D({label:e,links:t,onOpen:n}){return t.length?(0,C.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,C.jsx)(`span`,{className:T,children:e}),t.map((e,t)=>{let r=!e.exists&&!e.title;return(0,C.jsx)(m,{asChild:!0,variant:`outline`,size:`sm`,className:c(`w-full cursor-pointer gap-2 px-2.5 py-2 text-left hover:bg-accent`,r&&`cursor-default opacity-55 hover:bg-transparent`),children:(0,C.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>n(e.id),children:[(0,C.jsx)(`span`,{className:`min-w-[78px] shrink-0 font-mono text-[11px] font-medium`,children:e.id}),(0,C.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:e.title||(e.exists===!1?`Missing record`:e.id)}),e.relation?(0,C.jsx)(_,{variant:`secondary`,className:`font-mono text-[10px]`,children:e.relation}):null]})},`${e.id}-${t}`)})]}):null}var O=(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`});function k({selectedId:e,onSelect:t,onOpenCard:n}){let[m,_]=(0,S.useState)([]),[k,A]=(0,S.useState)(``),[j,M]=(0,S.useState)(!0),[N,P]=(0,S.useState)(``),[F,I]=(0,S.useState)(!1),[L,we]=(0,S.useState)(!1),[R,z]=(0,S.useState)(null),[B,V]=(0,S.useState)(!1),[H,U]=(0,S.useState)(``),[W,Te]=(0,S.useState)(null),[Ee,G]=(0,S.useState)(0);ge(e=>{oe(e,`/docs/`,`docs/`)&&G(e=>e+1)}),(0,S.useEffect)(()=>{let e=!1;M(!0);let t=window.setTimeout(()=>{g.docs(k.trim()).then(t=>{e||(_(t.records),P(``))}).catch(t=>{e||P(t instanceof Error?t.message:String(t))}).finally(()=>{e||M(!1)})},k?180:0);return()=>{e=!0,window.clearTimeout(t)}},[k,Ee]),(0,S.useEffect)(()=>{if(!R||W)return;let e=!1;return g.tasks().then(t=>{e||Te(t.schema.docs)}).catch(()=>{}),()=>{e=!0}},[R,W]);let K=(0,S.useMemo)(()=>F?m.filter(e=>e.managed):m,[m,F]),q=(0,S.useMemo)(()=>{let e=K.filter(e=>e.managed),t=K.filter(e=>!e.managed);return[{key:`managed`,label:`.project/docs · managed`,docs:e},{key:`indexed`,label:`indexed · read only`,docs:t}].filter(e=>e.docs.length>0)},[K]),De=le(),J=K.find(t=>t.id===e)||(De?void 0:K[0]),Y=(0,S.useRef)(null),[Oe,X]=(0,S.useState)(``),Z=(0,S.useMemo)(()=>J&&!L?se(J.body,w):[],[J,L]),Q=Z.length>1;(0,S.useEffect)(()=>{X(``);let e=Y.current;if(!e||!Q)return;let t=new Map,n=new IntersectionObserver(e=>{for(let n of e)t.set(n.target.id,n.isIntersecting);let n=Z.find(e=>t.get(e.id));n&&X(n.id)},{root:e,rootMargin:`0px 0px -66% 0px`,threshold:0});for(let e of Z){let t=document.getElementById(e.id);t&&n.observe(t)}return()=>n.disconnect()},[Z,Q]);let ke=e=>{document.getElementById(e)?.scrollIntoView({block:`start`,behavior:`smooth`}),X(e)},$=e=>{let r=m.find(t=>t.id===e);r?t(r.id):n(e)},Ae=(0,S.useMemo)(()=>{let e=new Set(W?.kinds??[]);for(let t of m)t.managed&&e.add(t.documentKind);return R&&e.add(R.kind),[...e].sort()},[W,m,R]),je=(0,S.useMemo)(()=>{let e=new Set(W?.statuses??xe);for(let t of m)t.managed&&e.add(t.status);return R&&e.add(R.status),[...e].sort()},[W,m,R]);function Me(e){U(``),z({id:e.id,title:e.title,kind:e.documentKind,status:e.status,owners:(e.owners??[]).join(`, `),reviewed:e.reviewed??``})}async function Ne(){if(!R)return;let e=m.find(e=>e.id===R.id);if(!e){U(`This document no longer exists in the workspace.`);return}let t=R.owners.split(`,`).map(e=>e.trim()).filter(Boolean),n={},r=R.title.trim();if(r&&r!==e.title&&(n.title=r),R.kind!==e.documentKind&&(n.kind=R.kind),R.status!==e.status&&(n.status=R.status),t.join(`
`)!==(e.owners??[]).join(`
`)&&(n.owners=t),(R.reviewed||``)!==(e.reviewed??``)&&(n.reviewed=R.reviewed||null),!Object.keys(n).length){z(null);return}V(!0),U(``);try{let t=await g.patchDocument(e.id,n,e.revision);_(n=>n.map(n=>n.id===e.id?t.record:n)),z(null)}catch(e){let t=e;t.code?.endsWith(`WRITE_CONFLICT`)?(G(e=>e+1),U(`The document changed on disk; the list was refreshed. Save again to apply your changes to the latest revision.`)):U(t.message||String(e))}finally{V(!1)}}return(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,C.jsxs)(`aside`,{"aria-label":`Documents`,className:c(`min-h-0 w-full shrink-0 flex-col border-r px-2 py-3 lg:flex lg:w-[290px]`,J?`hidden`:`flex`),children:[(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 pb-2.5`,children:[(0,C.jsxs)(he,{className:`h-8`,children:[(0,C.jsx)(me,{children:(0,C.jsx)(i,{"aria-hidden":`true`})}),(0,C.jsx)(ue,{className:`h-8`,type:`search`,value:k,"aria-label":`Search documentation`,placeholder:`Search documentation…`,onChange:e=>A(e.target.value)})]}),(0,C.jsx)(`div`,{className:`flex gap-1.5`,children:(0,C.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,"aria-pressed":F,className:c(`h-7 gap-1.5 px-2.5 text-xs`,F&&`border-ring bg-accent`),onClick:()=>I(!F),children:[`managed`,(0,C.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:F?`only`:`all`})]})})]}),(0,C.jsx)(`div`,{"aria-busy":j||void 0,className:`min-h-0 flex-1 overflow-y-auto`,children:j?(0,C.jsxs)(`span`,{className:`flex items-center gap-2 px-2 py-1.5 font-mono text-[10.5px] text-muted-foreground`,children:[(0,C.jsx)(ce,{className:`size-3`}),`Loading documents…`]}):N?(0,C.jsx)(f,{variant:`destructive`,className:`mt-1.5`,children:(0,C.jsx)(y,{children:N})}):q.length?q.map(e=>(0,C.jsxs)(`div`,{className:`flex flex-col gap-px pb-3.5`,children:[(0,C.jsxs)(`span`,{className:`flex items-center gap-2 px-2 py-1.5 font-mono text-[10.5px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`text-foreground/80`,children:e.label}),(0,C.jsx)(`span`,{children:e.docs.length})]}),e.docs.map(e=>(0,C.jsx)(Se,{document:e,selected:J?.id===e.id,onSelect:()=>t(e.id)},e.id))]},e.key)):(0,C.jsx)(ae,{className:`gap-2 p-4 md:p-4`,children:(0,C.jsxs)(ne,{children:[(0,C.jsx)(re,{className:`text-sm`,children:`No documents found.`}),(0,C.jsx)(ie,{className:`text-xs`,children:F?`Try another search, or include indexed files.`:`Try another search.`})]})})})]}),(0,C.jsx)(`section`,{ref:Y,className:c(`min-w-0 flex-1 overflow-y-auto px-6 py-6.5 sm:px-8.5`,J?`block`:`hidden lg:block`),children:(0,C.jsx)(`div`,{className:be,children:J?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(l,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-2 mb-2 lg:hidden`,onClick:()=>t(``),children:[(0,C.jsx)(ee,{"aria-hidden":`true`}),`All documents`]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 font-mono text-[11px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:J.id}),O,(0,C.jsx)(`span`,{children:J.documentKind}),O,(0,C.jsx)(`span`,{style:{color:s(J.status)},children:J.status}),O,(0,C.jsx)(`span`,{children:J.managed?`managed`:`indexed`}),(0,C.jsx)(`span`,{className:`flex-1`}),J.managed?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>we(e=>!e),children:[L?(0,C.jsx)(a,{"aria-hidden":`true`}):(0,C.jsx)(te,{"aria-hidden":`true`}),L?`Preview`:`Edit`]}),(0,C.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Me(J),children:[(0,C.jsx)(o,{"aria-hidden":`true`}),`Metadata`]})]}):null]}),(0,C.jsx)(`h2`,{className:`mt-3 mb-1.5 text-2xl font-semibold tracking-tight`,children:J.title}),(0,C.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground [overflow-wrap:anywhere]`,children:J.path}),(0,C.jsxs)(`div`,{className:`mt-4.5 flex flex-wrap gap-2`,children:[(0,C.jsx)(E,{label:`kind`,value:J.documentKind}),(0,C.jsx)(E,{label:`status`,value:J.status}),(0,C.jsx)(E,{label:`reviewed`,value:J.reviewed||`—`}),(0,C.jsx)(E,{label:`owners`,value:J.owners?.join(`, `)||`—`}),(0,C.jsx)(E,{label:`backlinks`,value:String(J.incomingTotal??J.incoming.length)}),J.updated?(0,C.jsx)(E,{label:`updated`,value:J.updated}):null]}),J.freshness.length>0?(0,C.jsxs)(f,{role:`status`,className:`mt-4.5 max-w-2xl`,children:[(0,C.jsx)(r,{"aria-hidden":`true`,className:`text-sev-warning`}),(0,C.jsx)(y,{children:J.freshness.map(e=>(0,C.jsx)(`span`,{children:e.message},`${e.code}-${e.message}`))})]}):null,(0,C.jsx)(`div`,{className:`mt-6.5`,children:L&&J.managed?(0,C.jsx)(p,{value:J.body,revision:J.revision,onSave:async(e,t)=>{let n=await g.patchDocument(J.id,{body:e},t);_(e=>e.map(e=>e.id===J.id?n.record:e))}},J.id):J.body.trim()?(0,C.jsx)(ye,{source:J.body,headingPrefix:w,onOpen:$}):(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:J.managed?`This document is empty. Use Edit to write its first version.`:`This file has no body to render.`})}),J.outgoing.length||J.incoming.length||J.scope?.length?(0,C.jsxs)(`div`,{className:`mt-7 flex max-w-[70ch] flex-col gap-4.5`,children:[(0,C.jsx)(D,{label:`links to`,links:J.outgoing,onOpen:$}),(0,C.jsx)(D,{label:(J.incomingTotal??J.incoming.length)>J.incoming.length?`backlinks (${J.incoming.length} of ${J.incomingTotal})`:`backlinks`,links:J.incoming,onOpen:$}),J.scope?.length?(0,C.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,C.jsx)(`span`,{className:T,children:`scope`}),J.scope.map(e=>(0,C.jsx)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground [overflow-wrap:anywhere]`,children:e},e))]}):null]}):null]}):(0,C.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-muted-foreground`,children:j?`Loading documents…`:`Select a document from the list to read it.`})})}),Q?(0,C.jsx)(Ce,{entries:Z,activeId:Oe,onJump:ke}):null,(0,C.jsx)(de,{open:R!==null,onOpenChange:e=>{!e&&!B&&z(null)},children:(0,C.jsxs)(_e,{"aria-describedby":void 0,children:[(0,C.jsx)(pe,{children:(0,C.jsx)(ve,{children:`Edit metadata${R?` — ${R.id}`:``}`})}),R?(0,C.jsxs)(x,{className:`gap-4`,children:[(0,C.jsxs)(b,{children:[(0,C.jsx)(v,{htmlFor:`docs-meta-title`,children:`title`}),(0,C.jsx)(h,{id:`docs-meta-title`,value:R.title,onChange:e=>z({...R,title:e.target.value})})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,C.jsxs)(b,{className:`[&_[data-slot=native-select-wrapper]]:w-full`,children:[(0,C.jsx)(v,{htmlFor:`docs-meta-kind`,children:`kind`}),(0,C.jsx)(d,{id:`docs-meta-kind`,value:R.kind,onChange:e=>z({...R,kind:e.target.value}),children:Ae.map(e=>(0,C.jsx)(u,{value:e,children:e},e))})]}),(0,C.jsxs)(b,{className:`[&_[data-slot=native-select-wrapper]]:w-full`,children:[(0,C.jsx)(v,{htmlFor:`docs-meta-status`,children:`status`}),(0,C.jsx)(d,{id:`docs-meta-status`,value:R.status,onChange:e=>z({...R,status:e.target.value}),children:je.map(e=>(0,C.jsx)(u,{value:e,children:e},e))})]})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,C.jsxs)(b,{children:[(0,C.jsx)(v,{htmlFor:`docs-meta-owners`,children:`owners`}),(0,C.jsx)(h,{id:`docs-meta-owners`,value:R.owners,placeholder:`comma-separated`,onChange:e=>z({...R,owners:e.target.value})})]}),(0,C.jsxs)(b,{children:[(0,C.jsx)(v,{htmlFor:`docs-meta-reviewed`,children:`reviewed`}),(0,C.jsx)(h,{id:`docs-meta-reviewed`,type:`date`,value:R.reviewed,onChange:e=>z({...R,reviewed:e.target.value})})]})]}),H?(0,C.jsx)(f,{variant:`destructive`,children:(0,C.jsx)(y,{children:H})}):null]}):null,(0,C.jsxs)(fe,{children:[(0,C.jsx)(l,{type:`button`,variant:`outline`,disabled:B,onClick:()=>z(null),children:`Cancel`}),(0,C.jsx)(l,{type:`button`,disabled:B,onClick:()=>void Ne(),children:B?`Saving…`:`Save`})]})]})})]})}export{k as DocsView};
import"./rolldown-runtime-CbXtAM7H.js";import{i as e,t}from"./react-Buq45Vzz.js";import{j as n}from"./ui-primitives-wYj92QGw.js";e();function r(e){var t,n,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=r(e[t]))&&(i&&(i+=` `),i+=n)}else for(n in e)e[n]&&(i&&(i+=` `),i+=n);return i}function i(){for(var e,t,n=0,i=``,a=arguments.length;n<a;n++)(e=arguments[n])&&(t=r(e))&&(i&&(i+=` `),i+=t);return i}var a=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,o=i,s=(e,t)=>n=>{if(t?.variants==null)return o(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,s=Object.keys(r).map(e=>{let t=n?.[e],o=i?.[e];if(t===null)return null;let s=a(t)||a(o);return r[e][s]}),c=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return o(e,s,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,...c}[t]):{...i,...c}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},c=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},l=(e,t)=>({classGroupId:e,validator:t}),u=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),d=`-`,ee=[],f=`arbitrary..`,te=e=>{let t=h(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return m(e);let n=e.split(d);return p(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?c(i,t):t:i||ee}return n[e]||ee}}},p=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=p(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(d):e.slice(t).join(d),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},m=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?f+r:void 0})(),h=e=>{let{theme:t,classGroups:n}=e;return g(n,t)},g=(e,t)=>{let n=u();for(let r in e){let i=e[r];_(i,n,r,t)}return n},_=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];v(i,t,n,r)}},v=(e,t,n,r)=>{if(typeof e==`string`){ne(e,t,n);return}if(typeof e==`function`){y(e,t,n,r);return}b(e,t,n,r)},ne=(e,t,n)=>{let r=e===``?t:x(t,e);r.classGroupId=n},y=(e,t,n,r)=>{if(S(e)){_(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(l(n,e))},b=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];_(o,x(t,a),n,r)}},x=(e,t)=>{let n=e,r=t.split(d),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=u(),n.nextPart.set(t,i)),n=i}return n},S=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,re=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},C=`!`,w=`:`,ie=[],T=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),E=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===w){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(C)?(c=s.slice(0,-1),l=!0):s.startsWith(C)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return T(t,l,c,u)};if(t){let e=t+w,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):T(ie,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},D=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},O=e=>({cache:re(e.cacheSize),parseClassName:E(e),sortModifiers:D(e),postfixLookupClassGroupIds:k(e),...te(e)}),k=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},A=/\s+/,j=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(A),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:ee,baseClassName:f,maybePostfixModifierPosition:te}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let p=!!te,m;if(p){m=r(f.substring(0,te));let e=m&&o[m]?r(f):void 0;e&&e!==m&&(m=e,p=!1)}else m=r(f);if(!m){if(!p){l=t+(l.length>0?` `+l:l);continue}if(m=r(f),!m){l=t+(l.length>0?` `+l:l);continue}p=!1}let h=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),g=ee?h+C:h,_=g+m;if(s.indexOf(_)>-1)continue;s.push(_);let v=i(m,p);for(let e=0;e<v.length;++e){let t=v[e];s.push(g+t)}l=t+(l.length>0?` `+l:l)}return l},ae=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=M(n))&&(i&&(i+=` `),i+=r);return i},M=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=M(e[r]))&&(n&&(n+=` `),n+=t);return n},oe=(e,...t)=>{let n,r,i,a,o=o=>(n=O(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=j(e,n);return i(e,a),a};return a=o,(...e)=>a(ae(...e))},se=[],N=e=>{let t=t=>t[e]||se;return t.isThemeGetter=!0,t},P=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,F=/^\((?:(\w[\w-]*):)?(.+)\)$/i,I=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ce=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,L=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,le=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,R=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,z=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,B=e=>I.test(e),V=e=>!!e&&!Number.isNaN(Number(e)),H=e=>!!e&&Number.isInteger(Number(e)),ue=e=>e.endsWith(`%`)&&V(e.slice(0,-1)),U=e=>ce.test(e),de=()=>!0,W=e=>L.test(e)&&!le.test(e),G=()=>!1,fe=e=>R.test(e),pe=e=>z.test(e),me=e=>!K(e)&&!J(e),he=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),ge=e=>X(e,je,G),K=e=>P.test(e),q=e=>X(e,Me,W),_e=e=>X(e,Ne,V),ve=e=>X(e,Fe,de),ye=e=>X(e,Pe,G),be=e=>X(e,ke,G),xe=e=>X(e,Ae,pe),Se=e=>X(e,Ie,fe),J=e=>F.test(e),Y=e=>Z(e,Me),Ce=e=>Z(e,Pe),we=e=>Z(e,ke),Te=e=>Z(e,je),Ee=e=>Z(e,Ae),De=e=>Z(e,Ie,!0),Oe=e=>Z(e,Fe,!0),X=(e,t,n)=>{let r=P.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Z=(e,t,n=!1)=>{let r=F.exec(e);return r?r[1]?t(r[1]):n:!1},ke=e=>e===`position`||e===`percentage`,Ae=e=>e===`image`||e===`url`,je=e=>e===`length`||e===`size`||e===`bg-size`,Me=e=>e===`length`,Ne=e=>e===`number`,Pe=e=>e===`family-name`,Fe=e=>e===`number`||e===`weight`,Ie=e=>e===`shadow`,Le=oe(()=>{let e=N(`color`),t=N(`font`),n=N(`text`),r=N(`font-weight`),i=N(`tracking`),a=N(`leading`),o=N(`breakpoint`),s=N(`container`),c=N(`spacing`),l=N(`radius`),u=N(`shadow`),d=N(`inset-shadow`),ee=N(`text-shadow`),f=N(`drop-shadow`),te=N(`blur`),p=N(`perspective`),m=N(`aspect`),h=N(`ease`),g=N(`animate`),_=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],v=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],ne=()=>[...v(),J,K],y=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],b=()=>[`auto`,`contain`,`none`],x=()=>[J,K,c],S=()=>[B,`full`,`auto`,...x()],re=()=>[H,`none`,`subgrid`,J,K],C=()=>[`auto`,{span:[`full`,H,J,K]},H,J,K],w=()=>[H,`auto`,J,K],ie=()=>[`auto`,`min`,`max`,`fr`,J,K],T=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],E=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],D=()=>[`auto`,...x()],O=()=>[B,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...x()],k=()=>[B,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...x()],A=()=>[B,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...x()],j=()=>[e,J,K],ae=()=>[...v(),we,be,{position:[J,K]}],M=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],oe=()=>[`auto`,`cover`,`contain`,Te,ge,{size:[J,K]}],se=()=>[ue,Y,q],P=()=>[``,`none`,`full`,l,J,K],F=()=>[``,V,Y,q],I=()=>[`solid`,`dashed`,`dotted`,`double`],ce=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],L=()=>[V,ue,we,be],le=()=>[``,`none`,te,J,K],R=()=>[`none`,V,J,K],z=()=>[`none`,V,J,K],W=()=>[V,J,K],G=()=>[B,`full`,...x()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[U],breakpoint:[U],color:[de],container:[U],"drop-shadow":[U],ease:[`in`,`out`,`in-out`],font:[me],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[U],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[U],shadow:[U],spacing:[`px`,V],text:[U],"text-shadow":[U],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,B,K,J,m]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,J,K]}],"container-named":[he],columns:[{columns:[V,K,J,s]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:ne()}],overflow:[{overflow:y()}],"overflow-x":[{"overflow-x":y()}],"overflow-y":[{"overflow-y":y()}],overscroll:[{overscroll:b()}],"overscroll-x":[{"overscroll-x":b()}],"overscroll-y":[{"overscroll-y":b()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:S()}],"inset-x":[{"inset-x":S()}],"inset-y":[{"inset-y":S()}],start:[{"inset-s":S(),start:S()}],end:[{"inset-e":S(),end:S()}],"inset-bs":[{"inset-bs":S()}],"inset-be":[{"inset-be":S()}],top:[{top:S()}],right:[{right:S()}],bottom:[{bottom:S()}],left:[{left:S()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[H,`auto`,J,K]}],basis:[{basis:[B,`full`,`auto`,s,...x()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[V,B,`auto`,`initial`,`none`,K]}],grow:[{grow:[``,V,J,K]}],shrink:[{shrink:[``,V,J,K]}],order:[{order:[H,`first`,`last`,`none`,J,K]}],"grid-cols":[{"grid-cols":re()}],"col-start-end":[{col:C()}],"col-start":[{"col-start":w()}],"col-end":[{"col-end":w()}],"grid-rows":[{"grid-rows":re()}],"row-start-end":[{row:C()}],"row-start":[{"row-start":w()}],"row-end":[{"row-end":w()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ie()}],"auto-rows":[{"auto-rows":ie()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...T(),`normal`]}],"justify-items":[{"justify-items":[...E(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...E()]}],"align-content":[{content:[`normal`,...T()]}],"align-items":[{items:[...E(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...E(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":T()}],"place-items":[{"place-items":[...E(),`baseline`]}],"place-self":[{"place-self":[`auto`,...E()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mbs:[{mbs:D()}],mbe:[{mbe:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":x()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":x()}],"space-y-reverse":[`space-y-reverse`],size:[{size:O()}],"inline-size":[{inline:[`auto`,...k()]}],"min-inline-size":[{"min-inline":[`auto`,...k()]}],"max-inline-size":[{"max-inline":[`none`,...k()]}],"block-size":[{block:[`auto`,...A()]}],"min-block-size":[{"min-block":[`auto`,...A()]}],"max-block-size":[{"max-block":[`none`,...A()]}],w:[{w:[s,`screen`,...O()]}],"min-w":[{"min-w":[s,`screen`,`none`,...O()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...O()]}],h:[{h:[`screen`,`lh`,...O()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...O()]}],"max-h":[{"max-h":[`screen`,`lh`,...O()]}],"font-size":[{text:[`base`,n,Y,q]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Oe,ve]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,ue,K]}],"font-family":[{font:[Ce,ye,t]}],"font-features":[{"font-features":[K]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,J,K]}],"line-clamp":[{"line-clamp":[V,`none`,J,_e]}],leading:[{leading:[a,...x()]}],"list-image":[{"list-image":[`none`,J,K]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,J,K]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...I(),`wavy`]}],"text-decoration-thickness":[{decoration:[V,`from-font`,`auto`,J,q]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[V,`auto`,J,K]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:x()}],"tab-size":[{tab:[H,J,K]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,J,K]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,J,K]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:ae()}],"bg-repeat":[{bg:M()}],"bg-size":[{bg:oe()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},H,J,K],radial:[``,J,K],conic:[H,J,K]},Ee,xe]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:se()}],"gradient-via-pos":[{via:se()}],"gradient-to-pos":[{to:se()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":F()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...I(),`hidden`,`none`]}],"divide-style":[{divide:[...I(),`hidden`,`none`]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...I(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[V,J,K]}],"outline-w":[{outline:[``,V,Y,q]}],"outline-color":[{outline:j()}],shadow:[{shadow:[``,`none`,u,De,Se]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":[`none`,d,De,Se]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:F()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[V,q]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":[`none`,ee,De,Se]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[V,J,K]}],"mix-blend":[{"mix-blend":[...ce(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ce()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[V]}],"mask-image-linear-from-pos":[{"mask-linear-from":L()}],"mask-image-linear-to-pos":[{"mask-linear-to":L()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":L()}],"mask-image-t-to-pos":[{"mask-t-to":L()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":L()}],"mask-image-r-to-pos":[{"mask-r-to":L()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":L()}],"mask-image-b-to-pos":[{"mask-b-to":L()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":L()}],"mask-image-l-to-pos":[{"mask-l-to":L()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":L()}],"mask-image-x-to-pos":[{"mask-x-to":L()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":L()}],"mask-image-y-to-pos":[{"mask-y-to":L()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[J,K]}],"mask-image-radial-from-pos":[{"mask-radial-from":L()}],"mask-image-radial-to-pos":[{"mask-radial-to":L()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[V]}],"mask-image-conic-from-pos":[{"mask-conic-from":L()}],"mask-image-conic-to-pos":[{"mask-conic-to":L()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ae()}],"mask-repeat":[{mask:M()}],"mask-size":[{mask:oe()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,J,K]}],filter:[{filter:[``,`none`,J,K]}],blur:[{blur:le()}],brightness:[{brightness:[V,J,K]}],contrast:[{contrast:[V,J,K]}],"drop-shadow":[{"drop-shadow":[``,`none`,f,De,Se]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:[``,V,J,K]}],"hue-rotate":[{"hue-rotate":[V,J,K]}],invert:[{invert:[``,V,J,K]}],saturate:[{saturate:[V,J,K]}],sepia:[{sepia:[``,V,J,K]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,J,K]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[V,J,K]}],"backdrop-contrast":[{"backdrop-contrast":[V,J,K]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,V,J,K]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[V,J,K]}],"backdrop-invert":[{"backdrop-invert":[``,V,J,K]}],"backdrop-opacity":[{"backdrop-opacity":[V,J,K]}],"backdrop-saturate":[{"backdrop-saturate":[V,J,K]}],"backdrop-sepia":[{"backdrop-sepia":[``,V,J,K]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,J,K]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[V,`initial`,J,K]}],ease:[{ease:[`linear`,`initial`,h,J,K]}],delay:[{delay:[V,J,K]}],animate:[{animate:[`none`,g,J,K]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[p,J,K]}],"perspective-origin":[{"perspective-origin":ne()}],rotate:[{rotate:R()}],"rotate-x":[{"rotate-x":R()}],"rotate-y":[{"rotate-y":R()}],"rotate-z":[{"rotate-z":R()}],scale:[{scale:z()}],"scale-x":[{"scale-x":z()}],"scale-y":[{"scale-y":z()}],"scale-z":[{"scale-z":z()}],"scale-3d":[`scale-3d`],skew:[{skew:W()}],"skew-x":[{"skew-x":W()}],"skew-y":[{"skew-y":W()}],transform:[{transform:[J,K,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:ne()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:G()}],"translate-x":[{"translate-x":G()}],"translate-y":[{"translate-y":G()}],"translate-z":[{"translate-z":G()}],"translate-none":[`translate-none`],zoom:[{zoom:[H,J,K]}],accent:[{accent:j()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:j()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,J,K]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":j()}],"scrollbar-track-color":[{"scrollbar-track":j()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,J,K]}],fill:[{fill:[`none`,...j()]}],"stroke-w":[{stroke:[V,Y,q,_e]}],stroke:[{stroke:[`none`,...j()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Q(...e){return Le(i(e))}var $=t(),Re=s(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function ze({className:e,variant:t=`default`,size:r=`default`,asChild:i=!1,...a}){let o=i?n:`button`;return(0,$.jsx)(o,{"data-slot":`button`,"data-variant":t,"data-size":r,className:Q(Re({variant:t,size:r,className:e})),...a})}function Be(e){return`var(--status-${e})`}function Ve(e){return`var(--priority-${e})`}function He(e){return`var(--sev-${e})`}var Ue={current:`done`,draft:`doing`,stale:`doing`,superseded:`backlog`,archived:`backlog`,indexed:`backlog`,active:`done`,accepted:`done`,resolved:`done`,graduated:`done`,proposed:`doing`,open:`doing`,mitigated:`doing`,closed:`done`,rejected:`discarded`,expired:`backlog`,deprecated:`backlog`,released:`done`,unreleased:`doing`};function We(e){let t=Ue[e];return t?`var(--status-${t})`:`var(--status-${e in Ge?e:`backlog`})`}var Ge={backlog:!0,next:!0,doing:!0,review:!0,blocked:!0,deferred:!0,done:!0,discarded:!0};function Ke(e){return e.startsWith(`T-`)?`cards`:e.startsWith(`DOC-`)||e.startsWith(`PATH-`)?`docs`:e.startsWith(`CHG-`)||e.startsWith(`REL-`)?`changelog`:`memory`}function qe(e){return e==null?``:e<1/60?`now`:e<1?`${Math.round(e*60)} min`:e<48?`${Math.round(e)} h`:`${Math.round(e/24)} d`}function Je({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`empty`,className:Q(`flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12`,e),...t})}function Ye({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`empty-header`,className:Q(`flex max-w-sm flex-col items-center gap-2 text-center`,e),...t})}var Xe=s(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-6`}},defaultVariants:{variant:`default`}});function Ze({className:e,variant:t=`default`,...n}){return(0,$.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":t,className:Q(Xe({variant:t,className:e})),...n})}function Qe({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`empty-title`,className:Q(`text-lg font-medium tracking-tight`,e),...t})}function $e({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`empty-description`,className:Q(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function et({className:e,...t}){return(0,$.jsx)(`div`,{"data-slot":`empty-content`,className:Q(`flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance`,e),...t})}export{Ze as a,Ke as c,qe as d,Be as f,s as h,Ye as i,We as l,Q as m,et as n,Qe as o,ze as p,$e as r,Ve as s,Je as t,He as u};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{Ct as r,St as i,b as a,ft as o,vt as s,y as c,z as ee}from"./ui-primitives-wYj92QGw.js";import{f as l,i as te,m as u,o as ne,p as d,r as re,s as f,t as ie}from"./empty-BHqXimMR.js";import{n as p,t as m}from"./native-select-NN1SzVJL.js";import{B as ae,D as oe,L as se,R as ce,V as le,a as h,i as ue,o as g,s as de,z as fe}from"./index-DEiK6_Ib.js";import{t as _}from"./progress-CKc41PRw.js";var v=e(t(),1),y=n();function b({className:e,...t}){return(0,y.jsx)(c,{"data-slot":`checkbox`,className:u(`peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary`,e),...t,children:(0,y.jsx)(a,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none`,children:(0,y.jsx)(s,{className:`size-3.5`})})})}function pe({className:e,...t}){return(0,y.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,y.jsx)(`table`,{"data-slot":`table`,className:u(`w-full caption-bottom text-sm`,e),...t})})}function me({className:e,...t}){return(0,y.jsx)(`thead`,{"data-slot":`table-header`,className:u(`[&_tr]:border-b`,e),...t})}function he({className:e,...t}){return(0,y.jsx)(`tbody`,{"data-slot":`table-body`,className:u(`[&_tr:last-child]:border-0`,e),...t})}function x({className:e,...t}){return(0,y.jsx)(`tr`,{"data-slot":`table-row`,className:u(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function S({className:e,...t}){return(0,y.jsx)(`th`,{"data-slot":`table-head`,className:u(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function C({className:e,...t}){return(0,y.jsx)(`td`,{"data-slot":`table-cell`,className:u(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}var w=[[`id`,`id`],[`title`,`title · claim`],[`status`,`status`],[`priority`,`prio`],[`type`,`type`],[`area`,`area`],[`epic`,`links`],[`updated`,`updated`]],T=new Map(h.map((e,t)=>[e,t])),E=new Map(g.map((e,t)=>[e,t])),D=w.length+1;function O(e,t){let n=new Map;for(let r of e){let e=r[t];typeof e==`string`&&n.set(e,(n.get(e)||0)+1)}return n}function k({title:e,values:t,counts:n,selected:r,color:i,onSelect:a}){let o=t.filter(e=>n.has(e));if(!o.length)return null;let s=Math.max(...o.map(e=>n.get(e)||0));return(0,y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,y.jsx)(`span`,{className:`px-1.5 font-mono text-[10px] tracking-widest uppercase text-muted-foreground`,children:e}),o.map(e=>{let t=n.get(e)||0,o=r===e;return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":o,onClick:()=>a(o?``:e),className:u(`flex w-full cursor-pointer flex-col gap-1 rounded-md px-1.5 py-1 text-left transition-colors hover:bg-accent/50`,o&&`bg-accent`),children:[(0,y.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,y.jsx)(`span`,{className:u(`min-w-0 flex-1 truncate text-xs`,o?`font-medium text-foreground`:`text-muted-foreground`),children:e}),(0,y.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:t})]}),(0,y.jsx)(_,{value:s?Math.round(t/s*100):0,className:u(`h-[5px] bg-muted [&>div]:bg-current`,!i&&`text-primary`),style:i?{color:i(e)}:void 0})]},e)})]})}function A({label:e,value:t,options:n,color:r,withDot:i,onChange:a}){return(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,style:{color:r},children:[i?(0,y.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":`true`}):null,(0,y.jsx)(m,{"aria-label":e,value:t,onChange:e=>a(e.target.value),className:`h-[22px] cursor-pointer border-transparent bg-transparent px-1 py-0 pr-8 font-mono text-[11px] text-inherit shadow-none dark:bg-transparent dark:hover:bg-transparent`,children:n.map(e=>(0,y.jsx)(p,{value:e,children:e},e))})]})}var ge=(0,v.memo)(function({task:e,epicId:t,checked:n,isOpen:r,onToggle:i,onOpen:a,onPatch:o}){let s=(e.depends?.length??0)+ +!!e.parent;return(0,y.jsxs)(x,{className:`h-[var(--row-h)] cursor-pointer`,"data-state":r?`selected`:void 0,tabIndex:0,onClick:()=>a(e.id),onKeyDown:t=>{t.key===`Enter`&&a(e.id)},children:[(0,y.jsx)(C,{className:u(`w-7 border-l-2 border-l-transparent`,r&&`border-l-primary`),onClick:e=>e.stopPropagation(),children:(0,y.jsx)(b,{"aria-label":`Select ${e.id}`,checked:n,onCheckedChange:()=>i(e.id)})}),(0,y.jsx)(C,{className:`font-mono text-xs text-muted-foreground`,children:e.id}),(0,y.jsx)(C,{className:`max-w-[520px]`,children:(0,y.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.claimed_by?(0,y.jsxs)(`span`,{className:`font-mono text-[10px] whitespace-nowrap text-muted-foreground/60`,children:[`· `,e.claimed_by]}):null]})}),(0,y.jsx)(C,{onClick:e=>e.stopPropagation(),children:(0,y.jsx)(A,{label:`Status for ${e.id}`,value:e.status,options:g,color:l(e.status),withDot:!0,onChange:t=>void o(e.id,{status:t}).catch(()=>void 0)})}),(0,y.jsx)(C,{onClick:e=>e.stopPropagation(),children:(0,y.jsx)(A,{label:`Priority for ${e.id}`,value:e.priority,options:h,color:f(e.priority),onChange:t=>void o(e.id,{priority:t}).catch(()=>void 0)})}),(0,y.jsx)(C,{className:`font-mono text-[11px] text-muted-foreground`,children:e.type}),(0,y.jsx)(C,{className:`font-mono text-[11px] text-muted-foreground`,children:e.area}),(0,y.jsxs)(C,{className:`font-mono text-[11px] text-muted-foreground/60`,children:[t?(0,y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a(t)},className:u(`cursor-pointer text-primary hover:underline`,s>0&&`mr-1.5`),children:t}):null,s>0?`${s} ↔`:t?null:`—`]}),(0,y.jsx)(C,{className:`font-mono text-[11px] text-muted-foreground/60`,children:e.updated||`—`})]})});function j({tasks:e,allTasks:t,areas:n,filters:a,setFilters:s,epicIds:c,onOpen:u,onPatch:_,onBulkPatch:C}){let[A,j]=(0,v.useState)(()=>new Set),[_e,ve]=(0,v.useState)(null),[M,ye]=(0,v.useState)(`id`),[N,P]=(0,v.useState)(`desc`),[F,I]=(0,v.useState)(``),[L,R]=(0,v.useState)(``),[z,B]=(0,v.useState)(``),V=(0,v.useRef)(null),[H,be]=(0,v.useState)({start:0,end:40}),[U,xe]=(0,v.useState)(40),W=(0,v.useDeferredValue)(a),G=(0,v.useMemo)(()=>{let e=e=>ue(t,{...W,...e});return{status:O(e({status:``}),`status`),type:O(e({type:``,showIdeas:!0}),`type`),priority:O(e({priority:``}),`priority`),area:O(e({area:``}),`area`)}},[t,W]),K=(0,v.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{let n=0;return n=M===`priority`?(T.get(e.priority)||0)-(T.get(t.priority)||0):M===`status`?(E.get(e.status)||0)-(E.get(t.status)||0):M===`epic`?(c.get(e.id)||``).localeCompare(c.get(t.id)||``):String(e[M]||``).localeCompare(String(t[M]||``),void 0,{numeric:!0}),N===`asc`?n:-n}),t},[c,N,M,e]),q=(0,v.useRef)(0),Se=K.length>0,J=(0,v.useCallback)(()=>{let e=V.current;if(!e)return;let t=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(`--row-h`))||40;xe(t);let n=Math.max(0,Math.floor(e.scrollTop/t)-10),r=Math.ceil(e.clientHeight/t);be({start:n,end:Math.min(q.current,n+r+20)})},[]);(0,v.useEffect)(()=>{let e=V.current;if(!e)return;e.addEventListener(`scroll`,J,{passive:!0}),window.addEventListener(`resize`,J);let t=new MutationObserver(J);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-density`]}),()=>{e.removeEventListener(`scroll`,J),window.removeEventListener(`resize`,J),t.disconnect()}},[J,Se]),(0,v.useEffect)(()=>{q.current=K.length,J()},[J,K.length]);let Ce=[a.search,a.status,a.area,a.type,a.priority,a.milestone,a.showIdeas,a.showClosed,M,N].join(`|`);(0,v.useEffect)(()=>{V.current&&(V.current.scrollTop=0),J()},[Ce,J]);let we=(0,v.useCallback)(e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Te=(0,v.useCallback)(e=>{ve(e),u(e)},[u]),Y=(0,v.useMemo)(()=>K.map(e=>e.id),[K]),X=Y.length>0&&Y.every(e=>A.has(e)),Ee=Y.some(e=>A.has(e)),De=K.slice(H.start,H.end),Z=!!(F||L||z);function Oe(e){M===e?P(e=>e===`asc`?`desc`:`asc`):(ye(e),P(e===`id`?`desc`:`asc`))}async function ke(){let e={};if(F&&(e.status=F),L&&(e.priority=L),z&&(e.area=z),!(!Z||A.size===0))try{await C([...A],e),j(new Set),I(``),R(``),B(``)}catch{}}let Q=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(k,{title:`status`,values:g,counts:G.status,selected:a.status,color:l,onSelect:e=>s(t=>({...t,status:e}))}),(0,y.jsx)(k,{title:`priority`,values:h,counts:G.priority,selected:a.priority,color:f,onSelect:e=>s(t=>({...t,priority:e}))}),(0,y.jsx)(k,{title:`area`,values:n,counts:G.area,selected:a.area,onSelect:e=>s(t=>({...t,area:e}))}),(0,y.jsx)(k,{title:`type`,values:de,counts:G.type,selected:a.type,onSelect:e=>s(t=>({...t,type:e}))})]}),$=[a.status,a.priority,a.area,a.type].filter(Boolean).length;return(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,y.jsx)(`aside`,{"aria-label":`Backlog facets`,className:`hidden w-[204px] flex-none flex-col gap-5 overflow-y-auto border-r px-3.5 py-4 lg:flex`,children:Q}),(0,y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex flex-none items-center gap-2 px-3.5 pt-2.5 lg:hidden`,children:[(0,y.jsxs)(se,{children:[(0,y.jsx)(le,{asChild:!0,children:(0,y.jsxs)(d,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5 px-2.5 text-xs`,children:[(0,y.jsx)(ee,{className:`size-3.5`}),`Facets`,$?(0,y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:$}):null]})}),(0,y.jsxs)(ce,{side:`left`,className:`w-[280px] gap-0 sm:max-w-[280px]`,children:[(0,y.jsx)(fe,{className:`pb-2`,children:(0,y.jsx)(ae,{className:`font-mono text-[11px] tracking-wide uppercase`,children:`Facets`})}),(0,y.jsx)(`div`,{className:`flex flex-col gap-5 overflow-y-auto px-4 pb-4`,children:Q})]})]}),(0,y.jsxs)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground/70`,children:[K.length.toLocaleString(),` row`,K.length===1?``:`s`,` · scroll sideways for every column`]})]}),A.size>0&&(0,y.jsxs)(`div`,{role:`region`,"aria-label":`Bulk actions`,className:`mx-3.5 mt-2.5 mb-2.5 flex flex-none flex-wrap items-center gap-2 rounded-md border bg-muted/50 px-3 py-2`,children:[(0,y.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[A.size,` selected`]}),(0,y.jsxs)(m,{"aria-label":`Set status`,value:F,onChange:e=>I(e.target.value),className:`h-7 px-2 py-0 pr-8 text-xs`,children:[(0,y.jsx)(p,{value:``,children:`status…`}),g.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]}),(0,y.jsxs)(m,{"aria-label":`Set priority`,value:L,onChange:e=>R(e.target.value),className:`h-7 px-2 py-0 pr-8 text-xs`,children:[(0,y.jsx)(p,{value:``,children:`priority…`}),h.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]}),(0,y.jsxs)(m,{"aria-label":`Set area`,value:z,onChange:e=>B(e.target.value),className:`h-7 px-2 py-0 pr-8 text-xs`,children:[(0,y.jsx)(p,{value:``,children:`area…`}),n.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]}),(0,y.jsxs)(oe,{children:[(0,y.jsx)(d,{size:`sm`,className:`h-7`,disabled:!Z,onClick:()=>void ke(),children:`Apply`}),(0,y.jsx)(d,{size:`sm`,variant:`outline`,className:`h-7`,onClick:()=>j(new Set),children:`Clear`})]})]}),K.length===0?(0,y.jsx)(ie,{children:(0,y.jsxs)(te,{children:[(0,y.jsx)(ne,{children:`No cards match`}),(0,y.jsx)(re,{children:`Adjust filters or clear the search`})]})}):(0,y.jsx)(`div`,{ref:V,className:`min-w-0 flex-1 overflow-auto [&>[data-slot=table-container]]:overflow-visible`,children:(0,y.jsxs)(pe,{className:`text-[13px]`,children:[(0,y.jsx)(me,{children:(0,y.jsxs)(x,{className:`hover:bg-transparent`,children:[(0,y.jsx)(S,{className:`sticky top-0 z-10 w-7 bg-background`,children:(0,y.jsx)(b,{"aria-label":`Select all matching cards`,checked:X?!0:Ee?`indeterminate`:!1,onCheckedChange:()=>j(e=>{let t=new Set(e);return X?Y.forEach(e=>t.delete(e)):Y.forEach(e=>t.add(e)),t})})}),w.map(([e,t])=>(0,y.jsx)(S,{"aria-sort":M===e?N===`asc`?`ascending`:`descending`:`none`,className:`sticky top-0 z-10 bg-background`,children:(0,y.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>Oe(e),className:`-ml-2 h-7 gap-1 px-2 text-xs text-muted-foreground`,children:[t,M===e?N===`asc`?(0,y.jsx)(i,{className:`size-3`}):(0,y.jsx)(r,{className:`size-3`}):(0,y.jsx)(o,{className:`size-3 opacity-50`})]})},e))]})}),(0,y.jsxs)(he,{children:[H.start>0&&(0,y.jsx)(`tr`,{"aria-hidden":`true`,children:(0,y.jsx)(`td`,{colSpan:D,style:{height:H.start*U}})}),De.map(e=>(0,y.jsx)(ge,{task:e,epicId:c.get(e.id)||``,checked:A.has(e.id),isOpen:_e===e.id,onToggle:we,onOpen:Te,onPatch:_},e.id)),H.end<K.length&&(0,y.jsx)(`tr`,{"aria-hidden":`true`,children:(0,y.jsx)(`td`,{colSpan:D,style:{height:(K.length-H.end)*U}})})]})]})})]})]})}export{j as Explorer};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{dt as r}from"./ui-primitives-wYj92QGw.js";import{a as i,f as a,i as o,o as s,p as c,r as l,t as u,u as d}from"./empty-BHqXimMR.js";import{$ as f,A as p,I as m,Q as h,T as g,et as _,j as v,k as y}from"./index-DEiK6_Ib.js";var b=e(t(),1),x=n(),S=[{level:`error`,label:`errors`,hint:`must be fixed for a consistent workspace`,zeroHint:`the doctor does not block the release`},{level:`warning`,label:`warnings`,hint:`worth a look, nothing is broken yet`,zeroHint:`nothing worth flagging`},{level:`info`,label:`infos`,hint:`informational, no action required`,zeroHint:`no notices from the doctor`}];function C(e){return e.replace(/[-_.]+/g,` `)}var w={error:0,warning:1,info:2};function T({onOpen:e}){let[t,n]=(0,b.useState)(null),[T,E]=(0,b.useState)(``),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0);y(()=>A(e=>e+1)),(0,b.useEffect)(()=>{let e=!0;return m.health().then(t=>{e&&n(t)}).catch(t=>{e&&E(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[k]);let j=(0,b.useMemo)(()=>{if(!t)return[];let e=D?t.issues.filter(e=>e.severity===D):t.issues,n=new Map;for(let t of e){let e=n.get(t.code);e?e.push(t):n.set(t.code,[t])}return[...n.entries()].sort(([e,[t]],[n,[r]])=>{let i=w[t.severity]-w[r.severity];return i===0?e.localeCompare(n):i})},[t,D]);if(T)return(0,x.jsx)(`div`,{className:`p-3.5`,children:(0,x.jsx)(f,{variant:`destructive`,children:(0,x.jsx)(_,{children:T})})});if(!t)return(0,x.jsxs)(`div`,{className:`flex items-center gap-2 p-3.5`,"aria-busy":`true`,children:[(0,x.jsx)(g,{className:`size-3 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:`running workfile doctor…`})]});let M=[[`cards`,t.modules?.cards??t.cards],[`docs`,t.modules?.docs],[`memory`,t.modules?.memory],[`changelog`,t.modules?.changelog]].filter(([,e])=>e!=null).map(([e,t])=>`${t.toLocaleString()} ${e}`).join(`, `),N=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.generatedAt));return(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-3.5`,children:[(0,x.jsx)(`div`,{className:`mb-2.5 flex gap-1.5`,children:S.map(({level:e,label:n})=>(0,x.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,"aria-pressed":D===e,className:`aria-pressed:border-ring aria-pressed:bg-accent`,onClick:()=>O(t=>t===e?``:e),children:[n,(0,x.jsx)(h,{variant:`secondary`,className:`px-1.5 font-mono text-[10.5px]`,children:t.counts[e]})]},e))}),(0,x.jsx)(`div`,{className:`flex flex-wrap gap-2.5`,children:S.map(({level:e,label:n,hint:r,zeroHint:i})=>{let o=t.counts[e],s=e===`error`&&o===0?a(`done`):d(e);return(0,x.jsxs)(v,{className:`relative min-w-[13rem] flex-1 gap-1 py-3 pl-5 pr-3.5`,children:[(0,x.jsx)(p,{edge:`left`,color:s}),(0,x.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,x.jsx)(`span`,{className:`text-[26px] font-semibold tracking-tight`,style:{color:s},children:o}),(0,x.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:n})]}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o===0?i:r})]},e)})}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 px-0.5 pt-4 pb-2`,children:[(0,x.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`grouped by code · `,M,` · checked `,N]}),(0,x.jsx)(`span`,{className:`ml-auto font-mono text-[10.5px] text-muted-foreground/70`,children:`workfile doctor --json`})]}),j.length===0?(0,x.jsx)(u,{className:`gap-2 p-10`,children:(0,x.jsxs)(o,{children:[(0,x.jsx)(i,{children:(0,x.jsx)(r,{"aria-hidden":`true`,size:20,style:{color:a(`done`)}})}),(0,x.jsx)(s,{className:`text-sm`,children:`All clear`}),(0,x.jsxs)(l,{className:`text-[12.5px]`,children:[`No `,D||`integrity`,` issues found.`]})]})}):(0,x.jsx)(`div`,{className:`flex flex-col gap-2`,children:j.map(([t,n])=>(0,x.jsxs)(v,{className:`gap-0 overflow-hidden py-0`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1.5`,children:[(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`size-[7px] rounded-full bg-current`,style:{color:d(n[0].severity)}}),(0,x.jsx)(`span`,{className:`font-mono text-[11.5px]`,children:t}),(0,x.jsx)(`span`,{className:`flex-1 text-[12.5px] text-muted-foreground`,children:C(t)}),(0,x.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/70`,children:n.length})]}),n.map((t,n)=>(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 border-b px-3 py-[7px] last:border-0`,children:[t.id?(0,x.jsx)(c,{type:`button`,variant:`link`,className:`h-auto w-[82px] flex-[0_0_82px] justify-start p-0 font-mono text-[11px] font-normal`,onClick:()=>e(t.id),children:t.id}):(0,x.jsx)(`span`,{className:`w-[82px] flex-[0_0_82px] font-mono text-[11px] text-muted-foreground/70`,children:`—`}),(0,x.jsx)(`span`,{className:`min-w-[12rem] flex-1 text-[12.5px] text-muted-foreground`,children:t.message}),t.file?(0,x.jsx)(`span`,{className:`max-w-full truncate font-mono text-[10.5px] text-muted-foreground/70 sm:max-w-80`,title:t.file,children:t.file}):null]},`${t.id||t.file}-${n}`))]},t))})]})}export{T as HealthView};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{K as r,N as i,_t as a,gt as o}from"./ui-primitives-wYj92QGw.js";import{f as s,l as c,m as l,p as u,r as d,t as f,u as p}from"./empty-BHqXimMR.js";import{n as m,t as h}from"./native-select-NN1SzVJL.js";import{$ as g,D as _,E as v,F as ee,G as y,H as b,I as x,K as S,M as C,N as w,O as te,P as ne,Q as T,Z as E,b as D,c as O,d as k,et as A,f as j,j as re,k as ie,l as M,p as N,q as P,u as F,v as I,w as ae,x as oe}from"./index-DEiK6_Ib.js";import{t as se}from"./layout-QiuZ_k5v.js";var L=e(t(),1),R=n(),z=`text-[10px] font-medium tracking-widest uppercase text-muted-foreground`;function B(e){switch(e){case`added`:return s(`done`);case`changed`:return s(`doing`);case`fixed`:return s(`review`);case`removed`:return s(`blocked`);case`security`:return p(`error`);default:return s(`backlog`)}}function ce(e,t){let n=null;for(let t of e){let e=/^v?(\d+)\.(\d+)\.(\d+)/.exec(t.version);if(!e)continue;let r=[Number(e[1]),Number(e[2]),Number(e[3])];(n?r[0]-n[0]||r[1]-n[1]||r[2]-n[2]:1)>0&&(n=r)}return n?t.some(e=>[`added`,`removed`,`deprecated`].includes(e.type))?`${n[0]}.${n[1]+1}.0`:`${n[0]}.${n[1]}.${n[2]+1}`:`0.1.0`}function V(e){return e instanceof Error?e.message:String(e)}function H({label:e,value:t,options:n,onChange:r}){return(0,R.jsxs)(y,{children:[(0,R.jsx)(E,{asChild:!0,children:(0,R.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e,className:l(`h-7 gap-1 px-2 text-xs`,t&&`border-ring bg-accent`),children:[e,(0,R.jsx)(`span`,{className:l(`font-normal`,!t&&`text-muted-foreground`),children:t||`all`}),(0,R.jsx)(a,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`})]})}),(0,R.jsxs)(P,{align:`start`,children:[(0,R.jsx)(S,{checked:!t,onSelect:()=>r(``),children:`all`}),n.map(e=>(0,R.jsx)(S,{checked:t===e,onSelect:()=>r(e),children:e},e))]})]})}function U({record:e,selected:t,onSelect:n}){let r=e.kind===`release`?`release`:e.type,i=e.kind===`release`?`var(--primary)`:B(e.type),a=e.kind===`release`?`${e.fragments.length} fragment${e.fragments.length===1?``:`s`} · ${e.date}`:e.area;return(0,R.jsx)(v,{asChild:!0,variant:`outline`,size:`sm`,children:(0,R.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:l(`flex-col flex-nowrap items-stretch gap-1 px-2.5 py-2 text-left shadow-xs`,t?`border-ring bg-accent`:`bg-card hover:border-ring`),children:[(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,R.jsx)(`span`,{className:`font-mono text-[10px]`,style:{color:i},children:r}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(`span`,{className:`max-w-[170px] truncate font-mono text-[10px] text-muted-foreground/70`,children:a})]}),(0,R.jsx)(`span`,{className:`text-sm leading-snug font-normal`,children:e.title})]})})}function W({label:e,records:t,selectedId:n,onSelect:r}){return t.length?(0,R.jsxs)(`div`,{role:`group`,"aria-label":e,className:`flex flex-col gap-1.5 pt-4`,children:[(0,R.jsxs)(`span`,{className:z,children:[e,` · `,t.length]}),t.map(e=>(0,R.jsx)(U,{record:e,selected:e.id===n,onSelect:()=>r(e.id)},e.id))]}):null}function G({id:e,title:t,relation:n,disabled:r,onOpen:i}){return(0,R.jsx)(v,{asChild:!0,variant:`outline`,size:`sm`,children:(0,R.jsxs)(`button`,{type:`button`,disabled:r,onClick:i,className:`flex-nowrap gap-2 bg-card px-2.5 py-1.5 text-left shadow-xs hover:border-ring disabled:pointer-events-none disabled:opacity-55`,children:[(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px]`,children:t}),n?(0,R.jsx)(T,{variant:`outline`,className:`shrink-0 font-mono text-[10px] font-normal text-muted-foreground`,children:n}):null]})})}function K({label:e,links:t,onOpen:n}){return t.length?(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`span`,{className:z,children:e}),t.map(t=>(0,R.jsx)(G,{id:t.id,title:t.title,relation:t.relation,disabled:t.disabled,onOpen:()=>n(t.id)},`${e}-${t.id}`))]}):null}function le(e){return e.map(e=>({id:e.id,title:e.title||`Missing record`,relation:e.relation,disabled:!e.exists&&!e.title}))}function ue({schema:e,areas:t,onClose:n,onCreated:r}){let[i,a]=(0,L.useState)({title:``,type:e.defaults.type,area:t[0]||`general`,visibility:e.defaults.visibility,body:``}),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),d=(e,t)=>a(n=>({...n,[e]:t})),f=async()=>{s(!0);try{r((await x.createChange(i)).record)}catch(e){l(V(e))}finally{s(!1)}};return(0,R.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,R.jsxs)(M,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsxs)(j,{children:[(0,R.jsx)(N,{children:`New change fragment`}),(0,R.jsx)(F,{children:`Record one user- or operator-meaningful change.`})]}),(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`new-fragment-title`,children:`Title`}),(0,R.jsx)(b,{id:`new-fragment-title`,autoFocus:!0,required:!0,maxLength:120,value:i.title,onChange:e=>d(`title`,e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:[(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`new-fragment-type`,children:`Type`}),(0,R.jsx)(h,{id:`new-fragment-type`,value:i.type,onChange:e=>d(`type`,e.target.value),children:e.types.map(e=>(0,R.jsx)(m,{value:e,children:e},e))})]}),(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`new-fragment-area`,children:`Area`}),(0,R.jsx)(h,{id:`new-fragment-area`,value:i.area,onChange:e=>d(`area`,e.target.value),children:t.map(e=>(0,R.jsx)(m,{value:e,children:e},e))})]}),(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`new-fragment-visibility`,children:`Visibility`}),(0,R.jsx)(h,{id:`new-fragment-visibility`,value:i.visibility,onChange:e=>d(`visibility`,e.target.value),children:e.visibilities.map(e=>(0,R.jsx)(m,{value:e,children:e},e))})]})]}),(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`new-fragment-details`,children:`Details`}),(0,R.jsx)(ae,{id:`new-fragment-details`,rows:5,value:i.body,onChange:e=>d(`body`,e.target.value)})]}),c?(0,R.jsx)(g,{variant:`destructive`,"aria-live":`polite`,children:(0,R.jsx)(A,{children:c})}):null,(0,R.jsxs)(k,{children:[(0,R.jsx)(u,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,R.jsx)(u,{type:`button`,disabled:o||!i.title.trim(),onClick:()=>void f(),children:o?`Saving…`:`Create fragment`})]})]})})}function de({preview:e,suggestedVersion:t,onClose:n,onReleased:r}){let[i,a]=(0,L.useState)(t),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(!1),[d,f]=(0,L.useState)(``),p=async()=>{l(!0);try{await x.createRelease({version:i,title:o||void 0,fragmentIds:e.fragments.map(e=>e.id)}),r()}catch(e){f(V(e))}finally{l(!1)}};return(0,R.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,R.jsxs)(M,{className:`flex max-h-[85vh] flex-col sm:max-w-[640px]`,children:[(0,R.jsxs)(j,{children:[(0,R.jsx)(N,{children:`Release preparation`}),(0,R.jsxs)(F,{children:[e.fragments.length,` unreleased fragment`,e.fragments.length===1?``:`s`,` selected.`]})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[150px_1fr] gap-2.5`,children:[(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`release-version`,children:`Version`}),(0,R.jsx)(b,{id:`release-version`,className:`font-mono`,placeholder:`2.4.0`,value:i,onChange:e=>a(e.target.value)})]}),(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`release-title`,children:`Release title`}),(0,R.jsx)(b,{id:`release-title`,placeholder:`Optional curated title`,value:o,onChange:e=>s(e.target.value)})]})]}),e.groups.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`span`,{className:z,style:{color:B(e.type)},children:[e.type,` · `,e.fragments.length]}),e.fragments.map(e=>(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2 text-[12.5px]`,children:[(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground/70`,children:e.area})]},e.id))]},e.type)),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:z,children:`release notes preview`}),(0,R.jsx)(`div`,{className:`max-h-[220px] overflow-y-auto rounded-md border bg-background px-3 py-1`,children:(0,R.jsx)(oe,{source:e.markdown||`No release notes to render.`})})]}),d?(0,R.jsx)(g,{variant:`destructive`,"aria-live":`polite`,children:(0,R.jsx)(A,{children:d})}):null]}),(0,R.jsxs)(k,{children:[(0,R.jsx)(u,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,R.jsx)(u,{type:`button`,disabled:c||!i.trim()||!e.fragments.length,onClick:()=>void p(),children:c?`Releasing…`:`Create release`})]})]})})}function fe({record:e,schema:t,areas:n,onSaved:r}){let[i,a]=(0,L.useState)({title:e.title,type:e.type,area:e.area,visibility:e.visibility}),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),d=(e,t)=>a(n=>({...n,[e]:t})),f={};for(let t of[`title`,`type`,`area`,`visibility`])i[t]!==e[t]&&(f[t]=i[t]);let g=Object.keys(f).length>0,_=n.includes(e.area)?n:[e.area,...n],v=async()=>{s(!0);try{let t=await x.patchChange(e.id,f,e.revision);l(``),r(t.record)}catch(e){l(V(e))}finally{s(!1)}};return(0,R.jsxs)(re,{className:`gap-2.5 rounded-lg py-3 shadow-xs`,children:[(0,R.jsx)(ne,{className:`px-3`,children:(0,R.jsx)(ee,{className:z,children:`edit fragment`})}),(0,R.jsxs)(C,{className:`flex flex-col gap-2.5 px-3`,children:[(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`edit-fragment-title`,children:`Title`}),(0,R.jsx)(b,{id:`edit-fragment-title`,maxLength:120,value:i.title,onChange:e=>d(`title`,e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:[(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`edit-fragment-type`,children:`Type`}),(0,R.jsx)(h,{id:`edit-fragment-type`,value:i.type,onChange:e=>d(`type`,e.target.value),children:t.types.map(e=>(0,R.jsx)(m,{value:e,children:e},e))})]}),(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`edit-fragment-area`,children:`Area`}),(0,R.jsx)(h,{id:`edit-fragment-area`,value:i.area,onChange:e=>d(`area`,e.target.value),children:_.map(e=>(0,R.jsx)(m,{value:e,children:e},e))})]}),(0,R.jsxs)(I,{children:[(0,R.jsx)(D,{htmlFor:`edit-fragment-visibility`,children:`Visibility`}),(0,R.jsx)(h,{id:`edit-fragment-visibility`,value:i.visibility,onChange:e=>d(`visibility`,e.target.value),children:t.visibilities.map(e=>(0,R.jsx)(m,{value:e,children:e},e))})]})]})]}),(0,R.jsxs)(w,{className:`gap-2.5 px-3`,children:[c?(0,R.jsx)(`span`,{className:`flex-1 text-xs`,style:{color:p(`error`)},"aria-live":`polite`,children:c}):(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,disabled:o||!g||!i.title.trim(),onClick:()=>void v(),children:o?`Saving…`:`Save changes`})]})]})}function pe({selectedId:e,onSelect:t,onOpenRecord:n,schema:a,areas:s}){let[m,h]=(0,L.useState)([]),[v,ee]=(0,L.useState)(``),[y,S]=(0,L.useState)(``),[C,w]=(0,L.useState)(``),[ne,E]=(0,L.useState)(!0),[D,O]=(0,L.useState)(``),[k,j]=(0,L.useState)(``),[M,N]=(0,L.useState)(!1),[P,F]=(0,L.useState)(null),[I,ae]=(0,L.useState)(`public`),[z,U]=(0,L.useState)({content:``,error:``,loading:!0}),[G,pe]=(0,L.useState)(0),me=()=>pe(e=>e+1);ie(e=>{te(e,`/changelog/`)&&me()}),(0,L.useEffect)(()=>{let e=!1,t=async()=>{E(!0);try{let t=await x.changelog(v.trim(),{state:y||void 0,visibility:C||void 0});if(e)return;h(t.records),O(``)}catch(t){e||O(V(t))}finally{e||E(!1)}},n=window.setTimeout(()=>void t(),v?180:0);return()=>{e=!0,window.clearTimeout(n)}},[v,y,C,G]),(0,L.useEffect)(()=>{let e=!1;return U(e=>({...e,loading:!0})),x.renderedChangelog(I).then(t=>{e||U({content:t.content,error:``,loading:!1})}).catch(t=>{e||U({content:``,error:V(t),loading:!1})}),()=>{e=!0}},[I,G]);let q=(0,L.useMemo)(()=>[...m].sort((e,t)=>{if(e.kind!==t.kind)return e.kind===`change`?-1:1;if(e.kind===`release`&&t.kind===`release`){let n=t.date.localeCompare(e.date);return n===0?t.id.localeCompare(e.id):n}return String(t.updated||``).localeCompare(String(e.updated||``))}),[m]),J=(0,L.useMemo)(()=>new Map(m.map(e=>[e.id,e])),[m]),Y=(0,L.useMemo)(()=>q.filter(e=>e.kind===`change`&&!e.released),[q]),he=(0,L.useMemo)(()=>q.filter(e=>e.kind===`change`&&e.released),[q]),X=(0,L.useMemo)(()=>q.filter(e=>e.kind===`release`),[q]),Z=(0,L.useMemo)(()=>ce(X,Y),[X,Y]),Q=e?J.get(e):void 0,$=e=>{if(J.has(e)){t(e);return}if(/^(CHG|REL)-/.test(e)){S(``),w(``),t(e);return}n(e)},ge=()=>{j(``),x.releasePreview().then(F).catch(e=>j(V(e)))},_e=Q?.issues.some(e=>e.severity===`error`)?`destructive`:`default`,ve=(0,R.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>N(!0),children:[(0,R.jsx)(r,{"aria-hidden":`true`}),`New fragment`]});return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:l(`w-full shrink-0 flex-col border-r lg:flex lg:w-[400px]`,Q?`hidden`:`flex`),children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 p-3.5 pb-0`,children:[(0,R.jsxs)(re,{className:`flex-row items-center gap-2.5 border-primary bg-primary/10 p-3`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`text-[13px] font-semibold`,children:[Y.length,` unpublished fragment`,Y.length===1?``:`s`]}),(0,R.jsxs)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground`,children:[`next: `,Z,` ·`,` `,a.releaseStrategy]})]}),(0,R.jsx)(u,{type:`button`,size:`sm`,className:`whitespace-nowrap`,onClick:ge,children:`Prepare release`})]}),k?(0,R.jsx)(g,{variant:`destructive`,"aria-live":`polite`,children:(0,R.jsx)(A,{children:k})}):null,(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(b,{type:`search`,"aria-label":`Search history`,placeholder:`Search fragments and releases…`,value:v,onChange:e=>ee(e.target.value),className:`h-7 flex-1 px-2.5 text-xs md:text-xs`}),(0,R.jsx)(H,{label:`state`,value:y,options:[`unreleased`,`released`],onChange:S}),(0,R.jsx)(H,{label:`visibility`,value:C,options:a.visibilities,onChange:w})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3.5 pb-6 [mask-image:linear-gradient(to_bottom,black_calc(100%-24px),transparent)]`,children:ne?(0,R.jsx)(`div`,{"aria-busy":`true`,className:`flex flex-col gap-2 pt-4`,children:Array.from({length:6},(e,t)=>(0,R.jsx)(`div`,{className:`h-[52px] animate-pulse rounded-md bg-muted`},t))}):D?(0,R.jsx)(g,{variant:`destructive`,className:`mt-4`,"aria-live":`polite`,children:(0,R.jsx)(A,{children:D})}):q.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(W,{label:`unpublished`,records:Y,selectedId:e,onSelect:t}),(0,R.jsx)(W,{label:`releases`,records:X,selectedId:e,onSelect:t}),(0,R.jsx)(W,{label:`published fragments`,records:he,selectedId:e,onSelect:t})]}):(0,R.jsx)(f,{className:`mt-4 gap-1 p-4 md:p-4`,children:(0,R.jsx)(d,{className:`text-xs`,children:`No history records match the filters.`})})})]}),(0,R.jsx)(`div`,{className:l(`min-w-0 flex-1 overflow-y-auto px-6 py-5 sm:px-8.5`,Q?`block`:`hidden lg:block`),children:(0,R.jsx)(`div`,{className:se,children:Q?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(u,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-2 mb-2 lg:hidden`,onClick:()=>t(``),children:[(0,R.jsx)(o,{"aria-hidden":`true`}),`All history`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[11px]`,children:[(0,R.jsx)(`span`,{className:`whitespace-nowrap text-primary`,children:Q.id}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:Q.kind}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),Q.kind===`change`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{style:{color:B(Q.type)},children:Q.type}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Q.area}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Q.visibility}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{style:{color:c(Q.released?`released`:`unreleased`)},children:Q.released?`released`:`unreleased`}),Q.updated?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:Q.updated})]}):null]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-primary`,children:Q.version}),(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:Q.date}),Q.commit?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:Q.commit})]}):null,(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,R.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[Q.fragments.length,` fragment`,Q.fragments.length===1?``:`s`]})]}),(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[ve,(0,R.jsx)(u,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close record`,title:`Back to the derived changelog`,onClick:()=>t(``),children:(0,R.jsx)(i,{"aria-hidden":`true`})})]})]}),(0,R.jsx)(`h2`,{className:`mt-2.5 mb-1 text-[26px] leading-tight font-semibold tracking-tight [text-wrap:pretty]`,children:Q.title}),(0,R.jsx)(`div`,{className:`font-mono text-[10.5px] break-all text-muted-foreground/70`,children:Q.path}),Q.issues.length>0?(0,R.jsx)(g,{variant:_e,className:`mt-3.5`,children:(0,R.jsx)(A,{className:`w-full gap-1`,children:Q.issues.map(e=>(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10.5px]`,style:{color:p(e.severity)},children:e.severity}),(0,R.jsx)(`span`,{children:e.message})]},`${e.code}-${e.message}`))})}):null,(0,R.jsx)(`div`,{className:`mt-4.5`,children:(0,R.jsx)(oe,{source:Q.body||`No additional notes.`,onOpen:$})}),(0,R.jsxs)(`div`,{className:`mt-5.5 flex flex-col gap-3.5`,children:[Q.kind===`change`?(0,R.jsx)(K,{label:`shipped in`,links:(Q.releaseIds||[]).map(e=>({id:e,title:J.get(e)?.title||`Open release`,relation:`release`})),onOpen:$}):(0,R.jsx)(K,{label:`fragments · ${Q.fragments.length}`,links:Q.fragments.map(e=>{let t=J.get(e);return{id:e,title:t?.title||`Open fragment`,relation:t?.kind===`change`?t.type:void 0}}),onOpen:$}),(0,R.jsx)(K,{label:`links to`,links:le(Q.outgoing),onOpen:$}),(0,R.jsx)(K,{label:`backlinks`,links:le(Q.incoming),onOpen:$})]}),Q.kind===`change`?(0,R.jsx)(`div`,{className:`mt-5.5`,children:(0,R.jsx)(fe,{record:Q,schema:a,areas:s,onSaved:e=>h(t=>t.map(t=>t.id===e.id?e:t))},`${Q.id}:${Q.revision}`)}):null]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-2 border-b pb-3`,children:[(0,R.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Derived changelog`}),(0,R.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`visibility `,I,` · CHANGELOG.md`]}),(0,R.jsxs)(`span`,{className:`ml-auto flex flex-wrap items-center gap-2.5`,children:[(0,R.jsx)(_,{children:a.visibilities.map(e=>(0,R.jsx)(u,{type:`button`,size:`sm`,variant:I===e?`default`:`outline`,"aria-pressed":I===e,className:`h-7 px-2.5 text-xs`,onClick:()=>ae(e),children:e},e))}),(0,R.jsx)(T,{variant:`outline`,className:`rounded-md font-mono text-[10.5px] font-normal whitespace-nowrap text-muted-foreground`,children:`render --write`}),ve]})]}),z.error?(0,R.jsx)(g,{variant:`destructive`,className:`mt-4`,"aria-live":`polite`,children:(0,R.jsx)(A,{children:z.error})}):(0,R.jsx)(`pre`,{className:`mt-4 font-mono text-xs leading-[1.75] whitespace-pre-wrap text-muted-foreground`,"aria-busy":z.loading||void 0,children:z.loading&&!z.content?`Rendering…`:z.content||`Nothing to render yet — create the first change fragment.`})]})})}),M?(0,R.jsx)(ue,{schema:a,areas:s,onClose:()=>N(!1),onCreated:e=>{N(!1),h(t=>[e,...t]),t(e.id)}}):null,P?(0,R.jsx)(de,{preview:P,suggestedVersion:Z,onClose:()=>F(null),onReleased:()=>{F(null),me()}}):null]})}export{pe as HistoryView};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{G as r,K as i,V as a,_t as o,it as s,q as c,vt as l}from"./ui-primitives-wYj92QGw.js";import{l as u,m as d,p as f,r as p,t as m,u as h}from"./empty-BHqXimMR.js";import{n as g,t as _}from"./native-select-NN1SzVJL.js";import{$ as v,E as y,G as b,H as x,I as S,J as C,M as ee,O as te,P as ne,Q as w,T,Z as E,_ as re,b as D,c as O,d as k,et as A,f as j,g as M,h as N,j as P,k as F,l as I,m as ie,p as L,q as R,v as z,w as B,x as V}from"./index-DEiK6_Ib.js";var H=e(t(),1),U=n(),W=[`low`,`medium`,`high`],G=[`critical`,`high`,`medium`,`low`],ae=`[mask-image:linear-gradient(to_bottom,black_calc(100%_-_24px),transparent)]`;function oe(e){return e&&e[0].toUpperCase()+e.slice(1)}function K(e,t){return`${e} ${t}${e===1?``:`s`}`}function q(e){return{category:e===`learnings`||e===`decisions`,confidence:e===`learnings`,severity:e===`incidents`,expires:e===`context`,review_after:e===`context`}}function se(e){let t=[];switch(e.collection){case`learnings`:t.push(e.confidence,e.category,e.occurrences==null?null:`${e.occurrences}×`);break;case`decisions`:e.superseded_by?.length?t.push(`superseded by ${e.superseded_by.join(`, `)}`):e.supersedes?.length?t.push(`supersedes ${e.supersedes.join(`, `)}`):t.push(e.category);break;case`incidents`:t.push(e.severity,e.corrective_actions?.length?K(e.corrective_actions.length,`corrective action`):null);break;case`conventions`:t.push(e.owners?.length?e.owners.join(`, `):`no owner`);break;case`context`:t.push(e.expires?`expires ${e.expires}`:null,e.review_after?`review after ${e.review_after}`:null);break;default:t.push(e.category,e.severity)}return t.filter(Boolean).join(` · `)}function J({label:e,value:t,options:n,allLabel:r=`all`,onChange:i}){return(0,U.jsxs)(b,{children:[(0,U.jsx)(E,{asChild:!0,children:(0,U.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e,className:d(`h-7 gap-1 rounded-full px-2.5 text-xs`,t&&`border-ring bg-accent`),children:[e,(0,U.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:t||r}),(0,U.jsx)(o,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`})]})}),(0,U.jsxs)(R,{align:`start`,sideOffset:4,children:[(0,U.jsxs)(C,{onSelect:()=>i(``),children:[r,t?null:(0,U.jsx)(l,{"aria-hidden":`true`,className:`ml-auto`})]}),n.map(e=>(0,U.jsxs)(C,{onSelect:()=>i(e.value),children:[e.color?(0,U.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:e.color},"aria-hidden":`true`}):null,e.label??e.value,t===e.value?(0,U.jsx)(l,{"aria-hidden":`true`,className:`ml-auto`}):null]},e.value))]})]})}function Y({id:e,label:t,children:n}){return(0,U.jsxs)(z,{className:`gap-1.5 [&_[data-slot=native-select-wrapper]]:w-full`,children:[(0,U.jsx)(D,{htmlFor:e,children:t}),n]})}function ce({record:e,selected:t,onSelect:n}){let r=se(e),i=e.lifecycleIssues?.length||0;return(0,U.jsx)(y,{asChild:!0,variant:`outline`,size:`sm`,className:`w-full flex-none flex-col items-stretch gap-1 rounded-lg bg-background px-2.5 py-2 text-left shadow-xs hover:border-ring aria-[current=true]:border-ring aria-[current=true]:bg-accent`,children:(0,U.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,children:[(0,U.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,U.jsxs)(w,{variant:`outline`,className:`h-[18px] gap-1 rounded-md px-1.5 font-mono text-[10px] font-medium`,children:[(0,U.jsx)(`span`,{className:`size-[5px] shrink-0 rounded-full`,style:{backgroundColor:u(e.status)},"aria-hidden":`true`}),e.status]})]}),(0,U.jsx)(`span`,{className:`text-[13px] font-medium leading-snug`,children:e.title}),r||i?(0,U.jsxs)(`span`,{className:`font-mono text-[10.5px] text-muted-foreground`,children:[r,r&&i?` · `:null,i?(0,U.jsx)(`span`,{style:{color:h(`warning`)},children:K(i,`lifecycle warning`)}):null]}):null]})})}function X({issues:e,kind:t}){return e.length?(0,U.jsx)(U.Fragment,{children:e.map(e=>(0,U.jsx)(v,{variant:e.severity===`error`?`destructive`:`default`,className:`px-3 py-2`,children:(0,U.jsxs)(A,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10.5px]`,style:{color:h(e.severity)},children:t===`lifecycle`?`lifecycle`:e.severity}),(0,U.jsx)(`span`,{children:e.message})]})},`${t}-${e.code}-${e.message}`))}):null}function Z({label:e,links:t,onOpen:n}){return t.length?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),t.map(t=>{let r=!t.exists&&!t.title;return(0,U.jsx)(y,{asChild:!0,variant:`outline`,size:`sm`,className:`gap-2 rounded-lg px-2.5 py-2 text-left hover:border-ring disabled:pointer-events-none disabled:opacity-50`,children:(0,U.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>n(t.id),children:[(0,U.jsx)(`span`,{className:`w-[78px] shrink-0 truncate font-mono text-[11px] font-medium`,children:t.id}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:t.title||`Missing record`}),t.relation||t.kind?(0,U.jsx)(w,{variant:`secondary`,className:`h-[18px] rounded-md px-1.5 font-mono text-[10px] font-medium`,children:t.relation||t.kind}):null]})},`${e}-${t.id}`)})]}):null}function Q({message:e}){return e?(0,U.jsx)(v,{variant:`destructive`,className:`px-3 py-2`,children:(0,U.jsx)(A,{children:e})}):null}function le({schema:e,initialCollection:t,onClose:n,onCreated:r}){let i=e.collections.find(e=>e.id===t)||e.collections[0],[a,o]=(0,H.useState)({collection:i?.id||`learnings`,status:i?.statuses[0]||`active`,title:``,category:``,confidence:``,severity:``,expires:``,body:``}),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(``),d=e.collections.find(e=>e.id===a.collection),p=q(a.collection),m=(e,t)=>o(n=>({...n,[e]:t})),h=t=>{let n=e.collections.find(e=>e.id===t);o(e=>({...e,collection:t,status:n?.statuses[0]||`active`}))},v=async()=>{c(!0);try{r((await S.createMemory({collection:a.collection,title:a.title,status:a.status,body:a.body,category:a.category||void 0,confidence:a.confidence||void 0,severity:a.severity||void 0,expires:a.expires||void 0})).record)}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}};return(0,U.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(I,{className:`sm:max-w-[520px]`,"aria-describedby":void 0,children:[(0,U.jsx)(j,{children:(0,U.jsxs)(L,{children:[`New `,d?.singular||`record`]})}),(0,U.jsxs)(`div`,{className:`-m-1 flex max-h-[65vh] flex-col gap-3 overflow-y-auto p-1`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,U.jsx)(Y,{id:`memory-create-collection`,label:`Collection`,children:(0,U.jsx)(_,{id:`memory-create-collection`,value:a.collection,onChange:e=>h(e.target.value),children:e.collections.map(e=>(0,U.jsx)(g,{value:e.id,children:e.id},e.id))})}),(0,U.jsx)(Y,{id:`memory-create-status`,label:`Status`,children:(0,U.jsx)(_,{id:`memory-create-status`,value:a.status,onChange:e=>m(`status`,e.target.value),children:(d?.statuses||[]).map(e=>(0,U.jsx)(g,{value:e,children:e},e))})})]}),(0,U.jsx)(Y,{id:`memory-create-title`,label:`Title`,children:(0,U.jsx)(x,{id:`memory-create-title`,autoFocus:!0,required:!0,maxLength:120,value:a.title,onChange:e=>m(`title`,e.target.value)})}),p.category||p.confidence||p.severity||p.expires?(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[p.category?(0,U.jsx)(Y,{id:`memory-create-category`,label:`Category`,children:(0,U.jsx)(x,{id:`memory-create-category`,value:a.category,onChange:e=>m(`category`,e.target.value)})}):null,p.confidence?(0,U.jsx)(Y,{id:`memory-create-confidence`,label:`Confidence`,children:(0,U.jsxs)(_,{id:`memory-create-confidence`,value:a.confidence,onChange:e=>m(`confidence`,e.target.value),children:[(0,U.jsx)(g,{value:``,children:`not set`}),W.map(e=>(0,U.jsx)(g,{value:e,children:e},e))]})}):null,p.severity?(0,U.jsx)(Y,{id:`memory-create-severity`,label:`Severity`,children:(0,U.jsxs)(_,{id:`memory-create-severity`,value:a.severity,onChange:e=>m(`severity`,e.target.value),children:[(0,U.jsx)(g,{value:``,children:`not set`}),G.map(e=>(0,U.jsx)(g,{value:e,children:e},e))]})}):null,p.expires?(0,U.jsx)(Y,{id:`memory-create-expires`,label:`Expires`,children:(0,U.jsx)(x,{id:`memory-create-expires`,type:`date`,value:a.expires,onChange:e=>m(`expires`,e.target.value)})}):null]}):null,(0,U.jsx)(Y,{id:`memory-create-body`,label:`Details`,children:(0,U.jsx)(B,{id:`memory-create-body`,rows:8,value:a.body,onChange:e=>m(`body`,e.target.value)})}),(0,U.jsx)(Q,{message:l})]}),(0,U.jsxs)(k,{children:[(0,U.jsx)(f,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(f,{type:`button`,disabled:s||!a.title.trim(),onClick:()=>void v(),children:s?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(T,{"aria-hidden":`true`}),`Saving…`]}):`Create record`})]})]})})}function ue({record:e,statuses:t,onClose:n,onUpdated:r}){let i=q(e.collection),[a,o]=(0,H.useState)({title:e.title,status:e.status,category:e.category||``,confidence:e.confidence||``,severity:e.severity||``,expires:e.expires||``,review_after:e.review_after||``,body:e.body}),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(``),d=(e,t)=>o(n=>({...n,[e]:t})),p=async()=>{let t={};a.title.trim()&&a.title!==e.title&&(t.title=a.title),a.status!==e.status&&(t.status=a.status),a.body!==e.body&&(t.body=a.body);for(let n of[`category`,`confidence`,`severity`,`expires`,`review_after`])a[n]!==(e[n]||``)&&(t[n]=a[n]||null);if(!Object.keys(t).length){n();return}c(!0);try{r((await S.patchMemory(e.id,t,e.revision)).record),n()}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}};return(0,U.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(I,{className:`sm:max-w-[520px]`,"aria-describedby":void 0,children:[(0,U.jsx)(j,{children:(0,U.jsxs)(L,{children:[`Edit `,e.id]})}),(0,U.jsxs)(`div`,{className:`-m-1 flex max-h-[65vh] flex-col gap-3 overflow-y-auto p-1`,children:[(0,U.jsx)(Y,{id:`memory-edit-title`,label:`Title`,children:(0,U.jsx)(x,{id:`memory-edit-title`,autoFocus:!0,required:!0,maxLength:120,value:a.title,onChange:e=>d(`title`,e.target.value)})}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,U.jsx)(Y,{id:`memory-edit-status`,label:`Status`,children:(0,U.jsx)(_,{id:`memory-edit-status`,value:a.status,onChange:e=>d(`status`,e.target.value),children:(t.includes(a.status)?t:[a.status,...t]).map(e=>(0,U.jsx)(g,{value:e,children:e},e))})}),i.category?(0,U.jsx)(Y,{id:`memory-edit-category`,label:`Category`,children:(0,U.jsx)(x,{id:`memory-edit-category`,value:a.category,onChange:e=>d(`category`,e.target.value)})}):null,i.confidence?(0,U.jsx)(Y,{id:`memory-edit-confidence`,label:`Confidence`,children:(0,U.jsxs)(_,{id:`memory-edit-confidence`,value:a.confidence,onChange:e=>d(`confidence`,e.target.value),children:[(0,U.jsx)(g,{value:``,children:`not set`}),W.map(e=>(0,U.jsx)(g,{value:e,children:e},e))]})}):null,i.severity?(0,U.jsx)(Y,{id:`memory-edit-severity`,label:`Severity`,children:(0,U.jsxs)(_,{id:`memory-edit-severity`,value:a.severity,onChange:e=>d(`severity`,e.target.value),children:[(0,U.jsx)(g,{value:``,children:`not set`}),G.map(e=>(0,U.jsx)(g,{value:e,children:e},e))]})}):null,i.expires?(0,U.jsx)(Y,{id:`memory-edit-expires`,label:`Expires`,children:(0,U.jsx)(x,{id:`memory-edit-expires`,type:`date`,value:a.expires,onChange:e=>d(`expires`,e.target.value)})}):null,i.review_after?(0,U.jsx)(Y,{id:`memory-edit-review-after`,label:`Review after`,children:(0,U.jsx)(x,{id:`memory-edit-review-after`,type:`date`,value:a.review_after,onChange:e=>d(`review_after`,e.target.value)})}):null]}),(0,U.jsx)(Y,{id:`memory-edit-body`,label:`Details`,children:(0,U.jsx)(B,{id:`memory-edit-body`,rows:10,value:a.body,onChange:e=>d(`body`,e.target.value)})}),(0,U.jsx)(Q,{message:l})]}),(0,U.jsxs)(k,{children:[(0,U.jsx)(f,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(f,{type:`button`,disabled:s||!a.title.trim(),onClick:()=>void p(),children:s?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(T,{"aria-hidden":`true`}),`Saving…`]}):`Save changes`})]})]})})}function de({record:e,mode:t,onClose:n,onUpdated:r}){let[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(``),u=async()=>{s(!0);try{r((t===`graduate`?await S.graduateMemory(e.id,i.split(`,`).map(e=>e.trim()).filter(Boolean),e.revision):await S.supersedeMemory(e.id,i.trim(),e.revision)).record),n()}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,U.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,U.jsxs)(I,{className:`sm:max-w-[420px]`,"aria-describedby":void 0,children:[(0,U.jsx)(j,{children:(0,U.jsxs)(L,{children:[t===`graduate`?`Graduate`:`Supersede`,` `,e.id]})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(Y,{id:`memory-lifecycle-target`,label:t===`graduate`?`Target IDs`:`Replacement ID`,children:(0,U.jsx)(x,{id:`memory-lifecycle-target`,autoFocus:!0,placeholder:t===`graduate`?`CONV-0001, DOC-0004`:`ADR-0009`,value:i,onChange:e=>a(e.target.value)})}),(0,U.jsx)(Q,{message:c})]}),(0,U.jsxs)(k,{children:[(0,U.jsx)(f,{type:`button`,variant:`outline`,onClick:n,children:`Cancel`}),(0,U.jsx)(f,{type:`button`,disabled:o||!i.trim(),onClick:()=>void u(),children:o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(T,{"aria-hidden":`true`}),`Saving…`]}):`Apply`})]})]})})}function fe({record:e,statuses:t,onOpenRelation:n,onOpenRecord:i,onUpdated:a,onDialogOpenChange:o}){let[l,d]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),g=l||!!p;(0,H.useEffect)(()=>{o?.(g)},[g,o]);let _=e.collection===`learnings`&&e.status!==`graduated`,v=[`learnings`,`decisions`,`conventions`].includes(e.collection),y=[[`status`,e.status,u(e.status)]];return e.category&&y.push([`category`,e.category]),e.confidence&&y.push([`confidence`,e.confidence]),e.severity&&y.push([`severity`,e.severity,h(e.severity)]),e.occurrences!=null&&y.push([`occurrences`,String(e.occurrences)]),e.expires&&y.push([`expires`,e.expires]),e.review_after&&y.push([`review after`,e.review_after]),e.started_at&&y.push([`started`,e.started_at]),e.resolved_at&&y.push([`resolved`,e.resolved_at]),e.graduated_to?.length&&y.push([`graduated to`,e.graduated_to.join(`, `)]),e.superseded_by?.length&&y.push([`superseded by`,e.superseded_by.join(`, `)]),e.owners?.length&&y.push([`owners`,e.owners.join(`, `)]),y.push([`updated`,e.updated||`—`]),(0,U.jsxs)(`aside`,{"aria-label":`Memory record`,className:`flex min-h-0 flex-col overflow-hidden border-l bg-background`,children:[(0,U.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b px-3.5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.id}),(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/60`,children:`·`}),(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.collection}),(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/60`,children:`·`}),(0,U.jsx)(`span`,{className:`font-mono text-[11px]`,style:{color:u(e.status)},children:e.status})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto p-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-[17px] font-semibold leading-[1.3] tracking-[-0.01em] [text-wrap:pretty]`,children:e.title}),e.path?(0,U.jsx)(`span`,{className:`break-all font-mono text-[10.5px] text-muted-foreground`,children:e.path}):null]}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-2`,children:y.map(([e,t,n])=>(0,U.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),(0,U.jsx)(`span`,{className:`text-sm`,style:n?{color:n}:void 0,children:t})]},e))}),(0,U.jsx)(X,{issues:e.issues,kind:`validation`}),(0,U.jsx)(X,{issues:e.lifecycleIssues||[],kind:`lifecycle`}),(0,U.jsx)(V,{className:`[--typeset-size:0.875rem]`,source:e.body||`No details recorded.`,onOpen:i}),(0,U.jsx)(Z,{label:`Links to`,links:e.outgoing,onOpen:n}),(0,U.jsx)(Z,{label:`Backlinks`,links:e.incoming,onOpen:n}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>d(!0),children:[(0,U.jsx)(c,{"aria-hidden":`true`}),`Edit`]}),_?(0,U.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(`graduate`),children:[(0,U.jsx)(s,{"aria-hidden":`true`}),`Graduate`]}):null,v?(0,U.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(`supersede`),children:[(0,U.jsx)(r,{"aria-hidden":`true`}),`Supersede`]}):null]})]}),l?(0,U.jsx)(ue,{record:e,statuses:t,onClose:()=>d(!1),onUpdated:a}):null,p?(0,U.jsx)(de,{record:e,mode:p,onClose:()=>m(``),onUpdated:a}):null]})}function $(e,t){return e.find(e=>e.id===t)?.statuses||[]}function pe({selectedId:e,onSelect:t,onOpenRecord:n,schema:r}){let[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)(``),[h,g]=(0,H.useState)(``),[_,y]=(0,H.useState)(``),[b,x]=(0,H.useState)(!0),[C,E]=(0,H.useState)(``),[D,O]=(0,H.useState)(null),[k,j]=(0,H.useState)(()=>localStorage.getItem(`workfile-memory-drawer`)===`expanded`);(0,H.useEffect)(()=>{localStorage.setItem(`workfile-memory-drawer`,k?`expanded`:`normal`)},[k]);let I=(0,H.useRef)(!1),L=(0,H.useRef)(0),R=(0,H.useCallback)(e=>{L.current=performance.now(),t(e)},[t]),[z,B]=(0,H.useState)(0);F(e=>{te(e,`/memory/`)&&B(e=>e+1)}),(0,H.useEffect)(()=>{let e=async()=>{x(!0);try{let e=await S.memory(c.trim(),{collection:h||void 0,status:_||void 0});s(e.records),E(``)}catch(e){E(e instanceof Error?e.message:String(e))}finally{x(!1)}},t=window.setTimeout(()=>void e(),c?180:0);return()=>window.clearTimeout(t)},[c,h,_,z]);let V=(0,H.useMemo)(()=>[...o].sort((e,t)=>String(t.updated||``).localeCompare(String(e.updated||``))||e.title.localeCompare(t.title)),[o]),W=(0,H.useMemo)(()=>{let e=r.collections.filter(e=>!h||e.id===h).map(e=>({schema:e,records:V.filter(t=>t.collection===e.id)})),t=new Set(r.collections.map(e=>e.id)),n=V.filter(e=>!t.has(e.collection));return n.length&&e.push({schema:{id:`other`,singular:`record`,idPrefix:`?`,statuses:[]},records:n}),e},[r.collections,V,h]),G=V.find(t=>t.id===e),q=h?$(r.collections,h):[...new Set(r.collections.flatMap(e=>e.statuses))];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3.5 pt-3.5`,children:[(0,U.jsxs)(N,{className:`w-full min-w-[180px] sm:w-[260px]`,children:[(0,U.jsx)(M,{children:(0,U.jsx)(a,{"aria-hidden":`true`})}),(0,U.jsx)(re,{type:`search`,"aria-label":`Search workfile memory`,placeholder:`Search decisions, incidents, learnings…`,value:c,onChange:e=>l(e.target.value)})]}),(0,U.jsx)(J,{label:`collection`,value:h,options:r.collections.map(e=>({value:e.id})),onChange:e=>{g(e),y(``)}}),(0,U.jsx)(J,{label:`status`,value:_,options:q.map(e=>({value:e,color:u(e)})),onChange:y}),(0,U.jsx)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 whitespace-nowrap font-mono text-[11px] text-muted-foreground`,children:b?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(T,{"aria-hidden":`true`,className:`size-3`}),`loading…`]}):K(o.length,`record`)})]}),C?(0,U.jsx)(v,{variant:`destructive`,className:`mx-3.5 mt-3 w-auto px-3 py-2`,children:(0,U.jsxs)(A,{children:[`Memory could not be loaded: `,C]})}):null,(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 gap-3 overflow-hidden p-3.5`,children:(0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 gap-3 overflow-x-auto`,children:W.map(t=>(0,U.jsxs)(P,{className:`w-[272px] flex-none gap-0 overflow-hidden rounded-xl py-0 [--card-spacing:--spacing(2)]`,children:[(0,U.jsxs)(ne,{className:`flex flex-row items-center gap-2 border-b px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-primary`,children:t.schema.idPrefix}),(0,U.jsx)(`span`,{className:`flex-1 text-[12.5px] font-semibold`,children:oe(t.schema.singular)}),(0,U.jsx)(w,{variant:`secondary`,className:`h-5 px-1.5 font-mono text-[11px] font-normal`,children:t.records.length}),t.schema.id===`other`?null:(0,U.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`New ${t.schema.singular}`,onClick:()=>O(t.schema.id),children:(0,U.jsx)(i,{"aria-hidden":`true`})})]}),(0,U.jsxs)(ee,{className:d(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2.5`,ae),children:[t.records.map(t=>(0,U.jsx)(ce,{record:t,selected:t.id===e,onSelect:()=>R(t.id)},t.id)),!t.records.length&&!b?(0,U.jsx)(m,{className:`gap-1 border border-dashed p-4 md:p-6`,children:(0,U.jsx)(p,{className:`font-mono text-xs`,children:`no records`})}):null]})]},t.schema.id))})}),(0,U.jsx)(ie,{open:!!G,expanded:k,label:`record`,description:`Details and lifecycle for the selected memory record.`,onOpenChange:e=>{e||t(``)},onExpandedChange:j,holdOpen:()=>I.current||performance.now()-L.current<200,children:G?(0,U.jsx)(fe,{record:G,statuses:$(r.collections,G.collection),onOpenRelation:e=>{o.some(t=>t.id===e)?R(e):n(e)},onOpenRecord:n,onUpdated:e=>s(t=>t.map(t=>t.id===e.id?e:t)),onDialogOpenChange:e=>{I.current=e}},G.id):null}),D===null?null:(0,U.jsx)(le,{schema:r,initialCollection:D,onClose:()=>O(null),onCreated:e=>{O(null),s(t=>[e,...t]),t(e.id)}})]})}export{pe as MemoryView};
import"./rolldown-runtime-CbXtAM7H.js";import{i as e,t}from"./react-Buq45Vzz.js";import{_t as n}from"./ui-primitives-wYj92QGw.js";import{m as r}from"./empty-BHqXimMR.js";e();var i=t();function a({className:e,size:t=`default`,...a}){return(0,i.jsxs)(`div`,{className:`group/native-select relative w-fit has-[select:disabled]:opacity-50`,"data-slot":`native-select-wrapper`,children:[(0,i.jsx)(`select`,{"data-slot":`native-select`,"data-size":t,className:r(`h-9 w-full min-w-0 appearance-none rounded-md border border-input bg-transparent px-3 py-2 pr-9 text-sm shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed data-[size=sm]:h-8 data-[size=sm]:py-1 dark:bg-input/30 dark:hover:bg-input/50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...a}),(0,i.jsx)(n,{className:`pointer-events-none absolute top-1/2 right-3.5 size-4 -translate-y-1/2 text-muted-foreground opacity-50 select-none`,"aria-hidden":`true`,"data-slot":`native-select-icon`})]})}function o({className:e,...t}){return(0,i.jsx)(`option`,{"data-slot":`native-select-option`,className:r(`bg-[Canvas] text-[CanvasText]`,e),...t})}export{o as n,a as t};
import"./rolldown-runtime-CbXtAM7H.js";import{i as e,t}from"./react-Buq45Vzz.js";import{c as n,s as r}from"./ui-primitives-wYj92QGw.js";import{m as i}from"./empty-BHqXimMR.js";e();var a=t();function o({className:e,value:t,...o}){return(0,a.jsx)(n,{"data-slot":`progress`,className:i(`relative h-2 w-full overflow-hidden rounded-full bg-primary/20`,e),...o,children:(0,a.jsx)(r,{"data-slot":`progress-indicator`,className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})})}export{o as t};
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,t as n}from"./react-Buq45Vzz.js";import{W as r,Y as i,yt as a}from"./ui-primitives-wYj92QGw.js";import{a as o,f as s,i as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h}from"./empty-BHqXimMR.js";import{W as g,a as _,x as v}from"./index-DEiK6_Ib.js";import{t as y}from"./layout-QiuZ_k5v.js";import{t as b}from"./progress-CKc41PRw.js";var x=e(t(),1),S=n(),C=[{key:`N`,label:`Move to next`,status:`next`},{key:`D`,label:`Defer`,status:`deferred`},{key:`X`,label:`Discard`,status:`discarded`}];function w({tasks:e,repoRoot:t,repoUrl:n,onPatch:w,onOpen:T}){let[E,D]=(0,x.useState)(()=>new Set),[O,k]=(0,x.useState)(0),A=(0,x.useMemo)(()=>e.filter(e=>!E.has(e.id)),[E,e]),j=A[O]||A[0],M=e.length;(0,x.useEffect)(()=>{O>=A.length&&k(Math.max(0,A.length-1))},[O,A.length]);let N=(0,x.useCallback)(async(e,t=!0)=>{if(j){try{await w(j.id,e)}catch{return}t&&(D(e=>new Set(e).add(j.id)),k(e=>Math.min(e,Math.max(0,A.length-2))))}},[w,A.length,j]);(0,x.useEffect)(()=>{let e=e=>{if(e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if([`INPUT`,`SELECT`,`TEXTAREA`].includes(t.tagName)||t.isContentEditable)return;let n=e.key.toUpperCase();if(n===`J`||e.key===`ArrowDown`)e.preventDefault(),k(e=>Math.min(A.length-1,e+1));else if(n===`K`||e.key===`ArrowUp`)e.preventDefault(),k(e=>Math.max(0,e-1));else if(/^[1-4]$/.test(n))e.preventDefault(),N({priority:_[Number(n)-1]},!1);else{let t=C.find(e=>e.key===n);t&&(e.preventDefault(),N({status:t.status}))}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[N,A.length]);let P=e=>n?`${n.replace(/\/+$/,``)}/blob/main/${e}`:`vscode://file${t}/${e}`;return j?(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b bg-card px-3.5 py-2.5`,children:[(0,S.jsx)(b,{value:M?E.size/M*100:0,className:`max-w-[340px] flex-1`}),(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[E.size,` of `,M,` processed`]}),(0,S.jsx)(`span`,{className:`flex-1`}),(0,S.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,disabled:O===0,onClick:()=>k(e=>Math.max(0,e-1)),children:[(0,S.jsx)(g,{children:`K`}),`Previous`]}),(0,S.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:[O+1,` / `,A.length]}),(0,S.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,disabled:O>=A.length-1,onClick:()=>k(e=>Math.min(A.length-1,e+1)),children:[(0,S.jsx)(g,{children:`J`}),`Next`]}),(0,S.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>T(j.id),children:[(0,S.jsx)(i,{"aria-hidden":`true`}),`Open full card`]})]}),(0,S.jsxs)(`div`,{className:l(y,`px-6 py-7 sm:px-8`),children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[11px] text-muted-foreground`,children:[(0,S.jsx)(`span`,{children:j.id}),(0,S.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,S.jsx)(`span`,{style:{color:s(j.status)},children:j.status}),(0,S.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,S.jsx)(`span`,{children:j.area}),(0,S.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,S.jsx)(`span`,{children:j.type})]}),(0,S.jsx)(`h2`,{className:`mt-3 mb-1 text-[26px] leading-[1.2] font-semibold tracking-tight [text-wrap:pretty]`,children:j.title}),j.file?(0,S.jsx)(`a`,{className:`font-mono text-[11px] text-muted-foreground/70 underline underline-offset-[3px]`,href:P(j.file),target:n?`_blank`:void 0,rel:n?`noreferrer`:void 0,children:j.file}):null,j.source?(0,S.jsxs)(`span`,{className:`mt-[3px] block font-mono text-[11px] text-muted-foreground/70`,children:[`source`,` `,(0,S.jsx)(`a`,{className:`font-mono underline underline-offset-[3px]`,href:P(j.source),target:n?`_blank`:void 0,rel:n?`noreferrer`:void 0,children:j.source})]}):null,(0,S.jsx)(`div`,{className:`mt-[22px]`,children:(0,S.jsx)(v,{source:j.body,onOpen:T})}),(0,S.jsxs)(`div`,{className:`mt-[30px] flex flex-wrap gap-2 border-t pt-[18px]`,children:[_.map((e,t)=>(0,S.jsxs)(f,{type:`button`,variant:`outline`,"aria-pressed":j.priority===e,style:j.priority===e?{borderColor:m(e)}:void 0,onClick:()=>void N({priority:e},!1),children:[(0,S.jsx)(g,{children:t+1}),(0,S.jsx)(`span`,{style:{color:m(e)},children:e})]},e)),C.map(e=>(0,S.jsxs)(f,{type:`button`,variant:`outline`,onClick:()=>void N({status:e.status}),children:[(0,S.jsx)(g,{children:e.key}),(0,S.jsx)(`span`,{style:{color:s(e.status)},children:e.label})]},e.key))]}),(0,S.jsx)(`span`,{className:`mt-3.5 block text-xs text-muted-foreground`,children:`Every action writes the card's frontmatter to disk immediately. Shortcuts work while focus is outside a form.`})]})]}):(0,S.jsxs)(h,{className:`gap-3 p-10`,children:[(0,S.jsxs)(c,{children:[(0,S.jsx)(o,{children:(0,S.jsx)(a,{"aria-hidden":`true`,size:20,style:{color:s(`done`)}})}),(0,S.jsx)(d,{className:`text-sm`,children:`Queue clear`}),(0,S.jsxs)(p,{className:`text-[12.5px]`,children:[`You processed `,E.size.toLocaleString(),` cards.`]})]}),(0,S.jsx)(u,{children:(0,S.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{D(new Set),k(0)},children:[(0,S.jsx)(r,{"aria-hidden":`true`}),`Start again`]})})]})}export{w as TriageView};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display