@remit/web-client-dist 0.0.530 → 0.0.532

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.
Files changed (147) hide show
  1. package/assets/{BriefPane-CitnWpvF.js → BriefPane-B-DbKb34.js} +1 -1
  2. package/assets/{CalendarComposePane-CzeHqJlY.js → CalendarComposePane-qouJ2ac1.js} +1 -1
  3. package/assets/{CalendarComposeSeed-q74GURU0.js → CalendarComposeSeed-C-Fjb-DN.js} +1 -1
  4. package/assets/{CalendarShell-8bWaslg9.js → CalendarShell-CvwKFWY4.js} +1 -1
  5. package/assets/{EmptyState-JWPbqD0B.js → EmptyState-CbLe8RyH.js} +1 -1
  6. package/assets/{ErrorState-C7SkMyjT.js → ErrorState-DeHr3dTk.js} +1 -1
  7. package/assets/{FlaggedPane-DWuY3UUn.js → FlaggedPane-C8ICa9mB.js} +1 -1
  8. package/assets/{FullCompose-w8zXvFLs.js → FullCompose-CjmuKjm2.js} +1 -1
  9. package/assets/{MailListHeader-jTIo82jU.js → MailListHeader-DwBQmyCm.js} +1 -1
  10. package/assets/{MailNav-3wPZ6ueM.js → MailNav-B3ulC_0x.js} +1 -1
  11. package/assets/{MailShell-CtpzsUrg.js → MailShell-OfaD4UcO.js} +1 -1
  12. package/assets/{MailViewChrome-BkjhETVf.js → MailViewChrome-CdYPg7kW.js} +1 -1
  13. package/assets/{MailboxPane-D2zZCDTP.js → MailboxPane-TByVBODS.js} +1 -1
  14. package/assets/{NavMenuButton-CTvfcdMC.js → NavMenuButton-DEpXlqD-.js} +1 -1
  15. package/assets/{OnboardingWizard-BJMvuFTb.js → OnboardingWizard-0WVEm1SL.js} +1 -1
  16. package/assets/{OpenCalendarEvent-ZaX9hmTt.js → OpenCalendarEvent-D_-F4qAI.js} +1 -1
  17. package/assets/{OutboxPane-avAVAFAz.js → OutboxPane-DAPpYoE_.js} +1 -1
  18. package/assets/_calendarObjectId-phVd51fB.js +1 -0
  19. package/assets/_mailboxId-3b_mLzhV.js +1 -0
  20. package/assets/_messageId-CJqr5kX5.js +1 -0
  21. package/assets/_messageId-DZ7xcogg.js +1 -0
  22. package/assets/_messageId-rUt2EvGA.js +1 -0
  23. package/assets/_outboxMessageId-CLlKwpsf.js +1 -0
  24. package/assets/_recurrenceId-Dk0s89DA.js +1 -0
  25. package/assets/_threadId-Cs3angzT.js +1 -0
  26. package/assets/_threadId-Gtf7VLmY.js +1 -0
  27. package/assets/_threadId-LMvh3OOU.js +1 -0
  28. package/assets/{_view._date-Bw1MUyny.js → _view._date-Bg-jBWJ2.js} +1 -1
  29. package/assets/{accounts-Byf3XCFh.js → accounts-BNI_QMwv.js} +1 -1
  30. package/assets/{advanced-BHr5wMV0.js → advanced-AWE93czY.js} +1 -1
  31. package/assets/{appearance-DA4WxugM.js → appearance-DAI7zZuL.js} +1 -1
  32. package/assets/{attachment-file-Bu6vQ8Vz.js → attachment-file-B1bTtN7l.js} +1 -1
  33. package/assets/{attendee-row-C96YrC-H.js → attendee-row-B4trWaMp.js} +1 -1
  34. package/assets/{avatar-Cu6oApht.js → avatar-BeXqEG8p.js} +1 -1
  35. package/assets/{bottom-sheet-B5-uBjKW.js → bottom-sheet-CbN20e5D.js} +1 -1
  36. package/assets/brief-BPfDlJbu.js +1 -0
  37. package/assets/{brief-DEUUnOs9.js → brief-Cw2xFjmS.js} +1 -1
  38. package/assets/{browser-ponyfill-D0iXvRcC.js → browser-ponyfill-wX3nkieC.js} +1 -1
  39. package/assets/{bug-CHFd_QBs.js → bug-GWDqtP-7.js} +1 -1
  40. package/assets/{calendar-Bo7DZISw.js → calendar-Mnp3Neao.js} +1 -1
  41. package/assets/{calendar-color-BvNkz_IE.js → calendar-color-CkDge1Jd.js} +1 -1
  42. package/assets/{calendar-event-chip-CCW3kNsR.js → calendar-event-chip-D7Csrx0j.js} +1 -1
  43. package/assets/{calendars-DnJkdIVm.js → calendars-CVfRnpqj.js} +1 -1
  44. package/assets/{card-Ctp_BSIO.js → card-CIAdkzXA.js} +1 -1
  45. package/assets/chevron-left-B3DPKF-6.js +1 -0
  46. package/assets/{circle-check-kfCtXQ-x.js → circle-check-B9V_jnPt.js} +1 -1
  47. package/assets/{circle-check-big-COplv7or.js → circle-check-big-BqKDZ3Q_.js} +1 -1
  48. package/assets/{circle-help-CM5yd27e.js → circle-help-BxPqzlGX.js} +1 -1
  49. package/assets/{clock-BwWVGnWa.js → clock-VKZRK796.js} +1 -1
  50. package/assets/compose._-_outboxMessageId_-CDnIxTKC.js +1 -0
  51. package/assets/compose._-_outboxMessageId_-CGVoX0Px.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-DYCA6X-7.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-Dj0u96Vj.js +1 -0
  54. package/assets/{config-import-CAKLt5QZ.js → config-import-Drv-f-ck.js} +1 -1
  55. package/assets/{confirm-dialog-CsyU1qLQ.js → confirm-dialog-jQWOUr73.js} +1 -1
  56. package/assets/{copy-6t3TJZ39.js → copy-Dhu6Zdn5.js} +1 -1
  57. package/assets/{credential-steps-BD-H3GsL.js → credential-steps-BMoVlEPM.js} +1 -1
  58. package/assets/{download-CaZ_cFMv.js → download-2kd2WUv5.js} +1 -1
  59. package/assets/{file-json-C9KEeUdc.js → file-json-ND_vvGBa.js} +1 -1
  60. package/assets/{filters-CEJ-o0td.js → filters-BCMnnaCv.js} +1 -1
  61. package/assets/{flagged-DWmZCNny.js → flagged-CJbDq0uf.js} +1 -1
  62. package/assets/flagged-CjRHlM4t.js +1 -0
  63. package/assets/{folders-CRgsEwVq.js → folders-V-dVJDus.js} +1 -1
  64. package/assets/{format-_j9Y6e_p.js → format-B7kZHooA.js} +1 -1
  65. package/assets/{help-copy-CXuweZFQ.js → help-copy-DK-7D875.js} +1 -1
  66. package/assets/{import-BEHZUTf2.js → import-CYKzb0bY.js} +1 -1
  67. package/assets/index-6rrwNlJV.js +1 -0
  68. package/assets/{index-BBGflFWf.js → index-8kDZ5Nbh.js} +4 -4
  69. package/assets/index-CJqr5kX5.js +1 -0
  70. package/assets/index-CTv9GIuU.js +1 -0
  71. package/assets/index-CmoVszGA.js +1 -0
  72. package/assets/index-DHpmlJ6O.js +1 -0
  73. package/assets/index-DLlZK0wP.js +1 -0
  74. package/assets/index-DPoS_wXz.js +1 -0
  75. package/assets/index-DZ7xcogg.js +1 -0
  76. package/assets/{index-DoeJCNcM.js → index-DqU4XTfz.js} +1 -1
  77. package/assets/index-DuJvR6zK.js +1 -0
  78. package/assets/{index-BZwGS3k8.js → index-kBWsgSL1.js} +4 -4
  79. package/assets/{kbd-BCbb_tUv.js → kbd-D4H0AykE.js} +1 -1
  80. package/assets/{labels-Qd-5QKb8.js → labels-Djr_Imjn.js} +1 -1
  81. package/assets/{mail-DftRSs2P.js → mail-CD3qDEly.js} +1 -1
  82. package/assets/{mail-BqMNZW4T.js → mail-z5ZuLbER.js} +1 -1
  83. package/assets/{map-pin-BeaC8Rf9.js → map-pin-CIJo6NcM.js} +1 -1
  84. package/assets/{menu-CdC5Sc0h.js → menu-CSDPUHfq.js} +1 -1
  85. package/assets/{new-BiyA07Qz.js → new-DqkOmr0J.js} +1 -1
  86. package/assets/onboarding-D6dchlX9.js +1 -0
  87. package/assets/{onboarding-completion-B_4UMMMi.js → onboarding-completion-BqXlNejL.js} +1 -1
  88. package/assets/outbox-YiSjcqJD.js +1 -0
  89. package/assets/{pencil-Cokk0JIp.js → pencil-Cd4AX53X.js} +1 -1
  90. package/assets/{refresh-cw-CY-7Dknf.js → refresh-cw-CM0dlacw.js} +1 -1
  91. package/assets/{rich-text-BCL7e-h_.js → rich-text-Byz0zxtB.js} +1 -1
  92. package/assets/{rich-text-spellcheck-worker-provider-07cIfhAo.js → rich-text-spellcheck-worker-provider-B1O4OBdp.js} +1 -1
  93. package/assets/{rotate-ccw-C6C8wGdH.js → rotate-ccw-MeJyarjq.js} +1 -1
  94. package/assets/{row-actions-Bqlhar_U.js → row-actions-dL-6MXJt.js} +1 -1
  95. package/assets/{search-mirror-C0Q_k35x.js → search-mirror-DXSTVIAm.js} +1 -1
  96. package/assets/{search-token-index-DrDyuYAU.js → search-token-index-DwVhD_Ps.js} +1 -1
  97. package/assets/{sections-cu4iJhq8.js → sections-CHQnT1gv.js} +1 -1
  98. package/assets/{senders-q6IgVHoY.js → senders-Dd0COHGM.js} +1 -1
  99. package/assets/settings-BKWXi2gA.js +1 -0
  100. package/assets/{settings-screen-DT7mZ0Ih.js → settings-screen-DhflM5kF.js} +1 -1
  101. package/assets/{shield-check-CHp_P7nB.js → shield-check-yirJ7LBD.js} +1 -1
  102. package/assets/{suggested-vips-h02Q-O1z.js → suggested-vips-D3sW9iSx.js} +1 -1
  103. package/assets/{useCalendarData-DM1eFwRx.js → useCalendarData-ZpdXYEEI.js} +1 -1
  104. package/assets/{useCalendars-C_zzTvbg.js → useCalendars-DwzgQIxe.js} +1 -1
  105. package/assets/{useDebouncedValue-DTQ9Y1tn.js → useDebouncedValue-F9ry5FbT.js} +1 -1
  106. package/assets/{useFilters-BwWZN3X7.js → useFilters-065zdrD3.js} +1 -1
  107. package/assets/{useLabels-BLXIqz-A.js → useLabels-CSIOGq7q.js} +1 -1
  108. package/assets/{useLayoutTier-BtlL79ys.js → useLayoutTier-BC3fixIj.js} +1 -1
  109. package/assets/{useMessageBodyContent-o8QcGqzL.js → useMessageBodyContent-Ddc3tsxr.js} +1 -1
  110. package/assets/{useQueries-BLrBiNgu.js → useQueries-C4FyFPIS.js} +1 -1
  111. package/assets/{useRefreshControl-DPOLAqGK.js → useRefreshControl-jDwAAVSL.js} +1 -1
  112. package/assets/{useResultFolderIndex-BfncbWVn.js → useResultFolderIndex-jZoBKfBv.js} +1 -1
  113. package/assets/{useSearchTokenContext-DoYK52TK.js → useSearchTokenContext-CtTpZfrh.js} +1 -1
  114. package/assets/{useSemanticSearch-_3emm-r8.js → useSemanticSearch-D8FXnEuv.js} +1 -1
  115. package/assets/{useSignature-C-OTkUGx.js → useSignature-ahrQ6zYZ.js} +1 -1
  116. package/assets/{window-ven3SsTb.js → window-CgA4ilXA.js} +1 -1
  117. package/index.html +1 -1
  118. package/package.json +1 -1
  119. package/assets/_calendarObjectId-ppd8uuoN.js +0 -1
  120. package/assets/_mailboxId-fqZWH0v8.js +0 -1
  121. package/assets/_messageId-CWAr0rYR.js +0 -1
  122. package/assets/_messageId-CvMS_mPT.js +0 -1
  123. package/assets/_messageId-DBt5uC_I.js +0 -1
  124. package/assets/_outboxMessageId-RrWYTMVv.js +0 -1
  125. package/assets/_recurrenceId-Du7HlLsi.js +0 -1
  126. package/assets/_threadId-Bso8AbX_.js +0 -1
  127. package/assets/_threadId-C0Up-XFy.js +0 -1
  128. package/assets/_threadId-Cxplnu8U.js +0 -1
  129. package/assets/brief-CustMb18.js +0 -1
  130. package/assets/chevron-left-Da7S3BDQ.js +0 -1
  131. package/assets/compose._-_outboxMessageId_-CzUYA76W.js +0 -1
  132. package/assets/compose._-_outboxMessageId_-DAAtbSVi.js +0 -1
  133. package/assets/compose._-_outboxMessageId_-DiL_nmmY.js +0 -1
  134. package/assets/compose._-_outboxMessageId_-X5baegkB.js +0 -1
  135. package/assets/flagged--Te69ucs.js +0 -1
  136. package/assets/index-0ttiMyMA.js +0 -1
  137. package/assets/index-C0MoyUOt.js +0 -1
  138. package/assets/index-C8eWk9Ar.js +0 -1
  139. package/assets/index-CIvdxQIz.js +0 -1
  140. package/assets/index-CPj8yj0D.js +0 -1
  141. package/assets/index-CvMS_mPT.js +0 -1
  142. package/assets/index-DBt5uC_I.js +0 -1
  143. package/assets/index-cXiPwNQR.js +0 -1
  144. package/assets/index-ziPHGxus.js +0 -1
  145. package/assets/onboarding-Ce9ZCxKo.js +0 -1
  146. package/assets/outbox-BDdu-q44.js +0 -1
  147. package/assets/settings-BlzYYZ9h.js +0 -1
