1import{k as u,j as e,B as y,ac as p,aO as K,w as x,a2 as h,aH as Q,aE as J,E as Y,aI as W,aF as q,aJ as T,L as R,aP as V,aQ as X,ah as Z,u as _,D as ee,aR as se,t as te}from"./index-1IeKS4sZ.js";import{F as ae,S as ne}from"./filter-popover-Bljw0Eh5.js";import{b as I,n as re,T as L,g as ie,a as oe,f as le}from"./task-status-Ct9WU6dH.js";import"./popover-B9foyvAP.js";const E={priorities:[],assignees:[]},ce=[["URGENT","Urgent"],["HIGH","High"],["MEDIUM","Medium"],["LOW","Low"],["NONE","None"]],de="grid w-full grid-cols-[72px_minmax(0,1fr)] items-center gap-x-3 sm:gap-x-4 sm:[grid-template-columns:72px_minmax(0,30%)_minmax(60px,1fr)_minmax(120px,1.5fr)_minmax(72px,1fr)]";function ue(t){const s=new Map;for(const r of t){const o=re(r.status||"BACKLOG");s.set(o,[...s.get(o)??[],r])}return[...L.filter(r=>s.has(r)),...Array.from(s.keys()).filter(r=>!L.includes(r))].map(r=>({status:r,tasks:s.get(r)??[]}))}function xe(t){if(!t)return!1;const s=new Date(t),n=new Date;return!Number.isNaN(s.getTime())&&s.getFullYear()===n.getFullYear()&&s.getMonth()===n.getMonth()&&s.getDate()===n.getDate()}function b(t){const s=t.createdAt??t.updatedAt;if(!s)return 0;const n=Date.parse(s);return Number.isNaN(n)?0:n}function D(t){return t.assignee?`name:${t.assignee.toLowerCase()}`:"__unassigned__"}function O(t,s){return t.includes(s)?t.filter(n=>n!==s):[...t,s]}function me({tasks:t,isProviderConnected:s,isProviderLoading:n=!1,isLoading:r=!1,isError:o=!1,onRetry:m}){const[l,f]=u.useState("newest"),[g,w]=u.useState(!1),[d,j]=u.useState(E),[k,M]=u.useState(""),[P,H]=u.useState(()=>new Set),[v,S]=u.useState(!1),U=u.useMemo(()=>{const i=new Map;for(const a of t){const c=D(a),G=i.get(c);i.set(c,{value:c,label:a.assignee||"Unassigned",count:(G?.count??0)+1})}return[...i.values()].sort((a,c)=>a.label.localeCompare(c.label))},[t]),N=u.useMemo(()=>{const i=k.trim().toLowerCase();return[...t].filter(a=>{if(g&&!xe(a.createdAt??a.updatedAt))return!1;const c=I(a.priority);return!(d.priorities.length>0&&!d.priorities.includes(c)||d.assignees.length>0&&!d.assignees.includes(D(a))||i&&![a.externalKey,a.title,a.description,a.assignee,a.status,a.priority].join(" ").toLowerCase().includes(i))}).sort((a,c)=>l==="newest"?b(c)-b(a):b(a)-b(c))},[t,g,d,k,l]),$=u.useMemo(()=>ue(N),[N]),C=d.priorities.length+d.assignees.length+Number(g),B=async()=>{S(!0);try{await m?.()}finally{S(!1)}};return e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col bg-background",children:[e.jsxs("div",{className:"shrink-0 border-b border-border",children:[e.jsxs("div",{className:x("flex h-[46px] items-center justify-between",h),children:[e.jsx("h2",{className:"px-1 text-base font-medium text-foreground",children:"Tasks"}),s?e.jsxs(y,{type:"button",variant:"outline",onClick:()=>{B()},disabled:v,className:"h-7 rounded-[12px] px-2.5 text-xs",children:[e.jsx(p,{icon:K,size:14,className:x(v&&"animate-spin")}),v?"Syncing...":"Sync"]}):null]}),s?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:x("flex items-center gap-2 overflow-x-auto pb-2 [scrollbar-width:none]",h),children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>w(i=>!i),"aria-pressed":g,className:x("h-8 rounded-[14px] px-3 text-xs",g?"border-primary/30 bg-primary/10 text-primary":"text-muted-foreground"),children:"Today"}),e.jsxs("label",{className:"relative block w-[112px] shrink-0",children:[e.jsx("span",{className:"sr-only",children:"Sort tasks"}),e.jsxs("select",{"aria-label":"Sort tasks",value:l,onChange:i=>f(i.target.value),className:"h-8 w-full appearance-none rounded-[14px] border border-input bg-background px-3 pr-7 text-xs text-foreground shadow-none outline-none transition-colors focus:border-ring focus:ring-1 focus:ring-ring",children:[e.jsx("option",{value:"newest",children:"Newest"}),e.jsx("option",{value:"oldest",children:"Oldest"})]}),e.jsx(Q,{"aria-hidden":"true",className:"pointer-events-none absolute right-2.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground"})]}),e.jsxs(ae,{ariaLabel:"Task filters",trigger:e.jsxs(e.Fragment,{children:[e.jsx(p,{icon:J,size:12}),"Filters",C>0?e.jsx("span",{className:"rounded-full bg-muted px-1.5 text-[10px]",children:C}):null]}),buttonClassName:"h-8 rounded-[14px] px-3 text-xs",contentClassName:"w-[340px] rounded-[18px] border-border/80 bg-popover/95 p-3 shadow-[0_18px_48px_-24px_rgba(0,0,0,0.35)] backdrop-blur-xl",children:[e.jsx(F,{label:"Priority",options:ce.map(([i,a])=>({value:i,label:a})),selected:d.priorities,onToggle:i=>j(a=>({...a,priorities:O(a.priorities,i)}))}),e.jsx(F,{label:"Assignee",options:U,selected:d.assignees,onToggle:i=>j(a=>({...a,assignees:O(a.assignees,i)}))})]}),e.jsxs("label",{className:"flex h-8 w-52 shrink-0 items-center rounded-[14px] border border-border bg-background px-2",children:[e.jsx(ne,{className:"size-3.5 shrink-0 text-muted-foreground"}),e.jsx("input",{value:k,onChange:i=>M(i.target.value),placeholder:"Search tasks...","aria-label":"Search tasks",className:"ml-2 min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-muted-foreground"})]})]}),e.jsx("div",{className:h,children:e.jsx(ge,{todayOnly:g,filters:d,onTodayClear:()=>w(!1),onChange:j,onClear:()=>{w(!1),j(E)}})}),e.jsxs("p",{className:x("pb-2 text-xs text-muted-foreground",h),children:["Showing ",N.length," of ",t.length," tasks"]})]}):null]}),e.jsx("div",{className:x("min-h-0 flex-1 overflow-y-auto py-4 pb-36",h,!s&&!n&&"flex items-start justify-center"),children:n?e.jsx(z,{message:"Checking task provider connection..."}):s?r?e.jsx(z,{message:"Loading tasks..."}):o?e.jsx(Y,{title:"Failed to load tasks",description:"Refresh the task provider and try again.",onRetry:m}
1):t.length===0?e.jsx(A,{title:"No tasks found",description:"Tasks from Linear or Jira will appear here after syncing"}):N.length===0?e.jsx(A,{title:"No matching tasks",description:"Try changing filters or search keywords"}):e.jsx("div",{className:"w-full space-y-2",children:$.map(i=>e.jsx(fe,{...i,isCollapsed:P.has(i.status),onToggle:()=>H(a=>{const c=new Set(a);return c.has(i.status)?c.delete(i.status):c.add(i.status),c})},i.status))}):e.jsx(pe,{})})]})}function z({message:t}){return e.jsxs("div",{className:"flex w-full flex-col items-center justify-center py-16",children:[e.jsx(q,{className:"size-6 animate-spin text-muted-foreground"}),e.jsx("p",{className:"mt-3 text-base text-muted-foreground",children:t})]})}function pe(){return e.jsxs("div",{className:"mt-11 flex flex-col items-center justify-center",children:[e.jsx("div",{className:"mb-3 flex size-12 items-center justify-center rounded-full bg-muted",children:e.jsx(p,{icon:T,size:24,className:"text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground",children:"Connect a Task Provider"}),e.jsx("p",{className:"mt-1 max-w-sm text-center text-sm text-muted-foreground",children:"Connect Linear or Jira in Settings to sync and view your tasks"}),e.jsxs(R,{to:"/app/settings",search:{tab:"integrations"},className:"mt-4 inline-flex h-7 items-center gap-1.5 rounded-full bg-primary px-3 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/80",children:[e.jsx(p,{icon:T,size:14}),"Go to Settings"]})]})}function A({title:t,description:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"mb-3 flex size-12 items-center justify-center rounded-full bg-muted",children:e.jsx(p,{icon:T,size:24,className:"text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground",children:t}),e.jsx("p",{className:"mt-1 max-w-sm text-center text-sm text-muted-foreground",children:s})]})}function F({label:t,options:s,selected:n,onToggle:r}){return e.jsxs("section",{className:"[&+section]:mt-3",children:[e.jsx("p",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("div",{className:"max-h-40 space-y-0.5 overflow-y-auto",children:s.length===0?e.jsx("p",{className:"px-2 py-1 text-sm text-muted-foreground",children:"None found"}):s.map(o=>e.jsxs("label",{className:"flex cursor-pointer items-center rounded-md px-2 py-1.5 hover:bg-muted",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:o.label}),o.count!==void 0?e.jsx("span",{className:"mx-2 text-xs text-muted-foreground",children:o.count}):null,e.jsx("input",{type:"checkbox",checked:n.includes(o.value),onChange:()=>r(o.value),className:"size-3.5 rounded border-border bg-transparent"})]},o.value))})]})}function ge({todayOnly:t,filters:s,onTodayClear:n,onChange:r,onClear:o}){const m=[...t?[{key:"today",label:"Today",remove:n}]:[],...s.priorities.map(l=>({key:`priority-${l}`,label:`Priority: ${l.toLowerCase()}`,remove:()=>r({...s,priorities:s.priorities.filter(f=>f!==l)})})),...s.assignees.map(l=>({key:`assignee-${l}`,label:l==="__unassigned__"?"Unassigned":`Assignee: ${l.replace("name:","")}`,remove:()=>r({...s,assignees:s.assignees.filter(f=>f!==l)})}))];return m.length===0?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.map(l=>e.jsxs(y,{type:"button",variant:"outline",onClick:l.remove,className:"h-6 rounded-[10px] px-2 text-[10px]",children:[l.label,e.jsx(p,{icon:W,size:10})]},l.key))}),e.jsx(y,{type:"button",variant:"ghost",onClick:o,className:"h-6 px-2 text-[10px] text-muted-foreground",children:"Clear all"})]})}function fe({status:t,tasks:s,isCollapsed:n,onToggle:r}){const o=ie(t);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:r,className:"flex w-full select-none items-center gap-2 pb-1 pt-3","aria-expanded":!n,children:[e.jsx("span",{className:x("size-2 shrink-0 rounded-full",o.dotClassName)}),e.jsx("span",{className:x("text-sm font-semibold uppercase tracking-wider",o.textClassName),children:o.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.length,")"]}),e.jsx(p,{icon:n?V:X,size:12,className:"ml-auto text-muted-foreground"})]}),n?null:s.map(m=>e.jsx(he,{task:m},m.id))]})}const he=u.memo(function({task:s}){const n=I(s.priority),r=oe(s.priority),o=le(s.dueDate);return e.jsx(R,{to:"/app/tasks/$taskId",params:{taskId:s.id},preload:"intent",className:"card-glass-hover block rounded-lg bg-transparent px-3 py-2.5",children:e.jsxs("div",{className:de,children:[e.jsx("span",{className:"flex h-6 min-w-0 items-center truncate whitespace-nowrap font-mono text-xs tabular-nums text-primary",children:s.externalKey??s.provider}),e.jsx("h3",{className:"flex h-6 min-w-0 items-center text-sm font-medium text-foreground",children:e.jsx("span",{className:"truncate",children:s.title})}),e.jsx("span",{className:x("hidden h-6 items-center whitespace-nowrap text-xs sm:inline-flex",n==="NONE"?"text-muted-foreground
1/70":r.className),children:n==="NONE"?"â":r.label}),e.jsxs("span",{className:"hidden h-6 min-w-0 items-center gap-1.5 text-xs text-muted-foreground sm:flex",children:[e.jsx(p,{icon:Z,size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:s.assignee??"Unassigned"})]}),e.jsx("span",{className:"hidden h-6 items-center whitespace-nowrap text-xs text-muted-foreground sm:flex",children:o?`Due ${o}`:"â"})]})})});function je({children:t}){return e.jsx(ee,{title:"Tasks",children:t})}function ke(){const t=_(se()),s=_(te()),n=!!s.data?.some(r=>(r.id==="linear"||r.id==="jira")&&r.connected);return e.jsx(je,{children:e.jsx(me,{tasks:t.data??[],isProviderConnected:n,isProviderLoading:s.isLoading,isLoading:t.isLoading,isError:t.isError||s.isError,onRetry:()=>{Promise.all([t.refetch(),s.refetch()])}})})}export{ke as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.