1import{h as K,a as rs,aQ as wa,aR as Sa,aS as Da,aT as Ta,aU as ka,aV as Aa,aW as Ma,aX as La,aF as za,r as i,j as e,C as ss,c as as,d as ts,b as ns,e as Ws,a4 as Pa,B as d,W as je,X as be,Y as ve,Z as _e,_ as Ne,$ as Ce,a0 as we,a1 as ls,N as Ia,aY as Ea,aZ as Oa,a_ as Ha,M as Vs,a$ as Ua,b0 as Ra,b1 as Fa,b2 as Va,b3 as $a,b4 as Ba,L as I,I as q,an as D,b5 as Ga,J as Ya,a9 as Wa,k as qa,H as Ka,af as Xa,b6 as Za,b7 as Ja,b8 as Qa,b9 as et,ba as st,bb as at,bc as tt,f as nt,ab as lt,bd as it,ad as rt,ag as $s,u as ot,g as ct,am as dt,U as ut,n as mt,S as ft,T as pt,al as ht}from"./index-D6SvOtgm.js";import{C as w,S as We}from"./CollapsibleCard-C6o9bjTP.js";import{S as qe,a as Ke,b as Xe,c as Ze,d as S}from"./select-YqoZZcp4.js";import{B as se}from"./badge-CMPlRQIo.js";import{c as xt,P as gt,a as yt,b as jt,C as bt}from"./popover-BPqxiDHY.js";import{C as vt}from"./checkbox-LW-Fk35x.js";import{C as _t,U as Nt}from"./upload-CbmV50I6.js";import{T as ee}from"./trash-2-CWQLxyCw.js";import{S as ue}from"./send-BoQM2sLe.js";import{r as Je,a as Qe,D as Ct,h as wt,n as St,b as Dt,g as Tt,c as kt,s as At,w as Mt}from"./dashboardLayout-C39oxoiq.js";import{C as Lt}from"./chevrons-up-down-D9J_Dbxk.js";import{P as Bs}from"./plus-D3Pyeiwz.js";import{C as zt}from"./chevron-up-0kWFayQS.js";import"./index-DsJJTj6Y.js";import"./collapsible-BC8w7Jcw.js";import"./index-DTVBxHJL.js";import"./index-BdQq_4o_.js";import"./subDays-DSIU38Yn.js";import"./endOfWeek-BYWjyhBm.js";import"./chevron-left-BR1Ep01q.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Gs=K("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Pt=K("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const It=K("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Et=K("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** 22 * @license lucide-react v0.462.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Ot=K("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** 27 * @license lucide-react v0.462.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const Ht=K("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** 32 * @license lucide-react v0.462.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const is=K("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** 37 * @license lucide-react v0.462.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree.
41 */const Ut=K("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),es="/settings";function Rt(){const{t}=rs(),{data:h,isLoading:T}=wa(),{data:x=[]}=Sa(),E=Da(),ae=Ta(),p=ka(),P=Aa(),O=Ma(),N=La(),R=za(),[F,V]=i.useState([]),[A,H]=i.useState({}),[k,a]=i.useState(!1),[U,$]=i.useState(!1);i.useEffect(()=>{const r=new URLSearchParams(window.location.search).get("code");if(r){const m=`${window.location.origin}${es}`;ae.mutate({code:r,redirectUri:m},{onSuccess:()=>{window.history.replaceState({},"",es)}})}},[]),i.useEffect(()=>{if(x.length>0){const u={};x.forEach(r=>{u[r.calendar_id]=r.is_enabled}),H(u)}},[x]);const M=async()=>{const u=`${window.location.origin}${es}`,r=await E.mutateAsync(u);window.location.href=r},Z=()=>{p.mutate(),V([]),H({}),a(!1)},B=async()=>{const u=await P.mutateAsync();V(u),a(!0);const r={};u.forEach(m=>{const j=x.find(G=>G.calendar_id===m.id);r[m.id]=j?j.is_enabled:m.primary}),H(r)},te=async()=>{const u=F.filter(r=>A[r.id]).map(r=>({calendar_id:r.id,calendar_name:r.name,calendar_color:r.color,is_enabled:!0}));await O.mutateAsync(u),a(!1),N.mutate({})},L=()=>{N.mutate({})};return T?e.jsxs(ss,{children:[e.jsx(as,{children:e.jsx(ts,{className:"font-display text-lg",children:t.googleCalendarSync})}),e.jsx(ns,{children:e.jsx("div",{className:"h-8 w-8 rounded-full border-2 border-primary border-t-transparent animate-spin mx-auto"})})]}):e.jsxs(ss,{children:[e.jsx(as,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ts,{className:"font-display text-lg",children:t.googleCalendarSync}),e.jsx(Ws,{children:t.googleCalendarSyncDescription})]}),e.jsx(se,{variant:h?"default":"secondary",className:"gap-1",children:h?e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-3 w-3"}),t.googleCalendarConnectedStatus]}):e.jsxs(e.Fragment,{children:[e.jsx(_t,{className:"h-3 w-3"}),t.googleCalendarNotConnected]})})]})}),e.jsx(ns,{className:"space-y-4",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{variant:"outline",size:"sm",onClick:B,disabled:P.isPending,className:"gap-1.5",children:P.isPending?t.googleCalendarLoadingCalendars:t.googleCalendarSelectCalendars}),e.jsxs(d,{variant:"outline",size:"sm",onClick:L,disabled:N.isPending||x.length===0,className:"gap-1.5",children:[e.jsx(Ot,{className:`h-3.5 w-3.5 ${N.isPending?"animate-spin":""}`}),N.isPending?t.googleCalendarSyncing:t.googleCalendarSyncNow]})]}),!k&&x.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.filter(u=>u.is_enabled).map(u=>e.jsxs(se,{variant:"outline",className:"gap-1.5",children:[u.calendar_color&&e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:u.calendar_color}}),u.calendar_name]},u.calendar_id))}),k&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-border p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t.googleCalendarSelectCalendarsDesc}),F.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:t.googleCalendarNoCalendars}):e.jsx("div",{className:"space-y-2",children:F.map(u=>e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-md hover:bg-muted/50 transition-colors",children:[e.jsx(vt,{checked:!!A[u.id],onCheckedChange:r=>H(m=>({...m,[u.id]:!!r}))}),u.color&&e.jsx("div",{className:"h-3 w-3 rounded-full flex-shrink-0",style:{backgroundColor:u.color}}),e.jsx("span",{className:"text-sm font-medium",children:u.name}),u.primary&&e.jsx(se,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Primary"})]},u.id))}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(d,{size:"sm",onClick:te,disabled:O.isPending,children:t.save}),e.jsx(d,{size:"sm",variant:"outline",onClick:()=>a(!1),children:t.cancel})]})]})]}),e.jsxs("div",{className:"pt-2 border-t border-border flex items-center gap-2",children:[e.jsxs(d,{variant:"ghost",size:"sm",onClick:()=>$(!0),disabled:R.isPending,className:"gap-1.5 text-destructive hover:text-destructive",children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),t.googleCalendarPurgeEvents]}),e.jsxs(d,{variant:"ghost",size:"sm",onClick:Z,disabled:p.isPending,className:"gap-1.5 text-destructive hover:text-destructive",children:[e.jsx(Ut,{className:"h-3.5 w-3.5"}),t.googleCalendarDisconnectBtn]})]}),e.jsx(je,{open:U,onOpenChange:$,children:e.jsxs(be,{children:[e.jsxs(ve,{children:[e.jsx(_e,{children:t.googleCalendarPurgeEvents}),e.jsx(Ne,{children:t.googleCalendarPurgeEventsConfirm})]}),e.jsxs(Ce,{children:[e.jsx(we,{children:t.cancel}),e.jsx(ls,{onClick:()=>R.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:t.delete})]})]})})]}):e.jsxs(d,{onClick:M,disabled:E.isPending,className:"gap-2",children:[e.jsx(It,{className:"h-4 w-4"}),t.googleCalendarConnectBtn]})})]})}function Ft({onApplyToAll:t}){const{data:h=[],isLoading:T}=Ia(),x=Ea(),E=Oa(),ae=Ha(),{t:p}=rs(),P=i.useRef(null),O=i.useRef(null),[N,R]=i.useState(""),[F,V]=i.useState(""),[A,H]=i.useState(""),[k,a]=i.useState(null),[U,$]=i.useState(null),[M,Z]=i.useState(!1),B=r=>{var j;const m=(j=r.target.files)==null?void 0:j[0];if(m){if(!m.type.startsWith("audio/")){D.error(p.snoozeTrackInvalidFormat??"Please select an audio file (MP3, WAV, etc.)");return}if(m.size>25*1024*1024){D.error(p.snoozeTrackTooLarge??"File must be under 25 MB");return}a(m),N||R(m.name.replace(/\.[^.]+$/,"").replace(/_/g," "))}},te=async()=>
41{if(!(!k||!N.trim())){if(h.length>=5){D.error(p.snoozeTrackLimitReached??"Maximum 5 tracks. Delete one to add another.");return}Z(!0);try{let r;try{const m=URL.createObjectURL(k),j=new Audio(m);await new Promise(G=>{j.onloadedmetadata=()=>{r=Math.round(j.duration),URL.revokeObjectURL(m),G()},j.onerror=()=>{URL.revokeObjectURL(m),G()}})}catch{}await x.mutateAsync({name:N.trim(),artist:F.trim()||void 0,attribution_text:A.trim()||void 0,file:k,is_default:h.length===0,duration_seconds:r}),D.success(p.snoozeTrackUploaded??"Track uploaded"),R(""),V(""),H(""),a(null),P.current&&(P.current.value="")}catch(r){D.error(r.message)}finally{Z(!1)}}},L=r=>{var j;if(U===r.id){(j=O.current)==null||j.pause(),$(null);return}O.current&&O.current.pause();const m=new Audio(Ga(r.file_path));m.onended=()=>$(null),m.play(),O.current=m,$(r.id)},u=r=>{if(!r)return"?:??";const m=Math.floor(r/60),j=r%60;return`${m}:${String(j).padStart(2,"0")}`};return e.jsxs(ss,{children:[e.jsxs(as,{children:[e.jsxs(ts,{className:"font-display text-lg flex items-center gap-2",children:[e.jsx(Vs,{className:"h-5 w-5"})," ",p.snoozeTracksTitle]}),e.jsxs(Ws,{children:[p.snoozeTracksDescription,e.jsxs("a",{href:"https://incompetech.com/music/royalty-free/music.html",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 ml-1 text-primary hover:underline",children:["incompetech.com ",e.jsx(Ua,{className:"h-3 w-3"})]})]})]}),e.jsxs(ns,{className:"space-y-4",children:[T&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.loading}),h.map(r=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/30",children:[e.jsx(d,{variant:"ghost",size:"icon",className:"h-8 w-8 flex-shrink-0",onClick:()=>L(r),children:U===r.id?e.jsx(Et,{className:"h-4 w-4"}):e.jsx(Ra,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:r.name}),r.attribution_text&&e.jsx(Fa,{children:e.jsxs(Va,{children:[e.jsx($a,{asChild:!0,children:e.jsx(Pt,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0 cursor-help"})}),e.jsx(Ba,{className:"max-w-xs whitespace-pre-line text-xs",children:r.attribution_text})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.artist&&e.jsx("span",{children:r.artist}),e.jsx("span",{children:u(r.duration_seconds)})]})]}),r.is_default?e.jsxs(se,{variant:"secondary",className:"text-[10px] gap-1 flex-shrink-0",children:[e.jsx(is,{className:"h-2.5 w-2.5"})," ",p.defaultMember]}):e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 text-[10px] flex-shrink-0",onClick:()=>E.mutate(r.id),children:p.setAsDefault}),e.jsx(d,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive hover:bg-destructive/10 flex-shrink-0",onClick:()=>ae.mutate(r),children:e.jsx(ee,{className:"h-3 w-3"})})]},r.id)),h.length===0&&!T&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.snoozeTracksEmpty}),h.length<5&&e.jsxs("div",{className:"space-y-3 pt-2 border-t border-border",children:[e.jsx(I,{className:"text-sm font-semibold",children:p.snoozeTrackUploadTitle}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(I,{className:"text-xs",children:p.snoozeTrackName}),e.jsx(q,{value:N,onChange:r=>R(r.target.value),placeholder:"Titre",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(I,{className:"text-xs",children:[p.snoozeTrackArtist," ",e.jsx("span",{className:"text-muted-foreground font-normal",children:p.nameOptional})]}),e.jsx(q,{value:F,onChange:r=>V(r.target.value),placeholder:"Artiste",className:"h-8 text-sm"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(I,{className:"text-xs",children:[p.snoozeTrackAttribution," ",e.jsx("span",{className:"text-muted-foreground font-normal",children:p.nameOptional})]}),e.jsx(q,{value:A,onChange:r=>H(r.target.value),placeholder:"Attribution (licence)",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:P,type:"file",accept:"audio/*",onChange:B,className:"hidden"}),e.jsxs(d,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>{var r;return(r=P.current)==null?void 0:r.click()},children:[e.jsx(Nt,{className:"h-3.5 w-3.5"}),k?k.name:p.snoozeTrackChooseFile??"Choose audio file"]}),e.jsxs(d,{size:"sm",className:"gap-1.5",onClick:te,disabled:!k||!N.trim()||M,children:[e.jsx(Vs,{className:"h-3.5 w-3.5"}),M?"...":p.snoozeTrackUploadBtn??"Upload"]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:p.snoozeTracksLimit})]}),t&&e.jsxs(d,{variant:"outline",size:"sm",onClick:()=>{const r=h.find(m=>m.is_default);t((r==null?void 0:r.id)??null)},className:"gap-1.5 mt-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," ",p.applyToAllHabits]})]})]})}let Vt=0;const Ys=()=>`__temp_${++Vt}_${Date.now()}`;function mn(){const{data:t}=Ya(),{data:h=[]}=Wa(),{data:T=[]}=qa(),{data:x=[]}=Ka(),{data:E=[]}
41=Xa(),ae=Za(),p=Ja(),P=Qa(),O=et(),N=st(),R=at(),F=tt(),V=nt(),A=lt(),H=it(),k=rt(),{t:a,language:U,setLanguage:$}=rs(),[M,Z]=i.useState((t==null?void 0:t.default_calendar_id)??""),[B,te]=i.useState((t==null?void 0:t.default_notification_mode)??"audio_popup"),[L,u]=i.useState((t==null?void 0:t.default_notification_timing)??"at_start_time"),[r,m]=i.useState((t==null?void 0:t.default_custom_offset_minutes)??5),[j,G]=i.useState(String((t==null?void 0:t.default_custom_offset_minutes)??5)),[Se,$t]=i.useState((t==null?void 0:t.default_audio_enabled)??!0),[De,Bt]=i.useState((t==null?void 0:t.default_popup_enabled)??!0),[qs]=i.useState(!0),[Te,Ks]=i.useState((t==null?void 0:t.simplified_mode)??!1),[ke,Xs]=i.useState((t==null?void 0:t.browser_notifications_enabled)??!0),[me,Zs]=i.useState((t==null?void 0:t.notification_language)??"en"),[J,Js]=i.useState(U),[X,ne]=i.useState(()=>Je()),[Ae,Me]=i.useState(()=>Qe()),[os,cs]=i.useState(()=>Je()),[Qs,ds]=i.useState(()=>Qe()),[us,ea]=i.useState(!1),[Le,ze]=i.useState(null),Pe=["lang","members","dayTypes","notifLang","notifDefaults","snoozeTracks","browserNotif","googleCal","syncCal","onboarding","layout","simplified","reset"],[b,ms]=i.useState(()=>Object.fromEntries(Pe.map(s=>[s,!1]))),fs=Pe.every(s=>b[s]!==!1),sa=()=>{const s=!fs;ms(Object.fromEntries(Pe.map(n=>[n,s])))},C=s=>ms(n=>({...n,[s]:!n[s]})),[Y,fe]=i.useState([]),[ps,aa]=i.useState(!1),[z,le]=i.useState([]),[ta,na]=i.useState(!1),[Ie,Ee]=i.useState([]),[la,ia]=i.useState(!1),[Oe,hs]=i.useState(""),[pe,xs]=i.useState(""),[gs,He]=i.useState(null),[he,ys]=i.useState(""),[ie,js]=i.useState(!1),[xe,Ue]=i.useState(null),[ge,Re]=i.useState(null),ra=i.useRef(null),[oa,ca]=i.useState(void 0),[bs,vs]=i.useState(!1),[_s,Ns]=i.useState(!1),[Cs,ws]=i.useState(!1),[Fe,Ss]=i.useState({pending:!1,trackId:null}),[Ds,Ts]=i.useState(!1),[re,ks]=i.useState(!1),[g,ye]=i.useState(null),[da,As]=i.useState(!1),[Ms,Ls]=i.useState(1),zs=i.useRef(!1),ua=s=>{const n=s.toLowerCase();return a[n]??s};i.useEffect(()=>{(T.length>0||!ps)&&(!ps||!ie)&&(fe(T.map(s=>({id:s.id,first_name:s.first_name,is_default:s.is_default}))),aa(!0))},[T]),i.useEffect(()=>{(!ta||!ie)&&(le(x.map(s=>({id:s.id,name:s.name}))),na(!0))},[x]),i.useEffect(()=>{(!la||!ie)&&(Ee($s.map(s=>{const n=E.find(l=>l.day_of_week===s);
41return{day_of_week:s,day_type_id:(n==null?void 0:n.day_type_id)??null}})),ia(!0))},[E]),i.useEffect(()=>{G(String(r))},[r]);const Ve=t?M!==((t==null?void 0:t.default_calendar_id)??"")||B!==(t==null?void 0:t.default_notification_mode)||L!==(t==null?void 0:t.default_notification_timing)||r!==((t==null?void 0:t.default_custom_offset_minutes)??5)||Se!==(t==null?void 0:t.default_audio_enabled)||De!==(t==null?void 0:t.default_popup_enabled)||Te!==((t==null?void 0:t.simplified_mode)??!1)||ke!==((t==null?void 0:t.browser_notifications_enabled)??!0)||me!==((t==null?void 0:t.notification_language)??"en")||J!==U:M!==""||J!==U,Ps=Y.length!==T.length?!0:Y.some(s=>{if(s._isNew)return!0;const n=T.find(l=>l.id===s.id);return n?n.first_name!==s.first_name||n.is_default!==s.is_default:!0}),$e=z.length!==x.length?!0:z.some((s,n)=>{if(s._isNew)return!0;const l=x.find(c=>c.id===s.id);return!l||l.name!==s.name?!0:x.findIndex(c=>c.id===s.id)!==n}),Is=Ie.some(s=>{const n=E.find(o=>o.day_of_week===s.day_of_week),l=(n==null?void 0:n.day_type_id)??null;return s.day_type_id!==l}),Q=X.length!==os.length||X.some((s,n)=>s!==os[n])?!0:Ct.some(s=>Ae[s]!==!1!=(Qs[s]!==!1));i.useEffect(()=>{if(us||typeof t>"u"||Q)return;const s=t==null?void 0:t.dashboard_layout_order,n=t==null?void 0:t.dashboard_layout_visible,l=wt(s,n),o=l?St(s):Je(),c=l?Dt(n):Qe();ne(o),cs(o),Me(c),ds(c),ea(!0)},[Q,us,t]);const W=Ve||Ps||$e||Is||Q||bs||_s||Cs||Fe.pending||Ds||re||!!g;i.useEffect(()=>{W&&!zs.current&&D.info(a.pendingApplyMessage),zs.current=W},[W]),i.useEffect(()=>{if(!W)return;const s=n=>{n.preventDefault(),n.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[W]);const Es=()=>{const s=Oe.trim();s&&(fe(n=>[...n,{id:Ys(),first_name:s,is_default:n.length===0,_isNew:!0}]),hs(""))},ma=s=>{fe(n=>n.filter(l=>l.id!==s))},Os=s=>{fe(n=>n.map(l=>({...l,is_default:l.id===s})))},Hs=()=>{const s=pe.trim();s&&(le(n=>[...n,{id:Ys(),name:s,_isNew:!0}]),xs(""))},fa=s=>{Ue(s)},pa=()=>{xe&&(le(s=>s.filter(n=>n.id!==xe)),Ee(s=>s.map(n=>n.day_type_id===xe?{...n,day_type_id:null}:n)),Ue(null))},ha=s=>{Re(s)},xa=(s,n)=>{s.preventDefault(),!(ge===null||ge===n)&&(le(l=>{const o=[...l],[c]=o.splice(ge,1);return o.splice(n,0,c),o}),Re(n))},ga=()=>{Re(null)},Us=(s,n)=>{le(l=>l.map(o=>o.id===s?{...o,name:n}:o))},ya=(s,n)=>{Ee(l=>l.map(o=>o.day_of_week===s?{...o,day_type_id:n}:o))},Rs=async()=>{js(!0);try{const s=At(Ae);if(J!==U&&$(J),(Ve||Q)&&await V.mutateAsync({...Ve?{default_calendar_id:M||null,default_notification_mode:B,default_notification_timing:L,default_custom_offset_minutes:L==="custom"?r:null,default_audio_enabled:Se,default_popup_enabled:De,advanced_mode:qs,simplified_mode:Te,browser_notifications_enabled:ke,notification_language:me,preferred_language:J}:{},...Q?{dashboard_layout_order:X,dashboard_layout_visible:s}:{}}),Ps){const l=T.map(c=>c.id),o=Y.filter(c=>!c._isNew).map(c=>c.id);for(const c of T)o.includes(c.id)||await P.mutateAsync(c.id);for(const c of Y)c._isNew&&await ae.mutateAsync({first_name:c.first_name,is_default:c.is_default});for(const c of Y)if(!c._isNew){const y=T.find(f=>f.id===c.id);y&&(y.first_name!==c.first_name||y.is_default!==c.is_default)&&await p.mutateAsync({id:c.id,first_name:c.first_name,is_default:c.is_default})}}const n=new Map;if($e){const l=z.filter(o=>!o._isNew).map(o=>o.id);for(const o of x)l.includes(o.id)||await R.mutateAsync(o.id);for(let o=0;o<z.length;o++){const c=z[o];if(c._isNew){const y=await O.mutateAsync(c.name);n.set(c.id,y.id),await N.mutateAsync({id:y.id,name:c.name,sort_order:o})}}for(let o=0;o<z.length;o++){const c=z[o];if(!c._isNew){const y=x.find(_=>_.id===c.id),f=x.findIndex(_=>_.id===c.id);y&&(y.name!==c.name||f!==o)&&await N.mutateAsync({id:c.id,name:c.name,sort_order:o})}}}if(Is||$e)for(const l of Ie){const o=E.find(f=>
41f.day_of_week===l.day_of_week),c=(o==null?void 0:o.day_type_id)??null;let y=l.day_type_id;y&&n.has(y)&&(y=n.get(y)),y!==c&&await F.mutateAsync({day_of_week:l.day_of_week,day_type_id:y})}if(bs){const l=h.map(o=>o.id);l.length>0&&await A.mutateAsync({ids:l,updates:{notification_mode:B,notification_timing:L,custom_notification_offset_minutes:L==="custom"?r:null,audio_enabled:Se,popup_enabled:De,use_global_notification_settings:!0}}),vs(!1)}if(_s){const l=Y.find(c=>c.is_default),o=h.map(c=>c.id);o.length>0&&await A.mutateAsync({ids:o,updates:{target_member_id:(l==null?void 0:l.id)??null}}),Ns(!1)}if(Cs){const l=h.map(o=>o.id);l.length>0&&await A.mutateAsync({ids:l,updates:{notification_language:me}}),ws(!1)}if(Fe.pending){const l=h.map(o=>o.id);l.length>0&&await A.mutateAsync({ids:l,updates:{notification_track_id:Fe.trackId}}),Ss({pending:!1,trackId:null})}if(Ds){const l=h.map(o=>o.id);l.length>0&&await A.mutateAsync({ids:l,updates:{calendar_id:M}}),Ts(!1)}if(re&&(await V.mutateAsync({onboarding_completed:!1}),ks(!1)),g){const l=g.mode==="from_date"&&g.fromDate?g.fromDate:void 0;await H.mutateAsync(l),ye(null)}return Q&&(Mt(X,s),cs([...X]),ds(s)),D.success(a.saveSettings),!0}catch(s){return D.error(a.toastError+": "+s.message),!1}finally{js(!1)}},ja=()=>{if(h.map(n=>n.id).length===0)return D.error(a.noHabitsToUpdate);vs(!0)},ba=()=>{if(!M)return D.error(a.enterCalendarFirst);if(h.map(n=>n.id).length===0)return D.error(a.noHabitsToUpdate);Ts(!0)},va=()=>{if(h.map(n=>n.id).length===0)return D.error(a.noHabitsToUpdate);Ns(!0)},_a=()=>{if(h.map(n=>n.id).length===0)return D.error(a.noHabitsToUpdate);ws(!0)},Na=s=>{if(h.map(l=>l.id).length===0)return D.error(a.noHabitsToUpdate);Ss({pending:!0,trackId:s})},Fs=ot(),[Be,oe]=i.useState(null),Ge=i.useRef(W),ce=i.useRef(!1);Ge.current=W;const Ye=i.useCallback(s=>{ce.current=!0,oe(null),s&&s!=="__back__"?Fs(s):s==="__back__"&&history.back()},[Fs]);return i.useEffect(()=>{const s=history.pushState.bind(history),n=function(...o){const c=o[2];if(ce.current)return ce.current=!1,s(...o);if(Ge.current&&c&&typeof c=="string"&&c!==window.location.pathname){oe(c);return}return s(...o)};history.pushState=n;const l=()=>{if(ce.current){ce.current=!1;return}Ge.current&&(history.pushState(null,"",window.location.pathname),oe("__back__"))};return window.addEventListener("popstate",l),()=>{history.pushState=s,window.removeEventListener("popstate",l)}},[Ye]),e.jsxs("div",{className:"space-y-6 max-w-2xl pb-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:a.settingsTitle}),e.jsx("p",{className:"text-muted-foreground mt-1",children:a.settingsDescription})]}),e.jsxs(d,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",onClick:sa,children:[e.jsx(Lt,{className:"h-4 w-4"}),fs?a.collapseAll:a.expandAll]})]}),e.jsx(w,{title:a.language,description:a.languageDescription,open:b.lang!==!1,onToggle:()=>C("lang"),children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ct.map(s=>e.jsxs("button",{onClick:()=>Js(s.value),className:`flex items-center gap-2 p-3 rounded-lg border transition-all text-left text-sm ${J===s.value?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border hover:border-primary/30 hover:bg-muted/50"}`,children:[e.jsx("span",{className:"text-lg",children:s.flag}),e.jsx("span",{className:"font-medium",children:s.label})]},s.value))})}),e.jsxs(w,{title:a.householdMembers,description:a.householdMembersDescription,open:b.members!==!1,onToggle:()=>C("members"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded bg-muted border border-border flex items-center justify-center text-xs font-bold text-muted-foreground flex-shrink-0",children:"â"}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:a.none}),Y.some(s=>s.is_default)?e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 text-[10px]",onClick:()=>Os(null),children:a.setAsDefault}):e.jsxs(se,{variant:"secondary",className:"text-[10px] gap-1",children:[e.jsx(is,{className:"h-2.5 w-2.5"})," ",a.defaultMember]}
41)]}),Y.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded bg-accent border border-accent-foreground/20 flex items-center justify-center text-xs font-bold text-accent-foreground flex-shrink-0",children:s.first_name.slice(0,1).toUpperCase()}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:s.first_name}),s.is_default&&e.jsxs(se,{variant:"secondary",className:"text-[10px] gap-1",children:[e.jsx(is,{className:"h-2.5 w-2.5"})," ",a.defaultMember]}),!s.is_default&&e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 text-[10px]",onClick:()=>Os(s.id),children:a.setAsDefault}),e.jsx(d,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>ma(s.id),children:e.jsx(ee,{className:"h-3 w-3"})})]},s.id)),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(q,{value:Oe,onChange:s=>hs(s.target.value),placeholder:a.memberNamePlaceholder,className:"h-8 text-sm",onKeyDown:s=>s.key==="Enter"&&Es()}),e.jsxs(d,{size:"sm",className:"h-8 gap-1",onClick:Es,disabled:!Oe.trim(),children:[e.jsx(Bs,{className:"h-3.5 w-3.5"})," ",a.addMember]})]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:va,className:"gap-1.5 mt-2",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," ",a.applyToAllHabits]})]}),e.jsxs(w,{title:a.dayTypes,description:a.dayTypesDescription,open:b.dayTypes!==!1,onToggle:()=>C("dayTypes"),children:[z.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a.noDayTypesYet}),z.map((s,n)=>e.jsxs("div",{className:`flex items-center gap-2 ${ge===n?"opacity-50":""}`,draggable:gs!==s.id,onDragStart:()=>ha(n),onDragOver:l=>xa(l,n),onDragEnd:ga,children:[e.jsx(Gs,{className:"h-4 w-4 text-muted-foreground cursor-grab flex-shrink-0"}),gs===s.id?e.jsxs("form",{className:"flex items-center gap-1 flex-1",onSubmit:l=>{l.preventDefault(),Us(s.id,he.trim()),He(null)},children:[e.jsx(q,{ref:ra,value:he,onChange:l=>ys(l.target.value),onBlur:()=>{he.trim()&&Us(s.id,he.trim()),He(null)},className:"h-7 text-sm flex-1",autoFocus:!0}),e.jsx(d,{type:"submit",variant:"ghost",size:"icon",className:"h-6 w-6",children:e.jsx(dt,{className:"h-3.5 w-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm font-medium",children:s.name}),e.jsx(d,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{He(s.id),ys(s.name)},children:e.jsx(xt,{className:"h-3 w-3"})}),e.jsx(d,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>fa(s.id),children:e.jsx(ee,{className:"h-3 w-3"})})]})]},s.id)),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(q,{value:pe,onChange:s=>xs(s.target.value),placeholder:a.dayTypeNamePlaceholder,className:"h-8 text-sm",onKeyDown:s=>s.key==="Enter"&&pe.trim()&&Hs()}),e.jsxs(d,{size:"sm",className:"h-8 gap-1",onClick:Hs,disabled:!pe.trim(),children:[e.jsx(Bs,{className:"h-3.5 w-3.5"})," ",a.addDayType]})]}),z.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border space-y-2",children:[e.jsx(I,{className:"text-sm font-semibold",children:a.dayTypeDefaults}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:a.dayTypeDefaultsDescription}),$s.map(s=>{const n=Ie.find(l=>l.day_of_week===s);return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm w-24 font-medium",children:ua(s)}
41),e.jsxs(qe,{value:(n==null?void 0:n.day_type_id)??"__none__",onValueChange:l=>ya(s,l==="__none__"?null:l),children:[e.jsx(Ke,{className:"h-7 text-xs flex-1",children:e.jsx(Xe,{})}),e.jsxs(Ze,{children:[e.jsx(S,{value:"__none__",children:a.noDayType}),z.map(l=>e.jsx(S,{value:l.id,children:l.name},l.id))]})]})]},s)})]})]}),e.jsxs(w,{title:a.notificationLanguage,description:a.notificationLanguageDescription,open:b.notifLang!==!1,onToggle:()=>C("notifLang"),children:[e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ut.map(s=>e.jsxs("button",{onClick:()=>Zs(s.value),className:`flex items-center gap-2 p-3 rounded-lg border transition-all text-left text-sm ${me===s.value?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border hover:border-primary/30 hover:bg-muted/50"}`,children:[e.jsx("span",{className:"text-lg",children:s.flag}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:s.label}),e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",s.gender==="female"?"â":"â",")"]})]})]},s.value))}),e.jsxs(d,{variant:"outline",size:"sm",onClick:_a,className:"gap-1.5 mt-3",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," ",a.applyToAllHabits]})]}),e.jsxs(w,{title:a.defaultNotifTitle,description:a.defaultNotifDescription,open:b.notifDefaults!==!1,onToggle:()=>C("notifDefaults"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{children:a.notificationMode}),e.jsxs(qe,{value:B,onValueChange:s=>te(s),children:[e.jsx(Ke,{children:e.jsx(Xe,{})}),e.jsxs(Ze,{className:"max-h-[300px]",children:[e.jsx(S,{value:"none",children:a.none}),e.jsx(S,{value:"popup",children:a.popup}),e.jsx(S,{value:"audio",children:a.audio}),e.jsx(S,{value:"music",children:a.music}),e.jsx(S,{value:"audio_popup",children:a.audioPopup}),e.jsx(S,{value:"popup_music",children:a.popupMusic}),e.jsx(S,{value:"audio_music",children:a.audioMusic}),e.jsx(S,{value:"popup_audio_music",children:a.popupAudioMusic})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{children:a.notificationTiming}),e.jsxs(qe,{value:L,onValueChange:s=>u(s),children:[e.jsx(Ke,{children:e.jsx(Xe,{})}),e.jsxs(Ze,{children:[e.jsx(S,{value:"at_start_time",children:a.atStartTime}),e.jsx(S,{value:"1_min_before",children:a.oneMinBefore}),e.jsx(S,{value:"5_min_before",children:a.fiveMinBefore}),e.jsx(S,{value:"custom",children:a.custom})]})]})]}),L==="custom"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(I,{children:a.customOffsetMinutes}),e.jsx(q,{type:"number",min:0,value:j,onChange:s=>{const n=s.target.value;if(G(n),n==="")return;const l=parseInt(n,10);isNaN(l)||m(l)},onFocus:s=>s.target.select(),onBlur:()=>{j===""&&G(String(r))}})]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:ja,className:"gap-1.5",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," ",a.applyToAllHabits]})]}),b.snoozeTracks!==!1&&e.jsx(Ft,{onApplyToAll:Na}),b.snoozeTracks===!1&&e.jsx(w,{title:a.snoozeTracksTitle,description:"",open:!1,onToggle:()=>C("snoozeTracks"),children:e.jsx(e.Fragment,{})}),e.jsx(w,{title:a.browserNotificationsEnabled,description:a.browserNotificationsEnabledDesc,open:b.browserNotif!==!1,onToggle:()=>C("browserNotif"),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{children:a.browserNotificationsEnabled}),e.jsx(We,{checked:ke,onCheckedChange:Xs})]})}),b.googleCal!==!1&&e.jsx(Rt,{}),b.googleCal===!1&&e.jsx(w,{title:a.googleCalendarSync,description:"",open:!1,onToggle:()=>C("googleCal"),children:e.jsx(e.Fragment,{})}),e.jsxs(w,{title:a.defaultCalendarTitle,description:a.defaultCalendarDescription,open:b.syncCal!==!1,onToggle:()=>C("syncCal"),children:[e.jsx(q,{placeholder:a.calendarIdPlaceholder,value:M,onChange:s=>Z(s.target.value)}),e.jsxs(d,{variant:"outline",size:"sm",onClick:ba,className:"gap-1.5",children:[e.jsx(ue,{className:"h-3.5 w-3.5"})," ",a.applyToAllHabits]})]}),e.jsxs(w,{title:a.replayOnboarding,description:a.replayOnboardingDesc,open:b.onboarding!==!1,onToggle:()=>C("onboarding"),children:[e.jsx(d,{variant:re?"default":"outline",size:"sm",onClick:()=>{ks(s=>!s)},children:re?`â ${a.replayOnboarding}`:a.replayOnboarding}),re&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:a.pendingApplyMessage})]}),e.jsx(w,{title:a.dashboardLayout,description:a.dashboardLayoutDesc,open:b.layout!==!1,onToggle:()=>C("layout"),children:(()=>{const s={current:a.sectionCurrent,next:a.sectionNext,"stat-today":a.sectionStatToday,"stat-completed":a.sectionStatCompleted,"stat-remaining":a.sectionStatRemaining,"stat-progress":a.sectionStatProgress,schedule:a.sectionSchedule},n=f=>{f<=0||ne(_=>{const v=[..._];return[v[f-1],v[f]]=[v[f],v[f-1]],v})},l=f=>{f>=X.length-1||ne(_=>{const v=[..._];return[v[f],v[f+1]]=[v[f+1],v[f]],v})},o=f=>ze(f),c=(f,_)=>{f.preventDefault(),!(Le===null||Le===_)&&(ne(v=>{const de=[...v],[Ca]=de.splice(Le,1);return de.splice(_,0,Ca),de}),ze(_))},y=()=>ze(null);return e.jsxs(e.Fragment,{children:[X.map((f,_)=>e.jsxs("div",{className:"flex items-center justify-between py-1",draggable:!0,onDragStart:()=>o(_),onDragOver:v=>c(v,_),onDragEnd:y,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col items-center gap-0",children:[e.jsx("button",{type:"button",onClick:()=>n(_),className:"p-0.5 rounded hover:bg-muted/80 text-muted-foreground hover:text-foreground",children:e.jsx(zt,{className:"h-3 w-3"})}),e.jsx(Gs,{className:"h-4 w-4 text-muted-foreground cursor-grab active:cursor-grabbing"}),e.jsx("button",{type:"button",onClick:()=>l(_),className:"p-0.5 rounded hover:bg-muted/80 text-muted-foreground hover:text-foreground",children:e.jsx(mt,{className:"h-3 w-3"})})]}),e.jsx("span",{className:"text-sm",children:s[f]??f})]}),e.jsx(We,{checked:Ae[f]!==!1,onCheckedChange:v=>{Me(de=>({...de,[f]:v}))}})]},f)),e.jsx(d,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{ne(Tt()),Me(kt())},children:a.dashboardResetLayout})]})})()}),e.jsxs(w,{title:a.simplifiedMode,description:a.simplifiedModeDescription,open:b.simplified!==!1,onToggle:()=>C("simplified"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{children:a.enableSimplifiedMode}),e.jsx(We,{checked:Te,onCheckedChange:Ks})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-line",children:a.simplifiedModeExplanation})]}
41),e.jsxs(w,{title:a.resetStatisticsTitle,description:a.resetStatisticsDescription,open:b.reset!==!1,onToggle:()=>C("reset"),className:"border-destructive/30",titleClassName:"text-destructive",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(d,{variant:(g==null?void 0:g.mode)==="all"?"default":"destructive",size:"sm",className:"gap-1.5",onClick:()=>{(g==null?void 0:g.mode)==="all"?ye(null):ye({mode:"all"})},children:[e.jsx(ee,{className:"h-3.5 w-3.5"})," ",(g==null?void 0:g.mode)==="all"?`â ${a.resetAllStats}`:a.resetAllStats]}),e.jsxs(gt,{children:[e.jsx(yt,{asChild:!0,children:e.jsxs(d,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(ft,{className:"h-3.5 w-3.5"})," ",a.resetFromDate]})}),e.jsx(jt,{className:"w-auto p-0",align:"start",children:e.jsx(bt,{mode:"single",selected:oa,onSelect:s=>{s&&(ca(s),ye({mode:"from_date",fromDate:pt(s,"yyyy-MM-dd")}))},initialFocus:!0})})]})]}),g&&e.jsx("p",{className:"text-xs text-muted-foreground",children:g.mode==="from_date"&&g.fromDate?`${a.pendingApplyMessage} (${a.resetFromDate}: ${g.fromDate})`:a.pendingApplyMessage})]}),e.jsxs(w,{title:a.deleteAllHabits,description:"",open:b.deleteAll!==!1,onToggle:()=>C("deleteAll"),className:"border-destructive/30",titleClassName:"text-destructive",children:[e.jsxs(d,{variant:"destructive",size:"sm",className:"gap-1.5",onClick:()=>As(!0),disabled:h.length===0,children:[e.jsx(ee,{className:"h-3.5 w-3.5"})," ",a.deleteAllHabits]}),h.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.noHabitsYet})]}),W&&e.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 w-full max-w-xl px-4",children:e.jsxs(d,{onClick:Rs,disabled:ie,className:"gap-2 w-full shadow-2xl animate-in fade-in slide-in-from-bottom-2 duration-300",children:[e.jsx(Ht,{className:"h-4 w-4"})," ",ie?"...":a.saveSettings]})}),e.jsx(je,{open:!!xe,onOpenChange:s=>!s&&Ue(null),children:e.jsxs(be,{children:[e.jsxs(ve,{children:[e.jsx(_e,{children:a.confirmDeleteDayType}),e.jsx(Ne,{children:a.confirmDeleteDayTypeDesc})]}),e.jsxs(Ce,{children:[e.jsx(we,{children:a.confirmDeleteCancel}),e.jsx(ls,{onClick:pa,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:a.confirmDeleteConfirm})]})]})}),e.jsx(je,{open:!!Be,onOpenChange:s=>{s||oe(null)},children:e.jsxs(be,{children:[e.jsxs(ve,{children:[e.jsx(_e,{children:a.unsavedChangesTitle}),e.jsx(Ne,{children:a.unsavedChangesDesc})]}),e.jsxs(Ce,{children:[e.jsx(we,{onClick:()=>oe(null),children:a.cancel}),e.jsx(d,{variant:"outline",onClick:()=>{Ye(Be)},children:a.unsavedChangesLeave}),e.jsx(d,{onClick:async()=>{const s=Be;await Rs()&&Ye(s)},children:a.unsavedChangesSave})]})]})}),e.jsx(je,{open:da,onOpenChange:s=>{As(s),s||Ls(1)},children:e.jsxs(be,{children:[e.jsxs(ve,{children:[e.jsxs(_e,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ht,{className:"h-5 w-5"}),a.deleteAllHabits]}),e.jsx(Ne,{asChild:!0,children:Ms===1?e.jsx("div",{className:"space-y-2",children:e.jsx("span",{className:"text-sm",children:a.deleteAllHabitsConfirm.replace("{habitsCount}",String(h.length)).replace("{occurrencesCount}","â")})}):e.jsx("span",{className:"text-sm text-destructive",children:a.deleteAllHabitsFinalConfirm})})]}),e.jsxs(Ce,{children:[e.jsx(we,{children:a.cancel}),Ms===1?e.jsx(d,{variant:"destructive",onClick:()=>Ls(2),children:a.confirmDeleteConfirm}):e.jsx(ls,{onClick:()=>k.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:k.isPending,children:k.isPending?a.deletingAllHabits:a.deleteAllHabits})]})]})})]})}export{mn as default};
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.