@remit/web-client-dist 0.0.636 → 0.0.638
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-D75cGk9R.js → BriefPane-BxVikrB5.js} +1 -1
- package/assets/{CalendarComposePane-CQPTeieA.js → CalendarComposePane-D0Vp2Itu.js} +1 -1
- package/assets/{CalendarComposeSeed-YcnTcc9q.js → CalendarComposeSeed-CtCL_mLJ.js} +1 -1
- package/assets/{CalendarShell-C5-6_oQz.js → CalendarShell-BWxhr-00.js} +1 -1
- package/assets/{EmptyState-CwwN8uxT.js → EmptyState-Yzi62DaU.js} +1 -1
- package/assets/{ErrorState-DWzQfscg.js → ErrorState-CIGSPve0.js} +1 -1
- package/assets/{FlaggedPane-Jts36qML.js → FlaggedPane-D8IuTKJA.js} +1 -1
- package/assets/{FullCompose-CPT2R-pn.js → FullCompose-Foofg86q.js} +1 -1
- package/assets/{MailListHeader-BVdr1xz_.js → MailListHeader-BNxHVYcv.js} +1 -1
- package/assets/{MailNav-CmvgCpY4.js → MailNav-CRW_3QAa.js} +1 -1
- package/assets/{MailShell-DpEV7moX.js → MailShell-CFJzfGlh.js} +1 -1
- package/assets/{MailViewChrome-DO8IvQ0g.js → MailViewChrome-ULEUFQJk.js} +1 -1
- package/assets/{MailboxPane-BsR7VsfJ.js → MailboxPane-DsErXpfG.js} +1 -1
- package/assets/{NavMenuButton-6SG5syJx.js → NavMenuButton-BsBb4gKY.js} +1 -1
- package/assets/{OnboardingWizard-CSUHbolo.js → OnboardingWizard-BJuDumXD.js} +1 -1
- package/assets/{OpenCalendarEvent-CeB7apup.js → OpenCalendarEvent-CeV-RNZn.js} +1 -1
- package/assets/{OutboxPane-y8lpgoA7.js → OutboxPane-D-E0SdFz.js} +1 -1
- package/assets/_calendarObjectId-CNGtch1F.js +1 -0
- package/assets/_mailboxId-_JEUXtNb.js +1 -0
- package/assets/_messageId-B4n8qZEX.js +1 -0
- package/assets/_messageId-C72CoRos.js +1 -0
- package/assets/_messageId-DpKgESw2.js +1 -0
- package/assets/_outboxMessageId-CTeAJVIn.js +1 -0
- package/assets/_recurrenceId-Ck1moEqj.js +1 -0
- package/assets/_threadId-BpT_ReI5.js +1 -0
- package/assets/_threadId-D53wdJ38.js +1 -0
- package/assets/_threadId-bKS2kXRh.js +1 -0
- package/assets/{_view._date-DZANiEIP.js → _view._date-BYJZ72Ef.js} +1 -1
- package/assets/{accounts-BNbNVL6a.js → accounts-BdD1zv_1.js} +1 -1
- package/assets/{advanced-jKFdPJg9.js → advanced-CSbMP3GY.js} +1 -1
- package/assets/{appearance-szgjdrBE.js → appearance-BYKpSF0u.js} +1 -1
- package/assets/{attendee-row-BMb3eM14.js → attendee-row-CBVkVyxg.js} +1 -1
- package/assets/{avatar-BI9-h2CG.js → avatar-wmwGOEbt.js} +1 -1
- package/assets/{bell-off-CC53fBB2.js → bell-off-Uq9jCSwI.js} +1 -1
- package/assets/{bottom-sheet-D8oEb9Zv.js → bottom-sheet-D0Hvhh5I.js} +1 -1
- package/assets/brief-B5nPOeQO.js +1 -0
- package/assets/{brief-DE8_cylr.js → brief-BOC3H9BR.js} +1 -1
- package/assets/{browser-ponyfill-CRcfJGCX.js → browser-ponyfill-4DFOXFag.js} +1 -1
- package/assets/{bug-Dh0UIzTd.js → bug-BKXcK0BN.js} +1 -1
- package/assets/{calendar-clash-strip-BeF8DhB-.js → calendar-clash-strip-CIkaESKF.js} +1 -1
- package/assets/{calendar-format-nYSxDVLX.js → calendar-format-DbZ5N68a.js} +1 -1
- package/assets/{calendar-DI1uSMAF.js → calendar-nsI6AZYh.js} +1 -1
- package/assets/{calendar-report-_QLAbdRS.js → calendar-report-BKdPffg-.js} +1 -1
- package/assets/{calendar-suggestion-E9w2nRWu.js → calendar-suggestion-i-cq1MOS.js} +1 -1
- package/assets/{calendars-Boz0CIFB.js → calendars-pAyLq0Sk.js} +1 -1
- package/assets/{card-BmYyqZU8.js → card-CY7yZwTr.js} +1 -1
- package/assets/{checkbox-CZD6i6IR.js → checkbox-DXK6Mpxl.js} +1 -1
- package/assets/chevron-left-CqIqzfO-.js +1 -0
- package/assets/{circle-check-Bpm-cdIg.js → circle-check-B_39Dniq.js} +1 -1
- package/assets/{circle-check-big-CA-bYUtr.js → circle-check-big-BfJeZRfu.js} +1 -1
- package/assets/{circle-help-gF5YAjts.js → circle-help-C58cjvyJ.js} +1 -1
- package/assets/{clock-CHCFgl4d.js → clock-C07X5jyq.js} +1 -1
- package/assets/compose._-_outboxMessageId_-B0Ou-u2T.js +1 -0
- package/assets/compose._-_outboxMessageId_-BhmtFxMI.js +1 -0
- package/assets/compose._-_outboxMessageId_-DeeXSup1.js +1 -0
- package/assets/compose._-_outboxMessageId_-wPBlGoe2.js +1 -0
- package/assets/{config-import-D9ehhdRH.js → config-import-XXRsI7y4.js} +1 -1
- package/assets/{confirm-dialog-CocDko9U.js → confirm-dialog-CO3Q47Ed.js} +1 -1
- package/assets/{copy-DgGekFwr.js → copy-DVZuCsXa.js} +1 -1
- package/assets/{credential-steps-C6B4LLDZ.js → credential-steps-D7oNgulr.js} +1 -1
- package/assets/{download-CHu9yf-9.js → download-Bw2Vllbt.js} +1 -1
- package/assets/{file-json-lCoJ4MMG.js → file-json-Dv1oCxjP.js} +1 -1
- package/assets/{filters-CgNi0_GK.js → filters-DxcDiW96.js} +1 -1
- package/assets/{flagged-C06PvFbr.js → flagged-C6o7eBE-.js} +1 -1
- package/assets/flagged-CCvNyKyt.js +1 -0
- package/assets/{folders-BC2O8pN-.js → folders-DGqtxuUX.js} +1 -1
- package/assets/{help-copy-0vW7Uvdo.js → help-copy-DXf84d45.js} +1 -1
- package/assets/{import-BJiWqnIA.js → import-D10yi0bw.js} +1 -1
- package/assets/index-B4n8qZEX.js +1 -0
- package/assets/index-BDhMRLuD.js +1 -0
- package/assets/index-BJfvEh0N.js +1 -0
- package/assets/index-BLoY2EQo.js +1 -0
- package/assets/index-BSy4QPFm.js +1 -0
- package/assets/{index-DdmJVTyk.js → index-BupDORUK.js} +1 -1
- package/assets/index-CKOj3o78.js +1 -0
- package/assets/index-CsvY1rsl.js +1 -0
- package/assets/{index-DMA0YSsS.js → index-CzK28i9j.js} +7 -7
- package/assets/{index-CTrN7dU7.js → index-DY92QCSR.js} +4 -4
- package/assets/index-DpKgESw2.js +1 -0
- package/assets/index-Duqa9TxT.js +1 -0
- package/assets/{kbd-DNmTK9ke.js → kbd-IshtYac4.js} +1 -1
- package/assets/{labels-1K3nCcmA.js → labels-D1cysYM_.js} +1 -1
- package/assets/{mail-DverAFVu.js → mail-0DZ75OrV.js} +1 -1
- package/assets/{mail-2Lzca0sU.js → mail-D9saRn9q.js} +1 -1
- package/assets/{menu-AiRz5rLS.js → menu-Cf9AvCB4.js} +1 -1
- package/assets/minus-DnRmyzfO.js +1 -0
- package/assets/{new-DHyHJz8l.js → new-C8VABXdU.js} +1 -1
- package/assets/onboarding-SXbo0_ap.js +1 -0
- package/assets/{onboarding-completion-Bgona01R.js → onboarding-completion-BezxZCwa.js} +1 -1
- package/assets/outbox-DaMYNB9X.js +1 -0
- package/assets/{pane-header-C6F97UxO.js → pane-header-DkjfZ8Tp.js} +1 -1
- package/assets/{pencil-DpZEcc9Q.js → pencil-Cr3cD7Ro.js} +1 -1
- package/assets/{popover-menu-I_p7C4RX.js → popover-menu-RWFTWH7G.js} +1 -1
- package/assets/{refresh-cw-CrSEtN0j.js → refresh-cw-CTbJ_p-q.js} +1 -1
- package/assets/{rich-text-BY2WyJzR.js → rich-text-Cllo2piV.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-C53QtR8U.js → rich-text-spellcheck-worker-provider-C-EjDMgy.js} +1 -1
- package/assets/{rotate-ccw-BwoJPdTA.js → rotate-ccw-CfDitVYq.js} +1 -1
- package/assets/{roving-focus-BYBMU9YM.js → roving-focus-DpMnVF68.js} +1 -1
- package/assets/{row-actions-M9Ety9op.js → row-actions-KF2BSk82.js} +1 -1
- package/assets/{search-mirror-C1R24HUl.js → search-mirror-D6I8q8Cs.js} +1 -1
- package/assets/{search-token-index-BinolOMC.js → search-token-index-Q9leSR3T.js} +1 -1
- package/assets/{sections-CfTDsSEu.js → sections-B-W-WtPt.js} +1 -1
- package/assets/{senders-CxFpOLNR.js → senders-ClJ8fRk3.js} +1 -1
- package/assets/settings-Wg8D3KXf.js +1 -0
- package/assets/{settings-screen-BVPfYXKu.js → settings-screen-B_PQFRuy.js} +1 -1
- package/assets/{shield-check-B8NtyqSa.js → shield-check-D8eo9LoA.js} +1 -1
- package/assets/{suggested-vips-CvGUhfMR.js → suggested-vips-BtcXutsA.js} +1 -1
- package/assets/{undo-2-DafMLJl8.js → undo-2-Butz7ccS.js} +1 -1
- package/assets/{useCalendarData-CEqOF86-.js → useCalendarData-BSAZPZ0B.js} +1 -1
- package/assets/{useCalendarWrites-B66T9V8C.js → useCalendarWrites-CnQvO4W7.js} +1 -1
- package/assets/{useCalendars-DSVgnNGS.js → useCalendars-CwM5mJht.js} +1 -1
- package/assets/{useDebouncedValue-DgoW2gtH.js → useDebouncedValue-fxnjgn0m.js} +1 -1
- package/assets/{useFilters-CI6nPI8A.js → useFilters-ChqmruAS.js} +1 -1
- package/assets/{useLabels-BLAR4UCi.js → useLabels-DUjI2qnU.js} +1 -1
- package/assets/{useLayoutTier-Cs2hRSyr.js → useLayoutTier-jwvTD03B.js} +1 -1
- package/assets/{useMessageBodyContent-C6WheWR5.js → useMessageBodyContent-Bz3PjBMR.js} +1 -1
- package/assets/{useQueries-8ibIA6jj.js → useQueries-KfiF_Pqo.js} +1 -1
- package/assets/{useRefreshControl-BHFXn1pg.js → useRefreshControl-Byq7VWci.js} +1 -1
- package/assets/{useResultFolderIndex-BhA2C88T.js → useResultFolderIndex-DfcOniK6.js} +1 -1
- package/assets/{useSearchTokenContext-BZ3hasAQ.js → useSearchTokenContext-JEb7TW_N.js} +1 -1
- package/assets/{useSemanticSearch-BPL9gQ__.js → useSemanticSearch-B2Ox50AS.js} +1 -1
- package/assets/{useSignature-COUd5paq.js → useSignature-C0qsG8qo.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/_calendarObjectId-CIuW-Ie5.js +0 -1
- package/assets/_mailboxId-5RNGPJGS.js +0 -1
- package/assets/_messageId-BuD0qcm0.js +0 -1
- package/assets/_messageId-DUkglFhL.js +0 -1
- package/assets/_messageId-DfTFQr44.js +0 -1
- package/assets/_outboxMessageId-jTJb98_M.js +0 -1
- package/assets/_recurrenceId-CKRdebZ4.js +0 -1
- package/assets/_threadId-9TH68C7M.js +0 -1
- package/assets/_threadId-BzUUgT3O.js +0 -1
- package/assets/_threadId-CqA1Cn_c.js +0 -1
- package/assets/brief-Bd33YTD_.js +0 -1
- package/assets/chevron-left-B1U3lovQ.js +0 -1
- package/assets/compose._-_outboxMessageId_-BH8gcpDj.js +0 -1
- package/assets/compose._-_outboxMessageId_-D3WpZSA8.js +0 -1
- package/assets/compose._-_outboxMessageId_-DI8h85aO.js +0 -1
- package/assets/compose._-_outboxMessageId_-WBhljHnY.js +0 -1
- package/assets/flagged-BRQyqp_w.js +0 -1
- package/assets/index-6DAZlug3.js +0 -1
- package/assets/index-B4H0cbaA.js +0 -1
- package/assets/index-BuD0qcm0.js +0 -1
- package/assets/index-CEzeDIpM.js +0 -1
- package/assets/index-CdEqoUhn.js +0 -1
- package/assets/index-CxnKAlnw.js +0 -1
- package/assets/index-DfTFQr44.js +0 -1
- package/assets/index-XCWyX4Nu.js +0 -1
- package/assets/index-jeAFdPQ9.js +0 -1
- package/assets/minus-QLsR9rVM.js +0 -1
- package/assets/onboarding-CRGGfEXZ.js +0 -1
- package/assets/outbox-egss0WYm.js +0 -1
- package/assets/settings-I6fzE2gz.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,bU as ws,c0 as js,c1 as Ms,cO as Rs,B as ft,f as X,W as Es,t as Re,g as Wt,r as c,_ as Os,$ as As,bw as Ns,cP as Ge,h as jt,c as mt,ad as zs,i as Mt,cQ as Fs,cK as Ds,I as _s,a7 as Ls,a3 as Kt,cR as Ps,cS as Vt,bY as $s,bq as Bs,cT as Ws,cU as Ks,at as qt,cV as Vs,cW as qs,aH as Hs,aI as Qs,cX as Us,cY as Js,q as Rt,m as Gs,Q as Ht,bt as Ys,K as Xs,bu as Zs,bv as en,cZ as tn,o as sn,E as nn,F as on,c_ as rn,cy as an,s as ln,c$ as cn,d0 as un,d1 as Qt,d2 as Ut,C as Jt,ai as dn,d3 as hn,d4 as fn,ak as mn,bF as gn}from"./index-CTrN7dU7.js";import{u as pn,p as Dt,R as xn}from"./useSearchTokenContext-BZ3hasAQ.js";import{u as bn,a as vn,R as Sn}from"./useRefreshControl-BHFXn1pg.js";import{r as Et,C as Gt,c as Yt,j as yn,M as Cn,t as Xt,u as In,a as kn,b as Zt,d as es,e as Tn,f as wn,g as jn,n as Mn,h as Rn,i as En,S as On,k as An,D as Nn,l as zn,m as Fn,o as ts,p as Dn,q as _n,s as Ln,v as Pn,w as $n,x as ss,y as Bn,z as Wn,A as Kn,B as Vn,E as qn,F as Hn,G as Qn,H as Un,I as Jn,J as _t,K as Lt,L as Gn,N as Yn,O as Xn,P as Zn,Q as eo,R as to,T as so,U as no,V as oo,W as io,X as ro,Y as ao,Z as ns,_ as os,$ as is,a0 as lo,a1 as co,a2 as uo,a3 as ho,a4 as fo,a5 as mo,a6 as go,a7 as po}from"./MailListHeader-BVdr1xz_.js";import{S as xo,M as bo,a as vo,u as So,l as yo,b as Co}from"./MailViewChrome-DO8IvQ0g.js";import{A as Ot}from"./avatar-BI9-h2CG.js";import{P as Io}from"./pane-header-C6F97UxO.js";import{c as ko,f as To,a as wo,u as jo}from"./useMessageBodyContent-C6WheWR5.js";import{e as Ye,f as Mo,g as Ro,h as Eo,i as Oo}from"./search-token-index-BinolOMC.js";import{N as Ao}from"./NavMenuButton-6SG5syJx.js";import{C as No}from"./confirm-dialog-CocDko9U.js";import{f as zo}from"./ErrorState-DWzQfscg.js";import{a as Fo}from"./useLabels-BLAR4UCi.js";import{L as Do,r as _o,t as Lo,s as Po,u as $o}from"./useSemanticSearch-BPL9gQ__.js";import{S as gt}from"./shield-check-B8NtyqSa.js";import{B as Bo}from"./bottom-sheet-D8oEb9Zv.js";import{C as rs}from"./checkbox-CZD6i6IR.js";import{C as Wo}from"./circle-help-gF5YAjts.js";import{C as Ko}from"./circle-check-Bpm-cdIg.js";import{u as Vo}from"./useLayoutTier-Cs2hRSyr.js";import{n as qo}from"./search-query-Cr_ZXBCp.js";import{u as Ho}from"./sections-CfTDsSEu.js";const Qo=e=>e.toLocaleString(),Uo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Qo(e.value)} ${t} for “${o}”`};function Jo({query:e,count:o}){return r.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-surface-sunken/30 px-3 py-2",children:[r.jsx(ws,{className:"size-4 text-fg-muted","aria-hidden":"true"}),r.jsx("span",{className:"text-sm text-fg-muted",children:Uo(o,e)})]})}const Go=({children:e,onRefresh:o,isRefreshing:t})=>js(Ms)?e:r.jsx(Rs,{onRefresh:o,isPullable:!t,children:e}),Yo=e=>e===1?"message":"messages";function Xo({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ft,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(gt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${Yo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(X,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const Zo=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",as=({senderTrust:e,size:o="sm",className:t})=>{const s=Zo(e,o);return s==="vip"?r.jsx(Es,{className:Re("text-warning shrink-0",o==="sm"&&"size-3.5",o==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Re("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function ei({candidate:e,selected:o,onToggle:t,hideSender:s=!1}){const{senderName:n,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:h}=e;return r.jsxs("label",{className:Re("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",o?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(rs,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(Ot,{name:n,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:n}),h&&r.jsx(as,{senderTrust:h,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:l}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const ti=e=>{const o=new Map,t=[];for(const s of e){const n=(s.senderAddress||s.senderName).toLowerCase(),i=o.get(n);if(i){i.messages.push(s);continue}o.set(n,{key:n,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(n)}return t.map(s=>o.get(s)).sort((s,n)=>n.messages.length-s.messages.length)},si=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Pt=e=>e===1?"message":"messages";function ni({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,i]=c.useState(!1),l=si(e,o),a=e.messages.length,u=n?Os:As;return r.jsxs("div",{className:Re(l!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(rs,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Pt(a)} from ${e.senderName}`}),r.jsx(Ot,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(as,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(d=>!d),"aria-expanded":n,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${Pt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),n&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(ei,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const At=e=>e===1?"message":"messages",oi=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${At(e)}`} out of Spam to ${o} now. Nothing later.`,wt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function ii(){return r.jsx(ft,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function ri({candidates:e,selected:o,onToggle:t,onToggleGroup:s,onSelectAll:n,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),h=o.size,g=c.useMemo(()=>ti(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(gt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Wo,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(ii,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(X,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(ni,{group:m,selected:o,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(X,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${At(h)}`}),r.jsx(X,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function ai({count:e,folders:o,delimiter:t,destination:s,onPick:n,onMove:i,onBack:l}){const[a,u]=c.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(Ns,{folders:o,selectedId:s,delimiter:t,onSelect:n,onCancel:()=>u(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:wt(o,s)}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:oi(e,wt(o,s))}),r.jsx(X,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(X,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function li({count:e,destinationLabel:o,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(Ko,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${At(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${o}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(X,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function ci({open:e,candidates:o,defaultDestinationId:t,availableFolders:s,delimiter:n,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,h]=c.useState(()=>e?new Set(o.map(k=>k.id)):new Set),[g,m]=c.useState(t),[p,S]=c.useState(0),y=c.useRef(!1);c.useEffect(()=>{e&&!y.current&&(u("review"),h(new Set(o.map(k=>k.id))),m(t),S(0)),y.current=e},[e,o,t]);const I=d.size,b=k=>{h(w=>{const O=new Set(w);return O.has(k)?O.delete(k):O.add(k),O})},x=(k,w)=>{h(O=>{const A=new Set(O);for(const B of k.messages)w?A.add(B.id):A.delete(B.id);return A})},j=()=>{const k=Array.from(d);S(k.length),i(k,g),u("done")};return r.jsxs(Bo,{open:e,onClose:l,label:"Rescue from spam",dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ri,{candidates:o,selected:d,onToggle:b,onToggleGroup:x,onSelectAll:()=>h(new Set(o.map(k=>k.id))),onSelectNone:()=>h(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(ai,{count:I,folders:s,delimiter:n,destination:g,onPick:m,onMove:j,onBack:()=>u("review")}),a==="done"&&r.jsx(li,{count:p,destinationLabel:wt(s,g),onClose:l})]})}function ui(e){const o=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:o?`To: ${o}`:"(No recipients)",timeLabel:Ge(e.updatedAt),isRead:!0}}function di(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,...Et(e)}}function hi({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(ui),n=t.map(di),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),n.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:n}),i}const fi=({label:e,count:o})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:o})]}),mi=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Yt({active:o})),children:[r.jsx(Ls,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Gt,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:n,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(Kt,{className:"size-3.5"})})})]}),gi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Yt({active:o})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Ot,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Gt,{thread:e})]})};function pi({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=ko(),l=To(),a=Ye(),u=jt(),{data:d}=mt(zs()),h=c.useMemo(()=>hi({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=Mt({...Ds(),onSuccess:()=>{u.invalidateQueries({queryKey:Fs()})}}),m=y=>{g.mutate({path:{outboxMessageId:y}})},p=y=>{const I=t.find(b=>b.messageId===y)?.threadId;I&&a({threadId:I,messageId:y})},S=h.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsx(Io,{title:s,leading:r.jsx(Ao,{}),children:(n??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[n," unread"]})}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:S?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(_s,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):h.map(y=>r.jsxs("div",{children:[y.label&&r.jsx(fi,{label:y.label,count:y.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:y.threads.map(I=>y.id==="remit-drafts"?r.jsx(mi,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(gi,{row:I,isSelected:I.id===o,onOpen:p},I.id))})]},y.id))})]})}const ls=e=>e===1?"1 message":`${Vt(e)} messages`,xi=e=>({title:"Empty Trash?",description:`${ls(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),bi=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=Ps(0,"unconfirmed",{trashFolderLabel:t});return{headline:n.title,body:n.description,actionLabel:n.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function vi({messageCount:e,isEmptying:o,deletedCount:t,refusalReason:s,trashFolderLabel:n,staleFolderLabel:i,onEmpty:l,onRepair:a,children:u}){const[d,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:u});const g=s?bi(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=xi(e);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&r.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${ls(t)} erased from the mail server.`}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Kt,{className:"size-3.5","aria-hidden":!0}),disabled:o||e<1,"aria-busy":o,onClick:()=>h(!0),children:o?"Emptying…":"Empty Trash"})]}),g&&r.jsx(ft,{tone:"warning",variant:"soft",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("p",{className:"font-semibold text-fg",children:g.headline}),r.jsx("p",{className:"text-sm",children:g.body}),r.jsx(X,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:u}),r.jsx(No,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function Si(e,o,t){const s=new Array(e);return new Proxy(s,{get(n,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=n[u];if(!d){const h=o[u*2];d=n[u]={index:u,key:t(u),start:h,size:o[u*2+1],end:h+o[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(n,i,l)}})}function Le(e,o,t){let s=t.initialDeps??[],n,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,h)=>s[h]!==d))&&(s=a,n=o(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(n),i=!1),n}return l.updateDeps=a=>{s=a},l}function $t(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const yi=(e,o)=>Math.abs(e-o)<1.01,Ci=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Je;const kt=()=>{if(Je!==void 0)return Je;if(typeof navigator>"u")return Je=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Je=!0;const e=navigator.maxTouchPoints;return Je=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Bt=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Ii=e=>e,ki=e=>{const o=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-o+1,n=new Array(s);for(let i=0;i<s;i++)n[i]=o+i;return n},Ti=(e,o)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=l=>{const{width:a,height:u}=l;o({width:Math.round(a),height:Math.round(u)})};if(n(Bt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const u=l[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){n({width:d.inlineSize,height:d.blockSize});return}}n(Bt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ht={passive:!0},wi=typeof window>"u"?!0:"onscrollend"in window,ji=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&wi;let l=0;const a=i?null:Ci(n,()=>o(l,!1),e.options.isScrollingResetDelay),u=g=>()=>{l=t(s),a?.(),o(l,g)},d=u(!0),h=u(!1);return s.addEventListener("scroll",d,ht),i&&s.addEventListener("scrollend",h,ht),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",h)}},Mi=(e,o)=>ji(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),Ri=(e,o,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),n=t.options.getItemKey(s);return t.itemSizeCache.get(n)??t.options.estimateSize(s)}if(o?.borderBoxSize){const s=o.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!o){const s=t.indexFromElement(e),n=t.options.getItemKey(s),i=t.itemSizeCache.get(n);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Ei=(e,{adjustments:o=0,behavior:t},s)=>{var n,i;(i=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[s.options.horizontal?"left":"top"]:e+o,behavior:t})},Oi=Ei;class Ai{constructor(o){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,n;return((n=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:n.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,h]of this.elementsCache)if(h===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var i;return(i=s())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return(i=s())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{var s,n;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ii,rangeExtractor:ki,onChange:()=>{},measureElement:Ri,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const p=t[m];p!==void 0&&(i[m]=p)}const l=this.options;let a=null,u=null,d=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,p=i.count,S=this.getMeasurements(),y=m>0?((s=S[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=S[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==y||i.getItemKey(p-1)!==I)){d=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??S[0]:null;j&&(a=[j.key,this.getScrollOffset()-j.start]);const k=i.followOnAppend===!0?"auto":i.followOnAppend||null;k&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==I)&&(u=k)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,S=this.getMeasurements(),{count:y,getItemKey:I}=this.options;let b=0;for(;b<y&&I(b)!==m;)b++;if(b<y){const x=S[b];if(x){const j=x.start+p;j!==this.scrollOffset&&(g=j-this.scrollOffset,this.scrollOffset=j,h=!0)}}}(h||u)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,u,g])},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Le(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,l)=>{if(l&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!kt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ht),i.addEventListener("touchend",a,ht),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=n;i!==null&&!a&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Le(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,n,i,l,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=Le(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},h)=>{const g=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const b of this.laneAssignments.keys())b>=t&&this.laneAssignments.delete(b);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(b=>{this.itemSizeCache.set(b.key,b.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const b=t*2;let x=this._flatMeasurements;if(!x||x.length<b){const w=new Float64Array(b);x&&m>0&&w.set(x.subarray(0,m*2)),x=w,this._flatMeasurements=x}let j;if(m===0)j=s+n;else{const w=m-1;j=x[w*2]+x[w*2+1]+d}for(let w=m;w<t;w++){const O=i(w),A=g.get(O),B=typeof A=="number"?A:this.options.estimateSize(w);x[w*2]=j,x[w*2+1]=B,j+=B+d}const k=Si(t,x,i);return this.measurementsCache=k,k}const p=this.measurementsCache.slice(0,m),S=new Array(a).fill(void 0),y=new Float64Array(a);let I=0;for(let b=0;b<m;b++){const x=p[b];x&&(S[x.lane]===void 0&&I++,S[x.lane]=b,y[x.lane]=x.end)}for(let b=m;b<t;b++){const x=i(b),j=this.laneAssignments.get(b);let k,w;const O=u==="estimate"||g.has(x);if(j!==void 0&&this.options.lanes>1){k=j;const G=S[k],R=G!==void 0?p[G]:void 0;w=R?R.end+d:s+n}else if(I===a){let G=0,R=y[0],oe=S[0];for(let F=1;F<a;F++){const P=y[F];(P<R||P===R&&S[F]<oe)&&(G=F,R=P,oe=S[F])}k=G,w=R+d,O&&this.laneAssignments.set(b,k)}else k=b%this.options.lanes,w=s+n,O&&this.laneAssignments.set(b,k);const A=g.get(x),B=typeof A=="number"?A:this.options.estimateSize(b),J=w+B;p[b]={index:b,start:w,size:B,end:J,key:x,lane:k},S[k]===void 0&&I++,S[k]=b,y[k]=J}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Le(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=zi(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Le(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const n=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(n!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,n-i),a=Math.min(this.options.count-1,n+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),n=this.options.getItemKey(s),i=this.elementsCache.get(n);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(n,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var n,i;if(t<0||t>=this.options.count)return;let l,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(t),a=d[t*2],l=d[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;u=m.key,a=m.start,l=m.size}const h=this.itemSizeCache.get(u)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,S=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:a,size:l,end:a+l,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-p):S&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Le(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];n.push(u)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const n=this._flatMeasurements,i=this.options.lanes===1&&n!=null,l=cs(0,s.length-1,i?a=>n[a*2]:a=>$t(s[a]).start,t);return $t(s[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(n-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+n-this.options.scrollPaddingEnd)s="end";else if(l.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:n="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:n,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:n="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[l,a]=i,u=this.now();this.scrollState={index:t,align:a,behavior:n,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const n=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?n=l[i*2]+l[i*2+1]:n=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}n=Math.max(...i.filter(a=>a!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const n of s)n&&this.itemSizeCache.has(n.key)&&t.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(o)}applyScrollAdjustment(o,t){o!==0&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,n=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=n!==this.scrollState.lastTargetOffset;if(!l&&yi(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==n&&this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(n-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=n,d||(this.scrollState.behavior="auto"),this._scrollToOffset(n,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const cs=(e,o,t,s)=>{for(;e<=o;){const n=(e+o)/2|0,i=t(n);if(i<s)e=n+1;else if(i>s)o=n-1;else return n}return e>0?e-1:0};function Ni(e,o,t){let s=0;for(;s<=o;){const n=(s+o)/2|0,i=e[n*2];if(i<t)s=n+1;else if(i>t)o=n-1;else return n}return s>0?s-1:0}function zi(e,o,t,s,n){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&n!==null){const d=Ni(n,i,t);let h=d;const g=t+o;for(;h<i&&n[h*2]+n[h*2+1]<g;)h++;return{startIndex:d,endIndex:h}}let a=cs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+o;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(g=>g<t+o);){const g=e[u];d[g.lane]=g.end,u++}const h=Array(s).fill(t+o);for(;a>=0&&h.some(g=>g>=t);){const g=e[a];h[g.lane]=g.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const Tt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Fi({useFlushSync:e=!0,directDomUpdates:o=!1,directDomUpdatesMode:t="transform",...s}){const n=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:o,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=o,i.current.mode=t;const l=d=>{const h=i.current;if(!h.enabled||!h.container)return;const g=d.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const b=d.options.horizontal?"width":"height";h.container.style[b]=`${g}px`}const m=!!d.options.horizontal,p=h.mode==="transform",S=m?"left":"top",y=d.options.scrollMargin,I=d.getVirtualItems();for(const b of I){const x=b.start-y,j=d.elementsCache.get(b.key);j&&h.lastPositions.get(j)!==x&&(h.lastPositions.set(j,x),p?j.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:j.style[S]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(d);const S=d.range,y=m.prevRange;p=!y||y.isScrolling!==d.isScrolling||y.startIndex!==S?.startIndex||y.endIndex!==S?.endIndex,p&&(m.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:d.isScrolling}:null)}p&&(e&&h?$s.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Ai(a);return Object.assign(d,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const p=d.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return u.setOptions(a),Tt(()=>u._didMount(),[]),Tt(()=>u._willUpdate()),Tt(()=>{l(u)}),u}function Di(e){return Fi({observeElementRect:Ti,observeElementOffset:Mi,scrollToFn:Oi,...e})}const Nt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",_i=e=>`Select all ${Nt(e)}`,Li=(e,o)=>`All ${Vt(o)} ${Nt(e)} selected`,Pi=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=yn(s,n);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},$i=(e,o,t)=>e==="BACK"&&o&&t===void 0,Bi=(e,o)=>({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),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels,...Et(e)}),Wi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:p})=>r.jsx(Cn,{thread:Bi(e,d),link:{mailboxId:o,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:n,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:h,onLongPress:g}}),Ki=c.memo(Wi),Vi=e=>{const o=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),suspicious:o,...Et(e)}},qi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:p,density:S})=>{const[y,I]=c.useState("none"),b=Ye(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),I("none")},[m,p,e.messageId,e.isRead]),j=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),k=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),w=c.useCallback(()=>{b({threadId:e.threadId,messageId:e.messageId})},[b,e.threadId,e.messageId]),O=In(e.messageId,u);return g||d?r.jsx(Ki,{thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,density:S}):r.jsx("div",{role:"presentation",onPointerDownCapture:O.onMouseDown,onClickCapture:O.claimClick,onContextMenu:O.onContextMenu,children:r.jsx(xo,{thread:Vi(e),selectionMode:!1,checked:!1,active:t,peek:y,onPeek:I,onToggleCheck:k,onLongPress:j,onOpen:w,onAct:x})})},Hi=72,Qi=32,Ui=5,us="remit:list-density",Ji=()=>{try{const e=localStorage.getItem(us);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Gi=(e,o,t)=>_o(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Yi=({mailboxId:e,threads:o,selectedMessageId:t,isLoading:s,isError:n=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,resultCount:d={kind:"unknown"},onDeleteMessages:h,isDeleting:g=!1,isMoving:m=!1,onLoadMore:p,hasMore:S=!1,isLoadingMore:y=!1,accountId:I,listTitle:b,listMeta:x,listFilter:j,listSearchText:k,listScopeLabel:w,onTriageContextChange:O,commandsRef:A,hideHeader:B=!1})=>{const J=c.useRef(null),G=Ye(),R=Bs(),oe=Ws(),{verb:F,start:P,startFromSearch:Ee}=oe,Se=Ks(),ye=!!a?.trim(),W=kn(),{labels:Pe}=Fo(I),{pushError:ie}=qt(),[M,Ce]=c.useState(t),[Oe,Ie]=c.useState(),N=c.useCallback(f=>{Ie(v=>v===f?v:void 0),Ce(f)},[]),[Z,$e]=c.useState(Ji),K=c.useCallback(()=>{$e(f=>{const v=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(us,v)}catch{}return v})},[]),{toggleReadFor:ke}=Zt({mailboxId:e}),{junkMailboxId:fe}=es(I),me=ts(fe,e),Ae=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:re,staleFolderLabel:Be,guessedMailboxId:Ne}=Tn(Ae),{selectedIds:z,selectedCount:_,hasSelection:ne,isSelected:ee,toggle:Y,select:Te,clearSelection:we,selectRange:ge,setAnchor:V,selectAll:pe,toggleAll:te,intersectWith:Xe}=wn(),We=Fn(_,R),[xe,E]=c.useState(null),Ze=c.useCallback((f,v,he)=>{const Q=Vs(f,v,he,re);Q&&ie(Q)},[ie,re]),je=ye&&!!u,et=`${e}|${JSON.stringify(u??{})}`,T=jn({mailboxId:e,mailboxLabel:b,accountId:I,enabled:je,predicateKey:et,searchQuery:u??{},reportEnding:Ze}),tt=T.phase.kind,Ke=T.clear,L=c.useCallback(()=>{tt==="escalated"&&Ke(),we()},[we,Ke,tt]),[st,ae]=c.useState(null),be=c.useRef(null),le=c.useRef(!1),ze=c.useRef(null),Me=!s&&o.length>0,ce=Di({count:o.length,getScrollElement:()=>J.current,estimateSize:()=>Z==="compact"?Qi:Hi,overscan:Ui}),Ve=t?o.findIndex(f=>f.messageId===t):-1,q=M?o.findIndex(f=>f.messageId===M):-1,se=c.useCallback(f=>{if(f<0||f>=o.length)return;const v=o[f];if(We){Y(v.messageId);return}be.current=v.messageId,le.current=!1,Ie(v.messageId),Ce(v.messageId)},[o,We,Y]),Fe=c.useCallback(()=>{if(o.length===0)return;const f=q<0?0:Math.min(q+1,o.length-1);se(f)},[o.length,q,se]),nt=c.useCallback(()=>{if(o.length===0)return;const f=q<=0?0:q-1;se(f)},[o.length,q,se]),qe=c.useCallback(()=>se(0),[se]),He=c.useCallback(()=>se(o.length-1),[se,o.length]),ve=c.useCallback(()=>{M&&Y(M)},[M,Y]),D=c.useMemo(()=>o.map(f=>f.messageId),[o]),De=c.useMemo(()=>{const f=[];for(const v of o)z.has(v.messageId)&&f.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:Ge(v.sentDate),accountId:I});return f},[o,z,I]),xt=c.useCallback((f,v)=>v.shiftKey?(ge(D,f,M),!0):v.metaKey||v.ctrlKey?(Y(f),!0):(L(),V(f),!1),[D,M,ge,Y,L,V]),ot=c.useCallback(f=>{!h||f.length===0||(ze.current=M??null,E(f))},[h,M]),_e=c.useCallback(f=>{const v=Mn(D,M,f);v!==void 0&&(ge(D,v),be.current=v,le.current=!1,Ie(void 0),Ce(v))},[D,M,ge]),ue=c.useCallback(()=>_e(-1),[_e]),it=c.useCallback(()=>_e(1),[_e]),rt=c.useCallback(()=>{D.length>0&&pe(D)},[D,pe]),at=c.useCallback(f=>{const v=Pi({verb:f,confirmingDelete:xe!==null,hasSelection:ne,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:h?M:void 0});return v.kind==="openWizard"?(P(f),!0):v.kind==="confirmDelete"?(ot([v.messageId]),!0):v.kind==="unavailable"?(ie({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[xe,h,ne,fe,e,P,M,ot,ie]),de=c.useCallback((f,v)=>{const he=o.find(Q=>Q.messageId===f)?.threadId;he&&G({threadId:he,messageId:f},{replace:v?.replace})},[G,o]),lt=c.useCallback(()=>{M&&de(M)},[M,de]),bt=c.useCallback(f=>de(f,{replace:!0}),[de]);Rn({keyboardFocusedMessageId:Oe,openMessageId:t,enabled:R&&_===0,open:bt});const Qe=T.phase.kind==="escalated"?{scope:Nt(u??{}),total:T.phase.total,searchQuery:u??{},run:(f,v)=>T.runAction(f,void 0,v),stop:T.stop}:void 0,ct=c.useCallback(f=>{if(f.length===0){E(null);return}const v=new Set(f),he=o.findIndex(U=>v.has(U.messageId));let Q;for(let U=he+1;U<o.length;U++)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}if(Q===void 0){for(let U=he-1;U>=0;U--)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}}h?.(f),L(),ze.current=null,E(null),Q!==void 0&&(be.current=Q,le.current=!1,N(Q),R&&de(Q,{replace:!0})),R||ae(qs("delete",f.length,re))},[o,h,L,de,R,N,re]),ut=c.useCallback(()=>{const f=ze.current;ze.current=null,E(null),f!==null&&(be.current=f,le.current=!1,N(f))},[N]),Ue=c.useMemo(()=>Gi(o,z,I),[I,z,o]),vt=c.useCallback(()=>{if(Qe){Ee();return}P("organize")},[Qe,Ee,P]),St=c.useCallback(f=>{h?.([f])},[h]),dt=c.useCallback((f,v)=>{ke([f],!v)},[ke]),yt=c.useCallback(f=>{R||Te(f)},[R,Te]),C=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}L()},[T,L]),H=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(le.current||!R&&t)return;const f=q>=0?q:Ve;f>=0&&ce.scrollToIndex(f,{align:"auto"})},[q,Ve,ce,R,t]),c.useEffect(()=>{t&&(le.current=!1,N(t))},[t,N]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||N(o[0]?.messageId))},[o,M,N]),c.useEffect(()=>{O?.({focusedMessageId:M,selectedIds:Array.from(z),hasList:Me})},[M,z,Me,O]);const $=c.useRef(O);$.current=O,c.useEffect(()=>()=>$.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||Xe(o.map(f=>f.messageId))},[o,Xe,T.phase,T.isRunning]);const zt=c.useRef(e);c.useEffect(()=>{zt.current!==e&&(zt.current=e,L())},[e,L]),En({shouldBlockFn:({action:f})=>$i(f,ne,Se)?(L(),!0):!1,enableBeforeUnload:!1,disabled:!ne||Se!==void 0}),c.useEffect(()=>{const f=J.current;if(!f||!S||!p)return;const v=()=>{if(y)return;const{scrollTop:he,scrollHeight:Q,clientHeight:U}=f;he+U>=Q-200&&p()};return f.addEventListener("scroll",v,{passive:!0}),v(),()=>f.removeEventListener("scroll",v)},[S,y,p]),c.useEffect(()=>{const f=be.current;if(!f)return;const v=J.current?.querySelector(`[data-message-id="${f}"]`);v&&(be.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(A){if(!Me){A.current=null;return}return A.current={focusNext:Fe,focusPrevious:nt,focusFirst:qe,focusLast:He,openFocused:lt,toggleSelect:ve,extendSelectDown:it,extendSelectUp:ue,selectAll:rt,clearSelection:()=>ne?(L(),!0):!1,requestVerb:at,toggleDensity:K},()=>{A.current=null}}},[A,Me,Fe,nt,qe,He,lt,ve,it,ue,rt,ne,L,at,K]);const Ft=s?"loading":n?"error":o.length===0?"empty":"ready",fs=n?zo(i):void 0,ms=c.useCallback(()=>{const f=Hs(Qs());window.open(f,"_blank","noopener,noreferrer")},[]),gs=[{id:"inbox",threads:[]}],Ct=D.length>0&&D.every(f=>z.has(f)),ps=je&&S&&Ct&&!g&&!m&&T.phase.kind==="idle"&&!T.isRunning,xs=g||m||T.isRunning,It=T.phase.kind==="escalated"?T.phase.total:T.progress?T.progress.total:_,bs=T.runningAction?Us(T.runningAction.kind,T.progress?.done??0,T.progress?.total??It):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?Li(u??{},T.phase.total):void 0,vs=T.phase.kind!=="escalated"&&D.length>0?{checked:Ct,indeterminate:_>0&&!Ct,onChange:()=>te(D)}:void 0,Ss=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??It,tone:Js(T.runningAction.kind)}:void 0,ys=(T.isRunning||T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"?{tone:"info",text:"",action:{label:"Clear selection",onClick:H}}:ps?{tone:"info",text:"",action:{label:_i(u??{}),onClick:T.escalate}}:void 0)??(Ue?{tone:"warning",text:Ue}:void 0),Cs=r.jsx(On,{title:W.title||b,navSlot:W.navSlot,titleMeta:W.titleMeta,searchSlot:W.searchSlot,searchField:W.searchField,idleSlot:W.makeFilterSlot,count:It,onCancel:C,onDelete:()=>P("delete"),onMove:()=>P("move"),onOrganize:vt,onJunk:me?()=>P("junk"):void 0,onMarkRead:()=>P("markRead"),overflowSlot:I&&e&&_>0&&Pe.length>0?r.jsx(Do,{accountId:I,mailboxId:e,messageIds:Array.from(z)}):void 0,isBusy:xs,isCounting:T.phase.kind==="counting",selectAll:vs,statusLabel:bs,progress:Ss,notice:ys}),Is=An(D,M),ks=c.useCallback(f=>{le.current=!0,N(f)},[N]),Ts=r.jsxs(r.Fragment,{children:[ye&&a&&r.jsx(Jo,{query:a,count:d}),r.jsxs("div",{ref:J,role:"listbox","aria-multiselectable":!0,"aria-label":b,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ce.getTotalSize()}px`},children:ce.getVirtualItems().map(f=>{const v=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ce.measureElement,className:Re("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(qi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:Is===v.messageId,onFocusRow:ks,isChecked:ee(v.messageId),onToggleCheck:Y,onRowSelect:xt,isMultiSelectMode:We,onLongPress:yt,isDesktop:R,onDelete:St,onToggleRead:dt,density:Z})},f.key)})}),y&&r.jsx(bo,{})]})]});return r.jsxs(r.Fragment,{children:[st&&!R&&r.jsx(ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ae(null),children:st}),r.jsx(vo,{listTitle:b,listMeta:x,sections:gs,flatList:!0,listState:W.searchResults?"ready":Ft,searchQuery:k,listFilter:j,listScopeLabel:w,errorMessage:fs,onRetry:l,onReportError:ms,density:Z,selectedThreadId:t,onSelectThread:f=>de(f),isDesktop:R,hideHeader:B,selectionBar:Cs,listBody:W.searchResults??(Ft==="ready"?Ts:void 0)}),r.jsx(Nn,{isOpen:xe!==null,messageIds:xe??[],outcome:re,accountId:I,trashFolderLabel:b,staleFolderLabel:Be,guessedMailboxId:Ne,isDeleting:g,onConfirm:ct,onCancel:ut}),r.jsx(zn,{verb:F,accountId:I,mailboxId:e,mailboxLabel:b,selection:De,selectionRestriction:Ue?"spansAccounts":void 0,escalated:Qe,escalatedProgress:T.progress,onFinished:L,onRunEnded:Ze})]})},Xi=e=>Ht({path:{accountId:e}}),Zi=e=>{const o=jt(),t=Rt(),s=Mt({...Gs(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:Xi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},er=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=Zi(e);return r.jsx(Go,{onRefresh:t,isRefreshing:s,children:o})};function tr({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=Rt(),u=Ys(),{inboxMailboxId:d}=Dn(e),h=_n(e),{data:g}=mt({...Xs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Zs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:o,translator:u}),[g?.items,h,o,u]),p=c.useMemo(()=>d||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[d,m]),S=c.useRef(!1);c.useEffect(()=>{S.current||(S.current=!0,Ln(a,t.length))},[a,t.length]);const y=c.useCallback(()=>{Pn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((b,x)=>{$n(a,{selected:b.length,total:t.length,toInbox:x===d}),s(b,x)},[a,t.length,d,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(Xo,{count:t.length,onReview:y})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(ci,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:en(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const sr=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,nr=({accountId:e,mailboxId:o})=>{const t=jt(),{pushError:s}=qt(),{requestAppointment:n}=tn(),{trashByAccount:i}=ss(),l=e?i.get(e):void 0,a=sr(e,o,l?.mailboxId,l?.source),[u,d]=c.useState({scope:a});u.scope!==a&&d({scope:a});const h=u.scope===a?u:void 0,g=c.useCallback(()=>t.getQueryData(sn())?.accounts.find(w=>w.accountId===e)?.folderAppointments.find(w=>w.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:p,isPending:S}=Mt({...cn(),meta:ln(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,j,k)=>{k.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,j,k)=>{const w=rn(x);if(!w){s({title:"Couldn't empty Trash",detail:an(x),error:x});return}k?.scope===a&&d({scope:a,refusal:w})},onSettled:(x,j,k,w)=>{m.current===w?.scope&&(m.current=void 0),nn(t,on([w?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Ht({path:{accountId:e}})})}}),y=c.useCallback(()=>e?(d({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),I=c.useCallback(()=>{y()},[y]),b=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:y})},[h,n,y]);return{emptyTrash:I,isEmptying:S&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:b}},or="We can verify this sender";function ir(e){const{data:o}=mt({...un({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(o?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:or,trustSubReason:Bn(s.senderTrust),senderTrust:s.senderTrust}))}}const rr=6e4,ar=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=mt({queryKey:Qt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:i}=await Ut({path:{mailboxId:e},query:s,throwOnError:!0});return i},enabled:t,staleTime:rr});return t?Lo(n?.count):{kind:"unknown"}},lr=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t},cr=50,ds=c.createContext(null);function pt(){const e=c.useContext(ds);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function ur({mailboxId:e,thread:o,children:t}){const s=Ye(),n=Mo(),i=Ho(),l=o?.threadId,a=o?.messageId,u=Rt(),{accounts:d,searchQuery:h,onToggleIntelligence:g,onSearchClearQuery:m}=Jt(),p=pn(),S=qo(h),y=S.length>0,{freeText:I,tokens:b}=Dt(S,p),x=Dt(h.trim(),p).freeText,[j,k]=c.useState("all"),[w,O]=c.useState(new Set),A=c.useMemo(()=>({category:j,attributes:w}),[j,w]),B=c.useMemo(()=>Wn(A),[A]),J=y||Kn(A),{params:G,residual:R}=Vn(b,B),oe={order:"desc",...I?{query:I}:{},...G,...B},F={...oe,limit:cr},P={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},Ee=J?Qt({path:{mailboxId:e},query:F}):dn({path:{mailboxId:e},query:{order:"desc"}}),{data:Se,isLoading:ye,isError:W,error:Pe,refetch:ie,fetchNextPage:M,hasNextPage:Ce,isFetchingNextPage:Oe}=So({queryKey:Ee,queryFn:async({pageParam:C})=>{if(J){const{data:$}=await Ut({path:{mailboxId:e},query:{...F,continuationToken:C},throwOnError:!0});return $}const{data:H}=await gn({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return H},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,H)=>po(H?.queryKey,P)?C:void 0}),Ie=ar({mailboxId:e,criteria:oe,enabled:Po({hasSearchQuery:y,freeText:I,residualTokenCount:R.length})}),{accountId:N,isLoading:Z}=qn(e),$e=Ro({accounts:d}),K=Hn(Qn(lr(Se?.pages.flatMap(C=>C.items??[])??[])),R,N),ke=c.useCallback(C=>{k(C)},[]),fe=c.useCallback(C=>{O(H=>{const $=new Set(H);return $.has(C)?$.delete(C):$.add(C),$})},[]),me=c.useCallback(()=>{k("all"),O(new Set)},[]),Ae=c.useCallback(()=>{me(),m()},[me,m]),re=yo({chips:A,tokens:b,reach:R.length>0?"loaded-pages":Un(F),onClear:Ae}),Be=l?K.find(C=>C.messageId===a)??K.find(C=>C.threadId===l):void 0,Ne=Jn(l,a),z=Be??Ne,_=a??z?.messageId,ne=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:z?.mailboxId??e,subject:z?.subject,messageId:_,authenticity:z?.authenticity}},[l,z,_,e]),ee=c.useCallback(C=>{_&&C.includes(_)&&n()},[_,n]),{deleteMessages:Y,isPending:Te}=_t({mailboxId:e,onAfterOptimisticRemove:ee}),{moveMessages:we,isPending:ge}=Lt({mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),V=c.useRef(null),pe=Gn(),{listCommandsRef:te,onTriageContextChange:Xe,focusedMessageId:We,selectedIds:xe}=pe,E=K.find(C=>C.messageId===We)??z,Ze=Eo({accounts:d})??null,je=Yn({thread:z,isOpen:!0,mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),{draftsMailboxId:et}=Xn(N),T=et!==void 0&&et===e,{archiveMailboxId:tt}=Zn(N),Ke=eo(),L=hn(),st=c.useMemo(()=>fn(L,l,_),[L,l,_]),ae=c.useMemo(()=>{if(E)return C=>L({threadId:E.threadId,messageId:E.messageId,mode:C})},[L,E]),be=wo(),le=mn(),ze=jo(),Me=c.useCallback(C=>C?Ke(C):[],[Ke]),{toggleStar:ce}=to({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:Ve}=Zt({mailboxId:e,accountId:N}),{junkMailboxId:q}=es(N),se=q!=null&&q===e,Fe=ts(q,e),{candidates:nt}=ir(se?q:void 0),{moveMessages:qe}=Lt({mailboxId:e,threadId:E?.threadId,accountId:N,onAfterOptimisticRemove:ee}),{deleteMessages:He}=_t({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:ee}),{addressId:ve,address:D}=so(E),{updateFlags:De}=no({addressId:ve,senderEmail:E?.fromEmail??void 0}),xt=c.useCallback(()=>ae?.("reply"),[ae]),ot=c.useCallback(()=>ae?.("reply-all"),[ae]),_e=c.useCallback(()=>ae?.("forward"),[ae]),ue=c.useCallback(()=>Me(E),[Me,E]),it=c.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const C=ue();C.length>0&&He(C)},[te,ue,He]),rt=c.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const C=ue();C.length!==0&&(oo(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?io(E):!1}),qe(C,Fe))},[te,Fe,ue,qe,u,E]),at=c.useCallback(()=>{if(xe.length>0){const C=!(E?.hasStars??!1),H=new Set(xe);for(const $ of K)H.has($.messageId)&&$.hasStars!==C&&ce($.messageId,$.hasStars);return}E&&ce(E.messageId,E.hasStars)},[xe,K,E,ce]),de=c.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const C=ue();if(C.length===0)return;const H=!(E?.isRead??!1);Ve(C,H)},[te,ue,E,Ve]),lt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.muted?.value!==!0;De({muted:{value:C}})},[ve,D,De]),bt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.vip?.value!==!0;De({vip:{value:C}})},[ve,D,De]),Qe=c.useCallback(()=>{V.current?.open()},[]),ct=T?"drafts":tt===e?"archive":q===e?"junk":"inbox",ut=c.useRef("");c.useEffect(()=>{const C=ut.current;ut.current=S,S.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:ct})},[S,ct,u]);const{goBack:Ue,nextMessageId:vt,previousMessageId:St}=ro({context:pe,orderedIds:K.map(C=>C.messageId),selectedMessageId:_,enabled:!be&&!le,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:xt,replyAll:ot,forward:_e,delete:it,toggleStar:at,toggleRead:de,muteSender:lt,blockSender:z?Qe:void 0,vipSender:bt,markJunk:rt,toggleIntelligence:z?()=>V.current?.toggle():void 0,compose:ze,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),dt=C=>{if(!C)return;const H=K.find($=>$.messageId===C);return H?{threadId:H.threadId,messageId:C}:void 0},yt={mailboxId:e,selectedMessageId:_,selectedThread:z,conversation:ne,onOpenThread:s,threads:K,isLoading:ye,isError:W,error:Pe,mailboxAccountId:N,mailboxAccountLoading:Z,mailboxName:$e,unreadCount:Ze,isDraftsMailbox:T,isSpamFolder:se,rescueCandidates:nt,filterCategory:j,filterAttributes:w,onSelectFilterCategory:ke,onToggleFilterAttribute:fe,onClearFilters:me,listFilter:re,listSearchText:x||void 0,onToggleIntelligence:g,intelligenceRef:V,handleDeselectIfRemoved:ee,searchPredicate:y&&R.length===0?F:void 0,resultCount:Ie,onDeleteMessages:Y,onMoveMessages:we,isDeleting:Te,isMoving:ge,onLoadMore:M,hasMore:Ce,isLoadingMore:Oe,onTriageContextChange:Xe,listCommandsRef:te,onRetry:()=>ie(),onReply:st,onToolbarDelete:je.deleteThread,onToolbarStar:je.toggleStar,isStarred:je.isStarred,onToolbarMove:je.moveThread,onBack:Ue,nextThread:dt(vt),previousThread:dt(St)};return r.jsx(ds.Provider,{value:yt,children:t})}function hs(){const{mailboxId:e,selectedMessageId:o,threads:t,isLoading:s,isError:n,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:p,mailboxName:S,unreadCount:y,isDraftsMailbox:I,isSpamFolder:b,rescueCandidates:x,onTriageContextChange:j,listCommandsRef:k,onRetry:w,filterCategory:O,filterAttributes:A,onSelectFilterCategory:B,onToggleFilterAttribute:J,onClearFilters:G,listFilter:R,listSearchText:oe,searchPredicate:F,resultCount:P}=pt(),{searchQuery:Ee,searchInput:Se,accounts:ye,resultFolderIndex:W}=Jt(),Pe=Vo(),ie=Ye(),M=S??"Inbox",Ce=c.useMemo(()=>ho(),[]),{trashMailboxId:Oe}=fo(p),Ie=Oo({accounts:ye}),{trashByAccount:N}=ss(),Z=nr({accountId:p,mailboxId:e}),$e=Oe!=null&&Oe===e,K=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:ke}=bn(),{state:fe,errorMessage:me,refresh:Ae}=vn(K,{onSettled:w}),re=c.useMemo(()=>r.jsx(Sn,{state:fe,onRefresh:Ae,label:`Refresh ${M}`,errorMessage:me,hasUpdate:ke(K)}),[fe,Ae,M,me,ke,K]),Be=c.useMemo(()=>t.map(V=>mo(V,W)),[t,W]),{hits:Ne,isLoading:z}=$o({mailboxId:e,filterCategory:O}),_=c.useMemo(()=>go(Ne,t.map(V=>V.threadId),W),[Ne,t,W]),ne=c.useCallback(V=>{const pe=V.threadId??t.find(te=>te.messageId===V.id)?.threadId;pe&&ie({threadId:pe,messageId:V.id},{mailboxId:V.mailboxId??e,query:Se})},[e,ie,Se,t]);if(I&&p)return r.jsx(pi,{accountId:p,selectedMessageId:o,imapThreads:t,title:S??"Drafts",unreadCount:y??void 0});const ee=r.jsx(Yi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:w,searchQuery:Ee,searchPredicate:F,resultCount:P,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:R,listSearchText:oe,listScopeLabel:M,hideHeader:!0,onTriageContextChange:j,commandsRef:k}),Y=ye[0]?.accountId,Te=Pe==="phone"&&Y?r.jsx(er,{accountId:Y,children:ee}):ee,we=b&&x.length>0&&p?r.jsx(tr,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:Te}):Te,ge=$e?r.jsx(vi,{messageCount:Ie,isEmptying:Z.isEmptying,deletedCount:Z.deletedCount,refusalReason:Z.refusal?.reason,trashFolderLabel:S??void 0,staleFolderLabel:p?N.get(p)?.staleFolderPath:void 0,onEmpty:Z.emptyTrash,onRepair:Z.repair,children:we}):we;return r.jsx(Co,{title:M,unreadCount:y,preset:Ce,selectedCategory:O,activeFilters:A,onSelectCategory:B,onToggleFilter:J,onClearFilters:G,searchResults:Be,searchLoading:s,relatedResults:_,relatedLoading:z,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:re,children:ge})}function dr(){const{mailboxId:e,mailboxAccountId:o,mailboxAccountLoading:t,selectedThread:s,conversation:n,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:u,onToolbarMove:d,handleDeselectIfRemoved:h,intelligenceRef:g}=pt(),m=!!n,p=co(n?.threadId);ns(g,p);const S=c.useRef(null),{railFits:y,openRail:I}=p;c.useEffect(()=>{if(!y)return;const x=s?.messageId??null;x&&S.current!==x&&s?.authenticity?.dkimMismatch&&(S.current=x,I())},[y,I,s?.messageId,s?.authenticity?.dkimMismatch]);const b=n?r.jsx(os,{threadId:n.threadId,mailboxId:n.mailboxId,subject:n.subject,selectedMessageId:n.messageId,authenticity:n.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(xn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(uo,{hasThread:m,messageId:n?.messageId,intelligenceOpen:p.isShowing,canToggleIntelligence:p.canToggle,onToggleIntelligence:p.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:m?l:void 0,onToggleStar:m?a:void 0,isStarred:u,moveContext:m&&o?{accountId:o,currentMailboxId:e,onMove:d}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:b})]}),r.jsx(is,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:o,onAfterOptimisticRemove:h})]})}function hr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n}=pt();return r.jsx(lo,{onClose:s,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:n})}function fr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=pt(),h=ao(s?.threadId??null);return ns(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(os,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>n(l):void 0,onSwipePrevious:a?()=>n(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(is,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:u})]}):r.jsx(hs,{})}const Lr=Object.assign(ur,{List:hs,Reading:dr,Intelligence:hr,Phone:fr});export{Lr as M};
|
|
1
|
+
import{j as r,bU as ws,c0 as js,c1 as Ms,cO as Rs,B as ft,f as X,W as Es,t as Re,g as Wt,r as c,_ as Os,$ as As,bw as Ns,cP as Ge,h as jt,c as mt,ad as zs,i as Mt,cQ as Fs,cK as Ds,I as _s,a7 as Ls,a3 as Kt,cR as Ps,cS as Vt,bY as $s,bq as Bs,cT as Ws,cU as Ks,at as qt,cV as Vs,cW as qs,aH as Hs,aI as Qs,cX as Us,cY as Js,q as Rt,m as Gs,Q as Ht,bt as Ys,K as Xs,bu as Zs,bv as en,cZ as tn,o as sn,E as nn,F as on,c_ as rn,cy as an,s as ln,c$ as cn,d0 as un,d1 as Qt,d2 as Ut,C as Jt,ai as dn,d3 as hn,d4 as fn,ak as mn,bF as gn}from"./index-DY92QCSR.js";import{u as pn,p as Dt,R as xn}from"./useSearchTokenContext-JEb7TW_N.js";import{u as bn,a as vn,R as Sn}from"./useRefreshControl-Byq7VWci.js";import{r as Et,C as Gt,c as Yt,j as yn,M as Cn,t as Xt,u as In,a as kn,b as Zt,d as es,e as Tn,f as wn,g as jn,n as Mn,h as Rn,i as En,S as On,k as An,D as Nn,l as zn,m as Fn,o as ts,p as Dn,q as _n,s as Ln,v as Pn,w as $n,x as ss,y as Bn,z as Wn,A as Kn,B as Vn,E as qn,F as Hn,G as Qn,H as Un,I as Jn,J as _t,K as Lt,L as Gn,N as Yn,O as Xn,P as Zn,Q as eo,R as to,T as so,U as no,V as oo,W as io,X as ro,Y as ao,Z as ns,_ as os,$ as is,a0 as lo,a1 as co,a2 as uo,a3 as ho,a4 as fo,a5 as mo,a6 as go,a7 as po}from"./MailListHeader-BNxHVYcv.js";import{S as xo,M as bo,a as vo,u as So,l as yo,b as Co}from"./MailViewChrome-ULEUFQJk.js";import{A as Ot}from"./avatar-wmwGOEbt.js";import{P as Io}from"./pane-header-DkjfZ8Tp.js";import{c as ko,f as To,a as wo,u as jo}from"./useMessageBodyContent-Bz3PjBMR.js";import{e as Ye,f as Mo,g as Ro,h as Eo,i as Oo}from"./search-token-index-Q9leSR3T.js";import{N as Ao}from"./NavMenuButton-BsBb4gKY.js";import{C as No}from"./confirm-dialog-CO3Q47Ed.js";import{f as zo}from"./ErrorState-CIGSPve0.js";import{a as Fo}from"./useLabels-DUjI2qnU.js";import{L as Do,r as _o,t as Lo,s as Po,u as $o}from"./useSemanticSearch-B2Ox50AS.js";import{S as gt}from"./shield-check-D8eo9LoA.js";import{B as Bo}from"./bottom-sheet-D0Hvhh5I.js";import{C as rs}from"./checkbox-DXK6Mpxl.js";import{C as Wo}from"./circle-help-C58cjvyJ.js";import{C as Ko}from"./circle-check-B_39Dniq.js";import{u as Vo}from"./useLayoutTier-jwvTD03B.js";import{n as qo}from"./search-query-Cr_ZXBCp.js";import{u as Ho}from"./sections-B-W-WtPt.js";const Qo=e=>e.toLocaleString(),Uo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Qo(e.value)} ${t} for “${o}”`};function Jo({query:e,count:o}){return r.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-surface-sunken/30 px-3 py-2",children:[r.jsx(ws,{className:"size-4 text-fg-muted","aria-hidden":"true"}),r.jsx("span",{className:"text-sm text-fg-muted",children:Uo(o,e)})]})}const Go=({children:e,onRefresh:o,isRefreshing:t})=>js(Ms)?e:r.jsx(Rs,{onRefresh:o,isPullable:!t,children:e}),Yo=e=>e===1?"message":"messages";function Xo({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ft,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(gt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${Yo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(X,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const Zo=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",as=({senderTrust:e,size:o="sm",className:t})=>{const s=Zo(e,o);return s==="vip"?r.jsx(Es,{className:Re("text-warning shrink-0",o==="sm"&&"size-3.5",o==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Re("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function ei({candidate:e,selected:o,onToggle:t,hideSender:s=!1}){const{senderName:n,senderAddress:i,subject:l,snippet:a,trustReason:u,trustSubReason:d,senderTrust:h}=e;return r.jsxs("label",{className:Re("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",o?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(rs,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(Ot,{name:n,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:n}),h&&r.jsx(as,{senderTrust:h,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:l}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const ti=e=>{const o=new Map,t=[];for(const s of e){const n=(s.senderAddress||s.senderName).toLowerCase(),i=o.get(n);if(i){i.messages.push(s);continue}o.set(n,{key:n,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(n)}return t.map(s=>o.get(s)).sort((s,n)=>n.messages.length-s.messages.length)},si=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Pt=e=>e===1?"message":"messages";function ni({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,i]=c.useState(!1),l=si(e,o),a=e.messages.length,u=n?Os:As;return r.jsxs("div",{className:Re(l!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(rs,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Pt(a)} from ${e.senderName}`}),r.jsx(Ot,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(as,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(d=>!d),"aria-expanded":n,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${Pt(a)}`,r.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),n&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(ei,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const At=e=>e===1?"message":"messages",oi=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${At(e)}`} out of Spam to ${o} now. Nothing later.`,wt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function ii(){return r.jsx(ft,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function ri({candidates:e,selected:o,onToggle:t,onToggleGroup:s,onSelectAll:n,onSelectNone:i,onContinue:l,onCancel:a}){const[u,d]=c.useState(!1),h=o.size,g=c.useMemo(()=>ti(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(gt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Wo,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(ii,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(X,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(ni,{group:m,selected:o,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(X,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${At(h)}`}),r.jsx(X,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function ai({count:e,folders:o,delimiter:t,destination:s,onPick:n,onMove:i,onBack:l}){const[a,u]=c.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(Ns,{folders:o,selectedId:s,delimiter:t,onSelect:n,onCancel:()=>u(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:wt(o,s)}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:oi(e,wt(o,s))}),r.jsx(X,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(X,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function li({count:e,destinationLabel:o,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(Ko,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${At(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${o}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(X,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function ci({open:e,candidates:o,defaultDestinationId:t,availableFolders:s,delimiter:n,onConfirmMove:i,onCancel:l}){const[a,u]=c.useState("review"),[d,h]=c.useState(()=>e?new Set(o.map(k=>k.id)):new Set),[g,m]=c.useState(t),[p,S]=c.useState(0),y=c.useRef(!1);c.useEffect(()=>{e&&!y.current&&(u("review"),h(new Set(o.map(k=>k.id))),m(t),S(0)),y.current=e},[e,o,t]);const I=d.size,b=k=>{h(w=>{const O=new Set(w);return O.has(k)?O.delete(k):O.add(k),O})},x=(k,w)=>{h(O=>{const A=new Set(O);for(const B of k.messages)w?A.add(B.id):A.delete(B.id);return A})},j=()=>{const k=Array.from(d);S(k.length),i(k,g),u("done")};return r.jsxs(Bo,{open:e,onClose:l,label:"Rescue from spam",dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ri,{candidates:o,selected:d,onToggle:b,onToggleGroup:x,onSelectAll:()=>h(new Set(o.map(k=>k.id))),onSelectNone:()=>h(new Set),onContinue:()=>u("destination"),onCancel:l}),a==="destination"&&r.jsx(ai,{count:I,folders:s,delimiter:n,destination:g,onPick:m,onMove:j,onBack:()=>u("review")}),a==="done"&&r.jsx(li,{count:p,destinationLabel:wt(s,g),onClose:l})]})}function ui(e){const o=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:o?`To: ${o}`:"(No recipients)",timeLabel:Ge(e.updatedAt),isRead:!0}}function di(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,...Et(e)}}function hi({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(ui),n=t.map(di),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),n.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:n}),i}const fi=({label:e,count:o})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:o})]}),mi=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Yt({active:o})),children:[r.jsx(Ls,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Gt,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:n,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(Kt,{className:"size-3.5"})})})]}),gi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",Yt({active:o})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Ot,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Gt,{thread:e})]})};function pi({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=ko(),l=To(),a=Ye(),u=jt(),{data:d}=mt(zs()),h=c.useMemo(()=>hi({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=Mt({...Ds(),onSuccess:()=>{u.invalidateQueries({queryKey:Fs()})}}),m=y=>{g.mutate({path:{outboxMessageId:y}})},p=y=>{const I=t.find(b=>b.messageId===y)?.threadId;I&&a({threadId:I,messageId:y})},S=h.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsx(Io,{title:s,leading:r.jsx(Ao,{}),children:(n??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[n," unread"]})}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:S?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(_s,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):h.map(y=>r.jsxs("div",{children:[y.label&&r.jsx(fi,{label:y.label,count:y.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:y.threads.map(I=>y.id==="remit-drafts"?r.jsx(mi,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(gi,{row:I,isSelected:I.id===o,onOpen:p},I.id))})]},y.id))})]})}const ls=e=>e===1?"1 message":`${Vt(e)} messages`,xi=e=>({title:"Empty Trash?",description:`${ls(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),bi=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=Ps(0,"unconfirmed",{trashFolderLabel:t});return{headline:n.title,body:n.description,actionLabel:n.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function vi({messageCount:e,isEmptying:o,deletedCount:t,refusalReason:s,trashFolderLabel:n,staleFolderLabel:i,onEmpty:l,onRepair:a,children:u}){const[d,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:u});const g=s?bi(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=xi(e);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&r.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${ls(t)} erased from the mail server.`}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Kt,{className:"size-3.5","aria-hidden":!0}),disabled:o||e<1,"aria-busy":o,onClick:()=>h(!0),children:o?"Emptying…":"Empty Trash"})]}),g&&r.jsx(ft,{tone:"warning",variant:"soft",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("p",{className:"font-semibold text-fg",children:g.headline}),r.jsx("p",{className:"text-sm",children:g.body}),r.jsx(X,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:u}),r.jsx(No,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function Si(e,o,t){const s=new Array(e);return new Proxy(s,{get(n,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=n[u];if(!d){const h=o[u*2];d=n[u]={index:u,key:t(u),start:h,size:o[u*2+1],end:h+o[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(n,i,l)}})}function Le(e,o,t){let s=t.initialDeps??[],n,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((d,h)=>s[h]!==d))&&(s=a,n=o(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(n),i=!1),n}return l.updateDeps=a=>{s=a},l}function $t(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const yi=(e,o)=>Math.abs(e-o)<1.01,Ci=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Je;const kt=()=>{if(Je!==void 0)return Je;if(typeof navigator>"u")return Je=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Je=!0;const e=navigator.maxTouchPoints;return Je=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Bt=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Ii=e=>e,ki=e=>{const o=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-o+1,n=new Array(s);for(let i=0;i<s;i++)n[i]=o+i;return n},Ti=(e,o)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=l=>{const{width:a,height:u}=l;o({width:Math.round(a),height:Math.round(u)})};if(n(Bt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const u=l[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){n({width:d.inlineSize,height:d.blockSize});return}}n(Bt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ht={passive:!0},wi=typeof window>"u"?!0:"onscrollend"in window,ji=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&wi;let l=0;const a=i?null:Ci(n,()=>o(l,!1),e.options.isScrollingResetDelay),u=g=>()=>{l=t(s),a?.(),o(l,g)},d=u(!0),h=u(!1);return s.addEventListener("scroll",d,ht),i&&s.addEventListener("scrollend",h,ht),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",h)}},Mi=(e,o)=>ji(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),Ri=(e,o,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),n=t.options.getItemKey(s);return t.itemSizeCache.get(n)??t.options.estimateSize(s)}if(o?.borderBoxSize){const s=o.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!o){const s=t.indexFromElement(e),n=t.options.getItemKey(s),i=t.itemSizeCache.get(n);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Ei=(e,{adjustments:o=0,behavior:t},s)=>{var n,i;(i=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[s.options.horizontal?"left":"top"]:e+o,behavior:t})},Oi=Ei;class Ai{constructor(o){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,n;return((n=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:n.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{const l=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,h]of this.elementsCache)if(h===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var i;return(i=s())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return(i=s())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{var s,n;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ii,rangeExtractor:ki,onChange:()=>{},measureElement:Ri,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const p=t[m];p!==void 0&&(i[m]=p)}const l=this.options;let a=null,u=null,d=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,p=i.count,S=this.getMeasurements(),y=m>0?((s=S[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=S[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==y||i.getItemKey(p-1)!==I)){d=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??S[0]:null;j&&(a=[j.key,this.getScrollOffset()-j.start]);const k=i.followOnAppend===!0?"auto":i.followOnAppend||null;k&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==I)&&(u=k)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,S=this.getMeasurements(),{count:y,getItemKey:I}=this.options;let b=0;for(;b<y&&I(b)!==m;)b++;if(b<y){const x=S[b];if(x){const j=x.start+p;j!==this.scrollOffset&&(g=j-this.scrollOffset,this.scrollOffset=j,h=!0)}}}(h||u)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,u,g])},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Le(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,l)=>{if(l&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!kt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ht),i.addEventListener("touchend",a,ht),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){const[i,l,a,u]=n;i!==null&&!a&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Le(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,n,i,l,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=Le(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:n,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:u,gap:d},h)=>{const g=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const b of this.laneAssignments.keys())b>=t&&this.laneAssignments.delete(b);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(b=>{this.itemSizeCache.set(b.key,b.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const b=t*2;let x=this._flatMeasurements;if(!x||x.length<b){const w=new Float64Array(b);x&&m>0&&w.set(x.subarray(0,m*2)),x=w,this._flatMeasurements=x}let j;if(m===0)j=s+n;else{const w=m-1;j=x[w*2]+x[w*2+1]+d}for(let w=m;w<t;w++){const O=i(w),A=g.get(O),B=typeof A=="number"?A:this.options.estimateSize(w);x[w*2]=j,x[w*2+1]=B,j+=B+d}const k=Si(t,x,i);return this.measurementsCache=k,k}const p=this.measurementsCache.slice(0,m),S=new Array(a).fill(void 0),y=new Float64Array(a);let I=0;for(let b=0;b<m;b++){const x=p[b];x&&(S[x.lane]===void 0&&I++,S[x.lane]=b,y[x.lane]=x.end)}for(let b=m;b<t;b++){const x=i(b),j=this.laneAssignments.get(b);let k,w;const O=u==="estimate"||g.has(x);if(j!==void 0&&this.options.lanes>1){k=j;const G=S[k],R=G!==void 0?p[G]:void 0;w=R?R.end+d:s+n}else if(I===a){let G=0,R=y[0],oe=S[0];for(let F=1;F<a;F++){const P=y[F];(P<R||P===R&&S[F]<oe)&&(G=F,R=P,oe=S[F])}k=G,w=R+d,O&&this.laneAssignments.set(b,k)}else k=b%this.options.lanes,w=s+n,O&&this.laneAssignments.set(b,k);const A=g.get(x),B=typeof A=="number"?A:this.options.estimateSize(b),J=w+B;p[b]={index:b,start:w,size:B,end:J,key:x,lane:k},S[k]===void 0&&I++,S[k]=b,y[k]=J}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Le(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=zi(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Le(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const n=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(n!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,n-i),a=Math.min(this.options.count-1,n+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),n=this.options.getItemKey(s),i=this.elementsCache.get(n);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(n,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var n,i;if(t<0||t>=this.options.count)return;let l,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(t),a=d[t*2],l=d[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;u=m.key,a=m.start,l=m.size}const h=this.itemSizeCache.get(u)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,S=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:a,size:l,end:a+l,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-p):S&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Le(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],u=s[a];n.push(u)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const n=this._flatMeasurements,i=this.options.lanes===1&&n!=null,l=cs(0,s.length-1,i?a=>n[a*2]:a=>$t(s[a]).start,t);return $t(s[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(n-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+n-this.options.scrollPaddingEnd)s="end";else if(l.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:n="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:n,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:n="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[l,a]=i,u=this.now();this.scrollState={index:t,align:a,behavior:n,startedAt:u,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const n=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?n=l[i*2]+l[i*2+1]:n=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}n=Math.max(...i.filter(a=>a!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const n of s)n&&this.itemSizeCache.has(n.key)&&t.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(o)}applyScrollAdjustment(o,t){o!==0&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,n=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=n!==this.scrollState.lastTargetOffset;if(!l&&yi(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==n&&this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,u=Math.abs(n-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=n,d||(this.scrollState.behavior="auto"),this._scrollToOffset(n,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const cs=(e,o,t,s)=>{for(;e<=o;){const n=(e+o)/2|0,i=t(n);if(i<s)e=n+1;else if(i>s)o=n-1;else return n}return e>0?e-1:0};function Ni(e,o,t){let s=0;for(;s<=o;){const n=(s+o)/2|0,i=e[n*2];if(i<t)s=n+1;else if(i>t)o=n-1;else return n}return s>0?s-1:0}function zi(e,o,t,s,n){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&n!==null){const d=Ni(n,i,t);let h=d;const g=t+o;for(;h<i&&n[h*2]+n[h*2+1]<g;)h++;return{startIndex:d,endIndex:h}}let a=cs(0,i,d=>e[d].start,t),u=a;if(s===1)for(;u<i&&e[u].end<t+o;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(g=>g<t+o);){const g=e[u];d[g.lane]=g.end,u++}const h=Array(s).fill(t+o);for(;a>=0&&h.some(g=>g>=t);){const g=e[a];h[g.lane]=g.start,a--}a=Math.max(0,a-a%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:a,endIndex:u}}const Tt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Fi({useFlushSync:e=!0,directDomUpdates:o=!1,directDomUpdatesMode:t="transform",...s}){const n=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:o,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=o,i.current.mode=t;const l=d=>{const h=i.current;if(!h.enabled||!h.container)return;const g=d.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const b=d.options.horizontal?"width":"height";h.container.style[b]=`${g}px`}const m=!!d.options.horizontal,p=h.mode==="transform",S=m?"left":"top",y=d.options.scrollMargin,I=d.getVirtualItems();for(const b of I){const x=b.start-y,j=d.elementsCache.get(b.key);j&&h.lastPositions.get(j)!==x&&(h.lastPositions.set(j,x),p?j.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:j.style[S]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(d);const S=d.range,y=m.prevRange;p=!y||y.isScrolling!==d.isScrolling||y.startIndex!==S?.startIndex||y.endIndex!==S?.endIndex,p&&(m.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:d.isScrolling}:null)}p&&(e&&h?$s.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Ai(a);return Object.assign(d,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const p=d.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return u.setOptions(a),Tt(()=>u._didMount(),[]),Tt(()=>u._willUpdate()),Tt(()=>{l(u)}),u}function Di(e){return Fi({observeElementRect:Ti,observeElementOffset:Mi,scrollToFn:Oi,...e})}const Nt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",_i=e=>`Select all ${Nt(e)}`,Li=(e,o)=>`All ${Vt(o)} ${Nt(e)} selected`,Pi=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=yn(s,n);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},$i=(e,o,t)=>e==="BACK"&&o&&t===void 0,Bi=(e,o)=>({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),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels,...Et(e)}),Wi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:p})=>r.jsx(Cn,{thread:Bi(e,d),link:{mailboxId:o,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:n,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:h,onLongPress:g}}),Ki=c.memo(Wi),Vi=e=>{const o=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ge(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Xt(e.category),suspicious:o,...Et(e)}},qi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:p,density:S})=>{const[y,I]=c.useState("none"),b=Ye(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),I("none")},[m,p,e.messageId,e.isRead]),j=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),k=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),w=c.useCallback(()=>{b({threadId:e.threadId,messageId:e.messageId})},[b,e.threadId,e.messageId]),O=In(e.messageId,u);return g||d?r.jsx(Ki,{thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,density:S}):r.jsx("div",{role:"presentation",onPointerDownCapture:O.onMouseDown,onClickCapture:O.claimClick,onContextMenu:O.onContextMenu,children:r.jsx(xo,{thread:Vi(e),selectionMode:!1,checked:!1,active:t,peek:y,onPeek:I,onToggleCheck:k,onLongPress:j,onOpen:w,onAct:x})})},Hi=72,Qi=32,Ui=5,us="remit:list-density",Ji=()=>{try{const e=localStorage.getItem(us);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Gi=(e,o,t)=>_o(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Yi=({mailboxId:e,threads:o,selectedMessageId:t,isLoading:s,isError:n=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:u,resultCount:d={kind:"unknown"},onDeleteMessages:h,isDeleting:g=!1,isMoving:m=!1,onLoadMore:p,hasMore:S=!1,isLoadingMore:y=!1,accountId:I,listTitle:b,listMeta:x,listFilter:j,listSearchText:k,listScopeLabel:w,onTriageContextChange:O,commandsRef:A,hideHeader:B=!1})=>{const J=c.useRef(null),G=Ye(),R=Bs(),oe=Ws(),{verb:F,start:P,startFromSearch:Ee}=oe,Se=Ks(),ye=!!a?.trim(),W=kn(),{labels:Pe}=Fo(I),{pushError:ie}=qt(),[M,Ce]=c.useState(t),[Oe,Ie]=c.useState(),N=c.useCallback(f=>{Ie(v=>v===f?v:void 0),Ce(f)},[]),[Z,$e]=c.useState(Ji),K=c.useCallback(()=>{$e(f=>{const v=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(us,v)}catch{}return v})},[]),{toggleReadFor:ke}=Zt({mailboxId:e}),{junkMailboxId:fe}=es(I),me=ts(fe,e),Ae=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:re,staleFolderLabel:Be,guessedMailboxId:Ne}=Tn(Ae),{selectedIds:z,selectedCount:_,hasSelection:ne,isSelected:ee,toggle:Y,select:Te,clearSelection:we,selectRange:ge,setAnchor:V,selectAll:pe,toggleAll:te,intersectWith:Xe}=wn(),We=Fn(_,R),[xe,E]=c.useState(null),Ze=c.useCallback((f,v,he)=>{const Q=Vs(f,v,he,re);Q&&ie(Q)},[ie,re]),je=ye&&!!u,et=`${e}|${JSON.stringify(u??{})}`,T=jn({mailboxId:e,mailboxLabel:b,accountId:I,enabled:je,predicateKey:et,searchQuery:u??{},reportEnding:Ze}),tt=T.phase.kind,Ke=T.clear,L=c.useCallback(()=>{tt==="escalated"&&Ke(),we()},[we,Ke,tt]),[st,ae]=c.useState(null),be=c.useRef(null),le=c.useRef(!1),ze=c.useRef(null),Me=!s&&o.length>0,ce=Di({count:o.length,getScrollElement:()=>J.current,estimateSize:()=>Z==="compact"?Qi:Hi,overscan:Ui}),Ve=t?o.findIndex(f=>f.messageId===t):-1,q=M?o.findIndex(f=>f.messageId===M):-1,se=c.useCallback(f=>{if(f<0||f>=o.length)return;const v=o[f];if(We){Y(v.messageId);return}be.current=v.messageId,le.current=!1,Ie(v.messageId),Ce(v.messageId)},[o,We,Y]),Fe=c.useCallback(()=>{if(o.length===0)return;const f=q<0?0:Math.min(q+1,o.length-1);se(f)},[o.length,q,se]),nt=c.useCallback(()=>{if(o.length===0)return;const f=q<=0?0:q-1;se(f)},[o.length,q,se]),qe=c.useCallback(()=>se(0),[se]),He=c.useCallback(()=>se(o.length-1),[se,o.length]),ve=c.useCallback(()=>{M&&Y(M)},[M,Y]),D=c.useMemo(()=>o.map(f=>f.messageId),[o]),De=c.useMemo(()=>{const f=[];for(const v of o)z.has(v.messageId)&&f.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:Ge(v.sentDate),accountId:I});return f},[o,z,I]),xt=c.useCallback((f,v)=>v.shiftKey?(ge(D,f,M),!0):v.metaKey||v.ctrlKey?(Y(f),!0):(L(),V(f),!1),[D,M,ge,Y,L,V]),ot=c.useCallback(f=>{!h||f.length===0||(ze.current=M??null,E(f))},[h,M]),_e=c.useCallback(f=>{const v=Mn(D,M,f);v!==void 0&&(ge(D,v),be.current=v,le.current=!1,Ie(void 0),Ce(v))},[D,M,ge]),ue=c.useCallback(()=>_e(-1),[_e]),it=c.useCallback(()=>_e(1),[_e]),rt=c.useCallback(()=>{D.length>0&&pe(D)},[D,pe]),at=c.useCallback(f=>{const v=Pi({verb:f,confirmingDelete:xe!==null,hasSelection:ne,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:h?M:void 0});return v.kind==="openWizard"?(P(f),!0):v.kind==="confirmDelete"?(ot([v.messageId]),!0):v.kind==="unavailable"?(ie({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[xe,h,ne,fe,e,P,M,ot,ie]),de=c.useCallback((f,v)=>{const he=o.find(Q=>Q.messageId===f)?.threadId;he&&G({threadId:he,messageId:f},{replace:v?.replace})},[G,o]),lt=c.useCallback(()=>{M&&de(M)},[M,de]),bt=c.useCallback(f=>de(f,{replace:!0}),[de]);Rn({keyboardFocusedMessageId:Oe,openMessageId:t,enabled:R&&_===0,open:bt});const Qe=T.phase.kind==="escalated"?{scope:Nt(u??{}),total:T.phase.total,searchQuery:u??{},run:(f,v)=>T.runAction(f,void 0,v),stop:T.stop}:void 0,ct=c.useCallback(f=>{if(f.length===0){E(null);return}const v=new Set(f),he=o.findIndex(U=>v.has(U.messageId));let Q;for(let U=he+1;U<o.length;U++)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}if(Q===void 0){for(let U=he-1;U>=0;U--)if(!v.has(o[U].messageId)){Q=o[U].messageId;break}}h?.(f),L(),ze.current=null,E(null),Q!==void 0&&(be.current=Q,le.current=!1,N(Q),R&&de(Q,{replace:!0})),R||ae(qs("delete",f.length,re))},[o,h,L,de,R,N,re]),ut=c.useCallback(()=>{const f=ze.current;ze.current=null,E(null),f!==null&&(be.current=f,le.current=!1,N(f))},[N]),Ue=c.useMemo(()=>Gi(o,z,I),[I,z,o]),vt=c.useCallback(()=>{if(Qe){Ee();return}P("organize")},[Qe,Ee,P]),St=c.useCallback(f=>{h?.([f])},[h]),dt=c.useCallback((f,v)=>{ke([f],!v)},[ke]),yt=c.useCallback(f=>{R||Te(f)},[R,Te]),C=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}L()},[T,L]),H=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(le.current||!R&&t)return;const f=q>=0?q:Ve;f>=0&&ce.scrollToIndex(f,{align:"auto"})},[q,Ve,ce,R,t]),c.useEffect(()=>{t&&(le.current=!1,N(t))},[t,N]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||N(o[0]?.messageId))},[o,M,N]),c.useEffect(()=>{O?.({focusedMessageId:M,selectedIds:Array.from(z),hasList:Me})},[M,z,Me,O]);const $=c.useRef(O);$.current=O,c.useEffect(()=>()=>$.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||Xe(o.map(f=>f.messageId))},[o,Xe,T.phase,T.isRunning]);const zt=c.useRef(e);c.useEffect(()=>{zt.current!==e&&(zt.current=e,L())},[e,L]),En({shouldBlockFn:({action:f})=>$i(f,ne,Se)?(L(),!0):!1,enableBeforeUnload:!1,disabled:!ne||Se!==void 0}),c.useEffect(()=>{const f=J.current;if(!f||!S||!p)return;const v=()=>{if(y)return;const{scrollTop:he,scrollHeight:Q,clientHeight:U}=f;he+U>=Q-200&&p()};return f.addEventListener("scroll",v,{passive:!0}),v(),()=>f.removeEventListener("scroll",v)},[S,y,p]),c.useEffect(()=>{const f=be.current;if(!f)return;const v=J.current?.querySelector(`[data-message-id="${f}"]`);v&&(be.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(A){if(!Me){A.current=null;return}return A.current={focusNext:Fe,focusPrevious:nt,focusFirst:qe,focusLast:He,openFocused:lt,toggleSelect:ve,extendSelectDown:it,extendSelectUp:ue,selectAll:rt,clearSelection:()=>ne?(L(),!0):!1,requestVerb:at,toggleDensity:K},()=>{A.current=null}}},[A,Me,Fe,nt,qe,He,lt,ve,it,ue,rt,ne,L,at,K]);const Ft=s?"loading":n?"error":o.length===0?"empty":"ready",fs=n?zo(i):void 0,ms=c.useCallback(()=>{const f=Hs(Qs());window.open(f,"_blank","noopener,noreferrer")},[]),gs=[{id:"inbox",threads:[]}],Ct=D.length>0&&D.every(f=>z.has(f)),ps=je&&S&&Ct&&!g&&!m&&T.phase.kind==="idle"&&!T.isRunning,xs=g||m||T.isRunning,It=T.phase.kind==="escalated"?T.phase.total:T.progress?T.progress.total:_,bs=T.runningAction?Us(T.runningAction.kind,T.progress?.done??0,T.progress?.total??It):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?Li(u??{},T.phase.total):void 0,vs=T.phase.kind!=="escalated"&&D.length>0?{checked:Ct,indeterminate:_>0&&!Ct,onChange:()=>te(D)}:void 0,Ss=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??It,tone:Js(T.runningAction.kind)}:void 0,ys=(T.isRunning||T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"?{tone:"info",text:"",action:{label:"Clear selection",onClick:H}}:ps?{tone:"info",text:"",action:{label:_i(u??{}),onClick:T.escalate}}:void 0)??(Ue?{tone:"warning",text:Ue}:void 0),Cs=r.jsx(On,{title:W.title||b,navSlot:W.navSlot,titleMeta:W.titleMeta,searchSlot:W.searchSlot,searchField:W.searchField,idleSlot:W.makeFilterSlot,count:It,onCancel:C,onDelete:()=>P("delete"),onMove:()=>P("move"),onOrganize:vt,onJunk:me?()=>P("junk"):void 0,onMarkRead:()=>P("markRead"),overflowSlot:I&&e&&_>0&&Pe.length>0?r.jsx(Do,{accountId:I,mailboxId:e,messageIds:Array.from(z)}):void 0,isBusy:xs,isCounting:T.phase.kind==="counting",selectAll:vs,statusLabel:bs,progress:Ss,notice:ys}),Is=An(D,M),ks=c.useCallback(f=>{le.current=!0,N(f)},[N]),Ts=r.jsxs(r.Fragment,{children:[ye&&a&&r.jsx(Jo,{query:a,count:d}),r.jsxs("div",{ref:J,role:"listbox","aria-multiselectable":!0,"aria-label":b,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ce.getTotalSize()}px`},children:ce.getVirtualItems().map(f=>{const v=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ce.measureElement,className:Re("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(qi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:Is===v.messageId,onFocusRow:ks,isChecked:ee(v.messageId),onToggleCheck:Y,onRowSelect:xt,isMultiSelectMode:We,onLongPress:yt,isDesktop:R,onDelete:St,onToggleRead:dt,density:Z})},f.key)})}),y&&r.jsx(bo,{})]})]});return r.jsxs(r.Fragment,{children:[st&&!R&&r.jsx(ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ae(null),children:st}),r.jsx(vo,{listTitle:b,listMeta:x,sections:gs,flatList:!0,listState:W.searchResults?"ready":Ft,searchQuery:k,listFilter:j,listScopeLabel:w,errorMessage:fs,onRetry:l,onReportError:ms,density:Z,selectedThreadId:t,onSelectThread:f=>de(f),isDesktop:R,hideHeader:B,selectionBar:Cs,listBody:W.searchResults??(Ft==="ready"?Ts:void 0)}),r.jsx(Nn,{isOpen:xe!==null,messageIds:xe??[],outcome:re,accountId:I,trashFolderLabel:b,staleFolderLabel:Be,guessedMailboxId:Ne,isDeleting:g,onConfirm:ct,onCancel:ut}),r.jsx(zn,{verb:F,accountId:I,mailboxId:e,mailboxLabel:b,selection:De,selectionRestriction:Ue?"spansAccounts":void 0,escalated:Qe,escalatedProgress:T.progress,onFinished:L,onRunEnded:Ze})]})},Xi=e=>Ht({path:{accountId:e}}),Zi=e=>{const o=jt(),t=Rt(),s=Mt({...Gs(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:Xi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},er=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=Zi(e);return r.jsx(Go,{onRefresh:t,isRefreshing:s,children:o})};function tr({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=Rt(),u=Ys(),{inboxMailboxId:d}=Dn(e),h=_n(e),{data:g}=mt({...Xs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Zs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:o,translator:u}),[g?.items,h,o,u]),p=c.useMemo(()=>d||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[d,m]),S=c.useRef(!1);c.useEffect(()=>{S.current||(S.current=!0,Ln(a,t.length))},[a,t.length]);const y=c.useCallback(()=>{Pn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((b,x)=>{$n(a,{selected:b.length,total:t.length,toInbox:x===d}),s(b,x)},[a,t.length,d,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(Xo,{count:t.length,onReview:y})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(ci,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:en(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const sr=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,nr=({accountId:e,mailboxId:o})=>{const t=jt(),{pushError:s}=qt(),{requestAppointment:n}=tn(),{trashByAccount:i}=ss(),l=e?i.get(e):void 0,a=sr(e,o,l?.mailboxId,l?.source),[u,d]=c.useState({scope:a});u.scope!==a&&d({scope:a});const h=u.scope===a?u:void 0,g=c.useCallback(()=>t.getQueryData(sn())?.accounts.find(w=>w.accountId===e)?.folderAppointments.find(w=>w.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:p,isPending:S}=Mt({...cn(),meta:ln(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,j,k)=>{k.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,j,k)=>{const w=rn(x);if(!w){s({title:"Couldn't empty Trash",detail:an(x),error:x});return}k?.scope===a&&d({scope:a,refusal:w})},onSettled:(x,j,k,w)=>{m.current===w?.scope&&(m.current=void 0),nn(t,on([w?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Ht({path:{accountId:e}})})}}),y=c.useCallback(()=>e?(d({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),I=c.useCallback(()=>{y()},[y]),b=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:y})},[h,n,y]);return{emptyTrash:I,isEmptying:S&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:b}},or="We can verify this sender";function ir(e){const{data:o}=mt({...un({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(o?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:or,trustSubReason:Bn(s.senderTrust),senderTrust:s.senderTrust}))}}const rr=6e4,ar=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=mt({queryKey:Qt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:i}=await Ut({path:{mailboxId:e},query:s,throwOnError:!0});return i},enabled:t,staleTime:rr});return t?Lo(n?.count):{kind:"unknown"}},lr=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t},cr=50,ds=c.createContext(null);function pt(){const e=c.useContext(ds);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function ur({mailboxId:e,thread:o,children:t}){const s=Ye(),n=Mo(),i=Ho(),l=o?.threadId,a=o?.messageId,u=Rt(),{accounts:d,searchQuery:h,onToggleIntelligence:g,onSearchClearQuery:m}=Jt(),p=pn(),S=qo(h),y=S.length>0,{freeText:I,tokens:b}=Dt(S,p),x=Dt(h.trim(),p).freeText,[j,k]=c.useState("all"),[w,O]=c.useState(new Set),A=c.useMemo(()=>({category:j,attributes:w}),[j,w]),B=c.useMemo(()=>Wn(A),[A]),J=y||Kn(A),{params:G,residual:R}=Vn(b,B),oe={order:"desc",...I?{query:I}:{},...G,...B},F={...oe,limit:cr},P={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},Ee=J?Qt({path:{mailboxId:e},query:F}):dn({path:{mailboxId:e},query:{order:"desc"}}),{data:Se,isLoading:ye,isError:W,error:Pe,refetch:ie,fetchNextPage:M,hasNextPage:Ce,isFetchingNextPage:Oe}=So({queryKey:Ee,queryFn:async({pageParam:C})=>{if(J){const{data:$}=await Ut({path:{mailboxId:e},query:{...F,continuationToken:C},throwOnError:!0});return $}const{data:H}=await gn({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return H},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,H)=>po(H?.queryKey,P)?C:void 0}),Ie=ar({mailboxId:e,criteria:oe,enabled:Po({hasSearchQuery:y,freeText:I,residualTokenCount:R.length})}),{accountId:N,isLoading:Z}=qn(e),$e=Ro({accounts:d}),K=Hn(Qn(lr(Se?.pages.flatMap(C=>C.items??[])??[])),R,N),ke=c.useCallback(C=>{k(C)},[]),fe=c.useCallback(C=>{O(H=>{const $=new Set(H);return $.has(C)?$.delete(C):$.add(C),$})},[]),me=c.useCallback(()=>{k("all"),O(new Set)},[]),Ae=c.useCallback(()=>{me(),m()},[me,m]),re=yo({chips:A,tokens:b,reach:R.length>0?"loaded-pages":Un(F),onClear:Ae}),Be=l?K.find(C=>C.messageId===a)??K.find(C=>C.threadId===l):void 0,Ne=Jn(l,a),z=Be??Ne,_=a??z?.messageId,ne=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:z?.mailboxId??e,subject:z?.subject,messageId:_,authenticity:z?.authenticity}},[l,z,_,e]),ee=c.useCallback(C=>{_&&C.includes(_)&&n()},[_,n]),{deleteMessages:Y,isPending:Te}=_t({mailboxId:e,onAfterOptimisticRemove:ee}),{moveMessages:we,isPending:ge}=Lt({mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),V=c.useRef(null),pe=Gn(),{listCommandsRef:te,onTriageContextChange:Xe,focusedMessageId:We,selectedIds:xe}=pe,E=K.find(C=>C.messageId===We)??z,Ze=Eo({accounts:d})??null,je=Yn({thread:z,isOpen:!0,mailboxId:e,accountId:N,onAfterOptimisticRemove:ee}),{draftsMailboxId:et}=Xn(N),T=et!==void 0&&et===e,{archiveMailboxId:tt}=Zn(N),Ke=eo(),L=hn(),st=c.useMemo(()=>fn(L,l,_),[L,l,_]),ae=c.useMemo(()=>{if(E)return C=>L({threadId:E.threadId,messageId:E.messageId,mode:C})},[L,E]),be=wo(),le=mn(),ze=jo(),Me=c.useCallback(C=>C?Ke(C):[],[Ke]),{toggleStar:ce}=to({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:Ve}=Zt({mailboxId:e,accountId:N}),{junkMailboxId:q}=es(N),se=q!=null&&q===e,Fe=ts(q,e),{candidates:nt}=ir(se?q:void 0),{moveMessages:qe}=Lt({mailboxId:e,threadId:E?.threadId,accountId:N,onAfterOptimisticRemove:ee}),{deleteMessages:He}=_t({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:ee}),{addressId:ve,address:D}=so(E),{updateFlags:De}=no({addressId:ve,senderEmail:E?.fromEmail??void 0}),xt=c.useCallback(()=>ae?.("reply"),[ae]),ot=c.useCallback(()=>ae?.("reply-all"),[ae]),_e=c.useCallback(()=>ae?.("forward"),[ae]),ue=c.useCallback(()=>Me(E),[Me,E]),it=c.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const C=ue();C.length>0&&He(C)},[te,ue,He]),rt=c.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const C=ue();C.length!==0&&(oo(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?io(E):!1}),qe(C,Fe))},[te,Fe,ue,qe,u,E]),at=c.useCallback(()=>{if(xe.length>0){const C=!(E?.hasStars??!1),H=new Set(xe);for(const $ of K)H.has($.messageId)&&$.hasStars!==C&&ce($.messageId,$.hasStars);return}E&&ce(E.messageId,E.hasStars)},[xe,K,E,ce]),de=c.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const C=ue();if(C.length===0)return;const H=!(E?.isRead??!1);Ve(C,H)},[te,ue,E,Ve]),lt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.muted?.value!==!0;De({muted:{value:C}})},[ve,D,De]),bt=c.useCallback(()=>{if(!ve)return;const C=D?.flags?.vip?.value!==!0;De({vip:{value:C}})},[ve,D,De]),Qe=c.useCallback(()=>{V.current?.open()},[]),ct=T?"drafts":tt===e?"archive":q===e?"junk":"inbox",ut=c.useRef("");c.useEffect(()=>{const C=ut.current;ut.current=S,S.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:ct})},[S,ct,u]);const{goBack:Ue,nextMessageId:vt,previousMessageId:St}=ro({context:pe,orderedIds:K.map(C=>C.messageId),selectedMessageId:_,enabled:!be&&!le,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:xt,replyAll:ot,forward:_e,delete:it,toggleStar:at,toggleRead:de,muteSender:lt,blockSender:z?Qe:void 0,vipSender:bt,markJunk:rt,toggleIntelligence:z?()=>V.current?.toggle():void 0,compose:ze,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),dt=C=>{if(!C)return;const H=K.find($=>$.messageId===C);return H?{threadId:H.threadId,messageId:C}:void 0},yt={mailboxId:e,selectedMessageId:_,selectedThread:z,conversation:ne,onOpenThread:s,threads:K,isLoading:ye,isError:W,error:Pe,mailboxAccountId:N,mailboxAccountLoading:Z,mailboxName:$e,unreadCount:Ze,isDraftsMailbox:T,isSpamFolder:se,rescueCandidates:nt,filterCategory:j,filterAttributes:w,onSelectFilterCategory:ke,onToggleFilterAttribute:fe,onClearFilters:me,listFilter:re,listSearchText:x||void 0,onToggleIntelligence:g,intelligenceRef:V,handleDeselectIfRemoved:ee,searchPredicate:y&&R.length===0?F:void 0,resultCount:Ie,onDeleteMessages:Y,onMoveMessages:we,isDeleting:Te,isMoving:ge,onLoadMore:M,hasMore:Ce,isLoadingMore:Oe,onTriageContextChange:Xe,listCommandsRef:te,onRetry:()=>ie(),onReply:st,onToolbarDelete:je.deleteThread,onToolbarStar:je.toggleStar,isStarred:je.isStarred,onToolbarMove:je.moveThread,onBack:Ue,nextThread:dt(vt),previousThread:dt(St)};return r.jsx(ds.Provider,{value:yt,children:t})}function hs(){const{mailboxId:e,selectedMessageId:o,threads:t,isLoading:s,isError:n,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:p,mailboxName:S,unreadCount:y,isDraftsMailbox:I,isSpamFolder:b,rescueCandidates:x,onTriageContextChange:j,listCommandsRef:k,onRetry:w,filterCategory:O,filterAttributes:A,onSelectFilterCategory:B,onToggleFilterAttribute:J,onClearFilters:G,listFilter:R,listSearchText:oe,searchPredicate:F,resultCount:P}=pt(),{searchQuery:Ee,searchInput:Se,accounts:ye,resultFolderIndex:W}=Jt(),Pe=Vo(),ie=Ye(),M=S??"Inbox",Ce=c.useMemo(()=>ho(),[]),{trashMailboxId:Oe}=fo(p),Ie=Oo({accounts:ye}),{trashByAccount:N}=ss(),Z=nr({accountId:p,mailboxId:e}),$e=Oe!=null&&Oe===e,K=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:ke}=bn(),{state:fe,errorMessage:me,refresh:Ae}=vn(K,{onSettled:w}),re=c.useMemo(()=>r.jsx(Sn,{state:fe,onRefresh:Ae,label:`Refresh ${M}`,errorMessage:me,hasUpdate:ke(K)}),[fe,Ae,M,me,ke,K]),Be=c.useMemo(()=>t.map(V=>mo(V,W)),[t,W]),{hits:Ne,isLoading:z}=$o({mailboxId:e,filterCategory:O}),_=c.useMemo(()=>go(Ne,t.map(V=>V.threadId),W),[Ne,t,W]),ne=c.useCallback(V=>{const pe=V.threadId??t.find(te=>te.messageId===V.id)?.threadId;pe&&ie({threadId:pe,messageId:V.id},{mailboxId:V.mailboxId??e,query:Se})},[e,ie,Se,t]);if(I&&p)return r.jsx(pi,{accountId:p,selectedMessageId:o,imapThreads:t,title:S??"Drafts",unreadCount:y??void 0});const ee=r.jsx(Yi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:w,searchQuery:Ee,searchPredicate:F,resultCount:P,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:R,listSearchText:oe,listScopeLabel:M,hideHeader:!0,onTriageContextChange:j,commandsRef:k}),Y=ye[0]?.accountId,Te=Pe==="phone"&&Y?r.jsx(er,{accountId:Y,children:ee}):ee,we=b&&x.length>0&&p?r.jsx(tr,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:Te}):Te,ge=$e?r.jsx(vi,{messageCount:Ie,isEmptying:Z.isEmptying,deletedCount:Z.deletedCount,refusalReason:Z.refusal?.reason,trashFolderLabel:S??void 0,staleFolderLabel:p?N.get(p)?.staleFolderPath:void 0,onEmpty:Z.emptyTrash,onRepair:Z.repair,children:we}):we;return r.jsx(Co,{title:M,unreadCount:y,preset:Ce,selectedCategory:O,activeFilters:A,onSelectCategory:B,onToggleFilter:J,onClearFilters:G,searchResults:Be,searchLoading:s,relatedResults:_,relatedLoading:z,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:re,children:ge})}function dr(){const{mailboxId:e,mailboxAccountId:o,mailboxAccountLoading:t,selectedThread:s,conversation:n,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:u,onToolbarMove:d,handleDeselectIfRemoved:h,intelligenceRef:g}=pt(),m=!!n,p=co(n?.threadId);ns(g,p);const S=c.useRef(null),{railFits:y,openRail:I}=p;c.useEffect(()=>{if(!y)return;const x=s?.messageId??null;x&&S.current!==x&&s?.authenticity?.dkimMismatch&&(S.current=x,I())},[y,I,s?.messageId,s?.authenticity?.dkimMismatch]);const b=n?r.jsx(os,{threadId:n.threadId,mailboxId:n.mailboxId,subject:n.subject,selectedMessageId:n.messageId,authenticity:n.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(xn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(uo,{hasThread:m,messageId:n?.messageId,intelligenceOpen:p.isShowing,canToggleIntelligence:p.canToggle,onToggleIntelligence:p.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:m?l:void 0,onToggleStar:m?a:void 0,isStarred:u,moveContext:m&&o?{accountId:o,currentMailboxId:e,onMove:d}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:b})]}),r.jsx(is,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:o,onAfterOptimisticRemove:h})]})}function hr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n}=pt();return r.jsx(lo,{onClose:s,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:n})}function fr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=pt(),h=ao(s?.threadId??null);return ns(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(os,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>n(l):void 0,onSwipePrevious:a?()=>n(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(is,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:u})]}):r.jsx(hs,{})}const Lr=Object.assign(ur,{List:hs,Reading:dr,Intelligence:hr,Phone:fr});export{Lr as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as n,j as a,f as o}from"./index-
|
|
1
|
+
import{v as n,j as a,f as o}from"./index-DY92QCSR.js";import{M as e}from"./menu-Cf9AvCB4.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as le,r as t,j as e,B as L,h as de,i as te,o as ue,ax as me,c as D,aT as Q,d as U,f as C,L as G,aU as W,ay as pe,az as q,I as he,n as fe}from"./index-CTrN7dU7.js";import{C as xe}from"./checkbox-CZD6i6IR.js";import{K as ge}from"./kbd-DNmTK9ke.js";import{A as ye,c as ve,d as Se,s as V,W as R,C as _,g as je,e as K,f as be,h as Ce,a as X,S as we,b as ke,R as Ee}from"./credential-steps-C6B4LLDZ.js";import{c as Ne}from"./account-form-helpers-DhckT_PN.js";import{M as Ae}from"./mail-2Lzca0sU.js";import{F as Me}from"./file-json-lCoJ4MMG.js";const se=le("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),Te="Pick at least one. An account has to sync something.",ne=[{id:"Mail",label:"Mail",description:"Messages, folders and sending."},{id:"Calendar",label:"Calendar",description:"This account's provider calendar, read into Remit."}];function Ie({providerName:s,offered:i,selected:c,onChange:o,error:u}){const g=t.useId(),r=ne.filter(p=>i.includes(p.id)),f=u?e.jsx(L,{tone:"danger",variant:"soft",className:"mt-2 text-xs",children:u}):null;if(r.length<2)return f;const l=(p,y)=>{if(!y){o(c.filter(a=>a!==p));return}o(r.filter(a=>a.id===p||c.includes(a.id)).map(a=>a.id))};return e.jsxs("fieldset",{"aria-describedby":g,children:[e.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What should Remit sync?"}),e.jsx("div",{className:"mt-1 divide-y divide-line",children:r.map(p=>e.jsx(xe,{label:p.label,description:p.description,checked:c.includes(p.id),onChange:y=>l(p.id,y.target.checked)},p.id))}),e.jsx("p",{id:g,className:"mt-1.5 text-2xs text-fg-subtle",children:`Adding a service later means signing in with ${s} again.`}),f]})}const ae=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}},{id:"gmail",label:"Gmail",username:"full-email",imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},passwordHelp:{text:"Gmail requires an app password, not your Google password. First turn on 2-Step Verification for your Google Account, then create an app password under Security → 2-Step Verification → App passwords.",url:ye["gmail.com"]}}];function Y(s){return ae.find(i=>i.id===s)}const Pe={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail","gmail.com":"gmail","googlemail.com":"gmail"};function Re(s){const i=s.indexOf("@");if(i===-1)return"";const c=s.slice(i+1).toLowerCase();return Pe[c]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],P={connector:0,"microsoft-granted":5,address:1,servers:2,credentials:3,test:4,sync:5},J={host:"",port:993,security:"tls"},Z={host:"",port:587,security:"starttls"};function Fe({onStart:s,onImportConfig:i}){return t.useEffect(()=>{const c=o=>{o.key==="Enter"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),e.jsx(R,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:i?"Set up your first account, or bring the settings from another Reader.":"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[i?e.jsx(C,{variant:"secondary",icon:e.jsx(Me,{className:"size-4"}),onClick:i,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(ge,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:s,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(Ae,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."}),i&&e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-relaxed text-fg-muted",children:"A config file carries your accounts, folder roles, rules, flagged senders and appearance from another Reader. It never carries passwords, so you sign in again here."})]})})}function Le({onContinue:s,onMicrosoft:i,onBack:c,showBack:o}){const[u,g]=t.useState("imap");t.useEffect(()=>{const f=l=>{l.key==="Enter"&&(u==="microsoft"?i():s()),l.key==="Escape"&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,i,c,u]);const r=()=>{u==="microsoft"?i():s()};return e.jsx(R,{steps:M,activeStep:P.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[o?e.jsx(C,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:r,children:u==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(X,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(we,{className:"size-5"}),selected:u==="imap",onSelect:()=>g("imap")}),e.jsx(X,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(he,{className:"size-5"}),selected:u==="microsoft",onSelect:()=>g("microsoft")})]})})}const ee=["Mail","Calendar"];function Oe({refusal:s,onBack:i,onConnected:c}){const[o,u]=t.useState(s?.email??""),[g,r]=t.useState(s?.services??ee),[f,l]=t.useState(!1),[p,y]=t.useState(s?.message??null),[a,w]=t.useState(!1),[N,j]=t.useState(!1),h=t.useRef(!0);t.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const v=t.useRef(new Set),{refetch:b}=D(U()),k=ke(d=>{if(j(!1),d==="stalled"){w(!1),y(Ee);return}b().then(({data:S,isError:x})=>{if(!h.current)return;if(x||!S){y("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}y(null);const m=S.accounts.find(n=>!v.current.has(n.accountId));m&&c(m.accountId)})}),F=te({...fe(),onSuccess:d=>{h.current&&(k(),w(!0),window.location.assign(d.authorizationUrl))},onError:d=>{j(!1),y(d instanceof Error?d.message:"Failed to start sign-in")}}),T=N||F.isPending,A=()=>{if(!T){if(g.length===0){l(!0);return}y(null),j(!0),b().then(({data:d,isError:S})=>{if(h.current){if(S||!d){j(!1),y("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}v.current=new Set(d.accounts.map(x=>x.accountId)),F.mutate({body:{email:o.trim()||void 0,services:g}})}})}},I=t.useRef(A);return I.current=A,t.useEffect(()=>{const d=S=>{S.key==="Enter"&&I.current(),S.key==="Escape"&&i()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),e.jsx(R,{steps:M,activeStep:P.connector,title:s?.reconnect&&s.email?`Reconnect ${s.email}`:"Sign in with Microsoft",subtitle:"Microsoft is asked for the mail and calendar access you pick here.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:i,children:"Back"}),e.jsx(C,{variant:"primary",onClick:A,disabled:T,icon:T?e.jsx(G,{className:"size-4 animate-spin"}):void 0,children:T?"Redirecting…":a?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ie,{providerName:"Microsoft",offered:ee,selected:g,onChange:d=>{r(d),d.length>0&&l(!1)},error:f?Te:void 0}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(q,{id:"microsoft-email",icon:e.jsx(se,{className:"size-4"}),placeholder:"you@outlook.com",value:o,onChange:d=>u(d.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),a&&e.jsx(L,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),p&&e.jsx(L,{tone:"danger",children:p})]})})}function _e({accountId:s,onSignInAgain:i,onContinue:c}){const{data:o,isError:u,isFetching:g,refetch:r}=D(U()),f=o?.accounts.find(l=>l.accountId===s);return u?e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"Couldn't read the new account",subtitle:"Microsoft finished, but this instance did not answer.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{r()},disabled:g,children:"Retry"})]}),children:e.jsx(L,{tone:"danger",children:"Couldn't load the account Microsoft just connected. Check your connection and retry, or open Settings › Accounts to see it."})}):!o||!f&&g?e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"Reading the new account",subtitle:"Checking what Microsoft granted.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Loading…"}),e.jsx("span",{})]}),children:e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(G,{className:"size-4 animate-spin text-accent"}),"Loading the account…"]})}):f?e.jsx(Ge,{account:f,onContinue:c}):e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"The account is not here",subtitle:"Microsoft sent the sign-in back, but no account was kept.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:i,children:"Sign in again"})]}),children:e.jsx(L,{tone:"danger",children:"This instance holds no account from that sign-in. Sign in with Microsoft again to connect it."})})}function Ge({account:s,onContinue:i}){const c=s.syncedServices.includes("Mail");return e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:`Connected ${s.email}`,subtitle:"Microsoft granted access to what you picked.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Change this later in Settings › Accounts"}),e.jsx(C,{variant:"primary",onClick:()=>i(s.accountId),children:c?"Go to inbox":"Continue"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"divide-y divide-line",children:ne.map(o=>s.syncedServices.includes(o.id)?e.jsx(_,{label:o.label,detail:"Access granted — syncing",state:"ok"},o.id):e.jsx(_,{label:o.label,detail:"Not synced. Turn it on in Settings › Accounts; Microsoft asks for access then.",state:"pending"},o.id))}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Permissions Microsoft granted"}),e.jsx("code",{className:"mt-1 block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted","data-testid":"granted-scopes",children:s.grantedScopes.join(" ")})]})]})})}function He({initialEmail:s,initialDisplayName:i,onContinue:c,onBack:o}){const[u,g]=t.useState(s),[r,f]=t.useState(i),[l,p]=t.useState(!1),[y,a]=t.useState(""),[w,N]=t.useState(null),j=t.useCallback(async()=>{const h=u.trim();if(!h.includes("@")||!h.includes(".")){N("Enter a valid email address.");return}N(null),p(!0),a(be(h));try{const v=await Ce(h);c(h,r.trim(),v)}finally{p(!1)}},[u,r,c]);return t.useEffect(()=>{const h=v=>{v.key==="Enter"&&!l&&j(),v.key==="Escape"&&o()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[j,l,o]),e.jsx(R,{steps:M,activeStep:P.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(C,{variant:"primary",disabled:l,onClick:()=>{j()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(W,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(q,{id:"onboarding-email",icon:e.jsx(se,{className:"size-4"}),placeholder:"you@example.com",value:u,onChange:h=>{g(h.target.value),N(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(q,{id:"onboarding-display-name",placeholder:"Alice",value:r,onChange:h=>f(h.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),l&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(G,{className:"size-3.5 animate-spin text-accent"}),y]}),w&&!l&&e.jsx("div",{className:"mt-3",children:e.jsx(L,{tone:"danger",children:w})})]})})}function ze({email:s,imapConfig:i,smtpConfig:c,discovered:o,onContinue:u,onBack:g,onChange:r}){const[f,l]=t.useState(i),[p,y]=t.useState(c),[a,w]=t.useState(()=>Re(s)),[N,j]=t.useState(!1),[h,v]=t.useState(null),b=Y(a),k=b!==void 0&&!N,F=t.useCallback(m=>{w(m),j(!1),v(null);const n=Y(m);n&&(l({host:n.imap.host,port:n.imap.port,security:n.imap.security}),y({host:n.smtp.host,port:n.smtp.port,security:n.smtp.security}))},[]);t.useEffect(()=>{r(f,p)},[f,p,r]);const T=f.host.trim()!=="",A=t.useCallback(()=>{if(!T){v("Enter the IMAP host.");return}v(null),u()},[T,u]);t.useEffect(()=>{const m=n=>{n.key==="Enter"&&A(),n.key==="Escape"&&g()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[A,g]);const I=s.split("@")[1]??"your domain",d=b?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":o?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${I} — enter them manually.`,S=k?{label:"preset",tone:"neutral"}:!b&&o?{label:"detected",tone:"positive"}:void 0,x=b?.passwordHelp.url??je(s);return e.jsx(R,{steps:M,activeStep:P.servers,title:"Confirm server settings",subtitle:d,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:g,children:"Back"}),e.jsx(C,{variant:"primary",onClick:A,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[h&&e.jsx(L,{tone:"danger",children:h}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(pe,{id:"provider-select",value:a,onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ae.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),b&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:k?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",b.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>j(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",b.label,"'s settings by hand."]})})]}),e.jsx(K,{legend:"IMAP — incoming",badge:S,readOnly:k,host:f.host,port:String(f.port),security:f.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{l(n=>({...n,host:m})),v(null)},onPortChange:m=>l(n=>({...n,port:Number(m)})),onSecurityChange:m=>l(n=>({...n,security:m}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(K,{legend:"SMTP — outgoing (optional)",badge:S,readOnly:k,host:p.host,port:String(p.port),security:p.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{y(n=>({...n,host:m})),v(null)},onPortChange:m=>y(n=>({...n,port:Number(m)})),onSecurityChange:m=>y(n=>({...n,security:m}))}),b&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[b.passwordHelp.text," ",x&&e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Be=2e4;function De({email:s,displayName:i,imapConfig:c,smtpConfig:o,username:u,password:g,onGoToInbox:r}){const f=de(),[l,p]=t.useState(null),[y,a]=t.useState(null),w=t.useRef(!1),N=V(c.security),j=V(o.security),h=te({...me(),onSuccess:E=>{p(E.accountId),f.invalidateQueries({queryKey:ue()})},onError:E=>{a(E instanceof Error?E.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const E=o.host.trim()!=="",z=Ne({imapHost:c.host,smtpHost:o.host,smtpPort:o.port}),B=E?z??{smtpHost:o.host,smtpPort:o.port,smtpTls:j.tls,smtpStartTls:j.startTls}:null;h.mutate({body:{email:s,displayName:i||void 0,username:u!==s?u:void 0,password:g,imapHost:c.host,imapPort:c.port,imapTls:N.tls,imapStartTls:N.startTls,smtpHost:B?.smtpHost||void 0,smtpPort:B?.smtpPort||void 0,smtpTls:B?.smtpTls??!1,smtpStartTls:B?.smtpStartTls??!1}})},[]);const{data:v,isError:b}=D({...Q({path:{accountId:l??""}}),enabled:!!l,refetchInterval:E=>{const z=E.state.data?.syncPhase;return z==="complete"||z==="error"?!1:2e3}}),k=v?.syncPhase==="error",{data:F}=D({...U(),enabled:!!l&&k}),T=F?.accounts.find(E=>E.accountId===l)?.lastError,A=v?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),I=v?.mailboxCountTotal??0,d=v?.mailboxCountSynced??0,S=A?.messagesTotal??0,x=A?.messagesSynced??0,m=S>0?x/S:0,n=v?.syncPhase,H=k?"failed":n==="idle"||n===void 0||n==="discovering_mailboxes"?"running":I>0?"ok":"running",O=k?"failed":!n||n==="idle"||n==="discovering_mailboxes"?"pending":n==="syncing_inbox"||n==="syncing_others"?"running":"ok",$=k?"failed":!n||n==="idle"||n==="discovering_mailboxes"||n==="syncing_inbox"?"pending":n==="syncing_others"?"running":"ok",ie=x>0||A?.phase==="complete"||n==="complete"||k,[oe,re]=t.useState(!1);t.useEffect(()=>{if(!l)return;const E=setTimeout(()=>re(!0),Be);return()=>clearTimeout(E)},[l]);const ce=!!l&&(ie||b||oe);return y?e.jsx(R,{steps:M,activeStep:P.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{w.current=!1,a(null),h.mutate({body:{email:s,displayName:i||void 0,username:u!==s?u:void 0,password:g,imapHost:c.host,imapPort:c.port,imapTls:N.tls,imapStartTls:N.startTls,smtpHost:o.host||void 0,smtpPort:o.port||void 0,smtpTls:j.tls,smtpStartTls:j.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:y})}):e.jsx(R,{steps:M,activeStep:P.sync,title:`Syncing ${s}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),ce?e.jsx(C,{variant:"primary",onClick:()=>l&&r(l),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx(G,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:h.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(G,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[S>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[x.toLocaleString()," / ",S.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,m*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:I>0?`${I} mailbox${I===1?"":"es"} found`:"Discovering…",state:H}),e.jsx(_,{label:"INBOX",detail:O==="ok"?`${x.toLocaleString()} messages synced`:O==="running"?"Syncing newest first…":"Queued",state:O}),d>1||n==="syncing_others"||n==="complete"?e.jsx(_,{label:"Other mailboxes",detail:$==="ok"?`${d-1} mailboxes synced`:$==="running"?"Syncing…":"Queued",state:$}):null]}),k&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{f.invalidateQueries({queryKey:Q({path:{accountId:l??""}}).queryKey})},children:"retry"})]}),T&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:T})]})]})})}const We=(s,i)=>i?.kind==="connected"?"microsoft-granted":i?.kind==="refused"?"microsoft-email":s?"connector":"welcome";function Ye({skipWelcome:s=!1,onComplete:i,onCancel:c,onImportConfig:o,microsoftReturn:u}){const[g,r]=t.useState(We(s,u)),[f,l]=t.useState(u?.kind==="refused"?u:void 0),[p,y]=t.useState(u?.kind==="connected"?u.accountId:null),[a,w]=t.useState({email:"",displayName:"",imapConfig:J,smtpConfig:Z,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),N=t.useCallback(()=>r("connector"),[]),j=t.useCallback(()=>r("address"),[]),h=t.useCallback(()=>r("microsoft-email"),[]),v=t.useCallback(()=>{s?c?.():r("welcome")},[s,c]),b=t.useCallback((d,S,x)=>{let m=J,n=Z,H=!1;x&&(H=x.source!=="heuristic",m={host:x.imap.host,port:x.imap.port,security:x.imap.security},n={host:x.smtp.host,port:x.smtp.port,security:x.smtp.security}),w(O=>({...O,email:d,displayName:S,imapConfig:m,smtpConfig:n,discoveryResult:x,discovered:H,username:d})),r("servers")},[]),k=t.useCallback((d,S)=>{w(x=>({...x,imapConfig:d,smtpConfig:S}))},[]),F=t.useCallback((d,S)=>{w(x=>({...x,username:d,password:S}))},[]),T=t.useCallback(()=>r("sync"),[]),A=t.useCallback(d=>{i(d)},[i]),I=e.jsx(Oe,{refusal:f,onBack:()=>{l(void 0),r("connector")},onConnected:d=>{y(d),r("microsoft-granted")}});switch(g){case"welcome":return e.jsx(Fe,{onStart:N,onImportConfig:o});case"connector":return e.jsx(Le,{onContinue:j,onMicrosoft:h,onBack:v,showBack:!s});case"microsoft-email":return I;case"microsoft-granted":return p===null?I:e.jsx(_e,{accountId:p,onSignInAgain:()=>r("microsoft-email"),onContinue:A});case"address":return e.jsx(He,{initialEmail:a.email,initialDisplayName:a.displayName,onContinue:b,onBack:()=>r("connector")});case"servers":return e.jsx(ze,{email:a.email,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,discovered:a.discovered,onContinue:()=>r("credentials"),onBack:()=>r("address"),onChange:k});case"credentials":return e.jsx(Se,{steps:M,activeStep:P.credentials,title:`Sign in to ${a.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:a.email,username:a.username,password:a.password,onContinue:()=>r("test"),onBack:()=>r("servers"),onChange:F});case"test":return e.jsx(ve,{steps:M,activeStep:P.test,email:a.email,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,username:a.username,password:a.password,onSuccess:T,onBackToCredentials:()=>r("credentials"),onBackToServers:()=>r("servers")});case"sync":return e.jsx(De,{email:a.email,displayName:a.displayName,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,username:a.username,password:a.password,onGoToInbox:A})}}export{ne as A,Ye as O,ae as P,Y as g};
|
|
1
|
+
import{e as le,r as t,j as e,B as L,h as de,i as te,o as ue,ax as me,c as D,aT as Q,d as U,f as C,L as G,aU as W,ay as pe,az as q,I as he,n as fe}from"./index-DY92QCSR.js";import{C as xe}from"./checkbox-DXK6Mpxl.js";import{K as ge}from"./kbd-IshtYac4.js";import{A as ye,c as ve,d as Se,s as V,W as R,C as _,g as je,e as K,f as be,h as Ce,a as X,S as we,b as ke,R as Ee}from"./credential-steps-D7oNgulr.js";import{c as Ne}from"./account-form-helpers-DhckT_PN.js";import{M as Ae}from"./mail-D9saRn9q.js";import{F as Me}from"./file-json-Dv1oCxjP.js";const se=le("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),Te="Pick at least one. An account has to sync something.",ne=[{id:"Mail",label:"Mail",description:"Messages, folders and sending."},{id:"Calendar",label:"Calendar",description:"This account's provider calendar, read into Remit."}];function Ie({providerName:s,offered:i,selected:c,onChange:o,error:u}){const g=t.useId(),r=ne.filter(p=>i.includes(p.id)),f=u?e.jsx(L,{tone:"danger",variant:"soft",className:"mt-2 text-xs",children:u}):null;if(r.length<2)return f;const l=(p,y)=>{if(!y){o(c.filter(a=>a!==p));return}o(r.filter(a=>a.id===p||c.includes(a.id)).map(a=>a.id))};return e.jsxs("fieldset",{"aria-describedby":g,children:[e.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What should Remit sync?"}),e.jsx("div",{className:"mt-1 divide-y divide-line",children:r.map(p=>e.jsx(xe,{label:p.label,description:p.description,checked:c.includes(p.id),onChange:y=>l(p.id,y.target.checked)},p.id))}),e.jsx("p",{id:g,className:"mt-1.5 text-2xs text-fg-subtle",children:`Adding a service later means signing in with ${s} again.`}),f]})}const ae=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}},{id:"gmail",label:"Gmail",username:"full-email",imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},passwordHelp:{text:"Gmail requires an app password, not your Google password. First turn on 2-Step Verification for your Google Account, then create an app password under Security → 2-Step Verification → App passwords.",url:ye["gmail.com"]}}];function Y(s){return ae.find(i=>i.id===s)}const Pe={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail","gmail.com":"gmail","googlemail.com":"gmail"};function Re(s){const i=s.indexOf("@");if(i===-1)return"";const c=s.slice(i+1).toLowerCase();return Pe[c]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],P={connector:0,"microsoft-granted":5,address:1,servers:2,credentials:3,test:4,sync:5},J={host:"",port:993,security:"tls"},Z={host:"",port:587,security:"starttls"};function Fe({onStart:s,onImportConfig:i}){return t.useEffect(()=>{const c=o=>{o.key==="Enter"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),e.jsx(R,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:i?"Set up your first account, or bring the settings from another Reader.":"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[i?e.jsx(C,{variant:"secondary",icon:e.jsx(Me,{className:"size-4"}),onClick:i,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(ge,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:s,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(Ae,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."}),i&&e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-relaxed text-fg-muted",children:"A config file carries your accounts, folder roles, rules, flagged senders and appearance from another Reader. It never carries passwords, so you sign in again here."})]})})}function Le({onContinue:s,onMicrosoft:i,onBack:c,showBack:o}){const[u,g]=t.useState("imap");t.useEffect(()=>{const f=l=>{l.key==="Enter"&&(u==="microsoft"?i():s()),l.key==="Escape"&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,i,c,u]);const r=()=>{u==="microsoft"?i():s()};return e.jsx(R,{steps:M,activeStep:P.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[o?e.jsx(C,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:r,children:u==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(X,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(we,{className:"size-5"}),selected:u==="imap",onSelect:()=>g("imap")}),e.jsx(X,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(he,{className:"size-5"}),selected:u==="microsoft",onSelect:()=>g("microsoft")})]})})}const ee=["Mail","Calendar"];function Oe({refusal:s,onBack:i,onConnected:c}){const[o,u]=t.useState(s?.email??""),[g,r]=t.useState(s?.services??ee),[f,l]=t.useState(!1),[p,y]=t.useState(s?.message??null),[a,w]=t.useState(!1),[N,j]=t.useState(!1),h=t.useRef(!0);t.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const v=t.useRef(new Set),{refetch:b}=D(U()),k=ke(d=>{if(j(!1),d==="stalled"){w(!1),y(Ee);return}b().then(({data:S,isError:x})=>{if(!h.current)return;if(x||!S){y("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}y(null);const m=S.accounts.find(n=>!v.current.has(n.accountId));m&&c(m.accountId)})}),F=te({...fe(),onSuccess:d=>{h.current&&(k(),w(!0),window.location.assign(d.authorizationUrl))},onError:d=>{j(!1),y(d instanceof Error?d.message:"Failed to start sign-in")}}),T=N||F.isPending,A=()=>{if(!T){if(g.length===0){l(!0);return}y(null),j(!0),b().then(({data:d,isError:S})=>{if(h.current){if(S||!d){j(!1),y("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}v.current=new Set(d.accounts.map(x=>x.accountId)),F.mutate({body:{email:o.trim()||void 0,services:g}})}})}},I=t.useRef(A);return I.current=A,t.useEffect(()=>{const d=S=>{S.key==="Enter"&&I.current(),S.key==="Escape"&&i()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),e.jsx(R,{steps:M,activeStep:P.connector,title:s?.reconnect&&s.email?`Reconnect ${s.email}`:"Sign in with Microsoft",subtitle:"Microsoft is asked for the mail and calendar access you pick here.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:i,children:"Back"}),e.jsx(C,{variant:"primary",onClick:A,disabled:T,icon:T?e.jsx(G,{className:"size-4 animate-spin"}):void 0,children:T?"Redirecting…":a?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ie,{providerName:"Microsoft",offered:ee,selected:g,onChange:d=>{r(d),d.length>0&&l(!1)},error:f?Te:void 0}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(q,{id:"microsoft-email",icon:e.jsx(se,{className:"size-4"}),placeholder:"you@outlook.com",value:o,onChange:d=>u(d.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),a&&e.jsx(L,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),p&&e.jsx(L,{tone:"danger",children:p})]})})}function _e({accountId:s,onSignInAgain:i,onContinue:c}){const{data:o,isError:u,isFetching:g,refetch:r}=D(U()),f=o?.accounts.find(l=>l.accountId===s);return u?e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"Couldn't read the new account",subtitle:"Microsoft finished, but this instance did not answer.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{r()},disabled:g,children:"Retry"})]}),children:e.jsx(L,{tone:"danger",children:"Couldn't load the account Microsoft just connected. Check your connection and retry, or open Settings › Accounts to see it."})}):!o||!f&&g?e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"Reading the new account",subtitle:"Checking what Microsoft granted.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Loading…"}),e.jsx("span",{})]}),children:e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(G,{className:"size-4 animate-spin text-accent"}),"Loading the account…"]})}):f?e.jsx(Ge,{account:f,onContinue:c}):e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"The account is not here",subtitle:"Microsoft sent the sign-in back, but no account was kept.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:i,children:"Sign in again"})]}),children:e.jsx(L,{tone:"danger",children:"This instance holds no account from that sign-in. Sign in with Microsoft again to connect it."})})}function Ge({account:s,onContinue:i}){const c=s.syncedServices.includes("Mail");return e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:`Connected ${s.email}`,subtitle:"Microsoft granted access to what you picked.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Change this later in Settings › Accounts"}),e.jsx(C,{variant:"primary",onClick:()=>i(s.accountId),children:c?"Go to inbox":"Continue"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"divide-y divide-line",children:ne.map(o=>s.syncedServices.includes(o.id)?e.jsx(_,{label:o.label,detail:"Access granted — syncing",state:"ok"},o.id):e.jsx(_,{label:o.label,detail:"Not synced. Turn it on in Settings › Accounts; Microsoft asks for access then.",state:"pending"},o.id))}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Permissions Microsoft granted"}),e.jsx("code",{className:"mt-1 block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted","data-testid":"granted-scopes",children:s.grantedScopes.join(" ")})]})]})})}function He({initialEmail:s,initialDisplayName:i,onContinue:c,onBack:o}){const[u,g]=t.useState(s),[r,f]=t.useState(i),[l,p]=t.useState(!1),[y,a]=t.useState(""),[w,N]=t.useState(null),j=t.useCallback(async()=>{const h=u.trim();if(!h.includes("@")||!h.includes(".")){N("Enter a valid email address.");return}N(null),p(!0),a(be(h));try{const v=await Ce(h);c(h,r.trim(),v)}finally{p(!1)}},[u,r,c]);return t.useEffect(()=>{const h=v=>{v.key==="Enter"&&!l&&j(),v.key==="Escape"&&o()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[j,l,o]),e.jsx(R,{steps:M,activeStep:P.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(C,{variant:"primary",disabled:l,onClick:()=>{j()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(W,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(q,{id:"onboarding-email",icon:e.jsx(se,{className:"size-4"}),placeholder:"you@example.com",value:u,onChange:h=>{g(h.target.value),N(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(q,{id:"onboarding-display-name",placeholder:"Alice",value:r,onChange:h=>f(h.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),l&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(G,{className:"size-3.5 animate-spin text-accent"}),y]}),w&&!l&&e.jsx("div",{className:"mt-3",children:e.jsx(L,{tone:"danger",children:w})})]})})}function ze({email:s,imapConfig:i,smtpConfig:c,discovered:o,onContinue:u,onBack:g,onChange:r}){const[f,l]=t.useState(i),[p,y]=t.useState(c),[a,w]=t.useState(()=>Re(s)),[N,j]=t.useState(!1),[h,v]=t.useState(null),b=Y(a),k=b!==void 0&&!N,F=t.useCallback(m=>{w(m),j(!1),v(null);const n=Y(m);n&&(l({host:n.imap.host,port:n.imap.port,security:n.imap.security}),y({host:n.smtp.host,port:n.smtp.port,security:n.smtp.security}))},[]);t.useEffect(()=>{r(f,p)},[f,p,r]);const T=f.host.trim()!=="",A=t.useCallback(()=>{if(!T){v("Enter the IMAP host.");return}v(null),u()},[T,u]);t.useEffect(()=>{const m=n=>{n.key==="Enter"&&A(),n.key==="Escape"&&g()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[A,g]);const I=s.split("@")[1]??"your domain",d=b?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":o?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${I} — enter them manually.`,S=k?{label:"preset",tone:"neutral"}:!b&&o?{label:"detected",tone:"positive"}:void 0,x=b?.passwordHelp.url??je(s);return e.jsx(R,{steps:M,activeStep:P.servers,title:"Confirm server settings",subtitle:d,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:g,children:"Back"}),e.jsx(C,{variant:"primary",onClick:A,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[h&&e.jsx(L,{tone:"danger",children:h}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(pe,{id:"provider-select",value:a,onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ae.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),b&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:k?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",b.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>j(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",b.label,"'s settings by hand."]})})]}),e.jsx(K,{legend:"IMAP — incoming",badge:S,readOnly:k,host:f.host,port:String(f.port),security:f.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{l(n=>({...n,host:m})),v(null)},onPortChange:m=>l(n=>({...n,port:Number(m)})),onSecurityChange:m=>l(n=>({...n,security:m}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(K,{legend:"SMTP — outgoing (optional)",badge:S,readOnly:k,host:p.host,port:String(p.port),security:p.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{y(n=>({...n,host:m})),v(null)},onPortChange:m=>y(n=>({...n,port:Number(m)})),onSecurityChange:m=>y(n=>({...n,security:m}))}),b&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[b.passwordHelp.text," ",x&&e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Be=2e4;function De({email:s,displayName:i,imapConfig:c,smtpConfig:o,username:u,password:g,onGoToInbox:r}){const f=de(),[l,p]=t.useState(null),[y,a]=t.useState(null),w=t.useRef(!1),N=V(c.security),j=V(o.security),h=te({...me(),onSuccess:E=>{p(E.accountId),f.invalidateQueries({queryKey:ue()})},onError:E=>{a(E instanceof Error?E.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const E=o.host.trim()!=="",z=Ne({imapHost:c.host,smtpHost:o.host,smtpPort:o.port}),B=E?z??{smtpHost:o.host,smtpPort:o.port,smtpTls:j.tls,smtpStartTls:j.startTls}:null;h.mutate({body:{email:s,displayName:i||void 0,username:u!==s?u:void 0,password:g,imapHost:c.host,imapPort:c.port,imapTls:N.tls,imapStartTls:N.startTls,smtpHost:B?.smtpHost||void 0,smtpPort:B?.smtpPort||void 0,smtpTls:B?.smtpTls??!1,smtpStartTls:B?.smtpStartTls??!1}})},[]);const{data:v,isError:b}=D({...Q({path:{accountId:l??""}}),enabled:!!l,refetchInterval:E=>{const z=E.state.data?.syncPhase;return z==="complete"||z==="error"?!1:2e3}}),k=v?.syncPhase==="error",{data:F}=D({...U(),enabled:!!l&&k}),T=F?.accounts.find(E=>E.accountId===l)?.lastError,A=v?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),I=v?.mailboxCountTotal??0,d=v?.mailboxCountSynced??0,S=A?.messagesTotal??0,x=A?.messagesSynced??0,m=S>0?x/S:0,n=v?.syncPhase,H=k?"failed":n==="idle"||n===void 0||n==="discovering_mailboxes"?"running":I>0?"ok":"running",O=k?"failed":!n||n==="idle"||n==="discovering_mailboxes"?"pending":n==="syncing_inbox"||n==="syncing_others"?"running":"ok",$=k?"failed":!n||n==="idle"||n==="discovering_mailboxes"||n==="syncing_inbox"?"pending":n==="syncing_others"?"running":"ok",ie=x>0||A?.phase==="complete"||n==="complete"||k,[oe,re]=t.useState(!1);t.useEffect(()=>{if(!l)return;const E=setTimeout(()=>re(!0),Be);return()=>clearTimeout(E)},[l]);const ce=!!l&&(ie||b||oe);return y?e.jsx(R,{steps:M,activeStep:P.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{w.current=!1,a(null),h.mutate({body:{email:s,displayName:i||void 0,username:u!==s?u:void 0,password:g,imapHost:c.host,imapPort:c.port,imapTls:N.tls,imapStartTls:N.startTls,smtpHost:o.host||void 0,smtpPort:o.port||void 0,smtpTls:j.tls,smtpStartTls:j.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:y})}):e.jsx(R,{steps:M,activeStep:P.sync,title:`Syncing ${s}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),ce?e.jsx(C,{variant:"primary",onClick:()=>l&&r(l),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx(G,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:h.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(G,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[S>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[x.toLocaleString()," / ",S.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,m*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:I>0?`${I} mailbox${I===1?"":"es"} found`:"Discovering…",state:H}),e.jsx(_,{label:"INBOX",detail:O==="ok"?`${x.toLocaleString()} messages synced`:O==="running"?"Syncing newest first…":"Queued",state:O}),d>1||n==="syncing_others"||n==="complete"?e.jsx(_,{label:"Other mailboxes",detail:$==="ok"?`${d-1} mailboxes synced`:$==="running"?"Syncing…":"Queued",state:$}):null]}),k&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{f.invalidateQueries({queryKey:Q({path:{accountId:l??""}}).queryKey})},children:"retry"})]}),T&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:T})]})]})})}const We=(s,i)=>i?.kind==="connected"?"microsoft-granted":i?.kind==="refused"?"microsoft-email":s?"connector":"welcome";function Ye({skipWelcome:s=!1,onComplete:i,onCancel:c,onImportConfig:o,microsoftReturn:u}){const[g,r]=t.useState(We(s,u)),[f,l]=t.useState(u?.kind==="refused"?u:void 0),[p,y]=t.useState(u?.kind==="connected"?u.accountId:null),[a,w]=t.useState({email:"",displayName:"",imapConfig:J,smtpConfig:Z,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),N=t.useCallback(()=>r("connector"),[]),j=t.useCallback(()=>r("address"),[]),h=t.useCallback(()=>r("microsoft-email"),[]),v=t.useCallback(()=>{s?c?.():r("welcome")},[s,c]),b=t.useCallback((d,S,x)=>{let m=J,n=Z,H=!1;x&&(H=x.source!=="heuristic",m={host:x.imap.host,port:x.imap.port,security:x.imap.security},n={host:x.smtp.host,port:x.smtp.port,security:x.smtp.security}),w(O=>({...O,email:d,displayName:S,imapConfig:m,smtpConfig:n,discoveryResult:x,discovered:H,username:d})),r("servers")},[]),k=t.useCallback((d,S)=>{w(x=>({...x,imapConfig:d,smtpConfig:S}))},[]),F=t.useCallback((d,S)=>{w(x=>({...x,username:d,password:S}))},[]),T=t.useCallback(()=>r("sync"),[]),A=t.useCallback(d=>{i(d)},[i]),I=e.jsx(Oe,{refusal:f,onBack:()=>{l(void 0),r("connector")},onConnected:d=>{y(d),r("microsoft-granted")}});switch(g){case"welcome":return e.jsx(Fe,{onStart:N,onImportConfig:o});case"connector":return e.jsx(Le,{onContinue:j,onMicrosoft:h,onBack:v,showBack:!s});case"microsoft-email":return I;case"microsoft-granted":return p===null?I:e.jsx(_e,{accountId:p,onSignInAgain:()=>r("microsoft-email"),onContinue:A});case"address":return e.jsx(He,{initialEmail:a.email,initialDisplayName:a.displayName,onContinue:b,onBack:()=>r("connector")});case"servers":return e.jsx(ze,{email:a.email,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,discovered:a.discovered,onContinue:()=>r("credentials"),onBack:()=>r("address"),onChange:k});case"credentials":return e.jsx(Se,{steps:M,activeStep:P.credentials,title:`Sign in to ${a.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:a.email,username:a.username,password:a.password,onContinue:()=>r("test"),onBack:()=>r("servers"),onChange:F});case"test":return e.jsx(ve,{steps:M,activeStep:P.test,email:a.email,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,username:a.username,password:a.password,onSuccess:T,onBackToCredentials:()=>r("credentials"),onBackToServers:()=>r("servers")});case"sync":return e.jsx(De,{email:a.email,displayName:a.displayName,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,username:a.username,password:a.password,onGoToInbox:A})}}export{ne as A,Ye as O,ae as P,Y as g};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as pe,j as t,t as k,f as W,a3 as ge,X as ve,c as F,eV as le,s as V,r as E,eD as ee,b5 as Z,Y as be,a0 as Ne,an as P,ab as je}from"./index-
|
|
1
|
+
import{e as pe,j as t,t as k,f as W,a3 as ge,X as ve,c as F,eV as le,s as V,r as E,eD as ee,b5 as Z,Y as be,a0 as Ne,an as P,ab as je}from"./index-DY92QCSR.js";import{u as ke,e as we,m as ye,t as Ce,C as Se,d as Ee,p as Te}from"./CalendarComposePane-D0Vp2Itu.js";import{c as Ie,R as De,F as ce,u as Oe,n as Re}from"./calendar-format-DbZ5N68a.js";import{R as Fe,A as Ae}from"./attendee-row-CBVkVyxg.js";import{C as ze}from"./clock-C07X5jyq.js";import{G as te,M as Le,a as $e}from"./calendar-report-BKdPffg-.js";import{M as Me}from"./mail-D9saRn9q.js";import{P as Pe}from"./pencil-Cr3cD7Ro.js";import{f as We,d as de,j as se,u as Ze,c as _e,s as Ue,U as ne,h as Ve}from"./useCalendars-CwM5mJht.js";import{a as qe}from"./useCalendarWrites-CnQvO4W7.js";import{b as Be}from"./useCalendarData-BSAZPZ0B.js";import{a as Ge}from"./calendar-subscription-B-aAc2Gy.js";const He=pe("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);function S({icon:e,children:s}){return t.jsxs("div",{className:"flex items-start gap-2.5 py-1",children:[t.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle",children:e}),t.jsx("div",{className:"min-w-0 flex-1 text-sm text-fg",children:s})]})}function Ye({event:e,calendar:s,whenText:r,onEdit:n,onDelete:i,onOpenThread:l,onClose:d,activeAttendee:c="",onActivateAttendee:u,renderAttendeeContext:p,touch:x=!1,chrome:f="header",className:v}){const N=Ie(s.color),a=t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"text-xl font-semibold text-fg",children:e.title}),t.jsxs("div",{className:"mt-3 flex flex-col border-b border-line pb-3",children:[t.jsx(S,{icon:t.jsx(ze,{className:"size-4"}),children:t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[r,e.attendees.length>0&&t.jsx(Fe,{rsvp:e.myRsvp})]})}),e.zoneCertainty==="ambiguous"?t.jsx(S,{icon:t.jsx(te,{className:"size-4 text-warning"}),children:t.jsx("span",{className:"text-warning",children:"The mail said a time but never a zone. Shown in your own; confirm before you travel for it."})}):e.timeZone!==""&&t.jsx(S,{icon:t.jsx(te,{className:"size-4"}),children:e.timeZone}),e.recurrenceRule!==""&&t.jsx(S,{icon:t.jsx(De,{className:"size-4"}),children:t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.recurrenceRule,e.seriesException&&t.jsx("span",{className:"rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning",children:"Moved out of the series"})]})}),e.location!==""&&t.jsx(S,{icon:t.jsx(Le,{className:"size-4"}),children:e.location})]}),e.threadId!==""&&l&&t.jsxs("button",{type:"button",onClick:l,className:"mt-3 flex w-full items-center gap-2.5 rounded-md border border-line bg-surface-sunken px-3 py-2 text-left outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx(Me,{className:"size-4 shrink-0 text-accent-2"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:"From this thread"}),t.jsx("span",{className:"block truncate text-sm text-fg",children:e.threadSubject})]})]}),e.attendees.length>0&&t.jsx(Ae,{attendees:e.attendees,activeEmail:c,onActivate:u,renderContext:p,touch:x,className:"mt-3"}),e.notes!==""&&t.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-fg-muted",children:e.notes})]});return f==="bare"?t.jsx("div",{className:k("flex flex-col",v),children:a}):t.jsxs("article",{className:k("flex h-full w-full flex-col bg-surface",v),children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[t.jsx("span",{className:k("size-2.5 shrink-0 rounded-full",N.solid)}),t.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:[s.name," · ",s.accountLabel]}),n&&t.jsx(W,{variant:"ghost",size:"sm",icon:t.jsx(Pe,{className:"size-3.5"}),onClick:n,children:"Edit"}),i&&t.jsx(W,{variant:"ghost",size:"sm",icon:t.jsx(ge,{className:"size-3.5"}),onClick:i,className:"text-danger",children:"Delete"}),d&&t.jsx("button",{type:"button","aria-label":"Close event",onClick:d,className:"flex size-7 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(ve,{className:"size-4"})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-3",children:a})]})}const Je=[{scope:"this",label:"This event",note:"Leaves the rest of the series alone"},{scope:"following",label:"This and everything after",note:"Splits the series here"},{scope:"all",label:"The whole series",note:"Rewrites the rule itself"}];function Ke({title:e,ruleText:s,instanceText:r,onChoose:n,onCancel:i,touch:l,className:d}){return t.jsxs("div",{className:k("flex flex-col gap-3",d),children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-md font-semibold text-fg",children:[e," repeats"]}),t.jsx("p",{className:"text-xs text-fg-muted",children:s}),t.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",r,"."]})]}),t.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),t.jsx("div",{className:"flex flex-col gap-1.5",children:Je.map(c=>t.jsxs("button",{type:"button",onClick:()=>n(c.scope),className:k("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",l&&"min-h-11 justify-center"),children:[t.jsx("span",{className:"text-sm font-medium text-fg",children:c.label}),t.jsx("span",{className:"text-2xs text-fg-subtle",children:c.note})]},c.scope))}),t.jsx(W,{variant:"ghost",size:l?"md":"sm",onClick:i,className:k("self-start",l&&"min-h-11"),children:"Cancel"})]})}const ue=e=>e.replace(/\r?\n[ \t]/g,""),re=e=>e.replace(/\\n/gi,`
|
|
2
2
|
`).replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\\\/g,"\\");function _(e,s){let r=!1;for(let n=s.length;n<e.length;n+=1){const i=e[n];if(n===s.length&&i!==";"&&i!==":")return;if(i==='"'){r=!r;continue}if(!r&&i===":")return e.slice(n+1).trim()}}function U(e,s){for(const r of ue(e).split(/\r?\n/)){if(!r.startsWith(s))continue;const n=_(r,s);if(n!==void 0)return n}return""}const Qe=e=>U(e,"RRULE"),Xe=e=>({location:re(U(e,"LOCATION")),description:re(U(e,"DESCRIPTION"))});function et(e,s){const r=ue(e).split(/\r?\n/).find(i=>i.startsWith("DTSTART")&&_(i,"DTSTART")!==void 0);if(r===void 0)return We(s);const n=/;TZID="?([^;:"]+)"?/i.exec(r)?.[1];return n!==void 0?Intl.supportedValuesOf("timeZone").includes(n)?n:s:_(r,"DTSTART")?.toUpperCase().endsWith("Z")?"":s}const tt=V(404);function st(e,s){const{data:r,isLoading:n,error:i,refetch:l}=F({...le({path:{calendarObjectId:e},query:{calendarId:s}}),meta:tt,enabled:e!==""&&s!==""});return{resource:r,isLoading:n,error:i,refetch:()=>{l()}}}const ae=365*24*60*6e4,nt=1440*6e4,ie=V(401),rt=V(401,404),R=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"+00:00"),at=e=>{const s=e instanceof Error&&e.message!==""?e.message:"no reason given",r=Z(e);return r===void 0?s:`${s} (HTTP ${r})`};function it(e,s){const[r]=E.useState(()=>Date.now()),n=de(),i=new Date(r).toISOString(),l=F({...ee({query:{from:R(r),to:R(r+ae),calendarObjectId:e}}),meta:ie,retry:!1,enabled:s}),d=l.data?se(l.data.items,e,i,n):void 0,c=F({...le({path:{calendarObjectId:e}}),meta:rt,retry:!1,enabled:s&&l.data!==void 0&&d===void 0}),u=Date.parse(c.data?.dtStart??""),p=c.data!==void 0&&Number.isNaN(u),x=Number.isNaN(u)?0:u-nt,f=F({...ee({query:{from:R(x),to:R(x+ae),calendarObjectId:e}}),meta:ie,retry:!1,enabled:s&&c.data!==void 0&&!p}),v=f.data?se(f.data.items,e,i,n):void 0;if(!s)return{kind:"Idle"};if(d)return{kind:"Found",jump:d};if(v)return{kind:"Found",jump:v};const N=Z(c.error)===404,a=[l.error,N?null:c.error,f.error].find(w=>w!==null);return a!==void 0?Z(a)===401?{kind:"SignedOut"}:{kind:"Failed",reason:at(a)}:N?{kind:"Deleted"}:p?{kind:"Failed",reason:`the stored event names no readable start (${c.data?.dtStart??""})`}:f.data!==void 0?{kind:"NoOccurrenceFound"}:{kind:"Searching"}}const ot={kind:"NotInView"},oe="rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring";function lt(e){switch(e.kind){case"Finding":return{title:"Finding the event",detail:"Looking for the day it falls on."};case"Deleted":return{title:"This event was deleted",detail:"None of your calendars holds it any more."};case"NoOccurrenceFound":return{title:"No occurrence in its first year or the coming year",detail:"Its repeat rule, or the days taken out of it, leave it no day in either."};case"SignedOut":return{title:"Your session has ended",detail:"Sign in again to open this event."};case"Failed":return{title:"The event couldn't be looked up",detail:e.reason};case"NotInView":return{title:"That event isn't on this week",detail:"The address names an event the calendar doesn't have here."}}}function ct({event:e,calendar:s,isOccurrence:r,absence:n=ot,problem:i="",readOnlyNote:l="",onEdit:d,onDelete:c,onClose:u}){if(!e||!s){const{title:p,detail:x}=lt(n),f=n.kind==="Failed"||n.kind==="SignedOut";return t.jsxs("div",{role:f?"alert":void 0,className:"flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center",children:[t.jsx(be,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:p}),t.jsx("p",{className:"max-w-xs break-words text-sm text-fg-muted",children:x}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[n.kind==="SignedOut"&&n.signIn,n.kind==="Failed"&&t.jsx("a",{href:n.reportHref,target:"_blank",rel:"noreferrer",className:oe,children:"Report an issue"}),t.jsx("button",{type:"button",onClick:u,className:oe,children:"Back to the calendar"})]})]})}return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[r&&t.jsx("p",{className:"shrink-0 border-b border-line bg-surface-sunken px-row-inset py-1.5 text-2xs uppercase tracking-wider text-fg-subtle",children:"One occurrence of a repeating event"}),l!==""&&t.jsxs("p",{className:"flex shrink-0 items-start gap-2 border-b border-line bg-surface-sunken px-row-inset py-2 text-sm text-fg-muted",children:[t.jsx(He,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:l})]}),i!==""&&t.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 border-b border-danger/40 bg-danger-soft px-row-inset py-2 text-sm",children:[t.jsx(Ne,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),t.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:i})]}),t.jsx(Ye,{event:e,calendar:s,whenText:ce(e),onEdit:d,onDelete:c,onClose:u,className:"min-h-0 flex-1"})]})}const dt="This event changed somewhere else — over CalDAV, or in another tab. Nothing was saved. Close it and open it again to see the version that's stored now.";function ut(){const{Account:e}=je();return t.jsx(e,{children:({signOut:s})=>t.jsx("button",{type:"button",onClick:()=>s(),className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Sign in again"})})}const ft=(e,s)=>{switch(e.kind){case"Deleted":case"NoOccurrenceFound":return{kind:e.kind};case"SignedOut":return{kind:"SignedOut",signIn:t.jsx(ut,{})};case"Failed":return{kind:"Failed",reason:e.reason,reportHref:$e(`opening an event failed: ${e.reason}`)};case"Searching":return{kind:"Finding"};default:return{kind:s?"Finding":"NotInView"}}};function Ct({calendarObjectId:e,recurrenceId:s}){const{view:r,date:n,calendarIds:i}=Oe(),{events:l,isLoading:d}=Be({view:r,date:n,calendarIds:i}),{calendars:c,collections:u,timeZoneByCalendarId:p}=Ze(),{closeEvent:x}=Re(),{updateEvent:f,deleteEvent:v,isWriting:N}=qe(),a=l.find(o=>o.id===_e(e,s??"")),w=s===void 0&&a===void 0,A=w?Ue(l,e,new Date().toISOString()):void 0,z=it(e,w&&!d&&A===void 0),T=c.find(o=>o.id===a?.calendarId),{resource:g}=st(e,a?.calendarId??""),[q,y]=E.useState(void 0),[b,L]=E.useState(void 0),[j,I]=E.useState(void 0),[B,C]=E.useState(""),fe=ke(j??we("",""),e),D=g?Xe(g.icalData):void 0,$=g?Qe(g.icalData):"",me=a&&!a.allDay?a.start.slice(11,16):"",M=g?et(g.icalData,p[a?.calendarId??""]??ne):ne,xe=a&&!a.allDay?ye($,Ve(a.start,M===""?"UTC":M).slice(0,10),a.start.slice(0,10)):$,O=$===""?"":Ce(xe,me)??"Repeats",G=a!==void 0&&a.seriesId!==""&&s!==void 0&&s!=="",H=a!==void 0&&g!==void 0&&!T?.readOnly,Y=(o,m)=>{if(o.kind==="written"){C(""),m();return}C(o.kind==="conflict"?dt:o.message)},J=o=>({calendarObjectId:e,calendarId:a?.calendarId??"",recurrenceId:s??"",scope:o,etag:g?.etag??""}),K=o=>{if(!a)return;const m=Ee(a,{repeat:O,location:D?.location??"",notes:D?.description??""});y(void 0),L({before:m,scope:o}),I(m),C("")},Q=o=>{y(void 0),v(J(o)).then(m=>Y(m,x))},he=()=>{if(!b||!j)return;const o=Te(b.before,j,{clock:de(),anchor:M});if(!o.ok){C(o.problem);return}f(J(b.scope),o.patch).then(m=>Y(m,()=>{L(void 0),I(void 0)}))};if(A)return t.jsx(P,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:r,date:n,calendarObjectId:e,recurrenceId:A.recurrenceId},search:!0,hash:!0,replace:!0});const h=z.kind==="Found"?z.jump:void 0,X=h!==void 0&&i.length>0&&!i.includes(h.calendarId);if(h&&(h.date!==n||X)){const o=X?m=>({...m,calendarId:[...i,h.calendarId]}):!0;return h.recurrenceId===""?t.jsx(P,{to:"/calendar/$view/$date/$calendarObjectId",params:{view:r,date:h.date,calendarObjectId:e},search:o,hash:!0,replace:!0}):t.jsx(P,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:r,date:h.date,calendarObjectId:e,recurrenceId:h.recurrenceId},search:o,hash:!0,replace:!0})}return q!==void 0&&a?t.jsx("div",{className:"flex h-full flex-col justify-center bg-surface px-row-inset",children:t.jsx(Ke,{className:"mx-auto w-full max-w-md",title:a.title,ruleText:O===""?"It repeats":O,instanceText:ce(a),onChoose:q==="edit"?K:Q,onCancel:()=>y(void 0)})}):b&&j?t.jsx(Se,{title:"Edit event",subtitle:b.scope==="this"?"This occurrence only":j.date,calendars:c,draft:j,onChange:I,problem:B,saveLabel:"Save",isSaving:N,repeatEditable:b.scope===void 0||b.scope==="all",calendarEditable:!1,clashes:fe,onSave:he,onCancel:()=>{L(void 0),I(void 0),C("")}}):t.jsx(ct,{event:a&&{...a,location:D?.location??"",notes:D?.description??"",recurrenceRule:O},calendar:T,readOnlyNote:T?.readOnly?Ge(u.find(o=>o.calendarId===T.id)?.subscriptionUrl??""):"",isOccurrence:s!==void 0,absence:ft(z,w&&d),problem:B,onEdit:H?()=>G?y("edit"):K(void 0):void 0,onDelete:H?()=>G?y("delete"):Q(void 0):void 0,onClose:x})}export{Ct as O};
|