@remit/web-client-dist 0.0.456 → 0.0.458

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 (110) hide show
  1. package/assets/{BriefPane-p2YcACxv.js → BriefPane-DyTCfE7R.js} +1 -1
  2. package/assets/{ErrorState-CrD1Pj3M.js → ErrorState-DxtMMIPM.js} +1 -1
  3. package/assets/{FlaggedPane-6pAW12t5.js → FlaggedPane-DRj5zl39.js} +1 -1
  4. package/assets/{FullCompose-Cfr-4IZD.js → FullCompose-BoG12Gnw.js} +1 -1
  5. package/assets/{MailListHeader-CsKbjImu.js → MailListHeader-BvUp2YAz.js} +1 -1
  6. package/assets/{MailShell-CcAKSzl1.js → MailShell-DdiQTKjw.js} +1 -1
  7. package/assets/{MailViewChrome-BkUCd6cc.js → MailViewChrome-CV4Xw32m.js} +1 -1
  8. package/assets/{MailboxPane-BApthp_u.js → MailboxPane-DPXlleMN.js} +1 -1
  9. package/assets/{NavMenuButton-D8BMeF0o.js → NavMenuButton-DCzDPYUK.js} +1 -1
  10. package/assets/OnboardingWizard-CcfEszMQ.js +1 -0
  11. package/assets/{OutboxPane-C8guFO9S.js → OutboxPane-Drq27E5R.js} +1 -1
  12. package/assets/_mailboxId-Cdqn4AND.js +1 -0
  13. package/assets/_messageId-DszEly0K.js +1 -0
  14. package/assets/_messageId-TfLVIOYC.js +1 -0
  15. package/assets/_messageId-USJgxF9U.js +1 -0
  16. package/assets/_outboxMessageId-Dlr-4V_S.js +1 -0
  17. package/assets/_threadId-B9MvrtrB.js +1 -0
  18. package/assets/_threadId-CsCEc_U2.js +1 -0
  19. package/assets/_threadId-a49iEnU3.js +1 -0
  20. package/assets/accounts-_l96d4U-.js +1 -0
  21. package/assets/{advanced-Cud2_BUY.js → advanced-BX8urixV.js} +1 -1
  22. package/assets/{appearance-uTDf5x3I.js → appearance-BvCx3QuQ.js} +1 -1
  23. package/assets/{attachment-file-cbAkJIUk.js → attachment-file-7SlOQtaK.js} +1 -1
  24. package/assets/{avatar-BW6OdazJ.js → avatar-Dx2nnu8-.js} +1 -1
  25. package/assets/{bottom-sheet-CAHDwwxd.js → bottom-sheet-B9BJ1XTT.js} +1 -1
  26. package/assets/{brief-CmMkx0h9.js → brief-Dq--qnCH.js} +1 -1
  27. package/assets/brief-wYPCy3Pg.js +1 -0
  28. package/assets/{browser-ponyfill-CQgM-Dfr.js → browser-ponyfill-gO2wURX_.js} +1 -1
  29. package/assets/{bug-BiUqwrUK.js → bug-ui4WBEYY.js} +1 -1
  30. package/assets/{circle-check-C2TKg5Pn.js → circle-check-4_VJQKru.js} +1 -1
  31. package/assets/{circle-check-big-KaEG9_dE.js → circle-check-big-CcZaO_x-.js} +1 -1
  32. package/assets/{circle-help-BRhBALDQ.js → circle-help-Bl00srtt.js} +1 -1
  33. package/assets/{clock-D1ARyiJ3.js → clock-BqYKa4LY.js} +1 -1
  34. package/assets/compose._-_outboxMessageId_-C-dTZD8u.js +1 -0
  35. package/assets/compose._-_outboxMessageId_-CV38fxsg.js +1 -0
  36. package/assets/compose._-_outboxMessageId_-Cy8UzE5w.js +1 -0
  37. package/assets/compose._-_outboxMessageId_-D0tv7HGf.js +1 -0
  38. package/assets/{confirm-dialog-DnHeXH_o.js → confirm-dialog-DwQkoRYj.js} +1 -1
  39. package/assets/{download-CspKblEZ.js → download-DBrnYKAw.js} +1 -1
  40. package/assets/{filters-BYi_700Y.js → filters-CZoJP1ag.js} +1 -1
  41. package/assets/flagged-DNpuylMn.js +1 -0
  42. package/assets/{flagged-BBNtZf-o.js → flagged-GRqBmRm0.js} +1 -1
  43. package/assets/{folders-DWxvP32R.js → folders-DHjhBJ3L.js} +1 -1
  44. package/assets/{format-BTjE7yjC.js → format-B3uyVYnZ.js} +1 -1
  45. package/assets/{help-copy-DD9UH9as.js → help-copy-Fs4K997z.js} +1 -1
  46. package/assets/index-BHc_DUCd.js +1 -0
  47. package/assets/{index-DcpmB860.js → index-C5WTfF4A.js} +4 -4
  48. package/assets/index-C7-jN1da.js +1 -0
  49. package/assets/{index-BXySuusI.js → index-C8DX_EQn.js} +3 -3
  50. package/assets/index-C9gjWfix.js +1 -0
  51. package/assets/index-CItZ2D0w.js +1 -0
  52. package/assets/index-DszEly0K.js +1 -0
  53. package/assets/index-J_OrADLr.js +1 -0
  54. package/assets/index-USJgxF9U.js +1 -0
  55. package/assets/index-fEXcHum5.js +1 -0
  56. package/assets/{kbd-CHR_zj97.js → kbd-B62acStO.js} +1 -1
  57. package/assets/{labels-1n6Zq6Ue.js → labels-6fZH_eHi.js} +1 -1
  58. package/assets/{mail-BYZr7HTW.js → mail-7swSEn2S.js} +1 -1
  59. package/assets/{mail-BC9dRM74.js → mail-BNCTp4RF.js} +1 -1
  60. package/assets/{menu-Du7BiMpN.js → menu-DGvf1N4B.js} +1 -1
  61. package/assets/{onboarding-DgJ_rgId.js → onboarding-no6XeVz4.js} +1 -1
  62. package/assets/outbox-FKUIA1q2.js +1 -0
  63. package/assets/{pencil-Bt5RUj2Q.js → pencil-DrCSwjWE.js} +1 -1
  64. package/assets/{rich-text-YZQYfUQ0.js → rich-text-Bsxr2TS3.js} +1 -1
  65. package/assets/{rich-text-spellcheck-worker-provider-BZ1PqBlA.js → rich-text-spellcheck-worker-provider-CN7fG4n3.js} +1 -1
  66. package/assets/{rotate-ccw-CGgdRHif.js → rotate-ccw-CrFWWh3G.js} +1 -1
  67. package/assets/{row-actions-3glmdUYW.js → row-actions-CO2bb9oK.js} +1 -1
  68. package/assets/{search-mirror-COWA5Gh8.js → search-mirror-8yIdpqZ4.js} +1 -1
  69. package/assets/{search-token-index-D-YMgBIi.js → search-token-index-BpY-q8ZV.js} +1 -1
  70. package/assets/{senders-7-_G2n1p.js → senders-B11PA4bD.js} +1 -1
  71. package/assets/settings-DYMDRfIw.js +1 -0
  72. package/assets/{settings-screen-ET650lUI.js → settings-screen-K5psovZm.js} +1 -1
  73. package/assets/{shield-check-CDl2yJIS.js → shield-check-CK0lIMjR.js} +1 -1
  74. package/assets/{suggested-vips-D-hDmrOt.js → suggested-vips-C2C2XZwO.js} +1 -1
  75. package/assets/{useDebouncedValue-0u_Z8eX-.js → useDebouncedValue-CxejlkZq.js} +1 -1
  76. package/assets/{useFilters-DLXuf5ni.js → useFilters-ClTpCTul.js} +1 -1
  77. package/assets/{useLabels-lN4IG8ez.js → useLabels-Jy2JcPrZ.js} +1 -1
  78. package/assets/{useMessageBodyContent-BR7wdj9-.js → useMessageBodyContent-yDESgRfR.js} +1 -1
  79. package/assets/{useRefreshControl-BX836Meb.js → useRefreshControl-DQLj8qF7.js} +1 -1
  80. package/assets/{useSearchTokenContext-DLYexShk.js → useSearchTokenContext-CrFL5qdR.js} +1 -1
  81. package/assets/{useSemanticSearch-CdovQnaJ.js → useSemanticSearch-RVZNROuq.js} +1 -1
  82. package/assets/{useSignature-CaDNkUpQ.js → useSignature-D7z3ao3j.js} +1 -1
  83. package/index.html +1 -1
  84. package/package.json +1 -1
  85. package/assets/OnboardingWizard-Cah1M5ld.js +0 -1
  86. package/assets/_mailboxId-CudCqph9.js +0 -1
  87. package/assets/_messageId-B32akND2.js +0 -1
  88. package/assets/_messageId-Bevl_b8C.js +0 -1
  89. package/assets/_messageId-De_8CzR7.js +0 -1
  90. package/assets/_outboxMessageId-D15XyNkQ.js +0 -1
  91. package/assets/_threadId-45SsWaot.js +0 -1
  92. package/assets/_threadId-B_obTaxY.js +0 -1
  93. package/assets/_threadId-CpA7PMcM.js +0 -1
  94. package/assets/accounts-DKCY-t8m.js +0 -1
  95. package/assets/brief-oKpF4D__.js +0 -1
  96. package/assets/compose._-_outboxMessageId_-B3iEhgUk.js +0 -1
  97. package/assets/compose._-_outboxMessageId_-BgH7naI1.js +0 -1
  98. package/assets/compose._-_outboxMessageId_-DjJQgk88.js +0 -1
  99. package/assets/compose._-_outboxMessageId_-kCmd4ndy.js +0 -1
  100. package/assets/flagged-ljGzeTJ5.js +0 -1
  101. package/assets/index-AYpQU2rS.js +0 -1
  102. package/assets/index-B32akND2.js +0 -1
  103. package/assets/index-BLFBo23f.js +0 -1
  104. package/assets/index-Bevl_b8C.js +0 -1
  105. package/assets/index-CWUMLHy8.js +0 -1
  106. package/assets/index-ChUlfgLC.js +0 -1
  107. package/assets/index-Ilm8eQUK.js +0 -1
  108. package/assets/index-lScz8ZIX.js +0 -1
  109. package/assets/outbox-B88SA0ON.js +0 -1
  110. package/assets/settings-mtQGceBF.js +0 -1
