@remit/web-client-dist 0.0.655 → 0.0.657
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-Bs89y0lU.js → BriefPane-DSaOlf0F.js} +1 -1
- package/assets/{CalendarComposePane-RIGLHEKc.js → CalendarComposePane-BU_sayZB.js} +1 -1
- package/assets/{CalendarComposeSeed-O0lmR5xH.js → CalendarComposeSeed-B3HKxMFT.js} +1 -1
- package/assets/{CalendarShell-refNUS-9.js → CalendarShell-D9HK76un.js} +1 -1
- package/assets/{EmptyState-KNDNyfvT.js → EmptyState-1soLLrUm.js} +1 -1
- package/assets/{ErrorState-DLtcLFLq.js → ErrorState-DPzwHis8.js} +1 -1
- package/assets/{FlaggedPane-DAMAdoUk.js → FlaggedPane-C6qW3NPH.js} +1 -1
- package/assets/{FullCompose-D5RGCLg7.js → FullCompose-rxgtwgLT.js} +1 -1
- package/assets/MailListHeader-BFFGRKyg.js +1 -0
- package/assets/{MailNav-De6DYmQz.js → MailNav-DJlI7RmG.js} +1 -1
- package/assets/{MailShell-CpfkjAiH.js → MailShell-DWiQS--r.js} +1 -1
- package/assets/{MailViewChrome-DCS7j8vw.js → MailViewChrome-HO-DgTY5.js} +1 -1
- package/assets/{MailboxPane-j-fLB3Ye.js → MailboxPane-hAP08rcM.js} +1 -1
- package/assets/{NavMenuButton-BIiSSMjn.js → NavMenuButton-DLvNMRhx.js} +1 -1
- package/assets/{OnboardingWizard-IYzlV8gT.js → OnboardingWizard-BwiBwlF7.js} +1 -1
- package/assets/{OpenCalendarEvent-xuyLG0yl.js → OpenCalendarEvent-BnGbsK2W.js} +1 -1
- package/assets/{OutboxPane-CJGasuMb.js → OutboxPane-BoLQds66.js} +1 -1
- package/assets/_calendarObjectId-Dk6ypYk-.js +1 -0
- package/assets/_mailboxId-BI2fCYSk.js +1 -0
- package/assets/_messageId-BojdkbIt.js +1 -0
- package/assets/_messageId-Br63cxHP.js +1 -0
- package/assets/_messageId-CElscOOg.js +1 -0
- package/assets/_outboxMessageId-B-LOsBw2.js +1 -0
- package/assets/_recurrenceId-CVQPBnfp.js +1 -0
- package/assets/_threadId-CBcvsEMo.js +1 -0
- package/assets/_threadId-DYIW9tHx.js +1 -0
- package/assets/_threadId-DbH9GuNd.js +1 -0
- package/assets/{_view._date-pfHyamYp.js → _view._date-DzTM5JlS.js} +1 -1
- package/assets/{accounts-CWQMjjjw.js → accounts-Dvrx4IYM.js} +1 -1
- package/assets/{advanced-B9ESEu8P.js → advanced-CJg3p5Bv.js} +1 -1
- package/assets/{appearance-CiHhA7B_.js → appearance-C5blyz0O.js} +1 -1
- package/assets/{attendee-row-B6tvnsNs.js → attendee-row-CvGDzdA4.js} +1 -1
- package/assets/{avatar-DlirA5AD.js → avatar-Bb8ScTir.js} +1 -1
- package/assets/{bell-off-CNej-tyT.js → bell-off-CS6Duk18.js} +1 -1
- package/assets/{bottom-sheet-CgDm7M7f.js → bottom-sheet-B5cf6MWK.js} +1 -1
- package/assets/brief-BFYTJF86.js +1 -0
- package/assets/{brief-BUtoJ-S9.js → brief-sKxBiyAp.js} +1 -1
- package/assets/{browser-ponyfill-DXG4VBth.js → browser-ponyfill-GPT1caT6.js} +1 -1
- package/assets/{bug-BxKBPCAb.js → bug-BZRMWJ8e.js} +1 -1
- package/assets/{calendar-CcwoHW3D.js → calendar-Bkx3aBLi.js} +1 -1
- package/assets/{calendar-clash-strip-BkYBh2Wc.js → calendar-clash-strip-BFmDAwFK.js} +1 -1
- package/assets/{calendar-format-Vcjfhlhl.js → calendar-format-Dl_kGdpq.js} +1 -1
- package/assets/{calendar-report-CBxPXQ5J.js → calendar-report-Dq8_JMmG.js} +1 -1
- package/assets/{calendar-suggestion-BifH_0f9.js → calendar-suggestion-CRkDiioj.js} +1 -1
- package/assets/{calendars-Ci1uQYPb.js → calendars-DbaCmJpW.js} +1 -1
- package/assets/{card-C3xvNh4f.js → card-BrGvFBtQ.js} +1 -1
- package/assets/{checkbox-Djhcc-aN.js → checkbox-7X0zR8En.js} +1 -1
- package/assets/chevron-left-BLnMK6Hm.js +1 -0
- package/assets/{circle-check-8zY_9fxi.js → circle-check-BAFZLxGj.js} +1 -1
- package/assets/{circle-check-big-CxFmEow9.js → circle-check-big-BpsV2KD8.js} +1 -1
- package/assets/{circle-help-DjzlhQI0.js → circle-help-BizC7pb0.js} +1 -1
- package/assets/{clock-CCGR0KuX.js → clock-CPsIZ6zJ.js} +1 -1
- package/assets/compose._-_outboxMessageId_-BmM1JqAv.js +1 -0
- package/assets/compose._-_outboxMessageId_-CXeMohJi.js +1 -0
- package/assets/compose._-_outboxMessageId_-ColAL-TU.js +1 -0
- package/assets/compose._-_outboxMessageId_-RC8PrqCU.js +1 -0
- package/assets/{config-import-D5LcCSdy.js → config-import-Dx5GIogE.js} +1 -1
- package/assets/{confirm-dialog-4-i7dCp5.js → confirm-dialog-Cv8nzgk0.js} +1 -1
- package/assets/{copy-C9vgpFVi.js → copy-CkXIeeHD.js} +1 -1
- package/assets/{credential-steps-DwaEJc6L.js → credential-steps-BZUL46-x.js} +1 -1
- package/assets/{download-CB58NRUV.js → download-C4etwdLI.js} +1 -1
- package/assets/{file-json-BbcIndXX.js → file-json-DqsJ4xJs.js} +1 -1
- package/assets/{filters-oms3fU12.js → filters-vQ_2-kyd.js} +1 -1
- package/assets/{flagged-BaJtxdoG.js → flagged-DRgV59IG.js} +1 -1
- package/assets/flagged-DseDsjLu.js +1 -0
- package/assets/{folders-CsI3jXEb.js → folders-DyTauiz9.js} +1 -1
- package/assets/{help-copy-BjGa7WTX.js → help-copy-tJC0-ZMl.js} +1 -1
- package/assets/{import-CKkWJtPs.js → import-CELB-bnR.js} +1 -1
- package/assets/index-B9DvuvdG.js +1 -0
- package/assets/index-BK6Ub1jz.js +1 -0
- package/assets/{index-aDMmeBcR.js → index-BLTKJWNr.js} +4 -4
- package/assets/index-BWg_f2zC.js +1 -0
- package/assets/{index-CDsYDTwV.js → index-BhjCjLJw.js} +1 -1
- package/assets/index-BojdkbIt.js +1 -0
- package/assets/index-CElscOOg.js +1 -0
- package/assets/index-DQGwT3GV.js +1 -0
- package/assets/index-DXKcs-mY.js +1 -0
- package/assets/index-KSHhd0R1.js +1 -0
- package/assets/index-_GSqQaV3.js +1 -0
- package/assets/{index-1mxX3_QN.js → index-owcFTp8Y.js} +49 -49
- package/assets/{kbd-Dp9xZFPh.js → kbd-lTvecOmZ.js} +1 -1
- package/assets/{labels-DNZ1e7DT.js → labels-DiA2JGmB.js} +1 -1
- package/assets/{mail-DxOUbZYP.js → mail-BxwAAW5X.js} +1 -1
- package/assets/{mail-n896QM6q.js → mail-CBC7EsCL.js} +1 -1
- package/assets/{map-pin-DT0APb7b.js → map-pin-D6VMw4yS.js} +1 -1
- package/assets/{menu-DDTDmbUg.js → menu-BQKKG_dY.js} +1 -1
- package/assets/minus-6qNWLdn9.js +1 -0
- package/assets/{new-hy2SkKdJ.js → new-CJ6kSPRF.js} +1 -1
- package/assets/onboarding-GJtMi48D.js +1 -0
- package/assets/{onboarding-completion-fANvE1aI.js → onboarding-completion-BbqmDbx7.js} +1 -1
- package/assets/outbox-B0H34lHj.js +1 -0
- package/assets/{pane-header-svjIOKfC.js → pane-header-Ca09EcL8.js} +1 -1
- package/assets/{pencil-ExQ6Smdq.js → pencil-DiRy6H7l.js} +1 -1
- package/assets/{popover-menu-CfA_guqF.js → popover-menu-B4BMf6LK.js} +1 -1
- package/assets/{refresh-cw-DYBLAWnZ.js → refresh-cw-Bot6vhqM.js} +1 -1
- package/assets/{rich-text-BFUWi7Nd.js → rich-text-BUR-C2Q6.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-DIMyFE6K.js → rich-text-spellcheck-worker-provider-CQ8rF4WA.js} +1 -1
- package/assets/{rotate-ccw-DSWQif2k.js → rotate-ccw-gjLXKk9W.js} +1 -1
- package/assets/{roving-focus-DlpDivMm.js → roving-focus-C3VQzsoq.js} +1 -1
- package/assets/{row-actions-QTX5H6T6.js → row-actions-_wAkj89Q.js} +1 -1
- package/assets/{search-mirror-EZkVoSiC.js → search-mirror-a3wl8YKf.js} +1 -1
- package/assets/{search-token-index-BRB-CGkj.js → search-token-index-BwY3fr3v.js} +1 -1
- package/assets/{sections-CcfWIv_w.js → sections-DKODQMWX.js} +1 -1
- package/assets/{senders-BRquTrmV.js → senders-Dpwg8Gn7.js} +1 -1
- package/assets/settings-CasU94x9.js +1 -0
- package/assets/{settings-screen-BPxMwZwZ.js → settings-screen-3GaT_yCl.js} +1 -1
- package/assets/{shield-check-DyrepgYg.js → shield-check-t1RKp08F.js} +1 -1
- package/assets/{suggested-vips-D9cfCwkN.js → suggested-vips-CAHDehKY.js} +1 -1
- package/assets/{suggestion._suggestionId-DUw3AAsS.js → suggestion._suggestionId-DSs2aOE3.js} +1 -1
- package/assets/{undo-2-BoTZN3H5.js → undo-2-CjsdasNX.js} +1 -1
- package/assets/{useCalendarData-C_jHapm8.js → useCalendarData-BNg59BCE.js} +1 -1
- package/assets/{useCalendarFreeBusy-BSwjpsWR.js → useCalendarFreeBusy-ClOpmxzB.js} +1 -1
- package/assets/{useCalendarWrites-pK8TUq_F.js → useCalendarWrites-onNcOsh0.js} +1 -1
- package/assets/{useCalendars-DOYXyUkA.js → useCalendars-LZefvRrA.js} +1 -1
- package/assets/{useDebouncedValue-DilE1ojx.js → useDebouncedValue-WWRLD9R5.js} +1 -1
- package/assets/{useFilters-BZyGJA1T.js → useFilters-1hN5d4xr.js} +1 -1
- package/assets/{useLabels-D34hpu4A.js → useLabels-C955uVg_.js} +1 -1
- package/assets/{useLayoutTier-rR-Jln8Q.js → useLayoutTier-A889tOk-.js} +1 -1
- package/assets/{useMessageBodyContent-D-AqdxBK.js → useMessageBodyContent-C6R-iTkz.js} +1 -1
- package/assets/{useQueries-CbWwzRRY.js → useQueries-jIdAkC8e.js} +1 -1
- package/assets/{useRefreshControl--3V0DtqJ.js → useRefreshControl-DT4gm04X.js} +1 -1
- package/assets/{useResultFolderIndex-D3dcov_9.js → useResultFolderIndex-CTrDyucm.js} +1 -1
- package/assets/{useSearchTokenContext-WrbDthen.js → useSearchTokenContext-CDbE53C_.js} +1 -1
- package/assets/{useSemanticSearch-DVkDVaeI.js → useSemanticSearch-CX-jW79N.js} +1 -1
- package/assets/{useSignature-DeCpWiaN.js → useSignature-BqhqHAev.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/MailListHeader-BSfcf-IH.js +0 -1
- package/assets/_calendarObjectId-B8_AN3Bn.js +0 -1
- package/assets/_mailboxId-BlL4k3EG.js +0 -1
- package/assets/_messageId-DNpLxhrh.js +0 -1
- package/assets/_messageId-hao7lbIn.js +0 -1
- package/assets/_messageId-yeL7wWhd.js +0 -1
- package/assets/_outboxMessageId-B6CcnXNb.js +0 -1
- package/assets/_recurrenceId-DrkGdj4p.js +0 -1
- package/assets/_threadId-B9g3Td57.js +0 -1
- package/assets/_threadId-SLBw3uKx.js +0 -1
- package/assets/_threadId-ug537Hn6.js +0 -1
- package/assets/brief-CbhnsM9g.js +0 -1
- package/assets/chevron-left-D5AYy_RP.js +0 -1
- package/assets/compose._-_outboxMessageId_-B5OcVfGt.js +0 -1
- package/assets/compose._-_outboxMessageId_-BeyuF_dY.js +0 -1
- package/assets/compose._-_outboxMessageId_-CljpRAaq.js +0 -1
- package/assets/compose._-_outboxMessageId_-Mrz7s9Vh.js +0 -1
- package/assets/flagged-Dcv9ngH7.js +0 -1
- package/assets/index-BcBtoNYg.js +0 -1
- package/assets/index-CSuGKSPO.js +0 -1
- package/assets/index-CtV0MWP7.js +0 -1
- package/assets/index-DNpLxhrh.js +0 -1
- package/assets/index-DxBX22wB.js +0 -1
- package/assets/index-RCzGf3-N.js +0 -1
- package/assets/index-uNpkWH7c.js +0 -1
- package/assets/index-x5-XjHud.js +0 -1
- package/assets/index-yeL7wWhd.js +0 -1
- package/assets/minus-BuYcA1Hp.js +0 -1
- package/assets/onboarding-DE5r6wOh.js +0 -1
- package/assets/outbox-CKS-pjfb.js +0 -1
- package/assets/settings-BAeuWCVE.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dh as or,e as ce,r as l,j as t,_ as De,$ as gt,L as Tn,t as E,a0 as ir,g as ye,di as lr,dj as An,dk as En,dl as Ls,a7 as cr,f as Q,X as qe,a3 as ds,aB as Ds,Y as dr,b9 as ur,dg as Os,dm as Fn,Z as He,dn as mr,dp as fr,dq as hr,W as Qe,dr as Ln,bJ as xt,ds as pr,bs as gr,dt as xr,du as br,dv as vr,dw as yr,dx as Dn,d9 as jr,aM as kr,dy as Cr,B as On,dz as Nr,dA as wr,dB as Sr,dC as Ir,dD as Rr,dE as Mr,w as Tr,cH as zn,d4 as Pn,c as se,d as We,K as us,dF as Ar,dG as Er,dH as zs,h as ue,at as be,i as pe,E as Ce,F as Ne,Q as ms,cy as we,dI as Ps,dJ as is,aJ as Fr,dK as fs,dL as Se,dM as hs,dN as ps,dO as gs,dP as Lr,dQ as Dr,dR as _t,cF as Or,s as _n,dS as zr,dT as Pr,dU as _r,b6 as Br,cp as Ur,G as _s,c_ as Bn,c$ as $r,dV as Kr,bq as bt,bt as Un,bn as $n,bu as Kn,bv as qn,bw as qr,dW as Qr,ab as Qn,cO as Hr,dX as ls,dY as Wr,aH as Gr,aI as Vr,dZ as Jr,bf as Hn,d_ as Yr,d$ as Zr,e0 as Wn,e1 as Xr,H as Gn,e2 as eo,bR as vt,e3 as so,cQ as Ge,e4 as Bt,e5 as Vn,bT as to,e6 as et,e7 as no,bS as ao,S as ro,q as oo,ah as Jn,J as io,e8 as lo,e9 as co,ea as uo,d3 as Ut,bD as mo,eb as fo,ec as ho,av as po,cS as go,d1 as xo,ed as bo,ai as vo,d2 as yo,ee as jo,ef as ko,eg as Co,eh as No,C as xs,ei as wo,ej as So,ek as $t,el as Io,em as Ro,en as Mo,eo as To,v as Yn,df as Ao,ep as yt,eq as Eo,er as Fo,cq as Lo,cn as Do,es as Oo,bU as zo,et as Zn,cr as Po}from"./index-owcFTp8Y.js";import{u as _o,L as Bo,a as Uo}from"./roving-focus-C3VQzsoq.js";import{j as $o,S as Xn,f as Ko,a as qo,t as ns,c as Qo,k as Ho,l as Wo,m as Go,u as Vo}from"./search-token-index-BwY3fr3v.js";import{K as Jo}from"./kbd-lTvecOmZ.js";import{c as ea,P as Yo,E as Zo}from"./popover-menu-B4BMf6LK.js";import{M as Xo}from"./mail-BxwAAW5X.js";import{A as cs}from"./avatar-Bb8ScTir.js";import{M as ei,a as si,b as sa,c as ti,s as ta,d as na,e as ni,f as ai,S as Kt,g as aa,u as ra,p as ri,r as oi}from"./useSearchTokenContext-CDbE53C_.js";import{P as Bs,f as ii,C as li,D as $e,s as ci,a as di,e as qt,b as ui,c as mi,d as fi,g as Qt,i as hi,u as pi}from"./index-BLTKJWNr.js";import{E as ot}from"./EmptyState-1soLLrUm.js";import{E as Le}from"./ErrorState-DPzwHis8.js";import{U as gi}from"./undo-2-CjsdasNX.js";import{D as xi}from"./download-C4etwdLI.js";import{s as bi,b as vi,Z as yi,E as ji,C as ki,e as Ci,u as Ni,d as wi}from"./useCalendarFreeBusy-ClOpmxzB.js";import{C as it,m as Si,j as Ii,n as Ri,o as Ht,k as Wt,p as Mi,s as Gt,q as Ti,v as Ai,t as Ei,x as Fi}from"./calendar-suggestion-CRkDiioj.js";import{c as Li,t as Di,v as Oi,x as zi,y as Pi,z as Vt}from"./calendar-format-Dl_kGdpq.js";import{R as _i}from"./attendee-row-CvGDzdA4.js";import{C as Bi}from"./calendar-clash-strip-BFmDAwFK.js";import{C as oa}from"./clock-CPsIZ6zJ.js";import{M as Ui}from"./map-pin-D6VMw4yS.js";import{B as ia}from"./bell-off-CS6Duk18.js";import{S as $i,C as la}from"./shield-check-t1RKp08F.js";import{u as Ki,a as qi,i as Qi,t as Hi,d as Wi,r as Gi}from"./useCalendars-LZefvRrA.js";import{c as Vi}from"./calendar-report-Dq8_JMmG.js";import{u as ca}from"./useDebouncedValue-WWRLD9R5.js";import{j as Jt,u as Ji,a as Yi,k as Zi,n as Xi,o as el,l as sl,S as tl}from"./useFilters-1hN5d4xr.js";import{u as jt}from"./useQueries-jIdAkC8e.js";import{C as nl}from"./checkbox-7X0zR8En.js";import{C as Ns}from"./confirm-dialog-Cv8nzgk0.js";import{u as al,i as rl}from"./useLayoutTier-A889tOk-.js";import{r as ol,a as il}from"./search-scope-B5-OK3Cq.js";import{M as ll}from"./menu-BQKKG_dY.js";function cl(...e){return(...s)=>{for(let n of e)typeof n=="function"&&n(...s)}}let lt=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{lt.delete(e)});function dl(e,s){if(e===s)return e;let n=lt.get(e);if(n)return n.forEach(r=>r.current=s),s;let a=lt.get(s);return a?(a.forEach(r=>r.current=e),e):s}function ul(...e){return e.length===1&&e[0]?e[0]:s=>{let n=!1;const a=e.map(r=>{const o=Yt(r,s);return n||=typeof o=="function",o});if(n)return()=>{a.forEach((r,o)=>{typeof r=="function"?r():Yt(e[o],null)})}}}function Yt(e,s){if(typeof e=="function")return e(s);e!=null&&(e.current=s)}function da(...e){let s={...e[0]};for(let n=1;n<e.length;n++){let a=e[n];for(let r in a){let o=s[r],i=a[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?s[r]=cl(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?s[r]=or(o,i):r==="id"&&o&&i?s.id=dl(o,i):r==="ref"&&o&&i?s.ref=ul(o,i):s[r]=i!==void 0?i:o}}return s}const Us=ce("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ml=ce("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const fl=ce("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const ua=ce("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const ma=ce("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);const hl=ce("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const pl=ce("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);const kt=ce("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const fa=ce("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);const Ct=ce("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const Ve=ce("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const gl=ce("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const xl=ce("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);const bl=ce("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),vl=({address:e,showTrustedBadge:s=!1})=>{const n=s?t.jsx(Us,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}):null;return e.displayName?t.jsxs("span",{children:[t.jsx("span",{className:"text-fg",children:e.displayName}),t.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),n]}):t.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,n]})},yl=({label:e,addresses:s,showTrustedBadge:n=!1})=>{const[a,r]=l.useState(!1);if(s.length===0)return null;const o=s.length>3,i=c=>{const u=n&&c.flags?.trusted?.value===!0;return t.jsx(vl,{address:c,showTrustedBadge:u})};return t.jsxs("div",{className:"flex gap-2 text-sm",children:[t.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),t.jsx("div",{className:"flex-1 min-w-0",children:a?t.jsx("div",{className:"flex flex-wrap gap-1",children:s.map((c,u)=>t.jsxs("span",{children:[i(c),u<s.length-1&&", "]},u))}):t.jsx("div",{className:"truncate",children:s.map((c,u)=>t.jsxs("span",{children:[i(c),u<s.length-1&&", "]},u))})}),o&&t.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r(!a)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":a?"Collapse":"Expand",children:a?t.jsx(De,{className:"h-4 w-4"}):t.jsx(gt,{className:"h-4 w-4"})})]})};function jl({state:e,onRetry:s}){return t.jsxs("div",{role:"alert","data-testid":"attachment-error",className:"flex items-start gap-2 border-t border-danger/30 bg-danger-soft px-2 py-2 text-xs",children:[t.jsx(ir,{className:"mt-0.5 size-3.5 shrink-0 text-danger","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-medium text-danger",children:e.title}),t.jsx("p",{className:"mt-0.5 text-fg-muted",children:e.detail})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:s,className:"font-medium text-accent hover:underline",children:"Try again"}),e.reportUrl&&t.jsx("a",{href:e.reportUrl,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report this"})]})]})}function kl({attachments:e,onDownload:s,hasUnlistedAttachment:n=!1,className:a}){return e.length===0&&!n?null:t.jsxs("section",{"aria-label":"Attachments","data-testid":"attachment-list",className:E("space-y-1.5",a),children:[t.jsxs("h3",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:[t.jsx(Bs,{className:"size-3","aria-hidden":!0}),e.length===0?"Attachment":e.length===1?"1 attachment":`${e.length} attachments`]}),e.length>0&&t.jsx("ul",{className:"overflow-hidden rounded-sm border border-line bg-surface",children:e.map(r=>{const o=r.download.status==="downloading";return t.jsxs("li",{className:"border-t border-line first:border-t-0",children:[t.jsxs("button",{type:"button",onClick:()=>s(r.attachmentId),disabled:o,"data-testid":"attachment-download","aria-label":`Download ${r.filename}`,className:"flex w-full items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("bdi",{className:"block truncate text-sm text-fg",title:r.filename,children:r.filename}),t.jsxs("span",{className:"block truncate text-2xs text-fg-subtle",children:[r.typeLabel," ·"," ",ii(r.sizeOctets)]})]}),o?t.jsx(Tn,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):t.jsx(xi,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0})]}),r.download.status==="failed"&&t.jsx(jl,{state:r.download,onRetry:()=>s(r.attachmentId)})]},r.attachmentId)})}),n&&t.jsx("p",{role:"alert","data-testid":"attachment-unlisted",className:"rounded-sm border border-line bg-surface px-2 py-2 text-xs text-fg-muted",children:"The mail server says this message carries an attachment, but none of its parts describe one. Re-sync the account from Settings; if the attachment still does not appear, the message is worth reporting."})]})}function Cl({label:e,onUndo:s,undoLabel:n="Undo",filtersHref:a,className:r}){return t.jsxs(ye,{tone:"accent",className:E("py-1 text-xs",r),children:[t.jsx(gi,{className:"size-3.5 shrink-0","aria-hidden":!0}),t.jsx("span",{children:e}),s&&t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),s()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:n}),a&&t.jsx("a",{href:a,onClick:o=>{o.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:"Manage filter"})]})}const Zt=10,Nl={kind:"unknown"},st=e=>e.toLocaleString();function wl({section:e,Row:s,selectedThreadId:n,initialExpanded:a=!1,initialCollapsed:r=!1,onShowAll:o,onRetry:i,onSelectThread:c}){const[u,b]=l.useState(a),[v,j]=l.useState(r),g=e.threads,p=e.loading===!0,m=e.error===!0,f=g.length>Zt,h=!u&&f?g.slice(0,Zt):g,y=e.total??Nl,x=y.kind==="exact"&&(g.length>0||p)&&!m?st(y.value):void 0,k=y.kind==="exact"?y.value>h.length:e.atCap===!0,C=o!==void 0&&h.length>0&&k?y.kind==="exact"?`Show all ${st(y.value)}`:"Show all":void 0,I=g.length-h.length;return t.jsxs("div",{children:[e.label&&t.jsxs("button",{type:"button","data-section-header":"","aria-expanded":!v,onClick:()=>j(M=>!M),className:"sticky top-0 z-10 flex h-section-row w-full items-center gap-1.5 border-b border-line bg-surface-sunken px-row-inset text-left outline-none transition-colors hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[t.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),x!==void 0&&t.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:x}),t.jsx(De,{className:E("size-3 shrink-0 text-fg-subtle transition-transform duration-200",v?"rotate-0":"rotate-180")})]}),!v&&t.jsxs(t.Fragment,{children:[g.length===0?m?t.jsxs("div",{className:"flex flex-col items-center gap-1 border-b border-line px-row-inset py-4 text-center text-2xs text-danger",children:[t.jsx("span",{children:`Couldn't load ${e.label??"these messages"}`}),i&&t.jsx("button",{type:"button",onClick:i,className:"font-medium text-accent underline outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Try again"})]}):p?t.jsx("div",{className:"animate-pulse divide-y divide-line",children:[0,1,2].map(M=>t.jsx("div",{className:"px-row-inset py-3",children:t.jsx("div",{className:"h-3 w-2/3 rounded bg-surface-sunken"})},M))}):t.jsx("p",{className:"border-b border-line px-row-inset py-4 text-center text-2xs text-fg-subtle",children:e.label?`No ${e.label} mail in this brief.`:"No mail in this brief."}):t.jsx("div",{className:"divide-y divide-line",children:h.map(M=>t.jsx(s,{thread:M,active:M.id===n,onClick:()=>c?.(M.id)},M.id))}),C!==void 0?t.jsxs("button",{type:"button",onClick:o,className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent outline-none transition-colors hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[C,t.jsx(gt,{className:"ml-1 size-3"})]}):f&&t.jsxs("button",{type:"button",onClick:()=>b(M=>!M),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent outline-none transition-colors hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[u?"Show less":`Show ${st(I)} more`,!u&&t.jsx(De,{className:"ml-1 size-3"})]})]})]})}function wf({sections:e,briefCategory:s="all",selectedThreadId:n,Row:a,keyboard:r,onSelectThread:o,onShowAllSection:i,onRetrySection:c,flat:u=!1,onSelectBriefCategory:b,sources:v,sourcesNote:j,onSelectSource:g,activeFilters:p,onToggleFilter:m,onClearFilters:f,hideChrome:d,defaultExpanded:h=!1}){const[y,x]=l.useState(h),k=l.useRef(null);_o({containerRef:k,itemSelector:Bo,enabled:!lr(r)});const C=!u&&(s==="all"||e.some(A=>A.total!==void 0)),I=e.filter(A=>A.threads.length>0||A.total!==void 0||A.loading===!0||A.error===!0),M=e.flatMap(A=>A.threads),w=En,N=C?I.length===0:M.length===0,T=t.jsxs("div",{ref:k,children:[C?I.map(A=>t.jsx(wl,{section:A,Row:a,selectedThreadId:n,onSelectThread:o,onShowAll:i?()=>i(A.id):void 0,onRetry:c?()=>c(A.id):void 0},A.id)):t.jsx("div",{className:"divide-y divide-line",children:M.map(A=>t.jsx(a,{thread:A,active:A.id===n,onClick:()=>o?.(A.id)},A.id))}),N&&t.jsx("div",{className:"px-row-inset py-6 text-center text-2xs text-fg-subtle",children:"No threads match these filters."})]});return t.jsx(An,{categories:[...Ls],filters:w,sources:v,sourcesNote:j,selectedCategory:s,activeFilters:p,expanded:y,onExpandedChange:x,onSelectCategory:A=>b?.(A),onSelectSource:g,onToggleFilter:A=>m(A),onClear:f,hideChrome:d,children:T})}const Sl={ics:"Attached invitation",markup:"Structured markup",pattern:"Read from the words"},Il={ics:cr,markup:fl,pattern:bl},Rl={ics:"border-positive/50 text-positive",markup:"border-accent-2/50 text-accent-2",pattern:"border-warning/50 text-warning"};function Ml({method:e,className:s}){const n=Il[e];return t.jsxs("span",{className:E("inline-flex items-center gap-1 rounded-sm border px-1.5 py-0.5 text-2xs font-medium",Rl[e],s),children:[t.jsx(n,{className:"size-3","aria-hidden":!0}),Sl[e]]})}const Tl=["accepted","tentative","declined","noReply"],Al={accepted:"coming",tentative:"maybe",declined:"not coming",noReply:"no reply"},El=(e,s)=>e==="dismissed"?"You dismissed this":s==="declined"?"You declined":"On your calendar";function Fl({invite:e,whenText:s,calendarName:n,color:a,clashes:r,rsvp:o,onAdd:i,onTentative:c,onDecline:u,onReopen:b,onOfferOtherTimes:v,mute:j,onRemove:g,onOpenNewer:p,guests:m,busy:f=!1,failure:d="",reportHref:h,addBlocked:y,touch:x,className:k}){const C=Li(a),I=e.state==="superseded"||e.state==="cancelled",M=e.proposed.attendees,w=Tl.map(N=>({state:N,count:M.filter(T=>T.rsvp===N).length})).filter(N=>N.count>0).map(N=>`${N.count} ${Al[N.state]}`).join(" · ");return t.jsxs("section",{className:E("flex flex-col gap-3 rounded-lg border border-line bg-surface-raised p-3",k),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:E("size-2.5 shrink-0 rounded-full",C.solid)}),t.jsxs("span",{className:"min-w-0 flex-1 truncate text-2xs uppercase tracking-wider text-fg-subtle",children:["Invitation from ",e.organizerName," · ",n]}),t.jsx(Ml,{method:e.method})]}),t.jsxs("div",{className:E(I&&"opacity-60"),children:[t.jsx("h3",{className:"text-md font-semibold text-fg",children:e.proposed.title}),t.jsxs("p",{className:"mt-1 flex items-center gap-2 text-sm text-fg",children:[t.jsx(oa,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),s]}),e.proposed.location!==""&&t.jsxs("p",{className:"mt-1 flex items-center gap-2 text-sm text-fg-muted",children:[t.jsx(Ui,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.proposed.location]})]}),e.state==="superseded"&&t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/40 bg-warning-soft p-2",children:[t.jsx(hl,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-xs font-semibold text-warning",children:[e.organizerName," has sent a newer version of this."]}),t.jsxs("p",{className:"mt-1 text-xs text-fg",children:["This one is revision ",e.sequence," and is out of date. The newer message carries the one to answer."]}),p&&t.jsx(Q,{variant:"secondary",size:x?"md":"sm",onClick:p,className:E("mt-2",x&&"min-h-11"),children:"Open the newer invitation"})]})]}),e.state==="cancelled"&&t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft p-2",children:[t.jsx(qe,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-xs font-semibold text-danger",children:[e.organizerName," cancelled this."]}),t.jsx("p",{className:"mt-1 text-xs text-fg",children:"It is still on your calendar. Nothing comes off it until you say so."}),g&&t.jsxs("div",{className:E("mt-2 flex gap-2",x&&"flex-wrap"),children:[t.jsx(Q,{variant:"primary",size:x?"md":"sm",icon:t.jsx(ds,{className:"size-3.5"}),onClick:g,disabled:f||y!==void 0,className:E(x&&"min-h-11 flex-1"),children:"Remove from calendar"}),b&&t.jsx(Q,{variant:"secondary",size:x?"md":"sm",onClick:b,disabled:f,className:E(x&&"min-h-11 flex-1"),children:"Keep it"})]})]})]}),!I&&t.jsx(Bi,{clashes:r}),m??(M.length>0&&t.jsxs("p",{className:"text-2xs uppercase tracking-wider text-fg-subtle",children:[M.length," guests",w===""?"":` · ${w}`]})),d!==""&&t.jsx(it,{text:d,reportHref:h}),y!==void 0&&t.jsx("div",{className:"rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg",children:y}),!I&&(o==="noReply"&&e.state!=="dismissed"?t.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[t.jsxs("div",{className:E("flex gap-2",x&&"flex-wrap"),children:[t.jsx(Q,{variant:"primary",size:x?"md":"sm",icon:t.jsx(ml,{className:"size-3.5"}),onClick:i,disabled:f||y!==void 0,className:E(x&&"min-h-11 flex-1"),children:"Add to calendar"}),c&&t.jsx(Q,{variant:"secondary",size:x?"md":"sm",onClick:c,disabled:f||y!==void 0,className:E(x&&"min-h-11 flex-1"),children:"Maybe"}),t.jsx(Q,{variant:"secondary",size:x?"md":"sm",icon:t.jsx(qe,{className:"size-3.5"}),onClick:u,disabled:f,className:E(x&&"min-h-11 flex-1"),children:"Decline"})]}),t.jsx(Q,{variant:"ghost",size:x?"md":"sm",onClick:v,className:E("self-start",x&&"min-h-11 w-full"),children:"Offer other times"}),j&&t.jsx(Q,{variant:"ghost",size:x?"md":"sm",icon:t.jsx(ia,{className:"size-3.5"}),onClick:j.onMute,disabled:f,className:E("self-start",x&&"min-h-11 w-full"),children:`Stop offering invitations from ${j.sender}`}),t.jsxs("p",{className:"text-2xs text-fg-subtle",children:[e.organizerName," is not notified. Reader writes this to your calendar and sends no reply — tell them in the thread."]})]}):t.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-fg",children:[El(e.state,o),e.state!=="dismissed"&&t.jsx(_i,{rsvp:o})]}),b&&t.jsx(Q,{variant:"ghost",size:x?"md":"sm",onClick:b,disabled:f,className:x?"min-h-11":"",children:"Change"}),o==="declined"&&t.jsx(Q,{variant:"secondary",size:x?"md":"sm",onClick:v,className:x?"min-h-11":"",children:"Offer other times"})]}),t.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-fg-subtle",children:[t.jsx(Ds,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.organizerName," was not notified."]})]}))]})}function Ll({slots:e,picked:s,onToggle:n,emptyText:a="Nothing free that day at this length.",touch:r,scroll:o,className:i}){return e.length===0?t.jsx("p",{className:E("text-xs text-fg-muted",i),children:a}):t.jsx("div",{className:E("flex gap-2",o?"overflow-x-auto pb-1":"flex-wrap",i),children:e.map(c=>{const u=s.has(c.startTime);return t.jsxs("button",{type:"button","aria-pressed":u,onClick:()=>n(c),className:E("shrink-0 rounded-md border px-2 text-xs tabular-nums outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",r?"min-h-11 px-3":"h-7",u?"border-accent bg-accent-soft font-semibold text-accent":"border-line bg-surface text-fg-muted hover:border-line-strong hover:text-fg"),children:[c.startTime," – ",c.endTime]},c.startTime)})})}function xe({label:e,children:s,className:n}){return t.jsxs("section",{className:E("border-b border-line px-row-inset py-3",n),children:[t.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t.jsx("div",{className:"mt-2",children:s})]})}function Dl({data:e,actions:s,selectedEventId:n="",touch:a,className:r}){const{invite:o,prose:i,suggestions:c,day:u,dayLabel:b,suggestionsBusy:v=!1,failure:j="",suggestionsFailure:g="",reportHref:p,addBlocked:m}=e,{onReviewSuggestion:f,onOpenThread:d}=s,[h,y]=l.useState({}),x=c[0],k=x===void 0?"":h[x.suggestion.id]??"",C=x===void 0?void 0:bi(x.suggestion,k),I=new Set(i?.picked??[]);return j===""&&o===void 0&&i===void 0&&c.length===0&&u.length===0?t.jsxs("div",{className:E("flex flex-1 flex-col items-center justify-center gap-2 px-row-inset py-10 text-center",r),children:[t.jsx(dr,{className:"size-6 text-fg-subtle","aria-hidden":!0}),t.jsx("p",{className:"text-sm text-fg-muted",children:"Nothing in this message is about a time."}),t.jsx("p",{className:"text-2xs text-fg-subtle",children:"An invitation, a booking or a thread proposing hours would show up here, with the day it lands on."})]}):t.jsxs("div",{className:E("flex flex-col",r),children:[j!==""&&t.jsx(it,{text:j,reportHref:p,className:"mx-row-inset mt-3"}),o&&t.jsx(xe,{label:"Invitation",children:t.jsx(Fl,{invite:o.invite,whenText:o.whenText,calendarName:o.calendarName,color:o.color,clashes:o.clashes,rsvp:o.rsvp,busy:o.busy,failure:o.failure,reportHref:o.reportHref,addBlocked:o.addBlocked,mute:s.onMuteInvite&&o.sender?{sender:o.sender,onMute:s.onMuteInvite}:void 0,onAdd:s.onAddInvite,onTentative:s.onTentativeInvite,onDecline:s.onDeclineInvite,onReopen:s.onReopenInvite,onOfferOtherTimes:s.onOfferOtherTimes,onRemove:s.onRemoveInvite,onOpenNewer:s.onOpenNewerInvite,touch:a})}),i&&t.jsxs(xe,{label:i.proposals.length>0?`Times named · ${i.dayLabel}`:`Other times · ${i.dayLabel}`,children:[t.jsx("ul",{className:E("flex flex-col gap-1",i.proposals.length===0&&"hidden"),children:i.proposals.map(w=>t.jsxs("li",{className:"flex items-baseline gap-2 text-xs",children:[t.jsx("span",{className:"w-24 shrink-0 truncate tabular-nums text-fg",children:w.phrase}),w.clashTitle===""?t.jsx("span",{className:"min-w-0 flex-1 truncate text-positive",children:"Nothing booked"}):t.jsxs("span",{className:"min-w-0 flex-1 truncate text-danger",children:[w.clashTitle," is already there"]})]},w.id))}),t.jsx("p",{className:"mt-3 pb-1.5 text-2xs uppercase tracking-wider text-fg-subtle",children:"Free, half an hour each"}),t.jsx(Ll,{slots:i.slots,picked:I,onToggle:s.onToggleSlot,touch:a,scroll:!0}),s.onReplyWithSlots?t.jsxs("div",{className:"mt-2 flex flex-col gap-1.5",children:[t.jsx(Q,{variant:"secondary",size:a?"md":"sm",icon:t.jsx(Ct,{className:"size-3.5"}),onClick:s.onReplyWithSlots,disabled:I.size===0,className:E("self-start",a&&"min-h-11"),children:"Reply with these times"}),t.jsx("p",{className:"text-2xs text-fg-subtle",children:"Picked slots go into the reply as plain text. Nothing is booked."})]}):t.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Picked slots go into the reply as plain text. Nothing is booked."})]}),c.length>0&&t.jsxs(xe,{label:"Read out of this thread",children:[t.jsx(vi,{hasCard:x!==void 0,remaining:c.length,blocked:C!==void 0&&!C.settled,blockedReason:yi,onConfirm:()=>{x&&C?.settled&&m===void 0&&s.onAddSuggestion(x.suggestion.id,C.timeZone)},onReject:()=>{x&&s.onDismissSuggestion(x.suggestion.id)},children:x&&t.jsx(ji,{suggestion:x.suggestion,whenText:x.whenText,addLabel:"Add to calendar",zoneChoice:k,onZoneChoice:w=>y(N=>({...N,[x.suggestion.id]:w})),onAdd:w=>s.onAddSuggestion(x.suggestion.id,w),onReview:f&&(w=>f(x.suggestion.id,w)),onDismiss:()=>s.onDismissSuggestion(x.suggestion.id),onOpenThread:d&&(()=>d(x.suggestion.threadId)),busy:v,addBlocked:m!==void 0,touch:a})}),m!==void 0&&t.jsx("div",{className:"mt-2 rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg",children:m}),g!==""&&t.jsx(it,{text:g,reportHref:p,className:"mt-2"}),t.jsx("p",{className:"mt-2 text-2xs text-fg-subtle",children:"None of this is on your calendar, and none of it will be until you say so."})]}),u.length>0&&t.jsx(xe,{label:b,className:"border-b-0",children:t.jsx("ul",{className:"flex flex-col gap-1",children:u.map(w=>t.jsx("li",{children:t.jsx(ki,{title:w.event.title,timeText:w.timeText,color:w.color,layout:"row",density:"compact",rsvp:w.event.myRsvp,status:w.event.status,hasThread:w.event.threadId!=="",isRecurring:w.event.recurrenceRule!=="",zoneCertainty:w.event.zoneCertainty,selected:w.event.id===n,onClick:()=>s.onSelectEvent(w.event.id)})},w.event.id))})})]})}const Ol=[{value:"sender",label:"Sender"},{value:"calendar",label:"Calendar"}],zl={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function Pl({sender:e}){const s=zl[e.trust],n=e.inboundCount==null?null:(e.replyCount??0)>0?`${e.inboundCount} received · you replied ${e.replyCount}×`:`${e.inboundCount} received · you've never replied`;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(cs,{name:e.name,email:e.email,size:"md"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),t.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),t.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?t.jsx(ye,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):t.jsx(ye,{tone:s.tone,dot:!0,children:s.label})}),t.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,n?` · ${n}`:""]})]})}function _l({auth:e,onShowSimilar:s}){if(e.verdict==="aligned")return t.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[t.jsx($i,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),t.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return t.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[t.jsx(gl,{className:"mt-0.5 size-4 shrink-0"}),t.jsx("p",{className:"text-xs leading-relaxed",children:e.summary})]});const n=e.addressUnreadable?"This sender can't be verified":"This message may be impersonating someone";return t.jsxs("div",{className:"rounded-md bg-danger-soft p-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Ve,{className:"mt-0.5 size-4 shrink-0 text-danger"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold text-danger",children:n}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&t.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",t.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",t.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]}),e.similarCount!=null&&e.similarCount>0&&t.jsxs(Q,{variant:"secondary",size:"sm",className:"mt-2 w-full border-danger/30 text-danger hover:bg-danger-soft",onClick:s,children:[e.similarCount," similar messages"]})]})}function ws({icon:e,label:s,active:n,danger:a,onClick:r,pending:o}){const i=r===void 0||o===!0;return t.jsxs("button",{type:"button",onClick:r,disabled:i,className:E("flex items-center gap-2 rounded-md border px-2 py-1 text-xs transition-colors",n?"border-accent-2 bg-accent-2-soft text-accent-2":"border-line text-fg-muted hover:border-line-strong hover:text-fg",a&&!n&&"text-danger hover:bg-danger-soft",i&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,s]})}const Bl={sender:"matched: sender",recipient:"matched: recipient",subject:"matched: subject",attachment:"matched: attachment",body:"matched: body",entities:"matched: entities"};function ha({data:e,onClose:s,onShowSimilar:n,actions:a,similarState:r="ready",similarLinkComponent:o,className:i,hideCloseButton:c=!1,reportSpamPending:u=!1,notSpamPending:b=!1,calendar:v,tab:j,onTabChange:g,defaultTab:p="sender",touch:m}){const{sender:f,authenticity:d,category:h,flags:y={},similar:x}=e,[k,C]=l.useState(p),I=l.useId(),M=j??k,w=v!==void 0&&M==="calendar"?v:void 0;return t.jsxs("aside",{className:E("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",i),children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[t.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!c&&t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(qe,{className:"size-3.5"}),onClick:s,"aria-label":"Collapse intelligence sidebar"})]}),v&&t.jsx("div",{className:"flex shrink-0 justify-center border-b border-line px-row-inset py-2",children:t.jsx(ur,{name:I,"aria-label":"What this panel is showing",size:"sm",options:Ol,value:M,onChange:N=>{j===void 0&&C(N),g?.(N)}})}),w&&t.jsx(Dl,{data:w.data,actions:w.actions,selectedEventId:w.selectedEventId,touch:m}),w===void 0&&t.jsxs(t.Fragment,{children:[t.jsx(xe,{label:"Sender",children:t.jsx(Pl,{sender:f})}),t.jsx(xe,{label:"Authenticity",children:t.jsx(_l,{auth:d,onShowSimilar:n})}),t.jsx(xe,{label:"Category",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ye,{tone:Fn[h.value],children:Os[h.value]}),h.overridden&&t.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),t.jsx("button",{type:"button",className:E("ml-auto text-2xs text-accent hover:underline",!a?.onReclassify&&"cursor-not-allowed opacity-50 hover:no-underline"),disabled:!a?.onReclassify,onClick:a?.onReclassify,children:"reclassify"})]})}),t.jsxs(xe,{label:"Quick actions",children:[t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsx(ws,{icon:t.jsx(He,{className:"size-3.5"}),label:"VIP",active:y.vip,onClick:a?.onToggleVip}),t.jsx(ws,{icon:t.jsx(ia,{className:"size-3.5"}),label:"Mute",active:y.muted,onClick:a?.onToggleMute}),a?.onNotSpam&&t.jsx(ws,{icon:t.jsx(pl,{className:"size-3.5"}),label:b?"Undoing…":"Not spam",active:!0,onClick:a.onNotSpam,pending:b}),a?.onReportSpam&&t.jsx(ws,{icon:t.jsx(xl,{className:"size-3.5"}),label:u?"Reporting…":"Report spam",danger:!0,onClick:a.onReportSpam,pending:u})]}),a?.onNotSpam&&t.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"You reported this message as spam"})]}),(r!=="ready"||x.length>0)&&t.jsx(xe,{label:"Similar messages",children:r==="loading"?t.jsx("div",{className:"animate-pulse space-y-2",children:Array.from({length:3}).map((N,T)=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-sunken"}),t.jsx("div",{className:"h-2.5 w-1/2 rounded bg-surface-sunken"})]},T))}):r==="error"?t.jsx("p",{className:"text-xs text-fg-subtle",children:"Similarity search unavailable"}):r==="off"?t.jsxs("div",{className:"space-y-1.5 text-xs text-fg-subtle",children:[t.jsx("p",{className:"text-fg-muted",children:mr}),t.jsx("p",{children:fr}),t.jsxs("p",{children:["Run"," ",t.jsx("code",{className:"rounded bg-surface-sunken px-1 py-px text-2xs text-fg-muted",children:hr})," ","on the server."]})]}):t.jsx("ul",{className:"-mx-1 space-y-1",children:x.map(N=>{const T="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",A=`Open message from ${N.fromName||"unknown sender"}: ${N.subject}`,K=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-fg",children:N.fromName}),t.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:N.timeLabel})]}),t.jsx("div",{className:"truncate text-xs text-fg-muted",children:N.subject}),t.jsx("span",{className:"mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle",children:Bl[N.matched]})]});return t.jsx("li",{children:o?o({mailboxId:N.mailboxId,threadId:N.threadId,messageId:N.id,className:T,ariaLabel:A,children:K}):t.jsx("div",{className:T,children:K})},N.id)})})}),t.jsx(xe,{label:"Coming soon",className:"border-b-0 opacity-70",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[t.jsx(Qe,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),t.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[t.jsx(Qe,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),t.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})]})}function Ul({open:e=!1,enabled:s=!0,onToggle:n,className:a}){return t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(Ln,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!s,onClick:n,className:E(e&&"bg-accent-2-soft text-accent-2",a)})}function Sf({hints:e=$o,className:s}){return e.length===0?null:t.jsx("footer",{className:E("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",s),children:e.map(n=>t.jsx($l,{hint:n},n.label))})}function $l({hint:e}){return t.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(s=>t.jsx(Jo,{children:s},s)),t.jsx("span",{children:e.label})]})}function Kl({hasThread:e,onUnavailable:s,unavailableHint:n,isStarred:a,showTriage:r=!0,onReply:o,onReplyAll:i,onForward:c,onDelete:u,onToggleStar:b,moveSlot:v,onMove:j,replyTitle:g="Reply (r)",replyAllTitle:p="Reply all (a)",forwardTitle:m="Forward (f)",deleteTitle:f="Move to Trash (#)",flagTitle:d="Star (s)",children:h,className:y}){const x=(k,C)=>()=>{if(!e||!C){s?.(k);return}C()};return t.jsxs("div",{className:"relative",children:[t.jsxs("header",{className:E("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",y),children:[t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(Ct,{className:"size-4"}),title:g,"aria-label":"Reply",onClick:x("reply",o)}),t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(fa,{className:"size-4"}),title:p,"aria-label":"Reply all",onClick:x("replyAll",i)}),t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(ma,{className:"size-4"}),title:m,"aria-label":"Forward",onClick:x("forward",c)}),r&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(ds,{className:"size-4"}),title:f,"aria-label":"Move to Trash",onClick:x("delete",u)}),v??t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(xt,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:x("move",j)}),t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(He,{className:E("size-4",a&&"fill-warning text-warning")}),title:d,"aria-label":"Star","aria-pressed":a,onClick:x("flag",b)})]}),t.jsx("div",{className:"flex-1"}),h]}),n&&t.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:n})]})}const ct=e=>({shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey}),Xt=e=>e.shiftKey||e.metaKey||e.ctrlKey,ql=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",Ql=(e,s)=>!s&&e>0,Hl=(e,s,n)=>{const a=e.indexOf(n);if(a===-1)return[];const r=s===void 0?-1:e.indexOf(s);if(r===-1)return[n];const o=Math.min(r,a),i=Math.max(r,a);return e.slice(o,i+1)},Wl=(e,s,n,a)=>s!==void 0&&e.includes(s)?s:n!==void 0&&e.includes(n)?n:a,Gl=(e,s)=>{const n=new Set(s),a=new Set;for(const r of e)n.has(r)&&a.add(r);return a},Vl=(e,s,n)=>{if(e.length===0)return;const a=s===void 0?-1:e.indexOf(s);if(a===-1)return n>0?e[0]:e[e.length-1];const r=Math.min(Math.max(a+n,0),e.length-1);return e[r]},Jl=e=>{const[s,n]=l.useState(()=>new Set(e?.initialSelectedIds)),[a,r]=l.useState(void 0),o=l.useCallback(f=>s.has(f),[s]),i=l.useCallback(f=>{r(f),n(d=>{const h=new Set(d);return h.has(f)?h.delete(f):h.add(f),h})},[]),c=l.useCallback(f=>{r(f),n(d=>{if(d.has(f))return d;const h=new Set(d);return h.add(f),h})},[]),u=l.useCallback(f=>{n(d=>{if(!d.has(f))return d;const h=new Set(d);return h.delete(f),h})},[]),b=l.useCallback(f=>{n(new Set(f))},[]),v=l.useCallback(()=>{r(void 0),n(new Set)},[]),j=l.useCallback(f=>{n(d=>f.every(y=>d.has(y))?new Set:new Set(f))},[]),g=l.useCallback(f=>{r(f)},[]),p=l.useCallback(f=>{n(d=>{if(d.size===0)return d;const h=Gl(d,f);return h.size===d.size?d:h})},[]),m=l.useCallback((f,d,h)=>{const y=Wl(f,a,h,d);n(x=>{const k=Hl(f,y,d);if(k.length===0)return x;const C=new Set(x);for(const I of k)C.add(I);return C}),r(y)},[a]);return{selectedIds:s,selectedCount:s.size,hasSelection:s.size>0,isSelected:o,toggle:i,select:c,deselect:u,selectAll:b,clearSelection:v,toggleAll:j,selectRange:m,setAnchor:g,anchorId:a,intersectWith:p}},As={delete_failed:{label:"Not deleted",title:"This message was not deleted",detail:"Remit removed it here first, then refused to finish the delete on the mail server — most often because the Trash folder it was headed for is not there any more. The message is back in this folder because that is where the server still has it.",retryLabel:"Delete again",retryPendingLabel:"Deleting…"},move_failed:{label:"Not moved",title:"This message was not moved",detail:"Remit filed it here first, then could not finish the move on the mail server and stopped trying. The message is back in this folder because that is where the server still has it. The folder you picked is not recorded, so moving it again means choosing one.",retryLabel:"Move again",retryPendingLabel:"Moving…"}};function pa({settlement:e,className:s}){const n=As[e];return t.jsxs(ye,{tone:"danger",className:E("shrink-0",s),title:n.title,"data-settlement":e,children:[t.jsx(la,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{children:n.label})]})}function Yl({settlement:e,onRetry:s,action:n,retryPending:a,reportHref:r,className:o}){const i=As[e];return t.jsxs("div",{role:"alert","data-testid":"message-settlement-notice","data-settlement":e,className:E("flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",o),children:[t.jsx(la,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-medium text-danger",children:i.title}),t.jsx("p",{className:"mt-1 break-words text-fg-muted",children:i.detail}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[n,s&&t.jsx("button",{type:"button",onClick:s,disabled:a,className:"font-medium text-accent hover:underline disabled:opacity-50",children:a?i.retryPendingLabel:i.retryLabel}),r&&t.jsx("a",{href:r,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}const ga="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",xa=({active:e,focused:s})=>E("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",ga,e?"bg-accent-2-soft":s?"bg-surface-sunken":"hover:bg-surface-sunken",s&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2"),Nt=({active:e,focused:s})=>E("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",ga,e?"bg-accent-2-soft":s?"bg-surface-sunken":"hover:bg-surface-sunken",s&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2");function ba({thread:e}){const s=!e.isRead;return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?t.jsx(Ve,{className:"size-3.5 text-danger"}):e.starred?t.jsx(He,{className:"size-3 fill-warning text-warning"}):s?t.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),t.jsx("span",{className:E("w-36 shrink-0 truncate text-xs",s?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),t.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[t.jsx("span",{className:E(s?"font-medium text-fg":"text-fg-muted"),children:e.subject}),t.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&t.jsx(Bs,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),e.settlement&&t.jsx(pa,{settlement:e.settlement}),t.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function en(e,s){const n=s?.trim();if(!n)return e;const a=e.toLowerCase(),r=n.toLowerCase(),o=[];let i=0,c=a.indexOf(r,i),u=0;for(;c!==-1;)c>i&&o.push(e.slice(i,c)),o.push(t.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(c,c+r.length)},u++)),i=c+r.length,c=a.indexOf(r,i);return i<e.length&&o.push(e.slice(i)),o}function Zl({thread:e,badge:s,highlightQuery:n}){const a=!e.isRead;return t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[t.jsxs("span",{className:E("flex min-w-0 items-center gap-1.5 truncate text-sm",a?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),t.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&t.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),t.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:E("truncate text-sm",a?"text-fg":"text-fg-muted"),children:en(e.subject,n)}),e.suspicious&&t.jsx(Ve,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&t.jsx(He,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&t.jsx(Bs,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:en(e.snippet,n)}),e.category&&e.category!=="personal"&&t.jsx(ye,{tone:Fn[e.category],className:"shrink-0",children:pr(e.category)}),e.labels?.map(r=>t.jsx(gr,{label:r,className:"max-w-20"},r.labelId)),e.settlement&&t.jsx(pa,{settlement:e.settlement}),s]})]})}function Xl({thread:e,selection:s}){if(!s)return t.jsx(cs,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:n,alwaysVisible:a}=s;return t.jsxs("span",{className:"relative size-7 shrink-0",children:[t.jsx(cs,{name:e.fromName,email:e.fromEmail,size:"sm",className:E("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(n||a)&&"opacity-0")}),t.jsx("span",{role:"button",tabIndex:-1,onClick:s.onToggle,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),r.stopPropagation(),s.onToggle(r))},className:E("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",a?"flex":"hidden sm:flex",n?"bg-accent border-accent text-accent-fg opacity-100":a?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":n?"Deselect message":"Select message",children:n&&t.jsx(Ds,{className:"size-3"})})]})}function wt({thread:e,selection:s,badge:n,highlightQuery:a}){const r=!e.isRead;return t.jsxs(t.Fragment,{children:[r&&t.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),t.jsx(Xl,{thread:e,selection:s}),t.jsx(Zl,{thread:e,badge:n,highlightQuery:a})]})}const va=e=>({...Uo,[xr]:"","data-message-id":e.id});function If({thread:e,active:s,focused:n,tabIndex:a,onClick:r}){return t.jsx("button",{type:"button",...va(e),tabIndex:a,onClick:r,className:xa({active:s,focused:n}),children:t.jsx(ba,{thread:e})})}function Rf({thread:e,active:s,focused:n,tabIndex:a,selection:r,onClick:o}){return t.jsx("button",{type:"button",...va(e),tabIndex:a,onClick:o,className:E("group",Nt({active:s,focused:n})),children:t.jsx(wt,{thread:e,selection:r})})}let Ke;const ya=5e3;function ja(e){e.preventDefault(),Es()}function Es(){Ke!==void 0&&(clearTimeout(Ke),Ke=void 0,document.removeEventListener("contextmenu",ja,!0),document.removeEventListener("pointerup",Es,!0))}function ec(){Ke===void 0?(document.addEventListener("contextmenu",ja,!0),document.addEventListener("pointerup",Es,!0)):clearTimeout(Ke),Ke=setTimeout(Es,ya)}let Ts;function ka(e){e.preventDefault(),e.stopPropagation(),rs()}function rs(){Ts!==void 0&&(clearTimeout(Ts),Ts=void 0,document.removeEventListener("click",ka,!0),document.removeEventListener("pointerdown",rs,!0))}function sc(){rs(),document.addEventListener("click",ka,!0),document.addEventListener("pointerdown",rs,!0),Ts=setTimeout(rs,ya)}const tc=500,nc=36,ac=e=>({delay:e,threshold:nc,triggerAllEvents:!0,pointer:{keys:!1}}),rc=e=>e.event.type==="pointerdown"&&e.first,oc={onPointerDown:e=>{e.pointerType!=="touch"&&e.pointerType!=="pen"||ec()}};function ic({onLongPress:e,isDisabled:s,delayMs:n=tc,accessibilityDescription:a}){const r=br(o=>{rc(o)&&(sc(),e())},{...ac(n),enabled:!s});return{longPressProps:da(r(),oc,{"aria-description":a})}}const as="min-h-11 min-w-11 px-0";function Ca({hasThread:e,onReply:s,onReplyAll:n,onForward:a,isStarred:r,onToggleStar:o,onDelete:i,isRead:c,onToggleRead:u,moveSlot:b,overflowItems:v=[],onUnavailable:j,unavailableHint:g,className:p}){const m=(d,h)=>()=>{if(!e){j?.(d);return}h?.()},f=u?[{key:"toggle-read",label:c?"Mark as unread":"Mark as read",icon:c?t.jsx(Xo,{className:"size-4"}):t.jsx(kt,{className:"size-4"}),onSelect:m("toggleRead",u)}]:[];return t.jsxs("div",{className:E("relative",p),children:[t.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[s&&t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(Ct,{className:"size-5"}),onClick:m("reply",s),"aria-label":"Reply",title:"Reply",className:as}),n&&t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(fa,{className:"size-5"}),onClick:m("replyAll",n),"aria-label":"Reply all",title:"Reply all",className:as}),a&&t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(ma,{className:"size-5"}),onClick:m("forward",a),"aria-label":"Forward",title:"Forward",className:as}),t.jsx("div",{className:"flex-1"}),o&&t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(He,{className:E("size-5",r&&"fill-warning text-warning")}),onClick:m("star",o),"aria-label":r?"Unstar":"Star","aria-pressed":r,title:r?"Unstar":"Star",className:as}),b,i&&t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(ds,{className:"size-5"}),onClick:m("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:as}),t.jsx(ea,{triggerLabel:"More actions",items:[...f,...v]})]}),!e&&g&&t.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:g})]})}function Na({message:e,onClick:s,isFocused:n,isUnread:a,trailing:r}){const o=t.jsxs(t.Fragment,{children:[t.jsx(gt,{className:"size-3.5 shrink-0 text-fg-subtle"}),t.jsxs("div",{className:"relative shrink-0",children:[t.jsx(cs,{name:e.fromName,email:e.fromEmail,size:"md"}),a&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),t.jsx("span",{className:E("w-36 shrink-0 truncate text-sm",a?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),r??t.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=E("group flex h-section-row w-full items-center gap-3 border-b border-line px-2 text-left transition-colors hover:bg-surface-sunken lg:px-4",n&&"bg-surface-sunken ring-1 ring-inset ring-accent/30");return s?t.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:s,onKeyDown:c=>{vr(c)&&(c.preventDefault(),s())},className:E(i,"cursor-pointer"),children:o}):t.jsx("div",{className:i,children:o})}function wa({message:e,warning:s,onHeaderClick:n,isFocused:a,senderBadge:r,trailing:o,to:i,indicators:c,actionMenu:u,actionBar:b,body:v}){const j=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,r]}),o??t.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),t.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&t.jsx("div",{className:"text-xs text-fg-subtle",children:i??t.jsxs(t.Fragment,{children:["to ",e.toLabel]})})]});return t.jsxs("div",{className:"px-2 py-3 lg:px-4",children:[t.jsxs("div",{className:E("-mx-2 -my-1 flex items-start gap-3 rounded-sm px-2 py-1",a&&"ring-1 ring-inset ring-accent/30"),children:[n?t.jsx("button",{type:"button",onClick:n,"aria-expanded":!0,"aria-label":"Collapse message",className:"mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg",children:t.jsx(De,{className:"size-3.5"})}):t.jsx(De,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),t.jsx(cs,{name:e.fromName,email:e.fromEmail,size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[n?t.jsx("button",{type:"button",onClick:n,className:"w-full text-left",children:j}):j,c]}),u&&t.jsx("div",{className:"shrink-0",children:u})]}),s&&t.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[t.jsx(Ve,{className:"mt-0.5 size-4 shrink-0 text-danger"}),t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),s," ",t.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),b&&t.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:b}),t.jsx(ei,{children:v??t.jsx(si,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function lc({thread:e,onBack:s,intelligence:n,intelligenceOpen:a,onToggleIntelligence:r,actions:o,children:i,onSwipeNext:c,onSwipePrevious:u}){const b=yr({onSwipeLeft:c,onSwipeRight:u}),[v,j]=l.useState(!1),g=r!==void 0,p=g?a??!1:v,m=!!n||g,f=()=>{if(g){r?.();return}j(h=>!h)},d=()=>{if(g){p&&r?.();return}j(!1)};return t.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(Dn,{className:"size-4"}),onClick:s,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),t.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),m&&t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(Ln,{className:"size-4"}),onClick:f,"aria-label":p?"Hide intelligence panel":"Show intelligence panel","aria-pressed":p,title:"Intelligence",className:E("shrink-0",p&&"bg-accent-2-soft text-accent-2")})]}),t.jsx(jr.Provider,{value:b.enabled,children:t.jsx("div",{ref:b.ref,className:"flex-1 overflow-y-auto",style:{touchAction:b.touchAction},...b.bind(),children:i??[...e.messages].reverse().map(h=>{const y=x=>x?()=>x(h.id):void 0;return h.expanded?t.jsx(wa,{message:h,warning:e.warning,onHeaderClick:y(o?.onToggleExpand),actionBar:t.jsx(Ca,{hasThread:!0,onReply:y(o?.onReply),onReplyAll:y(o?.onReplyAll),onForward:y(o?.onForward),onToggleStar:y(o?.onToggleStar),onDelete:y(o?.onDelete),onToggleRead:y(o?.onToggleRead),moveSlot:o?.moveSlot?.(h.id)})},h.id):t.jsx(Na,{message:h,onClick:y(o?.onToggleExpand)},h.id)})})}),n&&!g&&t.jsx(kr,{open:p,onClose:d,title:"Intelligence",anchor:"right",className:"p-0",children:t.jsx(ha,{data:n,onClose:d,className:"h-full w-full border-l-0"})})]})}function cc(e){return{id:e.id,fromName:e.sender,fromEmail:e.senderEmail??e.sender,subject:e.subject,snippet:e.snippet,timeLabel:e.date,isRead:!e.unread,starred:e.flagged,...e.mailboxId?{mailboxId:e.mailboxId}:{}}}function dc({result:e,onClick:s,query:n,showFolder:a=!0}){const r=a&&e.folder?Cr(e.folder):void 0;return t.jsx("button",{type:"button",onClick:s,className:E("group",Nt({}),"border-b border-line"),children:t.jsx(wt,{thread:cc(e),highlightQuery:n,badge:t.jsxs(t.Fragment,{children:[r&&t.jsx(ye,{tone:"neutral",className:"shrink-0",children:r}),e.category&&t.jsx(ye,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label}),e.matchedChunkLabel&&t.jsx(ye,{tone:"neutral",className:"shrink-0",children:`matched: ${e.matchedChunkLabel}`}),e.score!=null&&t.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.score.toFixed(2)})]})})})}const uc=e=>e===1?"result":"results";function mc({count:e,onScopeToSpam:s}){return t.jsx(On,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 text-xs text-fg-muted",children:e.kind==="exact"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e.value.toLocaleString()})," ",`${uc(e.value)} from Spam`]}):"Results from Spam"}),t.jsx(Q,{variant:"ghost",size:"sm",onClick:s,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const sn=6,fc={kind:"global"},tn={kind:"unknown"},hc=e=>e.kind==="folder"&&e.role==="junk",pc=e=>e.folder?.role==="junk";function gc(e){const s=[],n=[];for(const a of e)pc(a)?n.push(a):s.push(a);return{kept:s,spam:n}}function Sa({onClick:e,blockedReason:s}){const n=l.useId(),[a,r]=l.useState(!1);return t.jsxs("div",{className:"border-b border-line px-row-inset py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{if(s){r(!0);return}e()},"aria-describedby":s?n:void 0,className:E("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",s?"text-fg-subtle opacity-55":"text-accent hover:bg-surface-sunken"),children:[t.jsx(Nr,{className:"size-3.5 shrink-0","aria-hidden":"true"}),t.jsx("span",{children:"Make this a filter"})]}),s&&t.jsx(wr,{id:n,reason:s,nudged:a,className:"px-2 pt-1 text-2xs text-warning"})]})}function xc({section:e,query:s,onSelectResult:n,showFolder:a}){const[r,o]=l.useState(e.initialCollapsed??!1),[i,c]=l.useState(!1),u=e.results.length>sn,v=!i&&u?e.results.slice(0,sn):e.results,j=e.results.length-v.length;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","aria-expanded":!r,onClick:()=>o(g=>!g),className:"sticky top-0 z-10 flex h-section-row w-full items-center gap-1.5 border-b border-line bg-surface-sunken px-row-inset text-left transition-colors hover:bg-surface",children:[t.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),t.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),t.jsx(De,{className:E("size-3 shrink-0 text-fg-subtle transition-transform duration-200",r?"rotate-0":"rotate-180")})]}),!r&&t.jsxs(t.Fragment,{children:[v.map(g=>t.jsx(dc,{result:g,query:s,showFolder:a,onClick:n?()=>n(g):void 0},g.id)),u&&t.jsxs("button",{type:"button",onClick:()=>c(g=>!g),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent transition-colors hover:bg-surface",children:[i?"Show less":`Show ${j} more`,!i&&t.jsx(De,{className:"ml-1 size-3"})]})]})]})}function Ia({value:e,recentSearches:s,onPickRecent:n,sections:a,loading:r,onSelectResult:o,tokens:i,scope:c=fc,makeFilter:u}){if(!(e.trim().length>0))return s&&s.length>0?t.jsxs("div",{className:"flex flex-col",children:[t.jsx("h3",{className:"px-row-inset pb-1 pt-3 text-2xs font-semibold uppercase tracking-wide text-fg-subtle",children:"Recent searches"}),s.map(N=>t.jsxs("button",{type:"button",onClick:()=>n?.(N),className:"flex w-full items-center gap-2.5 border-b border-line px-row-inset py-2.5 text-left transition-colors hover:bg-surface-sunken",children:[t.jsx(oa,{className:"size-4 shrink-0 text-fg-subtle"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:N})]},N))]}):t.jsx("p",{className:"px-row-inset py-6 text-center text-sm text-fg-subtle",children:"Search across your mail by sender, subject or words in the message."});const v=i&&i.length>0&&t.jsx(Sr,{tokens:i}),j=u&&t.jsx(Sa,{...u});if(r)return t.jsxs("div",{className:"flex flex-col",children:[j,v,t.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(N=>t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),t.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),t.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},N))})]});const g=c.kind==="global",p=hc(c)||c.kind==="collection",m=g||c.kind==="collection",f=(a??[]).map(N=>{if(p)return{section:N,spam:[]};const{kept:T,spam:A}=gc(N.results);return{section:{...N,results:T},spam:A}}),d=f.map(N=>N.section),h=f.reduce((N,T)=>N+T.spam.length,0),x=(c.kind==="global"?c.spamCount:void 0)??tn,k=h>0||x.kind==="exact"&&x.value>0,I=x.kind==="exact"&&x.value===0&&h>0?tn:x,M=c.kind==="global"&&k&&c.onScopeToSpam!==void 0?t.jsx(mc,{count:I,onScopeToSpam:c.onScopeToSpam}):void 0;return d.some(N=>N.results.length>0)?t.jsxs("div",{className:"flex flex-col",children:[j,v,M,d.filter(N=>N.results.length>0).map(N=>t.jsx(xc,{section:N,query:e,showFolder:m,onSelectResult:o},N.id))]}):t.jsxs("div",{className:"flex flex-col",children:[j,v,M,t.jsxs("div",{className:"px-row-inset py-10 text-center",children:[t.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),t.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function bc({value:e,onChange:s,onClear:n,onCancel:a,filter:r,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:b,tokens:v,chips:j,onRemoveChip:g,scope:p,makeFilter:m,suggest:f,suggestList:d}){const h=t.jsx(Ia,{value:e,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:b,tokens:v,scope:p,makeFilter:m});return t.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Xn,{value:e,onChange:s,onClear:n,chips:j,onRemoveChip:g,globalFocusKey:!1,showClearButton:!1,suggest:f})}),t.jsx(Q,{variant:"ghost",size:"sm",icon:t.jsx(qe,{className:"size-4"}),onClick:a,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),d,r&&e.trim().length===0?t.jsx(Ir,{children:t.jsx(An,{...r,children:h})}):t.jsx("div",{className:"flex-1 overflow-y-auto",children:h})]})}const nn=e=>e.toLocaleString();function an({selectAll:e,selecting:s,className:n}){return t.jsx(nl,{className:n,checked:e.checked,indeterminate:e.indeterminate,onChange:e.onChange,label:t.jsx("span",{className:"font-medium text-accent",children:e.checked&&s?"Deselect all":"Select all"})})}function vc({title:e,count:s,onCancel:n,onDelete:a,onMove:r,onOrganize:o,onJunk:i,onMarkRead:c,navSlot:u,titleMeta:b,searchSlot:v,searchField:j,idleSlot:g,overflowSlot:p,isBusy:m=!1,isCounting:f=!1,selectAll:d,statusLabel:h,progress:y,notice:x}){const k=s>0||f,C=d?.checked?`All ${nn(s)} loaded selected`:`${nn(s)} ${s===1?"message":"messages"} selected`,I=[];return i&&!m&&!f&&I.push({key:"junk",label:"Junk",icon:t.jsx(Ve,{className:"size-4"}),onSelect:i}),c&&!m&&!f&&I.push({key:"mark-read",label:"Mark read",icon:t.jsx(kt,{className:"size-4"}),onSelect:c}),t.jsxs("header",{"data-selection-bar":"",className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[t.jsxs("div",{"data-selection-bar-row":"actions",className:"flex h-pane-header items-center gap-1 px-row-inset",children:[k?t.jsx(Q,{variant:"ghost",size:"touch",icon:t.jsx(Dn,{className:"size-5"}),onClick:n,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):u,d&&t.jsx(an,{selectAll:d,selecting:k,className:"hidden shrink-0 pr-2 md:flex"}),k?t.jsx("span",{"data-selection-count":"",className:"min-w-0 flex-1 truncate px-1 text-sm font-medium text-fg",role:"status","aria-live":"polite",children:h??C}):j?t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:j}):t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg",children:e}),b,v]}),k&&!f&&t.jsxs(t.Fragment,{children:[t.jsx(Q,{variant:"ghost",size:"touch",icon:m?t.jsx(Tn,{className:"size-5 animate-spin"}):t.jsx(ds,{className:"size-5 text-danger"}),onClick:m?void 0:a,"aria-label":"Move selected messages to Trash","aria-busy":m||void 0,className:"shrink-0"}),!m&&r&&t.jsx(Q,{variant:"ghost",size:"touch",icon:t.jsx(xt,{className:"size-5"}),onClick:r,"aria-label":"Move selected messages",className:"shrink-0"}),!m&&o&&t.jsx(Q,{variant:"ghost",size:"touch",icon:t.jsx(Qe,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),k&&t.jsx(ea,{triggerLabel:"More actions",items:I,className:"shrink-0",children:!m&&!f&&p})]}),!k&&g,k&&d&&t.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:t.jsx(an,{selectAll:d,selecting:k,className:"w-full"})}),y&&t.jsx("div",{className:"px-row-inset pb-2",children:t.jsx(Rr,{value:y.value,max:y.max,tone:y.tone})}),x&&t.jsx(On,{"data-selection-notice":"",tone:x.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[x.text&&t.jsx("span",{children:x.text}),x.action&&t.jsx(Q,{variant:"ghost",size:"md",onClick:x.action.onClick,className:"-my-1 min-h-11 shrink-0",children:x.action.label})]})})]})}const Ra={id:"unread",label:"Unread"},yc={id:"flagged",label:"Starred"},Ma={id:"attachment",label:"Has attachment"};function jc(e){if(!(e.length<=1))return e.map(s=>({id:s.id,label:s.label,count:s.count,active:s.active}))}function Mf(e=[]){return{categories:[...Ls],filters:En,sources:jc(e)}}function Tf(){return{categories:[...Ls],filters:[Ra,yc,Ma]}}function Af(){return{categories:[...Ls],filters:[Ra,Ma]}}function kc(e,s){return e.endsWith(s)?e.length===s.length||e[e.length-s.length-1]===".":!1}function Cc(e,s){const n=e.length-s.length-2,a=e.lastIndexOf(".",n);return a===-1?e:e.slice(a+1)}function Nc(e,s,n){if(n.validHosts!==null){const r=n.validHosts;for(const o of r)if(kc(s,o))return o}let a=0;if(s.startsWith("."))for(;a<s.length&&s[a]===".";)a+=1;return e.length===s.length-a?null:Cc(s,e)}const tt=/[\t\n\r]/g;let dt=!1;function rn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127||e>=65&&e<=90||e===45||e===95}function on(e,s,n){const a=n-s,r=e.charCodeAt(s)|32;if(a===2)return r===119&&(e.charCodeAt(s+1)|32)===115?1:0;if(a===3){const o=e.charCodeAt(s+1)|32,i=e.charCodeAt(s+2)|32;return r===119&&o===115&&i===115||r===102&&o===116&&i===112?1:0}else if(a===4){const o=e.charCodeAt(s+1)|32,i=e.charCodeAt(s+2)|32,c=e.charCodeAt(s+3)|32;return r===104&&o===116&&i===116&&c===112?1:r===102&&o===105&&i===108&&c===101?2:0}else if(a===5)return r===104&&(e.charCodeAt(s+1)|32)===116&&(e.charCodeAt(s+2)|32)===116&&(e.charCodeAt(s+3)|32)===112&&(e.charCodeAt(s+4)|32)===115?1:0;return 0}function os(e,s,n=!1){let a=0,r=e.length,o=!1,i=!1;if(dt=!1,!s){if(e.startsWith("data:"))return null;for(;a<e.length&&e.charCodeAt(a)<=32;)a+=1;for(;r>a+1&&e.charCodeAt(r-1)<=32;)r-=1;if(e.charCodeAt(a)===47&&e.charCodeAt(a+1)===47)a+=2;else{const d=e.indexOf(":/",a);if(d!==-1){const h=on(e,a,d);if(h===1)for(i=!0,a=d+2;e.charCodeAt(a)===47||e.charCodeAt(a)===92;)a+=1;else if(h===2){i=!0,a=d+1;let y=0;for(;(e.charCodeAt(a)===47||e.charCodeAt(a)===92)&&y<2;)a+=1,y+=1;if(y<2)return null}else{for(let y=a;y<d;y+=1){const x=e.charCodeAt(y)|32;if(!(x>=97&&x<=122||x>=48&&x<=57||x===46||x===45||x===43)){const k=e.charCodeAt(y);return k===9||k===10||k===13?os(e.replace(tt,""),s,n):null}}if(e.charCodeAt(d+2)===47)a=d+3;else return null}}else if(e.charCodeAt(a)!==91){let h=-1;for(let y=a;y<r;y+=1){const x=e.charCodeAt(y);if(x===9||x===10||x===13)return os(e.replace(tt,""),s,n);if(x===58){h=y;break}if(x===47||x===92||x===63||x===35)break}if(h!==-1){let y=!1;for(let x=h+1;x<r;x+=1){const k=e.charCodeAt(x);if(k===47||k===92||k===63||k===35)break;if(k===64){y=!0;break}}if(!y){let x=!0,k=h+1;for(;k<r;k+=1){const C=e.charCodeAt(k);if(C===47||C===92||C===63||C===35)break;if(C<48||C>57){x=!1;break}}if(k===h+1&&(x=!1),!x){const C=on(e,a,h);if(C===0){let I=!1;for(let M=h+1;M<r;M+=1){const w=e.charCodeAt(M);if(w===47||w===92||w===63||w===35)break;if(w===58){I=!0;break}}if(!I)return null}else if(i=!0,a=h+1,C===2){let I=0;for(;(e.charCodeAt(a)===47||e.charCodeAt(a)===92)&&I<2;)a+=1,I+=1;if(I<2)return null}else for(;e.charCodeAt(a)===47||e.charCodeAt(a)===92;)a+=1}}}}}let u=-1,b=-1,v=-1,j=-1,g=!1,p=n,m=a-1,f=-1;if(n&&a<r){const d=e.charCodeAt(a);(!(rn(d)||d===46||d===95)||d===45)&&(p=!1)}for(let d=a;d<r;d+=1){const h=e.charCodeAt(d);if(h<64)if(h===47||h===35||h===63){r=d;break}else h===58?(j===-1&&(j=d),v=d):h===9||h===10||h===13?g=!0:n&&(h===46?((d-m>64||f===46||f===45)&&(p=!1),m=d):(h<48||h>57)&&(h!==45||f===46)&&(p=!1));else if(i&&h===92){r=d;break}else h===64?(u=d,j=-1):h===93?b=d:h>=65&&h<=90?o=!0:n&&!rn(h)&&(p=!1);n&&(f=h)}if(g)return os(e.replace(tt,""),s,n);if(u!==-1&&u>=a&&u<r&&(a=u+1),e.charCodeAt(a)===91)return b!==-1?e.slice(a+1,b).toLowerCase():null;if(v!==-1&&v>a&&v<r&&j===v&&(r=v),a>=r)return null;n&&p&&u===-1&&v===-1&&b===-1&&e.charCodeAt(r-1)!==46&&r-a<=255&&r-m-1<=63&&f!==45&&(dt=!0)}for(;r>a+1&&e.charCodeAt(r-1)===46;)r-=1;const c=a!==0||r!==e.length?e.slice(a,r):e;return o?c.toLowerCase():c}function wc(e){if(e.length<7||e.length>15)return!1;let s=0;for(let n=0;n<e.length;n+=1){const a=e.charCodeAt(n);if(a===46)s+=1;else if(a<48||a>57)return!1}return s===3&&e.charCodeAt(0)!==46&&e.charCodeAt(e.length-1)!==46}function Sc(e){if(e.length<3)return!1;let s=e.startsWith("[")?1:0,n=e.length;if(e[n-1]==="]"&&(n-=1),n-s>39)return!1;let a=!1;for(;s<n;s+=1){const r=e.charCodeAt(s);if(r===58)a=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return a}function Ic(e){return Sc(e)||wc(e)}function ln(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function cn(e){if(e.length>255||e.length===0||!ln(e.charCodeAt(0))&&e.charCodeAt(0)!==46&&e.charCodeAt(0)!==95)return!1;let s=-1,n=-1;const a=e.length;for(let r=0;r<a;r+=1){const o=e.charCodeAt(r);if(o===46){if(r-s>64||n===46||n===45)return!1;s=r}else if(!(ln(o)||o===45||o===95)||o===45&&n===46)return!1;n=o}return a-s-1<=63&&n!==45}function Rc({allowIcannDomains:e=!0,allowPrivateDomains:s=!1,detectIp:n=!0,detectSpecialUse:a=!1,extractHostname:r=!0,mixedInputs:o=!0,validHosts:i=null,validateHostname:c=!0}){return{allowIcannDomains:e,allowPrivateDomains:s,detectIp:n,detectSpecialUse:a,extractHostname:r,mixedInputs:o,validHosts:i,validateHostname:c}}const Mc=Rc({});function Tc(e){return Mc}function Ac(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function Ec(e){e.domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.isSpecialUse=null,e.publicSuffix=null,e.subdomain=null}function Fc(e,s,n,a,r){const o=Tc();if(typeof e!="string")return r;let i=!1;return o.extractHostname?o.mixedInputs?(i=cn(e),r.hostname=os(e,i,o.validateHostname)):r.hostname=os(e,!1,o.validateHostname):r.hostname=e,o.detectIp&&r.hostname!==null&&(r.isIp=Ic(r.hostname),r.isIp)?r:o.validateHostname&&o.extractHostname&&r.hostname!==null&&!(i&&r.hostname===e)&&!dt&&!cn(r.hostname)?(r.hostname=null,r):(r.hostname===null||(n(r.hostname,o,r),r.publicSuffix===null)||(r.domain=Nc(r.publicSuffix,r.hostname,o)),r)}const dn=Ac();function Lc(e,s){return Ec(dn),Fc(e,3,Mr,s,dn).domain}const $s=e=>{const s=new Set,n=[];for(const a of e){const r=a.trim();if(r==="")continue;const o=r.toLowerCase();s.has(o)||(s.add(o),n.push(r))}return n},Dc=e=>{const s=e.lastIndexOf("@");return s>=0?e.slice(s+1):e},Ta=e=>Lc(Dc(e.trim())),Oc=e=>{const s=$s(e);if(s.length<2)return null;let n=null;for(const a of s){const r=Ta(a);if(r===null)return null;if(n===null)n=r;else if(n!==r)return null}return n},zc=e=>{const s=Oc(e);return s!==null?[{field:"FromDomain",value:s}]:$s(e).map(n=>({field:"From",value:n}))},Pc=e=>{const s=new Map;for(const r of e){const o=r.normalizedEmail.trim().toLowerCase();if(o==="")continue;const i=s.get(o);i?i.count+=1:s.set(o,{sender:r,count:1})}let n,a=0;for(const{sender:r,count:o}of s.values())o<=a||(n=r,a=o);return n},Aa=e=>e.displayName?.trim()||e.normalizedEmail,_c=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,Bc=e=>{let s=e.replace(/\s+/g," ").trim();for(;;){const n=s.replace(_c,"");if(n===s)return s.trim();s=n}},Uc=new Set(["a","an","and","are","as","at","be","by","for","from","has","have","in","is","it","me","my","new","of","on","or","our","the","this","to","was","we","with","you","your"]),$c=3,nt=e=>e.split(" ").filter(s=>s!==""),un=e=>e.length===0||e.join(" ").length<$c?!1:e.some(s=>!Uc.has(s.toLowerCase())),Kc=(e,s)=>e.findIndex((n,a)=>s.every((r,o)=>e[a+o]?.toLowerCase()===r.toLowerCase())),qc=e=>{const s=e.map(Bc).filter(o=>o!=="");if(s.length===0)return;const[n,...a]=s;if(a.length===0)return un(nt(n))?n:void 0;const r=nt(n);for(let o=r.length;o>0;o-=1)for(let i=0;i+o<=r.length;i+=1){const c=r.slice(i,i+o);if(un(c)&&a.every(u=>Kc(nt(u),c)>=0))return c.join(" ")}},St=(e,s)=>{const n=zc(e);if($s(e).length===1||n.length===1&&n[0].field==="FromDomain")return n;const a=qc(s);return a!==void 0?[{field:"Subject",value:a}]:n},Qc=({match:e,sender:s,folder:n})=>{const a=e??s;return a?n?`${a} → ${n}`:e?`Mail matching ${e}`:`Mail from ${a}`:n?`Mail to ${n}`:""},Hc=e=>e.clauses.length>0,Wc=e=>({scopedOutFolder:e.scopedOut?.label,droppedFacets:e.droppedFacets.map(s=>s.label),droppedSemantic:e.droppedSemantic}),Gc=({orderedIds:e,isDesktop:s,initialFocusedId:n,initialSelectedIds:a,onExitSelection:r})=>{const[o,i]=l.useState(n),[c,u]=l.useState(),b=l.useCallback(F=>{u(z=>z===F?z:void 0),i(F)},[]),v=Jl({initialSelectedIds:a}),{selectedCount:j,toggle:g,clearSelection:p,selectRange:m,setAnchor:f,selectAll:d}=v,h=Ql(j,s),y=l.useRef(null),x=l.useRef(!1),k=l.useCallback(()=>{r?.(),p()},[p,r]),C=l.useMemo(()=>o?e.indexOf(o):-1,[e,o]),I=l.useCallback(F=>{if(F<0||F>=e.length)return;const z=e[F];if(h){g(z);return}y.current=z,x.current=!1,u(z),i(z)},[e,h,g]),M=l.useCallback(()=>{e.length!==0&&I(C<0?0:Math.min(C+1,e.length-1))},[e.length,C,I]),w=l.useCallback(()=>{e.length!==0&&I(C<=0?0:C-1)},[e.length,C,I]),N=l.useCallback(()=>I(0),[I]),T=l.useCallback(()=>I(e.length-1),[I,e.length]),A=l.useCallback(()=>{o&&g(o)},[o,g]),K=l.useCallback((F,z)=>{const _=ql(z);return _==="range"?(m(e,F,o),!0):_==="toggle"?(g(F),!0):(k(),f(F),!1)},[e,o,m,g,k,f]),L=l.useCallback(F=>{const z=Vl(e,o,F);z!==void 0&&(m(e,z),y.current=z,x.current=!1,u(void 0),i(z))},[e,o,m]),W=l.useCallback(()=>L(-1),[L]),P=l.useCallback(()=>L(1),[L]),$=l.useCallback(()=>{e.length>0&&d(e)},[e,d]);return{focusedMessageId:o,setFocusedMessageId:b,keyboardFocusedMessageId:c,focusIndex:C,pendingDomFocusRef:y,cursorMovedByPointerRef:x,selection:v,isMultiSelectMode:h,exitSelection:k,moveFocusToIndex:I,focusNext:M,focusPrevious:w,focusFirst:N,focusLast:T,toggleFocusedSelection:A,extendRangeUp:W,extendRangeDown:P,selectAllLoaded:$,handleRowSelect:K}};function Vc(e,s){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const n=!!(e.condition??!0),a=e.blockerFn;return{shouldBlockFn:async()=>n&&a!==void 0?await a():n,enableBeforeUnload:n,withResolver:a===void 0}}function Jc(e,s){const{shouldBlockFn:n,enableBeforeUnload:a=!0,disabled:r=!1,withResolver:o=!1}=Vc(e),i=Tr(),{history:c}=i,[u,b]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const v=async j=>{function g(h){const y=i.parseLocation(h),x=i.getMatchedRoutes(y.pathname);return x.foundRoute===void 0?{routeId:"__notFound__",fullPath:y.pathname,pathname:y.pathname,params:x.routeParams,search:i.options.parseSearch(h.search)}:{routeId:x.foundRoute.id,fullPath:x.foundRoute.fullPath,pathname:y.pathname,params:x.routeParams,search:i.options.parseSearch(h.search)}}const p=g(j.currentLocation),m=g(j.nextLocation);if(p.routeId==="__notFound__"&&m.routeId!=="__notFound__")return!1;const f=await n({action:j.action,current:p,next:m});if(!o)return f;if(!f)return!1;const d=await new Promise(h=>{b({status:"blocked",current:p,next:m,action:j.action,proceed:()=>h(!1),reset:()=>h(!0)})});return b({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),d};return r?void 0:c.block({blockerFn:v,enableBeforeUnload:a})},[n,a,r,o,c,i]),u}function Ef(){const{insertIntoOpenReply:e}=zn(),s=Pn();return l.useCallback((n,a)=>{e(n.messageId,a)||s({...n,mode:"reply"},{body:a})},[e,s])}const Ks=e=>{const{data:s,isLoading:n}=se({...We(),staleTime:1/0,enabled:!!e}),a=l.useMemo(()=>(s?.accounts??[]).map(c=>c.accountId),[s?.accounts]),r=jt({queries:a.map(c=>({...us({path:{accountId:c}}),staleTime:1/0,enabled:!!e}))}),o=n||r.some(c=>c.isLoading);return{accountId:l.useMemo(()=>{if(e){for(let c=0;c<a.length;c++)if((r[c].data?.items??[]).some(v=>v.mailboxId===e))return a[c]}},[e,a,r]),isLoading:o}},Yc=({surface:e})=>{const s=Ar(),n=Er(),{registerOpenReply:a}=zn(),[r,o]=l.useState(),i=l.useCallback(g=>o(p=>({version:(p?.version??0)+1,text:g})),[]),c=e.sourceMessageId;l.useEffect(()=>a(c,i),[c,i,a]);const{data:u}=se({...zs({path:{messageId:e.sourceMessageId}})}),{data:b}=se({...We(),staleTime:1/0}),{accountId:v}=Ks(u?.message.mailboxId),j=b?.accounts?.find(g=>g.accountId===v);return t.jsx("div",{className:"border-b border-line bg-canvas",children:t.jsx(li,{layout:"flow",mode:e.mode,account:j,sourceMessage:u,outboxMessageId:e.outboxMessageId,seed:e.seed,insertion:r,onDraftCreated:s,onClose:n},e.sourceMessageId)})},Zc=3e3,Xc=(e,s,n)=>{if(e.length===0)return()=>{};const a=setTimeout(()=>n(e),s);return()=>clearTimeout(a)},It=(e,s,n)=>{const a=new Map(s.map(o=>[o.messageId,o.mailboxId])),r=new Set;for(const o of e)r.add(a.get(o)??n);return[...r]},Fs=(e,s,n)=>e.map(a=>s.has(a.messageId)?{...a,isRead:n}:a),ed=(e,s,n,a)=>e.filter(r=>!r.isRead&&s.has(r.threadMessageId)&&!n.has(r.messageId)&&!a.has(r.messageId)).map(r=>r.messageId),sd=({messages:e,expandedIds:s,threadId:n,mailboxId:a,accountId:r})=>{const o=ue(),{pushError:i}=be(),c=l.useRef(new Set),u=l.useRef(new Set),{mutate:b}=pe({...Ps(),meta:Fr,onMutate:async g=>{const p=new Set(g.body.messageIds??[]),m=g.body.isRead??!0,f=Se({path:{threadId:n}}),d=Ne(It(p,e,a));await Promise.all([o.cancelQueries({queryKey:f}),hs(o,d)]);const h=o.getQueriesData({queryKey:f}).filter(x=>x[1]!==void 0).map(([x,k])=>({queryKey:x,data:k})),y=ps(o,d);return o.setQueriesData({queryKey:f},x=>x&&{...x,items:Fs(x.items,p,m)}),gs(o,d,x=>Fs(x,p,m)),{threadMessagesPrefix:f,listPrefixes:d,previousThreadMessages:h,previousThreadsList:y}},onSuccess:(g,p)=>{const m=p.body.messageIds??[];for(const f of m)c.current.add(f),u.current.delete(f)},onError:(g,p,m)=>{const f=p.body.messageIds??[];for(const h of f)u.current.delete(h);if(m){for(const h of m.previousThreadMessages)o.setQueryData(h.queryKey,h.data);fs(o,m.previousThreadsList)}const d=p.body.isRead??!0;i({title:d?"Couldn't mark as read":"Couldn't mark as unread",detail:we(g),error:g})},onSettled:(g,p,m,f)=>{f&&(o.invalidateQueries({queryKey:f.threadMessagesPrefix}),Ce(o,f.listPrefixes),r&&o.invalidateQueries({queryKey:ms({path:{accountId:r}})}))}}),v=l.useCallback(g=>{const p=g.filter(m=>!c.current.has(m)&&!u.current.has(m));if(p.length!==0){for(const m of p)u.current.add(m);b({body:{messageIds:p,isRead:!0}})}},[b]),j=l.useMemo(()=>ed(e,s,c.current,u.current),[e,s]);l.useEffect(()=>Xc(j,Zc,v),[j,v]),l.useEffect(()=>{c.current.clear(),u.current.clear()},[n])},Ff=e=>{const{mailboxId:s,accountId:n,messages:a}=e,r=ue(),{pushError:o}=be(),{mutateAsync:i,isPending:c}=pe({...Ps(),onError:(b,v)=>{const j=v.body.isRead??!0;o({title:j?"Couldn't mark as read":"Couldn't mark as unread",detail:we(b),error:b})},onSettled:(b,v,j)=>{Ce(r,Ne(It(j.body.messageIds??[],a??[],s))),n&&r.invalidateQueries({queryKey:ms({path:{accountId:n}})})}});return{toggleReadFor:l.useCallback((b,v)=>{b.length!==0&&is(b,j=>i({body:{messageIds:j,isRead:v}}))},[i]),isPending:c}},td=(e,s,n)=>s?.find(a=>a.messageId===e)?.mailboxId??n,mn=(e,s,n)=>e.map(a=>a.messageId===s?{...a,hasStars:n}:a),Ea=({threadId:e,mailboxId:s,messages:n})=>{const a=ue(),{pushError:r}=be(),{mutate:o,isPending:i,variables:c}=pe({...Dr(),onMutate:async b=>{const v=b.path.messageId,j=b.body.isStarred??!1,g=Se({path:{threadId:e}}),p=Ne([td(v,n,s)]);await Promise.all([a.cancelQueries({queryKey:g}),hs(a,p)]);const m=a.getQueriesData({queryKey:g}).filter(d=>d[1]!==void 0).map(([d,h])=>({queryKey:d,data:h})),f=ps(a,p);return a.setQueriesData({queryKey:g},d=>Lr(d,h=>mn(h,v,j))),gs(a,p,d=>mn(d,v,j)),{threadMessagesPrefix:g,listPrefixes:p,previousThreadMessages:m,previousThreadsList:f}},onError:(b,v,j)=>{if(j){for(const p of j.previousThreadMessages)a.setQueryData(p.queryKey,p.data);fs(a,j.previousThreadsList)}const g=v.body.isStarred??!1;r({title:g?"Couldn't star message":"Couldn't unstar message",detail:we(b),error:b})},onSettled:(b,v,j,g)=>{g&&(a.invalidateQueries({queryKey:g.threadMessagesPrefix}),Ce(a,g.listPrefixes))}});return{toggleStar:(b,v)=>{o({path:{messageId:b},body:{isStarred:!v}})},isPending:i,pendingMessageId:i?c?.path.messageId:void 0}};function fn({authenticity:e,onOpenIntelligence:s}){return e.dkimMismatch?t.jsxs("div",{className:"flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm",children:[t.jsx(Ve,{className:"mt-0.5 size-4 shrink-0 text-danger"}),t.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",t.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."," ",s&&t.jsx("button",{type:"button",onClick:s,className:"font-medium text-danger hover:underline",children:"Why?"})]})]}):null}function Fa(e){return e===void 0?"uncategorized":e}const nd={inbox:"Inbox",junk:"Junk"},Rt=e=>e.destinationMailboxId!==void 0,ad=(e,s)=>{if(Rt(e))return`Moved from ${s??"another folder"} by Remit`;const n=e.fromPlacement??"";return`Moved from ${nd[n]??"another folder"} by Remit`},rd=(e,s)=>{if(e===_t.MoveToInbox)return s.inboxMailboxId;if(e===_t.MoveToJunk)return s.junkMailboxId},od=(e,s,n)=>{if(!e||!s)return!1;const a=Rt(e)?e.destinationMailboxId:rd(e.action,n);return a!==void 0&&a===s},id="Reported as spam",ld=(e,s)=>{if(e){if(Rt(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return s.inboxMailboxId;if(e.fromPlacement==="junk")return s.junkMailboxId}},bs=(e,s)=>{const{data:n,isLoading:a}=se({...We(),staleTime:1/0,enabled:!!e});return{mailboxId:l.useMemo(()=>e?n?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===s)?.mailboxId:void 0,[n,e,s]),isLoading:a}},Lf=e=>{const{mailboxId:s,isLoading:n}=bs(e,"Archive");return{archiveMailboxId:s,isLoading:n}},Df=e=>{const{mailboxId:s,isLoading:n}=bs(e,"Drafts");return{draftsMailboxId:s,isLoading:n}},La=e=>{const{mailboxId:s,isLoading:n}=bs(e,"Inbox");return{inboxMailboxId:s,isLoading:n}},Da=e=>{const{mailboxId:s,isLoading:n}=bs(e,"Junk");return{junkMailboxId:s,isLoading:n}},Of=e=>{const{mailboxId:s,isLoading:n}=bs(e,"Trash");return{trashMailboxId:s,isLoading:n}},cd=()=>{const{data:e,isError:s}=se({...We(),staleTime:1/0});return{trashByAccount:l.useMemo(()=>{const a=new Map;for(const r of e?.accounts??[]){const o=r.folderAppointments.find(i=>i.role==="Trash");a.set(r.accountId,{mailboxId:o?.mailboxId,source:o?.source??"None",staleFolderPath:o?.staleAppointmentPath})}return a},[e]),hasAppointments:e!==void 0,isError:s}},Oa=e=>{const{data:s}=se({...We(),staleTime:1/0,enabled:!!e});return l.useMemo(()=>s?.accounts.find(n=>n.accountId===e)?.folderAppointments??[],[s,e])},dd=new Set(["in_flight"]),hn=(e,s)=>{const n=e?.[s];return typeof n=="string"?n:void 0},za=e=>{const s=Or(e);if(s?.code!=="message_placement_unsettled")return;const{details:n}=s;if(!n)return;const a=hn(n,"reason"),r=hn(n,"messageId");if(!(!a||!dd.has(a)||!r))return{reason:a,messageId:r}},Pa=(e,s,n)=>({severity:"warning",title:s>1?`Couldn't ${n} ${s} messages yet`:`Couldn't ${n} this message yet`,detail:"It is still being moved on the mail server. Try again in a moment."}),pn=(e,s)=>e.filter(n=>!s.has(n.messageId)),vs=({mailboxId:e,threadId:s,accountId:n,onAfterOptimisticRemove:a})=>{const r=ue(),{pushError:o}=be(),{mutateAsync:i,isPending:c,isError:u}=pe({...zr(),meta:_n(409),onMutate:async v=>{const j=new Set(v.body.messageIds??[]),g=s?Se({path:{threadId:s}}):[],p=Ne([e,v.body.destinationMailboxId]);await Promise.all([...s?[r.cancelQueries({queryKey:g})]:[],hs(r,p)]);const m=s?r.getQueriesData({queryKey:g}).filter(d=>d[1]!==void 0).map(([d,h])=>({queryKey:d,data:h})):[],f=ps(r,p);return s&&r.setQueriesData({queryKey:g},d=>d&&{...d,items:pn(d.items,j)}),gs(r,p,d=>pn(d,j)),a?.(Array.from(j)),{threadMessagesPrefix:g,listPrefixes:p,previousThreadMessages:m,previousThreadsList:f}},onError:(v,j,g)=>{if(g){for(const f of g.previousThreadMessages)r.setQueryData(f.queryKey,f.data);fs(r,g.previousThreadsList)}const p=j.body.messageIds?.length??0,m=za(v);if(m){o(Pa(m,p,"move"));return}o({title:p>1?`Couldn't move ${p} messages`:"Couldn't move this message",detail:we(v),error:v})},onSettled:(v,j,g,p)=>{p&&(s&&r.invalidateQueries({queryKey:p.threadMessagesPrefix}),Ce(r,p.listPrefixes),n&&r.invalidateQueries({queryKey:ms({path:{accountId:n}})}))}});return{moveMessages:l.useCallback((v,j)=>{v.length!==0&&is(v,g=>i({body:{messageIds:g,destinationMailboxId:j}}))},[i]),isPending:c,isError:u}},ud="This message could not be processed. Please try again. If it keeps failing, report it.",md=(e,s)=>e.replace(`Message ${s}'s`,"This message's"),gn=e=>{if(e.failureCount===0)return;const s=e.failures?.[0],n=s?.reason??ud,a=s?md(n,s.messageId):n;throw new Br(a,422)};function _a({mailboxId:e,threadId:s,accountId:n,onAfterOptimisticRemove:a}){const r=ue(),{pushError:o}=be(),i=Ne([e]),c=s?Se({path:{threadId:s}}):[],u=()=>{s&&r.invalidateQueries({queryKey:c}),Ce(r,i),n&&r.invalidateQueries({queryKey:ms({path:{accountId:n}})})},b=()=>(f,d)=>{u(),a?.(d.body.messageIds)},v=f=>(d,h)=>{o({title:f(h.body.messageIds.length),detail:we(d),error:d})},j=pe({mutationFn:async f=>{const{data:d}=await Pr({...f,throwOnError:!0});return gn(d),d},meta:{softError:!0},onSuccess:b(),onError:v(f=>f>1?`Couldn't report ${f} messages as spam`:"Couldn't report this message as spam")}),g=pe({mutationFn:async f=>{const{data:d}=await _r({...f,throwOnError:!0});return gn(d),d},meta:{softError:!0},onSuccess:b(),onError:v(f=>f>1?`Couldn't undo the spam report for ${f} messages`:"Couldn't undo the spam report")}),p=l.useCallback(f=>{f.length!==0&&is(f,d=>j.mutateAsync({body:{messageIds:d}}))},[j.mutateAsync]),m=l.useCallback(f=>{f.length!==0&&is(f,d=>g.mutateAsync({body:{messageIds:d}}))},[g.mutateAsync]);return{reportSpam:p,notSpam:m,isReporting:j.isPending,isRestoring:g.isPending}}const fd=({accountId:e,messageId:s,threadId:n,mailboxId:a,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=La(e),{junkMailboxId:c}=Da(e),{moveMessages:u,isPending:b}=vs({mailboxId:a,threadId:n,accountId:e}),{notSpam:v,isRestoring:j}=_a({mailboxId:a,threadId:n,accountId:e}),{data:g}=se({...us({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),p={inboxMailboxId:i,junkMailboxId:c},m=ld(r,p),f=l.useCallback(()=>{m&&u([s],m)},[u,s,m]),d=l.useCallback(()=>{v([s])},[v,s]);if(o)return{show:!0,label:id,onUndo:d,isUndoing:j};if(!od(r,a,p)||!r)return{show:!1,label:"",isUndoing:!1};const y=r.fromMailboxId?g?.items.filter(x=>x.mailboxId===r.fromMailboxId).map(x=>Ur(x))[0]:void 0;return{show:!0,label:ad(r,y),onUndo:m?f:void 0,isUndoing:b,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function hd({accountId:e,messageId:s,threadId:n,mailboxId:a,autoMoved:r,spamReport:o}){const i=fd({accountId:e,messageId:s,threadId:n,mailboxId:a,autoMoved:r,spamReport:o});return i.show?t.jsx(Cl,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const pd=({trigger:e,children:s,align:n="right"})=>{const[a,r]=l.useState(!1),o=l.useRef(null),i=l.useCallback(c=>{o.current&&!o.current.contains(c.target)&&r(!1)},[]);return _s({id:"dropdown-menu",open:a,answers:{back:()=>r(!1)}}),l.useEffect(()=>(a&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)),[a,i]),t.jsxs("div",{ref:o,className:"relative",children:[t.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r(!a)},className:E("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),a&&t.jsx("div",{className:E("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:s})]})},Ss=({onClick:e,disabled:s,destructive:n,children:a})=>t.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),s||e()},disabled:s,className:E("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",s&&"opacity-50 cursor-not-allowed",!s&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:a}),gd=()=>t.jsx("div",{className:"my-1 h-px bg-line"}),xn=(e,s)=>e.filter(n=>!s.has(n.messageId)),zf=e=>e.filter(s=>s.isDeleted!==!0),qs=({mailboxId:e,threadId:s,accountId:n,messages:a,onAfterOptimisticRemove:r})=>{const o=ue(),{pushError:i}=be(),{requestAppointment:c}=Bn(),u=l.useRef([]),b=l.useRef(async()=>{}),{mutateAsync:v,isPending:j}=pe({...Kr(),meta:_n(409),onMutate:async m=>{const f=new Set(m.body.messageIds??[]),d=s?Se({path:{threadId:s}}):[],h=Ne(It(f,a??[],e));await Promise.all([o.cancelQueries({queryKey:d}),hs(o,h)]);const y=s?o.getQueriesData({queryKey:d}).filter(k=>k[1]!==void 0).map(([k,C])=>({queryKey:k,data:C})):[],x=ps(o,h);return s&&o.setQueriesData({queryKey:d},k=>k&&{...k,items:xn(k.items,f)}),gs(o,h,k=>xn(k,f)),r?.(Array.from(f)),{threadMessagesPrefix:d,listPrefixes:h,previousThreadMessages:y,previousThreadsList:x}},onSuccess:(m,f)=>{const d=m?.failureCount??0;if(d===0)return;const h=f.body.messageIds?.length??0;i({severity:"warning",title:d>1?`Couldn't delete ${d} of ${h} messages yet`:"Couldn't delete this message yet",detail:"Something else moved it while the delete was being prepared. It is back where it now sits — try again."})},onError:(m,f,d)=>{if(d){for(const k of d.previousThreadMessages)o.setQueryData(k.queryKey,k.data);fs(o,d.previousThreadsList)}const h=$r(m);if(h){const k=u.current;c({accountId:h.accountId,role:h.role,reason:h.reason,action:{kind:"delete",count:k.length},onAppointed:()=>b.current(k)});return}const y=f.body.messageIds?.length??0,x=za(m);if(x){i(Pa(x,y,"delete"));return}i({title:y>1?`Couldn't delete ${y} messages`:"Couldn't delete this message",detail:we(m),error:m})},onSettled:(m,f,d,h)=>{h&&(s&&o.invalidateQueries({queryKey:h.threadMessagesPrefix}),Ce(o,h.listPrefixes),n&&o.invalidateQueries({queryKey:ms({path:{accountId:n}})}))}}),g=l.useCallback(m=>is(m,f=>v({body:{messageIds:f}})),[v]);return l.useEffect(()=>{b.current=g},[g]),{deleteMessages:l.useCallback(m=>{m.length!==0&&(u.current=m,g(m))},[g]),isPending:j}},Ba="inline-flex items-center justify-center transition-colors",xd=E(Ba,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),bd=E(Ba,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),Qs=({accountId:e,currentMailboxId:s,onMove:n,disabled:a=!1,disabledHint:r,variant:o="icon-only",label:i,defaultOpen:c=!1})=>{const[u,b]=l.useState(c),[v,j]=l.useState(),g=bt(),p=l.useRef(null),m=l.useRef(null),f=l.useRef(null),d=i??"Move to folder",h=l.useId(),y=Un(),{data:x,isLoading:k,isError:C,error:I,refetch:M}=se({...us({path:{accountId:e}}),staleTime:1/0,enabled:u}),w=Oa(e),{createFolderIn:N}=$n(e),T=l.useMemo(()=>Kn({mailboxes:x?.items??[],folderAppointments:w,currentMailboxId:s,translator:y}),[x?.items,w,s,y]),A=qn(x?.items??[]),K=T.find(B=>B.id===v),L=l.useCallback(()=>{b(!1),j(void 0);const B=document.activeElement;B&&m.current?.contains(B)&&f.current?.focus()},[]),W=l.useCallback(()=>{K&&(L(),n(K.id))},[K,L,n]);_s({id:"move-to",open:u,answers:{back:L}}),l.useEffect(()=>{if(!u||!g)return;const B=J=>{const U=J.target;p.current?.contains(U)||m.current?.contains(U)||L()};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[u,g,L]);const P=()=>p.current?.getBoundingClientRect()??null,$=a||!!r,F=t.jsxs("button",{type:"button",ref:f,onClick:B=>{B.stopPropagation(),!$&&b(J=>!J)},"aria-label":d,"aria-haspopup":g?"tree":"dialog","aria-expanded":u,"aria-controls":u?h:void 0,title:r,className:o==="icon-only"?xd:bd,children:[t.jsx(xt,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&t.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),z=k?t.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):C?t.jsx("div",{className:"p-3",children:t.jsx(Le,{variant:"inline",title:"Couldn't load folders",error:I,onRetry:()=>M()})}):t.jsx(qr,{folders:T,selectedId:v,delimiter:A,onSelect:j,onCreateFolder:N,onCancel:L,autoFocusFilter:g,labels:{filterPlaceholder:"Filter folders…",filterAriaLabel:"Filter folders"}}),_=K&&t.jsx("div",{className:"shrink-0 border-t border-line p-2",children:t.jsx(Q,{variant:"primary",onClick:W,className:"h-11 w-full font-semibold",children:`Move to ${K.label}`})});return g?t.jsxs("div",{ref:p,className:"relative inline-block",children:[F,t.jsx(Yo,{open:u,align:"end",panelRef:m,getAnchor:P,children:t.jsxs("div",{id:h,ref:m,className:E("w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[z,_]})})]}):t.jsxs(t.Fragment,{children:[F,t.jsx($e.Root,{open:u,onOpenChange:B=>B?b(!0):L(),children:t.jsxs($e.Portal,{children:[t.jsx($e.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),t.jsxs($e.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:{maxHeight:"85dvh"},id:h,children:[t.jsx($e.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),t.jsx($e.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),t.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:z}),_]})]})})]})},vd=({messageId:e,threadId:s,mailboxId:n,isRead:a,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:u})=>{const b=ue(),v=Ko(),{pushError:j}=be(),g=qo()?.messageId,{mutate:p,isPending:m}=pe({...Ps(),onMutate:async P=>{const $=P.body.isRead??!0,F=new Set(P.body.messageIds??[]),z=Se({path:{threadId:s}}),_=Ne([n]);await Promise.all([b.cancelQueries({queryKey:z}),hs(b,_)]);const B=b.getQueriesData({queryKey:z}).filter(U=>U[1]!==void 0).map(([U,Y])=>({queryKey:U,data:Y})),J=ps(b,_);return b.setQueriesData({queryKey:z},U=>U&&{...U,items:Fs(U.items,F,$)}),gs(b,_,U=>Fs(U,F,$)),{threadMessagesPrefix:z,listPrefixes:_,previousThreadMessages:B,previousThreadsList:J}},onError:(P,$,F)=>{if(F){for(const _ of F.previousThreadMessages)b.setQueryData(_.queryKey,_.data);fs(b,F.previousThreadsList)}const z=$.body.isRead??!0;j({title:z?"Couldn't mark as read":"Couldn't mark as unread",detail:we(P),error:P})},onSettled:(P,$,F,z)=>{z&&(b.invalidateQueries({queryKey:z.threadMessagesPrefix}),Ce(b,z.listPrefixes))}}),f=l.useCallback(P=>{g&&P.includes(g)&&v()},[g,v]),{deleteMessages:d,isPending:h}=qs({mailboxId:n,threadId:s,onAfterOptimisticRemove:f}),{moveMessages:y,isPending:x}=vs({mailboxId:n,threadId:s,accountId:r,onAfterOptimisticRemove:f}),{toggleTrusted:k,isPending:C,error:I,reset:M}=sa({messageId:e}),w=()=>{p({body:{messageIds:[e],isRead:!1}})},N=()=>{d([e])},T=()=>{o&&k(o,i)},A=m||h||x||C,K=A||!o,L=l.useCallback(P=>{y([e],P)},[y,e]),W=o?void 0:"Sender has no parseable address";return t.jsxs("div",{className:"flex flex-col items-end gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[r&&t.jsx(Qs,{accountId:r,currentMailboxId:n,onMove:L,disabled:A,label:"Move this message"}),t.jsxs(pd,{trigger:t.jsx(Zo,{className:"size-4"}),children:[t.jsxs(Ss,{onClick:T,disabled:K,children:[i?t.jsx(Us,{className:"size-4 text-positive"}):t.jsx(Ds,{className:"size-4 opacity-0"}),t.jsx("span",{title:W,children:"Trusted sender"})]}),a&&t.jsxs(Ss,{onClick:w,disabled:A,children:[t.jsx(kt,{className:"size-4"}),"Mark as unread"]}),u&&t.jsxs(Ss,{onClick:u,children:[t.jsx(ua,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),t.jsx(gd,{}),t.jsxs(Ss,{onClick:N,disabled:A,destructive:!0,children:[t.jsx(ds,{className:"size-4"}),"Delete"]})]})]}),I&&t.jsx("div",{className:"w-64",children:t.jsx(Le,{variant:"inline",title:"Couldn't update trust",error:I,onRetry:()=>{M(),T()}})})]})},yd=e=>{const s=e.toUpperCase();return s==="OCTET-STREAM"?"FILE":s},jd=e=>{const s=e.toLowerCase().replace(/[^a-z0-9]/g,"");return s.length>0?`attachment.${s}`:"attachment"},bn=e=>e.filter(s=>!s.isMultipart&&s.disposition===Qr.Attachment&&s.contentUrl.length>0).map(s=>({bodyPartId:s.bodyPartId,filename:ci(s.dispositionFilename??"",jd(s.mediaSubtype)),typeLabel:yd(s.mediaSubtype),sizeOctets:s.sizeOctets,contentUrl:s.contentUrl})),vn={status:"idle"},kd=({messageId:e,bodyParts:s,hasAttachment:n=!1,className:a})=>{const{getToken:r}=Qn(),o=ue(),[i,c]=l.useState({}),u=l.useMemo(()=>bn(s??[]),[s]),b=Hr({path:{messageId:e}}),v=m=>Qt(m.contentUrl,r).catch(f=>{if(!hi(qt(f)))throw f;return o.refetchQueries({queryKey:b}).then(()=>{const d=o.getQueryData(b),h=d?bn(d.bodyParts).find(y=>y.bodyPartId===m.bodyPartId):void 0;return Qt(h?.contentUrl??m.contentUrl,r)})}),j=(m,f)=>c(d=>({...d,[m]:f})),g=m=>{const f=u.find(d=>d.bodyPartId===m);if(!f)throw new Error(`No attachment part ${m} on message ${e}`);j(m,{status:"downloading"}),v(f).then(d=>{di(d,f.filename),j(m,vn)}).catch(d=>{const h=qt(d),y=ui(d),{title:x,detail:k}=mi(h,f.filename,y);j(m,{status:"failed",title:x,detail:k,reportUrl:fi(h,f.filename,y)})})},p=n&&s!==void 0&&u.length===0;return t.jsx(kl,{className:a,attachments:u.map(m=>({attachmentId:m.bodyPartId,filename:m.filename,typeLabel:m.typeLabel,sizeOctets:m.sizeOctets,download:i[m.bodyPartId]??vn})),onDownload:g,hasUnlistedAttachment:p})},Ua=e=>e.syncStatus===Wr.abandoned?e.abandonedMutation:ls.none;function Cd({threadMessage:e,accountId:s,className:n}){const a=Ua(e),r=a===ls.delete?"delete_failed":a===ls.move?"move_failed":void 0,{accountId:o}=Ks(r==="move_failed"&&!s?e.mailboxId:void 0),i=s??o,{deleteMessages:c,isPending:u}=qs({mailboxId:e.mailboxId,threadId:e.threadId,accountId:i,messages:[e]}),{moveMessages:b,isPending:v}=vs({mailboxId:e.mailboxId,threadId:e.threadId,accountId:i}),j=l.useCallback(()=>{c([e.messageId])},[c,e.messageId]),g=l.useCallback(m=>{b([e.messageId],m)},[b,e.messageId]),p=l.useMemo(()=>r?Gr(Vr({title:As[r].title,errorMessage:`Message ${e.messageId}: status=${e.status} syncStatus=${e.syncStatus} abandonedMutation=${e.abandonedMutation}`})):void 0,[r,e.messageId,e.status,e.syncStatus,e.abandonedMutation]);return r?t.jsx(Yl,{settlement:r,onRetry:r==="delete_failed"?j:void 0,action:r==="move_failed"&&i?t.jsx(Qs,{accountId:i,currentMailboxId:e.mailboxId,onMove:g,disabled:v,variant:"compact",label:As.move_failed.retryLabel}):void 0,retryPending:r==="delete_failed"?u:v,reportHref:p,className:n}):null}const Nd=({messageId:e,threadId:s,mailboxId:n,accountId:a,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:u,showRaw:b,onToggleRaw:v,onReply:j,onReplyAll:g,onForward:p})=>{const m=ue(),{deleteMessages:f}=qs({mailboxId:n,threadId:s}),{moveMessages:d}=vs({mailboxId:n,threadId:s,accountId:a}),{toggleTrusted:h}=sa({messageId:e}),{mutate:y}=pe({...Ps(),onSettled:()=>{m.invalidateQueries({queryKey:Se({path:{threadId:s}})}),Ce(m,Ne([n]))}}),x=l.useCallback(M=>{d([e],M)},[d,e]),k=l.useCallback(()=>{f([e])},[f,e]),C=l.useCallback(()=>{y({body:{messageIds:[e],isRead:!r}})},[y,e,r]),I=[];return c&&I.push({key:"trusted",label:u?"Trusted sender":"Mark sender trusted",icon:u?t.jsx(Us,{className:"size-4 text-positive"}):t.jsx(Ds,{className:"size-4"}),onSelect:()=>h(c,u)}),v&&I.push({key:"raw",label:b?"Show formatted":"Show raw email",icon:t.jsx(ua,{className:"size-4"}),onSelect:v}),t.jsx(Ca,{hasThread:!0,onReply:j,onReplyAll:g,onForward:p,isStarred:o,onToggleStar:i,onDelete:k,isRead:r,onToggleRead:C,overflowItems:I,moveSlot:a?t.jsx(Qs,{accountId:a,currentMailboxId:n,onMove:x,label:"Move this message"}):void 0})},wd=()=>t.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",children:[t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),Sd=({messageId:e,enabled:s=!0})=>{const{data:n,isLoading:a,isError:r,error:o,refetch:i}=se({...Jr({path:{messageId:e}}),enabled:s});if(a)return t.jsx("div",{className:"message-body",children:t.jsx(wd,{})});if(r)return t.jsx("div",{className:"message-body",children:t.jsx(Le,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const c=n?.raw??"";return c===""?t.jsx("div",{className:"message-body",children:t.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):t.jsx("div",{className:"message-body",children:t.jsx("pre",{className:"email-text whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-sunken rounded-md p-3 max-h-[32rem] overflow-auto",children:c})})},Id=()=>t.jsx(Us,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),$a=(e,s)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:s,snippet:e.snippet||"",bodyHtml:""}),Ka=({isStarred:e,onToggleStar:s,isStarPending:n,hoverReveal:a})=>t.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),s()},disabled:n,"aria-label":e?"Remove star":"Add star",className:E("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":E("text-fg-subtle hover:text-warning",a&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),n&&"opacity-50"),children:t.jsx(He,{className:E("size-3.5",e&&"fill-current")})}),Rd=({threadMessage:e,isFocused:s,onToggle:n,onToggleStar:a,isStarPending:r})=>{const o=Hn(e.sentDate,"datetime"),i=$a(e,o);return t.jsx(Na,{message:i,onClick:n,isFocused:s,isUnread:!e.isRead,trailing:t.jsxs(t.Fragment,{children:[e.hasAttachment&&t.jsx(Bs,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),t.jsx(Ka,{isStarred:e.hasStars,onToggleStar:a,isStarPending:r,hoverReveal:!0}),t.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},Md=({threadMessage:e,messageData:s,isLoading:n,isError:a,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:u,isStarPending:b,accountId:v,showRaw:j,onToggleRaw:g,mobile:p,onReply:m,onReplyAll:f,onForward:d})=>{const h=Hn(e.sentDate,"long"),y=!e.isRead,x=s?.envelope.from[0]?.flags?.trusted?.value===!0,k=s?.envelope.from[0]?.flags?.blocked?.value===!0,C=s?.envelope.from[0]?.addressId,I=$a(e,h),M=e.autoMoved||e.spamReport?t.jsx(hd,{accountId:v,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return t.jsx(wa,{message:I,isFocused:p?!1:i,onHeaderClick:c,senderBadge:x&&!k?t.jsx(Id,{}):void 0,trailing:t.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:h}),to:s?t.jsx(yl,{label:"To",addresses:s.envelope.to}):null,indicators:M||!p?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[M,!p&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center justify-end gap-1",children:t.jsx(Ka,{isStarred:e.hasStars,onToggleStar:u,isStarPending:b})}),y&&t.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:p?void 0:t.jsx(vd,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:v,fromAddressId:C,isTrusted:x,showRaw:j,onToggleRaw:g}),actionBar:p?t.jsx(Nd,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:v,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:u,fromAddressId:C,isTrusted:x,showRaw:j,onToggleRaw:g,onReply:m,onReplyAll:f,onForward:d}):void 0,body:t.jsxs(t.Fragment,{children:[t.jsx(Cd,{threadMessage:e,accountId:v,className:"mt-3"}),n?t.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):a&&Yr(r)?t.jsx("div",{className:"mt-3",children:t.jsx(ot,{message:"This message is no longer on the mail server. It was moved or deleted in another mail app."})}):a&&Zr(r)?t.jsx("div",{className:"mt-3",children:t.jsx(ot,{message:"This message has been deleted"})}):a?t.jsx("div",{className:"mt-3",children:t.jsx(Le,{variant:"inline",title:"Couldn't load this message",error:r,onRetry:o})}):j?t.jsx("div",{className:"mt-3",children:t.jsx(Sd,{messageId:e.messageId})}):t.jsxs("div",{className:"mt-3",children:[t.jsx(ti,{bodyParts:s?.bodyParts,messageId:e.messageId,fromAddressId:s?.envelope.from[0]?.addressId,isTrusted:x,isBlocked:k,category:Fa(e.category)}),t.jsx(kd,{messageId:e.messageId,bodyParts:s?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})]})})},Td=({threadMessage:e,isExpanded:s,isFocused:n,onToggle:a,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:u,onReplyAll:b,onForward:v})=>{const[j,g]=l.useState(!1),{data:p,isLoading:m,isError:f,error:d,refetch:h}=se({...zs({path:{messageId:e.messageId}}),enabled:s,meta:{softError:!0}});return s?t.jsx(Md,{threadMessage:e,messageData:p,isLoading:m,isError:f,error:d,onRetry:()=>h(),isFocused:n,onToggle:a,onToggleStar:r,isStarPending:o,accountId:i,showRaw:j,onToggleRaw:()=>g(y=>!y),mobile:c,onReply:u,onReplyAll:b,onForward:v}):t.jsx(Rd,{threadMessage:e,isFocused:n,onToggle:a,onToggleStar:r,isStarPending:o})},Ad=()=>t.jsxs("div",{className:"animate-pulse p-4",children:[t.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),t.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,s)=>t.jsxs("div",{className:"flex gap-3 py-3",children:[t.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),t.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},s))})]}),Pf=({threadId:e,mailboxId:s,subject:n,selectedMessageId:a,authenticity:r,onOpenIntelligence:o,onBack:i,onSwipeNext:c,onSwipePrevious:u,mobileIntelligenceOpen:b,listOnScreen:v=!1})=>{const j=bt(),{accountId:g}=Ks(s),{data:p,isLoading:m,isError:f,error:d,refetch:h}=se({...Wn({path:{threadId:e}})}),y=l.useMemo(()=>p?.items??[],[p?.items]),x=y[y.length-1],k=l.useMemo(()=>[...y].reverse(),[y]),C=l.useRef(new Map),[I,M]=l.useState(new Set),[w,N]=l.useState(null),[T,A]=l.useState(0);l.useEffect(()=>{if(y.length>0&&e!==w){N(e);const R=new Set([y[y.length-1].threadMessageId]);if(a){const O=y.find(V=>V.messageId===a);O&&R.add(O.threadMessageId)}M(R),A(0)}},[e,y,w,a]);const K=l.useCallback(R=>{M(O=>{const V=new Set(O);return V.has(R)?V.delete(R):V.add(R),V})},[]),L=l.useCallback(R=>{const O=k[R];if(!O)return;C.current.get(O.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[k]),W=l.useCallback(()=>{if(k.length===0)return;const R=Math.min(T+1,k.length-1);A(R),L(R)},[k.length,T,L]),P=l.useCallback(()=>{if(k.length===0)return;const R=Math.max(T-1,0);A(R),L(R)},[k.length,T,L]),$=l.useCallback(()=>{const R=k[T];R&&K(R.threadMessageId)},[k,T,K]);sd({messages:y,expandedIds:I,threadId:e,mailboxId:s,accountId:g});const{toggleStar:F,isPending:z,pendingMessageId:_}=Ea({threadId:e,mailboxId:s,messages:y}),B=Xr(),J=Pn(),U=a??x?.messageId,Y=l.useCallback((R,O)=>{O&&J({threadId:e,messageId:O,mode:R})},[J,e]),te=l.useCallback(()=>Y("reply",U),[Y,U]),ae=l.useCallback(()=>Y("reply-all",U),[Y,U]),Z=l.useCallback(()=>Y("forward",U),[Y,U]),ne=l.useRef(null),X=B?.kind==="reply"?`${B.mode}:${B.sourceMessageId}`:void 0;if(l.useEffect(()=>{X&&ne.current?.scrollIntoView({behavior:"smooth",block:"start"})},[X]),pi({enabled:!m&&y.length>0&&B===void 0,bindings:[...v?[]:[{key:"j",action:"focusNext",handler:W,preventDefault:!0},{key:"ArrowDown",action:"focusNext",handler:W,preventDefault:!0},{key:"k",action:"focusPrevious",handler:P,preventDefault:!0},{key:"ArrowUp",action:"focusPrevious",handler:P,preventDefault:!0},{key:"Enter",action:"openFocused",handler:$,preventDefault:!0},{key:"o",action:"openFocused",handler:$,preventDefault:!0}],{key:"r",action:"reply",handler:te,preventDefault:!0},{key:"R",action:"replyAll",handler:ae,noModifiers:!1,preventDefault:!0},{key:"f",action:"forward",handler:Z,preventDefault:!0}]}),m)return t.jsx(Ad,{});if(f)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(Le,{title:B?"Couldn't load this conversation, so there is nothing to answer":"Couldn't load this conversation",error:d,onRetry:()=>h()})});if(y.length===0)return t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:B?t.jsx(Le,{variant:"inline",title:"There is nothing here to answer",error:"This conversation has no messages left. Another mail client may have moved or deleted them."}):t.jsx(ot,{message:"No messages in this thread"})});const de=n||y[0]?.subject||"(No subject)",fe=y.length,me=R=>t.jsx("div",{"data-testid":"conversation-messages",children:k.map((O,V)=>t.jsx("div",{ref:he=>{he&&C.current.set(O.threadMessageId,he)},children:t.jsx(Td,{threadMessage:O,isExpanded:I.has(O.threadMessageId),isFocused:V===T,onToggle:()=>K(O.threadMessageId),onToggleStar:()=>F(O.messageId,O.hasStars),isStarPending:z&&_===O.messageId,accountId:g,mobile:R,onReply:R?()=>Y("reply",O.messageId):void 0,onReplyAll:R?()=>Y("reply-all",O.messageId):void 0,onForward:R?()=>Y("forward",O.messageId):void 0})},O.threadMessageId))}),re=B&&t.jsx("div",{ref:ne,children:B.kind==="reply"?t.jsx(Yc,{surface:B}):t.jsx("div",{className:"border-b border-line bg-canvas p-4",children:t.jsx(Le,{variant:"inline",title:"That is not a way to answer a message",error:`"${B.segment}" is not reply, reply-all or forward.`})})}),q=t.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[t.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:de}),t.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[fe," ",fe===1?"message":"messages"]})]});return j?t.jsxs("article",{className:"h-full flex flex-col",children:[q,r?.dkimMismatch&&t.jsx(fn,{authenticity:r,onOpenIntelligence:o}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[re,me(!1)]})]}):t.jsxs(lc,{thread:{subject:de,messages:[]},onBack:i??(()=>{}),intelligenceOpen:b,onToggleIntelligence:o,onSwipeNext:c,onSwipePrevious:u,children:[r?.dkimMismatch&&t.jsx(fn,{authenticity:r,onOpenIntelligence:o}),re,me(!0)]})},Ed=e=>{switch(Ua(e)){case ls.delete:return{settlement:"delete_failed"};case ls.move:return{settlement:"move_failed"};default:return{}}},Fd=({isOpen:e,onClose:s,children:n,ariaLabel:a="Navigation",side:r="left",widthClassName:o="w-[80vw] max-w-[320px]",answers:i})=>{const c=l.useRef(null);if(_s({id:"drawer",open:e,answers:{back:s,...i}}),Gn(c,e),l.useEffect(()=>{if(!e)return;const b=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=b}},[e]),!e)return null;const u=r==="left"?"left-0 border-r animate-in slide-in-from-left duration-150":"right-0 border-l animate-in slide-in-from-right duration-150";return t.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":a,children:[t.jsx("button",{type:"button","aria-label":"Close menu",onClick:s,className:"absolute inset-0 bg-black/40 animate-in fade-in duration-150 cursor-default"}),t.jsxs("div",{ref:c,tabIndex:-1,className:E("safe-area-frame absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,u),children:[t.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:t.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 menu",children:t.jsx(qe,{className:"size-5"})})}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:n})]})]})},Is=e=>({messageId:e,tab:void 0,offering:!1,picked:[],answering:"",failure:{suggestionId:"",text:""}}),Ld=(e,s)=>{const n=+(s.state==="Pending")-+(e.state==="Pending");return n!==0?n:s.sequence-e.sequence},Dd=(e,s)=>s.kind==="refused"?`Couldn't ${e}: ${s.message} Try again, or answer from your calendar app.`:"";function Od(e,s,n){const a=e.messageId,{suggestions:r,isLoading:o,error:i}=Si(a),c=Ki(),{calendars:u,defaultCalendarId:b,colorByCalendarId:v,timeZoneByCalendarId:j}=c,g=Ci(c),p=Ii(),m=Di(),f=Oi(),[d,h]=l.useState(()=>Is(a)),y=d.messageId===a?d:Is(a),x=l.useRef(a);x.current=a;const k=R=>{x.current===a&&h(O=>({...O.messageId===a?O:Is(a),...R}))},C=l.useMemo(()=>r.filter(Ri).filter(R=>Ht(R)!==void 0).sort(Ld)[0],[r]),I=r.filter(R=>R!==C&&R.state==="Pending"),M=C??I[0],w=M?Wt(M):"",N=qi(w===""?"1970-01-01":w,1),T=zi({...N,calendarIds:[],enabled:w!==""}),A=Ni(w===""?[]:[N]),K={threadId:e.threadId,threadSubject:e.subject??"",calendarId:b},L=e.fromName??e.fromEmail??"",W=Vi(y.failure.text||"the invitations in a message could not be read"),P=wi(g,W),$=(R,O,V)=>{k({answering:R,failure:{suggestionId:R,text:""}}),V().then(he=>k({answering:"",failure:{suggestionId:R,text:Dd(O,he)}}))},F=C?.suggestionId??"",z=y.failure.suggestionId===F?y.failure.text:"",_=y.failure.suggestionId===F?"":y.failure.text,B=C?Ht(C):void 0,J=C&&B?{invite:Ti(C,B.state,{...K,senderName:L}),whenText:Gt(C),calendarName:u.find(R=>R.id===b)?.name??"Calendar",color:v[b]??"cal-1",clashes:B.state==="pending"?Mi({start:C.dtStart,end:C.dtEnd},A.spans):[],rsvp:B.rsvp,busy:y.answering===C.suggestionId,failure:z,reportHref:W,addBlocked:P,sender:L}:void 0,U=w===""?[]:Ai(w,A.spans),Y=T.instances.filter(Qi).filter(R=>!R.allDay).sort((R,O)=>R.start.localeCompare(O.start)).map(R=>({event:Hi(R,j[R.calendarId]??"",Wi()),timeText:Pi(R.start),color:v[R.calendarId]??"cal-1"})),te=I.map(R=>({suggestion:Ei(R,{...K,sender:L}),whenText:Gt(R)})),ae=i===null?"":"Couldn't read the invitations in this message. Reopen it to try again.",Z=C?.method==="Cancel",ne=R=>{const O=r.find(V=>V.suggestionId===R);O&&f(Wt(O),R)},X=R=>{const O=r.find(V=>V.suggestionId===R);return O?.zoneCertainty==="Ambiguous"&&O.method!=="Cancel"},de=w===""?"":Fi(w,U,y.picked),fe=C!==void 0&&C.answerOvertakenBy!==eo.None,me={onAddInvite:()=>{if(X(F)){ne(F);return}$(F,"add this to your calendar",()=>p.accept(F,b))},onTentativeInvite:Z?void 0:()=>$(F,"add this as a maybe",()=>p.tentative(F,b)),onDeclineInvite:()=>$(F,"decline this",()=>p.decline(F)),onMuteInvite:()=>$(F,"stop these invitations",()=>p.dismiss(F,!0)),onRemoveInvite:Z?()=>$(F,"take this off your calendar",()=>p.accept(F,b)):void 0,onReopenInvite:Z?()=>$(F,"keep this on your calendar",()=>p.dismiss(F,!1)):fe?void 0:()=>$(F,"take this answer back",()=>p.reopen(F)),onOpenNewerInvite:n&&C&&C.supersededByThreadId!==""?()=>n({threadId:C.supersededByThreadId,messageId:C.supersededByMessageId}):void 0,onOfferOtherTimes:()=>k({offering:!0}),onToggleSlot:R=>k({picked:y.picked.includes(R.startTime)?y.picked.filter(O=>O!==R.startTime):[...y.picked,R.startTime]}),onReplyWithSlots:s?()=>s({threadId:e.threadId,messageId:a},de):void 0,onAddSuggestion:R=>{if(X(R)){ne(R);return}$(R,"add this to your calendar",()=>p.accept(R,b))},onReviewSuggestion:I[0]?.method==="Cancel"?void 0:ne,onDismissSuggestion:R=>$(R,"dismiss this",()=>p.dismiss(R,!1)),onSelectEvent:R=>{const{calendarObjectId:O,recurrenceId:V}=Gi(R);m(w,O,V)}},re=J!==void 0||te.length>0||i!==null,q=y.tab!==void 0;return l.useEffect(()=>{o||q||h(R=>R.messageId===a&&R.tab!==void 0?R:{...R.messageId===a?R:Is(a),tab:re?"calendar":"sender"})},[o,q,re,a]),{surface:{data:{invite:J,prose:y.offering&&w!==""?{dayLabel:Vt(w),proposals:[],slots:U,picked:y.picked}:void 0,suggestions:te,day:Y,dayLabel:w===""?"":Vt(w),suggestionsBusy:y.answering!==""&&!J?.busy,failure:ae,suggestionsFailure:_,reportHref:W,addBlocked:P},actions:me},tab:y.tab??"sender",onTabChange:R=>k({tab:R})}}const qa=()=>{const{data:e}=se({...We(),staleTime:1/0});return e?.semanticSearchEnabled},zd=10,Qa=e=>({q:e?.toLowerCase()??"",limit:zd}),Pd=(e,s)=>{if(!s)return;const n=s.toLowerCase();return e?.find(a=>a.normalizedEmail===n)};function _d(e){const s=new Date(e),n=new Date;return s.toDateString()===n.toDateString()?"today":to(s,{month:"short",year:"numeric"})}function Ha(e){if(!e)return!0;const[,s]=e.split("@");return s?!s.includes("."):!0}const Bd="We can't verify the sender of this email, which could mean it's from an insecure source.",Ud="We couldn't read this sender's address, so we can't confirm who really sent this message.";function $d(e,s){const n=e.category??"personal";return{value:Vn(n)?n:"uncategorized",overridden:s?.flags?.category?.value!=null&&s.flags.category.value!==e.category}}function Kd(e,s){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:s?_d(s.createdAt):"unknown",inboundCount:s?.inboundCount,replyCount:s?.replyCount,addressUnverified:Ha(e.fromEmail)}}function qd(e){return e?.flags?{vip:e.flags.vip?.value===!0,muted:e.flags.muted?.value===!0,blocked:e.flags.blocked?.value===!0}:{}}function yn(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function Qd(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Hd(e,s){const n=[],a=e.displayNameCorrespondence;s&&(a===et.Unrelated?n.push(`The name it shows, "${s}", has nothing to do with ${e.fromDomain}.`):a===et.Lookalike?n.push(`The name it shows, "${s}", only looks like ${e.fromDomain}.`):a===et.ForeignAddress&&n.push(`The name it shows, "${s}", is an address ${e.fromDomain} cannot send from.`));const r=Wd(e.offDomainLinkDomains);return r.length>0&&n.push(`Its links go to ${Qd(r.slice(0,3))}.`),n}function Wd(e){return Array.isArray(e)?e.filter(s=>typeof s=="string"&&s.length>0):[]}function Gd(e,s){const n=s>0?s:void 0;if(Ha(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:Ud,similarCount:n};const a=e.authenticity;if(!a)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:Bd};if(!a.dkimMismatch){const b=yn(e),v=Hd(a,b);return v.length>0?{verdict:"caution",fromDomain:a.fromDomain,dkimDomain:a.dkimDomain,claimedBrand:b,summary:v.join(" ")}:{verdict:"aligned",fromDomain:a.fromDomain,dkimDomain:a.dkimDomain,summary:a.dkimDomain?`This message was signed by ${a.dkimDomain}.`:"Nothing looks unusual about this sender."}}const r=a.fromDomain,o=a.dkimDomain,i=yn(e),c=o?`it was actually sent from ${o}`:"its signature failed to verify",u=i?`The display name claims "${i}", but ${c}${o?` — not ${r}`:""}. Real senders use their own address.`:`This message claims to be from ${r}, but ${c}.`;return{verdict:"mismatch",fromDomain:r,dkimDomain:o,claimedBrand:i,summary:u,similarCount:n}}function Vd(e,s){const n=e?.fromEmail??null,a=e?.subject??"",{data:r,error:o}=se({...vt({query:Qa(n??void 0)}),enabled:!!n,staleTime:3e4}),i=Pd(r?.items,n??void 0),c=qa(),u=[a,n].filter(Boolean).join(" "),{data:b,isLoading:v,error:j}=se({...so({query:{query:u,limit:5}}),enabled:!!(e&&u.length>3)&&c===!0,staleTime:6e4,retry:1});return{data:l.useMemo(()=>{if(!e)return null;const p=(b?.items??[]).filter(y=>y.messageId!==e.messageId).map(y=>({id:y.messageId,threadId:y.threadId,mailboxId:s!=null&&y.mailboxIds.includes(s)?s:y.mailboxIds[0]??"",fromName:y.fromName??"",subject:y.subject??"(No subject)",timeLabel:y.sentDate!=null?Ge(y.sentDate*1e3):"",matched:y.matchedChunkType})),m=Kd(e,i),f=Gd(e,p.length),d=$d(e,i),h=qd(i);return{sender:m,authenticity:f,category:d,flags:h,similar:p}},[e,i,b,s]),isSimilarLoading:v,similarError:j,similarErrorIsFatal:Bt(j),semanticEnabled:c,addressErrorIsFatal:Bt(o),addressId:i?.addressId,address:i}}function Jd(e,s,n=[]){const a={...e??{}};for(const[r,o]of Object.entries(s))o==null?delete a[r]:a[r]={...o,setAt:o.setAt??Date.now()};for(const r of n)delete a[r];return a}function Yd({addressId:e,senderEmail:s}){const n=ue(),{pushError:a}=be(),r=no({query:Qa(s)}),{mutate:o,isPending:i}=pe({...ao(),onMutate:async v=>{const j=v.body.flags??{},g=v.body.clearFlags??[];await n.cancelQueries({queryKey:r});const p=n.getQueryData(r);return n.setQueryData(r,m=>m&&{...m,items:m.items.map(f=>f.addressId===v.path.addressId?{...f,flags:Jd(f.flags,j,g)}:f)}),{previous:p}},onError:(v,j,g)=>{g?.previous!==void 0&&n.setQueryData(r,g.previous),a({title:"Couldn't update sender preference",detail:we(v),error:v})},onSettled:()=>{n.invalidateQueries({queryKey:r})}}),c=l.useCallback(v=>{if(!e){ro(new Error(`Quick action fired but the sender's address record did not resolve (sender: ${s??"unknown"}). This should never happen — the address row exists.`));return}o({path:{addressId:e},body:v})},[e,o,s]),u=l.useCallback(v=>c({flags:v}),[c]),b=l.useCallback(v=>c({clearFlags:v}),[c]);return{updateFlags:u,clearFlags:b,isPending:i}}const _f=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",Zd=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function Bf(e,s){e.recordEvent("rescue.candidates_surfaced",{count:String(s)})}function Uf(e,s){e.recordEvent("rescue.flow_opened",{count:String(s)})}function $f(e,s){e.recordEvent("rescue.committed",{selected:String(s.selected),total:String(s.total),destination:s.toInbox?"inbox":"other"})}function Xd(e,s){e.recordEvent("rescue.sent_to_junk",{count:String(s.count),senderTrust:s.senderTrust,wasRescuable:String(s.wasRescuable)})}const eu=e=>e!=="uncategorized",su=lo.map(e=>e.category).filter(eu),tu=e=>e.spamReport?"notSpam":"reportSpam",nu=e=>{const{similarError:s,similarErrorIsFatal:n,isSimilarLoading:a,semanticEnabled:r}=e;return r===!1?"off":s&&!n?"error":a?"loading":"ready"};function au(){return t.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[t.jsx(Qe,{className:"size-3.5 text-fg-subtle"}),t.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),t.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),t.jsxs("div",{className:"flex-1 space-y-1.5",children:[t.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),t.jsx("div",{className:"h-8 rounded bg-surface"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,s)=>t.jsx("div",{className:"h-6 w-16 rounded bg-surface"},s))})]})]})]})}function ru({isOpen:e,current:s,hasOverride:n,onSelect:a,onClear:r,onCancel:o}){const i=l.useRef(null);return Gn(i,e),e?t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx(io,{label:"Dismiss reclassify sender",onDismiss:o,className:"backdrop-blur-sm"}),t.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":"Reclassify sender",tabIndex:-1,className:"relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),t.jsxs("div",{className:"mt-4 flex flex-col gap-1",children:[su.map(c=>t.jsxs("button",{type:"button",onClick:()=>a(c),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm transition-colors hover:bg-surface-raised ${c===s?"font-semibold text-accent":"text-fg"}`,children:[Os[c],c===s&&t.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},c)),n&&t.jsx("button",{type:"button",onClick:r,className:"mt-1 flex min-h-11 items-center rounded border-t border-line px-3 text-left text-sm text-fg transition-colors hover:bg-surface-raised",children:"Remove override — classify automatically again"})]}),t.jsx("div",{className:"mt-6 flex justify-end",children:t.jsx("button",{type:"button",onClick:o,className:"inline-flex min-h-11 items-center justify-center rounded border border-line px-4 text-sm font-medium transition-colors hover:bg-surface-raised",children:"Cancel"})})]})]}):null}function ou({thread:e,onClose:s,mailboxId:n,accountId:a,hideCloseButton:r,onAfterOptimisticRemove:o,onReplyWithText:i,onOpenThread:c}){const{data:u,address:b,addressId:v,isSimilarLoading:j,similarError:g,similarErrorIsFatal:p,semanticEnabled:m}=Vd(e,n),f=Od(e,i,c),[d,h]=l.useState(!1),y=e.fromEmail??void 0,{updateFlags:x,clearFlags:k}=Yd({addressId:v,senderEmail:y}),{reportSpam:C,notSpam:I,isReporting:M,isRestoring:w}=_a({mailboxId:e.mailboxId,threadId:e.threadId,accountId:a,onAfterOptimisticRemove:o}),N=oo(),T=tu(e),A=l.useCallback(()=>{I([e.messageId])},[I,e.messageId]),K=l.useCallback(()=>{Xd(N,{count:1,senderTrust:e.senderTrust,wasRescuable:Zd(e)}),C([e.messageId])},[C,e,N]),L=l.useCallback(()=>{},[]),W=l.useCallback(()=>{const U=u?.flags?.vip!==!0;x({vip:{value:U}})},[u?.flags?.vip,x]),P=l.useCallback(()=>{const U=u?.flags?.muted!==!0;x({muted:{value:U}})},[u?.flags?.muted,x]),$=l.useCallback(U=>{h(!1),x({category:{value:U}})},[x]),F=l.useCallback(()=>{h(!1),k(["category"])},[k]),z=v!==void 0,_={onToggleVip:z?W:void 0,onToggleMute:z?P:void 0,onReclassify:z?()=>h(!0):void 0,onNotSpam:T==="notSpam"?A:void 0,onReportSpam:T==="reportSpam"?K:void 0},B=({mailboxId:U,threadId:Y,messageId:te,className:ae,ariaLabel:Z,children:ne})=>t.jsx(Jn,{to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:U,threadId:Y,messageId:te},search:X=>X,variant:"row",className:ae,"aria-label":Z,children:ne});if(!u)return t.jsx(au,{});const J=nu({similarError:g,similarErrorIsFatal:p,isSimilarLoading:j,semanticEnabled:m});return t.jsxs(t.Fragment,{children:[t.jsx(ha,{data:u,calendar:f.surface,tab:f.tab,onTabChange:f.onTabChange,onClose:s,hideCloseButton:r,onShowSimilar:L,actions:_,similarState:J,similarLinkComponent:B,reportSpamPending:M,notSpamPending:w,className:"border-l-0 h-full w-full"}),t.jsx(ru,{isOpen:d,current:u.category.value,hasOverride:b?.flags?.category?.value!=null,onSelect:$,onClear:F,onCancel:()=>h(!1)})]})}const iu=({onClose:e,thread:s,mailboxId:n,accountId:a,hideCloseButton:r,onAfterOptimisticRemove:o,onReplyWithText:i,onOpenThread:c})=>s?t.jsx(ou,{thread:s,onClose:e,mailboxId:n,accountId:a,hideCloseButton:r,onAfterOptimisticRemove:o,onReplyWithText:i,onOpenThread:c}):t.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[t.jsx(Qe,{className:"size-3.5 text-fg-subtle"}),t.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[t.jsx(Qe,{className:"size-8 text-fg-subtle"}),t.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),t.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust, authenticity and similar messages will appear here."})]})]});function Kf({isOpen:e,onClose:s,thread:n,mailboxId:a,accountId:r,onAfterOptimisticRemove:o,onReplyWithText:i,onOpenThread:c}){return t.jsx(Fd,{isOpen:e,onClose:s,ariaLabel:"Message details",side:"right",answers:{toggleIntelligence:s},children:t.jsx(iu,{onClose:s,thread:n,mailboxId:a,accountId:r,hideCloseButton:!0,onAfterOptimisticRemove:o,onReplyWithText:i,onOpenThread:c})})}const lu=e=>{const{trashByAccount:s,hasAppointments:n,isError:a}=cd();return l.useMemo(()=>{const r=co({targets:e,trashByAccount:s,hasAppointments:n,isError:a}),o=i=>i.accountId?s.get(i.accountId):void 0;return{outcome:r,staleFolderLabel:e.map(o).find(i=>i?.source==="Stale")?.staleFolderPath,guessedMailboxId:r==="unconfirmed"?e.find(i=>o(i)?.mailboxId===i.mailboxId)?.mailboxId:void 0}},[e,s,n,a])},cu=100,du=({mailboxId:e,mailboxLabel:s,accountId:n,enabled:a,predicateKey:r,searchQuery:o,reportEnding:i})=>{const[c,u]=l.useState({kind:"idle"}),b=l.useRef(void 0),{run:v,start:j,stop:g}=uo(),{pushError:p}=be(),m=v?.mailboxId===e?v:void 0,f=m!==void 0,d=l.useRef(!1);d.current=f,l.useEffect(()=>{b.current?.abort(),u({kind:"idle"})},[a,r]);const h=l.useRef(o);h.current=o;const y=l.useCallback(N=>async(T,A)=>{const{data:K}=await Ut({path:{mailboxId:e},query:{...N,continuationToken:T,limit:cu},signal:A,throwOnError:!0});return{ids:(K.items??[]).map(L=>L.messageId),continuationToken:K.continuationToken}},[e]),x=l.useCallback(async N=>{const{data:T}=await Ut({path:{mailboxId:e},query:{...h.current,count:!0,results:!1},signal:N,throwOnError:!0});if(T.count===void 0)throw new Error("the search returned no count for the selection");return T.count},[e]),k=l.useCallback(N=>async(T,A)=>{if(N.kind==="move"){const{data:L}=await mo({body:{messageIds:T,destinationMailboxId:N.destinationMailboxId},signal:A,throwOnError:!0});return L}if(N.kind==="markRead"){const{data:L}=await fo({body:{messageIds:T,isRead:!0},signal:A,throwOnError:!0});return L}const{data:K}=await ho({body:{messageIds:T},signal:A,throwOnError:!0});return K},[]),C=l.useCallback(()=>{const N=new AbortController;b.current=N,u({kind:"counting"}),x(N.signal).then(T=>{if(N.signal.aborted){u({kind:"idle"});return}u({kind:"escalated",total:T})},T=>{if(N.signal.aborted){u({kind:"idle"});return}p(po("Couldn't count matching messages","The count didn't finish.",T)),u({kind:"idle"})})},[x,p]),I=l.useCallback(()=>{b.current?.abort(),d.current&&g(e)},[g,e]),M=l.useCallback(()=>{d.current||(b.current?.abort(),u({kind:"idle"}))},[]),w=l.useCallback(async(N,T,A)=>{const K=T?.length??(c.kind==="escalated"?c.total:0),L=T!==void 0?{kind:"targets",targets:T}:{kind:"predicate",fetchPage:y(h.current)},W=await j({action:N,mailboxId:e,mailboxLabel:s,accountId:n,matched:K,source:L,applyBatch:k(N),reportEnding:i,claimEnding:A});return W.kind==="ran"&&u({kind:"idle"}),W},[k,y,c,e,s,n,i,j]);return{phase:c,escalate:C,stop:I,clear:M,isRunning:f,runningAction:m?.action,progress:m?.progress,runAction:w}},uu=120,mu=({keyboardFocusedMessageId:e,openMessageId:s,enabled:n,open:a,delayMs:r=uu})=>{const o=l.useRef(a);o.current=a;const i=l.useRef(void 0);l.useEffect(()=>{const c=e;if(!n){i.current=c;return}if(c===void 0||c===s)return;if(c===i.current){i.current=void 0;return}const u=setTimeout(()=>o.current(c),r);return()=>clearTimeout(u)},[n,e,s,r])},Wa="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folder roles.",fu="These are already in Junk, so there is nowhere to file them.",hu=(e,s)=>e!==void 0&&e!==s?e:void 0,qf=(e,s)=>{if(hu(e,s)===void 0)return e===void 0?Wa:fu};function pu(e,s){if(e.length!==0)return s!==void 0&&e.includes(s)?s:e[0]}const gu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},ut=l.createContext(gu),xu=()=>l.useContext(ut),bu=({isOpen:e,messageIds:s,outcome:n,accountId:a,trashFolderLabel:r,staleFolderLabel:o,guessedMailboxId:i,isDeleting:c=!1,onConfirm:u,onCancel:b})=>{const{Account:v}=Qn(),{requestAppointment:j}=Bn(),g=s.length,p=()=>u([...s]),m=go(g,n,{trashFolderLabel:r,staleFolderLabel:o});if(n==="noTrash"||n==="staleTrash"||n==="unconfirmed"){const f=n==="noTrash"?"none":n==="staleTrash"?"stale":"unconfirmed";return t.jsx(Ns,{isOpen:e,...m,onConfirm:()=>{if(!a)return p();const d=[...s];b(),j({accountId:a,role:"Trash",reason:f,action:{kind:"delete",count:g},staleFolderLabel:o,trashFolderLabel:r,guessedMailboxId:i,onAppointed:async()=>u(d)})},onCancel:b})}return n==="unavailable"?t.jsx(v,{fallback:t.jsx(Ns,{isOpen:e,...m,confirmLabel:"Reload reader",onConfirm:()=>window.location.reload(),onCancel:b}),children:({signOut:f})=>t.jsx(Ns,{isOpen:e,...m,onConfirm:()=>f(),onCancel:b})}):t.jsx(Ns,{isOpen:e,...m,destructive:!0,isBusy:c||n==="unknown",onConfirm:p,onCancel:b})},Ga=8,Va=e=>e==="From"||e==="FromDomain",vu=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),yu=e=>{const s=Ta(e.email);if(s!==null)return{value:s,...e.fromSelection?{source:"selected"}:{}}},ju=(e,s)=>e.value.toLowerCase().includes(s)||(e.label??"").toLowerCase().includes(s),ku=(e,s,n)=>{if(!Va(e))return[];const a=s.trim().toLowerCase(),r=new Set,o=[];for(const i of n){if(i.email.trim()==="")continue;const c=e==="From"?vu(i):yu(i);if(!c)continue;const u=c.value.toLowerCase();if(!(u===""||r.has(u))&&(r.add(u),u!==a&&!(a!==""&&!ju(c,a))&&(o.push(c),o.length===Ga)))break}return o},Cu=250,Nu=2,wu=(e,s,n)=>{const a=s.trim(),r=ca(a,Cu),o=e!==void 0&&Va(e),{data:i}=se({...vt({query:{q:r,limit:Ga}}),enabled:o&&r.length>=Nu});if(!o||e===void 0)return[];const c=[...n.map(u=>({email:u,fromSelection:!0})),...(i?.items??[]).map(u=>({email:u.normalizedEmail,...u.displayName?{displayName:u.displayName}:{}}))];return ku(e,a,c)},Ja=12,Su=e=>{const{envelope:s}=e,n=s.from[0];return{id:s.messageId,sender:n?Aa({normalizedEmail:n.normalizedEmail,displayName:n.displayName}):"Unknown",subject:s.subject??"(No subject)",date:Ge(s.date)}},Iu=(e,s)=>{const n=e!==void 0&&s!==void 0,{data:a,isLoading:r}=se({...xo({path:{mailboxId:e??""},query:{...s,limit:Ja}}),enabled:n,staleTime:3e4});return{messages:(a?.items??[]).map(Ru),isPending:n&&r}},Ru=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:Ge(e.sentDate)}),Mu=e=>jt({queries:e.slice(0,Ja).map(s=>({...zs({path:{messageId:s}}),staleTime:Number.POSITIVE_INFINITY})),combine:s=>({messages:s.map(n=>n.data).filter(n=>n!==void 0).map(Su),isPending:s.some(n=>n.isPending)})}),Tu=(e,s)=>({matchOperator:"Or",literalClauses:St(e,s)}),Au=(e,s,n,a)=>{const r=pe(bo()),{mutate:o,reset:i}=r,[c,u]=l.useState(!1),b=l.useMemo(()=>$s(n),[n]),v=l.useMemo(()=>St(b,a),[b,a]),j=l.useCallback(()=>{!e||!s||(u(!1),o({path:{accountId:e},body:Jt({anchorMessageId:s,matchOperator:"And",literalClauses:[]})}))},[e,s,o]),g=l.useCallback(()=>{u(!1),i()},[i]),p=r.data,m=p?.semanticUnavailable===!0&&!c&&v.length>0;l.useEffect(()=>{!m||!e||(u(!0),o({path:{accountId:e},body:Jt(Tu(b,a))}))},[m,e,b,a,o]);const f=c||(p?.semanticUnavailable??!1),d=r.isPending||m,h=c?{matchOperator:"Or",literalClauses:v}:{...s?{anchorMessageId:s}:{},matchOperator:"And",literalClauses:[]};return{preview:j,reset:g,matchedCount:d?void 0:p?.matchedCount,messageIds:d?void 0:p?.messageIds,semanticUnavailable:f,senderFallback:c,senders:b,matchPredicate:h,isPending:d,isError:r.isError,error:r.error}},Eu=()=>[vo({path:{mailboxId:""}}),yo({path:{mailboxId:""}}),jo()].map(e=>[{_id:e[0]._id}]),Fu=e=>ko(e)?e.pages:Co(e)?[e]:[],Lu=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",Du=(e,s)=>{const n=new Set(s),a=new Map;for(const r of e)for(const o of Fu(r))for(const i of o.items){if(!Lu(i)||!n.has(i.messageId))continue;const c=i.subject?.trim();c&&a.set(i.messageId,c)}return s.map(r=>a.get(r)).filter(r=>r!==void 0)},Ou=e=>{const s=ue(),n=e.join("\0");return l.useMemo(()=>{const a=Eu().flatMap(r=>s.getQueriesData({queryKey:r}).map(([,o])=>o));return Du(a,e)},[s,n])},zu=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),Pu=e=>zu.has(e),_u=(e,{searchHadSemanticReach:s})=>{const n=[],a=[];let r,o;for(const u of e.tokens){if(u.type==="from"){n.push({field:"From",value:u.value});continue}if(u.type==="subject"){n.push({field:"Subject",value:u.value});continue}if(u.type==="in"){r={mailboxId:u.mailboxId,label:u.value};continue}if(u.type==="account"){o=u.accountId;continue}Pu(u.type)&&a.push({type:u.type,label:ta(u)})}const i=e.freeText.trim(),c=i.length>0;return c&&n.push({field:"HasWords",value:i}),{clauses:n,matchOperator:"all",scopedOut:r,droppedFacets:a,targetAccountId:o,keptTerms:c,droppedSemantic:c&&s}},Bu=(e,s,n)=>e.targetAccountId??s??n[0]?.accountId,mt=l.createContext(void 0),Uu=()=>l.useContext(mt),jn={matched:0,applied:0,failed:0,failedIds:[]},$u=({matched:e,outcome:s,failureReason:n,progressDone:a})=>{if(n!==void 0)return{...jn,state:"commitFailed",failureReason:n};if(!s)return{state:"backApplyRunning",matched:Math.max(e,a),applied:a,failed:0,failedIds:[]};if(!s.cancelled&&s.error===void 0)return{state:"backApplyComplete",matched:Math.max(e,s.done),applied:s.done,failed:0,failedIds:[]};if(!s.cancelled&&s.done===0)return{...jn,state:"commitFailed"};const r=s.failedIds.length>0?s.failedIds.length:Math.max(e-s.done,1);return{state:"runStopped",matched:Math.max(e,s.done),applied:s.done,failed:r,failedIds:s.failedIds}},Ku=({failure:e,isStarting:s,isRunning:n,isDone:a,failedCount:r,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":a?r>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":s||n?"backApplyRunning":"saving",qu=e=>{if(e.runState==="statusUnknown")return{kind:"refreshStatus"};if(e.isEscalated)return{kind:"rerunEscalated"};if(e.committedScope==="standing"||e.committedScope==="temporary")return e.createFilterFailed?{kind:"resetAndResend"}:e.backApplyPending?{kind:"startBackApply"}:{kind:"waitOnJob"};if(e.committedScope==="all-like-these"&&e.widenRunsAsJob)return{kind:"resend"};const s=new Set(e.failedIds);return{kind:"rerunBulk",targets:s.size>0?e.sent.filter(n=>s.has(n.id)):e.sent}},Qu=e=>e!==void 0&&e.outcome===void 0&&e.failureReason===void 0,Hu=(e,s)=>{if(e){e.stop();return}s()},Wu=(e,s)=>e==="run"?s.dismiss:s.cancel,Gu={clauses:[],matchOperator:"any"},Vu={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},Ju=[],Yu=(e,s,n)=>({verb:"organize",accountId:Bu(e,s.accountId,n),selection:Ju,selectionRestriction:void 0,escalated:void 0,searchConversion:e}),Rs={state:"saving",matched:0,applied:0,failed:0,failures:[]},kn=(e,s)=>e.map((n,a)=>({...n,id:`${s}-${a}`})),Cn=(e,s,n)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const a=e==="junk"?n:s;return a?{kind:"move",destinationMailboxId:a}:void 0},at=e=>e==="move"||e==="junk"||e==="organize",Nn=e=>e==="junk"?Wa:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function Zu({verb:e,accountId:s,mailboxId:n,mailboxLabel:a,selection:r,selectionRestriction:o,escalated:i,escalatedProgress:c,searchConversion:u,onFinished:b,onRunEnded:v,step:j,goToStep:g,goBack:p,closeWizard:m}){const[f]=l.useState(()=>u),[d]=l.useState(()=>i),h=f!==void 0,[y,x]=l.useState(h?"properties":"selected"),k=d?"escalated":y,[C,I]=l.useState(()=>f?{clauses:kn(f.clauses,"search"),matchOperator:f.matchOperator}:Gu),[M,w]=l.useState(void 0),[N,T]=l.useState(void 0),[A,K]=l.useState(!1),[L,W]=l.useState(void 0),[P,$]=l.useState(void 0),F=l.useRef(!1),z=l.useMemo(()=>r.map(S=>S.id),[r]),_=l.useMemo(()=>r.map(S=>({id:S.id,accountId:S.accountId})),[r]),B=l.useMemo(()=>r.map(S=>S.email).filter(Boolean),[r]),J=z[0],U=Ou(z),{junkMailboxId:Y}=Da(s),{inboxMailboxId:te}=La(s),ae=l.useMemo(()=>te?r.filter(S=>S.mailboxId!==void 0&&S.mailboxId!==te).map(S=>({id:S.id,accountId:S.accountId})):[],[r,te]),Z=Au(d?void 0:s,J,B,U),{preview:ne}=Z;l.useEffect(()=>{ne()},[ne]);const X=k==="similar"||k==="properties",de=l.useMemo(()=>({matchOperator:C.matchOperator==="all"?"And":"Or",literalClauses:C.clauses.map(S=>({field:S.field,value:S.value}))}),[C.clauses,C.matchOperator]),fe=k==="similar"?Z.matchPredicate:de,{count:me,matchedIds:re}=Ji(X?s:void 0,fe),q=Mu(X?re:[]),R=Iu(d?n:void 0,d?.searchQuery),O=d?{status:"ready",count:d.total}:X?me:{status:"ready",count:r.length},{data:V}=se({...us({path:{accountId:s??""}}),enabled:!!s,staleTime:Number.POSITIVE_INFINITY}),he=Oa(s),Oe=Un(),Ie=l.useMemo(()=>Kn({mailboxes:V?.items??[],folderAppointments:he,currentMailboxId:n,translator:Oe}),[V?.items,he,n,Oe]),{createFolderIn:Je}=$n(s),Hs=Ie.find(S=>S.id===C.moveMailboxId)?.label,ze=Pc(r.map(S=>({normalizedEmail:S.email,displayName:S.sender}))),Ye=Qc({match:k==="properties"&&C.clauses[0]?.value.trim()||void 0,sender:ze?Aa(ze):void 0,folder:Hs}),H=l.useMemo(()=>({...C,name:C.name??Ye}),[C,Ye]),ys=wu(M?.draft.field,M?.draft.value??"",B),Re=l.useRef(void 0),je=l.useCallback(S=>{Re.current?.(),Re.current=S},[]);l.useEffect(()=>()=>{Re.current?.(),Re.current=void 0},[]);const oe=Yi(s),ge=Zi(s),Pe=du({mailboxId:n??"",mailboxLabel:a,accountId:s,enabled:!1,predicateKey:"selection-wizard",searchQuery:{},reportEnding:v}),{runAction:_e}=Pe,ie=So({verb:e,mode:k,scope:C.scope,fromSearch:h}),ee=ie[$t(ie,j)],Me=Io(s,o),Te=Ro(k,Me),ke=(S=>{if(S==="folder")return Me.destination;if(S==="rule")return H.scope==="standing"||H.scope==="until"?Te:void 0})(ee)??Mo(ee,H,O),Ae=l.useCallback(()=>kn(St(B,U),"seed"),[B,U]),js=l.useCallback(S=>{x(S),I(D=>({...D,widen:S==="similar"&&J?{anchorCount:Math.max(r.length,1)}:void 0,...S==="properties"&&D.clauses.length===0?{clauses:Ae()}:{}}))},[J,r.length,Ae]),Be=l.useCallback(()=>{K(!0),x("properties"),I(S=>({...S,widen:void 0,clauses:Ae(),matchOperator:"any"})),g("properties")},[Ae,g]),Ee=qa()===!1,Ue=Ee||Z.semanticUnavailable||Z.isError;l.useEffect(()=>{ee==="match"&&(k!=="similar"||!Ue||A||Be())},[ee,k,Ue,A,Be]);const ks=l.useCallback(()=>{w({mode:"add",draft:{field:"From",value:""}})},[]),Ze=l.useCallback(S=>{const D=C.clauses.find(G=>G.id===S);D&&w({mode:"edit",clauseId:S,draft:{field:D.field,value:D.value}})},[C.clauses]),Xe=l.useCallback(S=>{I(D=>({...D,clauses:D.clauses.filter(G=>G.id!==S)}))},[]),es=l.useCallback(S=>{w(D=>D&&{...D,draft:S})},[]),le=l.useCallback(()=>{w(S=>{if(!S)return;const D=Xi(S.draft.field,S.draft.value),G={...S.draft,value:D};I(ts=>({...ts,clauses:S.clauseId?ts.clauses.map(Xs=>Xs.id===S.clauseId?{...Xs,...G}:Xs):[...ts.clauses,{id:crypto.randomUUID(),...G}]}))})},[]),ve=l.useCallback(()=>{if(ke){T(ee);return}T(void 0);const S=ie[$t(ie,ee)+1];S&&g(S)},[ke,ee,ie,g]),ss=l.useCallback(async S=>{const D=Cn(e,H.moveMailboxId,Y);if(!D){$({matched:S.length,sent:S,failureReason:Nn(e)});return}$({matched:S.length,sent:S});const G=await _e(D,S,je);$({matched:S.length,sent:S,outcome:G.kind==="ran"?G.outcome:void 0,failureReason:G.kind==="refused"?G.reason:void 0})},[e,H.moveMailboxId,Y,_e,je]),Gs=l.useCallback(async()=>{if(!d)return;const S=Cn(e,H.moveMailboxId,Y);if(!S){$({matched:d.total,sent:[],failureReason:Nn(e)});return}$({matched:d.total,sent:[]});const D=await d.run(S,je);$({matched:d.total,sent:[],outcome:D.kind==="ran"?D.outcome:void 0,failureReason:D.kind==="refused"?D.reason:void 0})},[d,e,H.moveMailboxId,Y,je]),{start:At,watch:Et}=oe,{createFilterAsync:Ft}=ge,Cs=l.useCallback(()=>{if(d){Gs();return}const S=el({mode:y,ruleScope:H.scope}),D=sl({mode:y,ruleScope:H.scope,anchorMessageId:J,clauses:H.clauses,matchOperator:H.matchOperator,moveMailboxId:H.moveMailboxId,until:H.until});if(W(S),S==="standing"||S==="temporary"){Ft(D,S,(H.name??"").trim()).then(G=>{G&&(Et(G.organizeJobId),ae.length>0&&ss(ae))});return}if(S==="all-like-these"&&at(e)){At(D);return}ss(S==="just-these"?_:re.map(G=>({id:G,accountId:s})))},[d,Gs,y,H,J,e,s,_,re,Ft,Et,ae,At,ss]),tr=l.useCallback(()=>{if(ke){T(ee);return}F.current||(F.current=!0,g("run"),Cs())},[ke,ee,g,Cs]),Lt=l.useCallback(S=>{const D=oe.progress,G=Ku({failure:oe.failure,isStarting:oe.isStarting,isRunning:oe.isRunning,isDone:oe.isDone,failedCount:D.failedCount,ruleSaved:S});return G==="saving"||G==="commitFailed"||G==="backApplyStartFailed"?{...Rs,state:G}:{state:G,matched:D.matchedCount,applied:D.appliedCount,failed:G==="backApplyFailed"||G==="backApplyRestartFailed"?D.failedCount:0,failures:[]}},[oe]),Dt=l.useMemo(()=>{const S=new Map;for(const D of[...r,...q.messages,...R.messages])S.set(D.id,D);return S},[r,q.messages,R.messages]),Ot=d?c:Pe.progress,Vs=l.useCallback(()=>{if(!P)return Rs;const S=$u({matched:P.matched,outcome:P.outcome,failureReason:P.failureReason,progressDone:Ot?.done??0});return{state:S.state,matched:S.matched,applied:S.applied,failed:S.failed,failures:S.failedIds.map(D=>Dt.get(D)).filter(D=>D!==void 0),failureReason:S.failureReason}},[P,Ot,Dt]),Js=ge.data,zt=P!==void 0&&(P.failureReason!==void 0||(P.outcome?.failedIds.length??0)>0),Fe=d?Vs():L==="standing"||L==="temporary"?ge.isError?{...Rs,state:"commitFailed"}:ge.isSuccess?zt?Vs():Lt(!0):Rs:L==="all-like-these"&&at(e)?Lt(!1):Vs(),nr=()=>{if((L==="standing"||L==="temporary")&&zt&&P){const G=new Set(P.outcome?.failedIds??[]);ss(G.size>0?P.sent.filter(ts=>G.has(ts.id)):P.sent);return}const D=qu({runState:Fe.state,isEscalated:d!==void 0,committedScope:L,createFilterFailed:ge.isError,backApplyPending:Js!==void 0,widenRunsAsJob:at(e),failedIds:P?.outcome?.failedIds??[],sent:P?.sent??_});switch(D.kind){case"refreshStatus":oe.refreshStatus();return;case"rerunEscalated":Gs();return;case"resetAndResend":ge.reset(),Cs();return;case"resend":Cs();return;case"startBackApply":Js&&oe.startForFilter(Js.filterId);return;case"waitOnJob":return;case"rerunBulk":ss(D.targets);return}},ar=l.useCallback(()=>{m(ie,ee)},[m,ie,ee]),Ys=l.useCallback(()=>{m(ie,ee),b()},[m,ie,ee,b]),{stop:Pt}=Pe,rr=l.useCallback(()=>{Hu(d,Pt)},[d,Pt]);Jc({shouldBlockFn:({action:S})=>S!=="BACK"?!1:(Ys(),!0),enableBeforeUnload:!1,disabled:ee!=="run"});const Zs={messages:d?R.messages:X?q.messages:r,count:O,label:k==="selected"?"Your selection":"A sample of what matches",emptyReason:k==="similar"&&Ue?"notIndexed":"noMatch",loading:d?R.isPending:X&&(O.status==="loading"||q.isPending)};return t.jsx(To,{verb:e,steps:ie,step:ee,blockedReason:ke,nudged:N===ee,onBack:p,onExit:Wu(ee,{dismiss:Ys,cancel:ar}),onContinue:ve,onCommit:tr,match:{selectedCount:r.length,mode:k,accountId:Me.accountId,onModeChange:js,semanticUnavailable:Ue,semanticOff:Ee,semanticErrorDetail:Z.error instanceof Error?Z.error.message:void 0,semanticFallbackTaken:A,onSemanticFallback:Be,escalatedScope:d?.scope,sample:Zs},properties:{clauses:H.clauses,matchOperator:H.matchOperator,onMatchOperatorChange:S=>I(D=>({...D,matchOperator:S})),clauseEdit:M,onStartAddClause:ks,onStartEditClause:Ze,onRemoveClause:Xe,onChangeDraft:es,onSubmitClause:le,onCancelClause:()=>w(void 0),clauseFields:tl,clauseSuggestions:ys,conversionNotice:f?Wc(f):void 0,semanticFallbackTaken:A,sample:{...Zs,label:"What this matches"}},folder:{folders:Ie,mailboxId:H.moveMailboxId,delimiter:qn(V?.items??[]),onSelect:S=>I(D=>({...D,moveMailboxId:S})),onCreateFolder:s?Je:void 0,restriction:Me.destination},rule:{draft:H,onScopeChange:S=>I(D=>({...D,scope:S})),onUntilChange:S=>I(D=>({...D,until:S})),restriction:Te},name:{name:H.name??"",onNameChange:S=>I(D=>({...D,name:S})),nudged:N===ee},review:{verb:e,mode:k,selectedCount:r.length,clauses:H.clauses,matchOperator:H.matchOperator,folder:Hs,scope:H.scope,until:H.until,ruleName:ie.includes("name")?H.name:void 0,escalatedScope:d?.scope,sample:Zs},run:{state:Fe.state,verb:e,scope:H.scope,matched:Fe.matched,applied:Fe.applied,failedCount:Fe.failed,failures:Fe.failures,failureReason:Fe.failureReason,onRetry:nr,onDismiss:Ys,onCancelRun:Qu(P)?rr:void 0}})}function Qf(e){const s=No()==="search",n=Uu(),{accounts:a}=xs(),{step:r,goToStep:o,goBack:i,closeWizard:c}=wo(s?"properties":"match");if(_s({id:"selection-wizard",open:r!==void 0}),!r)return null;const u=s?n??Vu:void 0;return t.jsx(Zu,{...e,...u?Yu(u,e,a):{},step:r,goToStep:o,goBack:i,closeWizard:c})}const Xu=[],Mt=l.createContext(null),em=e=>{const s=l.useContext(Mt);return s?s.rowInteraction(e):null},sm=()=>{const e=l.useContext(Mt);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},tm="[data-message-id]",nm=e=>Array.from(e.querySelectorAll(tm)).map(s=>s.dataset.messageId).filter(s=>s!==void 0),am=(e,s)=>e.length===s.length&&e.every((n,a)=>n===s[a]),rm=e=>{const[s,n]=l.useState([]);return l.useEffect(()=>{const a=e.current;if(!a)return;const r=()=>{const i=nm(a);n(c=>am(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(a,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),s};function Hf({selectedMessageId:e,rows:s,onOpen:n,onDeleteMessages:a,onSelectionVerb:r,isDeleting:o=!1,commandsRef:i,onTriageContextChange:c,children:u}){const b=bt(),{pushError:v}=be(),j=l.useRef(null),g=rm(j),p=Gc({orderedIds:g,isDesktop:b,initialFocusedId:e}),{focusedMessageId:m,setFocusedMessageId:f,pendingDomFocusRef:d,cursorMovedByPointerRef:h,selection:y,isMultiSelectMode:x,exitSelection:k,handleRowSelect:C}=p,{selectedIds:I,selectedCount:M,isSelected:w,toggle:N,select:T,toggleAll:A}=y,K=g.length>0&&g.every(q=>I.has(q)),L=l.useCallback(()=>{g.length>0&&A(g)},[g,A]),{intersectWith:W}=y;l.useEffect(()=>{W(g)},[W,g]),l.useEffect(()=>{const q=d.current;q!==null&&(d.current=null,j.current?.querySelector(`[data-message-id="${q}"]`)?.focus())});const P=l.useCallback(q=>{h.current=!0,f(q)},[h,f]),$=l.useCallback(q=>{b||T(q)},[b,T]),F=l.useCallback(()=>{m&&n(m)},[m,n]),z=l.useCallback(q=>n(q,{replace:!0}),[n]);mu({keyboardFocusedMessageId:p.keyboardFocusedMessageId,openMessageId:e,enabled:b&&M===0,open:z});const[_,B]=l.useState(null),{outcome:J,staleFolderLabel:U,guessedMailboxId:Y}=lu(_?.targets??Xu),te=l.useCallback(q=>{if(_!==null)return!0;if(M>0)return r(q),!0;if(q!=="delete"||!m)return!1;const R=s.find(O=>O.id===m);return!R?.mailboxId||!R.accountId?(v({title:"Couldn't delete this message",detail:"This list has lost track of which account and folder it is in, so reader can't tell whether deleting it would move it to Trash or erase it. Nothing was deleted.",action:{label:"Reload the list",href:window.location.href}}),!0):(B({ids:[m],targets:[{accountId:R.accountId,mailboxId:R.mailboxId}]}),!0)},[_,M,r,m,s,v]),ae=l.useCallback(q=>{q.length!==0&&(a(q),B(null),k())},[a,k]),Z=l.useCallback(()=>B(null),[]),ne=l.useCallback(()=>M===0?!1:(k(),!0),[M,k]),X=g.length>0;l.useEffect(()=>{if(i){if(!X){i.current=null;return}return i.current={focusNext:p.focusNext,focusPrevious:p.focusPrevious,focusFirst:p.focusFirst,focusLast:p.focusLast,openFocused:F,toggleSelect:p.toggleFocusedSelection,extendSelectDown:p.extendRangeDown,extendSelectUp:p.extendRangeUp,selectAll:p.selectAllLoaded,clearSelection:ne,requestVerb:te,toggleDensity:()=>{}},()=>{i.current=null}}},[i,X,p.focusNext,p.focusPrevious,p.focusFirst,p.focusLast,p.toggleFocusedSelection,p.extendRangeDown,p.extendRangeUp,p.selectAllLoaded,F,ne,te]);const de=l.useMemo(()=>Array.from(I),[I]),fe=_!==null;l.useEffect(()=>{c?.({focusedMessageId:m,selectedIds:de,orderedIds:g,hasList:X})},[c,m,de,g,X]);const me=pu(g,m),re=l.useMemo(()=>({selectedIds:I,selectedCount:M,exitSelection:k,startSelectionVerb:r,orderedIds:g,allSelected:K,toggleAllLoaded:L,rowInteraction:q=>({focused:q===m,isTabStop:q===me,isDesktop:b,onFocusRow:P,selection:{isChecked:w(q),onToggleCheck:N,onRowSelect:C,isMultiSelectMode:x,onLongPress:$}})}),[I,M,k,r,g,K,L,m,me,b,P,w,N,C,x,$]);return t.jsxs(Mt.Provider,{value:re,children:[t.jsx("div",{ref:j,className:"contents",children:u}),t.jsx(bu,{isOpen:fe,messageIds:_?.ids??[],outcome:J,accountId:_?.targets[0]?.accountId,staleFolderLabel:U,guessedMailboxId:Y,isDeleting:o,onConfirm:ae,onCancel:Z})]})}function Wf({title:e,isDeleting:s}){const n=xu(),{selectedCount:a,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:u}=sm();return t.jsx(vc,{title:n.title||e,navSlot:n.navSlot,titleMeta:n.titleMeta,searchSlot:n.searchSlot,searchField:n.searchField,idleSlot:n.makeFilterSlot,count:a,onCancel:r,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:s,selectAll:i.length>0?{checked:c,indeterminate:a>0&&!c,onChange:u}:void 0})}const rt=e=>{e.preventDefault(),e.stopPropagation()},om=(e,s)=>{const n=l.useRef(!1),a=l.useCallback(i=>{if(n.current=!1,i.button!==0)return;const c=ct(i);Xt(c)&&s?.(e,c)&&(rt(i),n.current=!0,i.currentTarget.focus(),c.shiftKey&&window.getSelection()?.removeAllRanges())},[s,e]),r=l.useCallback(i=>{!i.ctrlKey||!s||i.preventDefault()},[s]),o=l.useCallback(i=>{if(n.current)return n.current=!1,rt(i),!0;const c=ct(i);return!Xt(c)||!s?.(e,c)?!1:(rt(i),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[s,e]);return{onMouseDown:a,onContextMenu:r,claimClick:o}},im=({thread:e,active:s=!1,focused:n,isTabStop:a,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:u=!1,link:b,onClick:v,onFocusRow:j})=>{const g=ue(),p=e.id,m=em(p),f=n??m?.focused??!1,d=a??m?.isTabStop??!1,h=c??m?.selection,y=j??m?.onFocusRow,x=o??m?.isDesktop??!0,k=h?.isChecked??!1,C=h?.isMultiSelectMode??!1,I=h?.onToggleCheck,M=h?.onRowSelect,w=h?.onLongPress,N=l.useCallback(_=>{_.preventDefault(),_.stopPropagation(),I?.(p)},[I,p]),T=om(p,M),A=l.useCallback(_=>{if(!T.claimClick(_)){if(!x){if(C){_.preventDefault(),_.stopPropagation(),I?.(p);return}v?.();return}M?.(p,ct(_)),v?.()}},[T,x,C,I,M,v,p]),K=l.useCallback(()=>{w?.(p)},[w,p]),{longPressProps:L}=ic({onLongPress:K,accessibilityDescription:k?"Deselect message":"Select message"}),W=l.useCallback(()=>{g.prefetchQuery(zs({path:{messageId:p}}))},[g,p]),P=l.useCallback(()=>{W(),y?.(p)},[W,y,p]),$=da({"data-list-row":"","data-message-row":!0,"data-message-id":p,...u?{role:"option","aria-selected":k}:{},tabIndex:d?0:-1,onClick:A,onMouseDown:T.onMouseDown,onContextMenu:T.onContextMenu,onMouseEnter:W,onFocus:P},x||!h?{}:L),F=E(r==="compact"?xa({active:s,focused:f}):E("group",Nt({active:s,focused:f})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",k&&"bg-accent-soft",!x&&"min-h-11 select-none [-webkit-touch-callout:none]"),z=r==="compact"?t.jsx(ba,{thread:e}):t.jsx(wt,{thread:e,badge:i,selection:h?{checked:k,alwaysVisible:C,onToggle:N}:void 0});return b===void 0?t.jsx("button",{type:"button",...$,className:F,children:z}):t.jsx(Jn,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...b,messageId:p},search:_=>_,variant:"row",...$,className:F,children:z})},Gf=l.memo(im),lm="Open a message first",cm="This conversation hasn't loaded yet",dm="The mailbox list hasn't loaded yet",um="Couldn't find this mailbox's account — reload to try again",mm={reply:"Reply",replyAll:"Reply all",forward:"Forward",delete:"Move to Trash",move:"Move to mailbox",flag:"Star"},Vf=({hasThread:e,messageId:s,intelligenceOpen:n,canToggleIntelligence:a,onToggleIntelligence:r,onReply:o,onReplyAll:i,onForward:c,onDelete:u,onToggleStar:b,isStarred:v,moveContext:j,moveContextLoading:g})=>{const[p,m]=l.useState(null),f=s??null,d=w=>e?w==="move"?j?null:g?dm:um:{reply:o,replyAll:i,forward:c,delete:u,flag:b}[w]?null:cm:lm,h=p&&p.messageId===f?p:null,y=h?d(h.action):null,x=h?.action==="move"&&h.overThread&&!!j,k=y??(h&&!x?`${mm[h.action]} is ready — press it again`:null),C=w=>m({action:w,messageId:f,overThread:e}),I=w=>()=>C(w),M=(w,N)=>N?()=>{m(null),N()}:I(w);return t.jsx(Kl,{hasThread:e,isStarred:v,onUnavailable:C,unavailableHint:k,replyTitle:`Reply ${ns("reply")}`,replyAllTitle:`Reply all ${ns("replyAll")}`,forwardTitle:`Forward ${ns("forward")}`,deleteTitle:`Move to Trash ${ns("delete")}`,flagTitle:`Star ${ns("toggleStar")}`,onReply:M("reply",o),onReplyAll:M("replyAll",i),onForward:M("forward",c),onDelete:M("delete",u),onToggleStar:M("flag",b),onMove:I("move"),moveSlot:j?t.jsx(Qs,{accountId:j.accountId,currentMailboxId:j.currentMailboxId,onMove:j.onMove,label:"Move to mailbox",defaultOpen:x}):void 0,children:t.jsx(Ul,{open:n,enabled:a,onToggle:r})})};function fm(e){const[s,n]=l.useState(null);s!==null&&s!==e&&n(null);const a=e!==null&&s===e,r=l.useCallback(()=>n(null),[]),o=l.useCallback(()=>n(e),[e]),i=l.useCallback(()=>n(a?null:e),[a,e]);return{isOpen:a,open:o,close:r,toggle:i}}const Jf=e=>{const{intelligenceOpen:s,onToggleIntelligence:n,onRaiseIntelligence:a}=xs(),r=Yn()?.showIntelligencePane??!1,o=e??null,i=fm(o),c=!r&&i.isOpen,{open:u,toggle:b}=i,v=l.useCallback(()=>{if(r){n();return}b()},[r,n,b]),j=l.useCallback(()=>{!r||s||a()},[r,s,a]),g=l.useCallback(()=>{if(!r){u();return}j()},[r,u,j]);return{canToggle:o!==null,isShowing:o!==null&&(r?s:c),toggle:v,open:g,drawerOpen:c,closeDrawer:i.close,railFits:r,openRail:j}},Yf=(e,{toggle:s,open:n})=>{l.useEffect(()=>(e.current={toggle:s,open:n},()=>{e.current=null}),[e,s,n])},hm=()=>{const e=ue();return l.useCallback(s=>{const n=Se({path:{threadId:s.threadId}}),r=e.getQueriesData({queryKey:n}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return r.length>0?r:[s.messageId]},[e])},pm=[],Ya=e=>{const{data:s}=se({...Wn({path:{threadId:e??""}}),enabled:!!e});return s?.items??pm},Zf=(e,s)=>{const n=Ya(e),a=s?n.find(o=>o.messageId===s):void 0,r=n.length>0?n[n.length-1]:void 0;return a??r},Xf=({thread:e,isOpen:s=!1,mailboxId:n,accountId:a,onAfterOptimisticRemove:r})=>{const o=n??e?.mailboxId,i=a??e?.accountId,{accountId:c}=Ks(i?void 0:o),u=i??c,b=hm(),{deleteMessages:v}=qs({mailboxId:o??"",threadId:e?.threadId,accountId:u,onAfterOptimisticRemove:r}),{moveMessages:j}=vs({mailboxId:o??"",threadId:e?.threadId,accountId:u,onAfterOptimisticRemove:r}),g=Ya(s?e?.threadId:void 0),m=g.find(x=>x.messageId===e?.messageId)?.hasStars??e?.hasStars,{toggleStar:f}=Ea({threadId:e?.threadId??"",mailboxId:o??"",messages:g}),d=l.useCallback(()=>{e&&v(b(e))},[e,b,v]),h=l.useCallback(x=>{e&&j(b(e),x)},[e,b,j]),y=l.useCallback(()=>{e&&f(e.messageId,m??!1)},[e,m,f]);return{mailboxId:o,accountId:u,isStarred:m,deleteThread:d,moveThread:h,toggleStar:y}},wn=(e,s,n)=>{if(!s)return null;const a=e.indexOf(s);if(a===-1)return null;const r=n==="next"?a+1:a-1;return r<0||r>=e.length?null:e[r]},eh=()=>{const[e,s]=l.useState(void 0),[n,a]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,u]=l.useState(!1),b=l.useCallback(v=>{s(v.focusedMessageId),a(v.selectedIds),v.orderedIds&&o(v.orderedIds),u(v.hasList)},[]);return{listCommandsRef:i,onTriageContextChange:b,focusedMessageId:e,selectedIds:n,orderedIds:r,hasList:c}},sh=({context:e,orderedIds:s,selectedMessageId:n,enabled:a=!0,onClose:r,handlers:o,hasOpenThread:i=!1})=>{const{listCommandsRef:c,hasList:u}=e,b=l.useCallback(()=>{c.current?.clearSelection()||n&&r()},[c,n,r]),{reply:v,replyAll:j,forward:g,...p}=o;return Qo({enabled:a,handlers:{...u?{focusNext:()=>c.current?.focusNext(),focusPrevious:()=>c.current?.focusPrevious(),focusFirst:()=>c.current?.focusFirst(),focusLast:()=>c.current?.focusLast(),openFocused:()=>c.current?.openFocused(),toggleSelect:()=>c.current?.toggleSelect(),extendSelectDown:()=>c.current?.extendSelectDown(),extendSelectUp:()=>c.current?.extendSelectUp(),selectAll:()=>c.current?.selectAll(),toggleDensity:()=>c.current?.toggleDensity()}:{},back:b,...p,...i?{}:{reply:v,replyAll:j,forward:g}}}),{goBack:b,nextMessageId:wn(s,n,"next")??void 0,previousMessageId:wn(s,n,"previous")??void 0}},gm={unread:"unread",flagged:"starred",attachment:"attachments"},xm=new Set(Object.values(Ao)),Za=e=>xm.has(e),th=e=>Za(e.category)||e.attributes.size>0,nh=e=>{const s={};Za(e.category)&&(s.category=[e.category]);for(const n of e.attributes){const a=gm[n];a&&(s[a]=!0)}return s},ah=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",bm=["category","unread","starred","attachments","accountId","muted"],Sn=e=>JSON.stringify(bm.map(s=>e?.[s]??null)),vm=e=>{if(!Array.isArray(e))return;const[s]=e;if(typeof s!="object"||s===null)return;const n=s.query;if(!(typeof n!="object"||n===null))return n},rh=(e,s)=>{const n=vm(e);return n?Sn(n)===Sn(s):!1},oh=e=>Vn(e)?Os[e]:void 0,ym={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function jm(e){return ym[e]??e}function ih(e,s){const{folder:n}=yt(s,[e.mailboxId]);return{id:e.messageId,sender:e.fromName??e.fromEmail??"Unknown",...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject??"(No subject)",snippet:e.snippet??"",date:Ge(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...n?{folder:n}:{}}}function lh(e,s){const{folder:n}=yt(s,e.mailboxId?[e.mailboxId]:[]);return{id:e.id,sender:e.fromName,...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject,snippet:e.snippet,date:e.timeLabel,unread:!e.isRead,flagged:e.starred===!0,...e.threadId?{threadId:e.threadId}:{},...e.mailboxId?{mailboxId:e.mailboxId}:{},...n?{folder:n}:{}}}function km(e,s){const{mailboxId:n,folder:a}=yt(s,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?Ge(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:jm(e.matchedChunkType),score:e.score,...n?{mailboxId:n}:{},...a?{folder:a}:{}}}function ch(e,s,n){const a=new Set(s),r=[];for(const o of[...e].sort((i,c)=>c.score-i.score))a.has(o.threadId)||(a.add(o.threadId),r.push(km(o,n)));return r}function Cm(e){const s=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Fa(e.category),suspicious:s,...Ed(e)}}const Nm=Eo;function dh(e){const s=new Map(e.map(a=>[a.category,a])),n=[];for(const a of Nm){const r=s.get(a);!r||!(r.loading||r.failed||r.rows.length>0||r.total.kind==="exact"&&r.total.value>0)||n.push({id:a,label:Os[a],threads:r.rows,total:r.total,atCap:r.atCap,loading:r.loading,error:r.failed})}return n}function wm(e,s){return s.every(n=>{switch(n.type){case"from":{const a=n.value.toLowerCase();return e.fromEmail.toLowerCase().includes(a)||e.fromName.toLowerCase().includes(a)}case"subject":return e.subject.toLowerCase().includes(n.value.toLowerCase());case"category":return(e.category??"uncategorized")===n.category;case"hasAttachment":return e.hasAttachment===!0;case"isUnread":return!e.isRead;case"isRead":return e.isRead===!0;case"isStarred":return e.starred===!0;case"after":return e.sentDate!=null&&e.sentDate>=n.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<n.epochSeconds*1e3;case"in":return e.mailboxId===n.mailboxId;case"account":return e.accountId===n.accountId;default:return!1}})}const Sm=["from","subject","category","unread","starred","attachments"],Ms=e=>e[0],Im=e=>{const s=Ms(e.filter(c=>c.type==="from").map(c=>c.value)),n=Ms(e.filter(c=>c.type==="subject").map(c=>c.value)),a=Ms(e.filter(c=>c.type==="category").map(c=>c.category)),r=Ms(e.filter(c=>c.type==="isUnread"||c.type==="isRead").map(c=>c.type==="isUnread")),o=e.some(c=>c.type==="isStarred")?!0:void 0,i=e.some(c=>c.type==="hasAttachment")?!0:void 0;return{...s!==void 0?{from:s}:{},...n!==void 0?{subject:n}:{},...a!==void 0?{category:[a]}:{},...r!==void 0?{unread:r}:{},...o!==void 0?{starred:o}:{},...i!==void 0?{attachments:i}:{}}},Rm=(e,s)=>{switch(s.type){case"from":return e.from?.toLowerCase()===s.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===s.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===s.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}},In=(e,s)=>Object.fromEntries(Object.entries(e).filter(([n])=>s.includes(n)));function uh(e,s={},n=Sm){const a=In(Im(e),n),r={...a,...In(s,n)};return{params:a,residual:e.filter(o=>!Rm(r,o))}}function mh(e,s,n){if(s.length===0)return e;const a=[...s];return e.filter(r=>{const o=Cm(r);return wm({...o,accountId:o.accountId??n},a)})}const Xa=8;function Tt(e,s){const n=Math.max(0,Math.min(s,e.length)),a=ni(e).find(o=>n>=o.start&&n<=o.end);if(!a)return{start:n,end:n,raw:""};const r=ai(a.raw);return r?{start:a.start,end:a.end,raw:a.raw,name:r.name,value:r.value}:{start:a.start,end:a.end,raw:a.raw}}function Mm(e,s){const n=Tt(e,s);if(n.name===void 0)return{kind:"token",query:n.raw};const a=na(n.name);if(a)return{kind:"value",token:a.name,source:a.values,query:n.value??""}}const Tm={mailbox:"mailboxes",account:"accounts",contact:"contacts"},Am=(e,s)=>{if(e.values==="fixed")return e.options??[];const n=Tm[e.values];return n?s[n]??[]:[]},Em=(e,s)=>{if(s==="")return 1;const n=e.toLowerCase();return n.startsWith(s)?0:n.includes(s)?1:-1},ft=(e,...s)=>{let n=-1;for(const a of s){if(a===void 0)continue;const r=Em(a,e);r<0||(n<0||r<n)&&(n=r)}return n},er=e=>{const s=new Set;return e.filter(n=>n.rank>=0).sort((n,a)=>n.rank-a.rank).filter(n=>{const a=n.suggestion.value.toLowerCase();return s.has(a)?!1:(s.add(a),!0)}).slice(0,Xa).map(n=>n.suggestion)},Rn=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function Fm(e){const s=e.trim().toLowerCase();if(s==="")return Kt.map(Rn);const n=[];for(const a of Kt)if(n.push({rank:ft(s,`${a.name}:`,a.label),suggestion:Rn(a)}),a.values==="fixed")for(const r of a.options??[]){const o=aa(a.name,r.value);n.push({rank:ft(s,o,r.label),suggestion:{value:o,label:r.label??o,hint:o}})}return er(n)}function Lm(e,s,n){const a=s.trim().toLowerCase(),r=Am(e,n).map(o=>({rank:ft(a,o.value,o.label),suggestion:{value:aa(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return er(r)}function Dm(e,s,n={}){const a=Tt(e,s);if(a.name===void 0)return Fm(a.raw);const r=na(a.name);return r?Lm(r,a.value??"",n):[]}function Om(e,s,n){const a=Tt(e,s),r=!n.value.endsWith(":"),o=/\s/.test(e.slice(a.end,a.end+1)),i=r&&!o?`${n.value} `:n.value;return{query:e.slice(0,a.start)+i+e.slice(a.end),cursor:a.start+i.length+(r&&o?1:0)}}const zm=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),Pm=250,_m=2;function Bm({query:e,cursor:s,enabled:n}){const{accounts:a}=xs(),{mailboxesByName:r}=ra(),o=r!==void 0,i=n?Mm(e,s):void 0,c=i?.source==="contact"?i.query.trim():"",u=ca(c,Pm),{data:b}=se({...vt({query:{q:u,limit:Xa}}),enabled:u.length>=_m}),v=jt({queries:a.map(m=>({...us({path:{accountId:m.accountId}}),staleTime:1/0}))}),j=l.useMemo(()=>o?Ho(v.map(m=>m.data?.items??[]),a):[],[o,v,a]),g=l.useMemo(()=>Wo(a),[a]),p=l.useMemo(()=>(b?.items??[]).map(zm),[b]);return l.useMemo(()=>{if(!n)return[];const m=Dm(e,s,{mailboxes:j,accounts:g,contacts:p});return o?m:m.filter(f=>f.value!=="in:")},[n,e,s,j,g,p,o])}const sr="remit.recentSearches",Um=5;function ht(){try{const e=localStorage.getItem(sr);if(!e)return[];const s=JSON.parse(e);return Array.isArray(s)?s.filter(n=>typeof n=="string"):[]}catch{return[]}}function Mn(e){const s=e.trim();if(!s)return ht();const n=[s,...ht().filter(a=>a!==s)].slice(0,Um);try{localStorage.setItem(sr,JSON.stringify(n))}catch{return n}return n}const $m=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery),pt=l.createContext(null);function Km(){const e=l.useContext(pt),{searchInput:s,onSearchChange:n,onSearchClear:a}=xs();if(!e)throw new Error("ListHeaderSearchField rendered outside MailListHeader's HeaderSearchContext provider");return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Xn,{value:s,onChange:n,onClear:a,globalFocusKey:!1,showClearButton:!1,suggest:e.suggest})}),t.jsx(Q,{variant:"ghost",size:"touch",icon:t.jsx(qe,{className:"size-5"}),onClick:e.onClose,"aria-label":"Close search",className:"shrink-0"}),t.jsx(Zn,{})]})}function fh({title:e,unreadCount:s,children:n,selectionBar:a,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:u,relatedResults:b,relatedLoading:v,onSelectSearchResult:j,searchResultsLabel:g="Top matches",relatedResultsLabel:p="Related",searchResultsInBody:m=!1,spamOffer:f,refreshControl:d}){const{accounts:h,resultFolderIndex:y,searchQuery:x,searchInput:k,onSearchChange:C,onSearchClear:I,searchViewKey:M}=xs(),w=ra(),N=Go(),T=Yn(),A=al(),[K,L]=l.useState(!1),[W,P]=l.useState(ht),$=Fo(),F=l.useRef(M);l.useEffect(()=>{F.current!==M&&(F.current=M,L(!1))},[M]);const[z,_]=l.useState(0),[B,J]=l.useState(!1),[U,Y]=l.useState(void 0),te=Bm({query:k,cursor:z,enabled:B&&k.trim().length>0}),ae=l.useCallback(le=>{const ve=Om(k,z,le);C(ve.query),Y({cursor:ve.cursor})},[k,z,C]),Z=Lo({count:te.length,onAccept:le=>{const ve=te[le];ve&&ae(ve)}}),{comboboxProps:ne,handleKeyDown:X}=Z,de=l.useMemo(()=>({comboboxProps:ne,onKeyDown:X,onCaretChange:_,onFocusChange:J,...U?{caret:U}:{}}),[ne,X,U]),fe=l.useCallback(()=>{I(),L(!1)},[I]),me=l.useMemo(()=>({suggest:de,onClose:fe}),[de,fe]),re=Z.open?t.jsx(Po,{id:Z.listId,suggestions:te,activeIndex:Z.activeIndex,optionId:Z.optionId,onPick:ae,onHighlight:Z.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,q=k.trim().length>0,{mailboxesByName:R,accountsByName:O}=w,V=l.useMemo(()=>ri(k,{mailboxesByName:R,accountsByName:O}),[k,R,O]),he=l.useMemo(()=>V.tokens.map(le=>({label:ta(le),onRemove:()=>C(oi(k,le))})),[V,k,C]),Oe=l.useMemo(()=>c??[],[c]),Ie=l.useMemo(()=>b??[],[b]),Je=l.useMemo(()=>q?[{id:"top",label:g,results:Oe},{id:"related",label:p,results:Ie}]:[],[q,g,p,Oe,Ie]),ze=!(Oe.length+Ie.length>0)&&(u===!0||v===!0),{scope:Ye}=Vo(h),H=Do(),ys=ol(H),Re=ys?y.get(ys)?.role:void 0,je=l.useMemo(()=>il(H,Ye,Re),[H,Ye,Re]),oe=je.kind==="global"?f:void 0,ge=l.useMemo(()=>oe?{kind:"global",spamCount:oe.count,onScopeToSpam:()=>N(oe.mailboxId,x)}:je,[oe,je,N,x]),Pe=Ie.length>0,_e=l.useMemo(()=>_u(V,{searchHadSemanticReach:Pe}),[V,Pe]),ie=q?_e:void 0,ee=l.useCallback(()=>{L(!1),$("properties","search")},[$]),Me=Hc(_e)?void 0:Oo(_e.droppedFacets.map(le=>le.label)),Te=l.useMemo(()=>q?{onClick:ee,blockedReason:Me}:void 0,[q,Me,ee]),Ws=l.useMemo(()=>Te?t.jsx(Sa,{...Te}):null,[Te]),ke=$m({tier:A,hasLiveInput:q,hasCommittedQuery:x.trim().length>0,bodyRendersCommittedResults:m}),Ae=l.useCallback(le=>{P(Mn(k)),j?.(le)},[k,j]),js=l.useMemo(()=>t.jsx(Ia,{value:k,sections:Je,loading:ze,onSelectResult:Ae,tokens:he,scope:ge}),[k,Je,ze,Ae,he,ge]),Be=a===void 0,Ee=l.useMemo(()=>ke?t.jsx("div",{className:"h-full overflow-y-auto",children:js}):null,[ke,js]),Ue=Ee&&!Be?Ee:n,ks=Ee&&Be?Ee:null,Ze=rl(A),Xe=Ze&&(K||q),es=l.useMemo(()=>({title:e,searchResults:ks,makeFilterSlot:Ws,navSlot:T&&!T.showNavPane&&t.jsx(Q,{variant:"ghost",size:"touch",icon:t.jsx(ll,{className:"size-5"}),onClick:()=>T.openNav(),"aria-label":"Menu",className:"-ml-2 shrink-0"}),titleMeta:t.jsxs(t.Fragment,{children:[s===null?null:t.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[s.toLocaleString()," unread"]}),t.jsx(Zn,{}),d]}),searchSlot:Ze&&!Xe&&t.jsx(Q,{variant:"ghost",size:"touch",icon:t.jsx(zo,{className:"size-5"}),onClick:()=>L(!0),"aria-label":"Search",className:"shrink-0"}),searchField:Xe&&t.jsx(Km,{})}),[e,s,T,Ze,Xe,ks,Ws,d]);if(A==="phone"&&K){const le=ve=>{P(Mn(k)),L(!1),j?.(ve)};return t.jsx(pt.Provider,{value:me,children:t.jsx(mt.Provider,{value:ie,children:t.jsxs(ut.Provider,{value:es,children:[t.jsx(bc,{value:k,onChange:C,onClear:I,onCancel:()=>{L(!1),I()},filter:i,recentSearches:W,onPickRecent:C,makeFilter:Te,sections:Je,loading:ze,onSelectResult:le,tokens:he,scope:ge,suggest:de,suggestList:re}),r]})})})}return t.jsx(pt.Provider,{value:me,children:t.jsx(mt.Provider,{value:ie,children:t.jsx(ut.Provider,{value:es,children:t.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[a?.(es),re,t.jsx("div",{className:"min-h-0 flex-1",children:Ue}),o,r]})})})})}export{Pf as $,th as A,uh as B,Zl as C,bu as D,Ks as E,mh as F,zf as G,ah as H,Zf as I,qs as J,vs as K,eh as L,Gf as M,Xf as N,Df as O,Lf as P,hm as Q,Ea as R,vc as S,Vd as T,Yd as U,Xd as V,Zd as W,sh as X,Ef as Y,fm as Z,Yf as _,xu as a,Kf as a0,iu as a1,Jf as a2,Vf as a3,Tf as a4,Of as a5,ih as a6,ch as a7,rh as a8,da as a9,Af as aA,Wf as aB,kt as aa,oc as ab,ac,tc as ad,rc as ae,sc as af,ct as ag,If as ah,Rf as ai,wf as aj,Sf as ak,oh as al,fh as am,It as an,Nm as ao,Cm as ap,wm as aq,lh as ar,gc as as,dh as at,Mf as au,$m as av,mc as aw,Hf as ax,Zt as ay,sm as az,Ff as b,Nt as c,Da as d,lu as e,Jl as f,du as g,mu as h,Jc as i,qf as j,pu as k,Qf as l,Ql as m,Vl as n,hu as o,La as p,Oa as q,Ed as r,Bf as s,Fa as t,om as u,Uf as v,$f as w,cd as x,_f as y,nh as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as L,r as N,j as e,W,Y as H,Z as $,_ as A,$ as I,t as C,a0 as Q,a1 as V,a2 as Y,a3 as G,a4 as Z,a5 as J,a6 as X,a7 as ee,I as se,a8 as te,a9 as ae,aa as S,ab as ne,h as re,C as ie,ac as le,K as oe,c as ce,ad as ue,ae as de,af as R,ag as xe,ah as v,ai as fe,D as me,v as he}from"./index-1mxX3_QN.js";import{u as ge}from"./roving-focus-DlpDivMm.js";import{B as pe}from"./bell-off-CNej-tyT.js";import{u as be}from"./useQueries-CbWwzRRY.js";import{f as je}from"./folder-failure-CqkVSsrb.js";import{i as ye}from"./outbox-status-BlKn6P0x.js";import{B as ve}from"./bug-BxKBPCAb.js";const Ne=L("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);const ke=L("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const Ce=L("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Oe={Mail:"mail sync off"},Se="button:not([disabled]), a[href]",w="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function we({active:s,dimmed:a,indent:n}){return C("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",w,n&&"pl-7",s?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",a&&"opacity-55")}function ze({icon:s,label:a,count:n,active:r,failure:o}){return e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:C("shrink-0",r?"text-accent-2":"text-fg-subtle"),children:s}),e.jsx("span",{className:"flex-1 truncate",children:a}),o&&e.jsx(Q,{className:"size-3.5 shrink-0 text-danger","aria-hidden":"true"}),n!=null&&n>0&&e.jsx("span",{className:C("text-2xs tabular-nums",r?"text-accent-2":"text-fg-subtle"),children:n})]})}function O({icon:s,label:a,count:n,active:r,dimmed:o,indent:c,navId:f,linkComponent:g,ariaLabel:m,title:p,failure:d,onClick:k}){const j=we({active:r,dimmed:o,indent:c}),x=e.jsx(ze,{icon:s,label:a,count:n,active:r,failure:d}),y=m??a,i=d?`${y} — ${d}`:y,l=d?`${p??a} — ${d}`:p;return f&&g?g({navId:f,className:j,ariaLabel:i,title:l,onClick:k,children:x}):e.jsx("button",{type:"button",onClick:k,className:j,"aria-label":d?i:m,title:l,children:x})}const M={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function Re(s){switch(s){case"inbox":return e.jsx(se,{className:"size-4"});case"flagged":return e.jsx($,{className:"size-4"});case"drafts":return e.jsx(ee,{className:"size-4"});case"sent":return e.jsx(V,{className:"size-4"});case"archive":return e.jsx(X,{className:"size-4"});case"all":return e.jsx(J,{className:"size-4"});case"junk":return e.jsx(Z,{className:"size-4"});case"trash":return e.jsx(G,{className:"size-4"})}}const E=s=>s.role!=null,z=8,P="remit.nav.folders.open.",_="remit.nav.account.open.";function D(s,a,n){if(typeof localStorage>"u")return n;const r=localStorage.getItem(s+a);return r===null?n:r!=="0"}function B(s,a,n){typeof localStorage>"u"||localStorage.setItem(s+a,n?"1":"0")}function Le({account:s,selectedNavId:a,onSelectNav:n,linkComponent:r}){const[o,c]=N.useState(()=>D(_,s.id,!0)),[f,g]=N.useState(()=>D(P,s.id,!0)),[m,p]=N.useState(!1),d=()=>{c(t=>{const u=!t;return B(_,s.id,u),u})},k=()=>{g(t=>{const u=!t;return B(P,s.id,u),u})},j=s.mailboxes.filter(E).sort((t,u)=>M[t.role]-M[u.role]),x=s.mailboxes.filter(t=>!E(t)),y=m||x.length<=z?x:x.slice(0,z),i=x.length-y.length,l=s.status??"ready",h=s.syncedServices!==void 0&&!s.syncedServices.includes("Mail"),b=l==="ready"&&j.length===0&&x.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:d,"aria-expanded":o,className:C("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",w,s.muted&&"opacity-55"),children:[o?e.jsx(A,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(I,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:s.label}),s.muted&&e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:Oe.Mail})]})]}),o&&e.jsxs(e.Fragment,{children:[l==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),l==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(Q,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),s.onRetry&&e.jsx("button",{type:"button",onClick:s.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),b&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),l==="ready"&&e.jsxs(e.Fragment,{children:[j.map(t=>e.jsx(O,{navId:t.id,linkComponent:r,icon:Re(t.role),label:t.name,ariaLabel:t.name,title:t.fullPath??t.name,failure:t.failure,count:t.unseen,active:a===t.id,dimmed:s.muted,onClick:()=>n?.(t.id)},t.id)),s.outboxPending!==void 0&&e.jsx(O,{navId:"outbox",linkComponent:r,icon:e.jsx(V,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:s.outboxPending>0?s.outboxPending:void 0,active:a==="outbox",dimmed:s.muted,onClick:()=>n?.("outbox")}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:k,"aria-expanded":f,className:C("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",w),children:[f?e.jsx(A,{className:"size-3 shrink-0"}):e.jsx(I,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:x.length})]}),f&&e.jsxs(e.Fragment,{children:[y.map(t=>e.jsx(O,{navId:t.id,linkComponent:r,icon:e.jsx(Y,{className:"size-4"}),label:t.name,ariaLabel:t.name,title:t.fullPath??t.name,failure:t.failure,count:t.unseen,active:a===t.id,dimmed:s.muted,onClick:()=>n?.(t.id)},t.id)),(i>0||m)&&x.length>z&&e.jsx("button",{type:"button",onClick:()=>p(t=>!t),className:C("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",w),children:m?"Show less":`Show all (${x.length})`})]})]})]})]})]})}function Fe({accounts:s,selectedNavId:a,briefUnseen:n,onSelectNav:r,variant:o="desktop",linkComponent:c,calendarNav:f="hidden"}){const g=N.useRef(null);ge({containerRef:g,itemSelector:Se});const m=o==="drawer",p=e.jsxs("nav",{ref:m?g:void 0,className:m?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(O,{navId:"brief",linkComponent:c,icon:e.jsx(W,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:n,active:a==="brief",onClick:()=>r?.("brief")}),f==="shown"&&e.jsx(O,{navId:"calendar",linkComponent:c,icon:e.jsx(H,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:a==="calendar",onClick:()=>r?.("calendar")}),e.jsx(O,{navId:"flagged",linkComponent:c,icon:e.jsx($,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:a==="flagged",onClick:()=>r?.("flagged")}),s.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):s.map(d=>e.jsx(Le,{account:d,selectedNavId:a,onSelectNav:r,linkComponent:c},d.id))]});return m?p:e.jsx("aside",{ref:g,className:"flex h-full w-full flex-col bg-surface-sunken",children:p})}function Ae(){const{pathname:s}=te(),a=ae({from:"/mail/$mailboxId",shouldThrow:!1});return S(s,"/settings")?"settings":S(s,"/calendar")?"calendar":S(s,"/mail/outbox")?"outbox":S(s,"/mail/flagged")?"flagged":S(s,"/mail/brief")?"brief":a?.mailboxId??""}const Ie=({children:s})=>{const{Account:a}=ne();return e.jsx(a,{children:s})},T=s=>/^\d/.test(s),Me=(s,a)=>{const n=T(s),r=T(a);return n&&!r?-1:!n&&r?1:s.localeCompare(a,void 0,{sensitivity:"base",numeric:!0})};function Ee(s,a,n){const r=[],o=[];for(const c of s)a.has(c.mailboxId)?r.push(c):o.push(c);return o.sort((c,f)=>Me(R(c,void 0,n),R(f,void 0,n))),{system:r,labels:o}}function Pe(s,a,n){const r=xe(a)&&s.unseenCount>0;return{id:s.mailboxId,name:R(s,a,n),unseen:r?s.unseenCount:void 0,role:a,fullPath:s.fullPath,failure:je(s)}}function q({accounts:s,onMailboxSelect:a,variant:n="desktop"}){const r=re(),o=Ae(),{onSearchChange:c}=ie(),{t:f}=le("mail",{useSuspense:!1}),g=N.useCallback((i,l)=>f(i,{defaultValue:l}),[f]),m=be({queries:s.map(i=>({...oe({path:{accountId:i.accountId}}),staleTime:1/0}))}),{data:p}=ce(ue()),d=N.useMemo(()=>(p?.items??[]).filter(i=>ye(i.status)).length,[p?.items]),k=N.useMemo(()=>s.map((i,l)=>{const h=m[l],b=h?.data?.items??[],t=de(i.folderAppointments),{system:u,labels:K}=Ee(b,t,g),U=h?.isError?"error":h?.isLoading?"loading":"ready";return{id:i.accountId,label:i.email,email:i.email,muted:!!i.muted,outboxPending:d,status:U,onRetry:()=>h?.refetch(),mailboxes:[...u,...K].map(F=>Pe(F,t.get(F.mailboxId),g))}}),[s,m,d,g]),j=i=>{r.invalidateQueries({queryKey:fe({path:{mailboxId:i},query:{order:"desc"}})})},x=({navId:i,className:l,ariaLabel:h,title:b,children:t,onClick:u})=>i==="brief"?e.jsx(v,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="calendar"?e.jsx(v,{to:"/calendar",onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="outbox"?e.jsx(v,{to:"/mail/outbox",search:{q:void 0},onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="flagged"?e.jsx(v,{to:"/mail/flagged",search:{q:void 0},onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="settings"?e.jsx(v,{to:"/settings/accounts",onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):e.jsx(v,{to:"/mail/$mailboxId",params:{mailboxId:i},search:{q:void 0},onClick:()=>{j(i),u?.()},className:l,"aria-label":h,title:b,children:t}),y=()=>{c(""),a?.()};return e.jsx(Fe,{accounts:k,selectedNavId:o,onSelectNav:y,linkComponent:x,calendarNav:"shown",variant:n})}function _e(){return e.jsxs("button",{type:"button",onClick:me,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(ve,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function Ke({accounts:s,onMailboxSelect:a}){return he()?.showNavPane??!0?e.jsx(q,{accounts:s}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(q,{accounts:s,onMailboxSelect:a,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(v,{to:"/settings/accounts",onClick:a,children:[e.jsx(Ce,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(_e,{}),e.jsx(Ie,{children:({signOut:o})=>e.jsxs("button",{type:"button",onClick:()=>{a?.(),o()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(ke,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}export{Ie as A,ke as L,Ke as M,Ce as S};
|
|
1
|
+
import{e as L,r as N,j as e,W,Y as H,Z as $,_ as A,$ as I,t as C,a0 as Q,a1 as V,a2 as Y,a3 as G,a4 as Z,a5 as J,a6 as X,a7 as ee,I as se,a8 as te,a9 as ae,aa as S,ab as ne,h as re,C as ie,ac as le,K as oe,c as ce,ad as ue,ae as de,af as R,ag as xe,ah as v,ai as fe,D as me,v as he}from"./index-owcFTp8Y.js";import{u as ge}from"./roving-focus-C3VQzsoq.js";import{B as pe}from"./bell-off-CS6Duk18.js";import{u as be}from"./useQueries-jIdAkC8e.js";import{f as je}from"./folder-failure-CqkVSsrb.js";import{i as ye}from"./outbox-status-BlKn6P0x.js";import{B as ve}from"./bug-BZRMWJ8e.js";const Ne=L("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);const ke=L("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const Ce=L("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Oe={Mail:"mail sync off"},Se="button:not([disabled]), a[href]",w="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function we({active:s,dimmed:a,indent:n}){return C("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",w,n&&"pl-7",s?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",a&&"opacity-55")}function ze({icon:s,label:a,count:n,active:r,failure:o}){return e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:C("shrink-0",r?"text-accent-2":"text-fg-subtle"),children:s}),e.jsx("span",{className:"flex-1 truncate",children:a}),o&&e.jsx(Q,{className:"size-3.5 shrink-0 text-danger","aria-hidden":"true"}),n!=null&&n>0&&e.jsx("span",{className:C("text-2xs tabular-nums",r?"text-accent-2":"text-fg-subtle"),children:n})]})}function O({icon:s,label:a,count:n,active:r,dimmed:o,indent:c,navId:f,linkComponent:g,ariaLabel:m,title:p,failure:d,onClick:k}){const j=we({active:r,dimmed:o,indent:c}),x=e.jsx(ze,{icon:s,label:a,count:n,active:r,failure:d}),y=m??a,i=d?`${y} — ${d}`:y,l=d?`${p??a} — ${d}`:p;return f&&g?g({navId:f,className:j,ariaLabel:i,title:l,onClick:k,children:x}):e.jsx("button",{type:"button",onClick:k,className:j,"aria-label":d?i:m,title:l,children:x})}const M={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function Re(s){switch(s){case"inbox":return e.jsx(se,{className:"size-4"});case"flagged":return e.jsx($,{className:"size-4"});case"drafts":return e.jsx(ee,{className:"size-4"});case"sent":return e.jsx(V,{className:"size-4"});case"archive":return e.jsx(X,{className:"size-4"});case"all":return e.jsx(J,{className:"size-4"});case"junk":return e.jsx(Z,{className:"size-4"});case"trash":return e.jsx(G,{className:"size-4"})}}const E=s=>s.role!=null,z=8,P="remit.nav.folders.open.",_="remit.nav.account.open.";function D(s,a,n){if(typeof localStorage>"u")return n;const r=localStorage.getItem(s+a);return r===null?n:r!=="0"}function B(s,a,n){typeof localStorage>"u"||localStorage.setItem(s+a,n?"1":"0")}function Le({account:s,selectedNavId:a,onSelectNav:n,linkComponent:r}){const[o,c]=N.useState(()=>D(_,s.id,!0)),[f,g]=N.useState(()=>D(P,s.id,!0)),[m,p]=N.useState(!1),d=()=>{c(t=>{const u=!t;return B(_,s.id,u),u})},k=()=>{g(t=>{const u=!t;return B(P,s.id,u),u})},j=s.mailboxes.filter(E).sort((t,u)=>M[t.role]-M[u.role]),x=s.mailboxes.filter(t=>!E(t)),y=m||x.length<=z?x:x.slice(0,z),i=x.length-y.length,l=s.status??"ready",h=s.syncedServices!==void 0&&!s.syncedServices.includes("Mail"),b=l==="ready"&&j.length===0&&x.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:d,"aria-expanded":o,className:C("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",w,s.muted&&"opacity-55"),children:[o?e.jsx(A,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(I,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:s.label}),s.muted&&e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:Oe.Mail})]})]}),o&&e.jsxs(e.Fragment,{children:[l==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),l==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(Q,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),s.onRetry&&e.jsx("button",{type:"button",onClick:s.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),b&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),l==="ready"&&e.jsxs(e.Fragment,{children:[j.map(t=>e.jsx(O,{navId:t.id,linkComponent:r,icon:Re(t.role),label:t.name,ariaLabel:t.name,title:t.fullPath??t.name,failure:t.failure,count:t.unseen,active:a===t.id,dimmed:s.muted,onClick:()=>n?.(t.id)},t.id)),s.outboxPending!==void 0&&e.jsx(O,{navId:"outbox",linkComponent:r,icon:e.jsx(V,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:s.outboxPending>0?s.outboxPending:void 0,active:a==="outbox",dimmed:s.muted,onClick:()=>n?.("outbox")}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:k,"aria-expanded":f,className:C("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",w),children:[f?e.jsx(A,{className:"size-3 shrink-0"}):e.jsx(I,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:x.length})]}),f&&e.jsxs(e.Fragment,{children:[y.map(t=>e.jsx(O,{navId:t.id,linkComponent:r,icon:e.jsx(Y,{className:"size-4"}),label:t.name,ariaLabel:t.name,title:t.fullPath??t.name,failure:t.failure,count:t.unseen,active:a===t.id,dimmed:s.muted,onClick:()=>n?.(t.id)},t.id)),(i>0||m)&&x.length>z&&e.jsx("button",{type:"button",onClick:()=>p(t=>!t),className:C("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",w),children:m?"Show less":`Show all (${x.length})`})]})]})]})]})]})}function Fe({accounts:s,selectedNavId:a,briefUnseen:n,onSelectNav:r,variant:o="desktop",linkComponent:c,calendarNav:f="hidden"}){const g=N.useRef(null);ge({containerRef:g,itemSelector:Se});const m=o==="drawer",p=e.jsxs("nav",{ref:m?g:void 0,className:m?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(O,{navId:"brief",linkComponent:c,icon:e.jsx(W,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:n,active:a==="brief",onClick:()=>r?.("brief")}),f==="shown"&&e.jsx(O,{navId:"calendar",linkComponent:c,icon:e.jsx(H,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:a==="calendar",onClick:()=>r?.("calendar")}),e.jsx(O,{navId:"flagged",linkComponent:c,icon:e.jsx($,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:a==="flagged",onClick:()=>r?.("flagged")}),s.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):s.map(d=>e.jsx(Le,{account:d,selectedNavId:a,onSelectNav:r,linkComponent:c},d.id))]});return m?p:e.jsx("aside",{ref:g,className:"flex h-full w-full flex-col bg-surface-sunken",children:p})}function Ae(){const{pathname:s}=te(),a=ae({from:"/mail/$mailboxId",shouldThrow:!1});return S(s,"/settings")?"settings":S(s,"/calendar")?"calendar":S(s,"/mail/outbox")?"outbox":S(s,"/mail/flagged")?"flagged":S(s,"/mail/brief")?"brief":a?.mailboxId??""}const Ie=({children:s})=>{const{Account:a}=ne();return e.jsx(a,{children:s})},T=s=>/^\d/.test(s),Me=(s,a)=>{const n=T(s),r=T(a);return n&&!r?-1:!n&&r?1:s.localeCompare(a,void 0,{sensitivity:"base",numeric:!0})};function Ee(s,a,n){const r=[],o=[];for(const c of s)a.has(c.mailboxId)?r.push(c):o.push(c);return o.sort((c,f)=>Me(R(c,void 0,n),R(f,void 0,n))),{system:r,labels:o}}function Pe(s,a,n){const r=xe(a)&&s.unseenCount>0;return{id:s.mailboxId,name:R(s,a,n),unseen:r?s.unseenCount:void 0,role:a,fullPath:s.fullPath,failure:je(s)}}function q({accounts:s,onMailboxSelect:a,variant:n="desktop"}){const r=re(),o=Ae(),{onSearchChange:c}=ie(),{t:f}=le("mail",{useSuspense:!1}),g=N.useCallback((i,l)=>f(i,{defaultValue:l}),[f]),m=be({queries:s.map(i=>({...oe({path:{accountId:i.accountId}}),staleTime:1/0}))}),{data:p}=ce(ue()),d=N.useMemo(()=>(p?.items??[]).filter(i=>ye(i.status)).length,[p?.items]),k=N.useMemo(()=>s.map((i,l)=>{const h=m[l],b=h?.data?.items??[],t=de(i.folderAppointments),{system:u,labels:K}=Ee(b,t,g),U=h?.isError?"error":h?.isLoading?"loading":"ready";return{id:i.accountId,label:i.email,email:i.email,muted:!!i.muted,outboxPending:d,status:U,onRetry:()=>h?.refetch(),mailboxes:[...u,...K].map(F=>Pe(F,t.get(F.mailboxId),g))}}),[s,m,d,g]),j=i=>{r.invalidateQueries({queryKey:fe({path:{mailboxId:i},query:{order:"desc"}})})},x=({navId:i,className:l,ariaLabel:h,title:b,children:t,onClick:u})=>i==="brief"?e.jsx(v,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="calendar"?e.jsx(v,{to:"/calendar",onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="outbox"?e.jsx(v,{to:"/mail/outbox",search:{q:void 0},onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="flagged"?e.jsx(v,{to:"/mail/flagged",search:{q:void 0},onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):i==="settings"?e.jsx(v,{to:"/settings/accounts",onClick:()=>u?.(),className:l,"aria-label":h,title:b,children:t}):e.jsx(v,{to:"/mail/$mailboxId",params:{mailboxId:i},search:{q:void 0},onClick:()=>{j(i),u?.()},className:l,"aria-label":h,title:b,children:t}),y=()=>{c(""),a?.()};return e.jsx(Fe,{accounts:k,selectedNavId:o,onSelectNav:y,linkComponent:x,calendarNav:"shown",variant:n})}function _e(){return e.jsxs("button",{type:"button",onClick:me,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(ve,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function Ke({accounts:s,onMailboxSelect:a}){return he()?.showNavPane??!0?e.jsx(q,{accounts:s}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(q,{accounts:s,onMailboxSelect:a,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(v,{to:"/settings/accounts",onClick:a,children:[e.jsx(Ce,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(_e,{}),e.jsx(Ie,{children:({signOut:o})=>e.jsxs("button",{type:"button",onClick:()=>{a?.(),o()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(ke,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}export{Ie as A,ke as L,Ke as M,Ce as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aa as v,j as s,r as u,al as l,am as p}from"./index-
|
|
1
|
+
import{aa as v,j as s,r as u,al as l,am as p}from"./index-owcFTp8Y.js";import{F as x}from"./FullCompose-rxgtwgLT.js";import{a as m}from"./useMessageBodyContent-C6R-iTkz.js";function S(o,n,r){if(o!==n)return r}function d(o,n){return o===""?"":n}function j({searchInput:o,committedQuery:n,urlQuery:r,pathname:a,listPath:t}){return!v(a,t)||n!==o?!1:n!==r}const c=u.createContext(null),C=({chrome:o,children:n})=>s.jsx(c.Provider,{value:o,children:n});function M({phone:o,list:n,reading:r,intelligence:a,hasThread:t=!1}){const e=u.useContext(c),f=m();if(!e)return s.jsx(l,{});const i={nav:e.nav,overlay:e.overlay,skeleton:s.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?s.jsx(p,{...i,list:f?s.jsx(x,{}):o,intelligenceOpen:e.intelligenceOpen}):s.jsx(p,{...i,topBar:e.topBar,list:n,reading:r,intelligence:a,intelligenceOpen:e.intelligenceOpen,hasThread:t})}export{C as M,M as a,j as b,d as c,S as s};
|