1import{c as L,j as e,aM as F,aI as B,aH as V,aj as I,ad as D,a4 as H,bl as $}from"./vendor-1kUQ7zn2.js";import{S as Q,Q as U,R as _,c as d,bo as W,bp as q,ae as X,aS as Y,aZ as Z,a_ as z,bq as G,br as J,bs as O,bt as R,bu as K,bv as ee}from"./index--kdl1ae9.js";import"./vendor-date-en1IyhsK.js";import"./vendor-supabase-Dh2gyaRa.js";import"./vendor-motion-BX-jsy7E.js";const se=[{value:"all",label:"All"},{value:"today",label:"Today"},{value:"overdue",label:"Overdue"},{value:"today,overdue",label:"Today + late"},{value:"tomorrow",label:"Tomorrow"},{value:"this-week",label:"This week"},{value:"next-week",label:"Next week"},{value:"next-month",label:"Next month"}],ae=["do","schedule","delegate","backlog"],le=120,me=c=>{const{open:r,onOpenChange:i,activeFacetCount:N,onClearAll:h,resultCount:f}=c,[u,m]=L.useState("main");return L.useEffect(()=>{r||m("main")},[r]),e.jsx(Q,{open:r,onOpenChange:i,children:e.jsxs(U,{side:"bottom",onOpenAutoFocus:b=>{b.preventDefault(),b.target?.focus()},className:d("mx-sheet mx-filter fb-root flex flex-col p-0 gap-0 rounded-t-2xl border-t border-border/60","data-[state=open]:duration-200 data-[state=closed]:duration-150","[&>button]:hidden",u!=="main"&&"is-picking"),children:[e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-muted-foreground/30","aria-hidden":!0})}),u==="main"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mx-filter-head",children:[e.jsx(_,{className:"mx-filter-title",children:"Filters"}),e.jsx("button",{type:"button",className:"mx-filter-link",onClick:h,disabled:N===0,children:"Clear all"})]}),e.jsx(te,{...c,onPick:m}),e.jsxs("div",{className:"mx-filter-foot",children:[e.jsxs("button",{type:"button",className:"mx-filter-save",onClick:()=>{i(!1),window.setTimeout(c.onSaveCurrent,180)},children:[e.jsx(F,{className:"h-4 w-4 shrink-0","aria-hidden":!0})," ",e.jsx("span",{children:"Save preset"})]}),e.jsx("button",{type:"button",className:"mx-filter-done",onClick:()=>i(!1),children:`Show ${f} ${f===1?"task":"tasks"}`})]})]}):e.jsx(ne,{...c,facet:u,onBack:()=>m("main")})]})})},P=({title:c,children:r,action:i})=>e.jsxs("section",{className:"mx-filter-section",children:[e.jsxs("div",{className:"mx-filter-label",children:[e.jsx("h3",{children:c}),i]}),r]}),te=({isPending:c,selectedProjects:r,selectedLabels:i,onLabelsChange:N,selectedPriorities:h,onPrioritiesChange:f,dateFilter:u,onDateFilterChange:m,hideSubtasks:b,onHideSubtasksChange:g,presets:k,selectedPresetId:v,onSelectPreset:w,todoistFilters:y,todoistFiltersError:M,selectedTodoistFilter:t,onSelectTodoistFilter:p,onClearSaved:o,onManage:j,onOpenChange:E,projectNames:C,onPick:S})=>{const x=!!t,T=()=>window.setTimeout(()=>E(!1),le),s=a=>f(h.includes(a)?h.filter(n=>n!==a):[...h,a]),l=r.length?r.map(a=>C[a]??a).join(", "):"Any",A=i.length?i.map(W).join(", "):"Any";return e.jsxs("div",{className:d("mx-filter-body",c&&"is-pending"),children:[e.jsxs(P,{title:"Saved",action:k.some(a=>!a.builtIn)&&e.jsx("button",{type:"button",className:"mx-filter-link",onClick:j,children:"Manage"}),children:[k.length===0&&y.length===0?e.jsx("p",{className:"mx-filter-help",children:"No saved filters yet. Pick some filters, then Save as preset."}):e.jsxs("div",{className:"mx-chips",children:[k.map(a=>{const n=a.id===v&&!x;return e.jsxs("button",{type:"button",className:d("mx-chip",n&&"is-on"),"aria-pressed":n,onClick:()=>{if(n){o();return}w(a.id),T()},children:[a.is_default&&e.jsx(B,{className:"mx-chip-icon fill-amber-400 text-amber-400","aria-label":"Default"}),a.name]},a.id)}),y.map(a=>{const n=a.id===t?.id;return e.jsxs("button",{type:"button",className:d("mx-chip",n&&"is-on"),"aria-pressed":n,"aria-label":`Todoist filter ${a.name}`,onClick:()=>{if(n){p(null);return}p(a),T()},children:[e.jsx(V,{className:"mx-chip-icon","aria-hidden":!0}),a.name]},a.id)})]}),M&&e.jsx("p",{className:"mx-filter-help",children:"Couldn't load your Todoist filters. They'll be retried automatically."}),x&&e.jsxs("p",{className:"mx-filter-note",children:["Showing the Todoist filter ",e.jsx("b",{children:t?.name}),". The filters below are paused while it's on."]})]}),e.jsxs("div",{className:d(x&&"mx-filter-paused"),"aria-disabled":x||void 0,children:[e.jsx(P,{title:"When",children:e.jsx("div",{className:"mx-chips",role:"radiogroup","aria-label":"When",children:se.map(a=>{const n=u===a.value;return e.jsx("button",{type:"button",role:"radio","aria-checked":n,className:d("mx-chip fb-date",n&&"is-on"),onClick:()=>
1m(a.value),children:a.label},a.value)})})}),e.jsxs("div",{className:"mx-filter-rows",children:[e.jsxs("button",{type:"button",className:"mx-filter-row",onClick:()=>S("projects"),children:[e.jsx("span",{className:"mx-filter-row-name",children:"Projects"}),e.jsx("span",{className:d("mx-filter-row-value",r.length>0&&"is-set"),children:l}),e.jsx(I,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),e.jsxs("button",{type:"button",className:"mx-filter-row",onClick:()=>S("labels"),children:[e.jsx("span",{className:"mx-filter-row-name",children:"Labels"}),e.jsx("span",{className:d("mx-filter-row-value",i.length>0&&"is-set"),children:A}),e.jsx(I,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),i.length>=2&&e.jsxs("p",{className:"mx-filter-help mx-filter-rowhelp",children:["Tasks must have all selected labels."," ",e.jsx("button",{type:"button",className:"mx-filter-link",onClick:()=>N([]),children:"Clear labels"})]})]}),e.jsx(P,{title:"Priority",children:e.jsx("div",{className:"mx-chips",children:q.map(a=>{const n=h.includes(a.value);return e.jsxs("button",{type:"button","aria-pressed":n,className:d("mx-chip mx-chip-prio fb-priority",n&&"is-on"),onClick:()=>s(a.value),children:[e.jsx(D,{className:d("mx-chip-icon",a.tone),"aria-hidden":!0}),a.label]},a.value)})})})]}),e.jsxs("label",{htmlFor:"hide-subtasks",className:"mx-filter-row is-switch",children:[e.jsx("span",{className:"mx-filter-row-name",children:"Hide subtasks"}),e.jsx(X,{id:"hide-subtasks",checked:b,onCheckedChange:g})]})]})},ne=({facet:c,onBack:r,apiKey:i,selectedProjects:N,onProjectsChange:h,selectedLabels:f,onLabelsChange:u})=>{const[m,b]=L.useState(""),{projects:g,isLoading:k}=Y(i),{allLabels:v,todoistLabels:w}=Z(i),{trackProjectUsage:y,trackLabelUsage:M}=z(),t=c==="projects",p=L.useMemo(()=>{if(t)return g.map(l=>({id:l.id,name:l.is_inbox_project?"Inbox":l.name,color:l.color}));const s=new Map(w.map(l=>[l.name,l.color]));return v.filter(l=>!ae.includes(l.toLowerCase())).map(l=>({id:l,name:l,color:s.get(l)}))},[t,g,v,w]),o=t?N:f,j=t?h:u,E=s=>{o.includes(s.id)?j(o.filter(l=>l!==s.id)):(j([...o,s.id]),t?y(s.id,s.name):M(s.name)),b("")},C=(s,l)=>({id:s.id,checked:o.includes(s.id),onSelect:()=>E(s),content:e.jsxs(e.Fragment,{children:[e.jsx(O,{color:R(s.color)}),e.jsx("span",{className:"pk-name",children:e.jsx(ee,{text:s.name,range:l})})]})}),S=m.trim()?[{rows:G(p,m,s=>s.name).map(s=>C(s.item,s.range))}]:[{rows:(t?p:J(p,s=>s.name)).map(s=>C(s))}],x=new Map(p.map(s=>[s.id,s])),T=o.length>0&&e.jsx("div",{className:"fb-tokens","aria-label":t?"Selected projects":"Selected labels",children:o.map(s=>e.jsxs("span",{className:"fb-token pk-chip",children:[e.jsx(O,{color:R(x.get(s)?.color)}),e.jsx("span",{className:"fb-token-label",children:x.get(s)?.name??s}),e.jsx("button",{type:"button","aria-label":`Remove ${x.get(s)?.name??s}`,onClick:()=>j(o.filter(l=>l!==s)),children:e.jsx(H,{"aria-hidden":!0})})]},s))});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mx-filter-head is-sub",children:[e.jsx("button",{type:"button",className:"mx-filter-back",onClick:r,"aria-label":"Back to filters",children:e.jsx($,{className:"h-5 w-5","aria-hidden":!0})}),e.jsx(_,{className:"mx-filter-title",children:t?"Projects":"Labels"}),e.jsx("button",{type:"button",className:"mx-filter-link",onClick:()=>j([]),disabled:o.length===0,children:"Clear"})]}),e.jsx("p",{className:"mx-filter-help mx-filter-mode",children:t?"Tasks in any of these projects.":"Tasks with all of these labels."}),e.jsx("div",{className:"mx-filter-pick",children:e.jsx(K,{label:t?"Projects":"Labels",tone:t?"fb-project":"fb-label",query:m,onQueryChange:b,placeholder:t?"Search projects":"Search labels",groups:S,chips:T,onBackspaceEmpty:o.length?()=>j(o.slice(0,-1)):void 0,empty:e.jsx("div",{className:"pk-note",children:t?k?"Loading projectsâ¦":"No projects":"No labels"})})}),e.jsxs("div",{className:"mx-filter-foot",children:[e.jsx("span",{}),e.jsx("button",{type:"button",className:"mx-filter-done",onClick:r,children:"Done"})]})]})};export{me as MobileFilterSheet};
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.