@@ -1 +1 @@
1
- import{bz as Ts,bA as ws,j as r,bB as ks,aE as ut,B as ee,S as Ms,b as Oe,aF as Pt,r as c,C as Rs,d as Es,b9 as As,x as It,D as jt,E as Os,aj as Tt,bC as Ns,bD as zs,I as Fs,h as Ds,T as Bt,bE as Ls,b3 as _s,bF as Ps,bG as Bs,ah as $t,aR as $s,aS as Ws,g as Ks,a6 as wt,bH as Vs,Y as Wt,b6 as Hs,z as qs,b7 as Us,b8 as Qs,bI as Js,a5 as Gs,bJ as Ys,bK as Xs,bL as Zs,bM as en,bN as tn,v as Kt,bO as sn,K as nn,bP as on,bQ as rn,a8 as an,bR as ln,bj as cn}from"./index-DcpmB860.js";import{u as dn,p as un,R as hn}from"./useSearchTokenContext-DLYexShk.js";import{u as fn,a as mn,R as gn}from"./useRefreshControl-BX836Meb.js";import{C as Vt,a as Ht,c as qt,j as pn,M as xn,t as Ut,u as bn,b as vn,d as Qt,e as Jt,f as Sn,g as yn,h as Cn,r as In,n as jn,i as Tn,k as wn,l as kn,m as Mn,o as Rn,S as En,p as An,D as On,q as Nn,s as zn,v as Gt,w as Fn,x as Dn,y as Ln,z as _n,A as Pn,B as Yt,E as Bn,F as $n,G as Wn,H as Kn,I as Vn,J as Hn,K as qn,L as Un,N as Nt,O as zt,P as Qn,Q as Jn,R as Gn,T as Yn,U as Xn,V as Zn,W as eo,X as to,Y as so,Z as no,_ as oo,$ as io,a0 as Xt,a1 as Zt,a2 as es,a3 as ro,a4 as ao,a5 as lo,a6 as ts,a7 as co,a8 as uo,a9 as ho}from"./MailListHeader-CsKbjImu.js";import{S as fo,M as mo,a as go,u as po,b as xo}from"./MailViewChrome-BkUCd6cc.js";import{A as kt}from"./avatar-BW6OdazJ.js";import{b as Je,d as bo,c as ss}from"./format-BTjE7yjC.js";import{b as vo,c as So,a as yo,u as Co}from"./useMessageBodyContent-BR7wdj9-.js";import{k as Ge,l as Io,m as jo,n as To,f as wo,o as ko}from"./search-token-index-D-YMgBIi.js";import{N as Mo}from"./NavMenuButton-D8BMeF0o.js";import{C as Ro}from"./confirm-dialog-DnHeXH_o.js";import{f as Eo}from"./ErrorState-CrD1Pj3M.js";import{a as Ao}from"./useLabels-lN4IG8ez.js";import{L as Oo,r as No,u as zo}from"./useSemanticSearch-CdovQnaJ.js";import{S as ht}from"./shield-check-CDl2yJIS.js";import{B as Fo}from"./bottom-sheet-CAHDwwxd.js";import{C as Do}from"./circle-help-BRhBALDQ.js";import{C as Lo}from"./circle-check-C2TKg5Pn.js";import{n as _o}from"./search-query-Cr_ZXBCp.js";import{u as Po}from"./index-BXySuusI.js";const Bo=({children:e,onRefresh:n,isRefreshing:t})=>Ts(ws)?e:r.jsx(ks,{onRefresh:n,isPullable:!t,children:e}),$o=e=>e===1?"message":"messages";function Wo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ut,{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(ht,{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} ${$o(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(ee,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",ns=({senderTrust:e,size:n="sm",className:t})=>{const s=Ko(e,n);return s==="vip"?r.jsx(Ms,{className:Oe("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Oe("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 Vo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:l,snippet:a,trustReason:d,trustSubReason:u,senderTrust:h}=e;return r.jsxs("label",{className:Oe("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(Vt,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(kt,{name:o,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:o}),h&&r.jsx(ns,{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(ht,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const Ho=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},qo=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Ft=e=>e===1?"message":"messages";function Uo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=qo(e,n),a=e.messages.length,d=o?Rs:Es;return r.jsxs("div",{className:Oe(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(Vt,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Ft(a)} from ${e.senderName}`}),r.jsx(kt,{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(ns,{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(ht,{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(u=>!u),"aria-expanded":o,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} ${Ft(a)}`,r.jsx(d,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(u=>r.jsx(Vo,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const Mt=e=>e===1?"message":"messages",Qo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Mt(e)}`} out of Spam to ${n} now. Nothing later.`,Ct=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Jo(){return r.jsx(ut,{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 Go({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:l,onCancel:a}){const[d,u]=c.useState(!1),h=n.size,g=c.useMemo(()=>Ho(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(ht,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Do,{className:"size-3.5"}),onClick:()=>u(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."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(Jo,{})})]}),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(ee,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(ee,{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(Uo,{group:m,selected:n,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(ee,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${Mt(h)}`}),r.jsx(ee,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Yo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:l}){const[a,d]=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(As,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>d(!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:Ct(n,s)}),r.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>d(!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:Qo(e,Ct(n,s))}),r.jsx(ee,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(ee,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Xo({count:e,destinationLabel:n,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(Lo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Mt(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(ee,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Zo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:l}){const[a,d]=c.useState("review"),[u,h]=c.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[g,m]=c.useState(t),[p,C]=c.useState(0),b=c.useRef(!1);c.useEffect(()=>{e&&!b.current&&(d("review"),h(new Set(n.map(I=>I.id))),m(t),C(0)),b.current=e},[e,n,t]);const w=u.size,v=I=>{h(j=>{const E=new Set(j);return E.has(I)?E.delete(I):E.add(I),E})},x=(I,j)=>{h(E=>{const A=new Set(E);for(const L of I.messages)j?A.add(L.id):A.delete(L.id);return A})},k=()=>{const I=Array.from(u);C(I.length),i(I,g),d("done")};return r.jsxs(Fo,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(Go,{candidates:n,selected:u,onToggle:v,onToggleGroup:x,onSelectAll:()=>h(new Set(n.map(I=>I.id))),onSelectNone:()=>h(new Set),onContinue:()=>d("destination"),onCancel:l}),a==="destination"&&r.jsx(Yo,{count:w,folders:s,delimiter:o,destination:g,onPick:m,onMove:k,onBack:()=>d("review")}),a==="done"&&r.jsx(Xo,{count:p,destinationLabel:Ct(s,g),onClose:l})]})}function ei(e){const n=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:n?`To: ${n}`:"(No recipients)",timeLabel:Je(e.updatedAt),isRead:!0}}function ti(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:Je(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function si({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(ei),o=t.map(ti),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const ni=({label:e,count:n})=>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:n})]}),oi=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Oe("group",qt({active:n})),children:[r.jsx(Ds,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Ht,{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:o,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(Bt,{className:"size-3.5"})})})]}),ii=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Oe("group",qt({active:n})),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(kt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Ht,{thread:e})]})};function ri({accountId:e,selectedMessageId:n,imapThreads:t,title:s,unreadCount:o}){const i=vo(),l=So(),a=Ge(),d=It(),{data:u}=jt(Os()),h=c.useMemo(()=>si({outboxMessages:u?.items??[],accountId:e,imapThreads:t}),[u?.items,e,t]),g=Tt({...zs(),onSuccess:()=>{d.invalidateQueries({queryKey:Ns()})}}),m=b=>{g.mutate({path:{outboxMessageId:b}})},p=b=>{const w=t.find(v=>v.messageId===b)?.threadId;w&&a({threadId:w,messageId:b})},C=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(Mo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),(o??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[o," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:C?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Fs,{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(b=>r.jsxs("div",{children:[b.label&&r.jsx(ni,{label:b.label,count:b.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:b.threads.map(w=>b.id==="remit-drafts"?r.jsx(oi,{row:w,isSelected:w.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},w.id):r.jsx(ii,{row:w,isSelected:w.id===n,onOpen:p},w.id))})]},b.id))})]})}const os=e=>e===1?"1 message":`${ss(e)} messages`,ai=e=>({title:"Empty Trash?",description:`${os(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),li=(e,n={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=n;if(e==="unconfirmed"){const o=bo(0,"unconfirmed",{trashFolderLabel:t});return{headline:o.title,body:o.description,actionLabel:o.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 ci({messageCount:e,isEmptying:n,deletedCount:t,refusalReason:s,trashFolderLabel:o,staleFolderLabel:i,onEmpty:l,onRepair:a,children:d}){const[u,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:d});const g=s?li(s,{trashFolderLabel:o,staleFolderLabel:i}):void 0,m=ai(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:`${os(t)} erased from the mail server.`}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Bt,{className:"size-3.5","aria-hidden":!0}),disabled:n||e<1,"aria-busy":n,onClick:()=>h(!0),children:n?"Emptying…":"Empty Trash"})]}),g&&r.jsx(ut,{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(ee,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:d}),r.jsx(Ro,{isOpen:u,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function di(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const d=+i;if(Number.isInteger(d)&&d>=0&&d<e){let u=o[d];if(!u){const h=n[d*2];u=o[d]={index:d,key:t(d),start:h,size:n[d*2+1],end:h+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,l)}})}function Be(e,n,t){let s=t.initialDeps??[],o,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((u,h)=>s[h]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return l.updateDeps=a=>{s=a},l}function Dt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const ui=(e,n)=>Math.abs(e-n)<1.01,hi=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let Qe;const St=()=>{if(Qe!==void 0)return Qe;if(typeof navigator>"u")return Qe=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Qe=!0;const e=navigator.maxTouchPoints;return Qe=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Lt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},fi=e=>e,mi=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},gi=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=l=>{const{width:a,height:d}=l;n({width:Math.round(a),height:Math.round(d)})};if(o(Lt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const d=l[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Lt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},dt={passive:!0},pi=typeof window>"u"?!0:"onscrollend"in window,xi=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&pi;let l=0;const a=i?null:hi(o,()=>n(l,!1),e.options.isScrollingResetDelay),d=g=>()=>{l=t(s),a?.(),n(l,g)},u=d(!0),h=d(!1);return s.addEventListener("scroll",u,dt),i&&s.addEventListener("scrollend",h,dt),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",h)}},bi=(e,n)=>xi(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),vi=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Si=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},yi=Si;class Ci{constructor(n){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,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const l=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,h]of this.elementsCache)if(h===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:fi,rangeExtractor:mi,onChange:()=>{},measureElement:vi,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,d=null,u=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,p=i.count,C=this.getMeasurements(),b=m>0?((s=C[0])==null?void 0:s.key)??l.getItemKey(0):null,w=m>0?((o=C[m-1])==null?void 0:o.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==b||i.getItemKey(p-1)!==w)){u=!0;const k=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??C[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==w)&&(d=I)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,C=this.getMeasurements(),{count:b,getItemKey:w}=this.options;let v=0;for(;v<b&&w(v)!==m;)v++;if(v<b){const x=C[v];if(x){const k=x.start+p;k!==this.scrollOffset&&(g=k-this.scrollOffset,this.scrollOffset=k,h=!0)}}}(h||d)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,d,g])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=Be(()=>(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,!(!St()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,dt),i.addEventListener("touchend",a,dt),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 o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,l,a,d]=o;i!==null&&!a&&(St()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):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 o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,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=Be(()=>[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,o,i,l,a,d,u)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=Be(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:d,gap:u},h)=>{const g=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const v of this.laneAssignments.keys())v>=t&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.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 v=t*2;let x=this._flatMeasurements;if(!x||x.length<v){const j=new Float64Array(v);x&&m>0&&j.set(x.subarray(0,m*2)),x=j,this._flatMeasurements=x}let k;if(m===0)k=s+o;else{const j=m-1;k=x[j*2]+x[j*2+1]+u}for(let j=m;j<t;j++){const E=i(j),A=g.get(E),L=typeof A=="number"?A:this.options.estimateSize(j);x[j*2]=k,x[j*2+1]=L,k+=L+u}const I=di(t,x,i);return this.measurementsCache=I,I}const p=this.measurementsCache.slice(0,m),C=new Array(a).fill(void 0),b=new Float64Array(a);let w=0;for(let v=0;v<m;v++){const x=p[v];x&&(C[x.lane]===void 0&&w++,C[x.lane]=v,b[x.lane]=x.end)}for(let v=m;v<t;v++){const x=i(v),k=this.laneAssignments.get(v);let I,j;const E=d==="estimate"||g.has(x);if(k!==void 0&&this.options.lanes>1){I=k;const N=C[I],J=N!==void 0?p[N]:void 0;j=J?J.end+u:s+o}else if(w===a){let N=0,J=b[0],_=C[0];for(let G=1;G<a;G++){const te=b[G];(te<J||te===J&&C[G]<_)&&(N=G,J=te,_=C[G])}I=N,j=J+u,E&&this.laneAssignments.set(v,I)}else I=v%this.options.lanes,j=s+o,E&&this.laneAssignments.set(v,I);const A=g.get(x),L=typeof A=="number"?A:this.options.estimateSize(v),O=j+L;p[v]={index:v,start:j,size:L,end:O,key:x,lane:I},C[I]===void 0&&w++,C[I]=v,b[I]=O}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Be(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=ji(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Be(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,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 o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,o-i),a=Math.min(this.options.count-1,o+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),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let l,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],l=u[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;d=m.key,a=m.start,l=m.size}const h=this.itemSizeCache.get(d)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,C=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:d,start:a,size:l,end:a+l,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(d,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-p):C&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Be(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],d=s[a];o.push(d)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,l=is(0,s.length-1,i?a=>o[a*2]:a=>Dt(s[a]).start,t);return Dt(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,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(o-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 o=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+o-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:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="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,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{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 o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?o=l[i*2]+l[i*2+1]:o=((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--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(St()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,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,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=o!==this.scrollState.lastTargetOffset;if(!l&&ui(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,d=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&d>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const is=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function Ii(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function ji(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const u=Ii(o,i,t);let h=u;const g=t+n;for(;h<i&&o[h*2]+o[h*2+1]<g;)h++;return{startIndex:u,endIndex:h}}let a=is(0,i,u=>e[u].start,t),d=a;if(s===1)for(;d<i&&e[d].end<t+n;)d++;else if(s>1){const u=Array(s).fill(0);for(;d<i&&u.some(g=>g<t+n);){const g=e[d];u[g.lane]=g.end,d++}const h=Array(s).fill(t+n);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),d=Math.min(i,d+(s-1-d%s))}return{startIndex:a,endIndex:d}}const yt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Ti({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=c.useReducer(u=>u+1,0)[1],i=c.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const l=u=>{const h=i.current;if(!h.enabled||!h.container)return;const g=u.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const v=u.options.horizontal?"width":"height";h.container.style[v]=`${g}px`}const m=!!u.options.horizontal,p=h.mode==="transform",C=m?"left":"top",b=u.options.scrollMargin,w=u.getVirtualItems();for(const v of w){const x=v.start-b,k=u.elementsCache.get(v.key);k&&h.lastPositions.get(k)!==x&&(h.lastPositions.set(k,x),p?k.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:k.style[C]=`${x}px`)}},a={...s,onChange:(u,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(u);const C=u.range,b=m.prevRange;p=!b||b.isScrolling!==u.isScrolling||b.startIndex!==C?.startIndex||b.endIndex!==C?.endIndex,p&&(m.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:u.isScrolling}:null)}p&&(e&&h?Ls.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,h)}},[d]=c.useState(()=>{const u=new Ci(a);return Object.assign(u,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=u.getTotalSize();g.lastSize=m;const p=u.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return d.setOptions(a),yt(()=>d._didMount(),[]),yt(()=>d._willUpdate()),yt(()=>{l(d)}),d}function wi(e){return Ti({observeElementRect:gi,observeElementOffset:bi,scrollToFn:yi,...e})}const Rt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",ki=e=>`Select all ${Rt(e)}`,Mi=(e,n)=>`All ${ss(n)} ${Rt(e)} selected`,Ri=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=pn(s,o);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},Ei=(e,n,t)=>e==="BACK"&&n&&t===void 0,Ai=(e,n)=>({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:Je(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Oi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:p})=>r.jsx(xn,{thread:Ai(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:h,onLongPress:g}}),Ni=c.memo(Oi),zi=e=>{const n=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:Je(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),suspicious:n}},Fi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:p,density:C})=>{const[b,w]=c.useState("none"),v=Ge(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),w("none")},[m,p,e.messageId,e.isRead]),k=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),I=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{v({threadId:e.threadId,messageId:e.messageId})},[v,e.threadId,e.messageId]),E=bn(e.messageId,d);return g||u?r.jsx(Ni,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,density:C}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(fo,{thread:zi(e),selectionMode:!1,checked:!1,active:t,peek:b,onPeek:w,onToggleCheck:I,onLongPress:k,onOpen:j,onAct:x})})},Di=72,Li=32,_i=5,rs="remit:list-density",Pi=()=>{try{const e=localStorage.getItem(rs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Bi=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Ks,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),$i=(e,n,t)=>No(e.filter(s=>n.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Wi=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:h=!1,isMoving:g=!1,onLoadMore:m,hasMore:p=!1,isLoadingMore:C=!1,accountId:b,listTitle:w,listMeta:v,listFilter:x,listScopeLabel:k,onTriageContextChange:I,commandsRef:j,hideHeader:E=!1})=>{const A=c.useRef(null),L=Ge(),O=_s(),N=Ps(),{verb:J,start:_,startFromSearch:G}=N,te=Bs(),me=!!a?.trim(),P=vn(),{labels:$e}=Ao(b),{pushError:re}=$t(),[M,Ie]=c.useState(t),[W,je]=c.useState(),K=c.useCallback(f=>{je(S=>S===f?S:void 0),Ie(f)},[]),[D,We]=c.useState(Pi),ge=c.useCallback(()=>{We(f=>{const S=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(rs,S)}catch{}return S})},[]),{toggleReadFor:pe}=Qt({mailboxId:e}),{junkMailboxId:ae}=Jt(b),Ne=Gt(ae,e),ze=c.useMemo(()=>[{accountId:b,mailboxId:e}],[b,e]),{outcome:le,staleFolderLabel:V,guessedMailboxId:H}=Sn(ze),{selectedIds:X,selectedCount:q,hasSelection:oe,isSelected:Fe,toggle:Z,select:Te,clearSelection:ce,selectRange:de,setAnchor:z,selectAll:we,toggleAll:Ke,intersectWith:De}=yn(),R=zn(q,O),[ke,ue]=c.useState(null),Ve=me&&!!d,Ye=`${e}|${JSON.stringify(d??{})}`,T=Cn({mailboxId:e,accountId:b,enabled:Ve,predicateKey:Ye,searchQuery:d??{}}),Xe=c.useCallback((f,S,fe)=>{const Q=In(f,S,fe,le);Q&&re(Q)},[re,le]),Me=T.phase.kind,Ze=T.clear,F=c.useCallback(()=>{Me==="escalated"&&Ze(),ce()},[ce,Ze,Me]),[et,tt]=c.useState(null),xe=c.useRef(null),ie=c.useRef(!1),be=c.useRef(null),Re=!s&&n.length>0,ve=ke!==null,Se=wi({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>D==="compact"?Li:Di,overscan:_i}),Le=t?n.findIndex(f=>f.messageId===t):-1,se=M?n.findIndex(f=>f.messageId===M):-1,ne=c.useCallback(f=>{if(f<0||f>=n.length)return;const S=n[f];if(R){Z(S.messageId);return}xe.current=S.messageId,ie.current=!1,je(S.messageId),Ie(S.messageId)},[n,R,Z]),He=c.useCallback(()=>{if(n.length===0)return;const f=se<0?0:Math.min(se+1,n.length-1);ne(f)},[n.length,se,ne]),ye=c.useCallback(()=>{if(n.length===0)return;const f=se<=0?0:se-1;ne(f)},[n.length,se,ne]),Ee=c.useCallback(()=>ne(0),[ne]),Ae=c.useCallback(()=>ne(n.length-1),[ne,n.length]),st=c.useCallback(()=>{M&&Z(M)},[M,Z]),B=c.useMemo(()=>n.map(f=>f.messageId),[n]),mt=c.useMemo(()=>{const f=[];for(const S of n)X.has(S.messageId)&&f.push({id:S.messageId,sender:S.fromName??S.fromEmail??"Unknown",email:S.fromEmail??"",subject:S.subject??"(No subject)",date:Je(S.sentDate),accountId:b});return f},[n,X,b]),Ce=c.useCallback((f,S)=>S.shiftKey?(de(B,f,M),!0):S.metaKey||S.ctrlKey?(Z(f),!0):(F(),z(f),!1),[B,M,de,Z,F,z]),nt=c.useCallback(f=>{!u||f.length===0||(be.current=M??null,ue(f))},[u,M]),_e=c.useCallback(f=>{const S=jn(B,M,f);S!==void 0&&(de(B,S),xe.current=S,ie.current=!1,je(void 0),Ie(S))},[B,M,de]),ot=c.useCallback(()=>_e(-1),[_e]),it=c.useCallback(()=>_e(1),[_e]),rt=c.useCallback(()=>{B.length>0&&we(B)},[B,we]),at=c.useCallback(f=>{const S=Ri({verb:f,confirmingDelete:ke!==null,hasSelection:oe,junkMailboxId:ae,currentMailboxId:e,deletableMessageId:u?M:void 0});return S.kind==="openWizard"?(_(f),!0):S.kind==="confirmDelete"?(nt([S.messageId]),!0):S.kind==="unavailable"?(re({severity:"warning",title:S.reason}),!0):S.kind==="withheld"},[ke,u,oe,ae,e,_,M,nt,re]),he=c.useCallback((f,S)=>{const fe=n.find(Q=>Q.messageId===f)?.threadId;fe&&L({threadId:fe,messageId:f},{replace:S?.replace})},[L,n]),qe=c.useCallback(()=>{M&&he(M)},[M,he]),lt=c.useCallback(f=>he(f,{replace:!0}),[he]);Tn({keyboardFocusedMessageId:W,openMessageId:t,enabled:O&&q===0,open:lt});const Ue=T.phase.kind==="escalated"?{scope:Rt(d??{}),total:T.phase.total,searchQuery:d??{},run:f=>T.runAction(f),stop:T.stop}:void 0,gt=c.useCallback(f=>{if(f.length===0){ue(null);return}const S=new Set(f),fe=n.findIndex(Y=>S.has(Y.messageId));let Q;for(let Y=fe+1;Y<n.length;Y++)if(!S.has(n[Y].messageId)){Q=n[Y].messageId;break}if(Q===void 0){for(let Y=fe-1;Y>=0;Y--)if(!S.has(n[Y].messageId)){Q=n[Y].messageId;break}}u?.(f),F(),be.current=null,ue(null),Q!==void 0&&(xe.current=Q,ie.current=!1,K(Q),O&&he(Q,{replace:!0})),O||tt(wn("delete",f.length,le))},[n,u,F,he,O,K,le]),pt=c.useCallback(()=>{const f=be.current;be.current=null,ue(null),f!==null&&(xe.current=f,ie.current=!1,K(f))},[K]),Pe=c.useMemo(()=>$i(n,X,b),[b,X,n]),xt=c.useCallback(()=>{if(Ue){G();return}_("organize")},[Ue,G,_]),y=c.useCallback(f=>{u?.([f])},[u]),U=c.useCallback((f,S)=>{pe([f],!S)},[pe]),$=c.useCallback(f=>{O||Te(f)},[O,Te]),ds=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}F()},[T,F]),us=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(ie.current||!O&&t)return;const f=se>=0?se:Le;f>=0&&Se.scrollToIndex(f,{align:"auto"})},[se,Le,Se,O,t]),c.useEffect(()=>{t&&(ie.current=!1,K(t))},[t,K]),c.useEffect(()=>{M&&(n.some(f=>f.messageId===M)||K(n[0]?.messageId))},[n,M,K]),c.useEffect(()=>{I?.({focusedMessageId:M,selectedIds:Array.from(X),hasList:Re,blocksKeyboard:ve||N.isOpen})},[M,X,Re,ve,N.isOpen,I]);const Et=c.useRef(I);Et.current=I,c.useEffect(()=>()=>Et.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||De(n.map(f=>f.messageId))},[n,De,T.phase,T.isRunning]);const At=c.useRef(e);c.useEffect(()=>{At.current!==e&&(At.current=e,F())},[e,F]),kn({shouldBlockFn:({action:f})=>Ei(f,oe,te)?(F(),!0):!1,enableBeforeUnload:!1,disabled:!oe||te!==void 0}),c.useEffect(()=>{const f=A.current;if(!f||!p||!m)return;const S=()=>{if(C)return;const{scrollTop:fe,scrollHeight:Q,clientHeight:Y}=f;fe+Y>=Q-200&&m()};return f.addEventListener("scroll",S,{passive:!0}),S(),()=>f.removeEventListener("scroll",S)},[p,C,m]),c.useEffect(()=>{const f=xe.current;if(!f)return;const S=A.current?.querySelector(`[data-message-id="${f}"]`);S&&(xe.current=null,S.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!Re){j.current=null;return}return j.current={focusNext:He,focusPrevious:ye,focusFirst:Ee,focusLast:Ae,openFocused:qe,toggleSelect:st,extendSelectDown:it,extendSelectUp:ot,selectAll:rt,clearSelection:()=>oe?(F(),!0):!1,requestVerb:at,toggleDensity:ge},()=>{j.current=null}}},[j,Re,He,ye,Ee,Ae,qe,st,it,ot,rt,oe,F,at,ge]);const Ot=s?"loading":o?"error":n.length===0?"empty":"ready",hs=o?Eo(i):void 0,fs=c.useCallback(()=>{const f=$s(Ws());window.open(f,"_blank","noopener,noreferrer")},[]),ms=[{id:"inbox",threads:[]}],bt=B.length>0&&B.every(f=>X.has(f)),gs=Ve&&p&&bt&&!h&&!g&&T.phase.kind==="idle"&&!T.isRunning,ps=h||g||T.isRunning,vt=T.phase.kind==="escalated"?T.phase.total:q,xs=T.runningAction?Mn(T.runningAction.kind,T.progress?.done??0,T.progress?.total??vt):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?Mi(d??{},T.phase.total):void 0,bs=T.phase.kind!=="escalated"&&B.length>0?{checked:bt,indeterminate:q>0&&!bt,onChange:()=>Ke(B)}:void 0,vs=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??vt,tone:Rn(T.runningAction.kind)}:void 0,Ss=(T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"&&!T.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:us}}:gs?{tone:"info",text:"",action:{label:ki(d??{}),onClick:T.escalate}}:void 0)??(Pe?{tone:"warning",text:Pe}:void 0),ys=r.jsx(En,{title:P.title||w,navSlot:P.navSlot,titleMeta:P.titleMeta,searchSlot:P.searchSlot,searchField:P.searchField,idleSlot:P.makeFilterSlot,count:vt,onCancel:ds,onDelete:()=>_("delete"),onMove:()=>_("move"),onOrganize:xt,onJunk:Ne?()=>_("junk"):void 0,onMarkRead:()=>_("markRead"),overflowSlot:b&&e&&q>0&&$e.length>0?r.jsx(Oo,{accountId:b,mailboxId:e,messageIds:Array.from(X)}):void 0,isBusy:ps,isCounting:T.phase.kind==="counting",selectAll:bs,statusLabel:xs,progress:vs,notice:Ss}),Cs=An(B,M),Is=c.useCallback(f=>{ie.current=!0,K(f)},[K]),js=r.jsxs(r.Fragment,{children:[me&&a&&r.jsx(Bi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":w,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${Se.getTotalSize()}px`},children:Se.getVirtualItems().map(f=>{const S=n[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:Se.measureElement,className:Oe("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Fi,{thread:S,mailboxId:e,isSelected:t===S.messageId,isFocused:M===S.messageId,isTabStop:Cs===S.messageId,onFocusRow:Is,isChecked:Fe(S.messageId),onToggleCheck:Z,onRowSelect:Ce,isMultiSelectMode:R,onLongPress:$,isDesktop:O,onDelete:y,onToggleRead:U,density:D})},f.key)})}),C&&r.jsx(mo,{})]})]});return r.jsxs(r.Fragment,{children:[et&&!O&&r.jsx(ut,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>tt(null),children:et}),r.jsx(go,{listTitle:w,listMeta:v,sections:ms,flatList:!0,listState:P.searchResults?"ready":Ot,searchQuery:me?a:void 0,listFilter:x,listScopeLabel:k,errorMessage:hs,onRetry:l,onReportError:fs,density:D,selectedThreadId:t,onSelectThread:f=>he(f),isDesktop:O,hideHeader:E,selectionBar:ys,listBody:P.searchResults??(Ot==="ready"?js:void 0)}),r.jsx(On,{isOpen:ke!==null,messageIds:ke??[],outcome:le,accountId:b,trashFolderLabel:w,staleFolderLabel:V,guessedMailboxId:H,isDeleting:h,onConfirm:gt,onCancel:pt}),r.jsx(Nn,{verb:J,accountId:b,mailboxId:e,selection:mt,selectionRestriction:Pe?"spansAccounts":void 0,escalated:Ue,escalatedProgress:T.progress,onFinished:F,onRunEnded:Xe})]})},Ki=e=>Wt({path:{accountId:e}}),Vi=e=>{const n=It(),t=wt(),s=Tt({...Vs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Hi=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Vi(e);return r.jsx(Bo,{onRefresh:t,isRefreshing:s,children:n})};function qi({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=wt(),d=Hs(),{inboxMailboxId:u}=Fn(e),h=Dn(e),{data:g}=jt({...qs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Us({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:n,translator:d}),[g?.items,h,n,d]),p=c.useMemo(()=>u||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[u,m]),C=c.useRef(!1);c.useEffect(()=>{C.current||(C.current=!0,Ln(a,t.length))},[a,t.length]);const b=c.useCallback(()=>{_n(a,t.length),l(!0)},[a,t.length]),w=c.useCallback((v,x)=>{Pn(a,{selected:v.length,total:t.length,toInbox:x===u}),s(v,x)},[a,t.length,u,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(Wo,{count:t.length,onReview:b})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Zo,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:Qs(g?.items??[]),onConfirmMove:w,onCancel:()=>l(!1)})]})}const Ui=(e,n,t,s)=>`${e??""}|${n}|${t??""}|${s??""}`,Qi=({accountId:e,mailboxId:n})=>{const t=It(),{pushError:s}=$t(),{requestAppointment:o}=Js(),{trashByAccount:i}=Yt(),l=e?i.get(e):void 0,a=Ui(e,n,l?.mailboxId,l?.source),[d,u]=c.useState({scope:a});d.scope!==a&&u({scope:a});const h=d.scope===a?d:void 0,g=c.useCallback(()=>t.getQueryData(Gs())?.accounts.find(j=>j.accountId===e)?.folderAppointments.find(j=>j.role==="Trash")?.mailboxId??n,[t,e,n]),m=c.useRef(void 0),{mutateAsync:p,isPending:C}=Tt({...Zs(),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,k,I)=>{I.scope===a&&u({scope:a,deletedCount:x.deletedCount})},onError:(x,k,I)=>{const j=Ys(x);if(!j){s({title:"Couldn't empty Trash",detail:Xs(x),error:x});return}I?.scope===a&&u({scope:a,refusal:j})},onSettled:(x,k,I,j)=>{m.current===j?.scope&&(m.current=void 0),Bn(t,$n([j?.listMailboxId??n])),e&&t.invalidateQueries({queryKey:Wt({path:{accountId:e}})})}}),b=c.useCallback(()=>e?(u({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),w=c.useCallback(()=>{b()},[b]),v=c.useCallback(()=>{const x=h?.refusal;x&&o({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:b})},[h,o,b]);return{emptyTrash:w,isEmptying:C&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:v}},Ji="We can verify this sender";function Gi(e){const{data:n}=jt({...en({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.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:Ji,trustSubReason:Wn(s.senderTrust),senderTrust:s.senderTrust}))}}const Yi=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Xi={unread:"unread",flagged:"starred",attachment:"attachments"},Zi=new Set(Object.values(tn)),as=e=>Zi.has(e),er=e=>as(e.category)||e.attributes.size>0,tr=e=>{const n={};as(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Xi[t];s&&(n[s]=!0)}return n},sr=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",nr=["category","unread","starred","attachments"],_t=e=>JSON.stringify(nr.map(n=>e?.[n]??null)),or=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},ir=(e,n)=>{const t=or(e);return t?_t(t)===_t(n):!1},ct=e=>e[0],rr=e=>{const n=ct(e.filter(a=>a.type==="from").map(a=>a.value)),t=ct(e.filter(a=>a.type==="subject").map(a=>a.value)),s=ct(e.filter(a=>a.type==="category").map(a=>a.category)),o=ct(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,l=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...l!==void 0?{attachments:l}:{}}},ar=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function lr(e,n={}){const t=rr(e),s={...t,...n};return{params:t,residual:e.filter(o=>!ar(s,o))}}function cr(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=Kn(o);return Vn({...i,accountId:i.accountId??t},s)})}const dr=50,ur=new Map(ts().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),ls=c.createContext(null);function ft(){const e=c.useContext(ls);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function hr({mailboxId:e,thread:n,children:t}){const s=Ge(),o=Io(),i=Po(),l=n?.threadId,a=n?.messageId,d=wt(),{accounts:u,searchQuery:h,onToggleIntelligence:g}=Kt(),m=dn(),p=_o(h),C=p.length>0,{freeText:b,tokens:w}=un(p,m),[v,x]=c.useState("all"),[k,I]=c.useState(new Set),j=c.useMemo(()=>({category:v,attributes:k}),[v,k]),E=c.useMemo(()=>tr(j),[j]),A=C||er(j),{params:L,residual:O}=lr(w,E),N={order:"desc",limit:dr,...b?{query:b}:{},...L,...E},J={category:N.category,unread:N.unread,starred:N.starred,attachments:N.attachments},_=A?sn({path:{mailboxId:e},query:N}):nn({path:{mailboxId:e},query:{order:"desc"}}),{data:G,isLoading:te,isError:me,error:P,refetch:$e,fetchNextPage:re,hasNextPage:M,isFetchingNextPage:Ie}=po({queryKey:_,queryFn:async({pageParam:y})=>{if(A){const{data:$}=await ln({path:{mailboxId:e},query:{...N,continuationToken:y},throwOnError:!0});return $}const{data:U}=await cn({path:{mailboxId:e},query:{order:"desc",continuationToken:y},throwOnError:!0});return U},initialPageParam:void 0,getNextPageParam:y=>y.continuationToken,placeholderData:(y,U)=>ir(U?.queryKey,J)?y:void 0}),{accountId:W,isLoading:je}=Hn(e),K=jo({accounts:u}),D=cr(qn(Yi(G?.pages.flatMap(y=>y.items??[])??[])),O,W),We=c.useCallback(y=>{x(y)},[]),ge=c.useCallback(y=>{I(U=>{const $=new Set(U);return $.has(y)?$.delete(y):$.add(y),$})},[]),pe=c.useCallback(()=>{x("all"),I(new Set)},[]),ae=ur.get(v),Ne=ae?{label:ae,reach:O.length>0?"loaded-pages":sr(N),onClear:pe}:void 0,ze=l?D.find(y=>y.messageId===a)??D.find(y=>y.threadId===l):void 0,le=Un(l,a),V=ze??le,H=a??V?.messageId,X=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:V?.mailboxId??e,subject:V?.subject,messageId:H,authenticity:V?.authenticity}},[l,V,H,e]),q=c.useCallback(y=>{H&&y.includes(H)&&o()},[H,o]),{deleteMessages:oe,isPending:Fe}=Nt({mailboxId:e,onAfterOptimisticRemove:q}),{moveMessages:Z,isPending:Te}=zt({mailboxId:e,accountId:W,onAfterOptimisticRemove:q}),ce=c.useRef(null),de=Qn(),{listCommandsRef:z,onTriageContextChange:we,focusedMessageId:Ke,selectedIds:De}=de,R=D.find(y=>y.messageId===Ke)??V,ke=To({accounts:u})??0,ue=Jn({thread:V,isOpen:!0,mailboxId:e,accountId:W,onAfterOptimisticRemove:q}),{draftsMailboxId:Ve}=Gn(W),Ye=Ve!==void 0&&Ve===e,{archiveMailboxId:T}=Yn(W),Xe=Xn(),Me=on(),Ze=c.useMemo(()=>rn(Me,l,H),[Me,l,H]),F=c.useMemo(()=>{if(R)return y=>Me({threadId:R.threadId,messageId:R.messageId,mode:y})},[Me,R]),et=yo(),tt=an(),xe=Co(),ie=c.useCallback(y=>y?Xe(y):[],[Xe]),{toggleStar:be}=Zn({threadId:R?.threadId??"",mailboxId:e}),{toggleReadFor:Re}=Qt({mailboxId:e,accountId:W}),{junkMailboxId:ve}=Jt(W),Se=ve!=null&&ve===e,Le=Gt(ve,e),{candidates:se}=Gi(Se?ve:void 0),{moveMessages:ne}=zt({mailboxId:e,threadId:R?.threadId,accountId:W,onAfterOptimisticRemove:q}),{deleteMessages:He}=Nt({mailboxId:e,threadId:R?.threadId,onAfterOptimisticRemove:q}),{addressId:ye,address:Ee}=eo(R),{updateFlags:Ae}=to({addressId:ye,senderEmail:R?.fromEmail??void 0}),st=c.useCallback(()=>F?.("reply"),[F]),B=c.useCallback(()=>F?.("reply-all"),[F]),mt=c.useCallback(()=>F?.("forward"),[F]),Ce=c.useCallback(()=>ie(R),[ie,R]),nt=c.useCallback(()=>{if(z.current?.requestVerb("delete"))return;const y=Ce();y.length>0&&He(y)},[z,Ce,He]),_e=c.useCallback(()=>{if(z.current?.requestVerb("junk")||!Le)return;const y=Ce();y.length!==0&&(so(d,{count:y.length,senderTrust:R?.senderTrust??"unknown",wasRescuable:R?no(R):!1}),ne(y,Le))},[z,Le,Ce,ne,d,R]),ot=c.useCallback(()=>{if(De.length>0){const y=!(R?.hasStars??!1),U=new Set(De);for(const $ of D)U.has($.messageId)&&$.hasStars!==y&&be($.messageId,$.hasStars);return}R&&be(R.messageId,R.hasStars)},[De,D,R,be]),it=c.useCallback(()=>{if(z.current?.requestVerb("markRead"))return;const y=Ce();if(y.length===0)return;const U=!(R?.isRead??!1);Re(y,U)},[z,Ce,R,Re]),rt=c.useCallback(()=>{if(!ye)return;const y=Ee?.flags?.muted?.value!==!0;Ae({muted:{value:y}})},[ye,Ee,Ae]),at=c.useCallback(()=>{if(!ye)return;const y=Ee?.flags?.vip?.value!==!0;Ae({vip:{value:y}})},[ye,Ee,Ae]),he=c.useCallback(()=>{ce.current?.open()},[]),qe=Ye?"drafts":T===e?"archive":ve===e?"junk":"inbox",lt=c.useRef("");c.useEffect(()=>{const y=lt.current;lt.current=p,p.length>0&&y.length===0&&d.recordEvent("search.submitted",{mailboxType:qe})},[p,qe,d]);const{goBack:Ue,nextMessageId:gt,previousMessageId:pt}=oo({context:de,orderedIds:D.map(y=>y.messageId),selectedMessageId:H,enabled:!et&&!tt,hasOpenThread:l!==void 0,onClose:o,handlers:{reply:st,replyAll:B,forward:mt,delete:nt,toggleStar:ot,toggleRead:it,muteSender:rt,blockSender:V?he:void 0,vipSender:at,markJunk:_e,toggleIntelligence:V?()=>ce.current?.toggle():void 0,compose:xe,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),Pe=y=>{if(!y)return;const U=D.find($=>$.messageId===y);return U?{threadId:U.threadId,messageId:y}:void 0},xt={mailboxId:e,selectedMessageId:H,selectedThread:V,conversation:X,onOpenThread:s,threads:D,isLoading:te,isError:me,error:P,mailboxAccountId:W,mailboxAccountLoading:je,mailboxName:K,unreadCount:ke,isDraftsMailbox:Ye,isSpamFolder:Se,rescueCandidates:se,filterCategory:v,filterAttributes:k,onSelectFilterCategory:We,onToggleFilterAttribute:ge,onClearFilters:pe,listFilter:Ne,onToggleIntelligence:g,intelligenceRef:ce,handleDeselectIfRemoved:q,searchPredicate:C&&O.length===0?N:void 0,onDeleteMessages:oe,onMoveMessages:Z,isDeleting:Fe,isMoving:Te,onLoadMore:re,hasMore:M,isLoadingMore:Ie,onTriageContextChange:we,listCommandsRef:z,onRetry:()=>$e(),onReply:Ze,onToolbarDelete:ue.deleteThread,onToolbarStar:ue.toggleStar,isStarred:ue.isStarred,onToolbarMove:ue.moveThread,onBack:Ue,nextThread:Pe(gt),previousThread:Pe(pt)};return r.jsx(ls.Provider,{value:xt,children:t})}function cs(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:p,mailboxName:C,unreadCount:b,isDraftsMailbox:w,isSpamFolder:v,rescueCandidates:x,onTriageContextChange:k,listCommandsRef:I,onRetry:j,filterCategory:E,filterAttributes:A,onSelectFilterCategory:L,onToggleFilterAttribute:O,onClearFilters:N,listFilter:J,searchPredicate:_}=ft(),{searchQuery:G,searchInput:te,accounts:me,resultFolderIndex:P}=Kt(),$e=wo(),re=Ge(),M=C??"Inbox",Ie=c.useMemo(()=>ts(),[]),{trashMailboxId:W}=co(p),je=ko({accounts:me}),{trashByAccount:K}=Yt(),D=Qi({accountId:p,mailboxId:e}),We=W!=null&&W===e,ge=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:pe}=fn(),{state:ae,errorMessage:Ne,refresh:ze}=mn(ge,{onSettled:j}),le=c.useMemo(()=>r.jsx(gn,{state:ae,onRefresh:ze,label:`Refresh ${M}`,errorMessage:Ne,hasUpdate:pe(ge)}),[ae,ze,M,Ne,pe,ge]),V=c.useMemo(()=>t.map(z=>uo(z,P)),[t,P]),{hits:H,isLoading:X}=zo({mailboxId:e,filterCategory:E}),q=c.useMemo(()=>ho(H,t.map(z=>z.threadId),P),[H,t,P]),oe=c.useCallback(z=>{const we=z.threadId??t.find(Ke=>Ke.messageId===z.id)?.threadId;we&&re({threadId:we,messageId:z.id},{mailboxId:z.mailboxId??e,query:te})},[e,re,te,t]);if(w&&p)return r.jsx(ri,{accountId:p,selectedMessageId:n,imapThreads:t,title:C??"Drafts",unreadCount:b??void 0});const Fe=r.jsx(Wi,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:G,searchPredicate:_,onDeleteMessages:l,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:J,listScopeLabel:M,hideHeader:!0,onTriageContextChange:k,commandsRef:I}),Z=me[0]?.accountId,Te=$e==="phone"&&Z?r.jsx(Hi,{accountId:Z,children:Fe}):Fe,ce=v&&x.length>0&&p?r.jsx(qi,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:Te}):Te,de=We?r.jsx(ci,{messageCount:je,isEmptying:D.isEmptying,deletedCount:D.deletedCount,refusalReason:D.refusal?.reason,trashFolderLabel:C??void 0,staleFolderLabel:p?K.get(p)?.staleFolderPath:void 0,onEmpty:D.emptyTrash,onRepair:D.repair,children:ce}):ce;return r.jsx(xo,{title:M,unreadCount:b,preset:Ie,selectedCategory:E,activeFilters:A,onSelectCategory:L,onToggleFilter:O,onClearFilters:N,searchResults:V,searchLoading:s,relatedResults:q,relatedLoading:X,onSelectSearchResult:oe,searchResultsInBody:!0,refreshControl:le,children:de})}function fr(){const{mailboxId:e,mailboxAccountId:n,mailboxAccountLoading:t,selectedThread:s,conversation:o,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:d,onToolbarMove:u,handleDeselectIfRemoved:h,intelligenceRef:g}=ft(),m=!!o,p=ao(o?.threadId);Xt(g,p);const C=c.useRef(null),{railFits:b,openRail:w}=p;c.useEffect(()=>{if(!b)return;const x=s?.messageId??null;x&&C.current!==x&&s?.authenticity?.dkimMismatch&&(C.current=x,w())},[b,w,s?.messageId,s?.authenticity?.dkimMismatch]);const v=o?r.jsx(Zt,{threadId:o.threadId,mailboxId:o.mailboxId,subject:o.subject,selectedMessageId:o.messageId,authenticity:o.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(hn,{});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(lo,{hasThread:m,messageId:o?.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:d,moveContext:m&&n?{accountId:n,currentMailboxId:e,onMove:u}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:v})]}),r.jsx(es,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:h})]})}function mr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=ft();return r.jsx(ro,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function gr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:d,intelligenceRef:u}=ft(),h=io(s?.threadId??null);return Xt(u,h),s?r.jsxs(r.Fragment,{children:[r.jsx(Zt,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>o(l):void 0,onSwipePrevious:a?()=>o(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(es,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:d})]}):r.jsx(cs,{})}const _r=Object.assign(hr,{List:cs,Reading:fr,Intelligence:mr,Phone:gr});export{_r as M};
1
+ import{bz as Ts,bA as ws,j as r,bB as ks,aE as ut,B as ee,S as Ms,b as Oe,aF as Pt,r as c,C as Rs,d as Es,b9 as As,x as It,D as jt,E as Os,aj as Tt,bC as Ns,bD as zs,I as Fs,h as Ds,T as Bt,bE as Ls,b3 as _s,bF as Ps,bG as Bs,ah as $t,aR as $s,aS as Ws,g as Ks,a6 as wt,bH as Vs,Y as Wt,b6 as Hs,z as qs,b7 as Us,b8 as Qs,bI as Js,a5 as Gs,bJ as Ys,bK as Xs,bL as Zs,bM as en,bN as tn,v as Kt,bO as sn,K as nn,bP as on,bQ as rn,a8 as an,bR as ln,bj as cn}from"./index-C5WTfF4A.js";import{u as dn,p as un,R as hn}from"./useSearchTokenContext-CrFL5qdR.js";import{u as fn,a as mn,R as gn}from"./useRefreshControl-DQLj8qF7.js";import{C as Vt,a as Ht,c as qt,j as pn,M as xn,t as Ut,u as bn,b as vn,d as Qt,e as Jt,f as Sn,g as yn,h as Cn,r as In,n as jn,i as Tn,k as wn,l as kn,m as Mn,o as Rn,S as En,p as An,D as On,q as Nn,s as zn,v as Gt,w as Fn,x as Dn,y as Ln,z as _n,A as Pn,B as Yt,E as Bn,F as $n,G as Wn,H as Kn,I as Vn,J as Hn,K as qn,L as Un,N as Nt,O as zt,P as Qn,Q as Jn,R as Gn,T as Yn,U as Xn,V as Zn,W as eo,X as to,Y as so,Z as no,_ as oo,$ as io,a0 as Xt,a1 as Zt,a2 as es,a3 as ro,a4 as ao,a5 as lo,a6 as ts,a7 as co,a8 as uo,a9 as ho}from"./MailListHeader-BvUp2YAz.js";import{S as fo,M as mo,a as go,u as po,b as xo}from"./MailViewChrome-CV4Xw32m.js";import{A as kt}from"./avatar-Dx2nnu8-.js";import{b as Je,d as bo,c as ss}from"./format-B3uyVYnZ.js";import{b as vo,c as So,a as yo,u as Co}from"./useMessageBodyContent-yDESgRfR.js";import{k as Ge,l as Io,m as jo,n as To,f as wo,o as ko}from"./search-token-index-BpY-q8ZV.js";import{N as Mo}from"./NavMenuButton-DCzDPYUK.js";import{C as Ro}from"./confirm-dialog-DwQkoRYj.js";import{f as Eo}from"./ErrorState-DxtMMIPM.js";import{a as Ao}from"./useLabels-Jy2JcPrZ.js";import{L as Oo,r as No,u as zo}from"./useSemanticSearch-RVZNROuq.js";import{S as ht}from"./shield-check-CK0lIMjR.js";import{B as Fo}from"./bottom-sheet-B9BJ1XTT.js";import{C as Do}from"./circle-help-Bl00srtt.js";import{C as Lo}from"./circle-check-4_VJQKru.js";import{n as _o}from"./search-query-Cr_ZXBCp.js";import{u as Po}from"./index-C8DX_EQn.js";const Bo=({children:e,onRefresh:n,isRefreshing:t})=>Ts(ws)?e:r.jsx(ks,{onRefresh:n,isPullable:!t,children:e}),$o=e=>e===1?"message":"messages";function Wo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(ut,{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(ht,{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} ${$o(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(ee,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",ns=({senderTrust:e,size:n="sm",className:t})=>{const s=Ko(e,n);return s==="vip"?r.jsx(Ms,{className:Oe("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Oe("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 Vo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:l,snippet:a,trustReason:d,trustSubReason:u,senderTrust:h}=e;return r.jsxs("label",{className:Oe("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(Vt,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(kt,{name:o,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:o}),h&&r.jsx(ns,{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(ht,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const Ho=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},qo=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Ft=e=>e===1?"message":"messages";function Uo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=qo(e,n),a=e.messages.length,d=o?Rs:Es;return r.jsxs("div",{className:Oe(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(Vt,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Ft(a)} from ${e.senderName}`}),r.jsx(kt,{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(ns,{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(ht,{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(u=>!u),"aria-expanded":o,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} ${Ft(a)}`,r.jsx(d,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(u=>r.jsx(Vo,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const Mt=e=>e===1?"message":"messages",Qo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Mt(e)}`} out of Spam to ${n} now. Nothing later.`,Ct=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Jo(){return r.jsx(ut,{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 Go({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:l,onCancel:a}){const[d,u]=c.useState(!1),h=n.size,g=c.useMemo(()=>Ho(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(ht,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Do,{className:"size-3.5"}),onClick:()=>u(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."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(Jo,{})})]}),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(ee,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(ee,{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(Uo,{group:m,selected:n,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(ee,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${Mt(h)}`}),r.jsx(ee,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Yo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:l}){const[a,d]=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(As,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>d(!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:Ct(n,s)}),r.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>d(!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:Qo(e,Ct(n,s))}),r.jsx(ee,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(ee,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Xo({count:e,destinationLabel:n,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(Lo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Mt(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(ee,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Zo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:l}){const[a,d]=c.useState("review"),[u,h]=c.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[g,m]=c.useState(t),[p,C]=c.useState(0),b=c.useRef(!1);c.useEffect(()=>{e&&!b.current&&(d("review"),h(new Set(n.map(I=>I.id))),m(t),C(0)),b.current=e},[e,n,t]);const w=u.size,v=I=>{h(j=>{const E=new Set(j);return E.has(I)?E.delete(I):E.add(I),E})},x=(I,j)=>{h(E=>{const A=new Set(E);for(const L of I.messages)j?A.add(L.id):A.delete(L.id);return A})},k=()=>{const I=Array.from(u);C(I.length),i(I,g),d("done")};return r.jsxs(Fo,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(Go,{candidates:n,selected:u,onToggle:v,onToggleGroup:x,onSelectAll:()=>h(new Set(n.map(I=>I.id))),onSelectNone:()=>h(new Set),onContinue:()=>d("destination"),onCancel:l}),a==="destination"&&r.jsx(Yo,{count:w,folders:s,delimiter:o,destination:g,onPick:m,onMove:k,onBack:()=>d("review")}),a==="done"&&r.jsx(Xo,{count:p,destinationLabel:Ct(s,g),onClose:l})]})}function ei(e){const n=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:n?`To: ${n}`:"(No recipients)",timeLabel:Je(e.updatedAt),isRead:!0}}function ti(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:Je(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function si({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(ei),o=t.map(ti),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const ni=({label:e,count:n})=>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:n})]}),oi=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Oe("group",qt({active:n})),children:[r.jsx(Ds,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Ht,{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:o,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(Bt,{className:"size-3.5"})})})]}),ii=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Oe("group",qt({active:n})),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(kt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Ht,{thread:e})]})};function ri({accountId:e,selectedMessageId:n,imapThreads:t,title:s,unreadCount:o}){const i=vo(),l=So(),a=Ge(),d=It(),{data:u}=jt(Os()),h=c.useMemo(()=>si({outboxMessages:u?.items??[],accountId:e,imapThreads:t}),[u?.items,e,t]),g=Tt({...zs(),onSuccess:()=>{d.invalidateQueries({queryKey:Ns()})}}),m=b=>{g.mutate({path:{outboxMessageId:b}})},p=b=>{const w=t.find(v=>v.messageId===b)?.threadId;w&&a({threadId:w,messageId:b})},C=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(Mo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),(o??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[o," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:C?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Fs,{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(b=>r.jsxs("div",{children:[b.label&&r.jsx(ni,{label:b.label,count:b.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:b.threads.map(w=>b.id==="remit-drafts"?r.jsx(oi,{row:w,isSelected:w.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},w.id):r.jsx(ii,{row:w,isSelected:w.id===n,onOpen:p},w.id))})]},b.id))})]})}const os=e=>e===1?"1 message":`${ss(e)} messages`,ai=e=>({title:"Empty Trash?",description:`${os(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),li=(e,n={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=n;if(e==="unconfirmed"){const o=bo(0,"unconfirmed",{trashFolderLabel:t});return{headline:o.title,body:o.description,actionLabel:o.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 ci({messageCount:e,isEmptying:n,deletedCount:t,refusalReason:s,trashFolderLabel:o,staleFolderLabel:i,onEmpty:l,onRepair:a,children:d}){const[u,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:d});const g=s?li(s,{trashFolderLabel:o,staleFolderLabel:i}):void 0,m=ai(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:`${os(t)} erased from the mail server.`}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Bt,{className:"size-3.5","aria-hidden":!0}),disabled:n||e<1,"aria-busy":n,onClick:()=>h(!0),children:n?"Emptying…":"Empty Trash"})]}),g&&r.jsx(ut,{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(ee,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:d}),r.jsx(Ro,{isOpen:u,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function di(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,l){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const d=+i;if(Number.isInteger(d)&&d>=0&&d<e){let u=o[d];if(!u){const h=n[d*2];u=o[d]={index:d,key:t(d),start:h,size:n[d*2+1],end:h+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,l)}})}function Be(e,n,t){let s=t.initialDeps??[],o,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((u,h)=>s[h]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return l.updateDeps=a=>{s=a},l}function Dt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const ui=(e,n)=>Math.abs(e-n)<1.01,hi=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let Qe;const St=()=>{if(Qe!==void 0)return Qe;if(typeof navigator>"u")return Qe=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Qe=!0;const e=navigator.maxTouchPoints;return Qe=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Lt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},fi=e=>e,mi=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},gi=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=l=>{const{width:a,height:d}=l;n({width:Math.round(a),height:Math.round(d)})};if(o(Lt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const d=l[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Lt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},dt={passive:!0},pi=typeof window>"u"?!0:"onscrollend"in window,xi=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&pi;let l=0;const a=i?null:hi(o,()=>n(l,!1),e.options.isScrollingResetDelay),d=g=>()=>{l=t(s),a?.(),n(l,g)},u=d(!0),h=d(!1);return s.addEventListener("scroll",u,dt),i&&s.addEventListener("scrollend",h,dt),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",h)}},bi=(e,n)=>xi(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),vi=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Si=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},yi=Si;class Ci{constructor(n){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,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const l=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,h]of this.elementsCache)if(h===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:fi,rangeExtractor:mi,onChange:()=>{},measureElement:vi,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,d=null,u=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=l.count,p=i.count,C=this.getMeasurements(),b=m>0?((s=C[0])==null?void 0:s.key)??l.getItemKey(0):null,w=m>0?((o=C[m-1])==null?void 0:o.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==b||i.getItemKey(p-1)!==w)){u=!0;const k=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??C[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==w)&&(d=I)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,C=this.getMeasurements(),{count:b,getItemKey:w}=this.options;let v=0;for(;v<b&&w(v)!==m;)v++;if(v<b){const x=C[v];if(x){const k=x.start+p;k!==this.scrollOffset&&(g=k-this.scrollOffset,this.scrollOffset=k,h=!0)}}}(h||d)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,d,g])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=Be(()=>(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,!(!St()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,dt),i.addEventListener("touchend",a,dt),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 o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,l,a,d]=o;i!==null&&!a&&(St()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):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 o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,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=Be(()=>[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,o,i,l,a,d,u)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=Be(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:d,gap:u},h)=>{const g=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const v of this.laneAssignments.keys())v>=t&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.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 v=t*2;let x=this._flatMeasurements;if(!x||x.length<v){const j=new Float64Array(v);x&&m>0&&j.set(x.subarray(0,m*2)),x=j,this._flatMeasurements=x}let k;if(m===0)k=s+o;else{const j=m-1;k=x[j*2]+x[j*2+1]+u}for(let j=m;j<t;j++){const E=i(j),A=g.get(E),L=typeof A=="number"?A:this.options.estimateSize(j);x[j*2]=k,x[j*2+1]=L,k+=L+u}const I=di(t,x,i);return this.measurementsCache=I,I}const p=this.measurementsCache.slice(0,m),C=new Array(a).fill(void 0),b=new Float64Array(a);let w=0;for(let v=0;v<m;v++){const x=p[v];x&&(C[x.lane]===void 0&&w++,C[x.lane]=v,b[x.lane]=x.end)}for(let v=m;v<t;v++){const x=i(v),k=this.laneAssignments.get(v);let I,j;const E=d==="estimate"||g.has(x);if(k!==void 0&&this.options.lanes>1){I=k;const N=C[I],J=N!==void 0?p[N]:void 0;j=J?J.end+u:s+o}else if(w===a){let N=0,J=b[0],_=C[0];for(let G=1;G<a;G++){const te=b[G];(te<J||te===J&&C[G]<_)&&(N=G,J=te,_=C[G])}I=N,j=J+u,E&&this.laneAssignments.set(v,I)}else I=v%this.options.lanes,j=s+o,E&&this.laneAssignments.set(v,I);const A=g.get(x),L=typeof A=="number"?A:this.options.estimateSize(v),O=j+L;p[v]={index:v,start:j,size:L,end:O,key:x,lane:I},C[I]===void 0&&w++,C[I]=v,b[I]=O}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Be(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=ji(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Be(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,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 o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,o-i),a=Math.min(this.options.count-1,o+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),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let l,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],l=u[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;d=m.key,a=m.start,l=m.size}const h=this.itemSizeCache.get(d)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,C=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:d,start:a,size:l,end:a+l,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(d,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-p):C&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Be(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,l=t.length;i<l;i++){const a=t[i],d=s[a];o.push(d)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,l=is(0,s.length-1,i?a=>o[a*2]:a=>Dt(s[a]).start,t);return Dt(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,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+i?"end":"start"),s==="center"?t+=(o-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 o=this.getSize(),i=this.getScrollOffset(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+o-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:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="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,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{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 o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,l=this._flatMeasurements;l!=null?o=l[i*2]+l[i*2+1]:o=((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--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(St()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,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,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,l=o!==this.scrollState.lastTargetOffset;if(!l&&ui(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const a=this.getSize()||600,d=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&d>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const is=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function Ii(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function ji(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const u=Ii(o,i,t);let h=u;const g=t+n;for(;h<i&&o[h*2]+o[h*2+1]<g;)h++;return{startIndex:u,endIndex:h}}let a=is(0,i,u=>e[u].start,t),d=a;if(s===1)for(;d<i&&e[d].end<t+n;)d++;else if(s>1){const u=Array(s).fill(0);for(;d<i&&u.some(g=>g<t+n);){const g=e[d];u[g.lane]=g.end,d++}const h=Array(s).fill(t+n);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),d=Math.min(i,d+(s-1-d%s))}return{startIndex:a,endIndex:d}}const yt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Ti({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=c.useReducer(u=>u+1,0)[1],i=c.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const l=u=>{const h=i.current;if(!h.enabled||!h.container)return;const g=u.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const v=u.options.horizontal?"width":"height";h.container.style[v]=`${g}px`}const m=!!u.options.horizontal,p=h.mode==="transform",C=m?"left":"top",b=u.options.scrollMargin,w=u.getVirtualItems();for(const v of w){const x=v.start-b,k=u.elementsCache.get(v.key);k&&h.lastPositions.get(k)!==x&&(h.lastPositions.set(k,x),p?k.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:k.style[C]=`${x}px`)}},a={...s,onChange:(u,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(u);const C=u.range,b=m.prevRange;p=!b||b.isScrolling!==u.isScrolling||b.startIndex!==C?.startIndex||b.endIndex!==C?.endIndex,p&&(m.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:u.isScrolling}:null)}p&&(e&&h?Ls.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,h)}},[d]=c.useState(()=>{const u=new Ci(a);return Object.assign(u,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=u.getTotalSize();g.lastSize=m;const p=u.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return d.setOptions(a),yt(()=>d._didMount(),[]),yt(()=>d._willUpdate()),yt(()=>{l(d)}),d}function wi(e){return Ti({observeElementRect:gi,observeElementOffset:bi,scrollToFn:yi,...e})}const Rt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",ki=e=>`Select all ${Rt(e)}`,Mi=(e,n)=>`All ${ss(n)} ${Rt(e)} selected`,Ri=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=pn(s,o);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},Ei=(e,n,t)=>e==="BACK"&&n&&t===void 0,Ai=(e,n)=>({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:Je(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Oi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:p})=>r.jsx(xn,{thread:Ai(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:h,onLongPress:g}}),Ni=c.memo(Oi),zi=e=>{const n=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:Je(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),suspicious:n}},Fi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:p,density:C})=>{const[b,w]=c.useState("none"),v=Ge(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),w("none")},[m,p,e.messageId,e.isRead]),k=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),I=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{v({threadId:e.threadId,messageId:e.messageId})},[v,e.threadId,e.messageId]),E=bn(e.messageId,d);return g||u?r.jsx(Ni,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,density:C}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(fo,{thread:zi(e),selectionMode:!1,checked:!1,active:t,peek:b,onPeek:w,onToggleCheck:I,onLongPress:k,onOpen:j,onAct:x})})},Di=72,Li=32,_i=5,rs="remit:list-density",Pi=()=>{try{const e=localStorage.getItem(rs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Bi=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Ks,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),$i=(e,n,t)=>No(e.filter(s=>n.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Wi=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:h=!1,isMoving:g=!1,onLoadMore:m,hasMore:p=!1,isLoadingMore:C=!1,accountId:b,listTitle:w,listMeta:v,listFilter:x,listScopeLabel:k,onTriageContextChange:I,commandsRef:j,hideHeader:E=!1})=>{const A=c.useRef(null),L=Ge(),O=_s(),N=Ps(),{verb:J,start:_,startFromSearch:G}=N,te=Bs(),me=!!a?.trim(),P=vn(),{labels:$e}=Ao(b),{pushError:re}=$t(),[M,Ie]=c.useState(t),[W,je]=c.useState(),K=c.useCallback(f=>{je(S=>S===f?S:void 0),Ie(f)},[]),[D,We]=c.useState(Pi),ge=c.useCallback(()=>{We(f=>{const S=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(rs,S)}catch{}return S})},[]),{toggleReadFor:pe}=Qt({mailboxId:e}),{junkMailboxId:ae}=Jt(b),Ne=Gt(ae,e),ze=c.useMemo(()=>[{accountId:b,mailboxId:e}],[b,e]),{outcome:le,staleFolderLabel:V,guessedMailboxId:H}=Sn(ze),{selectedIds:X,selectedCount:q,hasSelection:oe,isSelected:Fe,toggle:Z,select:Te,clearSelection:ce,selectRange:de,setAnchor:z,selectAll:we,toggleAll:Ke,intersectWith:De}=yn(),R=zn(q,O),[ke,ue]=c.useState(null),Ve=me&&!!d,Ye=`${e}|${JSON.stringify(d??{})}`,T=Cn({mailboxId:e,accountId:b,enabled:Ve,predicateKey:Ye,searchQuery:d??{}}),Xe=c.useCallback((f,S,fe)=>{const Q=In(f,S,fe,le);Q&&re(Q)},[re,le]),Me=T.phase.kind,Ze=T.clear,F=c.useCallback(()=>{Me==="escalated"&&Ze(),ce()},[ce,Ze,Me]),[et,tt]=c.useState(null),xe=c.useRef(null),ie=c.useRef(!1),be=c.useRef(null),Re=!s&&n.length>0,ve=ke!==null,Se=wi({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>D==="compact"?Li:Di,overscan:_i}),Le=t?n.findIndex(f=>f.messageId===t):-1,se=M?n.findIndex(f=>f.messageId===M):-1,ne=c.useCallback(f=>{if(f<0||f>=n.length)return;const S=n[f];if(R){Z(S.messageId);return}xe.current=S.messageId,ie.current=!1,je(S.messageId),Ie(S.messageId)},[n,R,Z]),He=c.useCallback(()=>{if(n.length===0)return;const f=se<0?0:Math.min(se+1,n.length-1);ne(f)},[n.length,se,ne]),ye=c.useCallback(()=>{if(n.length===0)return;const f=se<=0?0:se-1;ne(f)},[n.length,se,ne]),Ee=c.useCallback(()=>ne(0),[ne]),Ae=c.useCallback(()=>ne(n.length-1),[ne,n.length]),st=c.useCallback(()=>{M&&Z(M)},[M,Z]),B=c.useMemo(()=>n.map(f=>f.messageId),[n]),mt=c.useMemo(()=>{const f=[];for(const S of n)X.has(S.messageId)&&f.push({id:S.messageId,sender:S.fromName??S.fromEmail??"Unknown",email:S.fromEmail??"",subject:S.subject??"(No subject)",date:Je(S.sentDate),accountId:b});return f},[n,X,b]),Ce=c.useCallback((f,S)=>S.shiftKey?(de(B,f,M),!0):S.metaKey||S.ctrlKey?(Z(f),!0):(F(),z(f),!1),[B,M,de,Z,F,z]),nt=c.useCallback(f=>{!u||f.length===0||(be.current=M??null,ue(f))},[u,M]),_e=c.useCallback(f=>{const S=jn(B,M,f);S!==void 0&&(de(B,S),xe.current=S,ie.current=!1,je(void 0),Ie(S))},[B,M,de]),ot=c.useCallback(()=>_e(-1),[_e]),it=c.useCallback(()=>_e(1),[_e]),rt=c.useCallback(()=>{B.length>0&&we(B)},[B,we]),at=c.useCallback(f=>{const S=Ri({verb:f,confirmingDelete:ke!==null,hasSelection:oe,junkMailboxId:ae,currentMailboxId:e,deletableMessageId:u?M:void 0});return S.kind==="openWizard"?(_(f),!0):S.kind==="confirmDelete"?(nt([S.messageId]),!0):S.kind==="unavailable"?(re({severity:"warning",title:S.reason}),!0):S.kind==="withheld"},[ke,u,oe,ae,e,_,M,nt,re]),he=c.useCallback((f,S)=>{const fe=n.find(Q=>Q.messageId===f)?.threadId;fe&&L({threadId:fe,messageId:f},{replace:S?.replace})},[L,n]),qe=c.useCallback(()=>{M&&he(M)},[M,he]),lt=c.useCallback(f=>he(f,{replace:!0}),[he]);Tn({keyboardFocusedMessageId:W,openMessageId:t,enabled:O&&q===0,open:lt});const Ue=T.phase.kind==="escalated"?{scope:Rt(d??{}),total:T.phase.total,searchQuery:d??{},run:f=>T.runAction(f),stop:T.stop}:void 0,gt=c.useCallback(f=>{if(f.length===0){ue(null);return}const S=new Set(f),fe=n.findIndex(Y=>S.has(Y.messageId));let Q;for(let Y=fe+1;Y<n.length;Y++)if(!S.has(n[Y].messageId)){Q=n[Y].messageId;break}if(Q===void 0){for(let Y=fe-1;Y>=0;Y--)if(!S.has(n[Y].messageId)){Q=n[Y].messageId;break}}u?.(f),F(),be.current=null,ue(null),Q!==void 0&&(xe.current=Q,ie.current=!1,K(Q),O&&he(Q,{replace:!0})),O||tt(wn("delete",f.length,le))},[n,u,F,he,O,K,le]),pt=c.useCallback(()=>{const f=be.current;be.current=null,ue(null),f!==null&&(xe.current=f,ie.current=!1,K(f))},[K]),Pe=c.useMemo(()=>$i(n,X,b),[b,X,n]),xt=c.useCallback(()=>{if(Ue){G();return}_("organize")},[Ue,G,_]),y=c.useCallback(f=>{u?.([f])},[u]),U=c.useCallback((f,S)=>{pe([f],!S)},[pe]),$=c.useCallback(f=>{O||Te(f)},[O,Te]),ds=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}F()},[T,F]),us=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(ie.current||!O&&t)return;const f=se>=0?se:Le;f>=0&&Se.scrollToIndex(f,{align:"auto"})},[se,Le,Se,O,t]),c.useEffect(()=>{t&&(ie.current=!1,K(t))},[t,K]),c.useEffect(()=>{M&&(n.some(f=>f.messageId===M)||K(n[0]?.messageId))},[n,M,K]),c.useEffect(()=>{I?.({focusedMessageId:M,selectedIds:Array.from(X),hasList:Re,blocksKeyboard:ve||N.isOpen})},[M,X,Re,ve,N.isOpen,I]);const Et=c.useRef(I);Et.current=I,c.useEffect(()=>()=>Et.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||De(n.map(f=>f.messageId))},[n,De,T.phase,T.isRunning]);const At=c.useRef(e);c.useEffect(()=>{At.current!==e&&(At.current=e,F())},[e,F]),kn({shouldBlockFn:({action:f})=>Ei(f,oe,te)?(F(),!0):!1,enableBeforeUnload:!1,disabled:!oe||te!==void 0}),c.useEffect(()=>{const f=A.current;if(!f||!p||!m)return;const S=()=>{if(C)return;const{scrollTop:fe,scrollHeight:Q,clientHeight:Y}=f;fe+Y>=Q-200&&m()};return f.addEventListener("scroll",S,{passive:!0}),S(),()=>f.removeEventListener("scroll",S)},[p,C,m]),c.useEffect(()=>{const f=xe.current;if(!f)return;const S=A.current?.querySelector(`[data-message-id="${f}"]`);S&&(xe.current=null,S.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!Re){j.current=null;return}return j.current={focusNext:He,focusPrevious:ye,focusFirst:Ee,focusLast:Ae,openFocused:qe,toggleSelect:st,extendSelectDown:it,extendSelectUp:ot,selectAll:rt,clearSelection:()=>oe?(F(),!0):!1,requestVerb:at,toggleDensity:ge},()=>{j.current=null}}},[j,Re,He,ye,Ee,Ae,qe,st,it,ot,rt,oe,F,at,ge]);const Ot=s?"loading":o?"error":n.length===0?"empty":"ready",hs=o?Eo(i):void 0,fs=c.useCallback(()=>{const f=$s(Ws());window.open(f,"_blank","noopener,noreferrer")},[]),ms=[{id:"inbox",threads:[]}],bt=B.length>0&&B.every(f=>X.has(f)),gs=Ve&&p&&bt&&!h&&!g&&T.phase.kind==="idle"&&!T.isRunning,ps=h||g||T.isRunning,vt=T.phase.kind==="escalated"?T.phase.total:q,xs=T.runningAction?Mn(T.runningAction.kind,T.progress?.done??0,T.progress?.total??vt):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?Mi(d??{},T.phase.total):void 0,bs=T.phase.kind!=="escalated"&&B.length>0?{checked:bt,indeterminate:q>0&&!bt,onChange:()=>Ke(B)}:void 0,vs=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??vt,tone:Rn(T.runningAction.kind)}:void 0,Ss=(T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"&&!T.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:us}}:gs?{tone:"info",text:"",action:{label:ki(d??{}),onClick:T.escalate}}:void 0)??(Pe?{tone:"warning",text:Pe}:void 0),ys=r.jsx(En,{title:P.title||w,navSlot:P.navSlot,titleMeta:P.titleMeta,searchSlot:P.searchSlot,searchField:P.searchField,idleSlot:P.makeFilterSlot,count:vt,onCancel:ds,onDelete:()=>_("delete"),onMove:()=>_("move"),onOrganize:xt,onJunk:Ne?()=>_("junk"):void 0,onMarkRead:()=>_("markRead"),overflowSlot:b&&e&&q>0&&$e.length>0?r.jsx(Oo,{accountId:b,mailboxId:e,messageIds:Array.from(X)}):void 0,isBusy:ps,isCounting:T.phase.kind==="counting",selectAll:bs,statusLabel:xs,progress:vs,notice:Ss}),Cs=An(B,M),Is=c.useCallback(f=>{ie.current=!0,K(f)},[K]),js=r.jsxs(r.Fragment,{children:[me&&a&&r.jsx(Bi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":w,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${Se.getTotalSize()}px`},children:Se.getVirtualItems().map(f=>{const S=n[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:Se.measureElement,className:Oe("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(Fi,{thread:S,mailboxId:e,isSelected:t===S.messageId,isFocused:M===S.messageId,isTabStop:Cs===S.messageId,onFocusRow:Is,isChecked:Fe(S.messageId),onToggleCheck:Z,onRowSelect:Ce,isMultiSelectMode:R,onLongPress:$,isDesktop:O,onDelete:y,onToggleRead:U,density:D})},f.key)})}),C&&r.jsx(mo,{})]})]});return r.jsxs(r.Fragment,{children:[et&&!O&&r.jsx(ut,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>tt(null),children:et}),r.jsx(go,{listTitle:w,listMeta:v,sections:ms,flatList:!0,listState:P.searchResults?"ready":Ot,searchQuery:me?a:void 0,listFilter:x,listScopeLabel:k,errorMessage:hs,onRetry:l,onReportError:fs,density:D,selectedThreadId:t,onSelectThread:f=>he(f),isDesktop:O,hideHeader:E,selectionBar:ys,listBody:P.searchResults??(Ot==="ready"?js:void 0)}),r.jsx(On,{isOpen:ke!==null,messageIds:ke??[],outcome:le,accountId:b,trashFolderLabel:w,staleFolderLabel:V,guessedMailboxId:H,isDeleting:h,onConfirm:gt,onCancel:pt}),r.jsx(Nn,{verb:J,accountId:b,mailboxId:e,selection:mt,selectionRestriction:Pe?"spansAccounts":void 0,escalated:Ue,escalatedProgress:T.progress,onFinished:F,onRunEnded:Xe})]})},Ki=e=>Wt({path:{accountId:e}}),Vi=e=>{const n=It(),t=wt(),s=Tt({...Vs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Hi=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Vi(e);return r.jsx(Bo,{onRefresh:t,isRefreshing:s,children:n})};function qi({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=wt(),d=Hs(),{inboxMailboxId:u}=Fn(e),h=Dn(e),{data:g}=jt({...qs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Us({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:n,translator:d}),[g?.items,h,n,d]),p=c.useMemo(()=>u||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[u,m]),C=c.useRef(!1);c.useEffect(()=>{C.current||(C.current=!0,Ln(a,t.length))},[a,t.length]);const b=c.useCallback(()=>{_n(a,t.length),l(!0)},[a,t.length]),w=c.useCallback((v,x)=>{Pn(a,{selected:v.length,total:t.length,toInbox:x===u}),s(v,x)},[a,t.length,u,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(Wo,{count:t.length,onReview:b})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Zo,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:Qs(g?.items??[]),onConfirmMove:w,onCancel:()=>l(!1)})]})}const Ui=(e,n,t,s)=>`${e??""}|${n}|${t??""}|${s??""}`,Qi=({accountId:e,mailboxId:n})=>{const t=It(),{pushError:s}=$t(),{requestAppointment:o}=Js(),{trashByAccount:i}=Yt(),l=e?i.get(e):void 0,a=Ui(e,n,l?.mailboxId,l?.source),[d,u]=c.useState({scope:a});d.scope!==a&&u({scope:a});const h=d.scope===a?d:void 0,g=c.useCallback(()=>t.getQueryData(Gs())?.accounts.find(j=>j.accountId===e)?.folderAppointments.find(j=>j.role==="Trash")?.mailboxId??n,[t,e,n]),m=c.useRef(void 0),{mutateAsync:p,isPending:C}=Tt({...Zs(),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,k,I)=>{I.scope===a&&u({scope:a,deletedCount:x.deletedCount})},onError:(x,k,I)=>{const j=Ys(x);if(!j){s({title:"Couldn't empty Trash",detail:Xs(x),error:x});return}I?.scope===a&&u({scope:a,refusal:j})},onSettled:(x,k,I,j)=>{m.current===j?.scope&&(m.current=void 0),Bn(t,$n([j?.listMailboxId??n])),e&&t.invalidateQueries({queryKey:Wt({path:{accountId:e}})})}}),b=c.useCallback(()=>e?(u({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),w=c.useCallback(()=>{b()},[b]),v=c.useCallback(()=>{const x=h?.refusal;x&&o({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:b})},[h,o,b]);return{emptyTrash:w,isEmptying:C&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:v}},Ji="We can verify this sender";function Gi(e){const{data:n}=jt({...en({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.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:Ji,trustSubReason:Wn(s.senderTrust),senderTrust:s.senderTrust}))}}const Yi=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Xi={unread:"unread",flagged:"starred",attachment:"attachments"},Zi=new Set(Object.values(tn)),as=e=>Zi.has(e),er=e=>as(e.category)||e.attributes.size>0,tr=e=>{const n={};as(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Xi[t];s&&(n[s]=!0)}return n},sr=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",nr=["category","unread","starred","attachments"],_t=e=>JSON.stringify(nr.map(n=>e?.[n]??null)),or=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},ir=(e,n)=>{const t=or(e);return t?_t(t)===_t(n):!1},ct=e=>e[0],rr=e=>{const n=ct(e.filter(a=>a.type==="from").map(a=>a.value)),t=ct(e.filter(a=>a.type==="subject").map(a=>a.value)),s=ct(e.filter(a=>a.type==="category").map(a=>a.category)),o=ct(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,l=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...l!==void 0?{attachments:l}:{}}},ar=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function lr(e,n={}){const t=rr(e),s={...t,...n};return{params:t,residual:e.filter(o=>!ar(s,o))}}function cr(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=Kn(o);return Vn({...i,accountId:i.accountId??t},s)})}const dr=50,ur=new Map(ts().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),ls=c.createContext(null);function ft(){const e=c.useContext(ls);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function hr({mailboxId:e,thread:n,children:t}){const s=Ge(),o=Io(),i=Po(),l=n?.threadId,a=n?.messageId,d=wt(),{accounts:u,searchQuery:h,onToggleIntelligence:g}=Kt(),m=dn(),p=_o(h),C=p.length>0,{freeText:b,tokens:w}=un(p,m),[v,x]=c.useState("all"),[k,I]=c.useState(new Set),j=c.useMemo(()=>({category:v,attributes:k}),[v,k]),E=c.useMemo(()=>tr(j),[j]),A=C||er(j),{params:L,residual:O}=lr(w,E),N={order:"desc",limit:dr,...b?{query:b}:{},...L,...E},J={category:N.category,unread:N.unread,starred:N.starred,attachments:N.attachments},_=A?sn({path:{mailboxId:e},query:N}):nn({path:{mailboxId:e},query:{order:"desc"}}),{data:G,isLoading:te,isError:me,error:P,refetch:$e,fetchNextPage:re,hasNextPage:M,isFetchingNextPage:Ie}=po({queryKey:_,queryFn:async({pageParam:y})=>{if(A){const{data:$}=await ln({path:{mailboxId:e},query:{...N,continuationToken:y},throwOnError:!0});return $}const{data:U}=await cn({path:{mailboxId:e},query:{order:"desc",continuationToken:y},throwOnError:!0});return U},initialPageParam:void 0,getNextPageParam:y=>y.continuationToken,placeholderData:(y,U)=>ir(U?.queryKey,J)?y:void 0}),{accountId:W,isLoading:je}=Hn(e),K=jo({accounts:u}),D=cr(qn(Yi(G?.pages.flatMap(y=>y.items??[])??[])),O,W),We=c.useCallback(y=>{x(y)},[]),ge=c.useCallback(y=>{I(U=>{const $=new Set(U);return $.has(y)?$.delete(y):$.add(y),$})},[]),pe=c.useCallback(()=>{x("all"),I(new Set)},[]),ae=ur.get(v),Ne=ae?{label:ae,reach:O.length>0?"loaded-pages":sr(N),onClear:pe}:void 0,ze=l?D.find(y=>y.messageId===a)??D.find(y=>y.threadId===l):void 0,le=Un(l,a),V=ze??le,H=a??V?.messageId,X=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:V?.mailboxId??e,subject:V?.subject,messageId:H,authenticity:V?.authenticity}},[l,V,H,e]),q=c.useCallback(y=>{H&&y.includes(H)&&o()},[H,o]),{deleteMessages:oe,isPending:Fe}=Nt({mailboxId:e,onAfterOptimisticRemove:q}),{moveMessages:Z,isPending:Te}=zt({mailboxId:e,accountId:W,onAfterOptimisticRemove:q}),ce=c.useRef(null),de=Qn(),{listCommandsRef:z,onTriageContextChange:we,focusedMessageId:Ke,selectedIds:De}=de,R=D.find(y=>y.messageId===Ke)??V,ke=To({accounts:u})??0,ue=Jn({thread:V,isOpen:!0,mailboxId:e,accountId:W,onAfterOptimisticRemove:q}),{draftsMailboxId:Ve}=Gn(W),Ye=Ve!==void 0&&Ve===e,{archiveMailboxId:T}=Yn(W),Xe=Xn(),Me=on(),Ze=c.useMemo(()=>rn(Me,l,H),[Me,l,H]),F=c.useMemo(()=>{if(R)return y=>Me({threadId:R.threadId,messageId:R.messageId,mode:y})},[Me,R]),et=yo(),tt=an(),xe=Co(),ie=c.useCallback(y=>y?Xe(y):[],[Xe]),{toggleStar:be}=Zn({threadId:R?.threadId??"",mailboxId:e}),{toggleReadFor:Re}=Qt({mailboxId:e,accountId:W}),{junkMailboxId:ve}=Jt(W),Se=ve!=null&&ve===e,Le=Gt(ve,e),{candidates:se}=Gi(Se?ve:void 0),{moveMessages:ne}=zt({mailboxId:e,threadId:R?.threadId,accountId:W,onAfterOptimisticRemove:q}),{deleteMessages:He}=Nt({mailboxId:e,threadId:R?.threadId,onAfterOptimisticRemove:q}),{addressId:ye,address:Ee}=eo(R),{updateFlags:Ae}=to({addressId:ye,senderEmail:R?.fromEmail??void 0}),st=c.useCallback(()=>F?.("reply"),[F]),B=c.useCallback(()=>F?.("reply-all"),[F]),mt=c.useCallback(()=>F?.("forward"),[F]),Ce=c.useCallback(()=>ie(R),[ie,R]),nt=c.useCallback(()=>{if(z.current?.requestVerb("delete"))return;const y=Ce();y.length>0&&He(y)},[z,Ce,He]),_e=c.useCallback(()=>{if(z.current?.requestVerb("junk")||!Le)return;const y=Ce();y.length!==0&&(so(d,{count:y.length,senderTrust:R?.senderTrust??"unknown",wasRescuable:R?no(R):!1}),ne(y,Le))},[z,Le,Ce,ne,d,R]),ot=c.useCallback(()=>{if(De.length>0){const y=!(R?.hasStars??!1),U=new Set(De);for(const $ of D)U.has($.messageId)&&$.hasStars!==y&&be($.messageId,$.hasStars);return}R&&be(R.messageId,R.hasStars)},[De,D,R,be]),it=c.useCallback(()=>{if(z.current?.requestVerb("markRead"))return;const y=Ce();if(y.length===0)return;const U=!(R?.isRead??!1);Re(y,U)},[z,Ce,R,Re]),rt=c.useCallback(()=>{if(!ye)return;const y=Ee?.flags?.muted?.value!==!0;Ae({muted:{value:y}})},[ye,Ee,Ae]),at=c.useCallback(()=>{if(!ye)return;const y=Ee?.flags?.vip?.value!==!0;Ae({vip:{value:y}})},[ye,Ee,Ae]),he=c.useCallback(()=>{ce.current?.open()},[]),qe=Ye?"drafts":T===e?"archive":ve===e?"junk":"inbox",lt=c.useRef("");c.useEffect(()=>{const y=lt.current;lt.current=p,p.length>0&&y.length===0&&d.recordEvent("search.submitted",{mailboxType:qe})},[p,qe,d]);const{goBack:Ue,nextMessageId:gt,previousMessageId:pt}=oo({context:de,orderedIds:D.map(y=>y.messageId),selectedMessageId:H,enabled:!et&&!tt,hasOpenThread:l!==void 0,onClose:o,handlers:{reply:st,replyAll:B,forward:mt,delete:nt,toggleStar:ot,toggleRead:it,muteSender:rt,blockSender:V?he:void 0,vipSender:at,markJunk:_e,toggleIntelligence:V?()=>ce.current?.toggle():void 0,compose:xe,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),Pe=y=>{if(!y)return;const U=D.find($=>$.messageId===y);return U?{threadId:U.threadId,messageId:y}:void 0},xt={mailboxId:e,selectedMessageId:H,selectedThread:V,conversation:X,onOpenThread:s,threads:D,isLoading:te,isError:me,error:P,mailboxAccountId:W,mailboxAccountLoading:je,mailboxName:K,unreadCount:ke,isDraftsMailbox:Ye,isSpamFolder:Se,rescueCandidates:se,filterCategory:v,filterAttributes:k,onSelectFilterCategory:We,onToggleFilterAttribute:ge,onClearFilters:pe,listFilter:Ne,onToggleIntelligence:g,intelligenceRef:ce,handleDeselectIfRemoved:q,searchPredicate:C&&O.length===0?N:void 0,onDeleteMessages:oe,onMoveMessages:Z,isDeleting:Fe,isMoving:Te,onLoadMore:re,hasMore:M,isLoadingMore:Ie,onTriageContextChange:we,listCommandsRef:z,onRetry:()=>$e(),onReply:Ze,onToolbarDelete:ue.deleteThread,onToolbarStar:ue.toggleStar,isStarred:ue.isStarred,onToolbarMove:ue.moveThread,onBack:Ue,nextThread:Pe(gt),previousThread:Pe(pt)};return r.jsx(ls.Provider,{value:xt,children:t})}function cs(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:p,mailboxName:C,unreadCount:b,isDraftsMailbox:w,isSpamFolder:v,rescueCandidates:x,onTriageContextChange:k,listCommandsRef:I,onRetry:j,filterCategory:E,filterAttributes:A,onSelectFilterCategory:L,onToggleFilterAttribute:O,onClearFilters:N,listFilter:J,searchPredicate:_}=ft(),{searchQuery:G,searchInput:te,accounts:me,resultFolderIndex:P}=Kt(),$e=wo(),re=Ge(),M=C??"Inbox",Ie=c.useMemo(()=>ts(),[]),{trashMailboxId:W}=co(p),je=ko({accounts:me}),{trashByAccount:K}=Yt(),D=Qi({accountId:p,mailboxId:e}),We=W!=null&&W===e,ge=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:pe}=fn(),{state:ae,errorMessage:Ne,refresh:ze}=mn(ge,{onSettled:j}),le=c.useMemo(()=>r.jsx(gn,{state:ae,onRefresh:ze,label:`Refresh ${M}`,errorMessage:Ne,hasUpdate:pe(ge)}),[ae,ze,M,Ne,pe,ge]),V=c.useMemo(()=>t.map(z=>uo(z,P)),[t,P]),{hits:H,isLoading:X}=zo({mailboxId:e,filterCategory:E}),q=c.useMemo(()=>ho(H,t.map(z=>z.threadId),P),[H,t,P]),oe=c.useCallback(z=>{const we=z.threadId??t.find(Ke=>Ke.messageId===z.id)?.threadId;we&&re({threadId:we,messageId:z.id},{mailboxId:z.mailboxId??e,query:te})},[e,re,te,t]);if(w&&p)return r.jsx(ri,{accountId:p,selectedMessageId:n,imapThreads:t,title:C??"Drafts",unreadCount:b??void 0});const Fe=r.jsx(Wi,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:G,searchPredicate:_,onDeleteMessages:l,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:J,listScopeLabel:M,hideHeader:!0,onTriageContextChange:k,commandsRef:I}),Z=me[0]?.accountId,Te=$e==="phone"&&Z?r.jsx(Hi,{accountId:Z,children:Fe}):Fe,ce=v&&x.length>0&&p?r.jsx(qi,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:Te}):Te,de=We?r.jsx(ci,{messageCount:je,isEmptying:D.isEmptying,deletedCount:D.deletedCount,refusalReason:D.refusal?.reason,trashFolderLabel:C??void 0,staleFolderLabel:p?K.get(p)?.staleFolderPath:void 0,onEmpty:D.emptyTrash,onRepair:D.repair,children:ce}):ce;return r.jsx(xo,{title:M,unreadCount:b,preset:Ie,selectedCategory:E,activeFilters:A,onSelectCategory:L,onToggleFilter:O,onClearFilters:N,searchResults:V,searchLoading:s,relatedResults:q,relatedLoading:X,onSelectSearchResult:oe,searchResultsInBody:!0,refreshControl:le,children:de})}function fr(){const{mailboxId:e,mailboxAccountId:n,mailboxAccountLoading:t,selectedThread:s,conversation:o,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:d,onToolbarMove:u,handleDeselectIfRemoved:h,intelligenceRef:g}=ft(),m=!!o,p=ao(o?.threadId);Xt(g,p);const C=c.useRef(null),{railFits:b,openRail:w}=p;c.useEffect(()=>{if(!b)return;const x=s?.messageId??null;x&&C.current!==x&&s?.authenticity?.dkimMismatch&&(C.current=x,w())},[b,w,s?.messageId,s?.authenticity?.dkimMismatch]);const v=o?r.jsx(Zt,{threadId:o.threadId,mailboxId:o.mailboxId,subject:o.subject,selectedMessageId:o.messageId,authenticity:o.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(hn,{});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(lo,{hasThread:m,messageId:o?.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:d,moveContext:m&&n?{accountId:n,currentMailboxId:e,onMove:u}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:v})]}),r.jsx(es,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:h})]})}function mr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=ft();return r.jsx(ro,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function gr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:d,intelligenceRef:u}=ft(),h=io(s?.threadId??null);return Xt(u,h),s?r.jsxs(r.Fragment,{children:[r.jsx(Zt,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>o(l):void 0,onSwipePrevious:a?()=>o(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(es,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:d})]}):r.jsx(cs,{})}const _r=Object.assign(hr,{List:cs,Reading:fr,Intelligence:mr,Phone:gr});export{_r as M};
@@ -1 +1 @@
1
- import{i as n,j as a,B as o}from"./index-DcpmB860.js";import{M as e}from"./menu-Du7BiMpN.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{i as n,j as a,B as o}from"./index-C5WTfF4A.js";import{M as e}from"./menu-DGvf1N4B.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};
@@ -0,0 +1 @@
1
+ import{c as re,j as e,b as z,ao as V,as as oe,r as i,aF as he,aI as I,ap as R,x as xe,aj as X,a5 as fe,an as ye,D as Q,aJ as Y,a1 as ne,B as E,ar as $,am as ge,aq as ve,aE as q,aB as be,I as we}from"./index-C5WTfF4A.js";import{K as Se}from"./kbd-B62acStO.js";import{c as je}from"./account-form-helpers-DhckT_PN.js";import{M as ke}from"./mail-7swSEn2S.js";const K=re("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"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ee({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ne({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...n}){return s?e.jsxs(V,{value:t,onChange:a=>s(a.target.value),...n,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...n,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,n)=>{const a=n<o,r=n===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[n>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",a&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!a&&!r&&"bg-surface-sunken text-fg-subtle"),children:a?e.jsx(oe,{className:"size-3"}):n+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function A({steps:t,activeStep:o,title:s,subtitle:n,children:a,footer:r,hideSteps:m}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!m&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ne,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),n&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:n})]}),e.jsx("div",{className:"px-5 py-5",children:a}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:n,selected:a,onSelect:r}){const[m,d]=i.useState(!1),c=()=>{if(r){r();return}n&&d(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":n||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",a?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",n&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",a&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),n&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),m&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:n,security:a,readOnly:r,onHostChange:m,onPortChange:d,onSecurityChange:c,hostPlaceholder:x,portPlaceholder:g}){const w=i.useId(),v=i.useId(),j=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Host"}),m?e.jsx(R,{id:w,readOnly:r,value:s,onChange:f=>m(f.target.value),placeholder:x}):e.jsx(R,{id:w,readOnly:r,defaultValue:s,placeholder:x})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:v,children:"Port"}),d?e.jsx(R,{id:v,readOnly:r,value:n,onChange:f=>d(f.target.value),placeholder:g}):e.jsx(R,{id:v,readOnly:r,defaultValue:n,placeholder:g})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:j,children:"Security"}),c?e.jsx(J,{id:j,value:a,onValueChange:c}):e.jsx(J,{id:j,defaultValue:a})]})]})]})}function _({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Le=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const n=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",n),window.addEventListener("pageshow",n),()=>{document.removeEventListener("visibilitychange",n),window.removeEventListener("pageshow",n)}},[t])},Ie=2e4,Ae="Couldn't open Microsoft's sign-in page. Check your connection, and anything blocking redirects, then try again.",Me=t=>{const o=i.useRef(!1),s=i.useRef(!1),n=i.useRef(null),a=i.useRef(t);a.current=t;const r=i.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null)},[]),m=i.useCallback(()=>{!o.current||!s.current||(r(),s.current=!1,a.current("returned"))},[r]);return i.useEffect(()=>{const d=()=>{s.current=!0,r()},c=()=>{document.visibilityState==="hidden"&&d()},x=g=>{g.persisted&&(d(),m())};return document.addEventListener("visibilitychange",c),window.addEventListener("pagehide",d),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",c),window.removeEventListener("pagehide",d),window.removeEventListener("pageshow",x),r()}},[m,r]),Le(!0,m),i.useCallback(()=>{o.current=!0,s.current=!1,r(),n.current=setTimeout(()=>{n.current=null,o.current=!1,s.current=!1,a.current("stalled")},Ie)},[r])},Re={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Fe={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const n=s.querySelectorAll("incomingServer[type='imap']"),a=s.querySelectorAll("outgoingServer[type='smtp']");if(!n.length||!a.length)return null;const r=n[0],m=a[0],d=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),x=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),g=m.querySelector("hostname")?.textContent?.trim(),w=m.querySelector("port")?.textContent?.trim(),v=m.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!d||!c||!g||!w)return null;const j=f=>f==="SSL"||f==="TLS"||f==="SSL/TLS"?"tls":f==="STARTTLS"?"starttls":"none";return{imap:{host:d,port:Number.parseInt(c,10),security:j(x)},smtp:{host:g,port:Number.parseInt(w,10),security:j(v)},source:"mozilla-autoconfig"}}catch{return null}}async function Oe(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,n=await fetch(s,{signal:o});if(!n.ok)return null;const a=await n.text(),r=ae(a);return r||null}catch{return null}}async function ze(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,n=await fetch(s,{signal:o});if(!n.ok)return null;const a=await n.text(),r=ae(a);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function _e(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function He(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const n=t.slice(s+1).toLowerCase();if(!n)return null;const a=Re[n];if(a)return a;const r=new AbortController,m=setTimeout(()=>r.abort(),o);try{const d=await Oe(n,r.signal);if(d)return d;const c=await ze(n,r.signal);if(c)return c}finally{clearTimeout(m)}return _e(n)}function De(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Fe[s]}const ce=[{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 ee(t){return ce.find(o=>o.id===t)}const $e={"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 qe(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return $e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],F={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function Ge({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(A,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(Se,{children:"Enter"})," to continue"]}),e.jsx(E,{variant:"primary",onClick:t,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(ke,{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."})]})})}function Be({onContinue:t,onMicrosoft:o,onBack:s,showBack:n}){const[a,r]=i.useState("imap");i.useEffect(()=>{const d=c=>{c.key==="Enter"&&(a==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t,o,s,a]);const m=()=>{a==="microsoft"?o():t()};return e.jsx(A,{steps:M,activeStep:F.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[n?e.jsx(E,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(E,{variant:"primary",onClick:m,children:a==="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(Ce,{className:"size-5"}),selected:a==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{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(we,{className:"size-5"}),selected:a==="microsoft",onSelect:()=>r("microsoft")})]})})}function Ue({onBack:t,onConnected:o}){const[s,n]=i.useState(""),[a,r]=i.useState(null),[m,d]=i.useState(!1),[c,x]=i.useState(!1),g=i.useRef(!0);i.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]);const w=i.useRef(new Set),{refetch:v}=Q(ne()),j=Me(l=>{if(x(!1),l==="stalled"){d(!1),r(Ae);return}v().then(({data:C,isError:y})=>{if(!g.current)return;if(y||!C){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const S=C.accounts.find(T=>!w.current.has(T.accountId));S&&o(S.accountId)})}),f=X({...be(),onSuccess:l=>{g.current&&(j(),d(!0),window.location.assign(l.authorizationUrl))},onError:l=>{x(!1),r(l instanceof Error?l.message:"Failed to start sign-in")}}),h=c||f.isPending,u=()=>{h||(r(null),x(!0),v().then(({data:l,isError:C})=>{if(g.current){if(C||!l){x(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}w.current=new Set(l.accounts.map(y=>y.accountId)),f.mutate({body:{email:s.trim()||void 0}})}}))},k=i.useRef(u);return k.current=u,i.useEffect(()=>{const l=C=>{C.key==="Enter"&&k.current(),C.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t]),e.jsx(A,{steps:M,activeStep:F.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(E,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(E,{variant:"primary",onClick:u,disabled:h,icon:h?e.jsx($,{className:"size-4 animate-spin"}):void 0,children:h?"Redirecting…":m?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(R,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:l=>n(l.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."})]}),m&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),a&&e.jsx(q,{tone:"danger",children:a})]})})}function We({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:n}){const[a,r]=i.useState(t),[m,d]=i.useState(o),[c,x]=i.useState(!1),[g,w]=i.useState(""),[v,j]=i.useState(null),f=i.useCallback(async()=>{const h=a.trim();if(!h.includes("@")||!h.includes(".")){j("Enter a valid email address.");return}j(null),x(!0),w(De(h));try{const u=await He(h);s(h,m.trim(),u)}finally{x(!1)}},[a,m,s]);return i.useEffect(()=>{const h=u=>{u.key==="Enter"&&!c&&f(),u.key==="Escape"&&n()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[f,c,n]),e.jsx(A,{steps:M,activeStep:F.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(E,{variant:"primary",disabled:c,onClick:()=>{f()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(R,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:a,onChange:h=>{r(h.target.value),j(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(R,{id:"onboarding-display-name",placeholder:"Alice",value:m,onChange:h=>d(h.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&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"}),g]}),v&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:v})})]})})}function Ve({email:t,imapConfig:o,smtpConfig:s,discovered:n,onContinue:a,onBack:r,onChange:m}){const[d,c]=i.useState(o),[x,g]=i.useState(s),[w,v]=i.useState(()=>qe(t)),[j,f]=i.useState(!1),[h,u]=i.useState(null),k=ee(w),l=k!==void 0&&!j,C=i.useCallback(b=>{v(b),f(!1),u(null);const p=ee(b);p&&(c({host:p.imap.host,port:p.imap.port,security:p.imap.security}),g({host:p.smtp.host,port:p.smtp.port,security:p.smtp.security}))},[]);i.useEffect(()=>{m(d,x)},[d,x,m]);const y=d.host.trim()!=="",S=i.useCallback(()=>{if(!y){u("Enter the IMAP host.");return}u(null),a()},[y,a]);i.useEffect(()=>{const b=p=>{p.key==="Enter"&&S(),p.key==="Escape"&&r()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[S,r]);const T=t.split("@")[1]??"your domain",O=k?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":n?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=l?{label:"preset",tone:"neutral"}:!k&&n?{label:"detected",tone:"positive"}:void 0,L=k?.passwordHelp.url??ie(t);return e.jsx(A,{steps:M,activeStep:F.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(E,{variant:"primary",onClick:S,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[h&&e.jsx(q,{tone:"danger",children:h}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:w,onChange:b=>C(b.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(b=>e.jsx("option",{value:b.id,children:b.label},b.id))]}),k&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:l?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",k.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>f(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",k.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:l,host:d.host,port:String(d.port),security:d.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:b=>{c(p=>({...p,host:b})),u(null)},onPortChange:b=>c(p=>({...p,port:Number(b)})),onSecurityChange:b=>c(p=>({...p,security:b}))}),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(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:l,host:x.host,port:String(x.port),security:x.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:b=>{g(p=>({...p,host:b})),u(null)},onPortChange:b=>g(p=>({...p,port:Number(b)})),onSecurityChange:b=>g(p=>({...p,security:b}))}),k&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[k.passwordHelp.text," ",L&&e.jsx("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Qe({email:t,username:o,password:s,onContinue:n,onBack:a,onChange:r}){const[m,d]=i.useState(o||t),[c,x]=i.useState(s),[g,w]=i.useState(null),v=t.split("@")[1]??"",j=ie(t),f=m.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(m,c)},[m,c,r]);const h=i.useCallback(()=>{if(!f){w("Enter your username and password.");return}w(null),n()},[f,n]);return i.useEffect(()=>{const u=k=>{k.key==="Enter"&&h(),k.key==="Escape"&&a()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[h,a]),e.jsx(A,{steps:M,activeStep:F.credentials,title:`Sign in to ${v||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(E,{variant:"primary",onClick:h,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[g&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:g}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(R,{id:"credentials-username",value:m,onChange:u=>{d(u.target.value),w(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:u=>{x(u.target.value),w(null)},autoComplete:"current-password"})]}),e.jsx(Ee,{url:j})]})})}function Xe({email:t,imapConfig:o,smtpConfig:s,username:n,password:a,onSuccess:r,onBackToCredentials:m,onBackToServers:d}){const[c,x]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[g,w]=i.useState(0),v=s.host.trim()!=="",j=G(o.security),f=G(s.security),h=X({...ge()});i.useEffect(()=>{let l=!1;const C=[];return x({imapState:"running",smtpState:"pending",phase:"running"}),h.mutate({body:{username:n,password:a,imapHost:o.host,imapPort:o.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:f.tls,smtpStartTls:f.startTls}},{onSuccess:y=>{if(l)return;const S=y.imapSuccess,T=v?y.smtpSuccess:!0;x({imapState:S?"ok":"failed",smtpState:v?"running":"ok",imapDetail:S?`Connected — ${o.host}:${o.port}`:y.imapError,phase:"running"}),C.push(window.setTimeout(()=>{if(l)return;const O=L=>{const b=L?.toLowerCase()??"";return b.includes("auth")||b.includes("login")||b.includes("535")||b.includes("credential")},P=!S&&O(y.imapError)||S&&v&&!y.smtpSuccess&&O(y.smtpError);x({imapState:S?"ok":"failed",smtpState:v?y.smtpSuccess?"ok":"failed":"ok",imapDetail:S?`Connected — ${o.host}:${o.port}`:y.imapError,smtpDetail:v?y.smtpSuccess?`Connected — ${s.host}:${s.port}`:y.smtpError:"Not set up — receive-only",rawError:S?v&&!y.smtpSuccess?y.smtpError:void 0:y.imapError,phase:S&&T?"success":P?"auth-failure":"network-failure"}),S&&T&&C.push(window.setTimeout(()=>{l||r()},800))},400))},onError:y=>{if(l)return;const S=y instanceof Error?y.message:"Connection failed";x({imapState:"failed",smtpState:"failed",imapDetail:S,smtpDetail:S,rawError:S,phase:"network-failure"})}}),()=>{l=!0;for(const y of C)window.clearTimeout(y)}},[g]);const{phase:u}=c;i.useEffect(()=>{const l=C=>{C.key==="Escape"&&(u==="auth-failure"?m():u==="network-failure"&&d())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[u,m,d]);const k=u==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"ghost",onClick:m,children:"Back to credentials"}),e.jsx(E,{variant:"primary",onClick:()=>w(l=>l+1),children:"Retry"})]}):u==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"ghost",onClick:d,children:"Back to servers"}),e.jsx(E,{variant:"primary",onClick:()=>w(l=>l+1),children:"Retry"})]}):u==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(E,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(A,{steps:M,activeStep:F.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:k,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(_,{label:v?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:v?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(u==="auth-failure"||u==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[u==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Ke=2e4;function Ye({email:t,displayName:o,imapConfig:s,smtpConfig:n,username:a,password:r,onGoToInbox:m}){const d=xe(),[c,x]=i.useState(null),[g,w]=i.useState(null),v=i.useRef(!1),j=G(s.security),f=G(n.security),h=X({...ye(),onSuccess:N=>{x(N.accountId),d.invalidateQueries({queryKey:fe()})},onError:N=>{w(N instanceof Error?N.message:"Failed to create account")}});i.useEffect(()=>{if(v.current)return;v.current=!0;const N=n.host.trim()!=="",H=je({imapHost:s.host,smtpHost:n.host,smtpPort:n.port}),D=N?H??{smtpHost:n.host,smtpPort:n.port,smtpTls:f.tls,smtpStartTls:f.startTls}:null;h.mutate({body:{email:t,displayName:o||void 0,username:a!==t?a:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:D?.smtpHost||void 0,smtpPort:D?.smtpPort||void 0,smtpTls:D?.smtpTls??!1,smtpStartTls:D?.smtpStartTls??!1}})},[]);const{data:u,isError:k}=Q({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:N=>{const H=N.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),l=u?.syncPhase==="error",{data:C}=Q({...ne(),enabled:!!c&&l}),y=C?.accounts.find(N=>N.accountId===c)?.lastError,S=u?.mailboxes.find(N=>N.fullPath==="INBOX"||N.fullPath==="Inbox"),T=u?.mailboxCountTotal??0,O=u?.mailboxCountSynced??0,P=S?.messagesTotal??0,L=S?.messagesSynced??0,b=P>0?L/P:0,p=u?.syncPhase,le=l?"failed":p==="idle"||p===void 0||p==="discovering_mailboxes"?"running":T>0?"ok":"running",B=l?"failed":!p||p==="idle"||p==="discovering_mailboxes"?"pending":p==="syncing_inbox"||p==="syncing_others"?"running":"ok",U=l?"failed":!p||p==="idle"||p==="discovering_mailboxes"||p==="syncing_inbox"?"pending":p==="syncing_others"?"running":"ok",ue=L>0||S?.phase==="complete"||p==="complete"||l,[me,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const N=setTimeout(()=>de(!0),Ke);return()=>clearTimeout(N)},[c]);const pe=!!c&&(ue||k||me);return g?e.jsx(A,{steps:M,activeStep:F.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(E,{variant:"primary",onClick:()=>{v.current=!1,w(null),h.mutate({body:{email:t,displayName:o||void 0,username:a!==t?a:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:n.host||void 0,smtpPort:n.port||void 0,smtpTls:f.tls,smtpStartTls:f.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:g})}):e.jsx(A,{steps:M,activeStep:F.sync,title:`Syncing ${t}`,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"}),pe?e.jsx(E,{variant:"primary",onClick:()=>c&&m(c),children:"Go to inbox"}):e.jsx(E,{variant:"primary",disabled:!0,icon:e.jsx($,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:h.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx($,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>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:[L.toLocaleString()," / ",P.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,b*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(_,{label:"INBOX",detail:B==="ok"?`${L.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||p==="syncing_others"||p==="complete"?e.jsx(_,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),l&&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:()=>{d.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),y&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:y})]})]})})}function st({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[n,a]=i.useState(t?"connector":"welcome"),[r,m]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),d=i.useCallback(()=>a("connector"),[]),c=i.useCallback(()=>a("address"),[]),x=i.useCallback(()=>a("microsoft-email"),[]),g=i.useCallback(()=>{t?s?.():a("welcome")},[t,s]),w=i.useCallback((u,k,l)=>{let C=te,y=se,S=!1;l&&(S=l.source!=="heuristic",C={host:l.imap.host,port:l.imap.port,security:l.imap.security},y={host:l.smtp.host,port:l.smtp.port,security:l.smtp.security}),m(T=>({...T,email:u,displayName:k,imapConfig:C,smtpConfig:y,discoveryResult:l,discovered:S,username:u})),a("servers")},[]),v=i.useCallback((u,k)=>{m(l=>({...l,imapConfig:u,smtpConfig:k}))},[]),j=i.useCallback((u,k)=>{m(l=>({...l,username:u,password:k}))},[]),f=i.useCallback(()=>a("sync"),[]),h=i.useCallback(u=>{o(u)},[o]);switch(n){case"welcome":return e.jsx(Ge,{onStart:d});case"connector":return e.jsx(Be,{onContinue:c,onMicrosoft:x,onBack:g,showBack:!t});case"microsoft-email":return e.jsx(Ue,{onBack:()=>a("connector"),onConnected:h});case"address":return e.jsx(We,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:w,onBack:()=>a("connector")});case"servers":return e.jsx(Ve,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>a("credentials"),onBack:()=>a("address"),onChange:v});case"credentials":return e.jsx(Qe,{email:r.email,username:r.username,password:r.password,onContinue:()=>a("test"),onBack:()=>a("servers"),onChange:j});case"test":return e.jsx(Xe,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:f,onBackToCredentials:()=>a("credentials"),onBackToServers:()=>a("servers")});case"sync":return e.jsx(Ye,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:h})}}export{st as O,ce as P,Ae as R,Me as a,ee as g,G as s,Le as u};
@@ -1 +1 @@
1
- import{af as g,e as w,ar as C,j as s,b,cM as $,T as _,f as k,l as q,a0 as H,cm as U,r as x,cn as K,D as W,E as G,v as J,u as S,dy as R,cP as V,x as X,ah as Y,bC as Z,aj as v,ak as y,cF as ee,bD as se}from"./index-DcpmB860.js";import{u as te,p as ne,R as j,e as ae}from"./useSearchTokenContext-DLYexShk.js";import{C as D}from"./circle-check-big-KaEG9_dE.js";import{C as I}from"./clock-D1ARyiJ3.js";import{R as oe}from"./row-actions-3glmdUYW.js";import{R as re}from"./rotate-ccw-CGgdRHif.js";import{N as T}from"./NavMenuButton-D8BMeF0o.js";import{a as p,t as ie}from"./format-BTjE7yjC.js";import{i as le,s as A}from"./outbox-status-BlKn6P0x.js";import{n as ce}from"./search-query-Cr_ZXBCp.js";import{c as de}from"./useMessageBodyContent-BR7wdj9-.js";const ue={queued:{icon:I,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:D,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}};function O({status:e,iconOnly:n,className:a}){const t=ue[e],o=t.icon;return s.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[s.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const xe=(e,n)=>n?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"||e==="unfiled"?"bg-warning/10":"";function fe({recipients:e,subject:n,time:a,status:t,error:o,selected:l,onSelect:c,onRetry:r,retrying:d,onEdit:i,onDelete:f,deleting:u}){const m=t==="failed"||t==="blocked"||t==="unfiled";return s.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",xe(t,l)),children:[s.jsxs("button",{type:"button",...$,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(O,{status:t,iconOnly:!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:e}),s.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),s.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),s.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.jsx(O,{status:t}),o&&s.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),m&&s.jsx("div",{className:"shrink-0",children:s.jsx(oe,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:s.jsx(re,{className:"size-3.5"}),busy:d,onClick:r}]:[],...t==="unfiled"?[]:[{label:"Edit as draft",iconOnly:!0,icon:s.jsx(k,{className:"size-3.5"}),onClick:i}]],destructive:{label:"Delete message",iconOnly:!0,icon:s.jsx(_,{className:"size-3.5"}),busy:u,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:f}})})]})}function Le(){return q({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function me(){const e=H(),n=U();return x.useCallback(a=>{e({to:"/mail/outbox/draft/$outboxMessageId",params:{outboxMessageId:a},search:t=>t,hash:n})},[e,n])}function he(){return K()}function be(e,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function ge(e){return e.tokens.length>0&&e.freeText.trim().length===0}const E={queued:{icon:I,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2"},sent:{icon:D,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}},pe=e=>ie(e).toDateString()===new Date().toDateString()?p(e,{hour:"numeric",minute:"2-digit"}):p(e,{month:"short",day:"numeric"}),M=e=>p(e,{dateStyle:"medium",timeStyle:"short"}),je=e=>{const n=e.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},L=(e,n)=>n?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",P=x.createContext(null);function N(){const e=x.useContext(P);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function Ne({outboxMessageId:e,children:n}){const a=me(),t=he(),{data:o,isLoading:l}=W(G()),{searchQuery:c}=J(),r=te(),d=ce(c),i=ne(d,r),f=d.length>0,u=ge(i),m=x.useMemo(()=>u?[]:(o?.items??[]).filter(h=>le(h.status)).filter(h=>be(h,i.freeText)),[o,i.freeText,u]),z=x.useMemo(()=>m.find(h=>h.outboxMessageId===e),[m,e]),F={messages:m,hasQuery:f,unsupportedQuery:u,isLoading:l,selectedMessageId:e,selectedMessage:z,onOpenMessage:a,onCloseMessage:t};return s.jsx(P.Provider,{value:F,children:n})}function Q({message:e,isSelected:n,onSelect:a}){const t=X(),o=de(),{pushError:l}=Y(),c=x.useCallback(()=>{t.invalidateQueries({queryKey:Z()})},[t]),r=v({...ee(),onSuccess:c,onError:u=>{l(y("Couldn't resend message","The message wasn't sent.",u))}}),d=v({...se(),onSuccess:c,onError:u=>{l(y("Couldn't delete message","The message wasn't deleted.",u))}}),i=e.status;if(!E[i])return null;const f=A(e.status);return s.jsx(fe,{recipients:je(e),subject:e.subject||"",time:pe(e.sentAt??e.updatedAt),status:i,error:f?e.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:i==="failed"?()=>r.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o(e.outboxMessageId),onDelete:()=>d.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:d.isPending})}function B({message:e,onBack:n}){const a=e.status,t=E[a],o=t?.icon??k,l=e.sentAt?M(e.sentAt):M(e.updatedAt);return s.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[s.jsxs("div",{className:"border-b border-line p-4",children:[n&&s.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[s.jsx(V,{className:"size-4"}),s.jsx("span",{children:"Back"})]}),s.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),s.jsxs("div",{className:"space-y-1 text-sm",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),s.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),s.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),s.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),s.jsx("span",{className:"text-fg",children:l})]}),t&&s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(o,{className:b("size-4",t.className,a==="sending"&&"animate-spin")}),s.jsx("span",{className:b("text-xs font-medium",t.className),children:t.label}),A(e.status)&&e.lastError&&s.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),s.jsx("div",{className:"p-4",children:s.jsx(ae,{html:e.htmlBody,text:e.textBody})})]})}function ve(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onOpenMessage:l}=N(),c=x.useRef(null);return S({containerRef:c,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:L(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(T,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:e.map(r=>s.jsx(Q,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>l(r.outboxMessageId)},r.outboxMessageId))})]})}function ye(){const{selectedMessage:e}=N();return s.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[s.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?s.jsx(B,{message:e}):s.jsx(j,{message:"Select a message to read",showHints:!1})})]})}function Oe(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:l,onOpenMessage:c,onCloseMessage:r}=N(),d=x.useRef(null);return S({containerRef:d,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):l?s.jsx(B,{message:l,onBack:r}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:L(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(T,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.map(i=>s.jsx(Q,{message:i,isSelected:o===i.outboxMessageId,onSelect:()=>c(i.outboxMessageId)},i.outboxMessageId))})]})}const Pe=Object.assign(Ne,{List:ve,Reading:ye,Phone:Oe});export{Pe as O,Le as u};
1
+ import{af as g,e as w,ar as C,j as s,b,cM as $,T as _,f as k,l as q,a0 as H,cm as U,r as x,cn as K,D as W,E as G,v as J,u as S,dy as R,cP as V,x as X,ah as Y,bC as Z,aj as v,ak as y,cF as ee,bD as se}from"./index-C5WTfF4A.js";import{u as te,p as ne,R as j,e as ae}from"./useSearchTokenContext-CrFL5qdR.js";import{C as D}from"./circle-check-big-CcZaO_x-.js";import{C as I}from"./clock-BqYKa4LY.js";import{R as oe}from"./row-actions-CO2bb9oK.js";import{R as re}from"./rotate-ccw-CrFWWh3G.js";import{N as T}from"./NavMenuButton-DCzDPYUK.js";import{a as p,t as ie}from"./format-B3uyVYnZ.js";import{i as le,s as A}from"./outbox-status-BlKn6P0x.js";import{n as ce}from"./search-query-Cr_ZXBCp.js";import{c as de}from"./useMessageBodyContent-yDESgRfR.js";const ue={queued:{icon:I,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:D,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}};function O({status:e,iconOnly:n,className:a}){const t=ue[e],o=t.icon;return s.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[s.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const xe=(e,n)=>n?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"||e==="unfiled"?"bg-warning/10":"";function fe({recipients:e,subject:n,time:a,status:t,error:o,selected:l,onSelect:c,onRetry:r,retrying:d,onEdit:i,onDelete:f,deleting:u}){const m=t==="failed"||t==="blocked"||t==="unfiled";return s.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",xe(t,l)),children:[s.jsxs("button",{type:"button",...$,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(O,{status:t,iconOnly:!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:e}),s.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),s.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),s.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.jsx(O,{status:t}),o&&s.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),m&&s.jsx("div",{className:"shrink-0",children:s.jsx(oe,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:s.jsx(re,{className:"size-3.5"}),busy:d,onClick:r}]:[],...t==="unfiled"?[]:[{label:"Edit as draft",iconOnly:!0,icon:s.jsx(k,{className:"size-3.5"}),onClick:i}]],destructive:{label:"Delete message",iconOnly:!0,icon:s.jsx(_,{className:"size-3.5"}),busy:u,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:f}})})]})}function Le(){return q({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function me(){const e=H(),n=U();return x.useCallback(a=>{e({to:"/mail/outbox/draft/$outboxMessageId",params:{outboxMessageId:a},search:t=>t,hash:n})},[e,n])}function he(){return K()}function be(e,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function ge(e){return e.tokens.length>0&&e.freeText.trim().length===0}const E={queued:{icon:I,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2"},sent:{icon:D,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}},pe=e=>ie(e).toDateString()===new Date().toDateString()?p(e,{hour:"numeric",minute:"2-digit"}):p(e,{month:"short",day:"numeric"}),M=e=>p(e,{dateStyle:"medium",timeStyle:"short"}),je=e=>{const n=e.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},L=(e,n)=>n?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",P=x.createContext(null);function N(){const e=x.useContext(P);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function Ne({outboxMessageId:e,children:n}){const a=me(),t=he(),{data:o,isLoading:l}=W(G()),{searchQuery:c}=J(),r=te(),d=ce(c),i=ne(d,r),f=d.length>0,u=ge(i),m=x.useMemo(()=>u?[]:(o?.items??[]).filter(h=>le(h.status)).filter(h=>be(h,i.freeText)),[o,i.freeText,u]),z=x.useMemo(()=>m.find(h=>h.outboxMessageId===e),[m,e]),F={messages:m,hasQuery:f,unsupportedQuery:u,isLoading:l,selectedMessageId:e,selectedMessage:z,onOpenMessage:a,onCloseMessage:t};return s.jsx(P.Provider,{value:F,children:n})}function Q({message:e,isSelected:n,onSelect:a}){const t=X(),o=de(),{pushError:l}=Y(),c=x.useCallback(()=>{t.invalidateQueries({queryKey:Z()})},[t]),r=v({...ee(),onSuccess:c,onError:u=>{l(y("Couldn't resend message","The message wasn't sent.",u))}}),d=v({...se(),onSuccess:c,onError:u=>{l(y("Couldn't delete message","The message wasn't deleted.",u))}}),i=e.status;if(!E[i])return null;const f=A(e.status);return s.jsx(fe,{recipients:je(e),subject:e.subject||"",time:pe(e.sentAt??e.updatedAt),status:i,error:f?e.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:i==="failed"?()=>r.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o(e.outboxMessageId),onDelete:()=>d.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:d.isPending})}function B({message:e,onBack:n}){const a=e.status,t=E[a],o=t?.icon??k,l=e.sentAt?M(e.sentAt):M(e.updatedAt);return s.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[s.jsxs("div",{className:"border-b border-line p-4",children:[n&&s.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[s.jsx(V,{className:"size-4"}),s.jsx("span",{children:"Back"})]}),s.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),s.jsxs("div",{className:"space-y-1 text-sm",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),s.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),s.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),s.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),s.jsx("span",{className:"text-fg",children:l})]}),t&&s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(o,{className:b("size-4",t.className,a==="sending"&&"animate-spin")}),s.jsx("span",{className:b("text-xs font-medium",t.className),children:t.label}),A(e.status)&&e.lastError&&s.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),s.jsx("div",{className:"p-4",children:s.jsx(ae,{html:e.htmlBody,text:e.textBody})})]})}function ve(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onOpenMessage:l}=N(),c=x.useRef(null);return S({containerRef:c,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:L(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(T,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:e.map(r=>s.jsx(Q,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>l(r.outboxMessageId)},r.outboxMessageId))})]})}function ye(){const{selectedMessage:e}=N();return s.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[s.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?s.jsx(B,{message:e}):s.jsx(j,{message:"Select a message to read",showHints:!1})})]})}function Oe(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:l,onOpenMessage:c,onCloseMessage:r}=N(),d=x.useRef(null);return S({containerRef:d,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):l?s.jsx(B,{message:l,onBack:r}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:L(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(T,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.map(i=>s.jsx(Q,{message:i,isSelected:o===i.outboxMessageId,onSelect:()=>c(i.outboxMessageId)},i.outboxMessageId))})]})}const Pe=Object.assign(Ne,{List:ve,Reading:ye,Phone:Oe});export{Pe as O,Le as u};
@@ -0,0 +1 @@
1
+ import{a7 as m,j as o,a4 as p}from"./index-C5WTfF4A.js";import{a}from"./MailShell-DdiQTKjw.js";import{M as r}from"./MailboxPane-DPXlleMN.js";import{g as e}from"./search-token-index-BpY-q8ZV.js";import{u as s}from"./search-mirror-8yIdpqZ4.js";import"./FullCompose-BoG12Gnw.js";import"./ErrorState-DxtMMIPM.js";import"./index-C8DX_EQn.js";import"./useMessageBodyContent-yDESgRfR.js";import"./useSignature-D7z3ao3j.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CxejlkZq.js";import"./confirm-dialog-DwQkoRYj.js";import"./useSearchTokenContext-CrFL5qdR.js";import"./kbd-B62acStO.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-DQLj8qF7.js";import"./circle-check-big-CcZaO_x-.js";import"./MailListHeader-BvUp2YAz.js";import"./attachment-file-7SlOQtaK.js";import"./mail-7swSEn2S.js";import"./avatar-Dx2nnu8-.js";import"./format-B3uyVYnZ.js";import"./download-DBrnYKAw.js";import"./shield-check-CK0lIMjR.js";import"./useFilters-ClTpCTul.js";import"./clock-BqYKa4LY.js";import"./menu-DGvf1N4B.js";import"./MailViewChrome-CV4Xw32m.js";import"./NavMenuButton-DCzDPYUK.js";import"./useLabels-Jy2JcPrZ.js";import"./useSemanticSearch-RVZNROuq.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-B9BJ1XTT.js";import"./circle-help-Bl00srtt.js";import"./circle-check-4_VJQKru.js";function N(){const{mailboxId:t}=m.useParams(),i=e();return s({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{N as component};
@@ -0,0 +1 @@
1
+ import{j as r}from"./index-C5WTfF4A.js";import{B as o}from"./BriefPane-DyTCfE7R.js";import"./useSearchTokenContext-CrFL5qdR.js";import"./kbd-B62acStO.js";import"./useMessageBodyContent-yDESgRfR.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-BvUp2YAz.js";import"./search-token-index-BpY-q8ZV.js";import"./attachment-file-7SlOQtaK.js";import"./mail-7swSEn2S.js";import"./avatar-Dx2nnu8-.js";import"./index-C8DX_EQn.js";import"./useSignature-D7z3ao3j.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CxejlkZq.js";import"./ErrorState-DxtMMIPM.js";import"./format-B3uyVYnZ.js";import"./download-DBrnYKAw.js";import"./shield-check-CK0lIMjR.js";import"./useFilters-ClTpCTul.js";import"./confirm-dialog-DwQkoRYj.js";import"./clock-BqYKa4LY.js";import"./menu-DGvf1N4B.js";import"./useRefreshControl-DQLj8qF7.js";import"./circle-check-big-CcZaO_x-.js";import"./useLabels-Jy2JcPrZ.js";import"./useSemanticSearch-RVZNROuq.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function A(){return r.jsx(o.Reading,{})}export{A as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-C5WTfF4A.js";import{M as r}from"./MailboxPane-DPXlleMN.js";import"./useSearchTokenContext-CrFL5qdR.js";import"./kbd-B62acStO.js";import"./useMessageBodyContent-yDESgRfR.js";import"./search-scope-DTcpOp3S.js";import"./useRefreshControl-DQLj8qF7.js";import"./circle-check-big-CcZaO_x-.js";import"./search-token-index-BpY-q8ZV.js";import"./MailListHeader-BvUp2YAz.js";import"./attachment-file-7SlOQtaK.js";import"./mail-7swSEn2S.js";import"./avatar-Dx2nnu8-.js";import"./index-C8DX_EQn.js";import"./useSignature-D7z3ao3j.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CxejlkZq.js";import"./ErrorState-DxtMMIPM.js";import"./format-B3uyVYnZ.js";import"./download-DBrnYKAw.js";import"./shield-check-CK0lIMjR.js";import"./useFilters-ClTpCTul.js";import"./confirm-dialog-DwQkoRYj.js";import"./clock-BqYKa4LY.js";import"./menu-DGvf1N4B.js";import"./MailViewChrome-CV4Xw32m.js";import"./NavMenuButton-DCzDPYUK.js";import"./useLabels-Jy2JcPrZ.js";import"./useSemanticSearch-RVZNROuq.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-B9BJ1XTT.js";import"./circle-help-Bl00srtt.js";import"./circle-check-4_VJQKru.js";function G(){return o.jsx(r.Reading,{})}export{G as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-C5WTfF4A.js";import{F as r}from"./FlaggedPane-DRj5zl39.js";import"./useSearchTokenContext-CrFL5qdR.js";import"./kbd-B62acStO.js";import"./useMessageBodyContent-yDESgRfR.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-BvUp2YAz.js";import"./search-token-index-BpY-q8ZV.js";import"./attachment-file-7SlOQtaK.js";import"./mail-7swSEn2S.js";import"./avatar-Dx2nnu8-.js";import"./index-C8DX_EQn.js";import"./useSignature-D7z3ao3j.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-CxejlkZq.js";import"./ErrorState-DxtMMIPM.js";import"./format-B3uyVYnZ.js";import"./download-DBrnYKAw.js";import"./shield-check-CK0lIMjR.js";import"./useFilters-ClTpCTul.js";import"./confirm-dialog-DwQkoRYj.js";import"./clock-BqYKa4LY.js";import"./menu-DGvf1N4B.js";import"./MailViewChrome-CV4Xw32m.js";import"./wizard-selection-B1bng5Jq.js";function v(){return o.jsx(r.Reading,{})}export{v as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-C5WTfF4A.js";import{O as t}from"./OutboxPane-Drq27E5R.js";import"./useSearchTokenContext-CrFL5qdR.js";import"./kbd-B62acStO.js";import"./useMessageBodyContent-yDESgRfR.js";import"./search-scope-DTcpOp3S.js";import"./circle-check-big-CcZaO_x-.js";import"./clock-BqYKa4LY.js";import"./row-actions-CO2bb9oK.js";import"./rotate-ccw-CrFWWh3G.js";import"./NavMenuButton-DCzDPYUK.js";import"./menu-DGvf1N4B.js";import"./format-B3uyVYnZ.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function P(){return o.jsx(t.Reading,{})}export{P as component};
@@ -0,0 +1 @@
1
+ import{a4 as o}from"./index-C5WTfF4A.js";const n=o;export{n as component};
@@ -0,0 +1 @@
1
+ import{a4 as o}from"./index-C5WTfF4A.js";const n=o;export{n as component};