1import{c,j as e,ac as M,ae as O,ba as $,cv as U,cz as V,a4 as T,aD as W,K as I}from"./vendor-1kUQ7zn2.js";import{u as Y,A as z,d as q}from"./AiConsentDialog-CkXfz-s-.js";import{ad as G,ac as J,g as K,w as Q,N as x,ae as v,c as l,S as X,Q as Z,R as ee}from"./index--kdl1ae9.js";import{S as te}from"./slider-D6mh3qnw.js";import{A as D,m as y}from"./vendor-motion-BX-jsy7E.js";import"./vendor-date-en1IyhsK.js";import"./vendor-supabase-Dh2gyaRa.js";const d=({icon:a,iconTint:n,title:u,description:h,checked:p,onCheckedChange:g,disabled:s,testId:o})=>e.jsxs("div",{className:"flex items-center justify-between gap-4 py-1",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:l("mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md",n),children:a}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(x,{className:"block text-[0.9375rem] font-medium leading-tight",children:u}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground leading-snug",children:h})]})]}),e.jsx(v,{checked:p,onCheckedChange:g,disabled:s,"aria-label":u,"data-testid":o})]}),j=({children:a})=>e.jsx("h3",{className:"text-[0.6875rem] font-semibold uppercase tracking-[0.08em] text-muted-foreground/80",children:a}),se=(()=>{const a=new Date;return a.setUTCHours(3,0,0,0),a.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})})(),le=({isOpen:a,onClose:n,showConfetti:u,onToggleConfetti:h,showTags:p,onToggleTags:g})=>{const{preferences:s,updatePreferences:o,isLoading:i}=G(),{nestSubtasks:N,toggleNestSubtasks:E}=J(),[f,k]=c.useState({top:0,right:0}),m=K(),r=Y(),[L,w]=c.useState(!1),[C,_]=c.useState(!1);c.useEffect(()=>{a&&Q("settings_opened")},[a]);const P=async()=>{if(!(C||r.isLoading)){if(!r.consented){w(!0);return}_(!0);try{await r.revoke(),I.success("AI suggestions turned off",{description:"No task titles will be sent.",duration:2e3})}catch{I.error("Couldn't turn off AI suggestions",{description:"Please try again in a moment."})}finally{_(!1)}}};c.useEffect(()=>{if(!document.getElementById("settings-portal-container")){const t=document.createElement("div");t.id="settings-portal-container",t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.zIndex="99999",t.style.pointerEvents="none",document.body.appendChild(t)}},[]),c.useEffect(()=>{if(!a||m)return;const t=document.querySelector('[title="Settings"]');if(t){const b=t.getBoundingClientRect();k({top:b.bottom+10,right:window.innerWidth-b.right})}else k({top:60,right:20})},[a,m]);const B=async()=>{if(!i)try{await o({auto_prioritize_enabled:!s?.auto_prioritize_enabled})}catch{}},R=async()=>{if(!(i||!s?.auto_prioritize_enabled))try{await o({include_today:!s?.include_today})}catch{}},F=async()=>{if(!(i||!s?.auto_prioritize_enabled))try{await o({include_overdue:!s?.include_overdue})}catch{}},H=async t=>{if(!(i||!s?.auto_prioritize_enabled))try{await o({days_before_due:t[0]})}catch{}},S=e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx(j,{children:"Display"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(d,{icon:e.jsx(M,{className:"h-3.5 w-3.5 text-purple-600 dark:text-purple-300"}),iconTint:"bg-purple-500/10 dark:bg-purple-500/20",title:"Show labels",description:"Display labels on each task",checked:p,onCheckedChange:g}),e.jsx(d,{icon:e.jsx(O,{className:"h-3.5 w-3.5 text-emerald-600 dark:text-emerald-300"}),iconTint:"bg-emerald-500/10 dark:bg-emerald-500/20",title:"Nest subtasks",description:"Show subtasks inside their parent task's card",checked:N,onCheckedChange:()=>E(!N)}),e.jsx(d,{icon:e.jsx($,{className:"h-3.5 w-3.5 text-amber-600 dark:text-amber-300"}),iconTint:"bg-amber-500/10 dark:bg-amber-500/20",title:"Confetti effects",description:"Celebrate completed tasks",checked:u,onCheckedChange:h})]})]}),e.jsx("div",{className:"h-px bg-border/60"}),e.jsxs("section",{className:"space-y-3",children:[e.jsx(j,{children:"Automation"}),e.jsx(d,{icon:e.jsx(U,{className:"h-3.5 w-3.5 text-blue-600 dark:text-blue-300"}),iconTint:"bg-blue-500/10 dark:bg-blue-500/20",title:"Auto-prioritize",description:`Once a day (around ${se}), moves tasks due in the next few days into Do First`,checked:s?.auto_prioritize_enabled||!1,onCheckedChange:B,disabled:i}),e.jsx(D,{initial:!1,children:s?.auto_prioritize_enabled&&e.jsx(y.div,{initial:{opacity:0,height:0}
1,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.18,ease:[.22,1,.36,1]},className:"overflow-hidden",children:e.jsxs("div",{className:l("mt-1 ml-10 space-y-4 rounded-lg border border-border/60 bg-muted/30 p-3.5 transition-opacity",i?"opacity-50":"opacity-100"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Move when due within"}),e.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s.days_before_due||3," ",(s.days_before_due||3)===1?"day":"days"]})]}),e.jsx(te,{defaultValue:[s.days_before_due||3],max:14,min:1,step:1,onValueChange:H,disabled:i,className:"py-0.5"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Also move tasks due today"}),e.jsx(v,{checked:s.include_today||!1,onCheckedChange:R,disabled:i})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Also move overdue tasks"}),e.jsx(v,{checked:s.include_overdue||!1,onCheckedChange:F,disabled:i})]})]})},"auto-prioritize-options")})]}),e.jsx("div",{className:"h-px bg-border/60"}),e.jsxs("section",{className:"space-y-3",children:[e.jsx(j,{children:"AI"}),e.jsx(d,{icon:e.jsx(V,{className:"h-3.5 w-3.5 text-violet-600 dark:text-violet-300"}),iconTint:"bg-violet-500/10 dark:bg-violet-500/20",title:z.settingTitle,description:z.settingDescription,checked:r.consented,onCheckedChange:P,disabled:r.isLoading||C,testId:"ai-consent-switch"})]}),e.jsx(q,{open:L,onOpenChange:w,aboveSettings:!m,reconsent:r.outdated})]});if(m)return e.jsx(X,{open:a,onOpenChange:t=>!t&&n(),children:e.jsxs(Z,{side:"bottom",onOpenAutoFocus:t=>{t.preventDefault(),t.target?.focus()},className:l("mx-sheet flex flex-col gap-0 p-0 rounded-t-2xl border-t border-border/60","max-h-[calc(100dvh-env(safe-area-inset-top)-24px)]","data-[state=open]:duration-200 data-[state=closed]:duration-150","[&>button]:hidden"),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})}),e.jsxs("div",{className:"flex items-center justify-between pl-5 pr-2 pt-1",children:[e.jsx(ee,{className:"text-[17px] font-semibold",children:"Settings"}),e.jsx("button",{onClick:n,"aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-full text-muted-foreground",children:e.jsx(T,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain px-5 pt-2 pb-[max(1.25rem,env(safe-area-inset-bottom))]",children:S})]})});const A=e.jsx(D,{children:a&&e.jsxs(e.Fragment,{children:[e.jsx(y.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 bg-black/40 backdrop-blur-sm",style:{zIndex:99999,pointerEvents:"auto"},onClick:n}),e.jsx(y.div,{initial:{opacity:0,y:-8,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.97},transition:{duration:.22,ease:[.22,1,.36,1]},className:l("fixed","w-[22rem] max-w-[calc(100vw-1.5rem)]"),style:{zIndex:1e5,pointerEvents:"auto",top:`${f.top}px`,right:`${f.right}px`},role:"dialog","aria-modal":"true","aria-label":"Settings",children:e.jsxs("div",{className:l("overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-2xl backdrop-blur-xl","flex flex-col"),style:{maxHeight:`min(42rem, calc(100vh - ${f.top}px - 16px))`},children:[e.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-3",children:[e.jsx("h2",{className:"text-base font-semibold tracking-tight",children:"Settings"}),e.jsx("button",{onClick:n,"aria-label":"Close settings",className:"-mr-1 -mt-1 inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:e.jsx(T,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain px-5 pb-5",children:S})]})})]})});return typeof document<"u"&&document.getElementById("settings-portal-container")?W.createPortal(A,document.getElementById("settings-portal-container")):A};export{le as SettingsDialog};
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.