@@ -1 +1 @@
1
- import{j as r,a1 as Is,bU as ks,bV as Ts,cK as js,B as ct,f as te,U as ws,t as Ne,g as Pt,r as c,Y as Ms,Z as Rs,bo as Es,h as Tt,c as ut,ac as Os,i as jt,cL as As,cB as Ns,I as zs,a6 as Fs,a2 as $t,bO as Ds,bi as Ls,cM as _s,cN as Ps,as as Bt,aX as $s,aY as Bs,q as wt,m as Ws,M as Wt,bl as Ks,G as Vs,bm as qs,bn as Hs,cO as Us,o as Qs,cP as Js,cz as Gs,s as Ys,cQ as Xs,cR as Zs,ch as Kt,cS as Vt,C as qt,ah as en,cT as tn,cU as sn,aj as nn,bx as on}from"./index-BZwGS3k8.js";import{u as rn,p as an,R as ln}from"./useSearchTokenContext-DoYK52TK.js";import{u as cn,a as un,R as dn}from"./useRefreshControl-DPOLAqGK.js";import{C as Ht,a as Ut,c as Qt,j as hn,M as fn,t as Jt,u as mn,b as gn,d as Gt,e as Yt,f as pn,g as xn,h as bn,r as vn,n as Sn,i as yn,k as Cn,l as In,m as kn,o as Tn,S as jn,p as wn,D as Mn,q as Rn,s as En,v as Xt,w as On,x as An,y as Nn,z as zn,A as Fn,B as Zt,E as Dn,F as Ln,G as _n,H as Pn,I as $n,J as Bn,K as Wn,L as Kn,N as Vn,O as qn,P as zt,Q as Ft,R as Hn,T as Un,U as Qn,V as Jn,W as Gn,X as Yn,Y as Xn,Z as Zn,_ as eo,$ as to,a0 as so,a1 as no,a2 as es,a3 as ts,a4 as ss,a5 as oo,a6 as io,a7 as ro,a8 as ao,a9 as lo,aa as co,ab as uo,ac as ho}from"./MailListHeader-jTIo82jU.js";import{S as fo,M as mo,a as go,u as po,b as xo}from"./MailViewChrome-BkjhETVf.js";import{A as Mt}from"./avatar-Cu6oApht.js";import{c as Qe,d as bo,e as ns}from"./format-_j9Y6e_p.js";import{c as vo,f as So,a as yo,u as Co}from"./useMessageBodyContent-o8QcGqzL.js";import{g as Je,i as Io,t as ko,h as To,j as jo,k as wo,l as Mo}from"./search-token-index-DrDyuYAU.js";import{N as Ro}from"./NavMenuButton-CTvfcdMC.js";import{C as Eo}from"./confirm-dialog-CsyU1qLQ.js";import{f as Oo}from"./ErrorState-C7SkMyjT.js";import{a as Ao}from"./useLabels-BLXIqz-A.js";import{L as No,r as zo,t as Fo,s as Do,u as Lo}from"./useSemanticSearch-_3emm-r8.js";import{S as dt}from"./shield-check-CHp_P7nB.js";import{B as _o}from"./bottom-sheet-B5-uBjKW.js";import{C as Po}from"./circle-help-CM5yd27e.js";import{C as $o}from"./circle-check-kfCtXQ-x.js";import{u as Bo}from"./useLayoutTier-BtlL79ys.js";import{n as Wo}from"./search-query-Cr_ZXBCp.js";import{u as Ko}from"./sections-cu4iJhq8.js";const Vo=e=>e.toLocaleString(),qo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Vo(e.value)} ${t} for “${o}”`};function Ho({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(Is,{className:"size-4 text-fg-muted","aria-hidden":"true"}),r.jsx("span",{className:"text-sm text-fg-muted",children:qo(o,e)})]})}const Uo=({children:e,onRefresh:o,isRefreshing:t})=>ks(Ts)?e:r.jsx(js,{onRefresh:o,isPullable:!t,children:e}),Qo=e=>e===1?"message":"messages";function Jo({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ct,{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(dt,{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} ${Qo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(te,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const Go=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",os=({senderTrust:e,size:o="sm",className:t})=>{const s=Go(e,o);return s==="vip"?r.jsx(ws,{className:Ne("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:Ne("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 Yo({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:Ne("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(Ht,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(Mt,{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(os,{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(Pt,{tone:"positive",children:[r.jsx(dt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const Xo=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)},Zo=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Dt=e=>e===1?"message":"messages";function ei({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,i]=c.useState(!1),l=Zo(e,o),a=e.messages.length,u=n?Ms:Rs;return r.jsxs("div",{className:Ne(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(Ht,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Dt(a)} from ${e.senderName}`}),r.jsx(Mt,{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(os,{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(Pt,{tone:"positive",children:[r.jsx(dt,{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} ${Dt(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(Yo,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const Rt=e=>e===1?"message":"messages",ti=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${Rt(e)}`} out of Spam to ${o} now. Nothing later.`,kt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function si(){return r.jsx(ct,{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 ni({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(()=>Xo(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(dt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Po,{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(si,{})})]}),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(te,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(te,{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(ei,{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(te,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${Rt(h)}`}),r.jsx(te,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function oi({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(Es,{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:kt(o,s)}),r.jsx(te,{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:ti(e,kt(o,s))}),r.jsx(te,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(te,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function ii({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($o,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Rt(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(te,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function ri({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,y]=c.useState(0),S=c.useRef(!1);c.useEffect(()=>{e&&!S.current&&(u("review"),h(new Set(o.map(k=>k.id))),m(t),y(0)),S.current=e},[e,o,t]);const I=d.size,b=k=>{h(T=>{const R=new Set(T);return R.has(k)?R.delete(k):R.add(k),R})},x=(k,T)=>{h(R=>{const F=new Set(R);for(const L of k.messages)T?F.add(L.id):F.delete(L.id);return F})},w=()=>{const k=Array.from(d);y(k.length),i(k,g),u("done")};return r.jsxs(_o,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ni,{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(oi,{count:I,folders:s,delimiter:n,destination:g,onPick:m,onMove:w,onBack:()=>u("review")}),a==="done"&&r.jsx(ii,{count:p,destinationLabel:kt(s,g),onClose:l})]})}function ai(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:Qe(e.updatedAt),isRead:!0}}function li(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function ci({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(ai),n=t.map(li),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 ui=({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})]}),di=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ne("group",Qt({active:o})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Ut,{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($t,{className:"size-3.5"})})})]}),hi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ne("group",Qt({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(Mt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Ut,{thread:e})]})};function fi({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=vo(),l=So(),a=Je(),u=Tt(),{data:d}=ut(Os()),h=c.useMemo(()=>ci({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=jt({...Ns(),onSuccess:()=>{u.invalidateQueries({queryKey:As()})}}),m=S=>{g.mutate({path:{outboxMessageId:S}})},p=S=>{const I=t.find(b=>b.messageId===S)?.threadId;I&&a({threadId:I,messageId:S})},y=h.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(Ro,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),(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:y?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(zs,{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(S=>r.jsxs("div",{children:[S.label&&r.jsx(ui,{label:S.label,count:S.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:S.threads.map(I=>S.id==="remit-drafts"?r.jsx(di,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(hi,{row:I,isSelected:I.id===o,onOpen:p},I.id))})]},S.id))})]})}const is=e=>e===1?"1 message":`${ns(e)} messages`,mi=e=>({title:"Empty Trash?",description:`${is(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),gi=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=bo(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 pi({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?gi(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=mi(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:`${is(t)} erased from the mail server.`}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx($t,{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(ct,{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(te,{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(Eo,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function xi(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 Pe(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 Lt(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const bi=(e,o)=>Math.abs(e-o)<1.01,vi=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Ue;const Ct=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>"u")return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;const e=navigator.maxTouchPoints;return Ue=navigator.platform==="MacIntel"&&e!==void 0&&e>0},_t=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Si=e=>e,yi=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},Ci=(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(_t(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(_t(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},lt={passive:!0},Ii=typeof window>"u"?!0:"onscrollend"in window,ki=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&Ii;let l=0;const a=i?null:vi(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,lt),i&&s.addEventListener("scrollend",h,lt),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",h)}},Ti=(e,o)=>ki(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),ji=(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"]},wi=(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})},Mi=wi;class Ri{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:Si,rangeExtractor:yi,onChange:()=>{},measureElement:ji,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,y=this.getMeasurements(),S=m>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=y[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==S||i.getItemKey(p-1)!==I)){d=!0;const w=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;w&&(a=[w.key,this.getScrollOffset()-w.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,y=this.getMeasurements(),{count:S,getItemKey:I}=this.options;let b=0;for(;b<S&&I(b)!==m;)b++;if(b<S){const x=y[b];if(x){const w=x.start+p;w!==this.scrollOffset&&(g=w-this.scrollOffset,this.scrollOffset=w,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=Pe(()=>(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,!(!Ct()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,lt),i.addEventListener("touchend",a,lt),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&&(Ct()&&(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=Pe(()=>[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=Pe(()=>[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 T=new Float64Array(b);x&&m>0&&T.set(x.subarray(0,m*2)),x=T,this._flatMeasurements=x}let w;if(m===0)w=s+n;else{const T=m-1;w=x[T*2]+x[T*2+1]+d}for(let T=m;T<t;T++){const R=i(T),F=g.get(R),L=typeof F=="number"?F:this.options.estimateSize(T);x[T*2]=w,x[T*2+1]=L,w+=L+d}const k=xi(t,x,i);return this.measurementsCache=k,k}const p=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),S=new Float64Array(a);let I=0;for(let b=0;b<m;b++){const x=p[b];x&&(y[x.lane]===void 0&&I++,y[x.lane]=b,S[x.lane]=x.end)}for(let b=m;b<t;b++){const x=i(b),w=this.laneAssignments.get(b);let k,T;const R=u==="estimate"||g.has(x);if(w!==void 0&&this.options.lanes>1){k=w;const O=y[k],A=O!==void 0?p[O]:void 0;T=A?A.end+d:s+n}else if(I===a){let O=0,A=S[0],me=y[0];for(let z=1;z<a;z++){const oe=S[z];(oe<A||oe===A&&y[z]<me)&&(O=z,A=oe,me=y[z])}k=O,T=A+d,R&&this.laneAssignments.set(b,k)}else k=b%this.options.lanes,T=s+n,R&&this.laneAssignments.set(b,k);const F=g.get(x),L=typeof F=="number"?F:this.options.estimateSize(b),G=T+L;p[b]={index:b,start:T,size:L,end:G,key:x,lane:k},y[k]===void 0&&I++,y[k]=b,S[k]=G}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Pe(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=Oi(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Pe(()=>{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,y=((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):y&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Pe(()=>[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=rs(0,s.length-1,i?a=>n[a*2]:a=>Lt(s[a]).start,t);return Lt(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&&(Ct()&&(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&&bi(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 rs=(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 Ei(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 Oi(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=Ei(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=rs(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 It=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Ai({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",y=m?"left":"top",S=d.options.scrollMargin,I=d.getVirtualItems();for(const b of I){const x=b.start-S,w=d.elementsCache.get(b.key);w&&h.lastPositions.get(w)!==x&&(h.lastPositions.set(w,x),p?w.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:w.style[y]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(d);const y=d.range,S=m.prevRange;p=!S||S.isScrolling!==d.isScrolling||S.startIndex!==y?.startIndex||S.endIndex!==y?.endIndex,p&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:d.isScrolling}:null)}p&&(e&&h?Ds.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Ri(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),It(()=>u._didMount(),[]),It(()=>u._willUpdate()),It(()=>{l(u)}),u}function Ni(e){return Ai({observeElementRect:Ci,observeElementOffset:Ti,scrollToFn:Mi,...e})}const Et=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",zi=e=>`Select all ${Et(e)}`,Fi=(e,o)=>`All ${ns(o)} ${Et(e)} selected`,Di=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=hn(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}},Li=(e,o,t)=>e==="BACK"&&o&&t===void 0,_i=(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Jt(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Pi=({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(fn,{thread:_i(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}}),$i=c.memo(Pi),Bi=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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Jt(e.category),suspicious:o}},Wi=({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:y})=>{const[S,I]=c.useState("none"),b=Je(),x=c.useCallback(F=>{navigator.vibrate?.(10),F==="trailing"?m(e.messageId):p(e.messageId,e.isRead),I("none")},[m,p,e.messageId,e.isRead]),w=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),k=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),T=c.useCallback(()=>{b({threadId:e.threadId,messageId:e.messageId})},[b,e.threadId,e.messageId]),R=mn(e.messageId,u);return g||d?r.jsx($i,{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:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:R.onMouseDown,onClickCapture:R.claimClick,onContextMenu:R.onContextMenu,children:r.jsx(fo,{thread:Bi(e),selectionMode:!1,checked:!1,active:t,peek:S,onPeek:I,onToggleCheck:k,onLongPress:w,onOpen:T,onAct:x})})},Ki=72,Vi=32,qi=5,as="remit:list-density",Hi=()=>{try{const e=localStorage.getItem(as);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Ui=(e,o,t)=>zo(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Qi=({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:y=!1,isLoadingMore:S=!1,accountId:I,listTitle:b,listMeta:x,listFilter:w,listScopeLabel:k,onTriageContextChange:T,commandsRef:R,hideHeader:F=!1})=>{const L=c.useRef(null),G=Je(),O=Ls(),A=_s(),{verb:me,start:z,startFromSearch:oe}=A,Ce=Ps(),ge=!!a?.trim(),_=gn(),{labels:$e}=Ao(I),{pushError:re}=Bt(),[M,Ie]=c.useState(t),[ze,P]=c.useState(),K=c.useCallback(f=>{P(v=>v===f?v:void 0),Ie(f)},[]),[se,Y]=c.useState(Hi),pe=c.useCallback(()=>{Y(f=>{const v=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(as,v)}catch{}return v})},[]),{toggleReadFor:ke}=Gt({mailboxId:e}),{junkMailboxId:ae}=Yt(I),Te=Xt(ae,e),Fe=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:le,staleFolderLabel:Be,guessedMailboxId:$}=pn(Fe),{selectedIds:N,selectedCount:ce,hasSelection:B,isSelected:De,toggle:X,select:je,clearSelection:we,selectRange:ie,setAnchor:V,selectAll:Q,toggleAll:We,intersectWith:Ge}=xn(),Me=En(ce,O),[E,Le]=c.useState(null),Re=ge&&!!u,Ye=`${e}|${JSON.stringify(u??{})}`,j=bn({mailboxId:e,accountId:I,enabled:Re,predicateKey:Ye,searchQuery:u??{}}),ft=c.useCallback((f,v,fe)=>{const U=vn(f,v,fe,le);U&&re(U)},[re,le]),Ke=j.phase.kind,Ee=j.clear,q=c.useCallback(()=>{Ke==="escalated"&&Ee(),we()},[we,Ee,Ke]),[ue,Xe]=c.useState(null),xe=c.useRef(null),de=c.useRef(!1),Oe=c.useRef(null),be=!s&&o.length>0,ve=Ni({count:o.length,getScrollElement:()=>L.current,estimateSize:()=>se==="compact"?Vi:Ki,overscan:qi}),Se=t?o.findIndex(f=>f.messageId===t):-1,Z=M?o.findIndex(f=>f.messageId===M):-1,ee=c.useCallback(f=>{if(f<0||f>=o.length)return;const v=o[f];if(Me){X(v.messageId);return}xe.current=v.messageId,de.current=!1,P(v.messageId),Ie(v.messageId)},[o,Me,X]),Ze=c.useCallback(()=>{if(o.length===0)return;const f=Z<0?0:Math.min(Z+1,o.length-1);ee(f)},[o.length,Z,ee]),Ve=c.useCallback(()=>{if(o.length===0)return;const f=Z<=0?0:Z-1;ee(f)},[o.length,Z,ee]),qe=c.useCallback(()=>ee(0),[ee]),ye=c.useCallback(()=>ee(o.length-1),[ee,o.length]),Ae=c.useCallback(()=>{M&&X(M)},[M,X]),D=c.useMemo(()=>o.map(f=>f.messageId),[o]),mt=c.useMemo(()=>{const f=[];for(const v of o)N.has(v.messageId)&&f.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:Qe(v.sentDate),accountId:I});return f},[o,N,I]),gt=c.useCallback((f,v)=>v.shiftKey?(ie(D,f,M),!0):v.metaKey||v.ctrlKey?(X(f),!0):(q(),V(f),!1),[D,M,ie,X,q,V]),et=c.useCallback(f=>{!h||f.length===0||(Oe.current=M??null,Le(f))},[h,M]),ne=c.useCallback(f=>{const v=Sn(D,M,f);v!==void 0&&(ie(D,v),xe.current=v,de.current=!1,P(void 0),Ie(v))},[D,M,ie]),tt=c.useCallback(()=>ne(-1),[ne]),st=c.useCallback(()=>ne(1),[ne]),nt=c.useCallback(()=>{D.length>0&&Q(D)},[D,Q]),ot=c.useCallback(f=>{const v=Di({verb:f,confirmingDelete:E!==null,hasSelection:B,junkMailboxId:ae,currentMailboxId:e,deletableMessageId:h?M:void 0});return v.kind==="openWizard"?(z(f),!0):v.kind==="confirmDelete"?(et([v.messageId]),!0):v.kind==="unavailable"?(re({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[E,h,B,ae,e,z,M,et,re]),he=c.useCallback((f,v)=>{const fe=o.find(U=>U.messageId===f)?.threadId;fe&&G({threadId:fe,messageId:f},{replace:v?.replace})},[G,o]),it=c.useCallback(()=>{M&&he(M)},[M,he]),pt=c.useCallback(f=>he(f,{replace:!0}),[he]);yn({keyboardFocusedMessageId:ze,openMessageId:t,enabled:O&&ce===0,open:pt});const _e=j.phase.kind==="escalated"?{scope:Et(u??{}),total:j.phase.total,searchQuery:u??{},run:f=>j.runAction(f),stop:j.stop}:void 0,rt=c.useCallback(f=>{if(f.length===0){Le(null);return}const v=new Set(f),fe=o.findIndex(J=>v.has(J.messageId));let U;for(let J=fe+1;J<o.length;J++)if(!v.has(o[J].messageId)){U=o[J].messageId;break}if(U===void 0){for(let J=fe-1;J>=0;J--)if(!v.has(o[J].messageId)){U=o[J].messageId;break}}h?.(f),q(),Oe.current=null,Le(null),U!==void 0&&(xe.current=U,de.current=!1,K(U),O&&he(U,{replace:!0})),O||Xe(Cn("delete",f.length,le))},[o,h,q,he,O,K,le]),xt=c.useCallback(()=>{const f=Oe.current;Oe.current=null,Le(null),f!==null&&(xe.current=f,de.current=!1,K(f))},[K]),He=c.useMemo(()=>Ui(o,N,I),[I,N,o]),bt=c.useCallback(()=>{if(_e){oe();return}z("organize")},[_e,oe,z]),at=c.useCallback(f=>{h?.([f])},[h]),vt=c.useCallback((f,v)=>{ke([f],!v)},[ke]),C=c.useCallback(f=>{O||je(f)},[O,je]),H=c.useCallback(()=>{if(j.isRunning||j.phase.kind==="counting"){j.stop();return}q()},[j,q]),W=c.useCallback(()=>{j.clear()},[j]);c.useEffect(()=>{if(de.current||!O&&t)return;const f=Z>=0?Z:Se;f>=0&&ve.scrollToIndex(f,{align:"auto"})},[Z,Se,ve,O,t]),c.useEffect(()=>{t&&(de.current=!1,K(t))},[t,K]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||K(o[0]?.messageId))},[o,M,K]),c.useEffect(()=>{T?.({focusedMessageId:M,selectedIds:Array.from(N),hasList:be})},[M,N,be,T]);const Ot=c.useRef(T);Ot.current=T,c.useEffect(()=>()=>Ot.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{j.phase.kind!=="idle"||j.isRunning||Ge(o.map(f=>f.messageId))},[o,Ge,j.phase,j.isRunning]);const At=c.useRef(e);c.useEffect(()=>{At.current!==e&&(At.current=e,q())},[e,q]),In({shouldBlockFn:({action:f})=>Li(f,B,Ce)?(q(),!0):!1,enableBeforeUnload:!1,disabled:!B||Ce!==void 0}),c.useEffect(()=>{const f=L.current;if(!f||!y||!p)return;const v=()=>{if(S)return;const{scrollTop:fe,scrollHeight:U,clientHeight:J}=f;fe+J>=U-200&&p()};return f.addEventListener("scroll",v,{passive:!0}),v(),()=>f.removeEventListener("scroll",v)},[y,S,p]),c.useEffect(()=>{const f=xe.current;if(!f)return;const v=L.current?.querySelector(`[data-message-id="${f}"]`);v&&(xe.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(R){if(!be){R.current=null;return}return R.current={focusNext:Ze,focusPrevious:Ve,focusFirst:qe,focusLast:ye,openFocused:it,toggleSelect:Ae,extendSelectDown:st,extendSelectUp:tt,selectAll:nt,clearSelection:()=>B?(q(),!0):!1,requestVerb:ot,toggleDensity:pe},()=>{R.current=null}}},[R,be,Ze,Ve,qe,ye,it,Ae,st,tt,nt,B,q,ot,pe]);const Nt=s?"loading":n?"error":o.length===0?"empty":"ready",us=n?Oo(i):void 0,ds=c.useCallback(()=>{const f=$s(Bs());window.open(f,"_blank","noopener,noreferrer")},[]),hs=[{id:"inbox",threads:[]}],St=D.length>0&&D.every(f=>N.has(f)),fs=Re&&y&&St&&!g&&!m&&j.phase.kind==="idle"&&!j.isRunning,ms=g||m||j.isRunning,yt=j.phase.kind==="escalated"?j.phase.total:ce,gs=j.runningAction?kn(j.runningAction.kind,j.progress?.done??0,j.progress?.total??yt):j.phase.kind==="counting"?"Counting matches…":j.phase.kind==="escalated"?Fi(u??{},j.phase.total):void 0,ps=j.phase.kind!=="escalated"&&D.length>0?{checked:St,indeterminate:ce>0&&!St,onChange:()=>We(D)}:void 0,xs=j.runningAction?{value:j.progress?.done??0,max:j.progress?.total??yt,tone:Tn(j.runningAction.kind)}:void 0,bs=(j.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:j.stop}}:j.phase.kind==="escalated"&&!j.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:W}}:fs?{tone:"info",text:"",action:{label:zi(u??{}),onClick:j.escalate}}:void 0)??(He?{tone:"warning",text:He}:void 0),vs=r.jsx(jn,{title:_.title||b,navSlot:_.navSlot,titleMeta:_.titleMeta,searchSlot:_.searchSlot,searchField:_.searchField,idleSlot:_.makeFilterSlot,count:yt,onCancel:H,onDelete:()=>z("delete"),onMove:()=>z("move"),onOrganize:bt,onJunk:Te?()=>z("junk"):void 0,onMarkRead:()=>z("markRead"),overflowSlot:I&&e&&ce>0&&$e.length>0?r.jsx(No,{accountId:I,mailboxId:e,messageIds:Array.from(N)}):void 0,isBusy:ms,isCounting:j.phase.kind==="counting",selectAll:ps,statusLabel:gs,progress:xs,notice:bs}),Ss=wn(D,M),ys=c.useCallback(f=>{de.current=!0,K(f)},[K]),Cs=r.jsxs(r.Fragment,{children:[ge&&a&&r.jsx(Ho,{query:a,count:d}),r.jsxs("div",{ref:L,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:`${ve.getTotalSize()}px`},children:ve.getVirtualItems().map(f=>{const v=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ve.measureElement,className:Ne("absolute left-0 top-0 w-full border-b border-line",j.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Wi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:Ss===v.messageId,onFocusRow:ys,isChecked:De(v.messageId),onToggleCheck:X,onRowSelect:gt,isMultiSelectMode:Me,onLongPress:C,isDesktop:O,onDelete:at,onToggleRead:vt,density:se})},f.key)})}),S&&r.jsx(mo,{})]})]});return r.jsxs(r.Fragment,{children:[ue&&!O&&r.jsx(ct,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>Xe(null),children:ue}),r.jsx(go,{listTitle:b,listMeta:x,sections:hs,flatList:!0,listState:_.searchResults?"ready":Nt,searchQuery:ge?a:void 0,listFilter:w,listScopeLabel:k,errorMessage:us,onRetry:l,onReportError:ds,density:se,selectedThreadId:t,onSelectThread:f=>he(f),isDesktop:O,hideHeader:F,selectionBar:vs,listBody:_.searchResults??(Nt==="ready"?Cs:void 0)}),r.jsx(Mn,{isOpen:E!==null,messageIds:E??[],outcome:le,accountId:I,trashFolderLabel:b,staleFolderLabel:Be,guessedMailboxId:$,isDeleting:g,onConfirm:rt,onCancel:xt}),r.jsx(Rn,{verb:me,accountId:I,mailboxId:e,selection:mt,selectionRestriction:He?"spansAccounts":void 0,escalated:_e,escalatedProgress:j.progress,onFinished:q,onRunEnded:ft})]})},Ji=e=>Wt({path:{accountId:e}}),Gi=e=>{const o=Tt(),t=wt(),s=jt({...Ws(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:Ji(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Yi=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=Gi(e);return r.jsx(Uo,{onRefresh:t,isRefreshing:s,children:o})};function Xi({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=wt(),u=Ks(),{inboxMailboxId:d}=On(e),h=An(e),{data:g}=ut({...Vs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>qs({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]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Nn(a,t.length))},[a,t.length]);const S=c.useCallback(()=>{zn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((b,x)=>{Fn(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(Jo,{count:t.length,onReview:S})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(ri,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:Hs(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const Zi=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,er=({accountId:e,mailboxId:o})=>{const t=Tt(),{pushError:s}=Bt(),{requestAppointment:n}=Us(),{trashByAccount:i}=Zt(),l=e?i.get(e):void 0,a=Zi(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(Qs())?.accounts.find(T=>T.accountId===e)?.folderAppointments.find(T=>T.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:p,isPending:y}=jt({...Xs(),meta:Ys(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,w,k)=>{k.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,w,k)=>{const T=Js(x);if(!T){s({title:"Couldn't empty Trash",detail:Gs(x),error:x});return}k?.scope===a&&d({scope:a,refusal:T})},onSettled:(x,w,k,T)=>{m.current===T?.scope&&(m.current=void 0),Io(t,ko([T?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Wt({path:{accountId:e}})})}}),S=c.useCallback(()=>e?(d({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),I=c.useCallback(()=>{S()},[S]),b=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:S})},[h,n,S]);return{emptyTrash:I,isEmptying:y&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:b}},tr="We can verify this sender";function sr(e){const{data:o}=ut({...Zs({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:tr,trustSubReason:Dn(s.senderTrust),senderTrust:s.senderTrust}))}}const nr=6e4,or=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=ut({queryKey:Kt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:i}=await Vt({path:{mailboxId:e},query:s,throwOnError:!0});return i},enabled:t,staleTime:nr});return t?Fo(n?.count):{kind:"unknown"}},ir=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t},rr=50,ls=c.createContext(null);function ht(){const e=c.useContext(ls);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function ar({mailboxId:e,thread:o,children:t}){const s=Je(),n=To(),i=Ko(),l=o?.threadId,a=o?.messageId,u=wt(),{accounts:d,searchQuery:h,onToggleIntelligence:g}=qt(),m=rn(),p=Wo(h),y=p.length>0,{freeText:S,tokens:I}=an(p,m),[b,x]=c.useState("all"),[w,k]=c.useState(new Set),T=c.useMemo(()=>({category:b,attributes:w}),[b,w]),R=c.useMemo(()=>Ln(T),[T]),F=y||_n(T),{params:L,residual:G}=Pn(I,R),O={order:"desc",...S?{query:S}:{},...L,...R},A={...O,limit:rr},me={category:A.category,unread:A.unread,starred:A.starred,attachments:A.attachments},z=F?Kt({path:{mailboxId:e},query:A}):en({path:{mailboxId:e},query:{order:"desc"}}),{data:oe,isLoading:Ce,isError:ge,error:_,refetch:$e,fetchNextPage:re,hasNextPage:M,isFetchingNextPage:Ie}=po({queryKey:z,queryFn:async({pageParam:C})=>{if(F){const{data:W}=await Vt({path:{mailboxId:e},query:{...A,continuationToken:C},throwOnError:!0});return W}const{data:H}=await on({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return H},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,H)=>ho(H?.queryKey,me)?C:void 0}),ze=or({mailboxId:e,criteria:O,enabled:Do({hasSearchQuery:y,freeText:S,residualTokenCount:G.length})}),{accountId:P,isLoading:K}=$n(e),se=jo({accounts:d}),Y=Bn(Wn(ir(oe?.pages.flatMap(C=>C.items??[])??[])),G,P),pe=c.useCallback(C=>{x(C)},[]),ke=c.useCallback(C=>{k(H=>{const W=new Set(H);return W.has(C)?W.delete(C):W.add(C),W})},[]),ae=c.useCallback(()=>{x("all"),k(new Set)},[]),Te=Kn(b),Fe=Te?{label:Te,reach:G.length>0?"loaded-pages":Vn(A),onClear:ae}:void 0,le=l?Y.find(C=>C.messageId===a)??Y.find(C=>C.threadId===l):void 0,Be=qn(l,a),$=le??Be,N=a??$?.messageId,ce=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:$?.mailboxId??e,subject:$?.subject,messageId:N,authenticity:$?.authenticity}},[l,$,N,e]),B=c.useCallback(C=>{N&&C.includes(N)&&n()},[N,n]),{deleteMessages:De,isPending:X}=zt({mailboxId:e,onAfterOptimisticRemove:B}),{moveMessages:je,isPending:we}=Ft({mailboxId:e,accountId:P,onAfterOptimisticRemove:B}),ie=c.useRef(null),V=Hn(),{listCommandsRef:Q,onTriageContextChange:We,focusedMessageId:Ge,selectedIds:Me}=V,E=Y.find(C=>C.messageId===Ge)??$,Le=wo({accounts:d})??null,Re=Un({thread:$,isOpen:!0,mailboxId:e,accountId:P,onAfterOptimisticRemove:B}),{draftsMailboxId:Ye}=Qn(P),j=Ye!==void 0&&Ye===e,{archiveMailboxId:ft}=Jn(P),Ke=Gn(),Ee=tn(),q=c.useMemo(()=>sn(Ee,l,N),[Ee,l,N]),ue=c.useMemo(()=>{if(E)return C=>Ee({threadId:E.threadId,messageId:E.messageId,mode:C})},[Ee,E]),Xe=yo(),xe=nn(),de=Co(),Oe=c.useCallback(C=>C?Ke(C):[],[Ke]),{toggleStar:be}=Yn({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:ve}=Gt({mailboxId:e,accountId:P}),{junkMailboxId:Se}=Yt(P),Z=Se!=null&&Se===e,ee=Xt(Se,e),{candidates:Ze}=sr(Z?Se:void 0),{moveMessages:Ve}=Ft({mailboxId:e,threadId:E?.threadId,accountId:P,onAfterOptimisticRemove:B}),{deleteMessages:qe}=zt({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:B}),{addressId:ye,address:Ae}=Xn(E),{updateFlags:D}=Zn({addressId:ye,senderEmail:E?.fromEmail??void 0}),mt=c.useCallback(()=>ue?.("reply"),[ue]),gt=c.useCallback(()=>ue?.("reply-all"),[ue]),et=c.useCallback(()=>ue?.("forward"),[ue]),ne=c.useCallback(()=>Oe(E),[Oe,E]),tt=c.useCallback(()=>{if(Q.current?.requestVerb("delete"))return;const C=ne();C.length>0&&qe(C)},[Q,ne,qe]),st=c.useCallback(()=>{if(Q.current?.requestVerb("junk")||!ee)return;const C=ne();C.length!==0&&(eo(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?to(E):!1}),Ve(C,ee))},[Q,ee,ne,Ve,u,E]),nt=c.useCallback(()=>{if(Me.length>0){const C=!(E?.hasStars??!1),H=new Set(Me);for(const W of Y)H.has(W.messageId)&&W.hasStars!==C&&be(W.messageId,W.hasStars);return}E&&be(E.messageId,E.hasStars)},[Me,Y,E,be]),ot=c.useCallback(()=>{if(Q.current?.requestVerb("markRead"))return;const C=ne();if(C.length===0)return;const H=!(E?.isRead??!1);ve(C,H)},[Q,ne,E,ve]),he=c.useCallback(()=>{if(!ye)return;const C=Ae?.flags?.muted?.value!==!0;D({muted:{value:C}})},[ye,Ae,D]),it=c.useCallback(()=>{if(!ye)return;const C=Ae?.flags?.vip?.value!==!0;D({vip:{value:C}})},[ye,Ae,D]),pt=c.useCallback(()=>{ie.current?.open()},[]),_e=j?"drafts":ft===e?"archive":Se===e?"junk":"inbox",rt=c.useRef("");c.useEffect(()=>{const C=rt.current;rt.current=p,p.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:_e})},[p,_e,u]);const{goBack:xt,nextMessageId:He,previousMessageId:bt}=so({context:V,orderedIds:Y.map(C=>C.messageId),selectedMessageId:N,enabled:!Xe&&!xe,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:mt,replyAll:gt,forward:et,delete:tt,toggleStar:nt,toggleRead:ot,muteSender:he,blockSender:$?pt:void 0,vipSender:it,markJunk:st,toggleIntelligence:$?()=>ie.current?.toggle():void 0,compose:de,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),at=C=>{if(!C)return;const H=Y.find(W=>W.messageId===C);return H?{threadId:H.threadId,messageId:C}:void 0},vt={mailboxId:e,selectedMessageId:N,selectedThread:$,conversation:ce,onOpenThread:s,threads:Y,isLoading:Ce,isError:ge,error:_,mailboxAccountId:P,mailboxAccountLoading:K,mailboxName:se,unreadCount:Le,isDraftsMailbox:j,isSpamFolder:Z,rescueCandidates:Ze,filterCategory:b,filterAttributes:w,onSelectFilterCategory:pe,onToggleFilterAttribute:ke,onClearFilters:ae,listFilter:Fe,onToggleIntelligence:g,intelligenceRef:ie,handleDeselectIfRemoved:B,searchPredicate:y&&G.length===0?A:void 0,resultCount:ze,onDeleteMessages:De,onMoveMessages:je,isDeleting:X,isMoving:we,onLoadMore:re,hasMore:M,isLoadingMore:Ie,onTriageContextChange:We,listCommandsRef:Q,onRetry:()=>$e(),onReply:q,onToolbarDelete:Re.deleteThread,onToolbarStar:Re.toggleStar,isStarred:Re.isStarred,onToolbarMove:Re.moveThread,onBack:xt,nextThread:at(He),previousThread:at(bt)};return r.jsx(ls.Provider,{value:vt,children:t})}function cs(){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:y,unreadCount:S,isDraftsMailbox:I,isSpamFolder:b,rescueCandidates:x,onTriageContextChange:w,listCommandsRef:k,onRetry:T,filterCategory:R,filterAttributes:F,onSelectFilterCategory:L,onToggleFilterAttribute:G,onClearFilters:O,listFilter:A,searchPredicate:me,resultCount:z}=ht(),{searchQuery:oe,searchInput:Ce,accounts:ge,resultFolderIndex:_}=qt(),$e=Bo(),re=Je(),M=y??"Inbox",Ie=c.useMemo(()=>ao(),[]),{trashMailboxId:ze}=lo(p),P=Mo({accounts:ge}),{trashByAccount:K}=Zt(),se=er({accountId:p,mailboxId:e}),Y=ze!=null&&ze===e,pe=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:ke}=cn(),{state:ae,errorMessage:Te,refresh:Fe}=un(pe,{onSettled:T}),le=c.useMemo(()=>r.jsx(dn,{state:ae,onRefresh:Fe,label:`Refresh ${M}`,errorMessage:Te,hasUpdate:ke(pe)}),[ae,Fe,M,Te,ke,pe]),Be=c.useMemo(()=>t.map(V=>co(V,_)),[t,_]),{hits:$,isLoading:N}=Lo({mailboxId:e,filterCategory:R}),ce=c.useMemo(()=>uo($,t.map(V=>V.threadId),_),[$,t,_]),B=c.useCallback(V=>{const Q=V.threadId??t.find(We=>We.messageId===V.id)?.threadId;Q&&re({threadId:Q,messageId:V.id},{mailboxId:V.mailboxId??e,query:Ce})},[e,re,Ce,t]);if(I&&p)return r.jsx(fi,{accountId:p,selectedMessageId:o,imapThreads:t,title:y??"Drafts",unreadCount:S??void 0});const De=r.jsx(Qi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:T,searchQuery:oe,searchPredicate:me,resultCount:z,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:A,listScopeLabel:M,hideHeader:!0,onTriageContextChange:w,commandsRef:k}),X=ge[0]?.accountId,je=$e==="phone"&&X?r.jsx(Yi,{accountId:X,children:De}):De,we=b&&x.length>0&&p?r.jsx(Xi,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:je}):je,ie=Y?r.jsx(pi,{messageCount:P,isEmptying:se.isEmptying,deletedCount:se.deletedCount,refusalReason:se.refusal?.reason,trashFolderLabel:y??void 0,staleFolderLabel:p?K.get(p)?.staleFolderPath:void 0,onEmpty:se.emptyTrash,onRepair:se.repair,children:we}):we;return r.jsx(xo,{title:M,unreadCount:S,preset:Ie,selectedCategory:R,activeFilters:F,onSelectCategory:L,onToggleFilter:G,onClearFilters:O,searchResults:Be,searchLoading:s,relatedResults:ce,relatedLoading:N,onSelectSearchResult:B,searchResultsInBody:!0,refreshControl:le,children:ie})}function lr(){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}=ht(),m=!!n,p=io(n?.threadId);es(g,p);const y=c.useRef(null),{railFits:S,openRail:I}=p;c.useEffect(()=>{if(!S)return;const x=s?.messageId??null;x&&y.current!==x&&s?.authenticity?.dkimMismatch&&(y.current=x,I())},[S,I,s?.messageId,s?.authenticity?.dkimMismatch]);const b=n?r.jsx(ts,{threadId:n.threadId,mailboxId:n.mailboxId,subject:n.subject,selectedMessageId:n.messageId,authenticity:n.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(ln,{});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(ro,{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(ss,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:o,onAfterOptimisticRemove:h})]})}function cr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n}=ht();return r.jsx(oo,{onClose:s,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:n})}function ur(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=ht(),h=no(s?.threadId??null);return es(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(ts,{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(ss,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:u})]}):r.jsx(cs,{})}const zr=Object.assign(ar,{List:cs,Reading:lr,Intelligence:cr,Phone:ur});export{zr as M};
1
+ import{j as r,a1 as Is,bU as ks,bV as Ts,cK as js,B as ct,f as te,U as ws,t as Ne,g as Pt,r as c,Y as Ms,Z as Rs,bo as Es,h as Tt,c as ut,ac as Os,i as jt,cL as As,cB as Ns,I as zs,a6 as Fs,a2 as $t,bO as Ds,bi as Ls,cM as _s,cN as Ps,as as Bt,aX as $s,aY as Bs,q as wt,m as Ws,M as Wt,bl as Ks,G as Vs,bm as qs,bn as Hs,cO as Us,o as Qs,cP as Js,cz as Gs,s as Ys,cQ as Xs,cR as Zs,ch as Kt,cS as Vt,C as qt,ah as en,cT as tn,cU as sn,aj as nn,bx as on}from"./index-kBWsgSL1.js";import{u as rn,p as an,R as ln}from"./useSearchTokenContext-CtTpZfrh.js";import{u as cn,a as un,R as dn}from"./useRefreshControl-jDwAAVSL.js";import{C as Ht,a as Ut,c as Qt,j as hn,M as fn,t as Jt,u as mn,b as gn,d as Gt,e as Yt,f as pn,g as xn,h as bn,r as vn,n as Sn,i as yn,k as Cn,l as In,m as kn,o as Tn,S as jn,p as wn,D as Mn,q as Rn,s as En,v as Xt,w as On,x as An,y as Nn,z as zn,A as Fn,B as Zt,E as Dn,F as Ln,G as _n,H as Pn,I as $n,J as Bn,K as Wn,L as Kn,N as Vn,O as qn,P as zt,Q as Ft,R as Hn,T as Un,U as Qn,V as Jn,W as Gn,X as Yn,Y as Xn,Z as Zn,_ as eo,$ as to,a0 as so,a1 as no,a2 as es,a3 as ts,a4 as ss,a5 as oo,a6 as io,a7 as ro,a8 as ao,a9 as lo,aa as co,ab as uo,ac as ho}from"./MailListHeader-DwBQmyCm.js";import{S as fo,M as mo,a as go,u as po,b as xo}from"./MailViewChrome-CdYPg7kW.js";import{A as Mt}from"./avatar-BeXqEG8p.js";import{c as Qe,d as bo,e as ns}from"./format-B7kZHooA.js";import{c as vo,f as So,a as yo,u as Co}from"./useMessageBodyContent-Ddc3tsxr.js";import{g as Je,i as Io,t as ko,h as To,j as jo,k as wo,l as Mo}from"./search-token-index-DwVhD_Ps.js";import{N as Ro}from"./NavMenuButton-DEpXlqD-.js";import{C as Eo}from"./confirm-dialog-jQWOUr73.js";import{f as Oo}from"./ErrorState-DeHr3dTk.js";import{a as Ao}from"./useLabels-CSIOGq7q.js";import{L as No,r as zo,t as Fo,s as Do,u as Lo}from"./useSemanticSearch-D8FXnEuv.js";import{S as dt}from"./shield-check-yirJ7LBD.js";import{B as _o}from"./bottom-sheet-CbN20e5D.js";import{C as Po}from"./circle-help-BxPqzlGX.js";import{C as $o}from"./circle-check-B9V_jnPt.js";import{u as Bo}from"./useLayoutTier-BC3fixIj.js";import{n as Wo}from"./search-query-Cr_ZXBCp.js";import{u as Ko}from"./sections-CHQnT1gv.js";const Vo=e=>e.toLocaleString(),qo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Vo(e.value)} ${t} for “${o}”`};function Ho({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(Is,{className:"size-4 text-fg-muted","aria-hidden":"true"}),r.jsx("span",{className:"text-sm text-fg-muted",children:qo(o,e)})]})}const Uo=({children:e,onRefresh:o,isRefreshing:t})=>ks(Ts)?e:r.jsx(js,{onRefresh:o,isPullable:!t,children:e}),Qo=e=>e===1?"message":"messages";function Jo({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ct,{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(dt,{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} ${Qo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(te,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const Go=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",os=({senderTrust:e,size:o="sm",className:t})=>{const s=Go(e,o);return s==="vip"?r.jsx(ws,{className:Ne("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:Ne("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 Yo({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:Ne("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(Ht,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?l:`message from ${n}`}`}),!s&&r.jsx(Mt,{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(os,{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(Pt,{tone:"positive",children:[r.jsx(dt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const Xo=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)},Zo=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Dt=e=>e===1?"message":"messages";function ei({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,i]=c.useState(!1),l=Zo(e,o),a=e.messages.length,u=n?Ms:Rs;return r.jsxs("div",{className:Ne(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(Ht,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Dt(a)} from ${e.senderName}`}),r.jsx(Mt,{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(os,{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(Pt,{tone:"positive",children:[r.jsx(dt,{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} ${Dt(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(Yo,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const Rt=e=>e===1?"message":"messages",ti=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${Rt(e)}`} out of Spam to ${o} now. Nothing later.`,kt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function si(){return r.jsx(ct,{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 ni({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(()=>Xo(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(dt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Po,{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(si,{})})]}),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(te,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),r.jsx(te,{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(ei,{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(te,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${Rt(h)}`}),r.jsx(te,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function oi({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(Es,{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:kt(o,s)}),r.jsx(te,{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:ti(e,kt(o,s))}),r.jsx(te,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(te,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function ii({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($o,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Rt(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(te,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function ri({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,y]=c.useState(0),S=c.useRef(!1);c.useEffect(()=>{e&&!S.current&&(u("review"),h(new Set(o.map(k=>k.id))),m(t),y(0)),S.current=e},[e,o,t]);const I=d.size,b=k=>{h(T=>{const R=new Set(T);return R.has(k)?R.delete(k):R.add(k),R})},x=(k,T)=>{h(R=>{const F=new Set(R);for(const L of k.messages)T?F.add(L.id):F.delete(L.id);return F})},w=()=>{const k=Array.from(d);y(k.length),i(k,g),u("done")};return r.jsxs(_o,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(ni,{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(oi,{count:I,folders:s,delimiter:n,destination:g,onPick:m,onMove:w,onBack:()=>u("review")}),a==="done"&&r.jsx(ii,{count:p,destinationLabel:kt(s,g),onClose:l})]})}function ai(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:Qe(e.updatedAt),isRead:!0}}function li(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function ci({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===o).map(ai),n=t.map(li),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 ui=({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})]}),di=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ne("group",Qt({active:o})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Ut,{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($t,{className:"size-3.5"})})})]}),hi=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ne("group",Qt({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(Mt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Ut,{thread:e})]})};function fi({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const i=vo(),l=So(),a=Je(),u=Tt(),{data:d}=ut(Os()),h=c.useMemo(()=>ci({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=jt({...Ns(),onSuccess:()=>{u.invalidateQueries({queryKey:As()})}}),m=S=>{g.mutate({path:{outboxMessageId:S}})},p=S=>{const I=t.find(b=>b.messageId===S)?.threadId;I&&a({threadId:I,messageId:S})},y=h.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(Ro,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),(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:y?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(zs,{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(S=>r.jsxs("div",{children:[S.label&&r.jsx(ui,{label:S.label,count:S.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:S.threads.map(I=>S.id==="remit-drafts"?r.jsx(di,{row:I,isSelected:I.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},I.id):r.jsx(hi,{row:I,isSelected:I.id===o,onOpen:p},I.id))})]},S.id))})]})}const is=e=>e===1?"1 message":`${ns(e)} messages`,mi=e=>({title:"Empty Trash?",description:`${is(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),gi=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=bo(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 pi({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?gi(s,{trashFolderLabel:n,staleFolderLabel:i}):void 0,m=mi(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:`${is(t)} erased from the mail server.`}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx($t,{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(ct,{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(te,{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(Eo,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function xi(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 Pe(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 Lt(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const bi=(e,o)=>Math.abs(e-o)<1.01,vi=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Ue;const Ct=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>"u")return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;const e=navigator.maxTouchPoints;return Ue=navigator.platform==="MacIntel"&&e!==void 0&&e>0},_t=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Si=e=>e,yi=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},Ci=(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(_t(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(_t(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},lt={passive:!0},Ii=typeof window>"u"?!0:"onscrollend"in window,ki=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const i=e.options.useScrollendEvent&&Ii;let l=0;const a=i?null:vi(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,lt),i&&s.addEventListener("scrollend",h,lt),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",h)}},Ti=(e,o)=>ki(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),ji=(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"]},wi=(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})},Mi=wi;class Ri{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:Si,rangeExtractor:yi,onChange:()=>{},measureElement:ji,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,y=this.getMeasurements(),S=m>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,I=m>0?((n=y[m-1])==null?void 0:n.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==S||i.getItemKey(p-1)!==I)){d=!0;const w=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;w&&(a=[w.key,this.getScrollOffset()-w.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,y=this.getMeasurements(),{count:S,getItemKey:I}=this.options;let b=0;for(;b<S&&I(b)!==m;)b++;if(b<S){const x=y[b];if(x){const w=x.start+p;w!==this.scrollOffset&&(g=w-this.scrollOffset,this.scrollOffset=w,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=Pe(()=>(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,!(!Ct()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,lt),i.addEventListener("touchend",a,lt),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&&(Ct()&&(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=Pe(()=>[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=Pe(()=>[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 T=new Float64Array(b);x&&m>0&&T.set(x.subarray(0,m*2)),x=T,this._flatMeasurements=x}let w;if(m===0)w=s+n;else{const T=m-1;w=x[T*2]+x[T*2+1]+d}for(let T=m;T<t;T++){const R=i(T),F=g.get(R),L=typeof F=="number"?F:this.options.estimateSize(T);x[T*2]=w,x[T*2+1]=L,w+=L+d}const k=xi(t,x,i);return this.measurementsCache=k,k}const p=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),S=new Float64Array(a);let I=0;for(let b=0;b<m;b++){const x=p[b];x&&(y[x.lane]===void 0&&I++,y[x.lane]=b,S[x.lane]=x.end)}for(let b=m;b<t;b++){const x=i(b),w=this.laneAssignments.get(b);let k,T;const R=u==="estimate"||g.has(x);if(w!==void 0&&this.options.lanes>1){k=w;const O=y[k],A=O!==void 0?p[O]:void 0;T=A?A.end+d:s+n}else if(I===a){let O=0,A=S[0],me=y[0];for(let z=1;z<a;z++){const oe=S[z];(oe<A||oe===A&&y[z]<me)&&(O=z,A=oe,me=y[z])}k=O,T=A+d,R&&this.laneAssignments.set(b,k)}else k=b%this.options.lanes,T=s+n,R&&this.laneAssignments.set(b,k);const F=g.get(x),L=typeof F=="number"?F:this.options.estimateSize(b),G=T+L;p[b]={index:b,start:T,size:L,end:G,key:x,lane:k},y[k]===void 0&&I++,y[k]=b,S[k]=G}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Pe(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,i)=>t.length===0||s===0?(this.range=null,null):(this.range=Oi(t,s,n,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Pe(()=>{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,y=((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):y&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Pe(()=>[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=rs(0,s.length-1,i?a=>n[a*2]:a=>Lt(s[a]).start,t);return Lt(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&&(Ct()&&(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&&bi(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 rs=(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 Ei(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 Oi(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=Ei(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=rs(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 It=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Ai({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",y=m?"left":"top",S=d.options.scrollMargin,I=d.getVirtualItems();for(const b of I){const x=b.start-S,w=d.elementsCache.get(b.key);w&&h.lastPositions.get(w)!==x&&(h.lastPositions.set(w,x),p?w.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:w.style[y]=`${x}px`)}},a={...s,onChange:(d,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(d);const y=d.range,S=m.prevRange;p=!S||S.isScrolling!==d.isScrolling||S.startIndex!==y?.startIndex||S.endIndex!==y?.endIndex,p&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:d.isScrolling}:null)}p&&(e&&h?Ds.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Ri(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),It(()=>u._didMount(),[]),It(()=>u._willUpdate()),It(()=>{l(u)}),u}function Ni(e){return Ai({observeElementRect:Ci,observeElementOffset:Ti,scrollToFn:Mi,...e})}const Et=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",zi=e=>`Select all ${Et(e)}`,Fi=(e,o)=>`All ${ns(o)} ${Et(e)} selected`,Di=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:i})=>{if(o)return{kind:"withheld"};if(e==="junk"){const l=hn(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}},Li=(e,o,t)=>e==="BACK"&&o&&t===void 0,_i=(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Jt(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Pi=({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(fn,{thread:_i(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}}),$i=c.memo(Pi),Bi=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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Jt(e.category),suspicious:o}},Wi=({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:y})=>{const[S,I]=c.useState("none"),b=Je(),x=c.useCallback(F=>{navigator.vibrate?.(10),F==="trailing"?m(e.messageId):p(e.messageId,e.isRead),I("none")},[m,p,e.messageId,e.isRead]),w=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),k=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),T=c.useCallback(()=>{b({threadId:e.threadId,messageId:e.messageId})},[b,e.threadId,e.messageId]),R=mn(e.messageId,u);return g||d?r.jsx($i,{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:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:R.onMouseDown,onClickCapture:R.claimClick,onContextMenu:R.onContextMenu,children:r.jsx(fo,{thread:Bi(e),selectionMode:!1,checked:!1,active:t,peek:S,onPeek:I,onToggleCheck:k,onLongPress:w,onOpen:T,onAct:x})})},Ki=72,Vi=32,qi=5,as="remit:list-density",Hi=()=>{try{const e=localStorage.getItem(as);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Ui=(e,o,t)=>zo(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Qi=({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:y=!1,isLoadingMore:S=!1,accountId:I,listTitle:b,listMeta:x,listFilter:w,listScopeLabel:k,onTriageContextChange:T,commandsRef:R,hideHeader:F=!1})=>{const L=c.useRef(null),G=Je(),O=Ls(),A=_s(),{verb:me,start:z,startFromSearch:oe}=A,Ce=Ps(),ge=!!a?.trim(),_=gn(),{labels:$e}=Ao(I),{pushError:re}=Bt(),[M,Ie]=c.useState(t),[ze,P]=c.useState(),K=c.useCallback(f=>{P(v=>v===f?v:void 0),Ie(f)},[]),[se,Y]=c.useState(Hi),pe=c.useCallback(()=>{Y(f=>{const v=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(as,v)}catch{}return v})},[]),{toggleReadFor:ke}=Gt({mailboxId:e}),{junkMailboxId:ae}=Yt(I),Te=Xt(ae,e),Fe=c.useMemo(()=>[{accountId:I,mailboxId:e}],[I,e]),{outcome:le,staleFolderLabel:Be,guessedMailboxId:$}=pn(Fe),{selectedIds:N,selectedCount:ce,hasSelection:B,isSelected:De,toggle:X,select:je,clearSelection:we,selectRange:ie,setAnchor:V,selectAll:Q,toggleAll:We,intersectWith:Ge}=xn(),Me=En(ce,O),[E,Le]=c.useState(null),Re=ge&&!!u,Ye=`${e}|${JSON.stringify(u??{})}`,j=bn({mailboxId:e,accountId:I,enabled:Re,predicateKey:Ye,searchQuery:u??{}}),ft=c.useCallback((f,v,fe)=>{const U=vn(f,v,fe,le);U&&re(U)},[re,le]),Ke=j.phase.kind,Ee=j.clear,q=c.useCallback(()=>{Ke==="escalated"&&Ee(),we()},[we,Ee,Ke]),[ue,Xe]=c.useState(null),xe=c.useRef(null),de=c.useRef(!1),Oe=c.useRef(null),be=!s&&o.length>0,ve=Ni({count:o.length,getScrollElement:()=>L.current,estimateSize:()=>se==="compact"?Vi:Ki,overscan:qi}),Se=t?o.findIndex(f=>f.messageId===t):-1,Z=M?o.findIndex(f=>f.messageId===M):-1,ee=c.useCallback(f=>{if(f<0||f>=o.length)return;const v=o[f];if(Me){X(v.messageId);return}xe.current=v.messageId,de.current=!1,P(v.messageId),Ie(v.messageId)},[o,Me,X]),Ze=c.useCallback(()=>{if(o.length===0)return;const f=Z<0?0:Math.min(Z+1,o.length-1);ee(f)},[o.length,Z,ee]),Ve=c.useCallback(()=>{if(o.length===0)return;const f=Z<=0?0:Z-1;ee(f)},[o.length,Z,ee]),qe=c.useCallback(()=>ee(0),[ee]),ye=c.useCallback(()=>ee(o.length-1),[ee,o.length]),Ae=c.useCallback(()=>{M&&X(M)},[M,X]),D=c.useMemo(()=>o.map(f=>f.messageId),[o]),mt=c.useMemo(()=>{const f=[];for(const v of o)N.has(v.messageId)&&f.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:Qe(v.sentDate),accountId:I});return f},[o,N,I]),gt=c.useCallback((f,v)=>v.shiftKey?(ie(D,f,M),!0):v.metaKey||v.ctrlKey?(X(f),!0):(q(),V(f),!1),[D,M,ie,X,q,V]),et=c.useCallback(f=>{!h||f.length===0||(Oe.current=M??null,Le(f))},[h,M]),ne=c.useCallback(f=>{const v=Sn(D,M,f);v!==void 0&&(ie(D,v),xe.current=v,de.current=!1,P(void 0),Ie(v))},[D,M,ie]),tt=c.useCallback(()=>ne(-1),[ne]),st=c.useCallback(()=>ne(1),[ne]),nt=c.useCallback(()=>{D.length>0&&Q(D)},[D,Q]),ot=c.useCallback(f=>{const v=Di({verb:f,confirmingDelete:E!==null,hasSelection:B,junkMailboxId:ae,currentMailboxId:e,deletableMessageId:h?M:void 0});return v.kind==="openWizard"?(z(f),!0):v.kind==="confirmDelete"?(et([v.messageId]),!0):v.kind==="unavailable"?(re({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[E,h,B,ae,e,z,M,et,re]),he=c.useCallback((f,v)=>{const fe=o.find(U=>U.messageId===f)?.threadId;fe&&G({threadId:fe,messageId:f},{replace:v?.replace})},[G,o]),it=c.useCallback(()=>{M&&he(M)},[M,he]),pt=c.useCallback(f=>he(f,{replace:!0}),[he]);yn({keyboardFocusedMessageId:ze,openMessageId:t,enabled:O&&ce===0,open:pt});const _e=j.phase.kind==="escalated"?{scope:Et(u??{}),total:j.phase.total,searchQuery:u??{},run:f=>j.runAction(f),stop:j.stop}:void 0,rt=c.useCallback(f=>{if(f.length===0){Le(null);return}const v=new Set(f),fe=o.findIndex(J=>v.has(J.messageId));let U;for(let J=fe+1;J<o.length;J++)if(!v.has(o[J].messageId)){U=o[J].messageId;break}if(U===void 0){for(let J=fe-1;J>=0;J--)if(!v.has(o[J].messageId)){U=o[J].messageId;break}}h?.(f),q(),Oe.current=null,Le(null),U!==void 0&&(xe.current=U,de.current=!1,K(U),O&&he(U,{replace:!0})),O||Xe(Cn("delete",f.length,le))},[o,h,q,he,O,K,le]),xt=c.useCallback(()=>{const f=Oe.current;Oe.current=null,Le(null),f!==null&&(xe.current=f,de.current=!1,K(f))},[K]),He=c.useMemo(()=>Ui(o,N,I),[I,N,o]),bt=c.useCallback(()=>{if(_e){oe();return}z("organize")},[_e,oe,z]),at=c.useCallback(f=>{h?.([f])},[h]),vt=c.useCallback((f,v)=>{ke([f],!v)},[ke]),C=c.useCallback(f=>{O||je(f)},[O,je]),H=c.useCallback(()=>{if(j.isRunning||j.phase.kind==="counting"){j.stop();return}q()},[j,q]),W=c.useCallback(()=>{j.clear()},[j]);c.useEffect(()=>{if(de.current||!O&&t)return;const f=Z>=0?Z:Se;f>=0&&ve.scrollToIndex(f,{align:"auto"})},[Z,Se,ve,O,t]),c.useEffect(()=>{t&&(de.current=!1,K(t))},[t,K]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||K(o[0]?.messageId))},[o,M,K]),c.useEffect(()=>{T?.({focusedMessageId:M,selectedIds:Array.from(N),hasList:be})},[M,N,be,T]);const Ot=c.useRef(T);Ot.current=T,c.useEffect(()=>()=>Ot.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{j.phase.kind!=="idle"||j.isRunning||Ge(o.map(f=>f.messageId))},[o,Ge,j.phase,j.isRunning]);const At=c.useRef(e);c.useEffect(()=>{At.current!==e&&(At.current=e,q())},[e,q]),In({shouldBlockFn:({action:f})=>Li(f,B,Ce)?(q(),!0):!1,enableBeforeUnload:!1,disabled:!B||Ce!==void 0}),c.useEffect(()=>{const f=L.current;if(!f||!y||!p)return;const v=()=>{if(S)return;const{scrollTop:fe,scrollHeight:U,clientHeight:J}=f;fe+J>=U-200&&p()};return f.addEventListener("scroll",v,{passive:!0}),v(),()=>f.removeEventListener("scroll",v)},[y,S,p]),c.useEffect(()=>{const f=xe.current;if(!f)return;const v=L.current?.querySelector(`[data-message-id="${f}"]`);v&&(xe.current=null,v.focus({preventScroll:!0}))}),c.useEffect(()=>{if(R){if(!be){R.current=null;return}return R.current={focusNext:Ze,focusPrevious:Ve,focusFirst:qe,focusLast:ye,openFocused:it,toggleSelect:Ae,extendSelectDown:st,extendSelectUp:tt,selectAll:nt,clearSelection:()=>B?(q(),!0):!1,requestVerb:ot,toggleDensity:pe},()=>{R.current=null}}},[R,be,Ze,Ve,qe,ye,it,Ae,st,tt,nt,B,q,ot,pe]);const Nt=s?"loading":n?"error":o.length===0?"empty":"ready",us=n?Oo(i):void 0,ds=c.useCallback(()=>{const f=$s(Bs());window.open(f,"_blank","noopener,noreferrer")},[]),hs=[{id:"inbox",threads:[]}],St=D.length>0&&D.every(f=>N.has(f)),fs=Re&&y&&St&&!g&&!m&&j.phase.kind==="idle"&&!j.isRunning,ms=g||m||j.isRunning,yt=j.phase.kind==="escalated"?j.phase.total:ce,gs=j.runningAction?kn(j.runningAction.kind,j.progress?.done??0,j.progress?.total??yt):j.phase.kind==="counting"?"Counting matches…":j.phase.kind==="escalated"?Fi(u??{},j.phase.total):void 0,ps=j.phase.kind!=="escalated"&&D.length>0?{checked:St,indeterminate:ce>0&&!St,onChange:()=>We(D)}:void 0,xs=j.runningAction?{value:j.progress?.done??0,max:j.progress?.total??yt,tone:Tn(j.runningAction.kind)}:void 0,bs=(j.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:j.stop}}:j.phase.kind==="escalated"&&!j.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:W}}:fs?{tone:"info",text:"",action:{label:zi(u??{}),onClick:j.escalate}}:void 0)??(He?{tone:"warning",text:He}:void 0),vs=r.jsx(jn,{title:_.title||b,navSlot:_.navSlot,titleMeta:_.titleMeta,searchSlot:_.searchSlot,searchField:_.searchField,idleSlot:_.makeFilterSlot,count:yt,onCancel:H,onDelete:()=>z("delete"),onMove:()=>z("move"),onOrganize:bt,onJunk:Te?()=>z("junk"):void 0,onMarkRead:()=>z("markRead"),overflowSlot:I&&e&&ce>0&&$e.length>0?r.jsx(No,{accountId:I,mailboxId:e,messageIds:Array.from(N)}):void 0,isBusy:ms,isCounting:j.phase.kind==="counting",selectAll:ps,statusLabel:gs,progress:xs,notice:bs}),Ss=wn(D,M),ys=c.useCallback(f=>{de.current=!0,K(f)},[K]),Cs=r.jsxs(r.Fragment,{children:[ge&&a&&r.jsx(Ho,{query:a,count:d}),r.jsxs("div",{ref:L,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:`${ve.getTotalSize()}px`},children:ve.getVirtualItems().map(f=>{const v=o[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ve.measureElement,className:Ne("absolute left-0 top-0 w-full border-b border-line",j.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Wi,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:Ss===v.messageId,onFocusRow:ys,isChecked:De(v.messageId),onToggleCheck:X,onRowSelect:gt,isMultiSelectMode:Me,onLongPress:C,isDesktop:O,onDelete:at,onToggleRead:vt,density:se})},f.key)})}),S&&r.jsx(mo,{})]})]});return r.jsxs(r.Fragment,{children:[ue&&!O&&r.jsx(ct,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>Xe(null),children:ue}),r.jsx(go,{listTitle:b,listMeta:x,sections:hs,flatList:!0,listState:_.searchResults?"ready":Nt,searchQuery:ge?a:void 0,listFilter:w,listScopeLabel:k,errorMessage:us,onRetry:l,onReportError:ds,density:se,selectedThreadId:t,onSelectThread:f=>he(f),isDesktop:O,hideHeader:F,selectionBar:vs,listBody:_.searchResults??(Nt==="ready"?Cs:void 0)}),r.jsx(Mn,{isOpen:E!==null,messageIds:E??[],outcome:le,accountId:I,trashFolderLabel:b,staleFolderLabel:Be,guessedMailboxId:$,isDeleting:g,onConfirm:rt,onCancel:xt}),r.jsx(Rn,{verb:me,accountId:I,mailboxId:e,selection:mt,selectionRestriction:He?"spansAccounts":void 0,escalated:_e,escalatedProgress:j.progress,onFinished:q,onRunEnded:ft})]})},Ji=e=>Wt({path:{accountId:e}}),Gi=e=>{const o=Tt(),t=wt(),s=jt({...Ws(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:Ji(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Yi=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=Gi(e);return r.jsx(Uo,{onRefresh:t,isRefreshing:s,children:o})};function Xi({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[i,l]=c.useState(!1),a=wt(),u=Ks(),{inboxMailboxId:d}=On(e),h=An(e),{data:g}=ut({...Vs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>qs({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]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Nn(a,t.length))},[a,t.length]);const S=c.useCallback(()=>{zn(a,t.length),l(!0)},[a,t.length]),I=c.useCallback((b,x)=>{Fn(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(Jo,{count:t.length,onReview:S})}),r.jsx("div",{className:"min-h-0 flex-1",children:n}),r.jsx(ri,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:Hs(g?.items??[]),onConfirmMove:I,onCancel:()=>l(!1)})]})}const Zi=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,er=({accountId:e,mailboxId:o})=>{const t=Tt(),{pushError:s}=Bt(),{requestAppointment:n}=Us(),{trashByAccount:i}=Zt(),l=e?i.get(e):void 0,a=Zi(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(Qs())?.accounts.find(T=>T.accountId===e)?.folderAppointments.find(T=>T.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:p,isPending:y}=jt({...Xs(),meta:Ys(409),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,w,k)=>{k.scope===a&&d({scope:a,deletedCount:x.deletedCount})},onError:(x,w,k)=>{const T=Js(x);if(!T){s({title:"Couldn't empty Trash",detail:Gs(x),error:x});return}k?.scope===a&&d({scope:a,refusal:T})},onSettled:(x,w,k,T)=>{m.current===T?.scope&&(m.current=void 0),Io(t,ko([T?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Wt({path:{accountId:e}})})}}),S=c.useCallback(()=>e?(d({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),I=c.useCallback(()=>{S()},[S]),b=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:S})},[h,n,S]);return{emptyTrash:I,isEmptying:y&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:b}},tr="We can verify this sender";function sr(e){const{data:o}=ut({...Zs({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:tr,trustSubReason:Dn(s.senderTrust),senderTrust:s.senderTrust}))}}const nr=6e4,or=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=ut({queryKey:Kt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:i}=await Vt({path:{mailboxId:e},query:s,throwOnError:!0});return i},enabled:t,staleTime:nr});return t?Fo(n?.count):{kind:"unknown"}},ir=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t},rr=50,ls=c.createContext(null);function ht(){const e=c.useContext(ls);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function ar({mailboxId:e,thread:o,children:t}){const s=Je(),n=To(),i=Ko(),l=o?.threadId,a=o?.messageId,u=wt(),{accounts:d,searchQuery:h,onToggleIntelligence:g}=qt(),m=rn(),p=Wo(h),y=p.length>0,{freeText:S,tokens:I}=an(p,m),[b,x]=c.useState("all"),[w,k]=c.useState(new Set),T=c.useMemo(()=>({category:b,attributes:w}),[b,w]),R=c.useMemo(()=>Ln(T),[T]),F=y||_n(T),{params:L,residual:G}=Pn(I,R),O={order:"desc",...S?{query:S}:{},...L,...R},A={...O,limit:rr},me={category:A.category,unread:A.unread,starred:A.starred,attachments:A.attachments},z=F?Kt({path:{mailboxId:e},query:A}):en({path:{mailboxId:e},query:{order:"desc"}}),{data:oe,isLoading:Ce,isError:ge,error:_,refetch:$e,fetchNextPage:re,hasNextPage:M,isFetchingNextPage:Ie}=po({queryKey:z,queryFn:async({pageParam:C})=>{if(F){const{data:W}=await Vt({path:{mailboxId:e},query:{...A,continuationToken:C},throwOnError:!0});return W}const{data:H}=await on({path:{mailboxId:e},query:{order:"desc",continuationToken:C},throwOnError:!0});return H},initialPageParam:void 0,getNextPageParam:C=>C.continuationToken,placeholderData:(C,H)=>ho(H?.queryKey,me)?C:void 0}),ze=or({mailboxId:e,criteria:O,enabled:Do({hasSearchQuery:y,freeText:S,residualTokenCount:G.length})}),{accountId:P,isLoading:K}=$n(e),se=jo({accounts:d}),Y=Bn(Wn(ir(oe?.pages.flatMap(C=>C.items??[])??[])),G,P),pe=c.useCallback(C=>{x(C)},[]),ke=c.useCallback(C=>{k(H=>{const W=new Set(H);return W.has(C)?W.delete(C):W.add(C),W})},[]),ae=c.useCallback(()=>{x("all"),k(new Set)},[]),Te=Kn(b),Fe=Te?{label:Te,reach:G.length>0?"loaded-pages":Vn(A),onClear:ae}:void 0,le=l?Y.find(C=>C.messageId===a)??Y.find(C=>C.threadId===l):void 0,Be=qn(l,a),$=le??Be,N=a??$?.messageId,ce=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:$?.mailboxId??e,subject:$?.subject,messageId:N,authenticity:$?.authenticity}},[l,$,N,e]),B=c.useCallback(C=>{N&&C.includes(N)&&n()},[N,n]),{deleteMessages:De,isPending:X}=zt({mailboxId:e,onAfterOptimisticRemove:B}),{moveMessages:je,isPending:we}=Ft({mailboxId:e,accountId:P,onAfterOptimisticRemove:B}),ie=c.useRef(null),V=Hn(),{listCommandsRef:Q,onTriageContextChange:We,focusedMessageId:Ge,selectedIds:Me}=V,E=Y.find(C=>C.messageId===Ge)??$,Le=wo({accounts:d})??null,Re=Un({thread:$,isOpen:!0,mailboxId:e,accountId:P,onAfterOptimisticRemove:B}),{draftsMailboxId:Ye}=Qn(P),j=Ye!==void 0&&Ye===e,{archiveMailboxId:ft}=Jn(P),Ke=Gn(),Ee=tn(),q=c.useMemo(()=>sn(Ee,l,N),[Ee,l,N]),ue=c.useMemo(()=>{if(E)return C=>Ee({threadId:E.threadId,messageId:E.messageId,mode:C})},[Ee,E]),Xe=yo(),xe=nn(),de=Co(),Oe=c.useCallback(C=>C?Ke(C):[],[Ke]),{toggleStar:be}=Yn({threadId:E?.threadId??"",mailboxId:e}),{toggleReadFor:ve}=Gt({mailboxId:e,accountId:P}),{junkMailboxId:Se}=Yt(P),Z=Se!=null&&Se===e,ee=Xt(Se,e),{candidates:Ze}=sr(Z?Se:void 0),{moveMessages:Ve}=Ft({mailboxId:e,threadId:E?.threadId,accountId:P,onAfterOptimisticRemove:B}),{deleteMessages:qe}=zt({mailboxId:e,threadId:E?.threadId,onAfterOptimisticRemove:B}),{addressId:ye,address:Ae}=Xn(E),{updateFlags:D}=Zn({addressId:ye,senderEmail:E?.fromEmail??void 0}),mt=c.useCallback(()=>ue?.("reply"),[ue]),gt=c.useCallback(()=>ue?.("reply-all"),[ue]),et=c.useCallback(()=>ue?.("forward"),[ue]),ne=c.useCallback(()=>Oe(E),[Oe,E]),tt=c.useCallback(()=>{if(Q.current?.requestVerb("delete"))return;const C=ne();C.length>0&&qe(C)},[Q,ne,qe]),st=c.useCallback(()=>{if(Q.current?.requestVerb("junk")||!ee)return;const C=ne();C.length!==0&&(eo(u,{count:C.length,senderTrust:E?.senderTrust??"unknown",wasRescuable:E?to(E):!1}),Ve(C,ee))},[Q,ee,ne,Ve,u,E]),nt=c.useCallback(()=>{if(Me.length>0){const C=!(E?.hasStars??!1),H=new Set(Me);for(const W of Y)H.has(W.messageId)&&W.hasStars!==C&&be(W.messageId,W.hasStars);return}E&&be(E.messageId,E.hasStars)},[Me,Y,E,be]),ot=c.useCallback(()=>{if(Q.current?.requestVerb("markRead"))return;const C=ne();if(C.length===0)return;const H=!(E?.isRead??!1);ve(C,H)},[Q,ne,E,ve]),he=c.useCallback(()=>{if(!ye)return;const C=Ae?.flags?.muted?.value!==!0;D({muted:{value:C}})},[ye,Ae,D]),it=c.useCallback(()=>{if(!ye)return;const C=Ae?.flags?.vip?.value!==!0;D({vip:{value:C}})},[ye,Ae,D]),pt=c.useCallback(()=>{ie.current?.open()},[]),_e=j?"drafts":ft===e?"archive":Se===e?"junk":"inbox",rt=c.useRef("");c.useEffect(()=>{const C=rt.current;rt.current=p,p.length>0&&C.length===0&&u.recordEvent("search.submitted",{mailboxType:_e})},[p,_e,u]);const{goBack:xt,nextMessageId:He,previousMessageId:bt}=so({context:V,orderedIds:Y.map(C=>C.messageId),selectedMessageId:N,enabled:!Xe&&!xe,hasOpenThread:l!==void 0,onClose:n,handlers:{reply:mt,replyAll:gt,forward:et,delete:tt,toggleStar:nt,toggleRead:ot,muteSender:he,blockSender:$?pt:void 0,vipSender:it,markJunk:st,toggleIntelligence:$?()=>ie.current?.toggle():void 0,compose:de,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),at=C=>{if(!C)return;const H=Y.find(W=>W.messageId===C);return H?{threadId:H.threadId,messageId:C}:void 0},vt={mailboxId:e,selectedMessageId:N,selectedThread:$,conversation:ce,onOpenThread:s,threads:Y,isLoading:Ce,isError:ge,error:_,mailboxAccountId:P,mailboxAccountLoading:K,mailboxName:se,unreadCount:Le,isDraftsMailbox:j,isSpamFolder:Z,rescueCandidates:Ze,filterCategory:b,filterAttributes:w,onSelectFilterCategory:pe,onToggleFilterAttribute:ke,onClearFilters:ae,listFilter:Fe,onToggleIntelligence:g,intelligenceRef:ie,handleDeselectIfRemoved:B,searchPredicate:y&&G.length===0?A:void 0,resultCount:ze,onDeleteMessages:De,onMoveMessages:je,isDeleting:X,isMoving:we,onLoadMore:re,hasMore:M,isLoadingMore:Ie,onTriageContextChange:We,listCommandsRef:Q,onRetry:()=>$e(),onReply:q,onToolbarDelete:Re.deleteThread,onToolbarStar:Re.toggleStar,isStarred:Re.isStarred,onToolbarMove:Re.moveThread,onBack:xt,nextThread:at(He),previousThread:at(bt)};return r.jsx(ls.Provider,{value:vt,children:t})}function cs(){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:y,unreadCount:S,isDraftsMailbox:I,isSpamFolder:b,rescueCandidates:x,onTriageContextChange:w,listCommandsRef:k,onRetry:T,filterCategory:R,filterAttributes:F,onSelectFilterCategory:L,onToggleFilterAttribute:G,onClearFilters:O,listFilter:A,searchPredicate:me,resultCount:z}=ht(),{searchQuery:oe,searchInput:Ce,accounts:ge,resultFolderIndex:_}=qt(),$e=Bo(),re=Je(),M=y??"Inbox",Ie=c.useMemo(()=>ao(),[]),{trashMailboxId:ze}=lo(p),P=Mo({accounts:ge}),{trashByAccount:K}=Zt(),se=er({accountId:p,mailboxId:e}),Y=ze!=null&&ze===e,pe=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:ke}=cn(),{state:ae,errorMessage:Te,refresh:Fe}=un(pe,{onSettled:T}),le=c.useMemo(()=>r.jsx(dn,{state:ae,onRefresh:Fe,label:`Refresh ${M}`,errorMessage:Te,hasUpdate:ke(pe)}),[ae,Fe,M,Te,ke,pe]),Be=c.useMemo(()=>t.map(V=>co(V,_)),[t,_]),{hits:$,isLoading:N}=Lo({mailboxId:e,filterCategory:R}),ce=c.useMemo(()=>uo($,t.map(V=>V.threadId),_),[$,t,_]),B=c.useCallback(V=>{const Q=V.threadId??t.find(We=>We.messageId===V.id)?.threadId;Q&&re({threadId:Q,messageId:V.id},{mailboxId:V.mailboxId??e,query:Ce})},[e,re,Ce,t]);if(I&&p)return r.jsx(fi,{accountId:p,selectedMessageId:o,imapThreads:t,title:y??"Drafts",unreadCount:S??void 0});const De=r.jsx(Qi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:i,onRetry:T,searchQuery:oe,searchPredicate:me,resultCount:z,onDeleteMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:A,listScopeLabel:M,hideHeader:!0,onTriageContextChange:w,commandsRef:k}),X=ge[0]?.accountId,je=$e==="phone"&&X?r.jsx(Yi,{accountId:X,children:De}):De,we=b&&x.length>0&&p?r.jsx(Xi,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:je}):je,ie=Y?r.jsx(pi,{messageCount:P,isEmptying:se.isEmptying,deletedCount:se.deletedCount,refusalReason:se.refusal?.reason,trashFolderLabel:y??void 0,staleFolderLabel:p?K.get(p)?.staleFolderPath:void 0,onEmpty:se.emptyTrash,onRepair:se.repair,children:we}):we;return r.jsx(xo,{title:M,unreadCount:S,preset:Ie,selectedCategory:R,activeFilters:F,onSelectCategory:L,onToggleFilter:G,onClearFilters:O,searchResults:Be,searchLoading:s,relatedResults:ce,relatedLoading:N,onSelectSearchResult:B,searchResultsInBody:!0,refreshControl:le,children:ie})}function lr(){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}=ht(),m=!!n,p=io(n?.threadId);es(g,p);const y=c.useRef(null),{railFits:S,openRail:I}=p;c.useEffect(()=>{if(!S)return;const x=s?.messageId??null;x&&y.current!==x&&s?.authenticity?.dkimMismatch&&(y.current=x,I())},[S,I,s?.messageId,s?.authenticity?.dkimMismatch]);const b=n?r.jsx(ts,{threadId:n.threadId,mailboxId:n.mailboxId,subject:n.subject,selectedMessageId:n.messageId,authenticity:n.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(ln,{});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(ro,{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(ss,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:o,onAfterOptimisticRemove:h})]})}function cr(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n}=ht();return r.jsx(oo,{onClose:s,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:n})}function ur(){const{mailboxId:e,mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:u,intelligenceRef:d}=ht(),h=no(s?.threadId??null);return es(d,h),s?r.jsxs(r.Fragment,{children:[r.jsx(ts,{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(ss,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:o,onAfterOptimisticRemove:u})]}):r.jsx(cs,{})}const zr=Object.assign(ar,{List:cs,Reading:lr,Intelligence:cr,Phone:ur});export{zr as M};
@@ -1 +1 @@
1
- import{v as n,j as a,f as o}from"./index-BZwGS3k8.js";import{M as e}from"./menu-CdC5Sc0h.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
+ import{v as n,j as a,f as o}from"./index-kBWsgSL1.js";import{M as e}from"./menu-CSDPUHfq.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 ie,r as t,j as e,h as ce,i as Z,o as le,aw as de,c as q,aN as K,d as ee,f as k,L as _,B as H,aO as G,ax as ue,ay as $,n as me,I as pe}from"./index-BZwGS3k8.js";import{K as he}from"./kbd-BCbb_tUv.js";import{c as fe,d as xe,s as U,W as L,C as D,g as ye,e as X,f as ge,h as ve,b as Se,R as be,a as W,S as je}from"./credential-steps-BD-H3GsL.js";import{c as we}from"./account-form-helpers-DhckT_PN.js";import{M as Ce}from"./mail-BqMNZW4T.js";import{F as ke}from"./file-json-C9KEeUdc.js";const Q=ie("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=[{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"}}];function Y(a){return te.find(d=>d.id===a)}const Ee={"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"};function Ne(a){const d=a.indexOf("@");if(d===-1)return"";const c=a.slice(d+1).toLowerCase();return Ee[c]??""}const T=["Connector","Address","Servers","Credentials","Test","Sync"],A={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},V={host:"",port:993,security:"tls"},J={host:"",port:587,security:"starttls"};function Pe({onStart:a,onImportConfig:d}){return t.useEffect(()=>{const c=p=>{p.key==="Enter"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),e.jsx(L,{steps:T,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:d?"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:[d?e.jsx(k,{variant:"secondary",icon:e.jsx(ke,{className:"size-4"}),onClick:d,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(he,{children:"Enter"})," to continue"]}),e.jsx(k,{variant:"primary",onClick:a,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(Ce,{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."}),d&&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 Te({onContinue:a,onMicrosoft:d,onBack:c,showBack:p}){const[h,o]=t.useState("imap");t.useEffect(()=>{const y=i=>{i.key==="Enter"&&(h==="microsoft"?d():a()),i.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[a,d,c,h]);const n=()=>{h==="microsoft"?d():a()};return e.jsx(L,{steps:T,activeStep:A.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[p?e.jsx(k,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:n,children:h==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(je,{className:"size-5"}),selected:h==="imap",onSelect:()=>o("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(Q,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(pe,{className:"size-5"}),selected:h==="microsoft",onSelect:()=>o("microsoft")})]})})}function Ae({onBack:a,onConnected:d}){const[c,p]=t.useState(""),[h,o]=t.useState(null),[n,y]=t.useState(!1),[i,g]=t.useState(!1),v=t.useRef(!0);t.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const E=t.useRef(new Set),{refetch:w}=q(ee()),j=Se(r=>{if(g(!1),r==="stalled"){y(!1),o(be);return}w().then(({data:u,isError:N})=>{if(!v.current)return;if(N||!u){o("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}o(null);const C=u.accounts.find(P=>!E.current.has(P.accountId));C&&d(C.accountId)})}),S=Z({...me(),onSuccess:r=>{v.current&&(j(),y(!0),window.location.assign(r.authorizationUrl))},onError:r=>{g(!1),o(r instanceof Error?r.message:"Failed to start sign-in")}}),l=i||S.isPending,f=()=>{l||(o(null),g(!0),w().then(({data:r,isError:u})=>{if(v.current){if(u||!r){g(!1),o("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}E.current=new Set(r.accounts.map(N=>N.accountId)),S.mutate({body:{email:c.trim()||void 0}})}}))},x=t.useRef(f);return x.current=f,t.useEffect(()=>{const r=u=>{u.key==="Enter"&&x.current(),u.key==="Escape"&&a()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[a]),e.jsx(L,{steps:T,activeStep:A.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(k,{variant:"primary",onClick:f,disabled:l,icon:l?e.jsx(_,{className:"size-4 animate-spin"}):void 0,children:l?"Redirecting…":n?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx($,{id:"microsoft-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@outlook.com",value:c,onChange:r=>p(r.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."})]}),n&&e.jsx(H,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),h&&e.jsx(H,{tone:"danger",children:h})]})})}function Ie({initialEmail:a,initialDisplayName:d,onContinue:c,onBack:p}){const[h,o]=t.useState(a),[n,y]=t.useState(d),[i,g]=t.useState(!1),[v,E]=t.useState(""),[w,j]=t.useState(null),S=t.useCallback(async()=>{const l=h.trim();if(!l.includes("@")||!l.includes(".")){j("Enter a valid email address.");return}j(null),g(!0),E(ge(l));try{const f=await ve(l);c(l,n.trim(),f)}finally{g(!1)}},[h,n,c]);return t.useEffect(()=>{const l=f=>{f.key==="Enter"&&!i&&S(),f.key==="Escape"&&p()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[S,i,p]),e.jsx(L,{steps:T,activeStep:A.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:p,children:"Back"}),e.jsx(k,{variant:"primary",disabled:i,onClick:()=>{S()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx($,{id:"onboarding-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@example.com",value:h,onChange:l=>{o(l.target.value),j(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx($,{id:"onboarding-display-name",placeholder:"Alice",value:n,onChange:l=>y(l.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."})]}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(_,{className:"size-3.5 animate-spin text-accent"}),v]}),w&&!i&&e.jsx("div",{className:"mt-3",children:e.jsx(H,{tone:"danger",children:w})})]})})}function Me({email:a,imapConfig:d,smtpConfig:c,discovered:p,onContinue:h,onBack:o,onChange:n}){const[y,i]=t.useState(d),[g,v]=t.useState(c),[E,w]=t.useState(()=>Ne(a)),[j,S]=t.useState(!1),[l,f]=t.useState(null),x=Y(E),r=x!==void 0&&!j,u=t.useCallback(m=>{w(m),S(!1),f(null);const s=Y(m);s&&(i({host:s.imap.host,port:s.imap.port,security:s.imap.security}),v({host:s.smtp.host,port:s.smtp.port,security:s.smtp.security}))},[]);t.useEffect(()=>{n(y,g)},[y,g,n]);const N=y.host.trim()!=="",C=t.useCallback(()=>{if(!N){f("Enter the IMAP host.");return}f(null),h()},[N,h]);t.useEffect(()=>{const m=s=>{s.key==="Enter"&&C(),s.key==="Escape"&&o()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[C,o]);const P=a.split("@")[1]??"your domain",F=x?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":p?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${P} — enter them manually.`,I=r?{label:"preset",tone:"neutral"}:!x&&p?{label:"detected",tone:"positive"}:void 0,M=x?.passwordHelp.url??ye(a);return e.jsx(L,{steps:T,activeStep:A.servers,title:"Confirm server settings",subtitle:F,footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(k,{variant:"primary",onClick:C,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[l&&e.jsx(H,{tone:"danger",children:l}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(ue,{id:"provider-select",value:E,onChange:m=>u(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),te.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),x&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:r?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",x.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>S(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",x.label,"'s settings by hand."]})})]}),e.jsx(X,{legend:"IMAP — incoming",badge:I,readOnly:r,host:y.host,port:String(y.port),security:y.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{i(s=>({...s,host:m})),f(null)},onPortChange:m=>i(s=>({...s,port:Number(m)})),onSecurityChange:m=>i(s=>({...s,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(X,{legend:"SMTP — outgoing (optional)",badge:I,readOnly:r,host:g.host,port:String(g.port),security:g.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{v(s=>({...s,host:m})),f(null)},onPortChange:m=>v(s=>({...s,port:Number(m)})),onSecurityChange:m=>v(s=>({...s,security:m}))}),x&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[x.passwordHelp.text," ",M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Le=2e4;function Fe({email:a,displayName:d,imapConfig:c,smtpConfig:p,username:h,password:o,onGoToInbox:n}){const y=ce(),[i,g]=t.useState(null),[v,E]=t.useState(null),w=t.useRef(!1),j=U(c.security),S=U(p.security),l=Z({...de(),onSuccess:b=>{g(b.accountId),y.invalidateQueries({queryKey:le()})},onError:b=>{E(b instanceof Error?b.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const b=p.host.trim()!=="",O=we({imapHost:c.host,smtpHost:p.host,smtpPort:p.port}),R=b?O??{smtpHost:p.host,smtpPort:p.port,smtpTls:S.tls,smtpStartTls:S.startTls}:null;l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:R?.smtpHost||void 0,smtpPort:R?.smtpPort||void 0,smtpTls:R?.smtpTls??!1,smtpStartTls:R?.smtpStartTls??!1}})},[]);const{data:f,isError:x}=q({...K({path:{accountId:i??""}}),enabled:!!i,refetchInterval:b=>{const O=b.state.data?.syncPhase;return O==="complete"||O==="error"?!1:2e3}}),r=f?.syncPhase==="error",{data:u}=q({...ee(),enabled:!!i&&r}),N=u?.accounts.find(b=>b.accountId===i)?.lastError,C=f?.mailboxes.find(b=>b.fullPath==="INBOX"||b.fullPath==="Inbox"),P=f?.mailboxCountTotal??0,F=f?.mailboxCountSynced??0,I=C?.messagesTotal??0,M=C?.messagesSynced??0,m=I>0?M/I:0,s=f?.syncPhase,se=r?"failed":s==="idle"||s===void 0||s==="discovering_mailboxes"?"running":P>0?"ok":"running",z=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"?"pending":s==="syncing_inbox"||s==="syncing_others"?"running":"ok",B=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"||s==="syncing_inbox"?"pending":s==="syncing_others"?"running":"ok",ne=M>0||C?.phase==="complete"||s==="complete"||r,[ae,oe]=t.useState(!1);t.useEffect(()=>{if(!i)return;const b=setTimeout(()=>oe(!0),Le);return()=>clearTimeout(b)},[i]);const re=!!i&&(ne||x||ae);return v?e.jsx(L,{steps:T,activeStep:A.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:()=>{w.current=!1,E(null),l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:p.host||void 0,smtpPort:p.port||void 0,smtpTls:S.tls,smtpStartTls:S.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:v})}):e.jsx(L,{steps:T,activeStep:A.sync,title:`Syncing ${a}`,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"}),re?e.jsx(k,{variant:"primary",onClick:()=>i&&n(i),children:"Go to inbox"}):e.jsx(k,{variant:"primary",disabled:!0,icon:e.jsx(_,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:l.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(_,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[I>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:[M.toLocaleString()," / ",I.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(D,{label:"Mailboxes discovered",detail:P>0?`${P} mailbox${P===1?"":"es"} found`:"Discovering…",state:se}),e.jsx(D,{label:"INBOX",detail:z==="ok"?`${M.toLocaleString()} messages synced`:z==="running"?"Syncing newest first…":"Queued",state:z}),F>1||s==="syncing_others"||s==="complete"?e.jsx(D,{label:"Other mailboxes",detail:B==="ok"?`${F-1} mailboxes synced`:B==="running"?"Syncing…":"Queued",state:B}):null]}),r&&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:()=>{y.invalidateQueries({queryKey:K({path:{accountId:i??""}}).queryKey})},children:"retry"})]}),N&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:N})]})]})})}function Be({skipWelcome:a=!1,onComplete:d,onCancel:c,onImportConfig:p}){const[h,o]=t.useState(a?"connector":"welcome"),[n,y]=t.useState({email:"",displayName:"",imapConfig:V,smtpConfig:J,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),i=t.useCallback(()=>o("connector"),[]),g=t.useCallback(()=>o("address"),[]),v=t.useCallback(()=>o("microsoft-email"),[]),E=t.useCallback(()=>{a?c?.():o("welcome")},[a,c]),w=t.useCallback((x,r,u)=>{let N=V,C=J,P=!1;u&&(P=u.source!=="heuristic",N={host:u.imap.host,port:u.imap.port,security:u.imap.security},C={host:u.smtp.host,port:u.smtp.port,security:u.smtp.security}),y(F=>({...F,email:x,displayName:r,imapConfig:N,smtpConfig:C,discoveryResult:u,discovered:P,username:x})),o("servers")},[]),j=t.useCallback((x,r)=>{y(u=>({...u,imapConfig:x,smtpConfig:r}))},[]),S=t.useCallback((x,r)=>{y(u=>({...u,username:x,password:r}))},[]),l=t.useCallback(()=>o("sync"),[]),f=t.useCallback(x=>{d(x)},[d]);switch(h){case"welcome":return e.jsx(Pe,{onStart:i,onImportConfig:p});case"connector":return e.jsx(Te,{onContinue:g,onMicrosoft:v,onBack:E,showBack:!a});case"microsoft-email":return e.jsx(Ae,{onBack:()=>o("connector"),onConnected:f});case"address":return e.jsx(Ie,{initialEmail:n.email,initialDisplayName:n.displayName,onContinue:w,onBack:()=>o("connector")});case"servers":return e.jsx(Me,{email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,discovered:n.discovered,onContinue:()=>o("credentials"),onBack:()=>o("address"),onChange:j});case"credentials":return e.jsx(xe,{steps:T,activeStep:A.credentials,title:`Sign in to ${n.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:n.email,username:n.username,password:n.password,onContinue:()=>o("test"),onBack:()=>o("servers"),onChange:S});case"test":return e.jsx(fe,{steps:T,activeStep:A.test,email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onSuccess:l,onBackToCredentials:()=>o("credentials"),onBackToServers:()=>o("servers")});case"sync":return e.jsx(Fe,{email:n.email,displayName:n.displayName,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onGoToInbox:f})}}export{Be as O,te as P,Y as g};
1
+ import{e as ie,r as t,j as e,h as ce,i as Z,o as le,aw as de,c as q,aN as K,d as ee,f as k,L as _,B as H,aO as G,ax as ue,ay as $,n as me,I as pe}from"./index-kBWsgSL1.js";import{K as he}from"./kbd-D4H0AykE.js";import{c as fe,d as xe,s as U,W as L,C as D,g as ye,e as X,f as ge,h as ve,b as Se,R as be,a as W,S as je}from"./credential-steps-BMoVlEPM.js";import{c as we}from"./account-form-helpers-DhckT_PN.js";import{M as Ce}from"./mail-z5ZuLbER.js";import{F as ke}from"./file-json-ND_vvGBa.js";const Q=ie("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=[{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"}}];function Y(a){return te.find(d=>d.id===a)}const Ee={"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"};function Ne(a){const d=a.indexOf("@");if(d===-1)return"";const c=a.slice(d+1).toLowerCase();return Ee[c]??""}const T=["Connector","Address","Servers","Credentials","Test","Sync"],A={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},V={host:"",port:993,security:"tls"},J={host:"",port:587,security:"starttls"};function Pe({onStart:a,onImportConfig:d}){return t.useEffect(()=>{const c=p=>{p.key==="Enter"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),e.jsx(L,{steps:T,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:d?"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:[d?e.jsx(k,{variant:"secondary",icon:e.jsx(ke,{className:"size-4"}),onClick:d,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(he,{children:"Enter"})," to continue"]}),e.jsx(k,{variant:"primary",onClick:a,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(Ce,{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."}),d&&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 Te({onContinue:a,onMicrosoft:d,onBack:c,showBack:p}){const[h,o]=t.useState("imap");t.useEffect(()=>{const y=i=>{i.key==="Enter"&&(h==="microsoft"?d():a()),i.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[a,d,c,h]);const n=()=>{h==="microsoft"?d():a()};return e.jsx(L,{steps:T,activeStep:A.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[p?e.jsx(k,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:n,children:h==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(je,{className:"size-5"}),selected:h==="imap",onSelect:()=>o("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(Q,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(pe,{className:"size-5"}),selected:h==="microsoft",onSelect:()=>o("microsoft")})]})})}function Ae({onBack:a,onConnected:d}){const[c,p]=t.useState(""),[h,o]=t.useState(null),[n,y]=t.useState(!1),[i,g]=t.useState(!1),v=t.useRef(!0);t.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const E=t.useRef(new Set),{refetch:w}=q(ee()),j=Se(r=>{if(g(!1),r==="stalled"){y(!1),o(be);return}w().then(({data:u,isError:N})=>{if(!v.current)return;if(N||!u){o("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}o(null);const C=u.accounts.find(P=>!E.current.has(P.accountId));C&&d(C.accountId)})}),S=Z({...me(),onSuccess:r=>{v.current&&(j(),y(!0),window.location.assign(r.authorizationUrl))},onError:r=>{g(!1),o(r instanceof Error?r.message:"Failed to start sign-in")}}),l=i||S.isPending,f=()=>{l||(o(null),g(!0),w().then(({data:r,isError:u})=>{if(v.current){if(u||!r){g(!1),o("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}E.current=new Set(r.accounts.map(N=>N.accountId)),S.mutate({body:{email:c.trim()||void 0}})}}))},x=t.useRef(f);return x.current=f,t.useEffect(()=>{const r=u=>{u.key==="Enter"&&x.current(),u.key==="Escape"&&a()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[a]),e.jsx(L,{steps:T,activeStep:A.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(k,{variant:"primary",onClick:f,disabled:l,icon:l?e.jsx(_,{className:"size-4 animate-spin"}):void 0,children:l?"Redirecting…":n?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx($,{id:"microsoft-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@outlook.com",value:c,onChange:r=>p(r.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."})]}),n&&e.jsx(H,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),h&&e.jsx(H,{tone:"danger",children:h})]})})}function Ie({initialEmail:a,initialDisplayName:d,onContinue:c,onBack:p}){const[h,o]=t.useState(a),[n,y]=t.useState(d),[i,g]=t.useState(!1),[v,E]=t.useState(""),[w,j]=t.useState(null),S=t.useCallback(async()=>{const l=h.trim();if(!l.includes("@")||!l.includes(".")){j("Enter a valid email address.");return}j(null),g(!0),E(ge(l));try{const f=await ve(l);c(l,n.trim(),f)}finally{g(!1)}},[h,n,c]);return t.useEffect(()=>{const l=f=>{f.key==="Enter"&&!i&&S(),f.key==="Escape"&&p()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[S,i,p]),e.jsx(L,{steps:T,activeStep:A.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:p,children:"Back"}),e.jsx(k,{variant:"primary",disabled:i,onClick:()=>{S()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx($,{id:"onboarding-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@example.com",value:h,onChange:l=>{o(l.target.value),j(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx($,{id:"onboarding-display-name",placeholder:"Alice",value:n,onChange:l=>y(l.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."})]}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(_,{className:"size-3.5 animate-spin text-accent"}),v]}),w&&!i&&e.jsx("div",{className:"mt-3",children:e.jsx(H,{tone:"danger",children:w})})]})})}function Me({email:a,imapConfig:d,smtpConfig:c,discovered:p,onContinue:h,onBack:o,onChange:n}){const[y,i]=t.useState(d),[g,v]=t.useState(c),[E,w]=t.useState(()=>Ne(a)),[j,S]=t.useState(!1),[l,f]=t.useState(null),x=Y(E),r=x!==void 0&&!j,u=t.useCallback(m=>{w(m),S(!1),f(null);const s=Y(m);s&&(i({host:s.imap.host,port:s.imap.port,security:s.imap.security}),v({host:s.smtp.host,port:s.smtp.port,security:s.smtp.security}))},[]);t.useEffect(()=>{n(y,g)},[y,g,n]);const N=y.host.trim()!=="",C=t.useCallback(()=>{if(!N){f("Enter the IMAP host.");return}f(null),h()},[N,h]);t.useEffect(()=>{const m=s=>{s.key==="Enter"&&C(),s.key==="Escape"&&o()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[C,o]);const P=a.split("@")[1]??"your domain",F=x?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":p?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${P} — enter them manually.`,I=r?{label:"preset",tone:"neutral"}:!x&&p?{label:"detected",tone:"positive"}:void 0,M=x?.passwordHelp.url??ye(a);return e.jsx(L,{steps:T,activeStep:A.servers,title:"Confirm server settings",subtitle:F,footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(k,{variant:"primary",onClick:C,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[l&&e.jsx(H,{tone:"danger",children:l}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(ue,{id:"provider-select",value:E,onChange:m=>u(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),te.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),x&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:r?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",x.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>S(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",x.label,"'s settings by hand."]})})]}),e.jsx(X,{legend:"IMAP — incoming",badge:I,readOnly:r,host:y.host,port:String(y.port),security:y.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{i(s=>({...s,host:m})),f(null)},onPortChange:m=>i(s=>({...s,port:Number(m)})),onSecurityChange:m=>i(s=>({...s,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(X,{legend:"SMTP — outgoing (optional)",badge:I,readOnly:r,host:g.host,port:String(g.port),security:g.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{v(s=>({...s,host:m})),f(null)},onPortChange:m=>v(s=>({...s,port:Number(m)})),onSecurityChange:m=>v(s=>({...s,security:m}))}),x&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[x.passwordHelp.text," ",M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Le=2e4;function Fe({email:a,displayName:d,imapConfig:c,smtpConfig:p,username:h,password:o,onGoToInbox:n}){const y=ce(),[i,g]=t.useState(null),[v,E]=t.useState(null),w=t.useRef(!1),j=U(c.security),S=U(p.security),l=Z({...de(),onSuccess:b=>{g(b.accountId),y.invalidateQueries({queryKey:le()})},onError:b=>{E(b instanceof Error?b.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const b=p.host.trim()!=="",O=we({imapHost:c.host,smtpHost:p.host,smtpPort:p.port}),R=b?O??{smtpHost:p.host,smtpPort:p.port,smtpTls:S.tls,smtpStartTls:S.startTls}:null;l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:R?.smtpHost||void 0,smtpPort:R?.smtpPort||void 0,smtpTls:R?.smtpTls??!1,smtpStartTls:R?.smtpStartTls??!1}})},[]);const{data:f,isError:x}=q({...K({path:{accountId:i??""}}),enabled:!!i,refetchInterval:b=>{const O=b.state.data?.syncPhase;return O==="complete"||O==="error"?!1:2e3}}),r=f?.syncPhase==="error",{data:u}=q({...ee(),enabled:!!i&&r}),N=u?.accounts.find(b=>b.accountId===i)?.lastError,C=f?.mailboxes.find(b=>b.fullPath==="INBOX"||b.fullPath==="Inbox"),P=f?.mailboxCountTotal??0,F=f?.mailboxCountSynced??0,I=C?.messagesTotal??0,M=C?.messagesSynced??0,m=I>0?M/I:0,s=f?.syncPhase,se=r?"failed":s==="idle"||s===void 0||s==="discovering_mailboxes"?"running":P>0?"ok":"running",z=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"?"pending":s==="syncing_inbox"||s==="syncing_others"?"running":"ok",B=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"||s==="syncing_inbox"?"pending":s==="syncing_others"?"running":"ok",ne=M>0||C?.phase==="complete"||s==="complete"||r,[ae,oe]=t.useState(!1);t.useEffect(()=>{if(!i)return;const b=setTimeout(()=>oe(!0),Le);return()=>clearTimeout(b)},[i]);const re=!!i&&(ne||x||ae);return v?e.jsx(L,{steps:T,activeStep:A.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:()=>{w.current=!1,E(null),l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:p.host||void 0,smtpPort:p.port||void 0,smtpTls:S.tls,smtpStartTls:S.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:v})}):e.jsx(L,{steps:T,activeStep:A.sync,title:`Syncing ${a}`,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"}),re?e.jsx(k,{variant:"primary",onClick:()=>i&&n(i),children:"Go to inbox"}):e.jsx(k,{variant:"primary",disabled:!0,icon:e.jsx(_,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:l.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(_,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[I>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:[M.toLocaleString()," / ",I.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(D,{label:"Mailboxes discovered",detail:P>0?`${P} mailbox${P===1?"":"es"} found`:"Discovering…",state:se}),e.jsx(D,{label:"INBOX",detail:z==="ok"?`${M.toLocaleString()} messages synced`:z==="running"?"Syncing newest first…":"Queued",state:z}),F>1||s==="syncing_others"||s==="complete"?e.jsx(D,{label:"Other mailboxes",detail:B==="ok"?`${F-1} mailboxes synced`:B==="running"?"Syncing…":"Queued",state:B}):null]}),r&&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:()=>{y.invalidateQueries({queryKey:K({path:{accountId:i??""}}).queryKey})},children:"retry"})]}),N&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:N})]})]})})}function Be({skipWelcome:a=!1,onComplete:d,onCancel:c,onImportConfig:p}){const[h,o]=t.useState(a?"connector":"welcome"),[n,y]=t.useState({email:"",displayName:"",imapConfig:V,smtpConfig:J,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),i=t.useCallback(()=>o("connector"),[]),g=t.useCallback(()=>o("address"),[]),v=t.useCallback(()=>o("microsoft-email"),[]),E=t.useCallback(()=>{a?c?.():o("welcome")},[a,c]),w=t.useCallback((x,r,u)=>{let N=V,C=J,P=!1;u&&(P=u.source!=="heuristic",N={host:u.imap.host,port:u.imap.port,security:u.imap.security},C={host:u.smtp.host,port:u.smtp.port,security:u.smtp.security}),y(F=>({...F,email:x,displayName:r,imapConfig:N,smtpConfig:C,discoveryResult:u,discovered:P,username:x})),o("servers")},[]),j=t.useCallback((x,r)=>{y(u=>({...u,imapConfig:x,smtpConfig:r}))},[]),S=t.useCallback((x,r)=>{y(u=>({...u,username:x,password:r}))},[]),l=t.useCallback(()=>o("sync"),[]),f=t.useCallback(x=>{d(x)},[d]);switch(h){case"welcome":return e.jsx(Pe,{onStart:i,onImportConfig:p});case"connector":return e.jsx(Te,{onContinue:g,onMicrosoft:v,onBack:E,showBack:!a});case"microsoft-email":return e.jsx(Ae,{onBack:()=>o("connector"),onConnected:f});case"address":return e.jsx(Ie,{initialEmail:n.email,initialDisplayName:n.displayName,onContinue:w,onBack:()=>o("connector")});case"servers":return e.jsx(Me,{email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,discovered:n.discovered,onContinue:()=>o("credentials"),onBack:()=>o("address"),onChange:j});case"credentials":return e.jsx(xe,{steps:T,activeStep:A.credentials,title:`Sign in to ${n.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:n.email,username:n.username,password:n.password,onContinue:()=>o("test"),onBack:()=>o("servers"),onChange:S});case"test":return e.jsx(fe,{steps:T,activeStep:A.test,email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onSuccess:l,onBackToCredentials:()=>o("credentials"),onBackToServers:()=>o("servers")});case"sync":return e.jsx(Fe,{email:n.email,displayName:n.displayName,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onGoToInbox:f})}}export{Be as O,te as P,Y as g};
@@ -1,2 +1,2 @@
1
- import{j as e,t as h,f as S,a2 as V,X as Y,c as K,en as Q,s as X,V as H,_ as J,r as C}from"./index-BZwGS3k8.js";import{u as ee,t as se,C as te,d as ae,p as ne}from"./CalendarComposePane-CzeHqJlY.js";import{c as re,R as ie}from"./calendar-color-BvNkz_IE.js";import{R as oe,A as le}from"./attendee-row-C96YrC-H.js";import{C as ce}from"./clock-BwWVGnWa.js";import{G as U,M as de}from"./map-pin-BeaC8Rf9.js";import{M as xe}from"./mail-BqMNZW4T.js";import{P as me}from"./pencil-Cokk0JIp.js";import{u as fe,c as ue,U as he}from"./useCalendars-C_zzTvbg.js";import{c as pe}from"./useCalendarData-DM1eFwRx.js";import{u as ge,b as ve}from"./window-ven3SsTb.js";function v({icon:s,children:t}){return e.jsxs("div",{className:"flex items-start gap-2.5 py-1",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle",children:s}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-fg",children:t})]})}function be({event:s,calendar:t,whenText:n,onEdit:a,onDelete:o,onOpenThread:l,onClose:c,activeAttendee:x="",onActivateAttendee:b,renderAttendeeContext:k,touch:E=!1,chrome:D="header",className:r}){const R=re(t.color),d=e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s.title}),e.jsxs("div",{className:"mt-3 flex flex-col border-b border-line pb-3",children:[e.jsx(v,{icon:e.jsx(ce,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[n,s.attendees.length>0&&e.jsx(oe,{rsvp:s.myRsvp})]})}),s.zoneCertainty==="ambiguous"?e.jsx(v,{icon:e.jsx(U,{className:"size-4 text-warning"}),children:e.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."})}):s.timeZone!==""&&e.jsx(v,{icon:e.jsx(U,{className:"size-4"}),children:s.timeZone}),s.recurrenceRule!==""&&e.jsx(v,{icon:e.jsx(ie,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[s.recurrenceRule,s.seriesException&&e.jsx("span",{className:"rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning",children:"Moved out of the series"})]})}),s.location!==""&&e.jsx(v,{icon:e.jsx(de,{className:"size-4"}),children:s.location})]}),s.threadId!==""&&l&&e.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:[e.jsx(xe,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:"From this thread"}),e.jsx("span",{className:"block truncate text-sm text-fg",children:s.threadSubject})]})]}),s.attendees.length>0&&e.jsx(le,{attendees:s.attendees,activeEmail:x,onActivate:b,renderContext:k,touch:E,className:"mt-3"}),s.notes!==""&&e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-fg-muted",children:s.notes})]});return D==="bare"?e.jsx("div",{className:h("flex flex-col",r),children:d}):e.jsxs("article",{className:h("flex h-full w-full flex-col bg-surface",r),children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx("span",{className:h("size-2.5 shrink-0 rounded-full",R.solid)}),e.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:[t.name," · ",t.accountLabel]}),a&&e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(me,{className:"size-3.5"}),onClick:a,children:"Edit"}),o&&e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(V,{className:"size-3.5"}),onClick:o,className:"text-danger",children:"Delete"}),c&&e.jsx("button",{type:"button","aria-label":"Close event",onClick:c,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:e.jsx(Y,{className:"size-4"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-3",children:d})]})}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 Ne({title:s,ruleText:t,instanceText:n,onChoose:a,onCancel:o,touch:l,className:c}){return e.jsxs("div",{className:h("flex flex-col gap-3",c),children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-md font-semibold text-fg",children:[s," repeats"]}),e.jsx("p",{className:"text-xs text-fg-muted",children:t}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",n,"."]})]}),e.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:je.map(x=>e.jsxs("button",{type:"button",onClick:()=>a(x.scope),className:h("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:[e.jsx("span",{className:"text-sm font-medium text-fg",children:x.label}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:x.note})]},x.scope))}),e.jsx(S,{variant:"ghost",size:l?"md":"sm",onClick:o,className:h("self-start",l&&"min-h-11"),children:"Cancel"})]})}const we=s=>s.replace(/\r?\n[ \t]/g,""),Z=s=>s.replace(/\\n/gi,`
1
+ import{j as e,t as h,f as S,a2 as V,X as Y,c as K,en as Q,s as X,V as H,_ as J,r as C}from"./index-kBWsgSL1.js";import{u as ee,t as se,C as te,d as ae,p as ne}from"./CalendarComposePane-qouJ2ac1.js";import{c as re,R as ie}from"./calendar-color-CkDge1Jd.js";import{R as oe,A as le}from"./attendee-row-B4trWaMp.js";import{C as ce}from"./clock-VKZRK796.js";import{G as U,M as de}from"./map-pin-CIJo6NcM.js";import{M as xe}from"./mail-z5ZuLbER.js";import{P as me}from"./pencil-Cd4AX53X.js";import{u as fe,c as ue,U as he}from"./useCalendars-DwzgQIxe.js";import{c as pe}from"./useCalendarData-ZpdXYEEI.js";import{u as ge,b as ve}from"./window-CgA4ilXA.js";function v({icon:s,children:t}){return e.jsxs("div",{className:"flex items-start gap-2.5 py-1",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle",children:s}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-fg",children:t})]})}function be({event:s,calendar:t,whenText:n,onEdit:a,onDelete:o,onOpenThread:l,onClose:c,activeAttendee:x="",onActivateAttendee:b,renderAttendeeContext:k,touch:E=!1,chrome:D="header",className:r}){const R=re(t.color),d=e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s.title}),e.jsxs("div",{className:"mt-3 flex flex-col border-b border-line pb-3",children:[e.jsx(v,{icon:e.jsx(ce,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[n,s.attendees.length>0&&e.jsx(oe,{rsvp:s.myRsvp})]})}),s.zoneCertainty==="ambiguous"?e.jsx(v,{icon:e.jsx(U,{className:"size-4 text-warning"}),children:e.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."})}):s.timeZone!==""&&e.jsx(v,{icon:e.jsx(U,{className:"size-4"}),children:s.timeZone}),s.recurrenceRule!==""&&e.jsx(v,{icon:e.jsx(ie,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[s.recurrenceRule,s.seriesException&&e.jsx("span",{className:"rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning",children:"Moved out of the series"})]})}),s.location!==""&&e.jsx(v,{icon:e.jsx(de,{className:"size-4"}),children:s.location})]}),s.threadId!==""&&l&&e.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:[e.jsx(xe,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:"From this thread"}),e.jsx("span",{className:"block truncate text-sm text-fg",children:s.threadSubject})]})]}),s.attendees.length>0&&e.jsx(le,{attendees:s.attendees,activeEmail:x,onActivate:b,renderContext:k,touch:E,className:"mt-3"}),s.notes!==""&&e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-fg-muted",children:s.notes})]});return D==="bare"?e.jsx("div",{className:h("flex flex-col",r),children:d}):e.jsxs("article",{className:h("flex h-full w-full flex-col bg-surface",r),children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx("span",{className:h("size-2.5 shrink-0 rounded-full",R.solid)}),e.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:[t.name," · ",t.accountLabel]}),a&&e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(me,{className:"size-3.5"}),onClick:a,children:"Edit"}),o&&e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(V,{className:"size-3.5"}),onClick:o,className:"text-danger",children:"Delete"}),c&&e.jsx("button",{type:"button","aria-label":"Close event",onClick:c,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:e.jsx(Y,{className:"size-4"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-3",children:d})]})}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 Ne({title:s,ruleText:t,instanceText:n,onChoose:a,onCancel:o,touch:l,className:c}){return e.jsxs("div",{className:h("flex flex-col gap-3",c),children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-md font-semibold text-fg",children:[s," repeats"]}),e.jsx("p",{className:"text-xs text-fg-muted",children:t}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",n,"."]})]}),e.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:je.map(x=>e.jsxs("button",{type:"button",onClick:()=>a(x.scope),className:h("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:[e.jsx("span",{className:"text-sm font-medium text-fg",children:x.label}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:x.note})]},x.scope))}),e.jsx(S,{variant:"ghost",size:l?"md":"sm",onClick:o,className:h("self-start",l&&"min-h-11"),children:"Cancel"})]})}const we=s=>s.replace(/\r?\n[ \t]/g,""),Z=s=>s.replace(/\\n/gi,`
2
2
  `).replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\\\/g,"\\");function Ce(s,t){let n=!1;for(let a=t.length;a<s.length;a+=1){const o=s[a];if(a===t.length&&o!==";"&&o!==":")return;if(o==='"'){n=!n;continue}if(!n&&o===":")return s.slice(a+1).trim()}}function A(s,t){for(const n of we(s).split(/\r?\n/)){if(!n.startsWith(t))continue;const a=Ce(n,t);if(a!==void 0)return a}return""}const ye=s=>A(s,"RRULE"),ke=s=>({location:Z(A(s,"LOCATION")),description:Z(A(s,"DESCRIPTION"))}),Ee=X(404);function De(s,t){const{data:n,isLoading:a,error:o,refetch:l}=K({...Q({path:{calendarObjectId:s},query:{calendarId:t}}),meta:Ee,enabled:s!==""&&t!==""});return{resource:n,isLoading:a,error:o,refetch:()=>{l()}}}const z=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),y=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});function G(s){const t=new Date(s.start),n=new Date(s.end),a=z.format(t);return s.allDay?`${a}, all day`:z.format(n)===a?`${a}, ${y.format(t)} – ${y.format(n)}`:`${a}, ${y.format(t)} – ${z.format(n)}, ${y.format(n)}`}function Re({event:s,calendar:t,isOccurrence:n,problem:a="",onEdit:o,onDelete:l,onClose:c}){return!s||!t?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center",children:[e.jsx(H,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"That event isn't on this week"}),e.jsx("p",{className:"max-w-xs text-sm text-fg-muted",children:"The address names an event the calendar doesn't have here."}),e.jsx("button",{type:"button",onClick:c,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:"Back to the calendar"})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[n&&e.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"}),a!==""&&e.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:[e.jsx(J,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:a})]}),e.jsx(be,{event:s,calendar:t,whenText:G(s),onEdit:o,onDelete:l,onClose:c,className:"min-h-0 flex-1"})]})}const Te="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 Be({calendarObjectId:s,recurrenceId:t}){const{view:n,date:a,calendarIds:o}=ge(),{events:l}=pe({view:n,date:a,calendarIds:o}),{calendars:c,timeZoneByCalendarId:x}=fe(),{closeEvent:b}=ve(),{updateEvent:k,deleteEvent:E,isWriting:D}=ee(),r=l.find(i=>i.id===ue(s,t??"")),R=c.find(i=>i.id===r?.calendarId),{resource:d}=De(s,r?.calendarId??""),[I,p]=C.useState(void 0),[f,T]=C.useState(void 0),[u,j]=C.useState(void 0),[L,g]=C.useState(""),N=d?ke(d.icalData):void 0,F=d?ye(d.icalData):"",_=r&&!r.allDay?r.start.slice(11,16):"",w=F===""?"":se(F,_)??"Repeats",O=r!==void 0&&r.seriesId!==""&&t!==void 0&&t!=="",P=r!==void 0&&d!==void 0,$=(i,m)=>{if(i.kind==="written"){g(""),m();return}g(i.kind==="conflict"?Te:i.message)},M=i=>({calendarObjectId:s,calendarId:r?.calendarId??"",recurrenceId:t??"",scope:i,etag:d?.etag??""}),W=i=>{if(!r)return;const m=ae(r,{repeat:w,location:N?.location??"",notes:N?.description??""});p(void 0),T({before:m,scope:i}),j(m),g("")},B=i=>{p(void 0),E(M(i)).then(m=>$(m,b))},q=()=>{if(!f||!u)return;const i=ne(f.before,u,x[u.calendarId]??he);if(!i.ok){g(i.problem);return}k(M(f.scope),i.patch).then(m=>$(m,()=>{T(void 0),j(void 0)}))};return I!==void 0&&r?e.jsx("div",{className:"flex h-full flex-col justify-center bg-surface px-row-inset",children:e.jsx(Ne,{className:"mx-auto w-full max-w-md",title:r.title,ruleText:w===""?"It repeats":w,instanceText:G(r),onChoose:I==="edit"?W:B,onCancel:()=>p(void 0)})}):f&&u?e.jsx(te,{title:"Edit event",subtitle:f.scope==="this"?"This occurrence only":u.date,calendars:c,draft:u,onChange:j,problem:L,saveLabel:"Save",isSaving:D,repeatEditable:f.scope===void 0||f.scope==="all",calendarEditable:!1,onSave:q,onCancel:()=>{T(void 0),j(void 0),g("")}}):e.jsx(Re,{event:r&&{...r,location:N?.location??"",notes:N?.description??"",recurrenceRule:w},calendar:R,isOccurrence:t!==void 0,problem:L,onEdit:P?()=>O?p("edit"):W(void 0):void 0,onDelete:P?()=>O?p("delete"):B(void 0):void 0,onClose:b})}export{Be as O};