@remit/web-client-dist 0.0.665 → 0.0.667
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{BriefPane-aOKdNvGX.js → BriefPane-C6kr88av.js} +1 -1
- package/assets/{CalendarComposePane-D0xRG5-n.js → CalendarComposePane-DtSGBvPp.js} +1 -1
- package/assets/{CalendarComposeSeed-BrPB8uE_.js → CalendarComposeSeed-DREDZc7J.js} +1 -1
- package/assets/{CalendarShell-DAW8td0F.js → CalendarShell-B3DAuDeO.js} +1 -1
- package/assets/{EmptyState-DXY4M8-n.js → EmptyState-B-axoIMw.js} +1 -1
- package/assets/{ErrorState-6GwHh1yf.js → ErrorState-CrDfgkFR.js} +1 -1
- package/assets/{FlaggedPane-D4NmTO77.js → FlaggedPane-D8YdVPkx.js} +1 -1
- package/assets/{FullCompose-Dm3IehS_.js → FullCompose-BetcBIR7.js} +1 -1
- package/assets/{MailListHeader-CbDi7zSJ.js → MailListHeader-B6L3wlep.js} +1 -1
- package/assets/{MailNav-Ab3TBSVG.js → MailNav-By1MlVer.js} +1 -1
- package/assets/{MailShell-DEqqkLHN.js → MailShell-DNGUfNTk.js} +1 -1
- package/assets/{MailViewChrome-DXg5IwXL.js → MailViewChrome-B-TV4RBP.js} +1 -1
- package/assets/{MailboxPane-G9RxaxiN.js → MailboxPane-DetZQ60N.js} +1 -1
- package/assets/{NavMenuButton-8Ks6_ktv.js → NavMenuButton-CBKqZy9O.js} +1 -1
- package/assets/{OnboardingWizard-StrEsYxy.js → OnboardingWizard-CBjuZEOX.js} +1 -1
- package/assets/{OpenCalendarEvent-Gjp6VGX9.js → OpenCalendarEvent-opDW6n_i.js} +1 -1
- package/assets/{OutboxPane-B5xiJ3p-.js → OutboxPane-DlTfX1yL.js} +1 -1
- package/assets/{SignInAgain-ZD_Ut8qM.js → SignInAgain-BHrWwQvs.js} +1 -1
- package/assets/_calendarObjectId-3UVtKpu7.js +1 -0
- package/assets/_mailboxId-CtJpSZe9.js +1 -0
- package/assets/_messageId-BPnY_7yA.js +1 -0
- package/assets/_messageId-Cjj4BDvR.js +1 -0
- package/assets/_messageId-DjxLwuFK.js +1 -0
- package/assets/_outboxMessageId-CoTesP2B.js +1 -0
- package/assets/_recurrenceId-shM8VVM4.js +1 -0
- package/assets/_threadId-4gHSVoeW.js +1 -0
- package/assets/_threadId-BJMzdKrw.js +1 -0
- package/assets/_threadId-CikvHZTQ.js +1 -0
- package/assets/{_view._date-BqrOIzIK.js → _view._date-BSaROJCj.js} +1 -1
- package/assets/{accounts-BEvZgzUX.js → accounts--SZv7R7b.js} +1 -1
- package/assets/{advanced-DhJUMzCF.js → advanced-BdIbkh7d.js} +1 -1
- package/assets/{appearance-DMUCgIUe.js → appearance-DxLD4626.js} +1 -1
- package/assets/{attendee-row-DcG8a4uU.js → attendee-row-ijHCScVe.js} +1 -1
- package/assets/{avatar-CzI5XwyR.js → avatar-CkLBBXYT.js} +1 -1
- package/assets/{bell-off-CZ-sPXwv.js → bell-off-BFfe7sjz.js} +1 -1
- package/assets/{bottom-sheet-CWDNxFUl.js → bottom-sheet-Chb1iAYN.js} +1 -1
- package/assets/brief-CfV-F9vr.js +1 -0
- package/assets/{brief-1H0db3K2.js → brief-DuNMfDF3.js} +1 -1
- package/assets/{bug-DBPiP3R-.js → bug-CcYIlYmo.js} +1 -1
- package/assets/{calendar-BMHLVTZQ.js → calendar-DRounzbS.js} +1 -1
- package/assets/{calendar-clash-strip-eOS4W7xA.js → calendar-clash-strip-CL_bKWfx.js} +1 -1
- package/assets/{calendar-format-BtVljxcO.js → calendar-format-DDfQBsqj.js} +1 -1
- package/assets/{calendar-report-4EJstR1X.js → calendar-report-DkjUWaq6.js} +1 -1
- package/assets/{calendar-suggestion-uqLeHU61.js → calendar-suggestion-CPMx3k0K.js} +1 -1
- package/assets/{calendars-DJUIOtAQ.js → calendars-CtNRv7sF.js} +1 -1
- package/assets/{card-CaHW2WeM.js → card-Bp-Ja8fj.js} +1 -1
- package/assets/{checkbox-I6P2xfr2.js → checkbox-CJc7QORM.js} +1 -1
- package/assets/chevron-left-BTzXgOUQ.js +1 -0
- package/assets/{circle-check-ByfNxBHR.js → circle-check-CcoIpvQ_.js} +1 -1
- package/assets/{circle-check-big-COa4dwsT.js → circle-check-big-C9xTaA4P.js} +1 -1
- package/assets/{circle-help-RE_HYzRb.js → circle-help-DDApoxTL.js} +1 -1
- package/assets/{clock-BYTnXKKp.js → clock-lLbtLAj5.js} +1 -1
- package/assets/compose._-_outboxMessageId_-Bi7q512F.js +1 -0
- package/assets/compose._-_outboxMessageId_-Bo3U4X72.js +1 -0
- package/assets/compose._-_outboxMessageId_-Ck7RazXr.js +1 -0
- package/assets/compose._-_outboxMessageId_-DdBqlpfQ.js +1 -0
- package/assets/{config-import-BfBn5l8g.js → config-import-DKzJGH-7.js} +1 -1
- package/assets/{confirm-dialog-dQY3mYWn.js → confirm-dialog-D9AgcZxD.js} +1 -1
- package/assets/{copy-Czmag9mk.js → copy-BFgUggrf.js} +1 -1
- package/assets/{credential-steps-CYrhIOer.js → credential-steps-CKq4EWVz.js} +1 -1
- package/assets/{download-BMhhKtVE.js → download-Qt-1Y4vU.js} +1 -1
- package/assets/{external-link-B4mtsWr3.js → external-link-Dl3PijIO.js} +1 -1
- package/assets/{file-json-Dhb2_x5Z.js → file-json--TlnFOkP.js} +1 -1
- package/assets/{filters-zt1-nVzY.js → filters-Z-r7pQtH.js} +1 -1
- package/assets/{flagged-6bS5xT1C.js → flagged-t5toTOsJ.js} +1 -1
- package/assets/flagged-z41jk9RD.js +1 -0
- package/assets/{folders-C824TnCU.js → folders-DAshtthG.js} +1 -1
- package/assets/{help-copy-DM4zdazN.js → help-copy-9AIAlHQo.js} +1 -1
- package/assets/{import-DlXOp_6l.js → import-DxEgeMyn.js} +1 -1
- package/assets/index-BL4lqNEw.js +1 -0
- package/assets/index-BPnY_7yA.js +1 -0
- package/assets/index-BbUoDj_5.js +1 -0
- package/assets/{index-F-xNWUc6.js → index-CaCj74wE.js} +1 -1
- package/assets/index-Cjj4BDvR.js +1 -0
- package/assets/index-D2MyGqQx.js +1 -0
- package/assets/{index-BulukkDG.js → index-DEjCMX0x.js} +4 -4
- package/assets/index-DbobW_8t.js +1 -0
- package/assets/{index-DmcPZs2v.js → index-DkIInRxS.js} +3 -3
- package/assets/index-Dv5KQbmQ.js +1 -0
- package/assets/index-YkJ9FpVc.js +1 -0
- package/assets/index-neOHYlGP.js +1 -0
- package/assets/{kbd-BgVYMJ9_.js → kbd-Dq56-T4Y.js} +1 -1
- package/assets/{labels-DUvkLBaj.js → labels-jpVXrSYu.js} +1 -1
- package/assets/{mail-DCZKjaOV.js → mail-C03fYYVJ.js} +1 -1
- package/assets/{mail-C32ojLi1.js → mail-DuMqdg7u.js} +1 -1
- package/assets/{map-pin-o6X892ZK.js → map-pin-Cs0ZHucC.js} +1 -1
- package/assets/{menu-B5-6_Cbe.js → menu-CD9_BviG.js} +1 -1
- package/assets/minus-kM-BvDQ2.js +1 -0
- package/assets/{new-BEmbgxpI.js → new-C9zZd_kY.js} +1 -1
- package/assets/{onboarding-completion-DDrxEczB.js → onboarding-completion-C4RR2ROq.js} +1 -1
- package/assets/onboarding-yORCfk_Z.js +1 -0
- package/assets/outbox-AmvYaVXm.js +1 -0
- package/assets/{pencil-B3c463nz.js → pencil-DxRBYL9w.js} +1 -1
- package/assets/{popover-menu-2qZ1GDOR.js → popover-menu-Bq-bl8zD.js} +1 -1
- package/assets/{refresh-cw-K06PujGj.js → refresh-cw-BPtJoQNb.js} +1 -1
- package/assets/{result-count-CWfvWsh3.js → result-count-k8zBfrNM.js} +1 -1
- package/assets/{rich-text-CFkkgFUv.js → rich-text-DeDPq8jc.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-CloFz0xt.js → rich-text-spellcheck-worker-provider-C6ul0AYW.js} +1 -1
- package/assets/{rotate-ccw-D94p3i_k.js → rotate-ccw-CYTCnHiu.js} +1 -1
- package/assets/{roving-focus-Cv0B315X.js → roving-focus-CpZ-vl1X.js} +1 -1
- package/assets/{row-actions-CYbWRx-Y.js → row-actions-biT_W_cq.js} +1 -1
- package/assets/{search-mirror-JXCsVfqM.js → search-mirror-DpTqMnCW.js} +1 -1
- package/assets/{search-query-B_q35euE.js → search-query-CS_x1E6a.js} +1 -1
- package/assets/{search-token-index-IxP4_SoE.js → search-token-index-B7mIWAbK.js} +1 -1
- package/assets/{sections-DQMnMdTX.js → sections-7lDa8HkJ.js} +1 -1
- package/assets/{senders-YrBqR_LL.js → senders-DX_ght2e.js} +1 -1
- package/assets/settings-CJ5Eu6Xf.js +1 -0
- package/assets/{settings-screen-BhcFqgyX.js → settings-screen-Ddd8IWZJ.js} +1 -1
- package/assets/{shield-check-4MK61sTA.js → shield-check-t24O3Jd3.js} +1 -1
- package/assets/{suggested-vips-D4J-VPl-.js → suggested-vips-ocWPBDTu.js} +1 -1
- package/assets/{suggestion._suggestionId-D706bJI-.js → suggestion._suggestionId-DK3xpITa.js} +1 -1
- package/assets/{undo-2-35Kpu1a5.js → undo-2-QhBYFgj8.js} +1 -1
- package/assets/{useCalendarData-D9ulGY91.js → useCalendarData-KC5YSBOE.js} +1 -1
- package/assets/{useCalendarFreeBusy-Dn7JLfB_.js → useCalendarFreeBusy-BoXLNCOd.js} +1 -1
- package/assets/{useCalendarWrites-D68OaZpz.js → useCalendarWrites-CF_QeOCW.js} +1 -1
- package/assets/{useCalendars-IZDEajvg.js → useCalendars-D2WfLVhR.js} +1 -1
- package/assets/{useDebouncedValue-ClVnU0sN.js → useDebouncedValue-fwzOS98D.js} +1 -1
- package/assets/{useFilters-DN4Qw5hY.js → useFilters-zqsEoTVH.js} +1 -1
- package/assets/{useLabels-BUc_2Eeb.js → useLabels-BqCJQg9Y.js} +1 -1
- package/assets/{useLayoutTier-ETG7UwOs.js → useLayoutTier-D8E34D0y.js} +1 -1
- package/assets/{useMessageBodyContent-SxJaTf8j.js → useMessageBodyContent-CR91yAv-.js} +1 -1
- package/assets/{useQueries-NnHi7Zqv.js → useQueries-CrA4N7UM.js} +1 -1
- package/assets/{useRefreshControl-BWf5Xt9_.js → useRefreshControl-AnOITG6_.js} +1 -1
- package/assets/{useResultFolderIndex-61g5vMVy.js → useResultFolderIndex-DGNj06KN.js} +1 -1
- package/assets/{useSearchTokenContext-BIb7Yhy8.js → useSearchTokenContext-CpseqdIz.js} +1 -1
- package/assets/{useSignature-DCMqEJ8s.js → useSignature-BHeuotO6.js} +1 -1
- package/assets/{warnings-DC60vLG-.js → warnings-DxbZARvO.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/_calendarObjectId-Bb5UIUae.js +0 -1
- package/assets/_mailboxId-B-okfzig.js +0 -1
- package/assets/_messageId-05c7AjVW.js +0 -1
- package/assets/_messageId-GRxJ-LGQ.js +0 -1
- package/assets/_messageId-zW7A1P09.js +0 -1
- package/assets/_outboxMessageId-ByQGeXfX.js +0 -1
- package/assets/_recurrenceId-C0So527o.js +0 -1
- package/assets/_threadId-CE6m0Yyz.js +0 -1
- package/assets/_threadId-CN4gHy2C.js +0 -1
- package/assets/_threadId-DxPX4TdY.js +0 -1
- package/assets/brief-BHc2YM6t.js +0 -1
- package/assets/chevron-left-DhPaULbj.js +0 -1
- package/assets/compose._-_outboxMessageId_-Bd7yy5dA.js +0 -1
- package/assets/compose._-_outboxMessageId_-Bpcg5a3L.js +0 -1
- package/assets/compose._-_outboxMessageId_-CmmluWup.js +0 -1
- package/assets/compose._-_outboxMessageId_-Dr61_DfQ.js +0 -1
- package/assets/flagged-JPIWa_he.js +0 -1
- package/assets/index-05c7AjVW.js +0 -1
- package/assets/index-BJD2Hwpa.js +0 -1
- package/assets/index-B_79zGYb.js +0 -1
- package/assets/index-CDj4fP2z.js +0 -1
- package/assets/index-CaxqHEyO.js +0 -1
- package/assets/index-DSxWRT_C.js +0 -1
- package/assets/index-GRxJ-LGQ.js +0 -1
- package/assets/index-SeKsMeoc.js +0 -1
- package/assets/index-wccscUeV.js +0 -1
- package/assets/minus-BEJ76nlq.js +0 -1
- package/assets/onboarding-CIBUtKxi.js +0 -1
- package/assets/outbox-fC_9PSgA.js +0 -1
- package/assets/settings-DGZLiU2M.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,L as Mt,e$ as Ue,f0 as ne,ec as re,r as a,c as Ke,G as ie,bm as jt,cX as kt,N as Et,e3 as Ot,f1 as Ft,f2 as At,a1 as $e,ew as Nt,f3 as Bt,al as Lt,d7 as qt,d8 as Dt}from"./index-DmcPZs2v.js";import{g as Ye,e as Pt,f as Ve,u as _t,p as Qt,R as zt}from"./useSearchTokenContext-BIb7Yhy8.js";import{a7 as Wt,z as Ht,B as Gt,an as Ut,ao as Kt,ap as $t,aq as De,ar as Yt,as as Vt,at as Jt,au as Zt,av as Xt,ai as es,M as ts,aw as ss,aj as os,ax as ns,ay as rs,d as as,o as is,al as cs,l as ls,S as ds,I as us,N as Pe,L as fs,J as ms,b as hs,X as gs,Y as xe,Z as ps,$ as Je,a0 as Ze,a1 as xs,a2 as Is,a3 as ys}from"./MailListHeader-CbDi7zSJ.js";import{S as vs,u as bs}from"./useLayoutTier-ETG7UwOs.js";import{u as Ss,a as Ts,R as Cs,b as ws,c as Rs}from"./useRefreshControl-BWf5Xt9_.js";import{u as ae}from"./useQueries-NnHi7Zqv.js";import{t as Xe,s as Ms,r as js,L as ks}from"./result-count-CWfvWsh3.js";import{a as Es}from"./useLabels-BUc_2Eeb.js";import{d as Os,w as Fs}from"./wizard-selection-zWa1qc6-.js";import{m as As,e as Ns,f as Bs}from"./search-token-index-IxP4_SoE.js";import{u as et}from"./sections-DQMnMdTX.js";import{R as Ls}from"./refresh-cw-K06PujGj.js";import{a as qs}from"./useMessageBodyContent-SxJaTf8j.js";function Ds({sync:e}){return e?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[r.jsx(Mt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:Ps(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(vs,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ps({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const tt=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],st="category",_s={unclassified:"uncategorized"},H=e=>Pt(e).map(t=>t.raw),W=e=>e.join(" "),Ie=e=>{const t=Ve(e);if(t)return tt.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ye=e=>{const t=Ve(e);if(!t||t.name!==st)return;const s=t.value.toLowerCase(),n=_s[s];if(n)return n;if(!(!Ue(s)||s==="all"))return s},ot=e=>tt.find(t=>t.id===e),nt=e=>ot(e)!==void 0,Qs=e=>{const t=new Set;for(const s of H(e)){const n=Ie(s);n&&t.add(n)}return t},zs=e=>{let t="all";for(const s of H(e)){const n=ye(s);n&&(t=n)}return t},Ws=(e,t)=>{const s=ot(t);if(!s)return;const n=H(e),i=n.filter(d=>Ie(d)!==t);return i.length<n.length?W(i):W([...n,Ye(s.name,s.value)])},Hs=(e,t)=>{const s=H(e).filter(n=>!ye(n));return W(t==="all"?s:[...s,Ye(st,t)])},Gs=e=>W(H(e).filter(t=>!Ie(t)&&!ye(t))),rt=e=>e.trim().length>0,_e=e=>{if(!rt(e.query))return e.ownFilters;const t=new Set(Qs(e.query));for(const s of e.ownFilters)nt(s)||t.add(s);return t},Qe=e=>rt(e.query)?zs(e.query):e.ownCategory,ze=6e4,Us=3e4,Ks={kind:"unknown"},We=e=>(t,s)=>Wt(s?.queryKey,e)?t:void 0,$s=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),Ys=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),He=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function Vs({categories:e,criteria:t,limit:s,counted:n}){const i=ae({queries:e.map(c=>{const h=$s(t,c,s),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:We(u),staleTime:ze}})}),d=ae({queries:e.map(c=>{const h=Ys(t,c),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:n,placeholderData:We(u),staleTime:ze}})}),m=a.useMemo(()=>e.map((c,h)=>{const u=i[h],v=d[h],p=u?.data?.items??[];return{category:c,rows:p,atCap:p.length>=s,total:n?Xe(v?.data?.count):Ks,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ke({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Us});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?Xe(n[d]?.data?.count):Xs,failed:s?n[d]?.isError??!1:!1})),[t,n,s])}const so=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),oo=e=>[...e].sort(so),no=["from","subject","category","unread","starred","attachments"],at=["contacts","today"],ro=e=>new Set(at.filter(t=>e.has(t))),ao=(e,t,s,n)=>{const i=Ht({category:e,attributes:t}),{params:d,residual:m}=Gt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ge=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=et();return r.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[r.jsx($e,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},go=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),n=js(s.map(d=>d.accountId));if(n.restriction)return n;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:n.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:n.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function po({header:e,rows:t,wizard:s,children:n}){const{selectedIds:i,selectedCount:d,exitSelection:m,orderedIds:l,allSelected:c,toggleAllLoaded:h}=rs(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=as(u.accountId),{labels:p}=Es(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Fs(t,i),[t,i]),x=is(v,u.mailboxId),S=a.useMemo(()=>l.length>0?{checked:c,indeterminate:d>0&&!c,onChange:h}:void 0,[l.length,c,d,h]),A=u.moveDisabledHint?{tone:"warning",text:u.moveDisabledHint}:void 0,T=R=>r.jsx(ds,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:m,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:u.accountId&&u.mailboxId&&d>0&&p.length>0?r.jsx(ks,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:A});return r.jsx(cs,{...e,selectionBar:T,paneOverlay:r.jsx(ls,{verb:s.verb,accountId:u.accountId,mailboxId:u.mailboxId,selection:L,selectionRestriction:u.restriction,onFinished:m}),children:n})}function xo({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:n,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:m,searchInput:l,resultFolderIndex:c,onSearchChange:h}=ie(),u=_t(),v=jt(),p=bs(),b=kt(),L=As(),x=a.useMemo(()=>oo(e.filter(o=>!o.muted?.value)),[e]),[S,A]=a.useState("all"),[T,R]=a.useState("all"),[N,q]=a.useState(new Set),[le,M]=a.useState(!1),D=a.useCallback(o=>{q(f=>{const g=new Set(f);return g.has(o)?g.delete(o):g.add(o),g})},[]),G=a.useCallback(()=>q(new Set),[]),E=l.trim().length>0,{freeText:w,tokens:P}=Qt(m.trim().toLowerCase(),u),y=w.length>0,_=a.useMemo(()=>_e({query:l,ownFilters:N}),[l,N]),Q=a.useMemo(()=>Qe({query:l,ownCategory:T}),[l,T]),F=a.useMemo(()=>_e({query:m,ownFilters:N}),[m,N]),C=a.useMemo(()=>Qe({query:m,ownCategory:T}),[m,T]),I=a.useCallback(o=>{if(!E||!nt(o)){D(o);return}const f=Ws(l,o);f!==void 0&&h(f)},[E,l,h,D]),j=a.useCallback(o=>{if(!E){R(o);return}h(Hs(l,o))},[E,l,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{Ue(o)&&j(o)}:void 0,[C,y,j]),ue=a.useCallback(()=>{R("all"),A("all"),G(),E&&h(Gs(l))},[E,l,h,G]),U=ae({queries:x.map(o=>({...Et({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),K=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(U[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,U]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=U[f];return g?.isError?!Ot(g.error):!1}),[x,U]),{criteria:fe,residual:$}=a.useMemo(()=>ao(C,F,P,S==="all"?void 0:S),[C,F,P,S]),dt=a.useMemo(()=>C==="all"?[...Ut]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:$,attributes:F}),{sections:Y,isLoading:ut,isError:ft,refetch:Se}=Vs({categories:y?mo:dt,criteria:fe,limit:C==="all"?ns:uo,counted:be}),{rows:Te,isLoading:mt,isError:ht,refetch:Ce}=Js(ve,fo,y),me=y?mt:ut,we=y?ht:ft,Re=a.useCallback(()=>{if(y){Ce();return}Se()},[y,Ce,Se]),Me=a.useMemo(()=>ro(F),[F]),V=a.useCallback(o=>Os(o).map(Kt).filter(f=>Ft(f,Me)&&$t(f,$)),[Me,$]),J=a.useMemo(()=>Y.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:V(o.rows)})),[Y,V]),Z=a.useMemo(()=>V(Te),[Te,V]),gt=a.useCallback(o=>{Y.find(f=>f.category===o)?.retry()},[Y]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>At(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&Ms({hasSearchQuery:y,freeText:w,residualTokenCount:$.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const f=k.map(O=>De(O,c)),{spam:g}=Yt(f),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=lo(je,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[k,w,c,je]),ke=a.useMemo(()=>{const o=f=>he===void 0?f:f.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:Vt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:K.get(o.accountId),active:S===o.accountId}))],[x,K,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(K.values()).reduce((o,f)=>o+f,0),[K]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Ss(),{state:Fe,errorMessage:Ae,refresh:Ne}=Ts(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(Cs,{state:Fe,onRefresh:Ne,label:"Refresh daily brief",errorMessage:Ae,hasUpdate:Oe(pe)}),[Fe,Ne,Ae,Oe,pe]),vt=a.useMemo(()=>k.map(o=>De(o,c)),[k,c]),bt=a.useMemo(()=>{const o=Jt(ge.map(f=>({id:f.id,label:f.label,count:f.count,active:f.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:_,expanded:le,onExpandedChange:M,onSelectCategory:f=>j(f),onSelectSource:A,onToggleFilter:f=>I(f),onClear:ue}},[ge,z,Q,_,le,I,j,ue]),Be=ke.length===0&&S==="all"&&w.length===0&&P.length===0,St=a.useMemo(()=>x.map(o=>o.accountId),[x]),Tt=a.useMemo(()=>x.some(o=>ws(o.syncPhase)),[x]),ee=Rs(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ge,{}),r.jsx(Ge,{})]}),qe=!me&&!we&&!Be,Ct=Zt({tier:p,hasLiveInput:E,hasCommittedQuery:m.trim().length>0,bodyRendersCommittedResults:!0}),wt=qe?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&r.jsx(Xt,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,m)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(es,{sections:ke,briefCategory:Q,Row:ts,selectedThreadId:t,onSelectThread:Ee,onShowAllSection:de,onRetrySection:gt,flat:y,onSelectBriefCategory:j,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:A,activeFilters:_,onToggleFilter:I,onClearFilters:ue})})]}):me?Le:we?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx($e,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>Re(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(Ls,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?r.jsx(Ds,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Le;return r.jsx(Nt,{hasSheet:qe&&!Ct,children:r.jsx(ss,{selectedMessageId:t,rows:k,onOpen:Ee,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:n,onTriageContextChange:i,children:r.jsx(po,{wizard:b,header:{title:"Daily brief",unreadCount:It,footer:v?r.jsx(os,{}):void 0,searchFilter:bt,searchResults:vt,searchLoading:me,onSelectSearchResult:xt,spamOffer:X,searchResultsInBody:!0,refreshControl:yt},rows:k,children:r.jsxs("div",{className:"flex h-full flex-col",children:[lt.map(o=>r.jsx(ho,{accountEmail:o.email,accountId:o.accountId},o.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:wt})]})})})})}const it=a.createContext(null);function ce(){const e=a.useContext(it);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Io({thread:e,children:t}){const s=Ns(),n=Bs(),i=et(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ke({...Bt(),staleTime:6e4}),h=a.useMemo(()=>c?.items??[],[c]),u=a.useMemo(()=>{if(m)return h.find(I=>I.messageId===l)??h.find(I=>I.threadId===m)},[h,m,l]),v=us(m,l),p=u??v,b=l??p?.messageId,L=a.useMemo(()=>{if(m)return{threadId:m,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[m,p,b]),x=a.useCallback((I,j)=>{s(I,{replace:j?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&n()},[b,n]),A=Pe({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=fs(),{deleteMessages:R}=ms({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=hs({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,M=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,D=Pe({thread:M,isOpen:M?.messageId===b}),G=qs(),E=Lt(),w=qt(),P=a.useMemo(()=>Dt(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:_,previousMessageId:Q}=gs({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!G&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||D.deleteThread()},toggleStar:D.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||M&&N([M.messageId],!M.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),F=a.useCallback(I=>{if(!I)return;const j=h.find(de=>de.messageId===I);return j?{threadId:j.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:n,nextThread:F(_),previousThread:F(Q),actions:A,onReply:P,triage:T,onDeleteMessages:R,handleDeselectIfRemoved:S};return r.jsx(it.Provider,{value:C,children:t})}function ct(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:n}=ce(),{accounts:i}=ie();return r.jsx(xo,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function yo(){const e=xe(),{conversation:t,selectedThread:s,actions:n,onReply:i,handleDeselectIfRemoved:d,onOpenThread:m}=ce(),l=!!t,c=Is(t?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(ys,{hasThread:l,intelligenceOpen:c.isShowing,canToggleIntelligence:c.canToggle,onToggleIntelligence:c.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?r.jsx(Je,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(zt,{})})]}),r.jsx(Ze,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e,onOpenThread:m})]})}function vo(){const e=xe(),{selectedThread:t,handleDeselectIfRemoved:s,onOpenThread:n}=ce(),{onToggleIntelligence:i}=ie();return r.jsx(xs,{onClose:i,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e,onOpenThread:n})}function bo(){const e=xe(),{selectedThread:t,conversation:s,onOpenThread:n,onCloseThread:i,nextThread:d,previousThread:m,handleDeselectIfRemoved:l}=ce(),c=ps(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Je,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:c.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:m?()=>n(m):void 0,mobileIntelligenceOpen:c.isOpen}),r.jsx(Ze,{isOpen:c.isOpen,onClose:c.close,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:l,onReplyWithText:e,onOpenThread:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ct,{})})}const Bo=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{Bo as B};
|
|
1
|
+
import{j as r,L as Mt,e$ as Ue,f0 as ne,ec as re,r as a,c as Ke,G as ie,bm as jt,cX as kt,N as Et,e3 as Ot,f1 as Ft,f2 as At,a1 as $e,ew as Nt,f3 as Bt,al as Lt,d7 as qt,d8 as Dt}from"./index-DkIInRxS.js";import{g as Ye,e as Pt,f as Ve,u as _t,p as Qt,R as zt}from"./useSearchTokenContext-CpseqdIz.js";import{a7 as Wt,z as Ht,B as Gt,an as Ut,ao as Kt,ap as $t,aq as De,ar as Yt,as as Vt,at as Jt,au as Zt,av as Xt,ai as es,M as ts,aw as ss,aj as os,ax as ns,ay as rs,d as as,o as is,al as cs,l as ls,S as ds,I as us,N as Pe,L as fs,J as ms,b as hs,X as gs,Y as xe,Z as ps,$ as Je,a0 as Ze,a1 as xs,a2 as Is,a3 as ys}from"./MailListHeader-B6L3wlep.js";import{S as vs,u as bs}from"./useLayoutTier-D8E34D0y.js";import{u as Ss,a as Ts,R as Cs,b as ws,c as Rs}from"./useRefreshControl-AnOITG6_.js";import{u as ae}from"./useQueries-CrA4N7UM.js";import{t as Xe,s as Ms,r as js,L as ks}from"./result-count-k8zBfrNM.js";import{a as Es}from"./useLabels-BqCJQg9Y.js";import{d as Os,w as Fs}from"./wizard-selection-zWa1qc6-.js";import{m as As,e as Ns,f as Bs}from"./search-token-index-B7mIWAbK.js";import{u as et}from"./sections-7lDa8HkJ.js";import{R as Ls}from"./refresh-cw-BPtJoQNb.js";import{a as qs}from"./useMessageBodyContent-CR91yAv-.js";function Ds({sync:e}){return e?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[r.jsx(Mt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:Ps(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(vs,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ps({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const tt=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],st="category",_s={unclassified:"uncategorized"},H=e=>Pt(e).map(t=>t.raw),W=e=>e.join(" "),Ie=e=>{const t=Ve(e);if(t)return tt.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ye=e=>{const t=Ve(e);if(!t||t.name!==st)return;const s=t.value.toLowerCase(),n=_s[s];if(n)return n;if(!(!Ue(s)||s==="all"))return s},ot=e=>tt.find(t=>t.id===e),nt=e=>ot(e)!==void 0,Qs=e=>{const t=new Set;for(const s of H(e)){const n=Ie(s);n&&t.add(n)}return t},zs=e=>{let t="all";for(const s of H(e)){const n=ye(s);n&&(t=n)}return t},Ws=(e,t)=>{const s=ot(t);if(!s)return;const n=H(e),i=n.filter(d=>Ie(d)!==t);return i.length<n.length?W(i):W([...n,Ye(s.name,s.value)])},Hs=(e,t)=>{const s=H(e).filter(n=>!ye(n));return W(t==="all"?s:[...s,Ye(st,t)])},Gs=e=>W(H(e).filter(t=>!Ie(t)&&!ye(t))),rt=e=>e.trim().length>0,_e=e=>{if(!rt(e.query))return e.ownFilters;const t=new Set(Qs(e.query));for(const s of e.ownFilters)nt(s)||t.add(s);return t},Qe=e=>rt(e.query)?zs(e.query):e.ownCategory,ze=6e4,Us=3e4,Ks={kind:"unknown"},We=e=>(t,s)=>Wt(s?.queryKey,e)?t:void 0,$s=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),Ys=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),He=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function Vs({categories:e,criteria:t,limit:s,counted:n}){const i=ae({queries:e.map(c=>{const h=$s(t,c,s),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:We(u),staleTime:ze}})}),d=ae({queries:e.map(c=>{const h=Ys(t,c),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:n,placeholderData:We(u),staleTime:ze}})}),m=a.useMemo(()=>e.map((c,h)=>{const u=i[h],v=d[h],p=u?.data?.items??[];return{category:c,rows:p,atCap:p.length>=s,total:n?Xe(v?.data?.count):Ks,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ke({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Us});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?Xe(n[d]?.data?.count):Xs,failed:s?n[d]?.isError??!1:!1})),[t,n,s])}const so=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),oo=e=>[...e].sort(so),no=["from","subject","category","unread","starred","attachments"],at=["contacts","today"],ro=e=>new Set(at.filter(t=>e.has(t))),ao=(e,t,s,n)=>{const i=Ht({category:e,attributes:t}),{params:d,residual:m}=Gt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ge=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=et();return r.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[r.jsx($e,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},go=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),n=js(s.map(d=>d.accountId));if(n.restriction)return n;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:n.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:n.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function po({header:e,rows:t,wizard:s,children:n}){const{selectedIds:i,selectedCount:d,exitSelection:m,orderedIds:l,allSelected:c,toggleAllLoaded:h}=rs(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=as(u.accountId),{labels:p}=Es(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Fs(t,i),[t,i]),x=is(v,u.mailboxId),S=a.useMemo(()=>l.length>0?{checked:c,indeterminate:d>0&&!c,onChange:h}:void 0,[l.length,c,d,h]),A=u.moveDisabledHint?{tone:"warning",text:u.moveDisabledHint}:void 0,T=R=>r.jsx(ds,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:m,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:u.accountId&&u.mailboxId&&d>0&&p.length>0?r.jsx(ks,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:A});return r.jsx(cs,{...e,selectionBar:T,paneOverlay:r.jsx(ls,{verb:s.verb,accountId:u.accountId,mailboxId:u.mailboxId,selection:L,selectionRestriction:u.restriction,onFinished:m}),children:n})}function xo({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:n,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:m,searchInput:l,resultFolderIndex:c,onSearchChange:h}=ie(),u=_t(),v=jt(),p=bs(),b=kt(),L=As(),x=a.useMemo(()=>oo(e.filter(o=>!o.muted?.value)),[e]),[S,A]=a.useState("all"),[T,R]=a.useState("all"),[N,q]=a.useState(new Set),[le,M]=a.useState(!1),D=a.useCallback(o=>{q(f=>{const g=new Set(f);return g.has(o)?g.delete(o):g.add(o),g})},[]),G=a.useCallback(()=>q(new Set),[]),E=l.trim().length>0,{freeText:w,tokens:P}=Qt(m.trim().toLowerCase(),u),y=w.length>0,_=a.useMemo(()=>_e({query:l,ownFilters:N}),[l,N]),Q=a.useMemo(()=>Qe({query:l,ownCategory:T}),[l,T]),F=a.useMemo(()=>_e({query:m,ownFilters:N}),[m,N]),C=a.useMemo(()=>Qe({query:m,ownCategory:T}),[m,T]),I=a.useCallback(o=>{if(!E||!nt(o)){D(o);return}const f=Ws(l,o);f!==void 0&&h(f)},[E,l,h,D]),j=a.useCallback(o=>{if(!E){R(o);return}h(Hs(l,o))},[E,l,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{Ue(o)&&j(o)}:void 0,[C,y,j]),ue=a.useCallback(()=>{R("all"),A("all"),G(),E&&h(Gs(l))},[E,l,h,G]),U=ae({queries:x.map(o=>({...Et({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),K=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(U[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,U]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=U[f];return g?.isError?!Ot(g.error):!1}),[x,U]),{criteria:fe,residual:$}=a.useMemo(()=>ao(C,F,P,S==="all"?void 0:S),[C,F,P,S]),dt=a.useMemo(()=>C==="all"?[...Ut]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:$,attributes:F}),{sections:Y,isLoading:ut,isError:ft,refetch:Se}=Vs({categories:y?mo:dt,criteria:fe,limit:C==="all"?ns:uo,counted:be}),{rows:Te,isLoading:mt,isError:ht,refetch:Ce}=Js(ve,fo,y),me=y?mt:ut,we=y?ht:ft,Re=a.useCallback(()=>{if(y){Ce();return}Se()},[y,Ce,Se]),Me=a.useMemo(()=>ro(F),[F]),V=a.useCallback(o=>Os(o).map(Kt).filter(f=>Ft(f,Me)&&$t(f,$)),[Me,$]),J=a.useMemo(()=>Y.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:V(o.rows)})),[Y,V]),Z=a.useMemo(()=>V(Te),[Te,V]),gt=a.useCallback(o=>{Y.find(f=>f.category===o)?.retry()},[Y]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>At(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&Ms({hasSearchQuery:y,freeText:w,residualTokenCount:$.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const f=k.map(O=>De(O,c)),{spam:g}=Yt(f),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=lo(je,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[k,w,c,je]),ke=a.useMemo(()=>{const o=f=>he===void 0?f:f.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:Vt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:K.get(o.accountId),active:S===o.accountId}))],[x,K,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(K.values()).reduce((o,f)=>o+f,0),[K]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Ss(),{state:Fe,errorMessage:Ae,refresh:Ne}=Ts(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(Cs,{state:Fe,onRefresh:Ne,label:"Refresh daily brief",errorMessage:Ae,hasUpdate:Oe(pe)}),[Fe,Ne,Ae,Oe,pe]),vt=a.useMemo(()=>k.map(o=>De(o,c)),[k,c]),bt=a.useMemo(()=>{const o=Jt(ge.map(f=>({id:f.id,label:f.label,count:f.count,active:f.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:_,expanded:le,onExpandedChange:M,onSelectCategory:f=>j(f),onSelectSource:A,onToggleFilter:f=>I(f),onClear:ue}},[ge,z,Q,_,le,I,j,ue]),Be=ke.length===0&&S==="all"&&w.length===0&&P.length===0,St=a.useMemo(()=>x.map(o=>o.accountId),[x]),Tt=a.useMemo(()=>x.some(o=>ws(o.syncPhase)),[x]),ee=Rs(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ge,{}),r.jsx(Ge,{})]}),qe=!me&&!we&&!Be,Ct=Zt({tier:p,hasLiveInput:E,hasCommittedQuery:m.trim().length>0,bodyRendersCommittedResults:!0}),wt=qe?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&r.jsx(Xt,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,m)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(es,{sections:ke,briefCategory:Q,Row:ts,selectedThreadId:t,onSelectThread:Ee,onShowAllSection:de,onRetrySection:gt,flat:y,onSelectBriefCategory:j,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:A,activeFilters:_,onToggleFilter:I,onClearFilters:ue})})]}):me?Le:we?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx($e,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>Re(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(Ls,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?r.jsx(Ds,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Le;return r.jsx(Nt,{hasSheet:qe&&!Ct,children:r.jsx(ss,{selectedMessageId:t,rows:k,onOpen:Ee,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:n,onTriageContextChange:i,children:r.jsx(po,{wizard:b,header:{title:"Daily brief",unreadCount:It,footer:v?r.jsx(os,{}):void 0,searchFilter:bt,searchResults:vt,searchLoading:me,onSelectSearchResult:xt,spamOffer:X,searchResultsInBody:!0,refreshControl:yt},rows:k,children:r.jsxs("div",{className:"flex h-full flex-col",children:[lt.map(o=>r.jsx(ho,{accountEmail:o.email,accountId:o.accountId},o.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:wt})]})})})})}const it=a.createContext(null);function ce(){const e=a.useContext(it);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Io({thread:e,children:t}){const s=Ns(),n=Bs(),i=et(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ke({...Bt(),staleTime:6e4}),h=a.useMemo(()=>c?.items??[],[c]),u=a.useMemo(()=>{if(m)return h.find(I=>I.messageId===l)??h.find(I=>I.threadId===m)},[h,m,l]),v=us(m,l),p=u??v,b=l??p?.messageId,L=a.useMemo(()=>{if(m)return{threadId:m,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[m,p,b]),x=a.useCallback((I,j)=>{s(I,{replace:j?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&n()},[b,n]),A=Pe({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=fs(),{deleteMessages:R}=ms({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=hs({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,M=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,D=Pe({thread:M,isOpen:M?.messageId===b}),G=qs(),E=Lt(),w=qt(),P=a.useMemo(()=>Dt(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:_,previousMessageId:Q}=gs({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!G&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||D.deleteThread()},toggleStar:D.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||M&&N([M.messageId],!M.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),F=a.useCallback(I=>{if(!I)return;const j=h.find(de=>de.messageId===I);return j?{threadId:j.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:n,nextThread:F(_),previousThread:F(Q),actions:A,onReply:P,triage:T,onDeleteMessages:R,handleDeselectIfRemoved:S};return r.jsx(it.Provider,{value:C,children:t})}function ct(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:n}=ce(),{accounts:i}=ie();return r.jsx(xo,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function yo(){const e=xe(),{conversation:t,selectedThread:s,actions:n,onReply:i,handleDeselectIfRemoved:d,onOpenThread:m}=ce(),l=!!t,c=Is(t?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(ys,{hasThread:l,intelligenceOpen:c.isShowing,canToggleIntelligence:c.canToggle,onToggleIntelligence:c.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?r.jsx(Je,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(zt,{})})]}),r.jsx(Ze,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e,onOpenThread:m})]})}function vo(){const e=xe(),{selectedThread:t,handleDeselectIfRemoved:s,onOpenThread:n}=ce(),{onToggleIntelligence:i}=ie();return r.jsx(xs,{onClose:i,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e,onOpenThread:n})}function bo(){const e=xe(),{selectedThread:t,conversation:s,onOpenThread:n,onCloseThread:i,nextThread:d,previousThread:m,handleDeselectIfRemoved:l}=ce(),c=ps(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Je,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:c.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:m?()=>n(m):void 0,mobileIntelligenceOpen:c.isOpen}),r.jsx(Ze,{isOpen:c.isOpen,onClose:c.close,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:l,onReplyWithText:e,onOpenThread:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ct,{})})}const Bo=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{Bo as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,f as C,t as m,$ as X,a0 as ee,aA as N,r as w,az as te,X as ne,as as se,a1 as ae}from"./index-DmcPZs2v.js";import{R as _,k as $,J as ie,c as re,K as oe,x as le,L as ce,G as de}from"./calendar-format-BtVljxcO.js";import{e as ue,g as j,h as me,u as he,b as U,d as xe,i as pe,t as ye,U as ve}from"./useCalendars-IZDEajvg.js";import{C as ge}from"./calendar-clash-strip-eOS4W7xA.js";const De=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ne=["January","February","March","April","May","June","July","August","September","October","November","December"],Te=["first","second","third","fourth","last"],k="";function fe(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[s,a,r]=e.split("-").map(Number),o=new Date(Date.UTC(s,a-1,r)),i=De[o.getUTCDay()],c=Te[Math.min(Math.floor((r-1)/7),4)],l=t===""?"":`, ${t}`,d=o.getUTCDay()>=1&&o.getUTCDay()<=5;return[`Every day${l}`,...d?[`Every weekday${l}`]:[],`Every week on ${i}${l}`,`Every month on the ${c} ${i}${l}`,`Every year on ${r} ${Ne[a-1]}${l}`]}const be="w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",p=({draft:e,onChange:t},s,a)=>t({...e,[s]:a});function D({label:e,children:t}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t]})}function je({draft:e,onChange:t,layout:s="compact",touch:a}){const r=s==="pane";return n.jsx(N,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:o=>p({draft:e,onChange:t},"title",o.target.value),className:m(r?"text-lg font-medium":"text-md font-medium",r?"h-11":a?"min-h-11":"")})}function P(e){return e.date===""||e.endDate===""?!1:e.allDay?e.endDate<e.date:e.startTime===""||e.endTime===""?!1:`${e.endDate}T${e.endTime}`<`${e.date}T${e.startTime}`}function Ee(e,t){return t===""?{...e,date:t}:e.endDate===""?{...e,date:t,endDate:t}:e.date===""?{...e,date:t}:{...e,date:t,endDate:$(t,ie(e.date,e.endDate))}}function Ce(e,t){const s=e.date!==""&&e.endDate===$(e.date,1)&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime;return t&&s?{...e,allDay:t,endDate:e.date}:!t&&e.date!==""&&e.endDate===e.date&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime?{...e,allDay:t,endDate:$(e.date,1)}:{...e,allDay:t}}function $e({draft:e,onChange:t,touch:s}){const a=s?"min-h-11":"",r=P(e),o=w.useId(),i={"aria-invalid":r,"aria-describedby":r?o:void 0},c=m("w-40",a,r&&"border-danger/60"),l=m("w-28",a,r&&"border-danger/60");return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(N,{type:"date",value:e.date,"aria-label":"Date",...i,onChange:d=>t(Ee(e,d.target.value)),className:c}),!e.allDay&&n.jsx(N,{type:"time",value:e.startTime,"aria-label":"Start time",...i,onChange:d=>p({draft:e,onChange:t},"startTime",d.target.value),className:l}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(N,{type:"date",value:e.endDate,"aria-label":"End date",min:e.date===""?void 0:e.date,...i,onChange:d=>p({draft:e,onChange:t},"endDate",d.target.value),className:c}),!e.allDay&&n.jsx(N,{type:"time",value:e.endTime,"aria-label":"End time",...i,onChange:d=>p({draft:e,onChange:t},"endTime",d.target.value),className:l}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:d=>t(Ce(e,d.target.checked)),className:"size-4 accent-current"}),"All day"]})]}),r&&n.jsx("p",{id:o,className:"text-xs text-danger",role:"alert",children:e.allDay?`Ends before it starts. Move the end to ${e.date} or later.`:`Ends before it starts. Move the end past ${e.date} ${e.startTime}, or start earlier.`})]})}function ke({draft:e,onChange:t,calendars:s,touch:a}){return n.jsx(Fe,{calendars:s,value:e.calendarId,onChange:r=>p({draft:e,onChange:t},"calendarId",r),touch:a})}function we({draft:e,onChange:t,touch:s,repeatEditable:a=!0,onCustom:r}){return a?n.jsx(Re,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:o=>p({draft:e,onChange:t},"repeat",o),onCustom:r,className:s?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(_,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===k?"Does not repeat":e.repeat]})}function Ae({draft:e,onChange:t,touch:s}){return n.jsx(N,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:a=>p({draft:e,onChange:t},"location",a.target.value),className:s?"min-h-11":""})}function Ye({draft:e,onChange:t,touch:s}){return n.jsx(N,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:a=>p({draft:e,onChange:t},"guests",a.target.value),className:s?"min-h-11":""})}function Oe({draft:e,onChange:t,layout:s="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:a=>p({draft:e,onChange:t},"notes",a.target.value),rows:s==="pane"?6:3,className:be})}function Me({draft:e,onChange:t,calendars:s,layout:a="compact",expanded:r=!1,onToggleExpanded:o,onSave:i,onCancel:c,onDelete:l,saveLabel:d="Add",header:h,repeatEditable:u=!0,guestsEditable:x=!1,calendarEditable:y=!0,onCustomRepeat:b,touch:v,className:Y}){const f=a==="pane",g={draft:e,onChange:t,layout:a,touch:v},O=n.jsx(je,{...g}),M=n.jsx($e,{...g}),R=n.jsx(ke,{...g,calendars:s}),F=n.jsx(we,{...g,repeatEditable:u,onCustom:b}),S=n.jsx(Ae,{...g}),I=n.jsx(Ye,{...g}),L=n.jsx(Oe,{...g}),B=n.jsxs("div",{className:m("flex items-center gap-2",f?"pt-2":"pt-1"),children:[n.jsx(C,{variant:"primary",size:v||f?"md":"sm",onClick:i,disabled:P(e),className:v?"min-h-11 flex-1":"",children:d}),n.jsx(C,{variant:"ghost",size:v||f?"md":"sm",onClick:c,className:v?"min-h-11":"",children:"Cancel"}),l&&n.jsx(C,{variant:"ghost",size:v||f?"md":"sm",onClick:l,className:m("ml-auto text-danger",v&&"min-h-11"),children:"Delete"})]});if(f)return n.jsxs("div",{className:m("flex flex-col gap-5",Y),children:[h,n.jsx(D,{label:"Title",children:O}),n.jsx(D,{label:"When",children:M}),y&&n.jsx(D,{label:"Calendar",children:R}),n.jsx(D,{label:"Repeat",children:F}),n.jsx(D,{label:"Location",children:S}),x&&n.jsx(D,{label:"Guests",children:I}),n.jsx(D,{label:"Notes",children:L}),B]});const q=o!==void 0&&!r;return n.jsxs("div",{className:m("flex flex-col gap-3",Y),children:[h,O,M,y&&R,o&&n.jsxs("button",{type:"button",onClick:o,"aria-expanded":r,className:m("flex items-center gap-1 self-start rounded-sm text-xs font-medium text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",v&&"min-h-11"),children:[r?n.jsx(X,{className:"size-3.5"}):n.jsx(ee,{className:"size-3.5"}),r?"Fewer details":"More details"]}),!q&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[S,x&&I,F,L]}),B]})}const W="__custom__";function Re({value:e,date:t,startTime:s,onChange:a,onCustom:r,className:o}){const i=fe(t,s),c=e===k||i.includes(e)?i:[e,...i];return n.jsxs(te,{icon:n.jsx(_,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:l=>{if(l.target.value===W){r?.();return}a(l.target.value)},className:o,children:[n.jsx("option",{value:k,children:"Does not repeat"}),c.map(l=>n.jsx("option",{value:l,children:l},l)),r&&n.jsx("option",{value:W,children:"Custom…"})]})}function Fe({calendars:e,value:t,onChange:s,touch:a}){const r=w.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(o=>{const i=re(o.color),c=o.id===t;return n.jsxs("label",{className:m("inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs transition-colors","has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",a?"min-h-11":"h-7",c?m(i.soft,i.text,i.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:r,value:o.id,checked:c,onChange:()=>s(o.id),className:"sr-only"}),n.jsx("span",{className:m("size-2 rounded-full",i.solid)}),o.name]},o.id)})]})}function Se({title:e,subtitle:t,onClose:s,children:a,className:r}){return n.jsxs("section",{className:m("flex h-full w-full flex-col bg-surface",r),children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),t!==void 0&&t!==""&&n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:t}),n.jsx("button",{type:"button","aria-label":"Close editor",onClick:s,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(ne,{className:"size-4"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:a})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],T=["SU","MO","TU","WE","TH","FR","SA"],z=["January","February","March","April","May","June","July","August","September","October","November","December"],Z=["first","second","third","fourth","last"],A=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function K(e){const t=Ie(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${J}`;const s=t.match(/^Every week on (\w+)$/);if(s){const o=E.indexOf(s[1]);return o===-1?void 0:`FREQ=WEEKLY;BYDAY=${T[o]}`}const a=t.match(/^Every month on the (\w+) (\w+)$/);if(a){const o=Z.indexOf(a[1]),i=E.indexOf(a[2]);return o===-1||i===-1?void 0:`FREQ=MONTHLY;BYDAY=${A[o]}${T[i]}`}const r=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(r){const o=z.indexOf(r[2]);return o===-1?void 0:`FREQ=YEARLY;BYMONTH=${o+1};BYMONTHDAY=${Number(r[1])}`}}const Le=e=>e===""?"":`, ${e}`;function Ze(e,t){const s=new Map(e.split(";").map(i=>i.split("=")).filter(i=>i.length===2).map(([i,c])=>[i.toUpperCase(),c.toUpperCase()])),a=Le(t),r=s.get("FREQ"),o=s.get("BYDAY");if(!(s.has("INTERVAL")&&s.get("INTERVAL")!=="1")&&!(s.has("UNTIL")||s.has("COUNT"))){if(r==="DAILY")return`Every day${a}`;if(r==="WEEKLY"){if(o===void 0)return;if(o===J)return`Every weekday${a}`;const i=T.indexOf(o);return i===-1?void 0:`Every week on ${E[i]}${a}`}if(r==="MONTHLY"){const i=o?.match(/^(-?\d)([A-Z]{2})$/);if(!i)return;const c=A.indexOf(Number(i[1])),l=T.indexOf(i[2]);return c===-1||l===-1?void 0:`Every month on the ${Z[c]} ${E[l]}${a}`}if(r==="YEARLY"){const i=Number(s.get("BYMONTH")),c=Number(s.get("BYMONTHDAY"));return!i||!c||i>12?void 0:`Every year on ${c} ${z[i-1]}${a}`}}}const H=e=>Date.parse(`${e}T00:00:00Z`)/864e5;function Be(e,t,s){const a=H(s)-H(t);if(e===""||a===0||Number.isNaN(a))return e;const[r,o,i]=s.split("-").map(Number),c=new Date(Date.UTC(r,o-1,i)).getUTCDay(),l=/FREQ=(\w+)/i.exec(e)?.[1]?.toUpperCase();return e.split(";").map(d=>{const[h,u=""]=d.split("="),x=h.toUpperCase();return x==="BYDAY"&&l==="MONTHLY"?`BYDAY=${A[Math.min(Math.floor((i-1)/7),4)]}${T[c]}`:x==="BYDAY"?`BYDAY=${u.split(",").map(y=>{const b=T.indexOf(y.toUpperCase());return b===-1?y:T[(b+a+7)%7]}).join(",")}`:x==="BYMONTH"?`BYMONTH=${o}`:x==="BYMONTHDAY"?`BYMONTHDAY=${i}`:d}).join(";")}function Je(e,t){return{title:"",date:e,startTime:"09:00",endDate:e,endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function Ke(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endDate:oe(e),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:"",notes:t.notes,repeat:t.repeat}}function Q(e,t){return e.allDay?{start:e.date,end:ue(e.endDate,1)}:{start:j(e.date,e.startTime,t),end:j(e.endDate,e.endTime,t)}}function G(e,t,s){const a=K(e.repeat)??"",r=e.allDay?e.date:me(t,s.anchor===""?"UTC":s.anchor).slice(0,10);return Be(a,e.date,r)}function V(e,t){return e.title.trim()===""?"Give the event a title before saving it.":e.date===""?"Pick the day the event is on.":e.endDate===""?"Pick the day the event ends on.":e.calendarId===""?"Pick the calendar to save the event in.":!e.allDay&&(e.startTime===""||e.endTime==="")?"Set a start and an end time, or mark the event all day.":e.allDay&&e.endDate<e.date?"The last day is before the first. Move one of them.":!e.allDay&&`${e.endDate}T${e.endTime}`<=`${e.date}T${e.startTime}`?"The end is not after the start. Move one of them.":t&&K(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function Qe(e,t){const s=V(e,!0);if(s!=="")return{ok:!1,problem:s};const{start:a,end:r}=Q(e,t.clock);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:a,end:r,allDay:e.allDay,...t.anchor===""?{}:{timeZone:t.anchor},recurrenceRule:G(e,a,t)}}}function Ge(e,t,s){const a=t.repeat!==e.repeat,o=t.allDay!==e.allDay||t.date!==e.date||t.startTime!==e.startTime,i=o||t.endDate!==e.endDate||t.endTime!==e.endTime,c=V(t,a);if(c!=="")return{ok:!1,problem:c};const l={};t.title.trim()!==e.title.trim()&&(l.summary=t.title.trim()),t.location!==e.location&&(l.location=t.location),t.notes!==e.notes&&(l.description=t.notes);const{start:d,end:h}=Q(t,s.clock);return o&&(l.start=d),i&&(l.end=h,l.allDay=t.allDay,s.anchor!==""&&(l.timeZone=s.anchor)),a&&(l.recurrenceRule=G(t,d,s)),{ok:!0,patch:l}}const Ue=[],We={from:"",to:""};function Ve(e,t=""){const{timeZoneByCalendarId:s}=he(),a=e.date!==""&&!e.allDay&&e.endDate!==""&&e.startTime!==""&&e.endTime!==""&&`${e.endDate}T${e.endTime}`>`${e.date}T${e.startTime}`,{instances:r,isLoading:o,error:i}=le({...a?{from:U("week",e.date).from,to:U("week",e.endDate).to}:We,calendarIds:Ue,enabled:a}),c=xe();return w.useMemo(()=>{if(!a||o||i)return;const l=j(e.date,e.startTime,c),d=j(e.endDate,e.endTime,c),h=r.filter(u=>pe(u)&&u.calendarObjectId!==t).map(u=>ye(u,s[u.calendarId]??ve,c));return ce({start:l,end:d},h).map(u=>({id:u.id,label:`${u.title}, ${de(u)}`}))},[a,o,i,e.date,e.endDate,e.startTime,e.endTime,c,r,t,s])}function qe({title:e,subtitle:t,notice:s="",calendars:a,draft:r,onChange:o,problem:i,saveLabel:c,isSaving:l,repeatEditable:d=!0,calendarEditable:h=!0,clashes:u,onSave:x,onCancel:y}){return n.jsx(Se,{title:e,subtitle:t,onClose:y,children:n.jsx(Me,{draft:r,onChange:o,calendars:a,layout:"pane",repeatEditable:d,calendarEditable:h,saveLabel:l?"Saving…":c,onSave:x,onCancel:y,header:i===""&&s===""&&u===void 0?void 0:n.jsxs("div",{className:"space-y-2",children:[s!==""&&n.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-warning/40 bg-warning-soft px-3 py-2 text-sm text-fg",children:[n.jsx(se,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 flex-1 break-words",children:s})]}),i!==""&&n.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[n.jsx(ae,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),n.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:i})]}),u!==void 0&&n.jsx(ge,{clashes:u,clearText:"Nothing else is booked at this time."})]})})})}export{qe as C,Se as E,Q as a,Qe as c,Ke as d,Je as e,Be as m,Ge as p,Ze as t,Ve as u};
|
|
1
|
+
import{j as n,f as C,t as m,$ as X,a0 as ee,aA as N,r as w,az as te,X as ne,as as se,a1 as ae}from"./index-DkIInRxS.js";import{R as _,k as $,J as ie,c as re,K as oe,x as le,L as ce,G as de}from"./calendar-format-DDfQBsqj.js";import{e as ue,g as j,h as me,u as he,b as U,d as xe,i as pe,t as ye,U as ve}from"./useCalendars-D2WfLVhR.js";import{C as ge}from"./calendar-clash-strip-CL_bKWfx.js";const De=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ne=["January","February","March","April","May","June","July","August","September","October","November","December"],Te=["first","second","third","fourth","last"],k="";function fe(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[s,a,r]=e.split("-").map(Number),o=new Date(Date.UTC(s,a-1,r)),i=De[o.getUTCDay()],c=Te[Math.min(Math.floor((r-1)/7),4)],l=t===""?"":`, ${t}`,d=o.getUTCDay()>=1&&o.getUTCDay()<=5;return[`Every day${l}`,...d?[`Every weekday${l}`]:[],`Every week on ${i}${l}`,`Every month on the ${c} ${i}${l}`,`Every year on ${r} ${Ne[a-1]}${l}`]}const be="w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",p=({draft:e,onChange:t},s,a)=>t({...e,[s]:a});function D({label:e,children:t}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t]})}function je({draft:e,onChange:t,layout:s="compact",touch:a}){const r=s==="pane";return n.jsx(N,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:o=>p({draft:e,onChange:t},"title",o.target.value),className:m(r?"text-lg font-medium":"text-md font-medium",r?"h-11":a?"min-h-11":"")})}function P(e){return e.date===""||e.endDate===""?!1:e.allDay?e.endDate<e.date:e.startTime===""||e.endTime===""?!1:`${e.endDate}T${e.endTime}`<`${e.date}T${e.startTime}`}function Ee(e,t){return t===""?{...e,date:t}:e.endDate===""?{...e,date:t,endDate:t}:e.date===""?{...e,date:t}:{...e,date:t,endDate:$(t,ie(e.date,e.endDate))}}function Ce(e,t){const s=e.date!==""&&e.endDate===$(e.date,1)&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime;return t&&s?{...e,allDay:t,endDate:e.date}:!t&&e.date!==""&&e.endDate===e.date&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime?{...e,allDay:t,endDate:$(e.date,1)}:{...e,allDay:t}}function $e({draft:e,onChange:t,touch:s}){const a=s?"min-h-11":"",r=P(e),o=w.useId(),i={"aria-invalid":r,"aria-describedby":r?o:void 0},c=m("w-40",a,r&&"border-danger/60"),l=m("w-28",a,r&&"border-danger/60");return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(N,{type:"date",value:e.date,"aria-label":"Date",...i,onChange:d=>t(Ee(e,d.target.value)),className:c}),!e.allDay&&n.jsx(N,{type:"time",value:e.startTime,"aria-label":"Start time",...i,onChange:d=>p({draft:e,onChange:t},"startTime",d.target.value),className:l}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(N,{type:"date",value:e.endDate,"aria-label":"End date",min:e.date===""?void 0:e.date,...i,onChange:d=>p({draft:e,onChange:t},"endDate",d.target.value),className:c}),!e.allDay&&n.jsx(N,{type:"time",value:e.endTime,"aria-label":"End time",...i,onChange:d=>p({draft:e,onChange:t},"endTime",d.target.value),className:l}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:d=>t(Ce(e,d.target.checked)),className:"size-4 accent-current"}),"All day"]})]}),r&&n.jsx("p",{id:o,className:"text-xs text-danger",role:"alert",children:e.allDay?`Ends before it starts. Move the end to ${e.date} or later.`:`Ends before it starts. Move the end past ${e.date} ${e.startTime}, or start earlier.`})]})}function ke({draft:e,onChange:t,calendars:s,touch:a}){return n.jsx(Fe,{calendars:s,value:e.calendarId,onChange:r=>p({draft:e,onChange:t},"calendarId",r),touch:a})}function we({draft:e,onChange:t,touch:s,repeatEditable:a=!0,onCustom:r}){return a?n.jsx(Re,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:o=>p({draft:e,onChange:t},"repeat",o),onCustom:r,className:s?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(_,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===k?"Does not repeat":e.repeat]})}function Ae({draft:e,onChange:t,touch:s}){return n.jsx(N,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:a=>p({draft:e,onChange:t},"location",a.target.value),className:s?"min-h-11":""})}function Ye({draft:e,onChange:t,touch:s}){return n.jsx(N,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:a=>p({draft:e,onChange:t},"guests",a.target.value),className:s?"min-h-11":""})}function Oe({draft:e,onChange:t,layout:s="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:a=>p({draft:e,onChange:t},"notes",a.target.value),rows:s==="pane"?6:3,className:be})}function Me({draft:e,onChange:t,calendars:s,layout:a="compact",expanded:r=!1,onToggleExpanded:o,onSave:i,onCancel:c,onDelete:l,saveLabel:d="Add",header:h,repeatEditable:u=!0,guestsEditable:x=!1,calendarEditable:y=!0,onCustomRepeat:b,touch:v,className:Y}){const f=a==="pane",g={draft:e,onChange:t,layout:a,touch:v},O=n.jsx(je,{...g}),M=n.jsx($e,{...g}),R=n.jsx(ke,{...g,calendars:s}),F=n.jsx(we,{...g,repeatEditable:u,onCustom:b}),S=n.jsx(Ae,{...g}),I=n.jsx(Ye,{...g}),L=n.jsx(Oe,{...g}),B=n.jsxs("div",{className:m("flex items-center gap-2",f?"pt-2":"pt-1"),children:[n.jsx(C,{variant:"primary",size:v||f?"md":"sm",onClick:i,disabled:P(e),className:v?"min-h-11 flex-1":"",children:d}),n.jsx(C,{variant:"ghost",size:v||f?"md":"sm",onClick:c,className:v?"min-h-11":"",children:"Cancel"}),l&&n.jsx(C,{variant:"ghost",size:v||f?"md":"sm",onClick:l,className:m("ml-auto text-danger",v&&"min-h-11"),children:"Delete"})]});if(f)return n.jsxs("div",{className:m("flex flex-col gap-5",Y),children:[h,n.jsx(D,{label:"Title",children:O}),n.jsx(D,{label:"When",children:M}),y&&n.jsx(D,{label:"Calendar",children:R}),n.jsx(D,{label:"Repeat",children:F}),n.jsx(D,{label:"Location",children:S}),x&&n.jsx(D,{label:"Guests",children:I}),n.jsx(D,{label:"Notes",children:L}),B]});const q=o!==void 0&&!r;return n.jsxs("div",{className:m("flex flex-col gap-3",Y),children:[h,O,M,y&&R,o&&n.jsxs("button",{type:"button",onClick:o,"aria-expanded":r,className:m("flex items-center gap-1 self-start rounded-sm text-xs font-medium text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",v&&"min-h-11"),children:[r?n.jsx(X,{className:"size-3.5"}):n.jsx(ee,{className:"size-3.5"}),r?"Fewer details":"More details"]}),!q&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[S,x&&I,F,L]}),B]})}const W="__custom__";function Re({value:e,date:t,startTime:s,onChange:a,onCustom:r,className:o}){const i=fe(t,s),c=e===k||i.includes(e)?i:[e,...i];return n.jsxs(te,{icon:n.jsx(_,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:l=>{if(l.target.value===W){r?.();return}a(l.target.value)},className:o,children:[n.jsx("option",{value:k,children:"Does not repeat"}),c.map(l=>n.jsx("option",{value:l,children:l},l)),r&&n.jsx("option",{value:W,children:"Custom…"})]})}function Fe({calendars:e,value:t,onChange:s,touch:a}){const r=w.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(o=>{const i=re(o.color),c=o.id===t;return n.jsxs("label",{className:m("inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs transition-colors","has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",a?"min-h-11":"h-7",c?m(i.soft,i.text,i.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:r,value:o.id,checked:c,onChange:()=>s(o.id),className:"sr-only"}),n.jsx("span",{className:m("size-2 rounded-full",i.solid)}),o.name]},o.id)})]})}function Se({title:e,subtitle:t,onClose:s,children:a,className:r}){return n.jsxs("section",{className:m("flex h-full w-full flex-col bg-surface",r),children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),t!==void 0&&t!==""&&n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:t}),n.jsx("button",{type:"button","aria-label":"Close editor",onClick:s,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(ne,{className:"size-4"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:a})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],T=["SU","MO","TU","WE","TH","FR","SA"],z=["January","February","March","April","May","June","July","August","September","October","November","December"],Z=["first","second","third","fourth","last"],A=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function K(e){const t=Ie(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${J}`;const s=t.match(/^Every week on (\w+)$/);if(s){const o=E.indexOf(s[1]);return o===-1?void 0:`FREQ=WEEKLY;BYDAY=${T[o]}`}const a=t.match(/^Every month on the (\w+) (\w+)$/);if(a){const o=Z.indexOf(a[1]),i=E.indexOf(a[2]);return o===-1||i===-1?void 0:`FREQ=MONTHLY;BYDAY=${A[o]}${T[i]}`}const r=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(r){const o=z.indexOf(r[2]);return o===-1?void 0:`FREQ=YEARLY;BYMONTH=${o+1};BYMONTHDAY=${Number(r[1])}`}}const Le=e=>e===""?"":`, ${e}`;function Ze(e,t){const s=new Map(e.split(";").map(i=>i.split("=")).filter(i=>i.length===2).map(([i,c])=>[i.toUpperCase(),c.toUpperCase()])),a=Le(t),r=s.get("FREQ"),o=s.get("BYDAY");if(!(s.has("INTERVAL")&&s.get("INTERVAL")!=="1")&&!(s.has("UNTIL")||s.has("COUNT"))){if(r==="DAILY")return`Every day${a}`;if(r==="WEEKLY"){if(o===void 0)return;if(o===J)return`Every weekday${a}`;const i=T.indexOf(o);return i===-1?void 0:`Every week on ${E[i]}${a}`}if(r==="MONTHLY"){const i=o?.match(/^(-?\d)([A-Z]{2})$/);if(!i)return;const c=A.indexOf(Number(i[1])),l=T.indexOf(i[2]);return c===-1||l===-1?void 0:`Every month on the ${Z[c]} ${E[l]}${a}`}if(r==="YEARLY"){const i=Number(s.get("BYMONTH")),c=Number(s.get("BYMONTHDAY"));return!i||!c||i>12?void 0:`Every year on ${c} ${z[i-1]}${a}`}}}const H=e=>Date.parse(`${e}T00:00:00Z`)/864e5;function Be(e,t,s){const a=H(s)-H(t);if(e===""||a===0||Number.isNaN(a))return e;const[r,o,i]=s.split("-").map(Number),c=new Date(Date.UTC(r,o-1,i)).getUTCDay(),l=/FREQ=(\w+)/i.exec(e)?.[1]?.toUpperCase();return e.split(";").map(d=>{const[h,u=""]=d.split("="),x=h.toUpperCase();return x==="BYDAY"&&l==="MONTHLY"?`BYDAY=${A[Math.min(Math.floor((i-1)/7),4)]}${T[c]}`:x==="BYDAY"?`BYDAY=${u.split(",").map(y=>{const b=T.indexOf(y.toUpperCase());return b===-1?y:T[(b+a+7)%7]}).join(",")}`:x==="BYMONTH"?`BYMONTH=${o}`:x==="BYMONTHDAY"?`BYMONTHDAY=${i}`:d}).join(";")}function Je(e,t){return{title:"",date:e,startTime:"09:00",endDate:e,endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function Ke(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endDate:oe(e),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:"",notes:t.notes,repeat:t.repeat}}function Q(e,t){return e.allDay?{start:e.date,end:ue(e.endDate,1)}:{start:j(e.date,e.startTime,t),end:j(e.endDate,e.endTime,t)}}function G(e,t,s){const a=K(e.repeat)??"",r=e.allDay?e.date:me(t,s.anchor===""?"UTC":s.anchor).slice(0,10);return Be(a,e.date,r)}function V(e,t){return e.title.trim()===""?"Give the event a title before saving it.":e.date===""?"Pick the day the event is on.":e.endDate===""?"Pick the day the event ends on.":e.calendarId===""?"Pick the calendar to save the event in.":!e.allDay&&(e.startTime===""||e.endTime==="")?"Set a start and an end time, or mark the event all day.":e.allDay&&e.endDate<e.date?"The last day is before the first. Move one of them.":!e.allDay&&`${e.endDate}T${e.endTime}`<=`${e.date}T${e.startTime}`?"The end is not after the start. Move one of them.":t&&K(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function Qe(e,t){const s=V(e,!0);if(s!=="")return{ok:!1,problem:s};const{start:a,end:r}=Q(e,t.clock);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:a,end:r,allDay:e.allDay,...t.anchor===""?{}:{timeZone:t.anchor},recurrenceRule:G(e,a,t)}}}function Ge(e,t,s){const a=t.repeat!==e.repeat,o=t.allDay!==e.allDay||t.date!==e.date||t.startTime!==e.startTime,i=o||t.endDate!==e.endDate||t.endTime!==e.endTime,c=V(t,a);if(c!=="")return{ok:!1,problem:c};const l={};t.title.trim()!==e.title.trim()&&(l.summary=t.title.trim()),t.location!==e.location&&(l.location=t.location),t.notes!==e.notes&&(l.description=t.notes);const{start:d,end:h}=Q(t,s.clock);return o&&(l.start=d),i&&(l.end=h,l.allDay=t.allDay,s.anchor!==""&&(l.timeZone=s.anchor)),a&&(l.recurrenceRule=G(t,d,s)),{ok:!0,patch:l}}const Ue=[],We={from:"",to:""};function Ve(e,t=""){const{timeZoneByCalendarId:s}=he(),a=e.date!==""&&!e.allDay&&e.endDate!==""&&e.startTime!==""&&e.endTime!==""&&`${e.endDate}T${e.endTime}`>`${e.date}T${e.startTime}`,{instances:r,isLoading:o,error:i}=le({...a?{from:U("week",e.date).from,to:U("week",e.endDate).to}:We,calendarIds:Ue,enabled:a}),c=xe();return w.useMemo(()=>{if(!a||o||i)return;const l=j(e.date,e.startTime,c),d=j(e.endDate,e.endTime,c),h=r.filter(u=>pe(u)&&u.calendarObjectId!==t).map(u=>ye(u,s[u.calendarId]??ve,c));return ce({start:l,end:d},h).map(u=>({id:u.id,label:`${u.title}, ${de(u)}`}))},[a,o,i,e.date,e.endDate,e.startTime,e.endTime,c,r,t,s])}function qe({title:e,subtitle:t,notice:s="",calendars:a,draft:r,onChange:o,problem:i,saveLabel:c,isSaving:l,repeatEditable:d=!0,calendarEditable:h=!0,clashes:u,onSave:x,onCancel:y}){return n.jsx(Se,{title:e,subtitle:t,onClose:y,children:n.jsx(Me,{draft:r,onChange:o,calendars:a,layout:"pane",repeatEditable:d,calendarEditable:h,saveLabel:l?"Saving…":c,onSave:x,onCancel:y,header:i===""&&s===""&&u===void 0?void 0:n.jsxs("div",{className:"space-y-2",children:[s!==""&&n.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-warning/40 bg-warning-soft px-3 py-2 text-sm text-fg",children:[n.jsx(se,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 flex-1 break-words",children:s})]}),i!==""&&n.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[n.jsx(ae,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),n.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:i})]}),u!==void 0&&n.jsx(ge,{clashes:u,clearText:"Nothing else is booked at this time."})]})})})}export{qe as C,Se as E,Q as a,Qe as c,Ke as d,Je as e,Be as m,Ge as p,Ze as t,Ve as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,r as e}from"./index-
|
|
1
|
+
import{j as t,r as e}from"./index-DkIInRxS.js";const o=e.createContext(void 0),C=({pick:s,children:r})=>t.jsx(o.Provider,{value:s,children:r}),d=()=>e.useContext(o);export{C,d as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as n,am as l,an as o}from"./index-
|
|
1
|
+
import{r,j as n,am as l,an as o}from"./index-DkIInRxS.js";const i=r.createContext(null),v=({chrome:s,children:a})=>n.jsx(i.Provider,{value:s,children:a});function C({workspace:s,reading:a,hasOpenEvent:x}){const e=r.useContext(i);if(!e)return n.jsx(l,{});const t={nav:e.nav,skeleton:n.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav,listBias:"list"};return e.isSinglePane?n.jsx(o,{...t,list:x?a:s}):n.jsx(o,{...t,list:s,reading:a})}export{v as C,C as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./index-
|
|
1
|
+
import{j as e}from"./index-DkIInRxS.js";const x=({message:s,icon:t})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&e.jsx("div",{className:"mb-4 text-fg-muted",children:t}),e.jsx("p",{className:"text-fg-muted",children:s})]});export{x as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,a1 as r}from"./index-
|
|
1
|
+
import{j as t,a1 as r}from"./index-DkIInRxS.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f0 as U,r as n,ec as X,c as le,G as z,bm as ce,cX as ue,aI as ge,aJ as he,j as r,al as me,d7 as pe,d8 as fe}from"./index-
|
|
1
|
+
import{f0 as U,r as n,ec as X,c as le,G as z,bm as ce,cX as ue,aI as ge,aJ as he,j as r,al as me,d7 as pe,d8 as fe}from"./index-DkIInRxS.js";import{u as xe,p as _,R as Ie}from"./useSearchTokenContext-CpseqdIz.js";import{z as Te,B as ye,ao as ve,ap as be,az as Re,aq as Ce,a as Se,M as we,aw as je,aA as Fe,ay as Me,l as Oe,I as ke,N as J,L as Pe,J as Le,b as Ne,X as Ae,Y as G,Z as De,$ as Y,a0 as Z,a1 as qe,a2 as Ee,a3 as Be}from"./MailListHeader-B6L3wlep.js";import{f as We}from"./ErrorState-CrDfgkFR.js";import{u as Qe,l as ze,b as Ge,a as He}from"./MailViewChrome-B-TV4RBP.js";import{d as Ke,w as Ve}from"./wizard-selection-zWa1qc6-.js";import{a as _e}from"./useMessageBodyContent-CR91yAv-.js";import{e as Je,f as Ue}from"./search-token-index-B7mIWAbK.js";import{u as Xe}from"./sections-7lDa8HkJ.js";const H=t=>({...t,starred:!0,order:"desc"}),Ye=(t={})=>X({query:H(t)});function $(t={}){const{data:e,isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}=Qe({queryKey:Ye(t),queryFn:async({pageParam:x})=>{const{data:u}=await U({query:{...H(t),continuationToken:x},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:x=>x.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(x=>x.items??[]),[e]),isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}}function Ze(t={}){const e={...H(t),unread:!0,count:!0,results:!1},{data:s}=le({queryKey:X({query:e}),queryFn:async()=>{const{data:a}=await U({query:e,throwOnError:!0});return a},staleTime:6e4});return s?.count}const $e=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=Te(t),{params:a,residual:i}=ye(e,{...s,starred:!0},$e);return{criteria:{...a,...s},residual:i}};function tt({rows:t,verb:e}){const{selectedIds:s,exitSelection:a}=Me(),i=n.useMemo(()=>Ve(t,s),[t,s]);return r.jsx(Oe,{verb:e,selection:i,selectionRestriction:"spansAccounts",onFinished:a})}function st({selectedMessageId:t,onOpenThread:e,commandsRef:s,onTriageContextChange:a,onDeleteMessages:i}){const{searchQuery:f,resultFolderIndex:l,onSearchClearQuery:g}=z(),o=xe(),k=ce(),x=ue(),[u,h]=n.useState("all"),[v,P]=n.useState(new Set),S=n.useCallback(d=>{P(C=>{const I=new Set(C);return I.has(d)?I.delete(d):I.add(d),I})},[]),w=n.useCallback(()=>{h("all"),P(new Set)},[]),T=n.useCallback(()=>{w(),g()},[w,g]),{freeText:j,tokens:b}=_(f.trim().toLowerCase(),o),L=_(f.trim(),o).freeText,{criteria:N,residual:m}=n.useMemo(()=>et({category:u,attributes:v},b),[u,v,b]),F=n.useMemo(()=>j?{...N,query:j}:N,[N,j]),{threads:A,isLoading:D,isError:y,error:E,refetch:M,fetchNextPage:B,hasNextPage:W,isFetchingNextPage:O}=$(F),p=n.useMemo(()=>Ke(A).map(ve).filter(d=>be(d,m)),[A,m]),c=n.useCallback((d,C)=>{const I=p.find(de=>de.id===d)?.threadId;I&&e?.({threadId:I,messageId:d},C)},[p,e]),R=n.useCallback(d=>{const C=d.threadId??p.find(I=>I.id===d.id)?.threadId;C&&e?.({threadId:C,messageId:d.id})},[p,e]),Q=n.useMemo(()=>Re(),[]),se=n.useMemo(()=>p.map(d=>Ce(d,l)),[p,l]),ae=Ze(F)??null,re=n.useMemo(()=>b.filter(d=>d.type!=="isStarred"),[b]),oe=ze({chips:{category:u,attributes:v},tokens:re,reach:m.length>0?"loaded-pages":"whole-folder",onClear:T}),K=D?"loading":y?"error":p.length===0?"empty":"ready",ne=n.useCallback(()=>{const d=ge(he());window.open(d,"_blank","noopener,noreferrer")},[]),V=Se(),ie=r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"divide-y divide-line",children:p.map(d=>r.jsx(we,{thread:d,active:d.id===t,onClick:()=>c(d.id)},d.id))}),W?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>B(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(Ge,{title:"Starred",unreadCount:ae,preset:Q,selectedCategory:u,activeFilters:v,onSelectCategory:h,onToggleFilter:S,onClearFilters:w,searchResults:se,searchLoading:D,onSelectSearchResult:R,searchResultsInBody:!0,children:r.jsxs(je,{selectedMessageId:t,rows:p,onOpen:c,onDeleteMessages:i,onSelectionVerb:x.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(He,{listTitle:"Starred",sections:[{id:"flagged",threads:p}],flatList:!0,hideHeader:!0,listState:V.searchResults?"ready":K,listFilter:oe,listScopeLabel:"Starred",searchQuery:L||void 0,errorMessage:y?We(E):void 0,onRetry:()=>M(),onReportError:ne,selectedThreadId:t,onSelectThread:c,isDesktop:k,selectionBar:r.jsx(Fe,{title:"Starred"}),listBody:V.searchResults??(K==="ready"?ie:void 0)}),r.jsx(tt,{rows:p,verb:x.verb})]})})}const ee=n.createContext(null);function q(){const t=n.useContext(ee);if(!t)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return t}function at({thread:t,children:e}){const s=Je(),a=Ue(),i=Xe(),{searchInput:f}=z(),l=t?.threadId,g=t?.messageId,{threads:o}=$(),k=n.useMemo(()=>{if(l)return o.find(c=>c.messageId===g)??o.find(c=>c.threadId===l)},[o,l,g]),x=ke(l,g),u=k??x,h=g??u?.messageId,v=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:h,authenticity:u?.authenticity}},[l,u,h]),P=n.useCallback((c,R)=>{s(c,{replace:R?.replace,query:f})},[s,f]),S=n.useCallback(c=>{h&&c.includes(h)&&a()},[h,a]),w=J({thread:u,isOpen:!0,onAfterOptimisticRemove:S}),T=Pe(),{deleteMessages:j}=Le({mailboxId:u?.mailboxId??"",messages:o,onAfterOptimisticRemove:S}),{toggleReadFor:b}=Ne({mailboxId:u?.mailboxId??"",messages:o}),L=T.focusedMessageId,m=n.useMemo(()=>o.find(c=>c.messageId===L),[o,L])??u,F=J({thread:m,isOpen:m?.messageId===h}),A=_e(),D=me(),y=pe(),E=n.useMemo(()=>fe(y,l,h),[y,l,h]),M=n.useMemo(()=>{if(m)return c=>y({threadId:m.threadId,messageId:m.messageId,mode:c})},[y,m]),{nextMessageId:B,previousMessageId:W}=Ae({context:T,orderedIds:T.orderedIds,selectedMessageId:h,enabled:!A&&!D,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>M?.("reply"),replyAll:()=>M?.("reply-all"),forward:()=>M?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||F.deleteThread()},toggleStar:F.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||m&&b([m.messageId],!m.isRead)},goBrief:()=>i("brief"),goSettings:()=>i("settings")}}),O=n.useCallback(c=>{if(!c)return;const R=o.find(Q=>Q.messageId===c);return R?{threadId:R.threadId,messageId:c}:void 0},[o]),p={selectedMessageId:h,selectedThread:u,conversation:v,onOpenThread:P,onCloseThread:a,nextThread:O(B),previousThread:O(W),actions:w,onReply:E,triage:T,onDeleteMessages:j,handleDeselectIfRemoved:S};return r.jsx(ee.Provider,{value:p,children:e})}function te(){const{selectedMessageId:t,onOpenThread:e,triage:s,onDeleteMessages:a}=q();return r.jsx(st,{selectedMessageId:t,onOpenThread:e,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function rt(){const t=G(),{conversation:e,selectedThread:s,actions:a,onReply:i,handleDeselectIfRemoved:f,onOpenThread:l}=q(),g=!!e,o=Ee(e?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Be,{hasThread:g,intelligenceOpen:o.isShowing,canToggleIntelligence:o.canToggle,onToggleIntelligence:o.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?a.deleteThread:void 0,onToggleStar:g?a.toggleStar:void 0,isStarred:a.isStarred,moveContext:g&&a.accountId&&a.mailboxId?{accountId:a.accountId,currentMailboxId:a.mailboxId,onMove:a.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Y,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:o.open,listOnScreen:!0}):r.jsx(Ie,{})})]}),r.jsx(Z,{isOpen:o.drawerOpen,onClose:o.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:f,onReplyWithText:t,onOpenThread:l})]})}function ot(){const t=G(),{selectedThread:e,handleDeselectIfRemoved:s,onOpenThread:a}=q(),{onToggleIntelligence:i}=z();return r.jsx(qe,{onClose:i,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t,onOpenThread:a})}function nt(){const t=G(),{selectedThread:e,conversation:s,onCloseThread:a,onOpenThread:i,nextThread:f,previousThread:l,handleDeselectIfRemoved:g}=q(),o=De(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Y,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:o.toggle,onSwipeNext:f?()=>i(f):void 0,onSwipePrevious:l?()=>i(l):void 0,mobileIntelligenceOpen:o.isOpen}),r.jsx(Z,{isOpen:o.isOpen,onClose:o.close,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:g,onReplyWithText:t,onOpenThread:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(te,{})})}const ft=Object.assign(at,{List:te,Reading:rt,Intelligence:ot,Phone:nt});export{ft as F};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,c as f,d as m,v as N,j as e,bm as w,X as E}from"./index-
|
|
1
|
+
import{r as n,c as f,d as m,v as N,j as e,bm as w,X as E}from"./index-DkIInRxS.js";import{E as u}from"./ErrorState-CrDfgkFR.js";import{D as r,C as x,u as k}from"./index-DEjCMX0x.js";import{d as p,e as h,f as b}from"./useMessageBodyContent-CR91yAv-.js";import{C as S}from"./confirm-dialog-D9AgcZxD.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=p(),i=h(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},q=()=>{const t=p(),i=h(),s=b(),a=w(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(k({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(E,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{q as F};
|